From c93ed344fbd26a9c2c49bdbc99014d8dc0cbe9ef Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 15 Oct 2014 07:19:47 +0000 Subject: Cleanups and version bump --- hash/a7800.xml | 6 +- hash/amiga_a3000.xml | 8 +- hash/amiga_hardware.xml | 22 +- hash/coleco.xml | 12 +- hash/fm7_disk.xml | 2 +- hash/fmtowns_cd.xml | 4 +- hash/gamegear.xml | 14 +- hash/gameking.xml | 32 +- hash/gbcolor.xml | 2 +- hash/intvecs.xml | 2 +- hash/msx1_cart.xml | 22 +- hash/nes.xml | 2 +- hash/pencil2.xml | 4 +- hash/psx.xml | 22 +- hash/timex_dock.xml | 2 +- src/emu/bus/a2bus/a2corvus.c | 2 +- src/emu/bus/a2bus/a2lang.c | 2 +- src/emu/bus/a2bus/corvfdc01.c | 17 +- src/emu/bus/a2bus/corvfdc02.c | 38 +- src/emu/bus/a2bus/corvfdc02.h | 2 +- src/emu/bus/a2bus/laser128.c | 6 +- src/emu/bus/a2bus/mouse.c | 136 +- src/emu/bus/a2bus/timemasterho.c | 43 +- src/emu/bus/a7800/a78_carts.h | 8 +- src/emu/bus/a7800/a78_slot.c | 86 +- src/emu/bus/a7800/a78_slot.h | 32 +- src/emu/bus/a7800/cpuwiz.c | 20 +- src/emu/bus/a7800/cpuwiz.h | 14 +- src/emu/bus/a7800/hiscore.c | 3 +- src/emu/bus/a7800/hiscore.h | 4 +- src/emu/bus/a7800/rom.c | 51 +- src/emu/bus/a7800/rom.h | 54 +- src/emu/bus/a7800/xboard.c | 30 +- src/emu/bus/a7800/xboard.h | 10 +- src/emu/bus/a800/a800_carts.h | 6 +- src/emu/bus/a800/a800_slot.c | 53 +- src/emu/bus/a800/a800_slot.h | 18 +- src/emu/bus/a800/oss.c | 31 +- src/emu/bus/a800/oss.h | 16 +- src/emu/bus/a800/rom.c | 89 +- src/emu/bus/a800/rom.h | 50 +- src/emu/bus/a800/sparta.c | 15 +- src/emu/bus/a800/sparta.h | 6 +- src/emu/bus/apf/rom.h | 2 +- src/emu/bus/apf/slot.c | 6 +- src/emu/bus/apf/slot.h | 7 +- src/emu/bus/arcadia/slot.c | 3 +- src/emu/bus/arcadia/slot.h | 3 +- src/emu/bus/c64/dela_ep256.c | 2 +- src/emu/bus/c64/rex_ep256.h | 2 +- src/emu/bus/centronics/digiblst.h | 8 +- src/emu/bus/chanf/rom.c | 11 +- src/emu/bus/chanf/rom.h | 26 +- src/emu/bus/chanf/slot.c | 14 +- src/emu/bus/chanf/slot.h | 7 +- src/emu/bus/cpc/amdrum.h | 2 +- src/emu/bus/cpc/symbfac2.c | 50 +- src/emu/bus/cpc/symbfac2.h | 2 +- src/emu/bus/crvision/rom.c | 2 +- src/emu/bus/crvision/rom.h | 10 +- src/emu/bus/crvision/slot.c | 5 +- src/emu/bus/crvision/slot.h | 3 +- src/emu/bus/gameboy/gb_slot.h | 8 +- src/emu/bus/gameboy/mbc.h | 4 +- src/emu/bus/gba/gba_slot.h | 6 +- src/emu/bus/generic/carts.c | 4 +- src/emu/bus/generic/ram.c | 15 +- src/emu/bus/generic/ram.h | 12 +- src/emu/bus/generic/rom.c | 9 +- src/emu/bus/generic/rom.h | 8 +- src/emu/bus/generic/slot.c | 21 +- src/emu/bus/generic/slot.h | 10 +- src/emu/bus/intv/ecs.c | 55 +- src/emu/bus/intv/ecs.h | 42 +- src/emu/bus/intv/rom.c | 1 - src/emu/bus/intv/rom.h | 8 +- src/emu/bus/intv/slot.c | 83 +- src/emu/bus/intv/slot.h | 13 +- src/emu/bus/intv/voice.h | 24 +- src/emu/bus/isa/sb16.c | 12 +- src/emu/bus/isa/svga_trident.c | 4 +- src/emu/bus/isa/trident.c | 120 +- src/emu/bus/megadrive/ggenie.c | 26 +- src/emu/bus/msx_cart/disk.c | 3 +- src/emu/bus/msx_slot/disk.c | 3 +- src/emu/bus/nes/disksys.c | 79 +- src/emu/bus/nes/nes_slot.c | 20 +- src/emu/bus/nes/nes_slot.h | 4 +- src/emu/bus/odyssey2/chess.h | 5 +- src/emu/bus/odyssey2/rom.c | 5 +- src/emu/bus/odyssey2/rom.h | 12 +- src/emu/bus/odyssey2/slot.c | 5 +- src/emu/bus/odyssey2/slot.h | 5 +- src/emu/bus/odyssey2/voice.c | 2 +- src/emu/bus/odyssey2/voice.h | 2 +- src/emu/bus/pet/cb2snd.c | 1 - src/emu/bus/rs232/xvd701.c | 4 +- src/emu/bus/saturn/sat_slot.c | 6 +- src/emu/bus/scv/rom.h | 16 +- src/emu/bus/scv/slot.c | 5 +- src/emu/bus/scv/slot.h | 7 +- src/emu/bus/sega8/ccatch.c | 4 +- src/emu/bus/sega8/mgear.h | 4 +- src/emu/bus/sega8/rom.c | 2 +- src/emu/bus/sega8/sega8_slot.c | 1 - src/emu/bus/sega8/sega8_slot.h | 2 +- src/emu/bus/sms_ctrl/graphic.c | 21 +- src/emu/bus/snes/snes_slot.h | 6 +- src/emu/bus/vboy/rom.h | 4 +- src/emu/bus/vboy/slot.c | 6 +- src/emu/bus/vboy/slot.h | 7 +- src/emu/bus/vc4000/rom.c | 106 +- src/emu/bus/vc4000/rom.h | 4 +- src/emu/bus/vc4000/slot.c | 8 +- src/emu/bus/vc4000/slot.h | 7 +- src/emu/bus/vcs/compumat.c | 4 +- src/emu/bus/vcs/compumat.h | 4 +- src/emu/bus/vcs/dpc.c | 11 +- src/emu/bus/vcs/dpc.h | 8 +- src/emu/bus/vcs/rom.c | 131 +- src/emu/bus/vcs/rom.h | 76 +- src/emu/bus/vcs/scharger.c | 38 +- src/emu/bus/vcs/scharger.h | 6 +- src/emu/bus/vcs/vcs_slot.c | 86 +- src/emu/bus/vcs/vcs_slot.h | 6 +- src/emu/bus/vectrex/rom.h | 6 +- src/emu/bus/vectrex/slot.c | 24 +- src/emu/bus/vectrex/slot.h | 3 +- src/emu/bus/vic20/fe3.c | 48 +- src/emu/bus/vic20/fe3.h | 2 +- src/emu/bus/wswan/rom.c | 108 +- src/emu/bus/wswan/rom.h | 8 +- src/emu/bus/wswan/slot.c | 28 +- src/emu/bus/wswan/slot.h | 7 +- src/emu/cpu/dsp56k/dsp56k.c | 9 +- src/emu/cpu/hd61700/hd61700.c | 2 +- src/emu/cpu/hd61700/hd61700.h | 4 +- src/emu/cpu/i86/i186.c | 8 +- src/emu/cpu/mcs96/mcs96.c | 8 +- src/emu/cpu/mips/mips3drc.c | 2 +- src/emu/cpu/rsp/rsp.c | 52 +- src/emu/cpu/rsp/rspdrc.c | 1 - src/emu/cpu/sh4/sh4.c | 4 +- src/emu/cpu/tlcs90/tlcs90.c | 90 +- src/emu/cpu/tms32031/tms32031.h | 2 +- src/emu/cpu/tms32051/tms32051.c | 4 +- src/emu/cpu/tms32051/tms32051.h | 2 +- src/emu/cpu/tms34010/tms34010.c | 4 +- src/emu/cpu/tms34010/tms34010.h | 34 +- src/emu/cpu/tms7000/tms7000.c | 4 +- src/emu/cpu/tms7000/tms7000.h | 2 +- src/emu/debug/debugcpu.c | 2 +- src/emu/devcpu.c | 1 - src/emu/diimage.c | 6 +- src/emu/imagedev/floppy.c | 2 +- src/emu/machine.c | 2 +- src/emu/machine/mb8421.c | 6 +- src/emu/machine/pit8253.c | 2 +- src/emu/machine/rp5h01.c | 2 +- src/emu/machine/smpc.c | 2 +- src/emu/machine/wozfdc.c | 6 +- src/emu/sound/flt_rc.h | 10 +- src/emu/sound/k053260.c | 4 +- src/emu/sound/k053260.h | 2 +- src/emu/sound/samples.c | 2 +- src/emu/sound/samples.h | 6 +- src/emu/sound/speaker.h | 4 +- src/emu/sound/ymf278b.c | 2 +- src/emu/sound/zsg2.c | 2 +- src/emu/ui/swlist.c | 2 +- src/emu/ui/ui.c | 4 +- src/emu/video/315_5124.c | 2 +- src/emu/video/epic12.c | 2 +- src/emu/video/upd7220.c | 2 +- src/emu/video/vooddefs.h | 18 +- src/emu/video/voodoo.c | 4 +- src/emu/webengine.c | 222 +- src/lib/formats/ap2_dsk.c | 4 +- src/lib/formats/dmk_dsk.c | 1 - src/lib/formats/dmk_dsk.h | 1 - src/lib/formats/mfi_dsk.c | 4 +- src/lib/web/mongoose.c | 7301 +++++++++++++++--------------- src/lib/web/mongoose.h | 104 +- src/mame/audio/cclimber.h | 4 +- src/mame/audio/leland.c | 6 +- src/mame/audio/mario.c | 1 - src/mame/drivers/20pacgal.c | 2 +- src/mame/drivers/4enraya.c | 14 +- src/mame/drivers/8080bw.c | 6 +- src/mame/drivers/aces1.c | 18 +- src/mame/drivers/alg.c | 24 +- src/mame/drivers/aristmk4.c | 2 +- src/mame/drivers/arkanoid.c | 10 +- src/mame/drivers/atarisy4.c | 16 +- src/mame/drivers/bartop52.c | 2 +- src/mame/drivers/battlera.c | 2 +- src/mame/drivers/bfm_sc1.c | 2 +- src/mame/drivers/bfm_sc2.c | 6 +- src/mame/drivers/bmcpokr.c | 76 +- src/mame/drivers/btoads.c | 2 +- src/mame/drivers/bublbobl.c | 2 +- src/mame/drivers/calchase.c | 19 +- src/mame/drivers/capr1.c | 18 +- src/mame/drivers/caprcyc.c | 6 +- src/mame/drivers/centiped.c | 16 +- src/mame/drivers/chqflag.c | 2 +- src/mame/drivers/coinmvga.c | 2 +- src/mame/drivers/coolpool.c | 2 +- src/mame/drivers/cops.c | 62 +- src/mame/drivers/cps1.c | 42 +- src/mame/drivers/cv1k.c | 8 +- src/mame/drivers/dkong.c | 4 +- src/mame/drivers/dlair.c | 2 +- src/mame/drivers/dlair2.c | 2 +- src/mame/drivers/dragrace.c | 2 +- src/mame/drivers/fcrash.c | 12 +- src/mame/drivers/foodf.c | 8 +- src/mame/drivers/fuukifg2.c | 2 +- src/mame/drivers/gaiden.c | 2 +- src/mame/drivers/galaxian.c | 8 +- src/mame/drivers/galpani3.c | 6 +- src/mame/drivers/galpanic.c | 2 +- src/mame/drivers/hikaru.c | 64 +- src/mame/drivers/igs011.c | 6 +- src/mame/drivers/igs017.c | 34 +- src/mame/drivers/iqblock.c | 6 +- src/mame/drivers/itech32.c | 28 +- src/mame/drivers/jchan.c | 2 +- src/mame/drivers/jclub2.c | 2 +- src/mame/drivers/jeutel.c | 2 +- src/mame/drivers/karnov.c | 8 +- src/mame/drivers/legionna.c | 14 +- src/mame/drivers/ltd.c | 2 +- src/mame/drivers/macs.c | 4 +- src/mame/drivers/mario.c | 22 +- src/mame/drivers/maxaflex.c | 4 +- src/mame/drivers/mazerbla.c | 2 +- src/mame/drivers/megatech.c | 18 +- src/mame/drivers/metro.c | 12 +- src/mame/drivers/mgavegas.c | 276 +- src/mame/drivers/midtunit.c | 2 +- src/mame/drivers/midwunit.c | 2 +- src/mame/drivers/midxunit.c | 2 +- src/mame/drivers/midyunit.c | 4 +- src/mame/drivers/model1.c | 4 +- src/mame/drivers/model3.c | 28 +- src/mame/drivers/mpu5hw.c | 38 +- src/mame/drivers/namcops2.c | 16 +- src/mame/drivers/namcos21.c | 2 +- src/mame/drivers/naomi.c | 30 +- src/mame/drivers/nmk16.c | 139 +- src/mame/drivers/pacman.c | 10 +- src/mame/drivers/peplus.c | 12 +- src/mame/drivers/potgoldu.c | 6 +- src/mame/drivers/punchout.c | 20 +- src/mame/drivers/r2dx_v33.c | 68 +- src/mame/drivers/raiden2.c | 20 +- src/mame/drivers/rainbow.c | 4 +- src/mame/drivers/rastersp.c | 2 +- src/mame/drivers/redclash.c | 2 +- src/mame/drivers/segac2.c | 2 +- src/mame/drivers/segas18.c | 2 +- src/mame/drivers/segas32.c | 40 +- src/mame/drivers/segaybd.c | 4 +- src/mame/drivers/simple_st0016.c | 4 +- src/mame/drivers/skimaxx.c | 10 +- src/mame/drivers/snesb.c | 66 +- src/mame/drivers/snk6502.c | 2 +- src/mame/drivers/snowbros.c | 2 +- src/mame/drivers/speedbal.c | 30 +- src/mame/drivers/speglsht.c | 2 +- src/mame/drivers/splash.c | 64 +- src/mame/drivers/srmp5.c | 8 +- src/mame/drivers/st_mp100.c | 2 +- src/mame/drivers/stv.c | 10 +- src/mame/drivers/system16.c | 4 +- src/mame/drivers/taito_z.c | 18 +- src/mame/drivers/tatsumi.c | 2 +- src/mame/drivers/tickee.c | 16 +- src/mame/drivers/travrusa.c | 1 - src/mame/drivers/twinkle.c | 4 +- src/mame/drivers/vamphalf.c | 6 +- src/mame/drivers/vectrex.c | 2 +- src/mame/drivers/warpsped.c | 4 +- src/mame/drivers/xtheball.c | 2 +- src/mame/includes/8080bw.h | 2 +- src/mame/includes/artmagic.h | 8 +- src/mame/includes/bfm_sc45.h | 2 +- src/mame/includes/cinemat.h | 4 +- src/mame/includes/coolpool.h | 4 +- src/mame/includes/cosmic.h | 4 +- src/mame/includes/exterm.h | 4 +- src/mame/includes/fuukifg2.h | 2 +- src/mame/includes/fuukifg3.h | 2 +- src/mame/includes/harddriv.h | 12 +- src/mame/includes/jpmimpct.h | 4 +- src/mame/includes/konamigx.h | 2 +- src/mame/includes/legionna.h | 4 +- src/mame/includes/meadows.h | 4 +- src/mame/includes/micro3d.h | 4 +- src/mame/includes/midtunit.h | 2 +- src/mame/includes/midyunit.h | 4 +- src/mame/includes/model1.h | 4 +- src/mame/includes/model3.h | 4 +- src/mame/includes/namcos2.h | 2 +- src/mame/includes/polyplay.h | 6 +- src/mame/includes/raiden2.h | 50 +- src/mame/includes/simple_st0016.h | 2 +- src/mame/includes/snk.h | 8 +- src/mame/includes/splash.h | 2 +- src/mame/includes/sslam.h | 4 +- src/mame/includes/stv.h | 2 +- src/mame/includes/suna8.h | 2 +- src/mame/includes/suprnova.h | 4 +- src/mame/includes/taito_f3.h | 6 +- src/mame/includes/tatsumi.h | 4 +- src/mame/includes/thepit.h | 4 +- src/mame/includes/tnzs.h | 4 +- src/mame/includes/vectrex.h | 2 +- src/mame/layout/mgavegas.lay | 64 +- src/mame/layout/s11a.lay | 2 +- src/mame/machine/315_5296.c | 28 +- src/mame/machine/amiga.c | 2 +- src/mame/machine/asic65.c | 2 +- src/mame/machine/atari.c | 2 +- src/mame/machine/awboard.h | 4 +- src/mame/machine/inder_vid.c | 2 +- src/mame/machine/inder_vid.h | 4 +- src/mame/machine/kaneko_calc3.h | 6 +- src/mame/machine/kaneko_toybox.h | 4 +- src/mame/machine/konppc.c | 2 +- src/mame/machine/model1.c | 96 +- src/mame/machine/nmk004.c | 2 +- src/mame/machine/raiden2cop.c | 143 +- src/mame/machine/raiden2cop.h | 7 +- src/mame/machine/seicop.c | 12 +- src/mame/machine/seicop.h | 1 - src/mame/machine/st0016.c | 53 +- src/mame/machine/st0016.h | 2 +- src/mame/machine/vectrex.c | 4 +- src/mame/mame.lst | 72 +- src/mame/mame.mak | 2 +- src/mame/video/antic.c | 131 +- src/mame/video/antic.h | 24 +- src/mame/video/battlera.c | 1 - src/mame/video/decmxc06.h | 2 +- src/mame/video/dooyong.c | 5 +- src/mame/video/fuukifg.c | 6 +- src/mame/video/fuukifg.h | 7 +- src/mame/video/fuukifg3.c | 4 +- src/mame/video/gtia.c | 14 +- src/mame/video/gtia.h | 24 +- src/mame/video/k054156_k054157_k056832.c | 2 +- src/mame/video/legionna.c | 15 +- src/mame/video/mario.c | 7 +- src/mame/video/model3.c | 676 +-- src/mame/video/seibuspi.c | 4 +- src/mame/video/sknsspr.h | 2 +- src/mame/video/skyfox.c | 2 +- src/mame/video/snk.c | 2 +- src/mame/video/taito_f3.c | 2 +- src/mame/video/tc0480scp.c | 2 +- src/mess/audio/vc4000snd.h | 8 +- src/mess/audio/wswan_snd.h | 12 +- src/mess/drivers/a2600.c | 6 +- src/mess/drivers/a7800.c | 26 +- src/mess/drivers/aim65.c | 2 +- src/mess/drivers/apf.c | 4 +- src/mess/drivers/apple2.c | 38 +- src/mess/drivers/apple2gs.c | 2 +- src/mess/drivers/apple3.c | 2 +- src/mess/drivers/atari400.c | 114 +- src/mess/drivers/atarist.c | 4 +- src/mess/drivers/atom.c | 8 +- src/mess/drivers/bbcbc.c | 2 +- src/mess/drivers/beta.c | 22 +- src/mess/drivers/casloopy.c | 8 +- src/mess/drivers/cc40.c | 14 +- src/mess/drivers/cgenie.c | 8 +- src/mess/drivers/channelf.c | 2 +- src/mess/drivers/concept.c | 4 +- src/mess/drivers/crvision.c | 4 +- src/mess/drivers/electron.c | 2 +- src/mess/drivers/ep64.c | 2 +- src/mess/drivers/exelv.c | 6 +- src/mess/drivers/fc100.c | 2 +- src/mess/drivers/fm7.c | 196 +- src/mess/drivers/gameking.c | 8 +- src/mess/drivers/gamepock.c | 2 +- src/mess/drivers/gba.c | 2 +- src/mess/drivers/geniusiq.c | 4 +- src/mess/drivers/gmaster.c | 2 +- src/mess/drivers/ibmpcjr.c | 2 +- src/mess/drivers/intv.c | 22 +- src/mess/drivers/itt3030.c | 46 +- src/mess/drivers/kyocera.c | 12 +- src/mess/drivers/laser3k.c | 162 +- src/mess/drivers/m5.c | 2 +- src/mess/drivers/msx.c | 43 +- src/mess/drivers/myvision.c | 8 +- src/mess/drivers/nc.c | 6 +- src/mess/drivers/nes.c | 20 +- src/mess/drivers/ngp.c | 14 +- src/mess/drivers/pc2000.c | 6 +- src/mess/drivers/pc6001.c | 16 +- src/mess/drivers/pc8401a.c | 2 +- src/mess/drivers/pc9801.c | 16 +- src/mess/drivers/pegasus.c | 16 +- src/mess/drivers/pencil2.c | 2 +- src/mess/drivers/pet.c | 4 +- src/mess/drivers/pockstat.c | 2 +- src/mess/drivers/pokemini.c | 6 +- src/mess/drivers/pt68k4.c | 34 +- src/mess/drivers/pv1000.c | 12 +- src/mess/drivers/pv2000.c | 10 +- src/mess/drivers/rx78.c | 12 +- src/mess/drivers/scv.c | 6 +- src/mess/drivers/socrates.c | 4 +- src/mess/drivers/sorcerer.c | 4 +- src/mess/drivers/spc1000.c | 48 +- src/mess/drivers/specpls3.c | 22 +- src/mess/drivers/spectrum.c | 8 +- src/mess/drivers/studio2.c | 36 +- src/mess/drivers/supracan.c | 8 +- src/mess/drivers/sv8000.c | 10 +- src/mess/drivers/svision.c | 8 +- src/mess/drivers/thomson.c | 2 +- src/mess/drivers/ti74.c | 32 +- src/mess/drivers/timex.c | 14 +- src/mess/drivers/tsispch.c | 6 +- src/mess/drivers/tutor.c | 6 +- src/mess/drivers/tvc.c | 12 +- src/mess/drivers/uzebox.c | 2 +- src/mess/drivers/vboy.c | 4 +- src/mess/drivers/vc4000.c | 30 +- src/mess/drivers/vii.c | 30 +- src/mess/drivers/x07.c | 6 +- src/mess/includes/apple2.h | 4 +- src/mess/includes/atom.h | 10 +- src/mess/includes/concept.h | 2 +- src/mess/includes/electron.h | 4 +- src/mess/includes/intv.h | 4 +- src/mess/includes/radio86.h | 2 +- src/mess/includes/svi318.h | 18 +- src/mess/machine/aim65.c | 2 +- src/mess/machine/amigakbd.c | 28 +- src/mess/machine/amstrad.c | 12 +- src/mess/machine/apple2.c | 8 +- src/mess/machine/apple3.c | 1 - src/mess/machine/bbc.c | 26 +- src/mess/machine/concept.c | 8 +- src/mess/machine/electron.c | 10 +- src/mess/machine/gamecom.c | 8 +- src/mess/machine/gamepock.c | 2 +- src/mess/machine/intv.c | 8 +- src/mess/machine/lynx.c | 17 +- src/mess/machine/nc.c | 11 +- src/mess/machine/nes.c | 2 +- src/mess/machine/primo.c | 2 +- src/mess/machine/svi318.c | 16 +- src/mess/machine/thomson.c | 8 +- src/mess/machine/vtech2.c | 12 +- src/mess/machine/wswan.c | 38 +- src/mess/mess.mak | 16 +- src/mess/tiny.lst | 2 +- src/mess/tools/imgtool/modules/amiga.c | 6 +- src/mess/video/advision.c | 2 +- src/mess/video/apple2.c | 14 +- src/mess/video/apple3.c | 2 +- src/mess/video/maria.c | 28 +- src/mess/video/maria.h | 10 +- src/mess/video/nes.c | 4 +- src/mess/video/thomson.c | 44 +- src/osd/sdl/osdsdl.h | 2 +- src/osd/sdl/sdlfile.c | 2 +- src/osd/sdl/sdlptty_win32.c | 1 - src/osd/sdl/sdlsocket.c | 2 +- src/osd/sdl/sdlsync_win32.c | 2 +- src/osd/sdl/video.c | 2 +- src/osd/windows/vconv.c | 2 +- src/osd/windows/video.c | 10 +- src/osd/windows/video.h | 6 +- src/osd/windows/window.c | 12 +- src/osd/windows/window.h | 4 +- src/osd/windows/winos.c | 2 +- src/osd/windows/winos.h | 2 +- src/osd/windows/winsync.c | 2 +- src/osd/windows/winsync.h | 2 +- src/version.c | 2 +- 489 files changed, 7744 insertions(+), 7847 deletions(-) diff --git a/hash/a7800.xml b/hash/a7800.xml index 8234a34d5dd..8539b816d36 100644 --- a/hash/a7800.xml +++ b/hash/a7800.xml @@ -1318,8 +1318,8 @@ the buttons not work in emulators. @@ -2369,7 +2369,7 @@ almost nothing like the prototype. diff --git a/hash/amiga_a3000.xml b/hash/amiga_a3000.xml index 932381fc1e0..3b066cc6ebd 100644 --- a/hash/amiga_a3000.xml +++ b/hash/amiga_a3000.xml @@ -31,9 +31,9 @@ - + - + A3000 Install Disk 2.03 1991 @@ -44,11 +44,11 @@ - + - + UNIX System V Release 4 Amiga Version 1.1 1990 diff --git a/hash/amiga_hardware.xml b/hash/amiga_hardware.xml index 984a9054921..7f5416bccfe 100644 --- a/hash/amiga_hardware.xml +++ b/hash/amiga_hardware.xml @@ -12,7 +12,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -138,7 +138,7 @@ - + diff --git a/hash/coleco.xml b/hash/coleco.xml index a1bf7ccee63..011b4fec841 100644 --- a/hash/coleco.xml +++ b/hash/coleco.xml @@ -437,7 +437,7 @@ - + Choplifter! 1984 Coleco / CBS @@ -699,7 +699,7 @@ - + @@ -2262,7 +2262,7 @@ - + @@ -2369,9 +2369,9 @@ - + Zaxxon (Taiwan Cooper) 198? Taiwan Cooper diff --git a/hash/fm7_disk.xml b/hash/fm7_disk.xml index 0c6918f409e..f75a5b179a4 100644 --- a/hash/fm7_disk.xml +++ b/hash/fm7_disk.xml @@ -1657,7 +1657,7 @@ Titles, serial #s, publishers and release dates taken from: - + M-DOS7 Volume 9 19?? diff --git a/hash/fmtowns_cd.xml b/hash/fmtowns_cd.xml index e2fc0a5f96c..f6d18346620 100644 --- a/hash/fmtowns_cd.xml +++ b/hash/fmtowns_cd.xml @@ -2,8 +2,8 @@ - - + + Raiden Densetsu / Raiden Trad 1991 diff --git a/hash/gamegear.xml b/hash/gamegear.xml index b99fe8e7104..805b3957d50 100644 --- a/hash/gamegear.xml +++ b/hash/gamegear.xml @@ -768,9 +768,9 @@ A few games have been listed as rumored, but they might very well be fake (pleas Beavis and Butt-head (Prototype?) @@ -7285,7 +7285,7 @@ a certain item) --> - + Sonic Labyrinth (World) 1995 Sega @@ -7594,7 +7594,7 @@ a certain item) --> - + Sonic The Hedgehog 2 (Rolling Demo) 1992 Sega @@ -7609,7 +7609,7 @@ a certain item) --> - + @@ -8634,7 +8634,7 @@ a certain item) --> - + Tails Adventures (World) 1995 Sega diff --git a/hash/gameking.xml b/hash/gameking.xml index b3335de0509..0764a60e97a 100644 --- a/hash/gameking.xml +++ b/hash/gameking.xml @@ -4,7 +4,7 @@ - + 2004 200? @@ -25,7 +25,7 @@ - + Aries @@ -36,7 +36,7 @@ - + Dino Adventure Legend @@ -47,7 +47,7 @@ - + Duck Man @@ -58,7 +58,7 @@ - + Happy Ball @@ -69,7 +69,7 @@ - + Happy Killer @@ -80,7 +80,7 @@ - + Lanneret @@ -91,7 +91,7 @@ - + Penguin @@ -102,8 +102,8 @@ - - + + Popper 200? @@ -113,7 +113,7 @@ - + Street Hero @@ -124,8 +124,8 @@ - - + + Supermotor 200? @@ -135,7 +135,7 @@ - + Trojan Legend @@ -146,8 +146,8 @@ - + + - diff --git a/hash/gbcolor.xml b/hash/gbcolor.xml index 467b29a918f..a1aa94e5170 100644 --- a/hash/gbcolor.xml +++ b/hash/gbcolor.xml @@ -23639,7 +23639,7 @@ These were produced between 2000 and 2001 by Rocket Games, run by Datel Design * CBA078 Shuma Baolong - Diannao Pian 数码暴龙-电脑篇 * CBA079 Yingxiong Tianxia 英雄天下 * CBA080 Sanguozhi Wudai 三国志五代 - * CBA083 Tai Kong Bao Bei 太空宝贝 + * CBA083 Tai Kong Bao Bei 太空宝贝 * CBA085 Shu Ma Bao Bei - Huojian Bingtuan 数码宝贝-火箭兵团 * CBA086 Shu Ma Bao Bei - Chao Mengmeng Fanji Zhan 数码宝贝-超梦梦反击战 * CBA087 Shu Ma Bao Bei - Hai Zhi Shen 数码宝贝-海之神 diff --git a/hash/intvecs.xml b/hash/intvecs.xml index 1136c341ace..b8663df873e 100644 --- a/hash/intvecs.xml +++ b/hash/intvecs.xml @@ -100,7 +100,7 @@ - + diff --git a/hash/msx1_cart.xml b/hash/msx1_cart.xml index 1a04999d34c..c4863b1214c 100644 --- a/hash/msx1_cart.xml +++ b/hash/msx1_cart.xml @@ -14536,12 +14536,12 @@ kept for now until finding out what those bytes affect... @@ -17109,8 +17109,8 @@ legacy FM implementations cannot find it. @@ -17126,9 +17126,9 @@ legacy FM implementations cannot find it. diff --git a/hash/nes.xml b/hash/nes.xml index 5d6494e8dff..834b9152f5b 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -35601,7 +35601,7 @@ - + diff --git a/hash/pencil2.xml b/hash/pencil2.xml index 0cd0b01f526..ea5eaa46645 100644 --- a/hash/pencil2.xml +++ b/hash/pencil2.xml @@ -2,7 +2,7 @@ - - - - + + + Raiden DX (Japan, V1.1) 199? Seibu / Hamster @@ -717,8 +717,8 @@ A few comments on these: - - + + Raiden DX (Japan, V1.0) 199? Seibu @@ -729,7 +729,7 @@ A few comments on these: - + Raiden Project (USA) 199? @@ -740,9 +740,9 @@ A few comments on these: - - - + + + Raiden Project (Japan) 1995 @@ -753,8 +753,8 @@ A few comments on these: - - + + diff --git a/hash/timex_dock.xml b/hash/timex_dock.xml index 0f1f7954229..ba2eb4bce67 100644 --- a/hash/timex_dock.xml +++ b/hash/timex_dock.xml @@ -235,7 +235,7 @@ - + rWP32 19?? diff --git a/src/emu/bus/a2bus/a2corvus.c b/src/emu/bus/a2bus/a2corvus.c index 7c6351537d0..e8a91030884 100644 --- a/src/emu/bus/a2bus/a2corvus.c +++ b/src/emu/bus/a2bus/a2corvus.c @@ -32,7 +32,7 @@ 7) When the format completes, type "RUN APPLESOFT BOOT PREP" and press Enter. 8) Once it finishes, quit MESS. Remove the diskii(ng) from slot 7 and the system will boot into DOS 3.3 from the Corvus HD. - + TODO: but there are no Corvus drivers present after that, only Disk II? diff --git a/src/emu/bus/a2bus/a2lang.c b/src/emu/bus/a2bus/a2lang.c index 581ce7d9dff..1f257789e55 100644 --- a/src/emu/bus/a2bus/a2lang.c +++ b/src/emu/bus/a2bus/a2lang.c @@ -112,7 +112,7 @@ UINT8 a2bus_lang_device::read_c0nx(address_space &space, UINT8 offset) // likely to be interrupt-safe. if (state->m_machinetype == APPLE_II) { - switch (offset & 0x03) + switch (offset & 0x03) { case 1: case 3: diff --git a/src/emu/bus/a2bus/corvfdc01.c b/src/emu/bus/a2bus/corvfdc01.c index 14cb6034c62..baf1f17a2d3 100644 --- a/src/emu/bus/a2bus/corvfdc01.c +++ b/src/emu/bus/a2bus/corvfdc01.c @@ -3,10 +3,10 @@ corvfdc01.c Implemention of the Corvus Systems CORVUS01 floppy controller - + Boot PROM 0.8 fixes this at: 8", 500 blocks total, 128 bytes/block, - 26 sectors/track, 77 tracks. - + 26 sectors/track, 77 tracks. + *********************************************************************/ #include "corvfdc01.h" @@ -21,8 +21,8 @@ const device_type A2BUS_CORVFDC01 = &device_creator; -#define FDC01_ROM_REGION "fdc01_rom" -#define FDC01_FDC_TAG "fdc01_fdc" +#define FDC01_ROM_REGION "fdc01_rom" +#define FDC01_FDC_TAG "fdc01_fdc" FLOPPY_FORMATS_MEMBER( a2bus_corvfdc01_device::corv_floppy_formats ) FLOPPY_IMD_FORMAT @@ -161,7 +161,7 @@ UINT8 a2bus_corvfdc01_device::read_c0nx(address_space &space, UINT8 offset) { switch (offset) { - case 0: // local status + case 0: // local status if (m_curfloppy) { m_fdc_local_status &= ~LS_DSKCHG_mask; @@ -169,7 +169,7 @@ UINT8 a2bus_corvfdc01_device::read_c0nx(address_space &space, UINT8 offset) } return m_fdc_local_status | LS_8IN_mask; - case 8: // WD1793 at 8-11 + case 8: // WD1793 at 8-11 return m_wdfdc->status_r(space, offset); case 9: @@ -225,7 +225,7 @@ void a2bus_corvfdc01_device::write_c0nx(address_space &space, UINT8 offset, UINT if (m_curfloppy != NULL) { // side select - m_curfloppy->ss_w((data & LC_FLPSD1_mask) != 0); + m_curfloppy->ss_w((data & LC_FLPSD1_mask) != 0); // motor control (active low) m_curfloppy->mon_w((data & LC_MOTOROF_mask) ? 1 : 0); @@ -278,4 +278,3 @@ WRITE_LINE_MEMBER(a2bus_corvfdc01_device::drq_w) else m_fdc_local_status &= ~LS_DRQ_mask; } - diff --git a/src/emu/bus/a2bus/corvfdc02.c b/src/emu/bus/a2bus/corvfdc02.c index 44a27718ec5..170438073a6 100644 --- a/src/emu/bus/a2bus/corvfdc02.c +++ b/src/emu/bus/a2bus/corvfdc02.c @@ -4,10 +4,10 @@ Implemention of the Corvus Systems CORVUS02 floppy controller aka the "Buffered Floppy Controller" - + Boot PROM 0.8 says 8" SSDD or 5.25" DSDD; we stick with 5.25" here and let the FDC01 handle 8". - + *********************************************************************/ #include "corvfdc02.h" @@ -23,8 +23,8 @@ const device_type A2BUS_CORVFDC02 = &device_creator; -#define FDC02_ROM_REGION "fdc02_rom" -#define FDC02_FDC_TAG "fdc02_fdc" +#define FDC02_ROM_REGION "fdc02_rom" +#define FDC02_FDC_TAG "fdc02_fdc" FLOPPY_FORMATS_MEMBER( a2bus_corvfdc02_device::corv_floppy_formats ) FLOPPY_CONCEPT_525DSDD_FORMAT, @@ -86,7 +86,6 @@ a2bus_corvfdc02_device::a2bus_corvfdc02_device(const machine_config &mconfig, de m_con3(*this, FDC02_FDC_TAG":2"), m_con4(*this, FDC02_FDC_TAG":3") { - } a2bus_corvfdc02_device::a2bus_corvfdc02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : @@ -143,20 +142,20 @@ UINT8 a2bus_corvfdc02_device::read_c0nx(address_space &space, UINT8 offset) { switch (offset) { - case 0: // 765 FIFO + case 0: // 765 FIFO return m_fdc->fifo_r(space, 0); - case 1: // 765 MSR + case 1: // 765 MSR return m_fdc->msr_r(space, 0); - case 2: // buffer address + case 2: // buffer address return (m_bufptr>>1) & 0xff; - case 3: -// printf("Read buffer @ %x = %02x\n", m_bufptr, m_buffer[m_bufptr]); + case 3: +// printf("Read buffer @ %x = %02x\n", m_bufptr, m_buffer[m_bufptr]); return m_buffer[m_bufptr--]; - case 4: // local status + case 4: // local status if (m_curfloppy) { m_fdc_local_status &= ~(1 | 0x40); @@ -188,13 +187,13 @@ void a2bus_corvfdc02_device::write_c0nx(address_space &space, UINT8 offset, UINT case 1: // FDC ??? break; - case 2: // buffer address + case 2: // buffer address m_bufptr = (data << 1) | (data & 1); -// printf("%02x to buffer address yields %x\n", data, m_bufptr); +// printf("%02x to buffer address yields %x\n", data, m_bufptr); break; - case 3: // buffer write -// printf("%02x to buffer[%x]\n", data, m_bufptr); + case 3: // buffer write +// printf("%02x to buffer[%x]\n", data, m_bufptr); m_buffer[m_bufptr--] = data; break; @@ -233,12 +232,12 @@ void a2bus_corvfdc02_device::write_c0nx(address_space &space, UINT8 offset, UINT { // motor control (active low) m_curfloppy->mon_w((data & 8) ? 1 : 0); -// printf("Cur drive %p motor %s\n", m_curfloppy, (data & 8) ? "OFF" : "ON"); +// printf("Cur drive %p motor %s\n", m_curfloppy, (data & 8) ? "OFF" : "ON"); } if (data & 0x80) { -// printf("Reset NEC765\n"); +// printf("Reset NEC765\n"); m_fdc->reset(); } break; @@ -266,7 +265,7 @@ WRITE_LINE_MEMBER(a2bus_corvfdc02_device::intrq_w) } else { - m_fdc_local_status |= 2; // clear IRQ + m_fdc_local_status |= 2; // clear IRQ lower_slot_irq(); } } @@ -279,7 +278,7 @@ WRITE_LINE_MEMBER(a2bus_corvfdc02_device::drq_w) if (m_fdc_local_command & 0x40) { m_buffer[m_bufptr] = m_fdc->dma_r(); -// printf("DMA %02x to buffer[%x]\n", m_buffer[m_bufptr], m_bufptr); +// printf("DMA %02x to buffer[%x]\n", m_buffer[m_bufptr], m_bufptr); if (!m_bufptr) { @@ -296,4 +295,3 @@ WRITE_LINE_MEMBER(a2bus_corvfdc02_device::drq_w) } } } - diff --git a/src/emu/bus/a2bus/corvfdc02.h b/src/emu/bus/a2bus/corvfdc02.h index 83c3a4c4ed9..7b16e1c899d 100644 --- a/src/emu/bus/a2bus/corvfdc02.h +++ b/src/emu/bus/a2bus/corvfdc02.h @@ -56,7 +56,7 @@ private: UINT8 *m_rom; UINT8 m_fdc_local_status, m_fdc_local_command; UINT16 m_bufptr; - UINT8 m_buffer[2048]; // 1x6116 SRAM + UINT8 m_buffer[2048]; // 1x6116 SRAM floppy_image_device *m_curfloppy; bool m_in_drq; emu_timer *m_timer; diff --git a/src/emu/bus/a2bus/laser128.c b/src/emu/bus/a2bus/laser128.c index bc42e977305..81315311ae3 100644 --- a/src/emu/bus/a2bus/laser128.c +++ b/src/emu/bus/a2bus/laser128.c @@ -108,7 +108,7 @@ UINT8 a2bus_laser128_device::read_c800(address_space &space, UINT16 offset) { return m_slot7_ram[offset]; } - return m_rom[(offset & 0x3ff) + 0x6000 + m_slot7_bank]; + return m_rom[(offset & 0x3ff) + 0x6000 + m_slot7_bank]; } return 0xff; @@ -124,12 +124,12 @@ void a2bus_laser128_device::write_c800(address_space &space, UINT16 offset, UINT // UDCREG if ((m_slot == 7) && (offset == 0x7f8)) { -// printf("%02x to UDCREG\n", data); +// printf("%02x to UDCREG\n", data); m_slot7_ram_bank = (data & 0x8) ? 0x400 : 0; m_slot7_bank = (((data >> 4) & 0x7) * 0x400); -// printf("\tRAM bank %x, ROM bank %x\n", m_slot7_ram_bank, m_slot7_bank); +// printf("\tRAM bank %x, ROM bank %x\n", m_slot7_ram_bank, m_slot7_bank); } } diff --git a/src/emu/bus/a2bus/mouse.c b/src/emu/bus/a2bus/mouse.c index d3828e3db32..a0340174034 100644 --- a/src/emu/bus/a2bus/mouse.c +++ b/src/emu/bus/a2bus/mouse.c @@ -3,18 +3,18 @@ mouse.c Implemention of the Apple II Mouse Card - + Apple II Mouse Interface PCB - Apple 1983 + Apple 1983 - This is a mouse interface for the Apple II + This is a mouse interface for the Apple II - PCB Layout - ---------- - apple computer - MOUSE INTERFACE - 670-0030-C (C) 1983 - Printed on back side - MOUSE INTERFACE 820-0104-B (C) 1983 APPLE COMPUTER + PCB Layout + ---------- + apple computer + MOUSE INTERFACE + 670-0030-C (C) 1983 + Printed on back side - MOUSE INTERFACE 820-0104-B (C) 1983 APPLE COMPUTER |-----------------------------------| | PAL16R4 6821 | | | @@ -25,40 +25,40 @@ |-------------------| |-| |-------------| - Notes: - J1 - 9 pin flat cable with female DB9 connector - 68705P3 - Motorola MC68705P3 microcontroller (DIP28) labelled '341-0269 (C) APPLE' - PCB printed '(C) APPLE 1983 341-0269 or 342-0285' - 8516 - Fujitsu MB8516 2k x8-bit EPROM (DIP24) labelled '341-0270-C (C) APPLE 1983' - PCB printed '(C) APPLE 1983 342-0270' - PAL16R4 - MMI PAL16R4ACN (DIP20) marked '341-0268-A' - PCB printed '(C) APPLE 1983 342-0268' - 6821 - AMI 6821 Peripheral Interface Adapter (DIP40) - X1/X2 - Jumper pads. X1 is open, X2 is closed. - - + Notes: + J1 - 9 pin flat cable with female DB9 connector + 68705P3 - Motorola MC68705P3 microcontroller (DIP28) labelled '341-0269 (C) APPLE' + PCB printed '(C) APPLE 1983 341-0269 or 342-0285' + 8516 - Fujitsu MB8516 2k x8-bit EPROM (DIP24) labelled '341-0270-C (C) APPLE 1983' + PCB printed '(C) APPLE 1983 342-0270' + PAL16R4 - MMI PAL16R4ACN (DIP20) marked '341-0268-A' + PCB printed '(C) APPLE 1983 342-0268' + 6821 - AMI 6821 Peripheral Interface Adapter (DIP40) + X1/X2 - Jumper pads. X1 is open, X2 is closed. + + Hookup notes: - PIA port A connects to 68705 port A in its entirety (bi-directional) - PIA PB4-PB7 connects to 68705 PC0-3 (bi-directional) - PIA PB0 is 'sync latch' - PIA PB1 is A8 on the EPROM - PIA PB2 is A9 on the EPROM - PIA PB3 is A10 on the EPROM - - 68705 PB0 is mouse X1 - 68705 PB1 is mouse X0 - 68705 PB2 is mouse Y0 - 68705 PB3 is mouse Y1 - 68705 PB4 and 5 are N/C - 68705 PB6 is IRQ for the slot - 68705 PB7 is the mouse button - - 68705 is clocked at 2M - PIA is clocked at 1M - + PIA port A connects to 68705 port A in its entirety (bi-directional) + PIA PB4-PB7 connects to 68705 PC0-3 (bi-directional) + PIA PB0 is 'sync latch' + PIA PB1 is A8 on the EPROM + PIA PB2 is A9 on the EPROM + PIA PB3 is A10 on the EPROM + + 68705 PB0 is mouse X1 + 68705 PB1 is mouse X0 + 68705 PB2 is mouse Y0 + 68705 PB3 is mouse Y1 + 68705 PB4 and 5 are N/C + 68705 PB6 is IRQ for the slot + 68705 PB7 is the mouse button + + 68705 is clocked at 2M + PIA is clocked at 1M + See the schematic at: - http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Interface%20Cards/Digitizers/Apple%20Mouse%20Interface%20Card/Schematics/ - + http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Interface%20Cards/Digitizers/Apple%20Mouse%20Interface%20Card/Schematics/ + *********************************************************************/ #include "mouse.h" @@ -73,17 +73,17 @@ const device_type A2BUS_MOUSE = &device_creator; -#define MOUSE_ROM_REGION "a2mse_rom" -#define MOUSE_PIA_TAG "a2mse_pia" -#define MOUSE_MCU_TAG "a2mse_mcu" -#define MOUSE_MCU_ROM "a2mse_mcurom" +#define MOUSE_ROM_REGION "a2mse_rom" +#define MOUSE_PIA_TAG "a2mse_pia" +#define MOUSE_MCU_TAG "a2mse_mcu" +#define MOUSE_MCU_ROM "a2mse_mcurom" -#define MOUSE_BUTTON_TAG "a2mse_button" -#define MOUSE_XAXIS_TAG "a2mse_x" -#define MOUSE_YAXIS_TAG "a2mse_y" +#define MOUSE_BUTTON_TAG "a2mse_button" +#define MOUSE_XAXIS_TAG "a2mse_x" +#define MOUSE_YAXIS_TAG "a2mse_y" -#define TIMER_68705 0 -#define TIMER_QUADRATURE 1 +#define TIMER_68705 0 +#define TIMER_QUADRATURE 1 static ADDRESS_MAP_START( mcu_mem, AS_PROGRAM, 8, a2bus_mouse_device ) ADDRESS_MAP_GLOBAL_MASK(0x7ff) @@ -113,14 +113,14 @@ MACHINE_CONFIG_END ROM_START( mouse ) ROM_REGION(0x800, MOUSE_ROM_REGION, 0) - ROM_LOAD( "341-0270-c.4b", 0x000000, 0x000800, CRC(0bcd1e8e) SHA1(3a9d881a8a8d30f55b9719aceebbcf717f829d6f) ) + ROM_LOAD( "341-0270-c.4b", 0x000000, 0x000800, CRC(0bcd1e8e) SHA1(3a9d881a8a8d30f55b9719aceebbcf717f829d6f) ) ROM_REGION(0x800, MOUSE_MCU_ROM, 0) - ROM_LOAD( "341-0269.2b", 0x000000, 0x000800, CRC(94067f16) SHA1(3a2baa6648efe4456d3ec3721216e57c64f7acfc) ) + ROM_LOAD( "341-0269.2b", 0x000000, 0x000800, CRC(94067f16) SHA1(3a2baa6648efe4456d3ec3721216e57c64f7acfc) ) ROM_REGION(0xc00, "pal", 0) - ROM_LOAD( "mmi_pal16r4a(jedec).2a", 0x000000, 0x000b04, CRC(1d620ee5) SHA1(5aa9a515c919ff7a18878649cac5d44f0c2abf28) ) - ROM_LOAD( "mmi_pal16r4a(binary).2a", 0x000000, 0x000100, CRC(1da5c745) SHA1(ba267b69a2fda2a2348b140979ece562411bb37b) ) + ROM_LOAD( "mmi_pal16r4a(jedec).2a", 0x000000, 0x000b04, CRC(1d620ee5) SHA1(5aa9a515c919ff7a18878649cac5d44f0c2abf28) ) + ROM_LOAD( "mmi_pal16r4a(binary).2a", 0x000000, 0x000100, CRC(1da5c745) SHA1(ba267b69a2fda2a2348b140979ece562411bb37b) ) ROM_END static INPUT_PORTS_START( mouse ) @@ -241,7 +241,7 @@ void a2bus_mouse_device::device_reset() m_rom_bank = 0; last_mx = last_my = count_x = count_y = 0; m_timer_cnt = 0xff; - m_timer_ctl = 0x40; // disable interrupt, everything else clear + m_timer_ctl = 0x40; // disable interrupt, everything else clear m_port_a_in = 0; m_port_b_in = 0x80; m_port_c_in = 0; @@ -261,7 +261,7 @@ void a2bus_mouse_device::device_reset() UINT8 a2bus_mouse_device::read_c0nx(address_space &space, UINT8 offset) { - return m_pia->read(space, offset & 3); + return m_pia->read(space, offset & 3); } @@ -394,10 +394,10 @@ WRITE8_MEMBER(a2bus_mouse_device::mcu_timer_w) m_timer_cnt = data; recalc = true; } - // offset 1 = timer control: b7 = IRQ, b6 = IRQ mask (1=suppress), - // b5 = input select (0=CPU clk, 1=ext), - // b4 = enable external timer input, - // b3 = clear, b2-b0 = scaler (1/2/4/8/16/32/64/128) + // offset 1 = timer control: b7 = IRQ, b6 = IRQ mask (1=suppress), + // b5 = input select (0=CPU clk, 1=ext), + // b4 = enable external timer input, + // b3 = clear, b2-b0 = scaler (1/2/4/8/16/32/64/128) else { // clearing the interrupt? @@ -425,7 +425,7 @@ WRITE8_MEMBER(a2bus_mouse_device::mcu_timer_w) recalc = true; } - m_timer_ctl = data; + m_timer_ctl = data; } } @@ -445,15 +445,15 @@ WRITE8_MEMBER(a2bus_mouse_device::mcu_timer_w) X1 = gate, must go 0/1 for each pixel moved Y0 = direction, 0 = up, 1 = down Y1 = gate, must go 0/1 for each pixel moved - + The direction must stay constant for a given train of gate pulses or the MCU will get confused. */ void a2bus_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - if (id == TIMER_68705) // 68705's built-in timer + if (id == TIMER_68705) // 68705's built-in timer { m_timer_ctl |= 0x80; // indicate timer expired - if (!(m_timer_ctl & 0x40)) // if interrupt not suppressed, fire! + if (!(m_timer_ctl & 0x40)) // if interrupt not suppressed, fire! { m_mcu->set_input_line(M68705_INT_TIMER, ASSERT_LINE); } @@ -509,9 +509,9 @@ void a2bus_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int else { count_x--; - m_port_b_in |= 0x01; // X1 + m_port_b_in |= 0x01; // X1 } - m_port_b_in |= 0x02; // X0 + m_port_b_in |= 0x02; // X0 } else if (count_y) { @@ -522,9 +522,9 @@ void a2bus_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int else { count_y--; - m_port_b_in |= 0x04; // Y0 + m_port_b_in |= 0x04; // Y0 } - m_port_b_in |= 0x08; // Y1 + m_port_b_in |= 0x08; // Y1 } } } diff --git a/src/emu/bus/a2bus/timemasterho.c b/src/emu/bus/a2bus/timemasterho.c index 7fc4b8dcd8f..9c1191d3aa9 100644 --- a/src/emu/bus/a2bus/timemasterho.c +++ b/src/emu/bus/a2bus/timemasterho.c @@ -20,17 +20,17 @@ |____________________________ _| | | |______________________| - - + + DIPS: 1:SET 2:MODE 3:NMI 4:IRQ 1 & 4 are on by default. - + J1: 8 pins for X10 home control functions (top to bottom) 1: ADJ 2: 5V 3: MODE 4: GND 5: A 6: 5V 7: B 8: GND - + X10 functions not supported. - + *********************************************************************/ #include "timemasterho.h" @@ -45,9 +45,9 @@ const device_type A2BUS_TIMEMASTERHO = &device_creator; -#define TIMEMASTER_ROM_REGION "timemst_rom" -#define TIMEMASTER_PIA_TAG "timemst_pia" -#define TIMEMASTER_M5832_TAG "timemst_msm" +#define TIMEMASTER_ROM_REGION "timemst_rom" +#define TIMEMASTER_PIA_TAG "timemst_pia" +#define TIMEMASTER_M5832_TAG "timemst_msm" MACHINE_CONFIG_FRAGMENT( timemaster ) MCFG_DEVICE_ADD(TIMEMASTER_PIA_TAG, PIA6821, 1021800) @@ -61,26 +61,26 @@ MACHINE_CONFIG_END ROM_START( timemaster ) ROM_REGION(0x1000, TIMEMASTER_ROM_REGION, 0) - ROM_LOAD( "ae timemaster ii h.o. rom rev. 5.bin", 0x000000, 0x001000, CRC(ff5bd644) SHA1(ae0173da61581a06188c1bee89e95a0aa536c411) ) + ROM_LOAD( "ae timemaster ii h.o. rom rev. 5.bin", 0x000000, 0x001000, CRC(ff5bd644) SHA1(ae0173da61581a06188c1bee89e95a0aa536c411) ) ROM_END static INPUT_PORTS_START( tmho ) PORT_START("DSW1") PORT_DIPNAME( 0x01, 0x01, "Set") - PORT_DIPSETTING( 0x00, "Apple can't set clock") - PORT_DIPSETTING( 0x01, "Apple can set clock") + PORT_DIPSETTING( 0x00, "Apple can't set clock") + PORT_DIPSETTING( 0x01, "Apple can set clock") PORT_DIPNAME( 0x02, 0x00, "Mode") - PORT_DIPSETTING( 0x00, "TimeMaster") - PORT_DIPSETTING( 0x02, "Mountain AppleClock") + PORT_DIPSETTING( 0x00, "TimeMaster") + PORT_DIPSETTING( 0x02, "Mountain AppleClock") PORT_DIPNAME( 0x04, 0x00, "NMI") - PORT_DIPSETTING( 0x00, DEF_STR(Off)) - PORT_DIPSETTING( 0x04, DEF_STR(On)) + PORT_DIPSETTING( 0x00, DEF_STR(Off)) + PORT_DIPSETTING( 0x04, DEF_STR(On)) PORT_DIPNAME( 0x08, 0x08, "IRQ") - PORT_DIPSETTING( 0x00, DEF_STR(Off)) - PORT_DIPSETTING( 0x08, DEF_STR(On)) + PORT_DIPSETTING( 0x00, DEF_STR(Off)) + PORT_DIPSETTING( 0x08, DEF_STR(On)) INPUT_PORTS_END /*************************************************************************** @@ -154,7 +154,7 @@ void a2bus_timemasterho_device::device_start() void a2bus_timemasterho_device::device_reset() { - m_msm5832->cs_w(ASSERT_LINE); // CS is tied to Vcc + m_msm5832->cs_w(ASSERT_LINE); // CS is tied to Vcc m_started = true; } @@ -167,7 +167,7 @@ UINT8 a2bus_timemasterho_device::read_c0nx(address_space &space, UINT8 offset) { if (offset <= 3) { - return m_pia->read(space, offset); + return m_pia->read(space, offset); } return 0xff; @@ -194,7 +194,7 @@ UINT8 a2bus_timemasterho_device::read_cnxx(address_space &space, UINT8 offset) { if (m_started) { - if (!(m_dsw1->read() & 2)) // TimeMaster native + if (!(m_dsw1->read() & 2)) // TimeMaster native { return m_rom[offset+0xc00]; } @@ -228,7 +228,7 @@ WRITE8_MEMBER(a2bus_timemasterho_device::pia_out_b) { if (m_dsw1->read() & 1) { - m_msm5832->write_w((data >> 6) & 1 ? ASSERT_LINE : CLEAR_LINE); + m_msm5832->write_w((data >> 6) & 1 ? ASSERT_LINE : CLEAR_LINE); } } @@ -277,4 +277,3 @@ WRITE_LINE_MEMBER(a2bus_timemasterho_device::pia_irqb_w) m_irqb = state; update_irqs(); } - diff --git a/src/emu/bus/a7800/a78_carts.h b/src/emu/bus/a7800/a78_carts.h index 1d31e22acdb..73739dddcf8 100644 --- a/src/emu/bus/a7800/a78_carts.h +++ b/src/emu/bus/a7800/a78_carts.h @@ -20,10 +20,10 @@ static SLOT_INTERFACE_START(a7800_cart) SLOT_INTERFACE_INTERNAL("a78_abs", A78_ROM_ABSOLUTE) SLOT_INTERFACE_INTERNAL("a78_act", A78_ROM_ACTIVISION) SLOT_INTERFACE_INTERNAL("a78_hsc", A78_HISCORE) - SLOT_INTERFACE_INTERNAL("a78_xboard", A78_XBOARD) // the actual XBoarD expansion (as passthru) - SLOT_INTERFACE_INTERNAL("a78_xm", A78_XM) // the actual XM expansion (as passthru) - SLOT_INTERFACE_INTERNAL("a78_megacart", A78_ROM_MEGACART) - SLOT_INTERFACE_INTERNAL("a78_versa", A78_ROM_VERSABOARD) + SLOT_INTERFACE_INTERNAL("a78_xboard", A78_XBOARD) // the actual XBoarD expansion (as passthru) + SLOT_INTERFACE_INTERNAL("a78_xm", A78_XM) // the actual XM expansion (as passthru) + SLOT_INTERFACE_INTERNAL("a78_megacart", A78_ROM_MEGACART) + SLOT_INTERFACE_INTERNAL("a78_versa", A78_ROM_VERSABOARD) // cart variants with a POKEY at 0x0450 (typically a VersaBoard variant, or an homebrew pcb) SLOT_INTERFACE_INTERNAL("a78_p450_t0", A78_ROM_P450) SLOT_INTERFACE_INTERNAL("a78_p450_t1", A78_ROM_P450_POKEY) diff --git a/src/emu/bus/a7800/a78_slot.c b/src/emu/bus/a7800/a78_slot.c index 9deac1afdd4..d1d6130ba26 100644 --- a/src/emu/bus/a7800/a78_slot.c +++ b/src/emu/bus/a7800/a78_slot.c @@ -21,7 +21,7 @@ - read_40xx/write_40xx for accesses in the $4000 to $ffff range even if not all carts use all of them (in particular no cart type seems to use access to the ranges $0500 to $0fff and $2800 to $2fff) - + ***********************************************************************************************************/ @@ -70,15 +70,15 @@ void device_a78_cart_interface::rom_alloc(UINT32 size, const char *tag) tempstring.cat(A78SLOT_ROM_REGION_TAG); m_rom = device().machine().memory().region_alloc(tempstring, size, 1, ENDIANNESS_LITTLE)->base(); m_rom_size = size; - + // setup other helpers if ((size / 0x4000) & 1) // compensate for SuperGame carts with 9 x 16K banks (to my knowledge no other cart has m_bank_mask != power of 2) m_bank_mask = (size / 0x4000) - 2; else m_bank_mask = (size / 0x4000) - 1; - + // the rom is mapped to the top of the memory area - // so we store the starting point of data to simplify + // so we store the starting point of data to simplify // the access handling m_base_rom = 0x10000 - size; } @@ -272,7 +272,7 @@ int a78_cart_slot_device::validate_header(int head, bool log) } head &= 0xff00; } - + if ((head & 0xff00) > 0x300) { if (log) @@ -282,7 +282,7 @@ int a78_cart_slot_device::validate_header(int head, bool log) } head &= 0x00ff; } - + return head; } @@ -329,7 +329,7 @@ static int a78_get_pcb_id(const char *slot) if (!core_stricmp(slot_list[i].slot_option, slot)) return slot_list[i].pcb_id; } - + return 0; } @@ -340,7 +340,7 @@ static const char *a78_get_slot(int type) if (slot_list[i].pcb_id == type) return slot_list[i].slot_option; } - + return "a78_rom"; } @@ -349,17 +349,17 @@ bool a78_cart_slot_device::call_load() if (m_cart) { UINT32 len; - + if (software_entry() != NULL) { const char *pcb_name; bool has_ram = get_software_region("ram") ? TRUE : FALSE; bool has_nvram = get_software_region("nvram") ? TRUE : FALSE; len = get_software_region_length("rom"); - + m_cart->rom_alloc(len, tag()); memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); - + if ((pcb_name = get_feature("slot")) != NULL) m_type = a78_get_pcb_id(pcb_name); else @@ -377,19 +377,19 @@ bool a78_cart_slot_device::call_load() { // Load and check the header int mapper; - char head[128]; + char head[128]; fread(head, 128); - + if (verify_header((char *)head) == IMAGE_VERIFY_FAIL) return IMAGE_INIT_FAIL; - + len = (head[49] << 24) | (head[50] << 16) | (head[51] << 8) | head[52]; if (len + 128 > length()) { logerror("Invalid length in the header. The game might be corrupted.\n"); len = length() - 128; } - + // let's try to auto-fix some common errors in the header mapper = validate_header((head[53] << 8) | head[54], TRUE); @@ -415,7 +415,7 @@ bool a78_cart_slot_device::call_load() m_type = A78_VERSABOARD; break; } - + // check if cart has a POKEY at $0450 (typically a VersaBoard variant)! if (mapper & 0x40) { @@ -425,7 +425,7 @@ bool a78_cart_slot_device::call_load() m_type += A78_POKEY0450; } } - + // check special bits, which override the previous if ((mapper & 0xff00) == 0x0100) m_type = A78_ACTIVISION; @@ -452,10 +452,10 @@ bool a78_cart_slot_device::call_load() } internal_header_logging((UINT8 *)head, length()); - + m_cart->rom_alloc(len, tag()); fread(m_cart->get_rom_base(), len); - + if (m_type == A78_TYPE6) m_cart->ram_alloc(0x4000); if (m_type == A78_MEGACART || (m_type >= A78_VERSABOARD && m_type <= A78_VERSA_POK450)) @@ -468,7 +468,7 @@ bool a78_cart_slot_device::call_load() battery_load(m_cart->get_nvram_base(), 0x800, 0xff); } } - + //printf("Type: %s\n", a78_get_slot(m_type)); } return IMAGE_INIT_PASS; @@ -476,7 +476,7 @@ bool a78_cart_slot_device::call_load() void a78_partialhash(hash_collection &dest, const unsigned char *data, - unsigned long length, const char *functions) + unsigned long length, const char *functions) { if (length <= 128) return; @@ -537,13 +537,13 @@ void a78_cart_slot_device::get_default_card_software(astring &result) const char *slot_string = "a78_rom"; dynamic_buffer head(128); int type = A78_TYPE0, mapper; - + // Load and check the header - core_fread(m_file, head, 128); + core_fread(m_file, head, 128); // let's try to auto-fix some common errors in the header mapper = validate_header((head[53] << 8) | head[54], FALSE); - + switch (mapper & 0x2e) { case 0x0000: @@ -566,7 +566,7 @@ void a78_cart_slot_device::get_default_card_software(astring &result) type = A78_VERSABOARD; break; } - + // check if cart has a POKEY at $0450 (typically a VersaBoard variant)! if (mapper & 0x40) { @@ -576,18 +576,18 @@ void a78_cart_slot_device::get_default_card_software(astring &result) type += A78_POKEY0450; } } - + // check special bits, which override the previous if ((mapper & 0xff00) == 0x0100) type = A78_ACTIVISION; else if ((mapper & 0xff00) == 0x0200) type = A78_ABSOLUTE; - + logerror("Cart type: %x\n", type); slot_string = a78_get_slot(type); - + clear(); - + result.cpy(slot_string); } else @@ -663,9 +663,9 @@ WRITE8_MEMBER(a78_cart_slot_device::write_40xx) /*------------------------------------------------- A78 header logging - + A78 HEADER FORMAT - + Bytes | Content | Length ======================================== 0 | Header version | 1 byte @@ -679,7 +679,7 @@ WRITE8_MEMBER(a78_cart_slot_device::write_40xx) 53..54 | Cart type [*] | 2 bytes -------|-------------------|------------ 55 | Controller 1 type | 1 byte - | | + | | | 0 = None | | 1 = Joystick | | 2 = Light Gun | @@ -690,23 +690,23 @@ WRITE8_MEMBER(a78_cart_slot_device::write_40xx) -------|-------------------|------------ 57 | TV System | 1 byte | | - | 0 = NTSC/1 = PAL | + | 0 = NTSC/1 = PAL | -------|-------------------|------------ 58 | Save data | 1 byte | | (only v2) | 0 = None / Unk | | 1 = High Score | | 2 = Savekey | - -------|-------------------|----------- + -------|-------------------|----------- 63 | Expansion module | 1 byte | | | 0 = No expansion | | module | | 1 = Expansion | | required | - -------|-------------------|----------- - - + -------|-------------------|----------- + + [*] Cart type: bit 0-7 - Hardware "flags" @@ -716,13 +716,13 @@ WRITE8_MEMBER(a78_cart_slot_device::write_40xx) bit 3 [0x08] - bank 0 of 144K ROM at $4000 bit 4 [0x10] - bank 6 at $4000 bit 5 [0x20] - banked RAM at $4000 - + bit 8-15 - Special values 0 = Normal cart 1 = Absolute (F18 Hornet) 2 = Activision (Double Dragon & Rampage) 3 = POKEY at $0450 - + -------------------------------------------------*/ void a78_cart_slot_device::internal_header_logging(UINT8 *header, UINT32 len) @@ -788,7 +788,7 @@ void a78_cart_slot_device::internal_header_logging(UINT8 *header, UINT32 len) ctrl1.cpy("Unknown controller"); break; } - + switch (head_ctrl2) { case 0x00: @@ -804,10 +804,10 @@ void a78_cart_slot_device::internal_header_logging(UINT8 *header, UINT32 len) ctrl2.cpy("Unknown controller"); break; } - + logerror( "ROM DETAILS\n" ); logerror( "===========\n\n" ); - logerror( "\tTotal length (with header): 0x%x (%dK + 128b header)\n\n", len, len/0x400); + logerror( "\tTotal length (with header): 0x%x (%dK + 128b header)\n\n", len, len/0x400); logerror( "HEADER DETAILS\n" ); logerror( "==============\n\n" ); logerror( "\tTitle: %.32s\n", head_title); @@ -829,5 +829,5 @@ void a78_cart_slot_device::internal_header_logging(UINT8 *header, UINT32 len) logerror( "\n"); logerror( "\tController 1: 0x%.2X [%s]\n", head_ctrl1, ctrl1.cstr()); logerror( "\tController 2: 0x%.2X [%s]\n", head_ctrl2, ctrl2.cstr()); - logerror( "\tVideo: %s\n", (head_ispal) ? "PAL" : "NTSC"); + logerror( "\tVideo: %s\n", (head_ispal) ? "PAL" : "NTSC"); } diff --git a/src/emu/bus/a7800/a78_slot.h b/src/emu/bus/a7800/a78_slot.h index b9c7e935d40..528c8932c04 100644 --- a/src/emu/bus/a7800/a78_slot.h +++ b/src/emu/bus/a7800/a78_slot.h @@ -12,19 +12,19 @@ /* PCB */ enum { - A78_TYPE0 = 0, // standard 8K/16K/32K games, no bankswitch - A78_TYPE1, // as TYPE0 + POKEY chip on the PCB - A78_TYPE2, // Atari SuperGame pcb (8x16K banks with bankswitch) - A78_TYPE3, // as TYPE1 + POKEY chip on the PCB - A78_TYPE6, // as TYPE1 + RAM IC on the PCB - A78_TYPEA, // Alien Brigade, Crossbow (9x16K banks with diff bankswitch) - A78_ABSOLUTE, // F18 Hornet - A78_ACTIVISION, // Double Dragon, Rampage - A78_HSC, // Atari HighScore cart - A78_XB_BOARD, // A7800 Expansion Board (it shall more or less apply to the Expansion Module too, but this is not officially released yet) - A78_XM_BOARD, // A7800 XM Expansion Module (theoretical specs only, since this is not officially released yet) - A78_MEGACART, // Homebrew by CPUWIZ, consists of SuperGame bank up to 512K + 32K RAM banked - A78_VERSABOARD = 0x10, // Homebrew by CPUWIZ, consists of SuperGame bank up to 256K + 32K RAM banked + A78_TYPE0 = 0, // standard 8K/16K/32K games, no bankswitch + A78_TYPE1, // as TYPE0 + POKEY chip on the PCB + A78_TYPE2, // Atari SuperGame pcb (8x16K banks with bankswitch) + A78_TYPE3, // as TYPE1 + POKEY chip on the PCB + A78_TYPE6, // as TYPE1 + RAM IC on the PCB + A78_TYPEA, // Alien Brigade, Crossbow (9x16K banks with diff bankswitch) + A78_ABSOLUTE, // F18 Hornet + A78_ACTIVISION, // Double Dragon, Rampage + A78_HSC, // Atari HighScore cart + A78_XB_BOARD, // A7800 Expansion Board (it shall more or less apply to the Expansion Module too, but this is not officially released yet) + A78_XM_BOARD, // A7800 XM Expansion Module (theoretical specs only, since this is not officially released yet) + A78_MEGACART, // Homebrew by CPUWIZ, consists of SuperGame bank up to 512K + 32K RAM banked + A78_VERSABOARD = 0x10, // Homebrew by CPUWIZ, consists of SuperGame bank up to 256K + 32K RAM banked // VersaBoard variants configured as Type 1/3/A or VersaBoard + POKEY at $0450 A78_TYPE0_POK450 = 0x20, A78_TYPE1_POK450 = 0x21, @@ -68,7 +68,7 @@ protected: UINT8 *m_rom; UINT32 m_rom_size; dynamic_buffer m_ram; - dynamic_buffer m_nvram; // HiScore cart can save scores! + dynamic_buffer m_nvram; // HiScore cart can save scores! // helpers UINT32 m_base_rom; int m_bank_mask; @@ -101,7 +101,7 @@ public: int get_cart_type() { return m_type; }; int identify_cart_type(UINT8 *ROM, UINT32 len); bool has_cart() { return m_cart != NULL; } - + virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } virtual bool is_writeable() const { return 0; } @@ -125,7 +125,7 @@ public: virtual DECLARE_WRITE8_MEMBER(write_10xx); virtual DECLARE_WRITE8_MEMBER(write_30xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + private: device_a78_cart_interface* m_cart; int m_type; diff --git a/src/emu/bus/a7800/cpuwiz.c b/src/emu/bus/a7800/cpuwiz.c index c5d6ef74532..f25580a1c08 100644 --- a/src/emu/bus/a7800/cpuwiz.c +++ b/src/emu/bus/a7800/cpuwiz.c @@ -3,26 +3,26 @@ /*********************************************************************************************************** A7800 CPUWIZ's homebrew boards (MegaCart+ and VersaBoard) - + Here we emulate the base configurations of these two boards: MegaCart+ = up to 512K (31 banks at $8000, 1 at $C000) of ROM and 2 x 16K RAM @ $4000 VersaBoard = up to 256K of ROM and 2 x 16K RAM - - Plus, for the moment, a VersaBoard with POKEY mapped at 0x0450 and support for 144K ROM, - since a few demo homebrew programs seems to use this to combine compatibility with + + Plus, for the moment, a VersaBoard with POKEY mapped at 0x0450 and support for 144K ROM, + since a few demo homebrew programs seems to use this to combine compatibility with XBoarD & XM expansions Note that the VersaBoard can be configured to work with different banking hardware e.g. with SG 9bank games or with SG + RAM (so to allow reproduction of games which - could have worked on old carts without sacrifying original carts), but games running + could have worked on old carts without sacrifying original carts), but games running on those "standard" variants can be emulated with the standard code from rom.c ;-) - - + + TO DO: - investigate whether the POKEY detection routines in homebrew do fail due to emulation issues or not - + ***********************************************************************************************************/ @@ -86,7 +86,7 @@ READ8_MEMBER(a78_versaboard_device::read_40xx) else if (offset < 0x8000) return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; else - return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank + return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank } WRITE8_MEMBER(a78_versaboard_device::write_40xx) @@ -130,5 +130,3 @@ machine_config_constructor a78_rom_p450_vb_device::device_mconfig_additions() co { return MACHINE_CONFIG_NAME( a78_pokeyvb ); } - - diff --git a/src/emu/bus/a7800/cpuwiz.h b/src/emu/bus/a7800/cpuwiz.h index ab019433b70..193ba336b96 100644 --- a/src/emu/bus/a7800/cpuwiz.h +++ b/src/emu/bus/a7800/cpuwiz.h @@ -15,15 +15,15 @@ public: // construction/destruction a78_versaboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_versaboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + protected: int m_ram_bank; }; @@ -36,7 +36,7 @@ class a78_megacart_device : public a78_versaboard_device public: // construction/destruction a78_megacart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_WRITE8_MEMBER(write_40xx); }; @@ -51,14 +51,14 @@ class a78_rom_p450_vb_device : public a78_versaboard_device public: // construction/destruction a78_rom_p450_vb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx) { if (offset >= 0x50 && offset < 0x60) return m_pokey450->read(space, offset & 0x0f); else return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_04xx) { if (offset >= 0x50 && offset < 0x60) m_pokey450->write(space, offset & 0x0f, data); } - + protected: required_device m_pokey450; }; diff --git a/src/emu/bus/a7800/hiscore.c b/src/emu/bus/a7800/hiscore.c index 2e941af9fbd..c51d1c26b74 100644 --- a/src/emu/bus/a7800/hiscore.c +++ b/src/emu/bus/a7800/hiscore.c @@ -3,7 +3,7 @@ /*********************************************************************************************************** A7800 HighScore passthrough cart emulation - + ***********************************************************************************************************/ @@ -75,4 +75,3 @@ WRITE8_MEMBER(a78_hiscore_device::write_40xx) { m_hscslot->write_40xx(space, offset, data); } - diff --git a/src/emu/bus/a7800/hiscore.h b/src/emu/bus/a7800/hiscore.h index d848becfea7..d1750c77486 100644 --- a/src/emu/bus/a7800/hiscore.h +++ b/src/emu/bus/a7800/hiscore.h @@ -14,10 +14,10 @@ class a78_hiscore_device : public a78_rom_device public: // construction/destruction a78_hiscore_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx); virtual DECLARE_WRITE8_MEMBER(write_04xx); diff --git a/src/emu/bus/a7800/rom.c b/src/emu/bus/a7800/rom.c index 508c9cc895b..d2bfc5d78a4 100644 --- a/src/emu/bus/a7800/rom.c +++ b/src/emu/bus/a7800/rom.c @@ -10,7 +10,7 @@ - 9 banks or not etc... But we might merge many of these if they become too many - + TODO: - Are POKEY regs readable somewhere in SG 144K + POKEY homebrew? How do they detect the POKEY otherwise?!? @@ -232,11 +232,11 @@ READ8_MEMBER(a78_rom_device::read_40xx) /*------------------------------------------------- Carts with no bankswitch + POKEY chip - The Pokey chips is accessed by writing at + The Pokey chips is accessed by writing at 0x4000-0x7fff. - + GAMES: Ballblazer, Beef Drop (homebrew) - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_pokey_device::read_40xx) @@ -274,19 +274,19 @@ machine_config_constructor a78_rom_pokey_device::device_mconfig_additions() cons some test is run) Note that the code is written so that also homebrew games with larger ROMs work! - + GAMES: Crack'd, Fatal Run, Ikari Warriors... - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_sg_device::read_40xx) { if (offset < 0x4000) - return m_rom[(offset & 0x3fff) + ((m_bank_mask - 1) * 0x4000)]; // second to last bank (is this always ok?!?) + return m_rom[(offset & 0x3fff) + ((m_bank_mask - 1) * 0x4000)]; // second to last bank (is this always ok?!?) else if (offset < 0x8000) return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; else - return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank + return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank } WRITE8_MEMBER(a78_rom_sg_device::write_40xx) @@ -300,9 +300,9 @@ WRITE8_MEMBER(a78_rom_sg_device::write_40xx) Carts with SuperGame bankswitch + POKEY chip As above + Pokey chip access - + GAMES: Commando - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_sg_pokey_device::read_40xx) @@ -312,7 +312,7 @@ READ8_MEMBER(a78_rom_sg_pokey_device::read_40xx) else if (offset < 0x8000) return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; else - return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank + return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank } WRITE8_MEMBER(a78_rom_sg_pokey_device::write_40xx) @@ -332,12 +332,12 @@ machine_config_constructor a78_rom_sg_pokey_device::device_mconfig_additions() c /*------------------------------------------------- Carts with SuperGame bankswitch + 16K RAM - FIXME: Some games contained only 8K of RAM, but + FIXME: Some games contained only 8K of RAM, but for the moment we treat all as 16K of RAM even if from softlist we shall differentiate between them. - + GAMES: Impossible Mission, Jinks and some protos - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_sg_ram_device::read_40xx) @@ -347,7 +347,7 @@ READ8_MEMBER(a78_rom_sg_ram_device::read_40xx) else if (offset < 0x8000) return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; else - return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank + return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank } WRITE8_MEMBER(a78_rom_sg_ram_device::write_40xx) @@ -364,11 +364,11 @@ WRITE8_MEMBER(a78_rom_sg_ram_device::write_40xx) Carts with SuperGame bankswitch 9banks: 9 x 16K banks mappable in 0x8000-0xbfff bank 7 is always mapped in 0xc000-0xffff - - GAMES: Alien Brigade & Crossbow + some homebrew - like Donkey Kong XM demo, Bentley Bear's Crystal + + GAMES: Alien Brigade & Crossbow + some homebrew + like Donkey Kong XM demo, Bentley Bear's Crystal Quest - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_sg9_device::read_40xx) @@ -378,7 +378,7 @@ READ8_MEMBER(a78_rom_sg9_device::read_40xx) else if (offset < 0x8000) return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; else - return m_rom[(offset & 0x3fff) + ((m_bank_mask + 1) * 0x4000)]; // last bank + return m_rom[(offset & 0x3fff) + ((m_bank_mask + 1) * 0x4000)]; // last bank } WRITE8_MEMBER(a78_rom_sg9_device::write_40xx) @@ -388,14 +388,14 @@ WRITE8_MEMBER(a78_rom_sg9_device::write_40xx) } /*------------------------------------------------- - + Carts with Absolute bankswitch: 64K games. Lower 32K are 2 banks of 16K to be mapped in 0x4000-0x7fff, depending on the value written at 0x8000. Higher 32K are fixed in 0x8000-0xffff - + GAMES: F-18 Hornet - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_abs_device::read_40xx) @@ -431,9 +431,9 @@ WRITE8_MEMBER(a78_rom_abs_device::write_40xx) 0x6000-0x7fff first 8kb of bank 6 0x8000-0x9fff second 8kb of bank 7 0xe000-0xffff first 8kb of bank 7 - + GAMES: Double Dragon, Rampage. - + -------------------------------------------------*/ READ8_MEMBER(a78_rom_act_device::read_40xx) @@ -495,4 +495,3 @@ machine_config_constructor a78_rom_p450_sg9_device::device_mconfig_additions() c { return MACHINE_CONFIG_NAME( a78_pokey450 ); } - diff --git a/src/emu/bus/a7800/rom.h b/src/emu/bus/a7800/rom.h index 425513d02d7..16f31360a74 100644 --- a/src/emu/bus/a7800/rom.h +++ b/src/emu/bus/a7800/rom.h @@ -34,14 +34,14 @@ public: // construction/destruction a78_rom_pokey_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_rom_pokey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + protected: required_device m_pokey; }; @@ -55,11 +55,11 @@ public: // construction/destruction a78_rom_sg_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_rom_sg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); @@ -76,14 +76,14 @@ class a78_rom_sg_pokey_device : public a78_rom_sg_device public: // construction/destruction a78_rom_sg_pokey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + protected: required_device m_pokey; }; @@ -97,7 +97,7 @@ public: // construction/destruction a78_rom_sg_ram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_rom_sg_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); @@ -112,7 +112,7 @@ public: // construction/destruction a78_rom_sg9_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_rom_sg9_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); @@ -126,15 +126,15 @@ class a78_rom_abs_device : public a78_rom_device public: // construction/destruction a78_rom_abs_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + protected: int m_bank; }; @@ -147,15 +147,15 @@ class a78_rom_act_device : public a78_rom_device public: // construction/destruction a78_rom_act_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_40xx); virtual DECLARE_WRITE8_MEMBER(write_40xx); - + protected: int m_bank; }; @@ -170,13 +170,13 @@ class a78_rom_p450_device : public a78_rom_device public: // construction/destruction a78_rom_p450_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx) { if (offset >= 0x50 && offset < 0x60) return m_pokey450->read(space, offset & 0x0f); else return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_04xx) { if (offset >= 0x50 && offset < 0x60) m_pokey450->write(space, offset & 0x0f, data); } - + protected: required_device m_pokey450; }; @@ -189,13 +189,13 @@ class a78_rom_p450_pokey_device : public a78_rom_pokey_device public: // construction/destruction a78_rom_p450_pokey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx) { if (offset >= 0x50 && offset < 0x60) return m_pokey450->read(space, offset & 0x0f); else return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_04xx) { if (offset >= 0x50 && offset < 0x60) m_pokey450->write(space, offset & 0x0f, data); } - + protected: required_device m_pokey450; }; @@ -208,13 +208,13 @@ class a78_rom_p450_sg_ram_device : public a78_rom_sg_ram_device public: // construction/destruction a78_rom_p450_sg_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual machine_config_constructor device_mconfig_additions() const; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx) { if (offset >= 0x50 && offset < 0x60) return m_pokey450->read(space, offset & 0x0f); else return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_04xx) { if (offset >= 0x50 && offset < 0x60) m_pokey450->write(space, offset & 0x0f, data); } - + protected: required_device m_pokey450; }; @@ -227,13 +227,13 @@ class a78_rom_p450_sg9_device : public a78_rom_sg9_device public: // construction/destruction a78_rom_p450_sg9_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual machine_config_constructor device_mconfig_additions() const; // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx) { if (offset >= 0x50 && offset < 0x60) return m_pokey450->read(space, offset & 0x0f); else return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_04xx) { if (offset >= 0x50 && offset < 0x60) m_pokey450->write(space, offset & 0x0f, data); } - + protected: required_device m_pokey450; }; diff --git a/src/emu/bus/a7800/xboard.c b/src/emu/bus/a7800/xboard.c index 66c89d3d05c..4a7d3742f1b 100644 --- a/src/emu/bus/a7800/xboard.c +++ b/src/emu/bus/a7800/xboard.c @@ -3,7 +3,7 @@ /*********************************************************************************************************** A7800 XBoarD & XM expansions emulation - + The XBoarD should be socketed in the A7800 pcb in place of the Maria chip. It adds to the system additional 128K of RAM and an onboard pokey. The XM seems to work the same as XBoarD, but it also features HighScore savings @@ -12,31 +12,31 @@ Currently, we emulate both of these as a passthru cart, even if not 100% accurate for the XBoarD - + Memory map: POKEY1 $0450 $045F 16 bytes POKEY2* $0460 $046F 16 bytes XCTRL $0470 $047F 1 byte RAM $4000 $7FFF 16384 bytes - + XCTRL Bit Description - + +-------------------------------+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-------------------------------+ | | | | | | | | | | | | | | | +-- Bank select bit 0 \ | | | | | | +------ Bank select bit 1 | Totally 128 KByte in 16 KByte banks - | | | | | +---------- Bank select bit 2 / + | | | | | +---------- Bank select bit 2 / | | | | +-------------- Enable memory bit (1 = Memory enabled, 0 after power on) | | | +------------------ Enable POKEY bit** (1 = POKEY enabled, 0 after power on) | | | NA NA NA = Not Available or Not Used - + * = Can be mounted piggy back on the first POKEY. Description how to do this will come when i have tried it out. ** This bit controls both POKEY chip select signals. - + TODO: - verify what happens when 2 POKEYs are present @@ -142,9 +142,9 @@ machine_config_constructor a78_xm_device::device_mconfig_additions() const -------------------------------------------------*/ /*------------------------------------------------- - + XBoarD: passthru + 128K RAM + POKEY - + -------------------------------------------------*/ READ8_MEMBER(a78_xboard_device::read_40xx) @@ -168,7 +168,7 @@ READ8_MEMBER(a78_xboard_device::read_04xx) if (BIT(m_reg, 4) && offset >= 0x50 && offset < 0x60) return m_pokey->read(space, offset & 0x0f); else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) - return m_xbslot->read_04xx(space, offset - 0x10); // access second POKEY + return m_xbslot->read_04xx(space, offset - 0x10); // access second POKEY else return 0xff; } @@ -178,7 +178,7 @@ WRITE8_MEMBER(a78_xboard_device::write_04xx) if (BIT(m_reg, 4) && offset >= 0x50 && offset < 0x60) m_pokey->write(space, offset & 0x0f, data); else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) - m_xbslot->write_04xx(space, offset - 0x10, data); // access second POKEY + m_xbslot->write_04xx(space, offset - 0x10, data); // access second POKEY else if (offset >= 0x70 && offset < 0x80) { m_reg = data; @@ -188,9 +188,9 @@ WRITE8_MEMBER(a78_xboard_device::write_04xx) /*------------------------------------------------- - + XM: Same as above but also featuring High Score savings - + -------------------------------------------------*/ READ8_MEMBER(a78_xm_device::read_10xx) @@ -215,7 +215,7 @@ READ8_MEMBER(a78_xm_device::read_04xx) else if (m_ym_enabled && offset >= 0x60 && offset <= 0x61) return m_ym->read(space, offset & 1); else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) - return m_xbslot->read_04xx(space, offset - 0x10); // access second POKEY + return m_xbslot->read_04xx(space, offset - 0x10); // access second POKEY else return 0xff; } @@ -227,7 +227,7 @@ WRITE8_MEMBER(a78_xm_device::write_04xx) else if (m_ym_enabled && offset >= 0x60 && offset <= 0x61) m_ym->write(space, offset & 1, data); else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) - m_xbslot->write_04xx(space, offset - 0x10, data); // access second POKEY + m_xbslot->write_04xx(space, offset - 0x10, data); // access second POKEY else if (offset >= 0x70 && offset < 0x80) { //printf("regs 0x%X\n", data); diff --git a/src/emu/bus/a7800/xboard.h b/src/emu/bus/a7800/xboard.h index 2eb63462b47..0e5e7f26cf0 100644 --- a/src/emu/bus/a7800/xboard.h +++ b/src/emu/bus/a7800/xboard.h @@ -17,12 +17,12 @@ public: // construction/destruction a78_xboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a78_xboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual machine_config_constructor device_mconfig_additions() const; virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx); virtual DECLARE_WRITE8_MEMBER(write_04xx); @@ -43,19 +43,19 @@ class a78_xm_device : public a78_xboard_device public: // construction/destruction a78_xm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual machine_config_constructor device_mconfig_additions() const; virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_04xx); virtual DECLARE_WRITE8_MEMBER(write_04xx); virtual DECLARE_READ8_MEMBER(read_10xx); virtual DECLARE_WRITE8_MEMBER(write_10xx); virtual DECLARE_READ8_MEMBER(read_30xx); - + protected: required_device m_ym; int m_ym_enabled; diff --git a/src/emu/bus/a800/a800_carts.h b/src/emu/bus/a800/a800_carts.h index 8a67ef656a0..eb28c9c3b2c 100644 --- a/src/emu/bus/a800/a800_carts.h +++ b/src/emu/bus/a800/a800_carts.h @@ -14,7 +14,7 @@ static SLOT_INTERFACE_START(a800_left) SLOT_INTERFACE_INTERNAL("a800_8k", A800_ROM) SLOT_INTERFACE_INTERNAL("a800_8k_right", A800_ROM) SLOT_INTERFACE_INTERNAL("a800_16k", A800_ROM) - SLOT_INTERFACE_INTERNAL("a800_phoenix", A800_ROM) // not really emulated at this stage + SLOT_INTERFACE_INTERNAL("a800_phoenix", A800_ROM) // not really emulated at this stage SLOT_INTERFACE_INTERNAL("a800_bbsb", A800_ROM_BBSB) SLOT_INTERFACE_INTERNAL("a800_oss8k", A800_ROM_OSS8K) SLOT_INTERFACE_INTERNAL("a800_oss034m", A800_ROM_OSS34) @@ -23,13 +23,13 @@ static SLOT_INTERFACE_START(a800_left) SLOT_INTERFACE_INTERNAL("a800_williams", A800_ROM_WILLIAMS) SLOT_INTERFACE_INTERNAL("a800_diamond", A800_ROM_EXPRESS) SLOT_INTERFACE_INTERNAL("a800_express", A800_ROM_EXPRESS) - SLOT_INTERFACE_INTERNAL("a800_sparta", A800_ROM_SPARTADOS) // this is a passthru cart with unemulated (atm) subslot + SLOT_INTERFACE_INTERNAL("a800_sparta", A800_ROM_SPARTADOS) // this is a passthru cart with unemulated (atm) subslot SLOT_INTERFACE_INTERNAL("a800_blizzard", A800_ROM) SLOT_INTERFACE_INTERNAL("a800_turbo64", A800_ROM_TURBO) SLOT_INTERFACE_INTERNAL("a800_turbo128", A800_ROM_TURBO) SLOT_INTERFACE_INTERNAL("a800_tlink2", A800_ROM_TELELINK2) SLOT_INTERFACE_INTERNAL("a800_sitsa", A800_ROM_MICROCALC) - SLOT_INTERFACE_INTERNAL("a800_corina", A800_ROM) // NOT SUPPORTED YET! + SLOT_INTERFACE_INTERNAL("a800_corina", A800_ROM) // NOT SUPPORTED YET! SLOT_INTERFACE_INTERNAL("xegs", XEGS_ROM) SLOT_INTERFACE_END diff --git a/src/emu/bus/a800/a800_slot.c b/src/emu/bus/a800/a800_slot.c index 0a86342247f..e6d06c936e6 100644 --- a/src/emu/bus/a800/a800_slot.c +++ b/src/emu/bus/a800/a800_slot.c @@ -6,12 +6,12 @@ Atari 8 bit cart emulation (through slot devices) - Emulation of the cartslot(s) for Atari 8bit series of home computers - + Emulation of the cartslot(s) for Atari 8bit series of home computers + Accessors to ROM are typically given in the area 0xa000-0xbfff, but some carts (and the right slot in A800) maps ROM to 0x8000-0x9fff too Bankswitch typically happens by accessing addresses in 0xd500-0xd5ff - + Accordingly, this device offers the following handlers - read_80xx/write_80xx - read_d5xx/write_d5xx @@ -67,9 +67,9 @@ void device_a800_cart_interface::rom_alloc(UINT32 size, const char *tag) tempstring.cat(A800SLOT_ROM_REGION_TAG); m_rom = device().machine().memory().region_alloc(tempstring, size, 1, ENDIANNESS_LITTLE)->base(); m_rom_size = size; - + // setup other helpers - m_bank_mask = (size / 0x2000) - 1; // code for XEGS carts makes use of this to simplify banking + m_bank_mask = (size / 0x2000) - 1; // code for XEGS carts makes use of this to simplify banking } } @@ -243,15 +243,15 @@ bool a800_cart_slot_device::call_load() if (m_cart) { UINT32 len; - + if (software_entry() != NULL) { const char *pcb_name; len = get_software_region_length("rom"); - + m_cart->rom_alloc(len, tag()); memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); - + if ((pcb_name = get_feature("slot")) != NULL) m_type = a800_get_pcb_id(pcb_name); else @@ -267,9 +267,9 @@ bool a800_cart_slot_device::call_load() UINT8 header[16]; fread(header, 0x10); m_type = identify_cart_type(header); - len -= 0x10; // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here + len -= 0x10; // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here } - else // otherwise try to guess based on size + else // otherwise try to guess based on size { if (len == 0x8000) m_type = A5200_32K; @@ -323,7 +323,7 @@ int a800_cart_slot_device::identify_cart_type(UINT8 *header) // check CART format if (strncmp((const char *)header, "CART", 4)) fatalerror("Invalid header detected!\n"); - + switch ((header[4] << 24) + (header[5] << 16) + (header[6] << 8) + (header[7] << 0)) { case 1: @@ -400,7 +400,7 @@ int a800_cart_slot_device::identify_cart_type(UINT8 *header) osd_printf_info("Cart type \"%d\" is currently unsupported.\n", (header[4] << 24) + (header[5] << 16) + (header[6] << 8) + (header[7] << 0)); break; } - + return type; } @@ -420,10 +420,10 @@ void a800_cart_slot_device::get_default_card_software(astring &result) // check whether there is an header, to identify the cart type if ((len % 0x1000) == 0x10) { - core_fread(m_file, head, 0x10); + core_fread(m_file, head, 0x10); type = identify_cart_type(head); } - else // otherwise try to guess based on size + else // otherwise try to guess based on size { if (len == 0x4000) type = A800_16K; @@ -435,9 +435,9 @@ void a800_cart_slot_device::get_default_card_software(astring &result) osd_printf_info("This game is not designed for A800. You might want to run it in A5200.\n"); slot_string = a800_get_slot(type); - + clear(); - + result.cpy(slot_string); } else @@ -453,11 +453,11 @@ void a5200_cart_slot_device::get_default_card_software(astring &result) dynamic_buffer head(0x10); UINT32 len = core_fsize(m_file); int type = A5200_8K; - + // check whether there is an header, to identify the cart type if ((len % 0x1000) == 0x10) { - core_fread(m_file, head, 0x10); + core_fread(m_file, head, 0x10); type = identify_cart_type(head); astring info; @@ -466,11 +466,11 @@ void a5200_cart_slot_device::get_default_card_software(astring &result) } if (type < A5200_4K) osd_printf_info("This game is not designed for A5200. You might want to run it in A800 or A800XL.\n"); - + slot_string = a800_get_slot(type); - + clear(); - + result.cpy(slot_string); } else @@ -486,11 +486,11 @@ void xegs_cart_slot_device::get_default_card_software(astring &result) dynamic_buffer head(0x10); UINT32 len = core_fsize(m_file); int type = A800_8K; - + // check whether there is an header, to identify the cart type if ((len % 0x1000) == 0x10) { - core_fread(m_file, head, 0x10); + core_fread(m_file, head, 0x10); type = identify_cart_type(head); } if (type != A800_XEGS) @@ -501,11 +501,11 @@ void xegs_cart_slot_device::get_default_card_software(astring &result) else osd_printf_info("You might want to run it in A800 or A800XL.\n"); } - + slot_string = a800_get_slot(type); - + clear(); - + result.cpy(slot_string); } else @@ -549,4 +549,3 @@ WRITE8_MEMBER(a800_cart_slot_device::write_d5xx) if (m_cart) m_cart->write_d5xx(space, offset, data, mem_mask); } - diff --git a/src/emu/bus/a800/a800_slot.h b/src/emu/bus/a800/a800_slot.h index 536ed38da3e..b9e4f491d73 100644 --- a/src/emu/bus/a800/a800_slot.h +++ b/src/emu/bus/a800/a800_slot.h @@ -20,11 +20,11 @@ enum A800_OSSM091, A800_OSS8K, A800_PHOENIX, - A800_XEGS, - A800_BBSB, + A800_XEGS, + A800_BBSB, A800_DIAMOND, A800_WILLIAMS, - A800_EXPRESS, + A800_EXPRESS, A800_SPARTADOS, A800_BLIZZARD, A800_TURBO64, @@ -71,7 +71,7 @@ protected: UINT8 *m_rom; UINT32 m_rom_size; dynamic_buffer m_ram; - dynamic_buffer m_nvram; // HiScore cart can save scores! + dynamic_buffer m_nvram; // HiScore cart can save scores! // helpers int m_bank_mask; }; @@ -101,7 +101,7 @@ public: int get_cart_type() { return m_type; }; int identify_cart_type(UINT8 *header); bool has_cart() { return m_cart != NULL; } - + virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } virtual bool is_writeable() const { return 0; } @@ -120,7 +120,7 @@ public: virtual DECLARE_READ8_MEMBER(read_d5xx); virtual DECLARE_WRITE8_MEMBER(write_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + private: device_a800_cart_interface* m_cart; int m_type; @@ -138,9 +138,9 @@ public: // construction/destruction a5200_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); virtual ~a5200_cart_slot_device(); - + virtual const char *file_extensions() const { return "bin,rom,car,a52"; } - + // slot interface overrides virtual void get_default_card_software(astring &result); }; @@ -155,7 +155,7 @@ public: virtual ~xegs_cart_slot_device(); virtual const char *file_extensions() const { return "bin,rom,car"; } - + // slot interface overrides virtual void get_default_card_software(astring &result); }; diff --git a/src/emu/bus/a800/oss.c b/src/emu/bus/a800/oss.c index 1cf4d176d68..3df4f2b0ed4 100644 --- a/src/emu/bus/a800/oss.c +++ b/src/emu/bus/a800/oss.c @@ -95,11 +95,11 @@ void a800_rom_oss91_device::device_reset() -------------------------------------------------*/ /*------------------------------------------------- - + OSS 8K - + This is used by The Writer's Tool only. - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_oss8k_device::read_80xx) @@ -128,12 +128,12 @@ WRITE8_MEMBER(a800_rom_oss8k_device::write_d5xx) /*------------------------------------------------- - + OSS 034M - + This apparently comes from a dump with the wrong bank order... investigate whether we should remove it! - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_oss34_device::read_80xx) @@ -156,7 +156,7 @@ WRITE8_MEMBER(a800_rom_oss34_device::write_d5xx) break; case 2: case 6: - m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff + m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff break; case 3: case 7: @@ -173,11 +173,11 @@ WRITE8_MEMBER(a800_rom_oss34_device::write_d5xx) /*------------------------------------------------- - + OSS 043M - + Same as above but with correct bank order - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_oss43_device::read_80xx) @@ -200,7 +200,7 @@ WRITE8_MEMBER(a800_rom_oss43_device::write_d5xx) break; case 2: case 6: - m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff + m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff break; case 3: case 7: @@ -217,12 +217,12 @@ WRITE8_MEMBER(a800_rom_oss43_device::write_d5xx) /*------------------------------------------------- - + OSS M091 - - Simplified banking system which only uses two + + Simplified banking system which only uses two address lines (A0 & A3) - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_oss91_device::read_80xx) @@ -250,4 +250,3 @@ WRITE8_MEMBER(a800_rom_oss91_device::write_d5xx) break; } } - diff --git a/src/emu/bus/a800/oss.h b/src/emu/bus/a800/oss.h index 5aef80526df..ad772689277 100644 --- a/src/emu/bus/a800/oss.h +++ b/src/emu/bus/a800/oss.h @@ -13,14 +13,14 @@ class a800_rom_oss8k_device : public a800_rom_device public: // construction/destruction a800_rom_oss8k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -53,14 +53,14 @@ class a800_rom_oss43_device : public a800_rom_device public: // construction/destruction a800_rom_oss43_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -73,14 +73,14 @@ class a800_rom_oss91_device : public a800_rom_device public: // construction/destruction a800_rom_oss91_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; diff --git a/src/emu/bus/a800/rom.c b/src/emu/bus/a800/rom.c index b527c3b228d..ed11faa7d7b 100644 --- a/src/emu/bus/a800/rom.c +++ b/src/emu/bus/a800/rom.c @@ -3,7 +3,7 @@ /*********************************************************************************************************** A800/A5200/XEGS ROM cart emulation - + Basic carts work the same (in addition of being mostly compatible) for all these systems and thus we deal with them in a single file @@ -196,7 +196,7 @@ void a5200_rom_bbsb_device::device_reset() /*------------------------------------------------- Carts with no bankswitch (8K, 16K) - + The cart accessors are mapped in the correct range at driver start @@ -210,14 +210,14 @@ READ8_MEMBER(a800_rom_device::read_80xx) /*------------------------------------------------- - + Bounty Bob Strikes Back! cart (40K) - + Area 0xa000-0xbfff always point to last 8K bank - Areas 0x8000-0x8fff and 0x9000-0x9fff are + Areas 0x8000-0x8fff and 0x9000-0x9fff are separate banks of 4K mapped either in the first 16K chunk or in the second 16K chunk - Bankswitch is controlled by data written in + Bankswitch is controlled by data written in 0x8000-0x8fff and 0x9000-0x9fff respectively -------------------------------------------------*/ @@ -240,12 +240,12 @@ WRITE8_MEMBER(a800_rom_bbsb_device::write_80xx) } /*------------------------------------------------- - + XEGS carts (32K, 64K or 128K) - - Bankswitch is controlled by data written in + + Bankswitch is controlled by data written in 0xd500-0xd5ff - + -------------------------------------------------*/ READ8_MEMBER(xegs_rom_device::read_80xx) @@ -253,8 +253,8 @@ READ8_MEMBER(xegs_rom_device::read_80xx) if (offset < 0x2000) return m_rom[(offset & 0x1fff) + (m_bank * 0x2000)]; else - return m_rom[(offset & 0x1fff) + (m_bank_mask * 0x2000)]; // always last 8K bank - + return m_rom[(offset & 0x1fff) + (m_bank_mask * 0x2000)]; // always last 8K bank + } WRITE8_MEMBER(xegs_rom_device::write_d5xx) @@ -264,16 +264,16 @@ WRITE8_MEMBER(xegs_rom_device::write_d5xx) /*------------------------------------------------- - + Williams 64K - + The rom is accessed in 8K chunks at 0xa000-0xbfff Bankswitch is controlled by writing to 7 diff - offsets (their location varies with the cart type): - offs 0 points to bank 0, offs 1 points to bank 1, - and so on... the rom can be disabled by writing to + offsets (their location varies with the cart type): + offs 0 points to bank 0, offs 1 points to bank 1, + and so on... the rom can be disabled by writing to the offsets 0x8-0xf of the same range as the bankswitch - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_williams_device::read_80xx) @@ -287,16 +287,16 @@ WRITE8_MEMBER(a800_rom_williams_device::write_d5xx) } /*------------------------------------------------- - + Express 64K / Diamond 64K carts - + The rom is accessed in 8K chunks at 0xa000-0xbfff - Bankswitch is the same as above, but writes trigger - banks in reverse order: offs 7 points to bank 0, offs 6 + Bankswitch is the same as above, but writes trigger + banks in reverse order: offs 7 points to bank 0, offs 6 points to bank 1, and so on... the rom can be disabled by writing to the offsets 0x8-0xf of the same range as the bankswitch - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_express_device::read_80xx) @@ -311,10 +311,10 @@ WRITE8_MEMBER(a800_rom_express_device::write_d5xx) /*------------------------------------------------- - + Turbosoft 64K / 128K - - + + -------------------------------------------------*/ READ8_MEMBER(a800_rom_turbo_device::read_80xx) @@ -329,10 +329,10 @@ WRITE8_MEMBER(a800_rom_turbo_device::write_d5xx) /*------------------------------------------------- - + Telelink II - - + + -------------------------------------------------*/ READ8_MEMBER(a800_rom_telelink2_device::read_80xx) @@ -347,7 +347,7 @@ READ8_MEMBER(a800_rom_telelink2_device::read_80xx) WRITE8_MEMBER(a800_rom_telelink2_device::write_80xx) { - m_nvram[offset & 0xff] = data | 0xf0; // low 4bits only + m_nvram[offset & 0xff] = data | 0xf0; // low 4bits only } READ8_MEMBER(a800_rom_telelink2_device::read_d5xx) @@ -364,10 +364,10 @@ WRITE8_MEMBER(a800_rom_telelink2_device::write_d5xx) /*------------------------------------------------- - + SITSA Microcalc - - + + -------------------------------------------------*/ READ8_MEMBER(a800_rom_microcalc_device::read_80xx) @@ -386,21 +386,21 @@ WRITE8_MEMBER(a800_rom_microcalc_device::write_d5xx) /*------------------------------------------------- - + Carts with no bankswitch (4K, 8K, 16K, 32K) - + Same as base carts above - + -------------------------------------------------*/ /*------------------------------------------------- - + Carts with 2x8K (16K) with A13 line not connected - + Range 0x4000-0x7fff contains two copies of the low 8K, range 0x8000-0xbfff contains two copies of the high 8K - + -------------------------------------------------*/ READ8_MEMBER(a5200_rom_2chips_device::read_80xx) @@ -413,18 +413,18 @@ READ8_MEMBER(a5200_rom_2chips_device::read_80xx) /*------------------------------------------------- - + Bounty Bob Strikes Back! cart (40K) - + Similar to the A800 version, but: Area 0x8000-0xbfff always point to last 8K bank (repeated twice) - Areas 0x4000-0x4fff and 0x5000-0x5fff are + Areas 0x4000-0x4fff and 0x5000-0x5fff are separate banks of 4K mapped either in the first 16K chunk or in the second 16K chunk - Bankswitch is controlled by data written in + Bankswitch is controlled by data written in 0x4000-0x4fff and 0x5000-0x5fff respectively - + -------------------------------------------------*/ READ8_MEMBER(a5200_rom_bbsb_device::read_80xx) @@ -445,4 +445,3 @@ WRITE8_MEMBER(a5200_rom_bbsb_device::write_80xx) if (addr >= 0xff6 && addr <= 0xff9) m_banks[BIT(offset, 12)] = (addr - 0xff6); } - diff --git a/src/emu/bus/a800/rom.h b/src/emu/bus/a800/rom.h index 55bb728a94f..4c4ea9b30c2 100644 --- a/src/emu/bus/a800/rom.h +++ b/src/emu/bus/a800/rom.h @@ -31,14 +31,14 @@ class a800_rom_bbsb_device : public a800_rom_device public: // construction/destruction a800_rom_bbsb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_80xx); - + protected: int m_banks[2]; }; @@ -51,14 +51,14 @@ class a800_rom_williams_device : public a800_rom_device public: // construction/destruction a800_rom_williams_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -71,14 +71,14 @@ class a800_rom_express_device : public a800_rom_device public: // construction/destruction a800_rom_express_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -91,11 +91,11 @@ class a800_rom_blizzard_device : public a800_rom_device public: // construction/destruction a800_rom_blizzard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); }; @@ -107,14 +107,14 @@ class a800_rom_turbo_device : public a800_rom_device public: // construction/destruction a800_rom_turbo_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -127,7 +127,7 @@ class a800_rom_telelink2_device : public a800_rom_device public: // construction/destruction a800_rom_telelink2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_80xx); virtual DECLARE_READ8_MEMBER(read_d5xx); @@ -142,14 +142,14 @@ class a800_rom_microcalc_device : public a800_rom_device public: // construction/destruction a800_rom_microcalc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -162,14 +162,14 @@ class xegs_rom_device : public a800_rom_device public: // construction/destruction xegs_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank; }; @@ -182,7 +182,7 @@ class a5200_rom_2chips_device : public a800_rom_device public: // construction/destruction a5200_rom_2chips_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + virtual DECLARE_READ8_MEMBER(read_80xx); }; @@ -194,14 +194,14 @@ class a5200_rom_bbsb_device : public a800_rom_device public: // construction/destruction a5200_rom_bbsb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_80xx); - + protected: int m_banks[2]; }; diff --git a/src/emu/bus/a800/sparta.c b/src/emu/bus/a800/sparta.c index 316dacb9fe9..a742be866c3 100644 --- a/src/emu/bus/a800/sparta.c +++ b/src/emu/bus/a800/sparta.c @@ -43,14 +43,14 @@ void a800_rom_spartados_device::device_reset() -------------------------------------------------*/ /*------------------------------------------------- - + SpartaDOS 64K carts - - Similar to Express / Diamond carts, because - bankswitch is controlled by writing to 7 diff - offsets in reverse order, but writes to offsets + + Similar to Express / Diamond carts, because + bankswitch is controlled by writing to 7 diff + offsets in reverse order, but writes to offsets 0x8-0xf also enable/disable subslot - + -------------------------------------------------*/ READ8_MEMBER(a800_rom_spartados_device::read_80xx) @@ -58,7 +58,7 @@ READ8_MEMBER(a800_rom_spartados_device::read_80xx) if (!m_subslot_enabled) return m_rom[(offset & 0x1fff) + (m_bank * 0x2000)]; else - return 0xff; // subslot, currently not implemented + return 0xff; // subslot, currently not implemented } WRITE8_MEMBER(a800_rom_spartados_device::write_d5xx) @@ -69,4 +69,3 @@ WRITE8_MEMBER(a800_rom_spartados_device::write_d5xx) m_bank = (offset ^ 0x07) & 0x0f; } - diff --git a/src/emu/bus/a800/sparta.h b/src/emu/bus/a800/sparta.h index ef6033e7716..983c5ba9200 100644 --- a/src/emu/bus/a800/sparta.h +++ b/src/emu/bus/a800/sparta.h @@ -13,14 +13,14 @@ class a800_rom_spartados_device : public a800_rom_device public: // construction/destruction a800_rom_spartados_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + virtual DECLARE_READ8_MEMBER(read_80xx); virtual DECLARE_WRITE8_MEMBER(write_d5xx); - + protected: int m_bank, m_subslot_enabled; }; diff --git a/src/emu/bus/apf/rom.h b/src/emu/bus/apf/rom.h index c1a674803cd..0db205afda5 100644 --- a/src/emu/bus/apf/rom.h +++ b/src/emu/bus/apf/rom.h @@ -43,7 +43,7 @@ class apf_spacedst_device : public apf_rom_device public: // construction/destruction apf_spacedst_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); diff --git a/src/emu/bus/apf/slot.c b/src/emu/bus/apf/slot.c index 504bd699389..6a92271fc7c 100644 --- a/src/emu/bus/apf/slot.c +++ b/src/emu/bus/apf/slot.c @@ -169,9 +169,9 @@ bool apf_cart_slot_device::call_load() seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, tag()); - + if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else @@ -294,5 +294,3 @@ WRITE8_MEMBER(apf_cart_slot_device::write_ram) if (m_cart) m_cart->write_ram(space, offset, data); } - - diff --git a/src/emu/bus/apf/slot.h b/src/emu/bus/apf/slot.h index d0c5903bc21..e40894b2cbe 100644 --- a/src/emu/bus/apf/slot.h +++ b/src/emu/bus/apf/slot.h @@ -39,7 +39,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_ram_size() { return m_ram.count(); } - void save_ram() { device().save_item(NAME(m_ram)); } + void save_ram() { device().save_item(NAME(m_ram)); } protected: // internal state @@ -71,7 +71,7 @@ public: int get_type() { return m_type; } - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -112,6 +112,5 @@ extern const device_type APF_CART_SLOT; #define MCFG_APF_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, APF_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/arcadia/slot.c b/src/emu/bus/arcadia/slot.c index 96eba58bfcc..13ed093e412 100644 --- a/src/emu/bus/arcadia/slot.c +++ b/src/emu/bus/arcadia/slot.c @@ -155,7 +155,7 @@ bool arcadia_cart_slot_device::call_load() UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom"); m_cart->rom_alloc(len, tag()); - + if (software_entry() == NULL) fread(m_cart->get_rom_base(), len); else @@ -260,4 +260,3 @@ READ8_MEMBER(arcadia_cart_slot_device::extra_rom) else return 0xff; } - diff --git a/src/emu/bus/arcadia/slot.h b/src/emu/bus/arcadia/slot.h index 71cd5e0dc96..ce9f6363dbd 100644 --- a/src/emu/bus/arcadia/slot.h +++ b/src/emu/bus/arcadia/slot.h @@ -99,6 +99,5 @@ extern const device_type EA2001_CART_SLOT; #define MCFG_ARCADIA_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, EA2001_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/c64/dela_ep256.c b/src/emu/bus/c64/dela_ep256.c index 9a9e6748c11..aa360b6c7b3 100644 --- a/src/emu/bus/c64/dela_ep256.c +++ b/src/emu/bus/c64/dela_ep256.c @@ -73,7 +73,7 @@ c64_dela_ep256_cartridge_device::c64_dela_ep256_cartridge_device(const machine_c char str[6]; sprintf(str, "rom%i", i + 1); m_eproms[i] = subdevice(str); - } + } } diff --git a/src/emu/bus/c64/rex_ep256.h b/src/emu/bus/c64/rex_ep256.h index e69c8c2fba2..8e791966ac9 100644 --- a/src/emu/bus/c64/rex_ep256.h +++ b/src/emu/bus/c64/rex_ep256.h @@ -49,7 +49,7 @@ protected: private: generic_slot_device *m_eproms[8]; - + UINT8 m_bank, m_socket; int m_reset; }; diff --git a/src/emu/bus/centronics/digiblst.h b/src/emu/bus/centronics/digiblst.h index 8ff24c8c434..3e66942961b 100644 --- a/src/emu/bus/centronics/digiblst.h +++ b/src/emu/bus/centronics/digiblst.h @@ -1,11 +1,11 @@ /* * digiblst.h * - * Digiblaster - a DIY printer port DAC for the Amstrad CPC - * Printed in the German magazine CPC Amstrad International issue 8-9/1991 - * Uses Strobe (inverted on the CPC) for the 8th bit (CPCs only have 7-bit printer ports) + * Digiblaster - a DIY printer port DAC for the Amstrad CPC + * Printed in the German magazine CPC Amstrad International issue 8-9/1991 + * Uses Strobe (inverted on the CPC) for the 8th bit (CPCs only have 7-bit printer ports) * - * Code borrows from the Covox Speech Thing device. + * Code borrows from the Covox Speech Thing device. * * Created on: 23/08/2014 */ diff --git a/src/emu/bus/chanf/rom.c b/src/emu/bus/chanf/rom.c index 01d681bf59b..d2b946269b7 100644 --- a/src/emu/bus/chanf/rom.c +++ b/src/emu/bus/chanf/rom.c @@ -164,7 +164,7 @@ UINT8 chanf_rom_device::common_read_2102(UINT32 offset) m_data0 = m_ram[m_addr] & 1; return (m_latch[0] & 0x7f) | (m_data0 << 7); } - + return m_latch[0]; } else @@ -176,10 +176,10 @@ void chanf_rom_device::common_write_2102(UINT32 offset, UINT8 data) if (offset == 0) { m_latch[0] = data; - + m_read_write = BIT(data, 0); - m_addr_latch = (m_addr_latch & 0x3f3) | (BIT(data, 2) << 2) | (BIT(data, 1) << 3); // bits 2,3 come from this write! + m_addr_latch = (m_addr_latch & 0x3f3) | (BIT(data, 2) << 2) | (BIT(data, 1) << 3); // bits 2,3 come from this write! m_addr = m_addr_latch; m_data0 = BIT(data, 3); @@ -199,7 +199,7 @@ void chanf_rom_device::common_write_2102(UINT32 offset, UINT8 data) // These are shared among Schach & Multigame cart types (not directly used by base chanf_rom_device) UINT8 chanf_rom_device::common_read_3853(UINT32 offset) -{ +{ if (offset < m_ram.count()) return m_ram[offset]; else @@ -207,7 +207,7 @@ UINT8 chanf_rom_device::common_read_3853(UINT32 offset) } void chanf_rom_device::common_write_3853(UINT32 offset, UINT8 data) -{ +{ if (offset < m_ram.count()) m_ram[offset] = data; } @@ -240,4 +240,3 @@ WRITE8_MEMBER(chanf_multi_final_device::write_bank) m_base_bank = data & 0x1f; m_half_bank = BIT(data, 5); } - diff --git a/src/emu/bus/chanf/rom.h b/src/emu/bus/chanf/rom.h index 272f0301012..e2afa9da580 100644 --- a/src/emu/bus/chanf/rom.h +++ b/src/emu/bus/chanf/rom.h @@ -24,14 +24,14 @@ public: UINT8 common_read_3853(UINT32 offset); void common_write_2102(UINT32 offset, UINT8 data); void common_write_3853(UINT32 offset, UINT8 data); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); - + protected: // used for RAM chip in Hangman & Maze - UINT8 m_latch[2]; // PORT A & PORT B + UINT8 m_latch[2]; // PORT A & PORT B UINT16 m_addr_latch, m_addr; int m_read_write, m_data0; }; @@ -43,11 +43,11 @@ class chanf_maze_device : public chanf_rom_device public: // construction/destruction chanf_maze_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_2102(offset); } virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_2102(offset, data); } @@ -61,11 +61,11 @@ class chanf_hangman_device : public chanf_rom_device public: // construction/destruction chanf_hangman_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_2102(offset); } virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_2102(offset, data); } @@ -79,7 +79,7 @@ class chanf_chess_device : public chanf_rom_device public: // construction/destruction chanf_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); } virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_3853(offset, data); } @@ -93,11 +93,11 @@ class chanf_multi_old_device : public chanf_rom_device public: // construction/destruction chanf_multi_old_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); } @@ -116,17 +116,17 @@ class chanf_multi_final_device : public chanf_rom_device public: // construction/destruction chanf_multi_final_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ8_MEMBER(read_ram) { return common_read_3853(offset); } virtual DECLARE_WRITE8_MEMBER(write_ram) { common_write_3853(offset, data); } virtual DECLARE_WRITE8_MEMBER(write_bank); - + private: int m_base_bank, m_half_bank; }; diff --git a/src/emu/bus/chanf/slot.c b/src/emu/bus/chanf/slot.c index 32f2e470b0d..e42a69629b9 100644 --- a/src/emu/bus/chanf/slot.c +++ b/src/emu/bus/chanf/slot.c @@ -178,9 +178,9 @@ bool channelf_cart_slot_device::call_load() // we default to "chess" slot because some homebrew programs have been written to run // on PCBs with RAM at $2000-$2800 as Saba Schach! if (len == 0x40000) - m_type = CF_MULTI; // TODO1: differentiate multicart final and earlier from fullpath + m_type = CF_MULTI; // TODO1: differentiate multicart final and earlier from fullpath else - m_type = CF_CHESS; // TODO2: is there any way to detect Maze and Hangman from fullpath? + m_type = CF_CHESS; // TODO2: is there any way to detect Maze and Hangman from fullpath? m_cart->ram_alloc(0x800); } @@ -226,17 +226,17 @@ void channelf_cart_slot_device::get_default_card_software(astring &result) const char *slot_string = "chess"; UINT32 len = core_fsize(m_file); int type; - + if (len == 0x40000) type = CF_MULTI; else - type = CF_CHESS; // is there any way to detect the other carts from fullpath? - + type = CF_CHESS; // is there any way to detect the other carts from fullpath? + slot_string = chanf_get_slot(type); - + //printf("type: %s\n", slot_string); clear(); - + result.cpy(slot_string); return; } diff --git a/src/emu/bus/chanf/slot.h b/src/emu/bus/chanf/slot.h index 24752c05df5..161eef039f8 100644 --- a/src/emu/bus/chanf/slot.h +++ b/src/emu/bus/chanf/slot.h @@ -42,7 +42,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_ram_size() { return m_ram.count(); } - void save_ram() { device().save_item(NAME(m_ram)); } + void save_ram() { device().save_item(NAME(m_ram)); } protected: // internal state @@ -74,7 +74,7 @@ public: int get_type() { return m_type; } - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -115,6 +115,5 @@ extern const device_type CHANF_CART_SLOT; #define MCFG_CHANNELF_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, CHANF_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/cpc/amdrum.h b/src/emu/bus/cpc/amdrum.h index 0abcdefb558..5439855943c 100644 --- a/src/emu/bus/cpc/amdrum.h +++ b/src/emu/bus/cpc/amdrum.h @@ -18,7 +18,7 @@ #include "sound/dac.h" class cpc_amdrum_device : public device_t, - public device_cpc_expansion_card_interface + public device_cpc_expansion_card_interface { public: // construction/destruction diff --git a/src/emu/bus/cpc/symbfac2.c b/src/emu/bus/cpc/symbfac2.c index 87df7e214d2..ccbc700f38d 100644 --- a/src/emu/bus/cpc/symbfac2.c +++ b/src/emu/bus/cpc/symbfac2.c @@ -47,11 +47,11 @@ static INPUT_PORTS_START(cpc_symbiface2) PORT_BIT(0x00000010, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("PS/2 Mouse forward button") PORT_CODE(MOUSECODE_BUTTON5) PORT_CHANGED_MEMBER(DEVICE_SELF,cpc_symbiface2_device,mouse_change_x,NULL) // TODO: mouse scroll wheel support -// PORT_START("sf2_mouse_scroll") -// PORT_BIT(0x1f , 0, IPT_TRACKBALL_Y) -// PORT_SENSITIVITY(100) -// PORT_KEYDELTA(10) -// PORT_PLAYER(1) +// PORT_START("sf2_mouse_scroll") +// PORT_BIT(0x1f , 0, IPT_TRACKBALL_Y) +// PORT_SENSITIVITY(100) +// PORT_KEYDELTA(10) +// PORT_PLAYER(1) INPUT_PORTS_END @@ -189,26 +189,26 @@ WRITE8_MEMBER(cpc_symbiface2_device::rtc_w) // PS/2 Mouse connector // #FD10 (read only) read mouse status /* - Status byte - Bit 76543210 - Use mmDDDDDD - - m: Mode - D: Use-Data - - If read and... - - m = 00 -> no more data available, you can stop reading the status for a while - m = 01 -> D = X offset (signed); you will receive positive values, if the user - is moving the mouse to the right - m = 10 -> D = Y offset (signed); you will receive positive values, if the user - is moving the mouse upwards - m = 11 -> D[bit5] = 0 -> D[bit0] = left button - D[bit1] = right button - D[bit2] = middle button - D[bit3] = forward button - D[bit4] = backward button - D[bit5] = 1 -> D[bit0-4] = scroll wheel offset (signed) + Status byte + Bit 76543210 + Use mmDDDDDD + + m: Mode + D: Use-Data + + If read and... + + m = 00 -> no more data available, you can stop reading the status for a while + m = 01 -> D = X offset (signed); you will receive positive values, if the user + is moving the mouse to the right + m = 10 -> D = Y offset (signed); you will receive positive values, if the user + is moving the mouse upwards + m = 11 -> D[bit5] = 0 -> D[bit0] = left button + D[bit1] = right button + D[bit2] = middle button + D[bit3] = forward button + D[bit4] = backward button + D[bit5] = 1 -> D[bit0-4] = scroll wheel offset (signed) */ READ8_MEMBER(cpc_symbiface2_device::mouse_r) { diff --git a/src/emu/bus/cpc/symbfac2.h b/src/emu/bus/cpc/symbfac2.h index 58a97ae12ad..bcc8f0eedba 100644 --- a/src/emu/bus/cpc/symbfac2.h +++ b/src/emu/bus/cpc/symbfac2.h @@ -14,7 +14,7 @@ #include "cpcexp.h" class cpc_symbiface2_device : public device_t, - public device_cpc_expansion_card_interface + public device_cpc_expansion_card_interface { public: // construction/destruction diff --git a/src/emu/bus/crvision/rom.c b/src/emu/bus/crvision/rom.c index 61eebfb92ac..f67a27a054e 100644 --- a/src/emu/bus/crvision/rom.c +++ b/src/emu/bus/crvision/rom.c @@ -88,7 +88,7 @@ READ8_MEMBER(crvision_rom6k_device::read_rom80) offset &= 0x1fff; if (offset < 0x1000) return m_rom[0x1000 + (offset & 0x7ff)]; - + return m_rom[offset & 0xfff]; } diff --git a/src/emu/bus/crvision/rom.h b/src/emu/bus/crvision/rom.h index 118a398b7a6..eb44fee4ef9 100644 --- a/src/emu/bus/crvision/rom.h +++ b/src/emu/bus/crvision/rom.h @@ -43,7 +43,7 @@ class crvision_rom8k_device : public crvision_rom_device public: // construction/destruction crvision_rom8k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom80); }; @@ -55,7 +55,7 @@ class crvision_rom10k_device : public crvision_rom_device public: // construction/destruction crvision_rom10k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom40); virtual DECLARE_READ8_MEMBER(read_rom80); @@ -68,7 +68,7 @@ class crvision_rom12k_device : public crvision_rom_device public: // construction/destruction crvision_rom12k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom40); virtual DECLARE_READ8_MEMBER(read_rom80); @@ -81,7 +81,7 @@ class crvision_rom16k_device : public crvision_rom_device public: // construction/destruction crvision_rom16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom80); }; @@ -93,7 +93,7 @@ class crvision_rom18k_device : public crvision_rom_device public: // construction/destruction crvision_rom18k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom40); virtual DECLARE_READ8_MEMBER(read_rom80); diff --git a/src/emu/bus/crvision/slot.c b/src/emu/bus/crvision/slot.c index b72bebd00a1..195dd476588 100644 --- a/src/emu/bus/crvision/slot.c +++ b/src/emu/bus/crvision/slot.c @@ -163,9 +163,9 @@ bool crvision_cart_slot_device::call_load() seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, tag()); - + if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else @@ -295,4 +295,3 @@ READ8_MEMBER(crvision_cart_slot_device::read_rom80) else return 0xff; } - diff --git a/src/emu/bus/crvision/slot.h b/src/emu/bus/crvision/slot.h index db59daed13c..4219c153d1f 100644 --- a/src/emu/bus/crvision/slot.h +++ b/src/emu/bus/crvision/slot.h @@ -104,6 +104,5 @@ extern const device_type CRVISION_CART_SLOT; #define MCFG_CRVISION_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, CRVISION_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/gameboy/gb_slot.h b/src/emu/bus/gameboy/gb_slot.h index b4c16bbce74..ea6036a1481 100644 --- a/src/emu/bus/gameboy/gb_slot.h +++ b/src/emu/bus/gameboy/gb_slot.h @@ -71,8 +71,8 @@ public: void set_has_battery(bool val) { has_battery = val; } bool get_has_battery() { return has_battery; } - void save_ram() { device().save_item(NAME(m_ram)); } - + void save_ram() { device().save_item(NAME(m_ram)); } + // internal state UINT8 *m_rom; UINT32 m_rom_size; @@ -122,8 +122,8 @@ public: void setup_ram(UINT8 banks); void internal_header_logging(UINT8 *ROM, UINT32 len); - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } - + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } virtual bool is_writeable() const { return 0; } diff --git a/src/emu/bus/gameboy/mbc.h b/src/emu/bus/gameboy/mbc.h index 504f2327397..f480dc875fd 100644 --- a/src/emu/bus/gameboy/mbc.h +++ b/src/emu/bus/gameboy/mbc.h @@ -183,11 +183,11 @@ class gb_rom_188in1_device : public gb_rom_mbc1_device public: // construction/destruction gb_rom_188in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start() { shared_start(); save_item(NAME(m_game_base)); }; virtual void device_reset() { shared_reset(); m_game_base = 0; }; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); diff --git a/src/emu/bus/gba/gba_slot.h b/src/emu/bus/gba/gba_slot.h index 339666db18b..79ac615d25e 100644 --- a/src/emu/bus/gba/gba_slot.h +++ b/src/emu/bus/gba/gba_slot.h @@ -42,7 +42,7 @@ public: UINT32 get_nvram_size() { return m_nvram.bytes(); } void set_rom_size(UINT32 val) { m_rom_size = val; } - void save_nvram() { device().save_item(NAME(m_nvram)); } + void save_nvram() { device().save_item(NAME(m_nvram)); } // internal state UINT32 *m_rom; // this points to the cart rom region @@ -77,7 +77,7 @@ public: void setup_ram(UINT8 banks); void internal_header_logging(UINT8 *ROM, UINT32 len); - void save_nvram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); } + void save_nvram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -175,7 +175,7 @@ static const gba_chip_fix_conflict_item gba_chip_fix_conflict_list[] = { "BR4J", GBA_CHIP_FLASH }, // 1586 - Rockman EXE 4.5 - Real Operation (JPN) { "BG8J", GBA_CHIP_EEPROM_64K }, // 1853 - Ganbare! Dodge Fighters (JPN) { "AROP", GBA_CHIP_EEPROM_4K }, // 1862 - Rocky (EUR) -// "A2YE" - 1906 - Top Gun - Combat Zones (USA) - multiple NVRAM chips detected, but none present (protection against emu?) +// "A2YE" - 1906 - Top Gun - Combat Zones (USA) - multiple NVRAM chips detected, but none present (protection against emu?) { "BKMJ", GBA_CHIP_EEPROM_4K }, // 2039 - Kim Possible (JPN) { "BKEJ", GBA_CHIP_EEPROM_64K }, // 2047 - Konjiki no Gashbell - The Card Battle for GBA (JPN) { "BKMP", GBA_CHIP_EEPROM_4K }, // 2297 - Kim Possible 2 - Drakken's Demise (EUR) diff --git a/src/emu/bus/generic/carts.c b/src/emu/bus/generic/carts.c index 244f9a28b70..91f53077054 100644 --- a/src/emu/bus/generic/carts.c +++ b/src/emu/bus/generic/carts.c @@ -1,9 +1,9 @@ // license:BSD-3-Clause // copyright-holders:etabeta /********************************************************************** - + Generic ROM / RAM socket slots - + **********************************************************************/ diff --git a/src/emu/bus/generic/ram.c b/src/emu/bus/generic/ram.c index 2750cd5de7e..4632c614cbc 100644 --- a/src/emu/bus/generic/ram.c +++ b/src/emu/bus/generic/ram.c @@ -1,21 +1,21 @@ // license:BSD-3-Clause // copyright-holders:etabeta /*********************************************************************************************************** - - + + Generic RAM socket emulation - + This offers generic access to RAM - + generic_ram_plain : returns 0xff when the system reads beyond the end of the RAM - generic_ram_linear : maps linearly the RAM in the accessed area (i.e., read/write offset is masked with + generic_ram_linear : maps linearly the RAM in the accessed area (i.e., read/write offset is masked with (RAM size - 1) ) - + TODO: - support variable RAM size - possibly support linear mapping when non-power of 2 RAMs are mapped - add support for 16bit & 32bit RAM access - + ***********************************************************************************************************/ @@ -121,4 +121,3 @@ WRITE8_MEMBER(generic_ram_linear_device::write_ram) { m_ram[offset % m_ram.bytes()] = data; } - diff --git a/src/emu/bus/generic/ram.h b/src/emu/bus/generic/ram.h index be777167a6a..7d5637286f3 100644 --- a/src/emu/bus/generic/ram.h +++ b/src/emu/bus/generic/ram.h @@ -14,14 +14,14 @@ class generic_ram_plain_device : public device_t, public: // construction/destruction generic_ram_plain_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source); - + // device-level overrides virtual void device_start(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); - + private: UINT32 m_size; }; @@ -35,14 +35,14 @@ class generic_ram_linear_device : public device_t, public: // construction/destruction generic_ram_linear_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source); - + // device-level overrides virtual void device_start(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); - + private: UINT32 m_size; }; diff --git a/src/emu/bus/generic/rom.c b/src/emu/bus/generic/rom.c index 352acc4c141..fd2107eb798 100644 --- a/src/emu/bus/generic/rom.c +++ b/src/emu/bus/generic/rom.c @@ -4,18 +4,18 @@ Generic ROM emulation (for carts and ROM sockets) - + This offers generic access to a ROM - + generic_rom_plain : returns 0xff when the system reads beyond the end of the ROM generic_rom_linear : maps linearly the ROM in the accessed area (i.e., read offset is masked with (ROM size - 1) ) generic_romram_plain : allows support for carts always containing ROM + RAM (e.g. X07) - + TODO: - possibly support linear mapping when non-power of 2 ROMs are mapped - + ***********************************************************************************************************/ @@ -120,4 +120,3 @@ WRITE8_MEMBER(generic_romram_plain_device::write_ram) if (offset < m_ram.bytes()) m_ram[offset] = data; } - diff --git a/src/emu/bus/generic/rom.h b/src/emu/bus/generic/rom.h index c41fc427018..1a9b0bd1883 100644 --- a/src/emu/bus/generic/rom.h +++ b/src/emu/bus/generic/rom.h @@ -14,7 +14,7 @@ class generic_rom_device : public device_t, public: // construction/destruction generic_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - + // device-level overrides virtual void device_start() {} }; @@ -28,7 +28,7 @@ public: // construction/destruction generic_rom_plain_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); generic_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ16_MEMBER(read16_rom); @@ -43,7 +43,7 @@ class generic_romram_plain_device : public generic_rom_plain_device public: // construction/destruction generic_romram_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); @@ -57,7 +57,7 @@ class generic_rom_linear_device : public generic_rom_device public: // construction/destruction generic_rom_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ16_MEMBER(read16_rom); diff --git a/src/emu/bus/generic/slot.c b/src/emu/bus/generic/slot.c index 119478fe38e..40f959e404e 100644 --- a/src/emu/bus/generic/slot.c +++ b/src/emu/bus/generic/slot.c @@ -3,7 +3,7 @@ /*********************************************************************************************************** Generic ROM / RAM Socket and Cartslot device - + This device offers basic RAM / ROM allocation and access The available handlers are suited for any situation where a system opens a @@ -12,12 +12,12 @@ This device is not suited whenever the system exposes additional lines to the socket/slot: e.g. whenever input/output lines are present, whenever there are lines controlling bankswitch / paging, and whenever different - cart configurations have to be supported (like some PCBs containing ROM + cart configurations have to be supported (like some PCBs containing ROM only, and other containing both ROM and RAM) In the latter situations, per-system slot devices have to be created (see e.g. APF cart slot device for an example of a simple device with multiple pcbs supported) - + ***********************************************************************************************************/ @@ -136,15 +136,15 @@ void generic_slot_device::device_config_complete() bool generic_slot_device::call_load() { if (m_cart) - { + { if (!m_device_image_load.isnull()) return m_device_image_load(*this); else { UINT32 len = common_get_size("rom"); - + rom_alloc(len, m_width, m_endianness); - common_load_rom(get_rom_base(), len, "rom"); + common_load_rom(get_rom_base(), len, "rom"); return IMAGE_INIT_PASS; } @@ -189,13 +189,13 @@ void generic_slot_device::get_default_card_software(astring &result) /************************************************** - Implementation - + Implementation + **************************************************/ /*------------------------------------------------- - common_get_size - it gets image file size both + common_get_size - it gets image file size both for fullpath and for softlist -------------------------------------------------*/ @@ -208,7 +208,7 @@ UINT32 generic_slot_device::common_get_size(const char *region) } /*------------------------------------------------- - common_load_rom - it loads from image file both + common_load_rom - it loads from image file both for fullpath and for softlist -------------------------------------------------*/ @@ -283,4 +283,3 @@ WRITE8_MEMBER(generic_slot_device::write_ram) if (m_cart) m_cart->write_ram(space, offset, data); } - diff --git a/src/emu/bus/generic/slot.h b/src/emu/bus/generic/slot.h index 9d90d3a2253..a93d7d8904e 100644 --- a/src/emu/bus/generic/slot.h +++ b/src/emu/bus/generic/slot.h @@ -93,14 +93,14 @@ public: static void static_set_device_load(device_t &device, device_image_load_delegate callback) { downcast(device).m_device_image_load = callback; } static void static_set_device_unload(device_t &device, device_image_func_delegate callback) { downcast(device).m_device_image_unload = callback; } - + void set_interface(const char * interface) { m_interface = interface; } void set_default_card(const char * def) { m_default_card = def; } void set_extensions(const char * exts) { m_extensions = exts; } void set_must_be_loaded(bool mandatory) { m_must_be_loaded = mandatory; } void set_width(int width) { m_width = width; } void set_endian(endianness_t end) { m_endianness = end; } - + // device-level overrides virtual void device_start(); virtual void device_config_complete(); @@ -168,11 +168,9 @@ extern const device_type GENERIC_SOCKET; #define MCFG_GENERIC_CARTSLOT_ADD(_tag, _slot_intf, _dev_intf) \ MCFG_DEVICE_ADD(_tag, GENERIC_SOCKET, 0) \ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) \ - MCFG_GENERIC_INTERFACE(_dev_intf) \ - + MCFG_GENERIC_INTERFACE(_dev_intf) #define MCFG_GENERIC_SOCKET_ADD(_tag, _slot_intf, _dev_intf) \ MCFG_DEVICE_ADD(_tag, GENERIC_SOCKET, 0) \ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) \ - MCFG_GENERIC_INTERFACE(_dev_intf) \ - + MCFG_GENERIC_INTERFACE(_dev_intf) #endif diff --git a/src/emu/bus/intv/ecs.c b/src/emu/bus/intv/ecs.c index 6b42f004bab..4400b5e8839 100644 --- a/src/emu/bus/intv/ecs.c +++ b/src/emu/bus/intv/ecs.c @@ -4,10 +4,10 @@ Mattel Intellivision Entertainment Computer System expansion emulation TODO: - - Make paged rom emulation more accurate (according to + - Make paged rom emulation more accurate (according to http://spatula-city.org/~im14u2c/intv/tech/ecs.html - writes to $xa5y should be available for every x and every y, i.e. we shall - have writes to every 4K chunk of the memory map, and there shall be 16 pages + writes to $xa5y should be available for every x and every y, i.e. we shall + have writes to every 4K chunk of the memory map, and there shall be 16 pages for each) Current emulation is instead tailored around the minimal usage necessary to make the main expansion and World Series Major League Baseball happy @@ -67,12 +67,12 @@ void intv_ecs_device::device_start() } void intv_ecs_device::device_reset() -{ +{ memset(m_bank_base, 0, sizeof(m_bank_base)); } void intv_ecs_device::late_subslot_setup() -{ +{ switch (m_subslot->get_type()) { case INTV_RAM: @@ -107,13 +107,13 @@ UINT8 intv_ecs_device::intv_control_r(int hand) 0xFF, 0x3F, 0x9F, 0x5F, 0xD7, 0xB7, 0x77, 0xDB, 0xBB, 0x7B, 0xDD, 0xBD, 0x7D, 0xDE, 0xBE, 0x7E }; - + static const UINT8 disc_table[] = { 0xF3, 0xE3, 0xE7, 0xF7, 0xF6, 0xE6, 0xEE, 0xFE, 0xFC, 0xEC, 0xED, 0xFD, 0xF9, 0xE9, 0xEB, 0xFB }; - + static const UINT8 discyx_table[5][5] = { { 0xE3, 0xF3, 0xFB, 0xEB, 0xE9 }, @@ -122,10 +122,10 @@ UINT8 intv_ecs_device::intv_control_r(int hand) { 0xF6, 0xE6, 0xFE, 0xEC, 0xED }, { 0xE6, 0xEE, 0xFE, 0xFC, 0xEC } }; - + int x, y; UINT8 val = 0xff; - + /* keypad */ x = m_keypad[hand]->read(); for (y = 0; y < 16; y++) @@ -135,12 +135,12 @@ UINT8 intv_ecs_device::intv_control_r(int hand) val &= keypad_table[y]; } } - + switch ((m_options->read() >> hand) & 4) { case 0: /* disc == digital */ default: - + x = m_disc[hand]->read(); for (y = 0; y < 16; y++) { @@ -150,14 +150,14 @@ UINT8 intv_ecs_device::intv_control_r(int hand) } } break; - + case 1: /* disc == _fake_ analog */ - + x = m_discx[hand]->read(); y = m_discy[hand]->read(); val &= discyx_table[y / 32][x / 32]; } - + return val; } @@ -252,7 +252,7 @@ static INPUT_PORTS_START( intv_ecs_kbd ) Bit 4 D E 2 3 W S Z X Bit 5 A CTL (right) 1 Q (up) (down) (space) Bit 6 SHIFT NC NC NC NC NC NC NC - + Shifted keys that differ from pc: Key : 1 2 5 6 7 (left) (right) (up) (down) Shift + key: = " + - / % ' ^ ? @@ -530,32 +530,32 @@ ioport_constructor intv_ecs_device::device_input_ports() const Paged ROM handling -------------------------------------------------*/ -READ16_MEMBER(intv_ecs_device::read_rom20) -{ +READ16_MEMBER(intv_ecs_device::read_rom20) +{ if (m_bank_base[2]) - return INTV_ROM16_READ(offset + 0x2000); + return INTV_ROM16_READ(offset + 0x2000); else return 0xffff; } -READ16_MEMBER(intv_ecs_device::read_rom70) -{ +READ16_MEMBER(intv_ecs_device::read_rom70) +{ if (m_bank_base[7]) return 0xffff; else - return INTV_ROM16_READ(offset + 0x7000); + return INTV_ROM16_READ(offset + 0x7000); } -READ16_MEMBER(intv_ecs_device::read_rome0) -{ +READ16_MEMBER(intv_ecs_device::read_rome0) +{ if (m_bank_base[14]) - return INTV_ROM16_READ(offset + 0xe000); - else // if WSMLB is loaded, it shall go here, otherwise 0xffff + return INTV_ROM16_READ(offset + 0xe000); + else // if WSMLB is loaded, it shall go here, otherwise 0xffff return m_subslot->read_rome0(space, offset, mem_mask); } -READ16_MEMBER(intv_ecs_device::read_romf0) -{ +READ16_MEMBER(intv_ecs_device::read_romf0) +{ // only WSMLB should come here with bank_base = 1 if (m_bank_base[15]) return m_subslot->read_romf0(space, offset + 0x1000, mem_mask); @@ -585,4 +585,3 @@ WRITE16_MEMBER(intv_ecs_device::write_ay) if (ACCESSING_BITS_0_7) return m_snd->write(space, offset, data, mem_mask); } - diff --git a/src/emu/bus/intv/ecs.h b/src/emu/bus/intv/ecs.h index 6db3609c7ce..52ca99b76e5 100644 --- a/src/emu/bus/intv/ecs.h +++ b/src/emu/bus/intv/ecs.h @@ -14,14 +14,14 @@ class intv_ecs_device : public intv_rom_device public: // construction/destruction intv_ecs_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); virtual machine_config_constructor device_mconfig_additions() const; virtual ioport_constructor device_input_ports() const; virtual const rom_entry *device_rom_region() const; - + // reading and writing // actual ECS accesses @@ -32,14 +32,14 @@ public: virtual DECLARE_READ16_MEMBER(read_romf0); // RAM virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } - virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } + virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } // AY8914 virtual DECLARE_READ16_MEMBER(read_ay); virtual DECLARE_WRITE16_MEMBER(write_ay); DECLARE_READ8_MEMBER(ay_porta_r); DECLARE_READ8_MEMBER(ay_portb_r); DECLARE_WRITE8_MEMBER(ay_porta_w); - + // passthru accesses virtual DECLARE_READ16_MEMBER(read_rom04) { return m_subslot->read_rom04(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom40) { return m_subslot->read_rom40(space, offset, mem_mask); } @@ -47,27 +47,27 @@ public: virtual DECLARE_READ16_MEMBER(read_rom50) { return m_subslot->read_rom50(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom60) { return m_subslot->read_rom60(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom80) - { + { if (m_ram88_enabled && offset >= 0x800) - return m_subslot->read_ram(space, offset & 0x7ff, mem_mask); + return m_subslot->read_ram(space, offset & 0x7ff, mem_mask); else - return m_subslot->read_rom80(space, offset, mem_mask); + return m_subslot->read_rom80(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom90) { return m_subslot->read_rom90(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_roma0) { return m_subslot->read_roma0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_romb0) { return m_subslot->read_romb0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_romc0) { return m_subslot->read_romc0(space, offset, mem_mask); } - virtual DECLARE_READ16_MEMBER(read_romd0) - { + virtual DECLARE_READ16_MEMBER(read_romd0) + { if (m_ramd0_enabled && offset < 0x800) - return m_subslot->read_ram(space, offset, mem_mask); + return m_subslot->read_ram(space, offset, mem_mask); else - return m_subslot->read_romd0(space, offset, mem_mask); + return m_subslot->read_romd0(space, offset, mem_mask); } // paged ROM banking - virtual DECLARE_WRITE16_MEMBER(write_rom20) - { + virtual DECLARE_WRITE16_MEMBER(write_rom20) + { if (offset == 0xfff) { if (data == 0x2a50) @@ -76,8 +76,8 @@ public: m_bank_base[2] = 1; } } - virtual DECLARE_WRITE16_MEMBER(write_rom70) - { + virtual DECLARE_WRITE16_MEMBER(write_rom70) + { if (offset == 0xfff) { if (data == 0x7a50) @@ -86,8 +86,8 @@ public: m_bank_base[7] = 1; } } - virtual DECLARE_WRITE16_MEMBER(write_rome0) - { + virtual DECLARE_WRITE16_MEMBER(write_rome0) + { if (offset == 0xfff) { if (data == 0xea50) @@ -96,8 +96,8 @@ public: m_bank_base[14] = 1; } } - virtual DECLARE_WRITE16_MEMBER(write_romf0) - { + virtual DECLARE_WRITE16_MEMBER(write_romf0) + { if (offset == 0xfff) { if (data == 0xfa50) @@ -112,11 +112,11 @@ public: // IntelliVoice passthru virtual DECLARE_READ16_MEMBER(read_speech) { if (m_voice_enabled) return m_subslot->read_speech(space, offset, mem_mask); else return 0xffff; } virtual DECLARE_WRITE16_MEMBER(write_speech) { if (m_voice_enabled) m_subslot->write_speech(space, offset, data, mem_mask); } - + virtual void late_subslot_setup(); UINT8 intv_control_r(int hand); - + private: required_device m_snd; diff --git a/src/emu/bus/intv/rom.c b/src/emu/bus/intv/rom.c index 6bc190f4a83..6ff9cbd58d7 100644 --- a/src/emu/bus/intv/rom.c +++ b/src/emu/bus/intv/rom.c @@ -47,4 +47,3 @@ intv_wsmlb_device::intv_wsmlb_device(const machine_config &mconfig, const char * : intv_rom_device(mconfig, INTV_ROM_WSMLB, "Intellivision World Series Baseball Cart", tag, owner, clock, "intv_wsmlb", __FILE__) { } - diff --git a/src/emu/bus/intv/rom.h b/src/emu/bus/intv/rom.h index 2eb13cc5c76..cb6947b833c 100644 --- a/src/emu/bus/intv/rom.h +++ b/src/emu/bus/intv/rom.h @@ -13,7 +13,7 @@ public: // construction/destruction intv_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); intv_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ16_MEMBER(read_rom04) { return INTV_ROM16_READ(offset + 0x0400); } virtual DECLARE_READ16_MEMBER(read_rom20) { return INTV_ROM16_READ(offset + 0x2000); } @@ -30,7 +30,7 @@ public: virtual DECLARE_READ16_MEMBER(read_romd0) { return INTV_ROM16_READ(offset + 0xd000); } virtual DECLARE_READ16_MEMBER(read_rome0) { return INTV_ROM16_READ(offset + 0xe000); } virtual DECLARE_READ16_MEMBER(read_romf0) { return INTV_ROM16_READ(offset + 0xf000); } - + // device-level overrides virtual void device_start() {} virtual void device_reset() {} @@ -43,7 +43,7 @@ class intv_ram_device : public intv_rom_device public: // construction/destruction intv_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } @@ -56,7 +56,7 @@ class intv_gfact_device : public intv_rom_device public: // construction/destruction intv_gfact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } diff --git a/src/emu/bus/intv/slot.c b/src/emu/bus/intv/slot.c index 0b60e504593..4b633fdb997 100644 --- a/src/emu/bus/intv/slot.c +++ b/src/emu/bus/intv/slot.c @@ -3,18 +3,18 @@ Mattel Intellivision cart emulation (through slot devices) - + This is a strange beast, because INTV carts had potentially access to a *LOT* of memory ranges! Quoting Joe Zbiciak's documentation for his emu (jzIntv): - - + + The Intellivision leaves many addresses available to cartridges. However, several address ranges come with caveats, such as interactions with other - devices in the system, or incompatibilities with various peripherals. - + devices in the system, or incompatibilities with various peripherals. + Below is a summary. - + ADDRESSES NOTES -------------- -------------------------------------------------------------- $0400 - $04FF RAM/ROM ok on all but Intellivision 2. @@ -26,7 +26,7 @@ $4800 ROM ok. RAM ok only if boot ROM at $7000. $4801 - $4FFF RAM/ROM ok. $5000 - $5014 ROM ok. RAM ok only if boot ROM at $7000 or $4800. - $5015 - $6FFF RAM/ROM ok. + $5015 - $6FFF RAM/ROM ok. $7000 ROM ok if no ECS. RAM at $7000 confuses EXEC boot sequence. $7001 - $77FF RAM/ROM ok if no ECS. $7800 - $7FFF ROM ok if no ECS. Do not map RAM here due to GRAM alias. @@ -38,8 +38,8 @@ $E000 - $EFFF RAM/ROM ok if no ECS. $F000 - $F7FF RAM/ROM ok. $F800 - $FFFF ROM ok. Do not map RAM here due to GRAM alias. - - + + We handle this, by always creating a 0x10000 wide ROM region to load the cart image and exposing the following (long list of) read handlers: read_rom04 @@ -58,7 +58,7 @@ read_rome0 read_romf0 Each pcb types will then use the correct ones for its wiring setup. - + The BIN+CFG format introduced by INTVPC emulator includes metadata about where to load ROM into memory in the CFG file, but we don't support it (because we don't parse the CFG at all) and we rely instead on the intv.hsi metadata for fullpath loading of @@ -69,7 +69,7 @@ TODO: - Convert also the keyboard component to be a passthru slot device - Merge some of the ROM accessor above, once it is clear which ones can be merged - + ***********************************************************************************************************/ @@ -239,16 +239,16 @@ int intv_cart_slot_device::load_fullpath() UINT8 num_segments; UINT8 start_seg; UINT8 end_seg; - + UINT32 current_address; UINT32 end_address; - + UINT8 high_byte; UINT8 low_byte; - + UINT8 *ROM; const char *file_type = filetype(); - + /* if it is in .rom format, we enter here */ if (!core_stricmp (file_type, "rom")) { @@ -256,9 +256,9 @@ int intv_cart_slot_device::load_fullpath() fread(&temp, 1); if (temp != 0xa8) return IMAGE_INIT_FAIL; - + fread(&num_segments, 1); - + fread(&temp, 1); if (temp != (num_segments ^ 0xff)) return IMAGE_INIT_FAIL; @@ -270,10 +270,10 @@ int intv_cart_slot_device::load_fullpath() { fread(&start_seg, 1); current_address = start_seg * 0x100; - + fread(&end_seg, 1); end_address = end_seg * 0x100 + 0xff; - + while (current_address <= end_address) { fread(&low_byte, 1); @@ -282,12 +282,12 @@ int intv_cart_slot_device::load_fullpath() ROM[current_address << 1] = high_byte; current_address++; } - + // Here we should calculate and compare the CRC16... fread(&temp, 1); fread(&temp, 1); } - + // Access tables and fine address restriction tables are not supported ATM for (int i = 0; i < (16 + 32 + 2); i++) { @@ -300,7 +300,7 @@ int intv_cart_slot_device::load_fullpath() { // This code is a blatant hack, due to impossibility to load a separate .cfg file in MESS. // It shall be eventually replaced by the .xml loading - + // extrainfo format // 1. mapper number (to deal with bankswitch). no bankswitch is mapper 0 (most games). // 2.->5. current images have at most 4 chunks of data. we store here block size and location to load @@ -314,7 +314,7 @@ int intv_cart_slot_device::load_fullpath() m_cart->rom_alloc(0x20000, tag()); ROM = (UINT8 *)m_cart->get_rom_base(); - + if (!hashfile_extrainfo(*this, extrainfo)) { // If no extrainfo, we assume a single 0x2000 chunk at 0x5000 @@ -329,12 +329,12 @@ int intv_cart_slot_device::load_fullpath() else { sscanf(extrainfo.cstr() ,"%d %d %d %d %d %d %d", &mapper, &rom[0], &rom[1], &rom[2], - &rom[3], &ram, &extra); + &rom[3], &ram, &extra); //printf("extrainfo: %d %d %d %d %d %d %d \n", mapper, rom[0], rom[1], rom[2], rom[3], ram, extra); - + if (mapper) logerror("Bankswitch not yet implemented!\n"); - + if (ram) { start = ((ram & 0xf0) >> 4) * 0x1000; @@ -355,25 +355,25 @@ int intv_cart_slot_device::load_fullpath() } if (extra & INTELLIVOICE_MASK) { - printf("WARNING: This game requires emulation of the IntelliVoice module.\n"); + printf("WARNING: This game requires emulation of the IntelliVoice module.\n"); } - + if (extra & ECS_MASK) { printf("WARNING: This game requires emulation of the ECS module.\n"); } - + for (int j = 0; j < 4; j++) { start = ((rom[j] & 0xf0) >> 4) * 0x1000; size = (rom[j] & 0x0f) * 0x800; - // some cart has to be loaded to 0x4800, but none of the available ones goes to 0x4000. + // some cart has to be loaded to 0x4800, but none of the available ones goes to 0x4000. // Hence, we use 0x04 << 4 in extrainfo (to reduce the stored values) and fix the value here. if (start == 0x4000) start += 0x800; - + // logerror("step %d: %d %d \n", j, start / 0x1000, size / 0x1000); - + for (int i = 0; i < size; i++) { fread(&low_byte, 1); @@ -383,7 +383,7 @@ int intv_cart_slot_device::load_fullpath() } } } - + return IMAGE_INIT_PASS; } } @@ -408,7 +408,7 @@ bool intv_cart_slot_device::call_load() // so if we are loading one of these, we allocate additional 0x2000 bytes for the paged bank if (m_type == INTV_WSMLB) extra_bank = true; - + UINT32 size = 0; UINT16 address = 0; UINT8 *ROM, *region; @@ -423,7 +423,7 @@ bool intv_cart_slot_device::call_load() if (size) { region = get_software_region(region_name[i]); - + for (int j = 0; j < size / 2; j++) { ROM[((address + j) << 1) + 1] = region[2 * j]; @@ -467,7 +467,7 @@ void intv_cart_slot_device::get_default_card_software(astring &result) UINT32 len = core_fsize(m_file); dynamic_buffer rom(len); int type = INTV_STD; - + core_fread(m_file, rom, len); if (rom[0] == 0xa8 && (rom[1] == (rom[2] ^ 0xff))) @@ -480,12 +480,12 @@ void intv_cart_slot_device::get_default_card_software(astring &result) int start; int mapper, rom[5], ram, extra; astring extrainfo; - + if (hashfile_extrainfo(*this, extrainfo)) { sscanf(extrainfo.cstr() ,"%d %d %d %d %d %d %d", &mapper, &rom[0], &rom[1], &rom[2], - &rom[3], &ram, &extra); - + &rom[3], &ram, &extra); + if (ram) { start = ((ram & 0xf0) >> 4) * 0x1000; @@ -495,7 +495,7 @@ void intv_cart_slot_device::get_default_card_software(astring &result) type = INTV_GFACT; } } - + } slot_string = intv_get_slot(type); @@ -567,6 +567,5 @@ SLOT_INTERFACE_START(intv_cart) SLOT_INTERFACE_INTERNAL("intv_wsmlb", INTV_ROM_WSMLB) SLOT_INTERFACE_INTERNAL("intv_voice", INTV_ROM_VOICE) SLOT_INTERFACE_INTERNAL("intv_ecs", INTV_ROM_ECS) -// SLOT_INTERFACE_INTERNAL("intv_keycomp", INTV_ROM_KEYCOMP) +// SLOT_INTERFACE_INTERNAL("intv_keycomp", INTV_ROM_KEYCOMP) SLOT_INTERFACE_END - diff --git a/src/emu/bus/intv/slot.h b/src/emu/bus/intv/slot.h index e14243f190f..03b3792349b 100644 --- a/src/emu/bus/intv/slot.h +++ b/src/emu/bus/intv/slot.h @@ -11,7 +11,7 @@ enum { INTV_STD = 0, INTV_RAM, - INTV_GFACT, // has RAM too but at diff offset + INTV_GFACT, // has RAM too but at diff offset INTV_WSMLB, INTV_VOICE, INTV_ECS, @@ -51,7 +51,7 @@ public: virtual DECLARE_READ16_MEMBER(read_ram) { return 0xffff; } virtual DECLARE_WRITE16_MEMBER(write_ram) {} - + // Used by IntelliVoice & ECS virtual DECLARE_READ16_MEMBER(read_ay) { return 0xffff; } virtual DECLARE_WRITE16_MEMBER(write_ay) {} @@ -71,7 +71,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_ram_size() { return m_ram.count(); } - void save_ram() { device().save_item(NAME(m_ram)); } + void save_ram() { device().save_item(NAME(m_ram)); } virtual void late_subslot_setup() {} protected: @@ -105,7 +105,7 @@ public: int get_type() { return m_type; } int load_fullpath(); - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -136,7 +136,7 @@ public: virtual DECLARE_READ16_MEMBER(read_romd0) { if (m_cart) return m_cart->read_romd0(space, offset, mem_mask); else return 0xffff; } virtual DECLARE_READ16_MEMBER(read_rome0) { if (m_cart) return m_cart->read_rome0(space, offset, mem_mask); else return 0xffff; } virtual DECLARE_READ16_MEMBER(read_romf0) { if (m_cart) return m_cart->read_romf0(space, offset, mem_mask); else return 0xffff; } - + virtual DECLARE_READ16_MEMBER(read_ay); virtual DECLARE_WRITE16_MEMBER(write_ay); virtual DECLARE_READ16_MEMBER(read_speech); @@ -176,8 +176,7 @@ extern const device_type INTV_CART_SLOT; #define MCFG_INTV_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, INTV_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) SLOT_INTERFACE_EXTERN(intv_cart); diff --git a/src/emu/bus/intv/voice.h b/src/emu/bus/intv/voice.h index 9ba16aef358..96e92bbf44c 100644 --- a/src/emu/bus/intv/voice.h +++ b/src/emu/bus/intv/voice.h @@ -13,7 +13,7 @@ class intv_voice_device : public intv_rom_device public: // construction/destruction intv_voice_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual machine_config_constructor device_mconfig_additions() const; @@ -23,7 +23,7 @@ public: // actual IntelliVoice access virtual DECLARE_READ16_MEMBER(read_speech); virtual DECLARE_WRITE16_MEMBER(write_speech); - + // passthru access virtual DECLARE_READ16_MEMBER(read_rom04) { return m_subslot->read_rom04(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom20) { return m_subslot->read_rom20(space, offset, mem_mask); } @@ -33,34 +33,34 @@ public: virtual DECLARE_READ16_MEMBER(read_rom60) { return m_subslot->read_rom60(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom70) { return m_subslot->read_rom70(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom80) - { + { if (m_ram88_enabled && offset >= 0x800) - return m_subslot->read_ram(space, offset & 0x7ff, mem_mask); + return m_subslot->read_ram(space, offset & 0x7ff, mem_mask); else - return m_subslot->read_rom80(space, offset, mem_mask); + return m_subslot->read_rom80(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rom90) { return m_subslot->read_rom90(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_roma0) { return m_subslot->read_roma0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_romb0) { return m_subslot->read_romb0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_romc0) { return m_subslot->read_romc0(space, offset, mem_mask); } - virtual DECLARE_READ16_MEMBER(read_romd0) - { + virtual DECLARE_READ16_MEMBER(read_romd0) + { if (m_ramd0_enabled && offset < 0x800) - return m_subslot->read_ram(space, offset, mem_mask); + return m_subslot->read_ram(space, offset, mem_mask); else - return m_subslot->read_romd0(space, offset, mem_mask); + return m_subslot->read_romd0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_rome0) { return m_subslot->read_rome0(space, offset, mem_mask); } virtual DECLARE_READ16_MEMBER(read_romf0) { return m_subslot->read_romf0(space, offset, mem_mask); } - + // RAM passthru write virtual DECLARE_WRITE16_MEMBER(write_88) { if (m_ram88_enabled) m_subslot->write_ram(space, offset, data, mem_mask); } virtual DECLARE_WRITE16_MEMBER(write_d0) { if (m_ramd0_enabled) m_subslot->write_ram(space, offset, data, mem_mask); } virtual DECLARE_READ16_MEMBER(read_ram) { return m_subslot->read_ram(space, offset, mem_mask); } virtual DECLARE_WRITE16_MEMBER(write_ram) { m_subslot->write_ram(space, offset, data, mem_mask); } - + virtual void late_subslot_setup(); - + private: required_device m_speech; required_device m_subslot; diff --git a/src/emu/bus/isa/sb16.c b/src/emu/bus/isa/sb16.c index 9c4e39d92b9..cff27627c2c 100644 --- a/src/emu/bus/isa/sb16.c +++ b/src/emu/bus/isa/sb16.c @@ -370,12 +370,12 @@ ROM_END static ADDRESS_MAP_START(sb16_io, AS_IO, 8, sb16_lle_device) AM_RANGE(0x0000, 0x0000) AM_MIRROR(0xff00) AM_READWRITE(dsp_data_r, dsp_data_w) -// AM_RANGE(0x0001, 0x0001) // MIDI related? -// AM_RANGE(0x0002, 0x0002) +// AM_RANGE(0x0001, 0x0001) // MIDI related? +// AM_RANGE(0x0002, 0x0002) AM_RANGE(0x0004, 0x0004) AM_MIRROR(0xff00) AM_READWRITE(mode_r, mode_w) AM_RANGE(0x0005, 0x0005) AM_MIRROR(0xff00) AM_READWRITE(dac_ctrl_r, dac_ctrl_w) AM_RANGE(0x0006, 0x0006) AM_MIRROR(0xff00) AM_READ(dma_stat_r) -// AM_RANGE(0x0007, 0x0007) // unknown +// AM_RANGE(0x0007, 0x0007) // unknown AM_RANGE(0x0008, 0x0008) AM_MIRROR(0xff00) AM_READWRITE(ctrl8_r, ctrl8_w) AM_RANGE(0x0009, 0x0009) AM_MIRROR(0xff00) AM_WRITE(rate_w) AM_RANGE(0x000A, 0x000A) AM_MIRROR(0xff00) AM_READ(dma8_cnt_lo_r) @@ -393,9 +393,9 @@ static ADDRESS_MAP_START(sb16_io, AS_IO, 8, sb16_lle_device) AM_RANGE(0x001B, 0x001B) AM_MIRROR(0xff00) AM_READ(adc_data_r) AM_RANGE(0x001D, 0x001D) AM_MIRROR(0xff00) AM_WRITE(dma8_w) AM_RANGE(0x001F, 0x001F) AM_MIRROR(0xff00) AM_READ(dma8_r) -// AM_RANGE(0x0080, 0x0080) // ASP comms -// AM_RANGE(0x0081, 0x0081) -// AM_RANGE(0x0082, 0x0082) +// AM_RANGE(0x0080, 0x0080) // ASP comms +// AM_RANGE(0x0081, 0x0081) +// AM_RANGE(0x0082, 0x0082) AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(p1_r, p1_w) AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_READWRITE(p2_r, p2_w) ADDRESS_MAP_END diff --git a/src/emu/bus/isa/svga_trident.c b/src/emu/bus/isa/svga_trident.c index f5885769e2a..feea3722dde 100644 --- a/src/emu/bus/isa/svga_trident.c +++ b/src/emu/bus/isa/svga_trident.c @@ -87,10 +87,10 @@ void isa8_svga_tgui9680_device::device_start() m_isa->install_memory(0xa0000, 0xbffff, 0, 0, read8_delegate(FUNC(trident_vga_device::mem_r),m_vga), write8_delegate(FUNC(trident_vga_device::mem_w),m_vga)); // uncomment to test Windows 3.1 TGUI9440AGi driver -// m_isa->install_memory(0x4400000, 0x45fffff, 0, 0, read8_delegate(FUNC(trident_vga_device::vram_r),m_vga), write8_delegate(FUNC(trident_vga_device::vram_w),m_vga)); +// m_isa->install_memory(0x4400000, 0x45fffff, 0, 0, read8_delegate(FUNC(trident_vga_device::vram_r),m_vga), write8_delegate(FUNC(trident_vga_device::vram_w),m_vga)); // win95 drivers -// m_isa->install_memory(0x4000000, 0x41fffff, 0, 0, read8_delegate(FUNC(trident_vga_device::vram_r),m_vga), write8_delegate(FUNC(trident_vga_device::vram_w),m_vga)); +// m_isa->install_memory(0x4000000, 0x41fffff, 0, 0, read8_delegate(FUNC(trident_vga_device::vram_r),m_vga), write8_delegate(FUNC(trident_vga_device::vram_w),m_vga)); // acceleration ports m_isa->install_device(0x2120, 0x21ff, 0, 0, read8_delegate(FUNC(trident_vga_device::accel_r),m_vga), write8_delegate(FUNC(trident_vga_device::accel_w),m_vga)); diff --git a/src/emu/bus/isa/trident.c b/src/emu/bus/isa/trident.c index 2ed9c76bbbd..a4afa62d9f8 100644 --- a/src/emu/bus/isa/trident.c +++ b/src/emu/bus/isa/trident.c @@ -45,21 +45,21 @@ UINT8 trident_vga_device::READPIXEL8(INT16 x, INT16 y) UINT16 trident_vga_device::READPIXEL15(INT16 x, INT16 y) { return (vga.memory[((y & 0xfff)*offset() + (x & 0xfff)*2) % vga.svga_intf.vram_size] | - (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*2)+1) % vga.svga_intf.vram_size] << 8)); + (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*2)+1) % vga.svga_intf.vram_size] << 8)); } UINT16 trident_vga_device::READPIXEL16(INT16 x, INT16 y) { return (vga.memory[((y & 0xfff)*offset() + (x & 0xfff)*2) % vga.svga_intf.vram_size] | - (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*2)+1) % vga.svga_intf.vram_size] << 8)); + (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*2)+1) % vga.svga_intf.vram_size] << 8)); } UINT32 trident_vga_device::READPIXEL32(INT16 x, INT16 y) { return (vga.memory[((y & 0xfff)*offset() + (x & 0xfff)*4) % vga.svga_intf.vram_size] | - (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+1) % vga.svga_intf.vram_size] << 8) | - (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+2) % vga.svga_intf.vram_size] << 16) | - (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+3) % vga.svga_intf.vram_size] << 24)); + (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+1) % vga.svga_intf.vram_size] << 8) | + (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+2) % vga.svga_intf.vram_size] << 16) | + (vga.memory[((y & 0xfff)*offset() + ((x & 0xfff)*4)+3) % vga.svga_intf.vram_size] << 24)); } void trident_vga_device::WRITEPIXEL8(INT16 x, INT16 y, UINT8 data) @@ -249,9 +249,9 @@ UINT32 trident_vga_device::screen_update(screen_device &screen, bitmap_rgb32 &bi for(x=0;xm_cart->read(space, offset); - } + } else return 0xffff; } @@ -114,7 +114,7 @@ WRITE16_MEMBER(md_rom_ggenie_device::write) else { m_gg_bypass = 0; - + // bit9 set = read goes to ASIC registers if (data & 0x200) m_reg_enable = 1; @@ -122,7 +122,7 @@ WRITE16_MEMBER(md_rom_ggenie_device::write) else m_reg_enable = 0; } - + // LOCK bit if (data & 0x100) { @@ -133,7 +133,7 @@ WRITE16_MEMBER(md_rom_ggenie_device::write) m_gg_addr[3] = ((m_gg_regs[11] & 0x3f) << 16) | m_gg_regs[12]; m_gg_addr[4] = ((m_gg_regs[14] & 0x3f) << 16) | m_gg_regs[15]; m_gg_addr[5] = ((m_gg_regs[17] & 0x3f) << 16) | m_gg_regs[18]; - + // data m_gg_data[0] = m_gg_regs[4]; m_gg_data[1] = m_gg_regs[7]; @@ -144,9 +144,9 @@ WRITE16_MEMBER(md_rom_ggenie_device::write) //printf("mode %X\n", data); //for (int i = 0; i < 6; i++) - // printf("addr %d = 0x%X - data 0x%X\n", i, m_gg_addr[i], m_gg_data[i]); + // printf("addr %d = 0x%X - data 0x%X\n", i, m_gg_addr[i], m_gg_data[i]); } - } + } else if (offset == 1) { // RESET diff --git a/src/emu/bus/msx_cart/disk.c b/src/emu/bus/msx_cart/disk.c index a49285fc28e..93def4a5adf 100644 --- a/src/emu/bus/msx_cart/disk.c +++ b/src/emu/bus/msx_cart/disk.c @@ -164,7 +164,7 @@ msx_cart_fsfd1::msx_cart_fsfd1(const machine_config &mconfig, const char *tag, d msx_cart_fscf351::msx_cart_fscf351(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : msx_cart_disk_type2(mconfig, MSX_CART_FSCF351, "MSX Cartridge - FS-CF351", tag, owner, clock, "msx_cart_fscf351") + : msx_cart_disk_type2(mconfig, MSX_CART_FSCF351, "MSX Cartridge - FS-CF351", tag, owner, clock, "msx_cart_fscf351") { } @@ -624,4 +624,3 @@ WRITE8_MEMBER(msx_cart_fsfd1a::write_cart) break; } } - diff --git a/src/emu/bus/msx_slot/disk.c b/src/emu/bus/msx_slot/disk.c index 04f398ef6ef..998ab6e9899 100644 --- a/src/emu/bus/msx_slot/disk.c +++ b/src/emu/bus/msx_slot/disk.c @@ -677,7 +677,7 @@ void msx_slot_disk6_device::post_load() void msx_slot_disk6_device::select_drive() { - if (m_drive_select1) + if (m_drive_select1) { m_floppy = m_floppy1 ? m_floppy1->get_device() : NULL; if (!m_floppy) @@ -809,4 +809,3 @@ WRITE8_MEMBER(msx_slot_disk6_device::write) break; } } - diff --git a/src/emu/bus/nes/disksys.c b/src/emu/bus/nes/disksys.c index 23eee5c4573..ae95074102c 100644 --- a/src/emu/bus/nes/disksys.c +++ b/src/emu/bus/nes/disksys.c @@ -11,7 +11,7 @@ Famicom Disk System. Based on info from NESDev wiki ( http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System ) - + TODO: - convert floppy drive + fds format to modern code! - add sound bits @@ -124,14 +124,14 @@ void nes_disksys_device::device_start() irq_timer = timer_alloc(TIMER_IRQ); irq_timer->adjust(attotime::zero, 0, machine().device("maincpu")->cycles_to_attotime(1)); - + save_item(NAME(m_fds_motor_on)); save_item(NAME(m_fds_door_closed)); save_item(NAME(m_fds_current_side)); save_item(NAME(m_fds_head_position)); save_item(NAME(m_fds_status0)); save_item(NAME(m_read_mode)); - save_item(NAME(m_drive_ready)); + save_item(NAME(m_drive_ready)); save_item(NAME(m_irq_enable)); save_item(NAME(m_irq_transfer)); save_item(NAME(m_irq_count)); @@ -173,8 +173,8 @@ void nes_disksys_device::pcb_reset() RAM is in 0x6000-0xdfff (32K) ROM is in 0xe000-0xffff (8K) - - registers + disk drive are accessed in + + registers + disk drive are accessed in 0x4020-0x403f (read_ex/write_ex below) -------------------------------------------------*/ @@ -210,7 +210,7 @@ READ8_MEMBER(nes_disksys_device::read_m) } void nes_disksys_device::hblank_irq(int scanline, int vblank, int blanked) -{ +{ if (m_irq_transfer) m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE); } @@ -218,7 +218,7 @@ void nes_disksys_device::hblank_irq(int scanline, int vblank, int blanked) WRITE8_MEMBER(nes_disksys_device::write_ex) { LOG_MMC(("Famicom Disk System write_ex, offset: %04x, data: %02x\n", offset, data)); - + if (offset >= 0x20 && offset < 0x60) { // wavetable @@ -255,34 +255,34 @@ WRITE8_MEMBER(nes_disksys_device::write_ex) // bit4 - CRC control (set during CRC calculation of transfer) // bit5 - Always set to '1' // bit6 - Read/Write Start (Set to 1 when the drive becomes ready for read/write) - // bit7 - Interrupt Transfer (0: Transfer without using IRQ; 1: Enable IRQ when + // bit7 - Interrupt Transfer (0: Transfer without using IRQ; 1: Enable IRQ when // the drive becomes ready) m_fds_motor_on = BIT(data, 0); - + if (BIT(data, 1)) m_fds_head_position = 0; - + if (!(data & 0x40) && m_drive_ready && m_fds_head_position > 2) m_fds_head_position -= 2; // ??? is this some sort of compensation?? - + m_read_mode = BIT(data, 2); - set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); m_drive_ready = data & 0x40; m_irq_transfer = BIT(data, 7); break; case 0x06: // external connector break; - case 0x60: // $4080 - Volume envelope - read through $4090 - case 0x62: // $4082 - Frequency low - case 0x63: // $4083 - Frequency high - case 0x64: // $4084 - Mod envelope - read through $4092 - case 0x65: // $4085 - Mod counter - case 0x66: // $4086 - Mod frequency low - case 0x67: // $4087 - Mod frequency high - case 0x68: // $4088 - Mod table write - case 0x69: // $4089 - Wave write / master volume - case 0x6a: // $408a - Envelope speed + case 0x60: // $4080 - Volume envelope - read through $4090 + case 0x62: // $4082 - Frequency low + case 0x63: // $4083 - Frequency high + case 0x64: // $4084 - Mod envelope - read through $4092 + case 0x65: // $4085 - Mod counter + case 0x66: // $4086 - Mod frequency low + case 0x67: // $4087 - Mod frequency high + case 0x68: // $4088 - Mod table write + case 0x69: // $4089 - Wave write / master volume + case 0x6a: // $408a - Envelope speed break; } } @@ -299,11 +299,11 @@ READ8_MEMBER(nes_disksys_device::read_ex) switch (offset) { - case 0x10: + case 0x10: // $4030 - disk status 0 // bit0 - Timer Interrupt (1: an IRQ occurred) - // bit1 - Byte transfer flag (Set to 1 every time 8 bits have been transfered between - // the RAM adaptor & disk drive through $4024/$4031; Reset to 0 when $4024, + // bit1 - Byte transfer flag (Set to 1 every time 8 bits have been transfered between + // the RAM adaptor & disk drive through $4024/$4031; Reset to 0 when $4024, // $4031, or $4030 has been serviced) // bit4 - CRC control (0: CRC passed; 1: CRC error) // bit6 - End of Head (1 when disk head is on the most inner track) @@ -312,7 +312,7 @@ READ8_MEMBER(nes_disksys_device::read_ex) // clear the disk IRQ detect flag m_fds_status0 &= ~0x01; break; - case 0x11: + case 0x11: // $4031 - data latch // don't read data if disk is unloaded if (!m_fds_data) @@ -330,8 +330,8 @@ READ8_MEMBER(nes_disksys_device::read_ex) else ret = 0; break; - case 0x12: - // $4032 - disk status 1: + case 0x12: + // $4032 - disk status 1: // bit0 - Disk flag (0: Disk inserted; 1: Disk not inserted) // bit1 - Ready flag (0: Disk ready; 1: Disk not ready) // bit2 - Protect flag (0: Not write protected; 1: Write protected or disk ejected) @@ -351,17 +351,17 @@ READ8_MEMBER(nes_disksys_device::read_ex) else ret = (m_fds_current_side == 0) ? 1 : 0; // 0 if a disk is inserted break; - case 0x13: + case 0x13: // $4033 - external connector (bits 0-6) + battery status (bit 7) ret = 0x80; break; - case 0x70: // $4090 - Volume gain - write through $4080 - case 0x72: // $4092 - Mod gain - read through $4084 + case 0x70: // $4090 - Volume gain - write through $4080 + case 0x72: // $4092 - Mod gain - read through $4084 default: ret = 0x00; break; } - + return ret; } @@ -372,7 +372,7 @@ READ8_MEMBER(nes_disksys_device::read_ex) void nes_disksys_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { if (id == TIMER_IRQ) - { + { if (m_irq_enable && m_irq_count) { m_irq_count--; @@ -381,7 +381,7 @@ void nes_disksys_device::device_timer(emu_timer &timer, device_timer_id id, int m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE); m_irq_enable = 0; m_fds_status0 |= 0x01; - m_irq_count_latch = 0; // used in Kaettekita Mario Bros + m_irq_count_latch = 0; // used in Kaettekita Mario Bros } } } @@ -399,7 +399,7 @@ void nes_disksys_device::disk_flip_side() if (m_fds_current_side == 0) popmessage("No disk inserted."); else - popmessage("Disk set to side %d", m_fds_current_side); + popmessage("Disk set to side %d", m_fds_current_side); } @@ -410,15 +410,15 @@ void nes_disksys_device::load_disk(device_image_interface &image) { int header = 0; m_fds_sides = 0; - + if (image.length() % 65500) header = 0x10; - + m_fds_sides = (image.length() - header) / 65500; - + if (!m_fds_data) m_fds_data = auto_alloc_array(machine(), UINT8, m_fds_sides * 65500); - + // if there is an header, skip it image.fseek(header, SEEK_SET); image.fread(m_fds_data, 65500 * m_fds_sides); @@ -430,4 +430,3 @@ void nes_disksys_device::unload_disk(device_image_interface &image) /* TODO: should write out changes here as well */ m_fds_sides = 0; } - diff --git a/src/emu/bus/nes/nes_slot.c b/src/emu/bus/nes/nes_slot.c index bcd22d74381..89107fb1664 100644 --- a/src/emu/bus/nes/nes_slot.c +++ b/src/emu/bus/nes/nes_slot.c @@ -161,9 +161,9 @@ void device_nes_cart_interface::prg_alloc(size_t size, const char *tag) printf("Warning! The loaded PRG has size not a multiple of 8KB (0x%X)\n", (UINT32)size); m_prg_chunks--; } - + m_prg_mask = ((m_prg_chunks << 1) - 1); - + // printf("first mask %x!\n", m_prg_mask); if ((m_prg_chunks << 1) & m_prg_mask) { @@ -172,7 +172,7 @@ void device_nes_cart_interface::prg_alloc(size_t size, const char *tag) // only half a dozen of NES carts have PRG which is not a power of 2 // so we use this bank_map only as an exception // printf("uneven rom!\n"); - + // 1. redefine mask as (next power of 2)-1 for (; temp; ) { @@ -182,15 +182,15 @@ void device_nes_cart_interface::prg_alloc(size_t size, const char *tag) m_prg_mask = (1 << mask_bits) - 1; // printf("new mask %x!\n", m_prg_mask); mapsize = (1 << mask_bits)/2; - + // 2. create a bank_map for banks in the range mask/2 -> mask m_prg_bank_map.resize(mapsize); - + // 3. fill the bank_map accounting for mirrors int j; for (j = mapsize; j < (m_prg_chunks << 1); j++) m_prg_bank_map[j - mapsize] = j; - + while (j % mapsize) { int k = 0, repeat_banks; @@ -201,7 +201,7 @@ void device_nes_cart_interface::prg_alloc(size_t size, const char *tag) m_prg_bank_map[(j - mapsize) + l] = m_prg_bank_map[(j - mapsize) + l - repeat_banks]; j += repeat_banks; } - + // check bank map! // for (int i = 0; i < mapsize; i++) // { @@ -674,7 +674,7 @@ void device_nes_cart_interface::pcb_start(running_machine &machine, UINT8 *ciram // main NES CPU here, even if it does not belong to this device. m_maincpu = machine.device("maincpu"); - if (cart_mounted) // disksys expansion can arrive here without the memory banks! + if (cart_mounted) // disksys expansion can arrive here without the memory banks! { // Setup PRG m_prg_bank_mem[0] = machine.root_device().membank("prg0"); @@ -691,11 +691,11 @@ void device_nes_cart_interface::pcb_start(running_machine &machine, UINT8 *ciram } } } - + // Setup CHR (VRAM can be present also without PRG rom) m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; chr8(0, m_chr_source); - + // Setup NT m_ciram = ciram_ptr; diff --git a/src/emu/bus/nes/nes_slot.h b/src/emu/bus/nes/nes_slot.h index 02e017b0923..9c73d95d17d 100644 --- a/src/emu/bus/nes/nes_slot.h +++ b/src/emu/bus/nes/nes_slot.h @@ -376,10 +376,10 @@ public: virtual DECLARE_WRITE8_MEMBER(write_m); virtual DECLARE_WRITE8_MEMBER(write_h); virtual DECLARE_WRITE8_MEMBER(write_ex); - + // hack until disk system is made modern! virtual void disk_flip_side() { if (m_cart) m_cart->disk_flip_side(); } - + int get_pcb_id() { return m_pcb_id; }; void pcb_start(UINT8 *ciram_ptr); diff --git a/src/emu/bus/odyssey2/chess.h b/src/emu/bus/odyssey2/chess.h index 8b71f56ed93..66015c033cb 100644 --- a/src/emu/bus/odyssey2/chess.h +++ b/src/emu/bus/odyssey2/chess.h @@ -12,10 +12,9 @@ class o2_chess_device : public o2_rom_device { - virtual machine_config_constructor device_mconfig_additions() const; -// virtual const rom_entry *device_rom_region() const; - +// virtual const rom_entry *device_rom_region() const; + public: // construction/destruction o2_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); diff --git a/src/emu/bus/odyssey2/rom.c b/src/emu/bus/odyssey2/rom.c index da0f02f6941..d741dcdd802 100644 --- a/src/emu/bus/odyssey2/rom.c +++ b/src/emu/bus/odyssey2/rom.c @@ -50,12 +50,12 @@ o2_rom16_device::o2_rom16_device(const machine_config &mconfig, const char *tag, //------------------------------------------------- void o2_rom_device::device_start() -{ +{ save_item(NAME(m_bank_base)); } void o2_rom_device::device_reset() -{ +{ m_bank_base = 0; } @@ -94,4 +94,3 @@ READ8_MEMBER(o2_rom16_device::read_rom0c) { return m_rom[offset + 0xc00 + (m_bank_base & 0x03) * 0x1000]; } - diff --git a/src/emu/bus/odyssey2/rom.h b/src/emu/bus/odyssey2/rom.h index 52b08a0e5e4..7a4af0a32b5 100644 --- a/src/emu/bus/odyssey2/rom.h +++ b/src/emu/bus/odyssey2/rom.h @@ -15,17 +15,17 @@ public: // construction/destruction o2_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); o2_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom04); virtual DECLARE_READ8_MEMBER(read_rom0c); - + virtual void write_bank(int bank); - + protected: int m_bank_base; }; @@ -37,7 +37,7 @@ class o2_rom12_device : public o2_rom_device public: // construction/destruction o2_rom12_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom04); virtual DECLARE_READ8_MEMBER(read_rom0c); @@ -50,7 +50,7 @@ class o2_rom16_device : public o2_rom_device public: // construction/destruction o2_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom04); virtual DECLARE_READ8_MEMBER(read_rom0c); diff --git a/src/emu/bus/odyssey2/slot.c b/src/emu/bus/odyssey2/slot.c index 12bde81adc1..c8dc8e053f5 100644 --- a/src/emu/bus/odyssey2/slot.c +++ b/src/emu/bus/odyssey2/slot.c @@ -166,7 +166,7 @@ bool o2_cart_slot_device::call_load() { UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); m_cart->rom_alloc(size, tag()); - + if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else @@ -223,7 +223,7 @@ void o2_cart_slot_device::get_default_card_software(astring &result) type = O2_ROM12; if (size == 16384) type = O2_ROM16; - + slot_string = o2_get_slot(type); //printf("type: %s\n", slot_string); @@ -278,4 +278,3 @@ SLOT_INTERFACE_START(o2_cart) SLOT_INTERFACE_INTERNAL("o2_chess", O2_ROM_CHESS) SLOT_INTERFACE_INTERNAL("o2_voice", O2_ROM_VOICE) SLOT_INTERFACE_END - diff --git a/src/emu/bus/odyssey2/slot.h b/src/emu/bus/odyssey2/slot.h index 4de4d26b9b0..fad028fc10a 100644 --- a/src/emu/bus/odyssey2/slot.h +++ b/src/emu/bus/odyssey2/slot.h @@ -92,7 +92,7 @@ public: virtual DECLARE_WRITE8_MEMBER(io_write); virtual DECLARE_READ8_MEMBER(t0_read) { if (m_cart) return m_cart->t0_read(space, offset); else return 0; } - virtual void write_bank(int bank) { if (m_cart) m_cart->write_bank(bank); } + virtual void write_bank(int bank) { if (m_cart) m_cart->write_bank(bank); } protected: @@ -114,8 +114,7 @@ extern const device_type O2_CART_SLOT; #define MCFG_O2_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, O2_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) SLOT_INTERFACE_EXTERN(o2_cart); diff --git a/src/emu/bus/odyssey2/voice.c b/src/emu/bus/odyssey2/voice.c index d229ab21934..c3f5fce565e 100644 --- a/src/emu/bus/odyssey2/voice.c +++ b/src/emu/bus/odyssey2/voice.c @@ -33,7 +33,7 @@ o2_voice_device::o2_voice_device(const machine_config &mconfig, const char *tag, void o2_voice_device::device_start() -{ +{ save_item(NAME(m_lrq_state)); } diff --git a/src/emu/bus/odyssey2/voice.h b/src/emu/bus/odyssey2/voice.h index 85339aa699f..83b8c532e1f 100644 --- a/src/emu/bus/odyssey2/voice.h +++ b/src/emu/bus/odyssey2/voice.h @@ -27,7 +27,7 @@ public: virtual DECLARE_READ8_MEMBER(read_rom04) { if (m_subslot->exists()) return m_subslot->read_rom04(space, offset); else return 0xff; } virtual DECLARE_READ8_MEMBER(read_rom0c) { if (m_subslot->exists()) return m_subslot->read_rom0c(space, offset); else return 0xff; } - virtual void write_bank(int bank) { if (m_subslot->exists()) m_subslot->write_bank(bank); } + virtual void write_bank(int bank) { if (m_subslot->exists()) m_subslot->write_bank(bank); } DECLARE_WRITE_LINE_MEMBER(lrq_callback); DECLARE_WRITE8_MEMBER(io_write); diff --git a/src/emu/bus/pet/cb2snd.c b/src/emu/bus/pet/cb2snd.c index b9e916b0e49..0ff4659a24c 100644 --- a/src/emu/bus/pet/cb2snd.c +++ b/src/emu/bus/pet/cb2snd.c @@ -65,4 +65,3 @@ DECLARE_WRITE_LINE_MEMBER( pet_userport_cb2_sound_device::input_m ) { m_dac->write_unsigned8(state ? 0xff : 0x00); } - diff --git a/src/emu/bus/rs232/xvd701.c b/src/emu/bus/rs232/xvd701.c index 4484bb2ba36..a7a1ba40eab 100644 --- a/src/emu/bus/rs232/xvd701.c +++ b/src/emu/bus/rs232/xvd701.c @@ -93,7 +93,7 @@ void jvc_xvd701_device::send_response() { if (m_response_index < sizeof(m_response) && is_transmit_register_empty()) { -// printf("sending %02x\n", m_response[m_response_index]); +// printf("sending %02x\n", m_response[m_response_index]); transmit_register_setup(m_response[m_response_index++]); } } @@ -115,7 +115,7 @@ void jvc_xvd701_device::rcv_complete() // printf("xvd701"); //for (int i = 0; i < sizeof(m_command); i++) - // printf(" %02x", m_command[i]); + // printf(" %02x", m_command[i]); //printf("\n"); diff --git a/src/emu/bus/saturn/sat_slot.c b/src/emu/bus/saturn/sat_slot.c index 1868c23de15..ebd9c6e8890 100644 --- a/src/emu/bus/saturn/sat_slot.c +++ b/src/emu/bus/saturn/sat_slot.c @@ -156,15 +156,15 @@ bool sat_cart_slot_device::call_load() // from fullpath, only ROM carts UINT32 len = (software_entry() != NULL) ? get_software_region_length("rom") : length(); UINT32 *ROM; - + m_cart->rom_alloc(len, tag()); ROM = m_cart->get_rom_base(); - + if (software_entry() != NULL) memcpy(ROM, get_software_region("rom"), len); else fread(ROM, len); - + // fix endianness.... for (int i = 0; i < len/4; i ++) ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24); diff --git a/src/emu/bus/scv/rom.h b/src/emu/bus/scv/rom.h index e765df921c9..6d8ccff4d49 100644 --- a/src/emu/bus/scv/rom.h +++ b/src/emu/bus/scv/rom.h @@ -79,11 +79,11 @@ class scv_rom64_device : public scv_rom8_device public: // construction/destruction scv_rom64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_cart); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -100,15 +100,15 @@ class scv_rom128_device : public scv_rom8_device public: // construction/destruction scv_rom128_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_cart); virtual DECLARE_WRITE8_MEMBER(write_bank); - + private: UINT8 m_bank_base; }; @@ -121,16 +121,16 @@ class scv_rom128ram4_device : public scv_rom8_device public: // construction/destruction scv_rom128ram4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_cart); virtual DECLARE_WRITE8_MEMBER(write_cart); virtual DECLARE_WRITE8_MEMBER(write_bank); - + private: UINT8 m_bank_base, m_ram_enabled; }; diff --git a/src/emu/bus/scv/slot.c b/src/emu/bus/scv/slot.c index ffffe98fcc2..dcd3639c1ed 100644 --- a/src/emu/bus/scv/slot.c +++ b/src/emu/bus/scv/slot.c @@ -175,11 +175,11 @@ bool scv_cart_slot_device::call_load() seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(len, tag()); if (has_ram) m_cart->ram_alloc(get_software_region_length("ram")); - + ROM = m_cart->get_rom_base(); if (software_entry() == NULL) @@ -317,4 +317,3 @@ WRITE8_MEMBER(scv_cart_slot_device::write_bank) if (m_cart) m_cart->write_bank(space, offset, data); } - diff --git a/src/emu/bus/scv/slot.h b/src/emu/bus/scv/slot.h index 3be1c8734b3..7db8b6eee9e 100644 --- a/src/emu/bus/scv/slot.h +++ b/src/emu/bus/scv/slot.h @@ -42,7 +42,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_ram_size() { return m_ram.count(); } - void save_ram() { device().save_item(NAME(m_ram)); } + void save_ram() { device().save_item(NAME(m_ram)); } protected: // internal state @@ -75,7 +75,7 @@ public: int get_type() { return m_type; } int get_cart_type(UINT8 *ROM, UINT32 len); - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -115,6 +115,5 @@ extern const device_type SCV_CART_SLOT; #define MCFG_SCV_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, SCV_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/sega8/ccatch.c b/src/emu/bus/sega8/ccatch.c index 3e917fa8d09..0f1b464660d 100644 --- a/src/emu/bus/sega8/ccatch.c +++ b/src/emu/bus/sega8/ccatch.c @@ -1,10 +1,10 @@ /*********************************************************************************************************** SG-1000 Card Catcher emulation - + Sega Card Catcher is a passthrough adapter for SG-1000 to load games in MyCard format into the - main cartslot + main cartslot ***********************************************************************************************************/ diff --git a/src/emu/bus/sega8/mgear.h b/src/emu/bus/sega8/mgear.h index 27672464ced..d4e800c19e8 100644 --- a/src/emu/bus/sega8/mgear.h +++ b/src/emu/bus/sega8/mgear.h @@ -12,11 +12,11 @@ class sega8_mgear_device : public sega8_rom_device public: // construction/destruction sega8_mgear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_cart) { return m_subslot->read_cart(space, offset); } virtual DECLARE_WRITE8_MEMBER(write_cart) { m_subslot->write_cart(space, offset, data); } diff --git a/src/emu/bus/sega8/rom.c b/src/emu/bus/sega8/rom.c index 9b222867ba3..436b710545c 100644 --- a/src/emu/bus/sega8/rom.c +++ b/src/emu/bus/sega8/rom.c @@ -752,7 +752,7 @@ READ8_MEMBER(sega8_4pak_device::read_cart) { int bank = offset / 0x4000; - return m_rom[m_rom_bank_base[bank] * 0x4000 + (offset & 0x3fff)]; + return m_rom[m_rom_bank_base[bank] * 0x4000 + (offset & 0x3fff)]; } diff --git a/src/emu/bus/sega8/sega8_slot.c b/src/emu/bus/sega8/sega8_slot.c index 2933929081c..5a64c283f66 100644 --- a/src/emu/bus/sega8/sega8_slot.c +++ b/src/emu/bus/sega8/sega8_slot.c @@ -873,4 +873,3 @@ SLOT_INTERFACE_START(gg_cart) SLOT_INTERFACE_INTERNAL("codemasters", SEGA8_ROM_CODEMASTERS) SLOT_INTERFACE_INTERNAL("mgear", SEGA8_ROM_MGEAR) SLOT_INTERFACE_END - diff --git a/src/emu/bus/sega8/sega8_slot.h b/src/emu/bus/sega8/sega8_slot.h index d70ae51a805..8a1caf8df9f 100644 --- a/src/emu/bus/sega8/sega8_slot.h +++ b/src/emu/bus/sega8/sega8_slot.h @@ -121,7 +121,7 @@ public: int verify_cart(UINT8 *magic, int size); void set_lphaser_xoffset(UINT8 *rom, int size); - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } void set_mandatory(bool val) { m_must_be_loaded = val; } void set_intf(const char * interface) { m_interface = interface; } diff --git a/src/emu/bus/sms_ctrl/graphic.c b/src/emu/bus/sms_ctrl/graphic.c index 6b0024d91af..20a1f68dcda 100644 --- a/src/emu/bus/sms_ctrl/graphic.c +++ b/src/emu/bus/sms_ctrl/graphic.c @@ -9,18 +9,18 @@ I/O 3f write | this method 0x20 | 0x7f 0x00 | 0x3f 0x30 | 0xff - + Typical sequence: - 3f write 0x20 - read dc - 3f write 0x00 -- read dc +- read dc - 3f write 0x20 - read dc - 3f write 0x30 Suspect from kind of counter that is reset by a 0x30 write to I/O port 0x3f. Once reset reads from i/O port dc expect to see 0xE0. -And then any write with differing bits goes through several internal I/O ports +And then any write with differing bits goes through several internal I/O ports with the first port being the one with the buttons In the reset/start state the lower four/five bits are 0. @@ -45,11 +45,11 @@ const device_type SMS_GRAPHIC = &device_creator; static INPUT_PORTS_START( sms_graphic ) - PORT_START("BUTTONS") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // MENU - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // DO - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) // PEN - PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_START("BUTTONS") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // MENU + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // DO + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) // PEN + PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("X") PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15) @@ -110,8 +110,8 @@ UINT8 sms_graphic_device::peripheral_r() { case 0: // Initial state / "I am a board" // If any regular button is pressed raise/lower TL ? -// if ((m_buttons->read() & 0x07) != 0x07) -// return 0xf0; +// if ((m_buttons->read() & 0x07) != 0x07) +// return 0xf0; return 0xd0; case 1: // Read buttons (active low) @@ -155,4 +155,3 @@ void sms_graphic_device::peripheral_w(UINT8 data) m_previous_write = data; } - diff --git a/src/emu/bus/snes/snes_slot.h b/src/emu/bus/snes/snes_slot.h index 808c2105f82..7d440437eaa 100644 --- a/src/emu/bus/snes/snes_slot.h +++ b/src/emu/bus/snes/snes_slot.h @@ -125,8 +125,8 @@ public: UINT32 get_rtc_ram_size() { return m_rtc_ram.count(); }; void rom_map_setup(UINT32 size); - void save_nvram() { device().save_item(NAME(m_nvram)); } - void save_rtc_ram() { device().save_item(NAME(m_rtc_ram)); } + void save_nvram() { device().save_item(NAME(m_nvram)); } + void save_rtc_ram() { device().save_item(NAME(m_rtc_ram)); } // internal state UINT8 *m_rom; @@ -166,7 +166,7 @@ public: void setup_nvram(); void internal_header_logging(UINT8 *ROM, UINT32 len); - void save_ram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); + void save_ram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); if (m_cart && m_cart->get_rtc_ram_size()) m_cart->save_rtc_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } diff --git a/src/emu/bus/vboy/rom.h b/src/emu/bus/vboy/rom.h index 6d474256d33..0101c303790 100644 --- a/src/emu/bus/vboy/rom.h +++ b/src/emu/bus/vboy/rom.h @@ -15,10 +15,10 @@ public: // construction/destruction vboy_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); vboy_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start() {} - + // reading and writing virtual DECLARE_READ32_MEMBER(read_cart); }; diff --git a/src/emu/bus/vboy/slot.c b/src/emu/bus/vboy/slot.c index a20d8ef5933..bcc3961e842 100644 --- a/src/emu/bus/vboy/slot.c +++ b/src/emu/bus/vboy/slot.c @@ -151,7 +151,7 @@ static const char *vboy_get_slot(int type) if (slot_list[i].pcb_id == type) return slot_list[i].slot_option; } - + return "vb_rom"; } #endif @@ -179,7 +179,7 @@ bool vboy_cart_slot_device::call_load() m_cart->rom_alloc(0x200000, tag()); if (has_eeprom) m_cart->eeprom_alloc(get_software_region_length("eeprom")); - + ROM = (UINT8 *)m_cart->get_rom_base(); if (software_entry() == NULL) @@ -190,7 +190,7 @@ bool vboy_cart_slot_device::call_load() if (len < 0x080000) { memcpy(ROM + 0x040000, ROM, 0x040000); } if (len < 0x100000) { memcpy(ROM + 0x080000, ROM, 0x080000); } if (len < 0x200000) { memcpy(ROM + 0x100000, ROM, 0x100000); } - + if (software_entry() == NULL) m_type = vboy_get_pcb_id("vb_rom"); else diff --git a/src/emu/bus/vboy/slot.h b/src/emu/bus/vboy/slot.h index 910d61ab2ea..afa33c600d4 100644 --- a/src/emu/bus/vboy/slot.h +++ b/src/emu/bus/vboy/slot.h @@ -37,7 +37,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_eeprom_size() { return m_eeprom.count(); } - void save_eeprom() { device().save_item(NAME(m_eeprom)); } + void save_eeprom() { device().save_item(NAME(m_eeprom)); } protected: // internal state @@ -71,7 +71,7 @@ public: int get_type() { return m_type; } int get_cart_type(UINT8 *ROM, UINT32 len); - void save_eeprom() { if (m_cart && m_cart->get_eeprom_size()) m_cart->save_eeprom(); } + void save_eeprom() { if (m_cart && m_cart->get_eeprom_size()) m_cart->save_eeprom(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -111,6 +111,5 @@ extern const device_type VBOY_CART_SLOT; #define MCFG_VBOY_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, VBOY_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/vc4000/rom.c b/src/emu/bus/vc4000/rom.c index f8b41852921..200d5d4127f 100644 --- a/src/emu/bus/vc4000/rom.c +++ b/src/emu/bus/vc4000/rom.c @@ -10,173 +10,173 @@ /* Game List and Emulation Status - + When you load a game it will normally appear to be unresponsive. Most carts contain a number of variants of each game (e.g. Difficulty, Player1 vs Player2 or Player1 vs Computer, etc). - + Press F2 (if needed) to select which game variant you would like to play. The variant number will increment on-screen. When you've made your choice, press F1 to start. The main keys are unlabelled, because an overlay is provided with each cart. See below for a guide. You need to read the instructions that come with each game. - + In some games, the joystick is used like 4 buttons, and other games like a paddle. The two modes are incompatible when using a keyboard. Therefore (in the emulation) a config dipswitch is used. The preferred setting is listed below. - + (AC = Auto-centre, NAC = no auto-centre, 90 = turn controller 90 degrees). - + The list is rather incomplete, information will be added as it becomes available. - + The game names and numbers were obtained from the Amigan Software site. - + Cart Num Name ---------------------------------------------- 1. Grand Prix / Car Races / Autosport / Motor Racing / Road Race Config: Paddle, NAC Status: Working Controls: Left-Right: Steer; Up: Accelerate - + 2. Black Jack Status: Not working (some digits missing; indicator missing; dealer's cards missing) Controls: set bet with S and D; A to deal; 1 to hit, 2 to stay; Q accept insurance, E to decline; double-up (unknown key) Indicator: E make a bet then deal; I choose insurance; - you lost; + you won; X hit or stay - + 3. Olympics / Paddle Games / Bat & Ball / Pro Sport 60 / Sportsworld Config: Paddle, NAC Status: Working - + 4. Tank Battle / Combat Config: Button, 90 Status: Working Controls: Left-Right: Steer; Up: Accelerate; Fire: Shoot - + 5. Maths 1 Status: Working Controls: Z difficulty; X = addition or subtraction; C ask question; A=1;S=2;D=3;Q=4;W=5;E=6;1=7;2=8;3=9;0=0; C enter - + 6. Maths 2 Status: Not working Controls: Same as above. - + 7. Air Sea Attack / Air Sea Battle Config: Button, 90 Status: Working Controls: Left-Right: Move; Fire: Shoot - + 8. Treasure Hunt / Capture the Flag / Concentration / Memory Match Config: Buttons Status: Working - + 9. Labyrinth / Maze / Intelligence 1 Config: Buttons Status: Working - + 10. Winter Sports Notes: Background colours should be Cyan and White instead of Red and Black - + 11. Hippodrome / Horse Race - + 12. Hunting / Shooting Gallery - + 13. Chess 1 Status: Can't see what you're typing, wrong colours - + 14. Moto-cros - + 15. Four in a row / Intelligence 2 Config: Buttons Status: Working Notes: Seems the unused squares should be black. The screen jumps about while the computer is "thinking". - + 16. Code Breaker / Master Mind / Intelligence 3 / Challenge - + 17. Circus STatus: severe gfx issues - + 18. Boxing / Prize Fight - + 19. Outer Space / Spacewar / Space Attack / Outer Space Combat - + 20. Melody Simon / Musical Memory / Follow the Leader / Musical Games / Electronic Music / Face the Music - + 21. Capture / Othello / Reversi / Attack / Intelligence 4 Config: Buttons Status: Working Notes: Seems the unused squares should be black - + 22. Chess 2 Status: Can't see what you're typing, wrong colours - + 23. Pinball / Flipper / Arcade Status: gfx issues - + 24. Soccer - + 25. Bowling / NinePins Config: Paddle, rotated 90 degrees, up/down autocentre, left-right does not Status: Working - + 26. Draughts - + 27. Golf Status: gfx issues - + 28. Cockpit Status: gfx issues - + 29. Metropolis / Hangman Status: gfx issues - + 30. Solitaire - + 31. Casino Status: gfx issues, items missing and unplayable Controls: 1 or 3=START; q=GO; E=STOP; D=$; Z=^; X=tens; C=units - + 32. Invaders / Alien Invasion / Earth Invasion Status: Works Config: Buttons - + 33. Super Invaders Status: Stars are missing, colours are wrong Config: Buttons (90) - + 36. BackGammon Status: Not all counters are visible, Dice & game number not visible. Controls: Fire=Exec; 1=D+; 3=D-; Q,W,E=4,5,6; A,S,D=1,2,3; Z=CL; X=STOP; C=SET - + 37. Monster Man / Spider's Web Status: Works Config: Buttons - + 38. Hyperspace Status: Works Config: Buttons (90) Controls: 3 - status button; Q,W,E,A,S,D,Z,X,C selects which galaxy to visit - - + + 40. Super Space Status: Works, some small gfx issues near the bottom Config: Buttons - - - + + + Acetronic: (dumps are compatible) ------------ - + * Shooting Gallery Status: works but screen flickers Config: Buttons - + * Planet Defender Status: Works Config: Paddle (NAC) - + * Laser Attack Status: Works Config: Buttons - - - + + + Public Domain: (written for emulators, may not work on real hardware) --------------- * Picture (no controls) - works diff --git a/src/emu/bus/vc4000/rom.h b/src/emu/bus/vc4000/rom.h index ac64abee2de..53ef34a4805 100644 --- a/src/emu/bus/vc4000/rom.h +++ b/src/emu/bus/vc4000/rom.h @@ -31,7 +31,7 @@ class vc4000_ram1k_device : public vc4000_rom_device public: // construction/destruction vc4000_ram1k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); @@ -44,7 +44,7 @@ class vc4000_chess2_device : public vc4000_rom_device public: // construction/destruction vc4000_chess2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(extra_rom); virtual DECLARE_READ8_MEMBER(read_ram); diff --git a/src/emu/bus/vc4000/slot.c b/src/emu/bus/vc4000/slot.c index b9524565f77..43fbfa992e2 100644 --- a/src/emu/bus/vc4000/slot.c +++ b/src/emu/bus/vc4000/slot.c @@ -169,9 +169,9 @@ bool vc4000_cart_slot_device::call_load() seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for a VC4000 cart"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, tag()); - + if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else @@ -236,7 +236,7 @@ void vc4000_cart_slot_device::get_default_card_software(astring &result) type = VC4000_CHESS2; else if (size > 0x0800) // some 4k roms have 1k of mirrored ram type = VC4000_RAM1K; - + slot_string = vc4000_get_slot(type); //printf("type: %s\n", slot_string); @@ -294,5 +294,3 @@ WRITE8_MEMBER(vc4000_cart_slot_device::write_ram) if (m_cart) m_cart->write_ram(space, offset, data); } - - diff --git a/src/emu/bus/vc4000/slot.h b/src/emu/bus/vc4000/slot.h index 5f992d342aa..c4226d1c9b9 100644 --- a/src/emu/bus/vc4000/slot.h +++ b/src/emu/bus/vc4000/slot.h @@ -39,7 +39,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_ram_size() { return m_ram.count(); } - void save_ram() { device().save_item(NAME(m_ram)); } + void save_ram() { device().save_item(NAME(m_ram)); } protected: // internal state @@ -71,7 +71,7 @@ public: int get_type() { return m_type; } - void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -112,6 +112,5 @@ extern const device_type VC4000_CART_SLOT; #define MCFG_VC4000_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, VC4000_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/vcs/compumat.c b/src/emu/bus/vcs/compumat.c index fe67e120c41..57de9257711 100644 --- a/src/emu/bus/vcs/compumat.c +++ b/src/emu/bus/vcs/compumat.c @@ -1,10 +1,10 @@ /*************************************************************************** - Atari 2600 cart Spectravideo Compumate (Cart + keyboard!) + Atari 2600 cart Spectravideo Compumate (Cart + keyboard!) This is tricky to implement and it is only a skeleton ATM. The device needs to interface with both the TIA and the RIOT. - + ***************************************************************************/ diff --git a/src/emu/bus/vcs/compumat.h b/src/emu/bus/vcs/compumat.h index d2d81fc83f0..b18988181ac 100644 --- a/src/emu/bus/vcs/compumat.h +++ b/src/emu/bus/vcs/compumat.h @@ -19,10 +19,10 @@ public: virtual void device_start(); virtual ioport_constructor device_input_ports() const; virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); - + private: }; diff --git a/src/emu/bus/vcs/dpc.c b/src/emu/bus/vcs/dpc.c index 85d8689067d..7387c6dbb34 100644 --- a/src/emu/bus/vcs/dpc.c +++ b/src/emu/bus/vcs/dpc.c @@ -37,7 +37,7 @@ void dpc_device::device_reset() m_df[data_fetcher].music_mode = 0; } m_oscillator->adjust(attotime::from_hz(18400), 0, attotime::from_hz(18400)); - + } void dpc_device::check_flag(UINT8 data_fetcher) @@ -60,7 +60,7 @@ void dpc_device::decrement_counter(UINT8 data_fetcher) if (data_fetcher > 4 && m_df[data_fetcher].music_mode) m_df[data_fetcher].low = m_df[data_fetcher].top; } - + check_flag(data_fetcher); } @@ -149,7 +149,7 @@ READ8_MEMBER(dpc_device::read) data = m_df[data_fetcher].flag ? 0xff : 0x00; break; } - + if (data_fetcher < 5 || !m_df[data_fetcher].osc_clk) { decrement_counter(data_fetcher); @@ -161,7 +161,7 @@ READ8_MEMBER(dpc_device::read) WRITE8_MEMBER(dpc_device::write) { UINT8 data_fetcher = offset & 0x07; - + switch (offset & 0x38) { case 0x00: // Top count @@ -235,7 +235,7 @@ void a26_rom_dpc_device::device_reset() m_base_bank = 0; } -void a26_rom_dpc_device::setup_addon_ptr(UINT8 *ptr) +void a26_rom_dpc_device::setup_addon_ptr(UINT8 *ptr) { m_dpc->set_display_data(ptr); } @@ -279,4 +279,3 @@ DIRECT_UPDATE_MEMBER(a26_rom_dpc_device::cart_opbase) } return address; } - diff --git a/src/emu/bus/vcs/dpc.h b/src/emu/bus/vcs/dpc.h index 8cf12d893eb..a54e67e5778 100644 --- a/src/emu/bus/vcs/dpc.h +++ b/src/emu/bus/vcs/dpc.h @@ -19,7 +19,7 @@ struct df_t { UINT8 osc_clk; /* Only used by data fetchers 5,6, and 7 */ }; -// m_dpc.oscillator = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(a2600_state::modeDPC_timer_callback),this)); +// m_dpc.oscillator = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(a2600_state::modeDPC_timer_callback),this)); class dpc_device : public device_t { @@ -74,16 +74,16 @@ public: virtual void device_reset(); required_device m_dpc; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); virtual DECLARE_DIRECT_UPDATE_MEMBER(cart_opbase); virtual void setup_addon_ptr(UINT8 *ptr); - + protected: -// int m_reset_bank; +// int m_reset_bank; }; diff --git a/src/emu/bus/vcs/rom.c b/src/emu/bus/vcs/rom.c index a585734c6f4..f9cc271b316 100755 --- a/src/emu/bus/vcs/rom.c +++ b/src/emu/bus/vcs/rom.c @@ -62,13 +62,13 @@ a26_rom_4k_device::a26_rom_4k_device(const machine_config &mconfig, const char * a26_rom_f6_device::a26_rom_f6_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : a26_rom_2k_device(mconfig, type, name, tag, owner, clock, shortname, source), - m_base_bank(-1) // set to -1 to help the Xin1 multicart... + m_base_bank(-1) // set to -1 to help the Xin1 multicart... { } a26_rom_f6_device::a26_rom_f6_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : a26_rom_2k_device(mconfig, A26_ROM_F6, "Atari VCS 2600 ROM Carts w/F6 bankswitch", tag, owner, clock, "vcs_f6", __FILE__), - m_base_bank(-1) // set to -1 to help the Xin1 multicart... + m_base_bank(-1) // set to -1 to help the Xin1 multicart... { } @@ -337,7 +337,7 @@ READ8_MEMBER(a26_rom_2k_device::read_rom) /*------------------------------------------------- "F4 Bankswitch" Carts: - read/write access to 0x1ff4-0x1ffb determines the + read/write access to 0x1ff4-0x1ffb determines the 4K ROM bank to be read GAMES: Fatal Run @@ -350,7 +350,7 @@ READ8_MEMBER(a26_rom_f4_device::read_rom) { return m_ram[offset & (m_ram.count() - 1)]; } - + // update banks if (!space.debugger_access()) { @@ -368,7 +368,7 @@ READ8_MEMBER(a26_rom_f4_device::read_rom) break; } } - + return m_rom[offset + (m_base_bank * 0x1000)]; } @@ -380,7 +380,7 @@ WRITE8_MEMBER(a26_rom_f4_device::write_bank) m_ram[offset & (m_ram.count() - 1)] = data; return; } - + switch (offset) { case 0x0ff4: @@ -401,10 +401,10 @@ WRITE8_MEMBER(a26_rom_f4_device::write_bank) /*------------------------------------------------- "F6 Bankswitch" Carts: - read/write access to 0x1ff6-0x1ff9 determines the + read/write access to 0x1ff6-0x1ff9 determines the 4K ROM bank to be read - GAMES: Atari 16K games, like Crossbow, Crystal + GAMES: Atari 16K games, like Crossbow, Crystal Castles and the 2-in-1 carts -------------------------------------------------*/ @@ -469,7 +469,7 @@ DIRECT_UPDATE_MEMBER(a26_rom_f6_device::cart_opbase) /*------------------------------------------------- "F8 Bankswitch" Carts: - read/write access to 0x1ff8-0x1ff9 determines the + read/write access to 0x1ff8-0x1ff9 determines the 4K ROM bank to be read GAMES: Atari 8K games, like Asteroids, Battlezone @@ -484,7 +484,7 @@ READ8_MEMBER(a26_rom_f8_device::read_rom) { return m_ram[offset & (m_ram.count() - 1)]; } - + // update banks if (!space.debugger_access()) { @@ -496,7 +496,7 @@ READ8_MEMBER(a26_rom_f8_device::read_rom) break; } } - + return m_rom[offset + (m_base_bank * 0x1000)]; } @@ -508,7 +508,7 @@ WRITE8_MEMBER(a26_rom_f8_device::write_bank) m_ram[offset & (m_ram.count() - 1)] = data; return; } - + switch (offset) { case 0x0ff8: @@ -523,12 +523,12 @@ WRITE8_MEMBER(a26_rom_f8_device::write_bank) /*------------------------------------------------- "FA Bankswitch" Carts: - read/write access to 0x1ff8-0x1ffa determines the + read/write access to 0x1ff8-0x1ffa determines the 4K ROM bank to be read - These games contained the CBS RAM+ chip (256bytes + These games contained the CBS RAM+ chip (256bytes of RAM) - - GAMES: CBS RAM Plus games like Omega Race and Tunnel + + GAMES: CBS RAM Plus games like Omega Race and Tunnel Runner -------------------------------------------------*/ @@ -540,7 +540,7 @@ READ8_MEMBER(a26_rom_fa_device::read_rom) { return m_ram[offset & (m_ram.count() - 1)]; } - + // update banks if (!space.debugger_access()) { @@ -553,7 +553,7 @@ READ8_MEMBER(a26_rom_fa_device::read_rom) break; } } - + return m_rom[offset + (m_base_bank * 0x1000)]; } @@ -563,8 +563,8 @@ WRITE8_MEMBER(a26_rom_fa_device::write_bank) if (m_ram && offset < 0x100) { m_ram[offset & (m_ram.count() - 1)] = data; - } - + } + switch (offset) { case 0x0ff8: @@ -580,22 +580,22 @@ WRITE8_MEMBER(a26_rom_fa_device::write_bank) /*------------------------------------------------- "FE Bankswitch" Carts: - read/write access to 0x01fe-0x1ff determines the + read/write access to 0x01fe-0x1ff determines the 4K ROM bank to be read - + GAMES: Activision 8K games like Decathlon -------------------------------------------------*/ /* - + There seems to be a kind of lag between the writing to address 0x1FE and the Activision switcher springing into action. It waits for the next byte to arrive on the data bus, which is the new PCH in the case of a JSR, and the PCH of the stored PC on the stack in the case of an RTS. - + depending on last byte & 0x20 -> 0x00 -> switch to bank #1 -> 0x20 -> switch to bank #0 - + */ READ8_MEMBER(a26_rom_fe_device::read_rom) @@ -607,9 +607,9 @@ READ8_MEMBER(a26_rom_fe_device::read_rom) { return m_ram[offset & (m_ram.count() - 1)]; } - + data = m_rom[offset + (m_base_bank * 0x1000)]; - + if (!space.debugger_access()) { if (m_trigger_on_next_access) @@ -618,7 +618,7 @@ READ8_MEMBER(a26_rom_fe_device::read_rom) m_trigger_on_next_access = 0; } } - + return data; } @@ -634,7 +634,7 @@ WRITE8_MEMBER(a26_rom_fe_device::write_ram) READ8_MEMBER(a26_rom_fe_device::read_bank) { UINT8 data = space.read_byte(0xfe + offset); - + if (!space.debugger_access()) { switch (offset & 1) @@ -643,7 +643,7 @@ READ8_MEMBER(a26_rom_fe_device::read_bank) // The next byte on the data bus determines which bank to switch to m_trigger_on_next_access = 1; break; - + case 1: if (m_trigger_on_next_access) { @@ -667,11 +667,11 @@ WRITE8_MEMBER(a26_rom_fe_device::write_bank) } /*------------------------------------------------- - "3E Bankswitch" Carts: - write access to 0x3e determines the 2K ROM bank to - be read, write access to 0x3f determines the RAM bank + "3E Bankswitch" Carts: + write access to 0x3e determines the 2K ROM bank to + be read, write access to 0x3f determines the RAM bank to be read - + GAMES: Boulder Dash (Homebrew) -------------------------------------------------*/ @@ -680,7 +680,7 @@ READ8_MEMBER(a26_rom_3e_device::read_rom) { if (m_ram && m_ram_enable && offset < 0x400) return m_ram[offset + (m_ram_bank * 0x400)]; - + if (offset >= 0x800) return m_rom[(offset & 0x7ff) + (m_num_bank - 1) * 0x800]; else @@ -709,11 +709,11 @@ WRITE8_MEMBER(a26_rom_3e_device::write_ram) /*------------------------------------------------- - "3F Bankswitch" Carts: - write access to 0x00-0x3f determines the 2K ROM bank + "3F Bankswitch" Carts: + write access to 0x00-0x3f determines the 2K ROM bank to be read - GAMES: Tigervision 8K games like Espial and Miner + GAMES: Tigervision 8K games like Espial and Miner 2049er. Extended version with bankswitch up to 512K shall be supported as well (but we lack a test case) @@ -733,8 +733,8 @@ WRITE8_MEMBER(a26_rom_3f_device::write_bank) } /*------------------------------------------------- - "E0 Bankswitch" Carts: - read/write access to 0x1fe0-0x1ff8 determines the + "E0 Bankswitch" Carts: + read/write access to 0x1fe0-0x1ff8 determines the 1K ROM bank to be read in each 1K chunk (0x1c00-0x1fff always points to the last 1K of the ROM) @@ -769,16 +769,16 @@ WRITE8_MEMBER(a26_rom_e0_device::write_bank) 1800-19ff is RAM 1a00-1fff is fixed to the last 0x600 of ROM - The selectable bank can be ROM (if selected by - 0x1fe0-0x1fe6 access) or a first 1K of RAM (if + The selectable bank can be ROM (if selected by + 0x1fe0-0x1fe6 access) or a first 1K of RAM (if selected by 0x1fe7 access). - The other 256byte RAM bank can be one of the + The other 256byte RAM bank can be one of the four different chunks forming the other 1K of RAM (the bank is selected by accessing 0x1fe8-0x1feb) - GAMES: M Network 16K games like Burgertime and + GAMES: M Network 16K games like Burgertime and Bump'n Jump - + -------------------------------------------------*/ READ8_MEMBER(a26_rom_e7_device::read_rom) @@ -833,12 +833,12 @@ WRITE8_MEMBER(a26_rom_e7_device::write_bank) } /*------------------------------------------------- - "UA Bankswitch" Carts: - read/write access to 0x200-0x27f determines the + "UA Bankswitch" Carts: + read/write access to 0x200-0x27f determines the 4K ROM bank to be read (0x220-0x23f for low 4K, 0x240-0x27f for high 4K) - GAMES: UA Ltd. 8K games like Funky Flash and + GAMES: UA Ltd. 8K games like Funky Flash and Pleaides -------------------------------------------------*/ @@ -863,9 +863,9 @@ WRITE8_MEMBER(a26_rom_ua_device::write_bank) /*------------------------------------------------- - Commavid Carts: + Commavid Carts: It allows for both ROM and RAM on the cartridge, - without using bankswitching. There's 2K of ROM + without using bankswitching. There's 2K of ROM and 1K of RAM. GAMES: Magicard and Video Life by Commavid @@ -894,8 +894,8 @@ WRITE8_MEMBER(a26_rom_cv_device::write_bank) /*------------------------------------------------- - Dynacom Megaboy Carts (aka "F0 Banswitch"): - read/write access to 0x1ff0 determines the 4K ROM + Dynacom Megaboy Carts (aka "F0 Banswitch"): + read/write access to 0x1ff0 determines the 4K ROM bank to be read (each access increases the bank index up to 16, since the cart was 64K wide) @@ -925,8 +925,8 @@ WRITE8_MEMBER(a26_rom_dc_device::write_bank) /*------------------------------------------------- - "FV Bankswitch" Carts: - The first access to 0x1fd0 switch the bank, but + "FV Bankswitch" Carts: + The first access to 0x1fd0 switch the bank, but only if pc() & 0x1f00 == 0x1f00! GAMES: Challenge by HES @@ -964,14 +964,14 @@ WRITE8_MEMBER(a26_rom_fv_device::write_bank) /*------------------------------------------------- - "JVP Bankswitch" Carts: - read/write access to 0x0fa0-0x0fc0 determines the + "JVP Bankswitch" Carts: + read/write access to 0x0fa0-0x0fc0 determines the 4K ROM bank to be read (notice that this overlaps the RIOT, currently handled in the main driver until I can better investigate the behavior) - + GAMES: No test case!?! - + -------------------------------------------------*/ READ8_MEMBER(a26_rom_jvp_device::read_rom) @@ -997,9 +997,9 @@ WRITE8_MEMBER(a26_rom_jvp_device::write_bank) /*------------------------------------------------- 4 in 1 Carts (Reset based): the 4K bank changes at each reset - + GAMES: 4 in 1 carts - + -------------------------------------------------*/ READ8_MEMBER(a26_rom_4in1_device::read_rom) @@ -1012,9 +1012,9 @@ READ8_MEMBER(a26_rom_4in1_device::read_rom) 8 in 1 Carts (Reset based): the 8K banks change at each reset, and internally each game runs as a F8-bankswitched cart - + GAMES: 8 in 1 cart - + -------------------------------------------------*/ READ8_MEMBER(a26_rom_8in1_device::read_rom) @@ -1029,7 +1029,7 @@ READ8_MEMBER(a26_rom_8in1_device::read_rom) break; } } - + return m_rom[offset + (m_base_bank * 0x1000) + (m_reset_bank * 0x2000)]; } @@ -1037,13 +1037,12 @@ READ8_MEMBER(a26_rom_8in1_device::read_rom) /*------------------------------------------------- 32 in 1 Carts (Reset based): the 2K banks change at each reset - + GAMES: 32 in 1 cart - + -------------------------------------------------*/ READ8_MEMBER(a26_rom_32in1_device::read_rom) { return m_rom[(offset & 0x7ff) + (m_base_bank * 0x800)]; } - diff --git a/src/emu/bus/vcs/rom.h b/src/emu/bus/vcs/rom.h index 33b00d0b5ea..a0434bd35c4 100755 --- a/src/emu/bus/vcs/rom.h +++ b/src/emu/bus/vcs/rom.h @@ -30,7 +30,7 @@ class a26_rom_4k_device : public a26_rom_2k_device public: // construction/destruction a26_rom_4k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing // accesses just use the 2K ones, since it is just direct access to ROM/RAM @@ -46,16 +46,16 @@ public: // construction/destruction a26_rom_f6_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a26_rom_f6_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); virtual DECLARE_DIRECT_UPDATE_MEMBER(cart_opbase); - + protected: int m_base_bank; }; @@ -68,10 +68,10 @@ class a26_rom_f4_device : public a26_rom_f6_device public: // construction/destruction a26_rom_f4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -86,7 +86,7 @@ public: // construction/destruction a26_rom_f8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); a26_rom_f8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -100,7 +100,7 @@ class a26_rom_f8_sw_device : public a26_rom_f8_device public: // construction/destruction a26_rom_f8_sw_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); }; @@ -113,7 +113,7 @@ class a26_rom_fa_device : public a26_rom_f6_device public: // construction/destruction a26_rom_fa_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -127,17 +127,17 @@ class a26_rom_fe_device : public a26_rom_2k_device public: // construction/destruction a26_rom_fe_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ8_MEMBER(read_bank); virtual DECLARE_WRITE8_MEMBER(write_ram); virtual DECLARE_WRITE8_MEMBER(write_bank); - + protected: int m_base_bank; int m_trigger_on_next_access; @@ -151,16 +151,16 @@ class a26_rom_3e_device : public a26_rom_f6_device public: // construction/destruction a26_rom_3e_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); virtual DECLARE_WRITE8_MEMBER(write_ram); - + protected: int m_num_bank; int m_ram_bank; @@ -175,14 +175,14 @@ class a26_rom_3f_device : public a26_rom_f6_device public: // construction/destruction a26_rom_3f_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); - + protected: int m_num_bank; }; @@ -195,15 +195,15 @@ class a26_rom_e0_device : public a26_rom_f6_device public: // construction/destruction a26_rom_e0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); - + protected: int m_base_banks[4]; }; @@ -216,15 +216,15 @@ class a26_rom_e7_device : public a26_rom_f6_device public: // construction/destruction a26_rom_e7_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); - + protected: int m_ram_bank; }; @@ -237,10 +237,10 @@ class a26_rom_ua_device : public a26_rom_f6_device public: // construction/destruction a26_rom_ua_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_READ8_MEMBER(read_bank); @@ -255,7 +255,7 @@ class a26_rom_cv_device : public a26_rom_2k_device public: // construction/destruction a26_rom_cv_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -269,7 +269,7 @@ class a26_rom_dc_device : public a26_rom_f6_device public: // construction/destruction a26_rom_dc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -283,15 +283,15 @@ class a26_rom_fv_device : public a26_rom_f6_device public: // construction/destruction a26_rom_fv_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); - + protected: int m_locked; }; @@ -304,7 +304,7 @@ class a26_rom_jvp_device : public a26_rom_f6_device public: // construction/destruction a26_rom_jvp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -318,10 +318,10 @@ class a26_rom_4in1_device : public a26_rom_f6_device public: // construction/destruction a26_rom_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); }; @@ -334,11 +334,11 @@ class a26_rom_8in1_device : public a26_rom_f8_device public: // construction/destruction a26_rom_8in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); @@ -354,10 +354,10 @@ class a26_rom_32in1_device : public a26_rom_f6_device public: // construction/destruction a26_rom_32in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); }; diff --git a/src/emu/bus/vcs/scharger.c b/src/emu/bus/vcs/scharger.c index efd685a5969..e536a474c18 100644 --- a/src/emu/bus/vcs/scharger.c +++ b/src/emu/bus/vcs/scharger.c @@ -2,31 +2,31 @@ Atari 2600 cart Starpath Supercharger (Cart + Tape drive!) - - + + From kevtris notes ( http://blog.kevtris.org/blogfiles/Atari%202600%20Mappers.txt ): - + - Control register [0x1ff8] - + 7 0 --------- 1FF8: DDDB BBWE - + D: write delay (see below) B: bankswitching mode (see below) W: RAM write enable (1 = enabled, 0 = disabled) E: ROM power enable (0 = enabled, 1 = turn off ROM) - + - Audio input register [0x1ff9] - + 7 0 - --------- + --------- 1FF9: 0000 000A - + A: Supercharger audio data. 0 = low input, 1 = high input. - - + + ***************************************************************************/ @@ -83,8 +83,8 @@ static MACHINE_CONFIG_FRAGMENT( a26_ss ) MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED) MCFG_CASSETTE_INTERFACE("a2600_cass") -// MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette") -// MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) +// MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette") +// MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END machine_config_constructor a26_rom_ss_device::device_mconfig_additions() const @@ -109,17 +109,17 @@ READ8_MEMBER(a26_rom_ss_device::read_rom) if (space.debugger_access()) return read_byte(offset); - // Bankswitch + // Bankswitch if (offset == 0xff8) { //logerror("%04X: Access to control register data = %02X\n", m_maincpu->pc(), m_modeSS_byte); m_write_delay = m_reg >> 5; m_ram_write_enabled = BIT(m_reg, 1); m_rom_enabled = !BIT(m_reg, 0); - + // compensate time spent in this access to avoid spurious RAM write m_byte_started -= 5; - + // handle bankswitch switch (m_reg & 0x1c) { @@ -164,10 +164,10 @@ READ8_MEMBER(a26_rom_ss_device::read_rom) { //logerror("%04X: Cassette port read, tap_val = %f\n", m_maincpu->pc(), tap_val); double tap_val = m_cassette->input(); - + // compensate time spent in this access to avoid spurious RAM write m_byte_started -= 5; - + if (tap_val < 0) return 0x00; else @@ -181,7 +181,7 @@ READ8_MEMBER(a26_rom_ss_device::read_rom) /* Check for dummy read from same address */ if (m_last_address == offset) m_diff_adjust++; - + int diff = m_maincpu->total_cycles() - m_byte_started; //logerror("%04X: offset = %04X, %d\n", m_maincpu->pc(), offset, diff); diff --git a/src/emu/bus/vcs/scharger.h b/src/emu/bus/vcs/scharger.h index d13d8e5b6d7..94ffda7230c 100644 --- a/src/emu/bus/vcs/scharger.h +++ b/src/emu/bus/vcs/scharger.h @@ -22,14 +22,14 @@ public: virtual void device_reset(); required_device m_cassette; - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); - + private: cpu_device *m_maincpu; inline UINT8 read_byte(UINT32 offset); - + int m_base_banks[2]; UINT8 m_reg; UINT8 m_write_delay, m_ram_write_enabled, m_rom_enabled; diff --git a/src/emu/bus/vcs/vcs_slot.c b/src/emu/bus/vcs/vcs_slot.c index a60cf55da52..a1a8797c18b 100755 --- a/src/emu/bus/vcs/vcs_slot.c +++ b/src/emu/bus/vcs/vcs_slot.c @@ -186,14 +186,14 @@ bool vcs_cart_slot_device::call_load() { UINT8 *ROM; UINT32 len; - + if (software_entry() != NULL) len = get_software_region_length("rom"); else len = length(); - + //printf("Size: 0x%X\n", len); - + // check that filesize is among the supported ones switch (len) { @@ -208,21 +208,21 @@ bool vcs_cart_slot_device::call_load() case 0x10000: case 0x80000: break; - + default: seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid rom file size" ); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(len, tag()); ROM = m_cart->get_rom_base(); - + if (software_entry() != NULL) { const char *pcb_name; bool has_ram = get_software_region("ram") ? TRUE : FALSE; memcpy(ROM, get_software_region("rom"), len); - + if ((pcb_name = get_feature("slot")) != NULL) m_type = vcs_get_pcb_id(pcb_name); else @@ -272,7 +272,7 @@ bool vcs_cart_slot_device::call_load() { fread(ROM, len); m_type = identify_cart_type(ROM, len); - + // check for Special Chip (128bytes of RAM) if (len == 0x2000 || len == 0x4000 || len == 0x8000) if (detect_super_chip(ROM, len)) @@ -284,7 +284,7 @@ bool vcs_cart_slot_device::call_load() // dig dig, crystal castles, millipede, stargate, defender ii, jr. Pac Man, // desert falcon, dark chambers, super football, sprintmaster, fatal run, // off the wall, shooting arcade, secret quest, radar lock, save mary, klax - + // add CBS RAM+ (256bytes of RAM) if (m_type == A26_FA) m_cart->ram_alloc(0x100); @@ -301,16 +301,16 @@ bool vcs_cart_slot_device::call_load() else if (m_type == A26_3E) m_cart->ram_alloc(0x8000); } - + //printf("Type: %s\n", vcs_get_slot(m_type)); - + // pass a pointer to the now allocated ROM for the DPC chip if (m_type == A26_DPC) m_cart->setup_addon_ptr((UINT8 *)m_cart->get_rom_base() + 0x2000); - + return IMAGE_INIT_PASS; } - + return IMAGE_INIT_PASS; } @@ -356,7 +356,7 @@ int vcs_cart_slot_device::detect_modeDC(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -376,7 +376,7 @@ int vcs_cart_slot_device::detect_modeF6(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -408,7 +408,7 @@ int vcs_cart_slot_device::detect_mode3E(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -428,7 +428,7 @@ int vcs_cart_slot_device::detect_modeSS(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -456,7 +456,7 @@ int vcs_cart_slot_device::detect_modeFE(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -486,7 +486,7 @@ int vcs_cart_slot_device::detect_modeE0(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -512,7 +512,7 @@ int vcs_cart_slot_device::detect_modeCV(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -535,7 +535,7 @@ int vcs_cart_slot_device::detect_modeFV(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -561,7 +561,7 @@ int vcs_cart_slot_device::detect_modeJVP(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -587,7 +587,7 @@ int vcs_cart_slot_device::detect_modeE7(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -607,7 +607,7 @@ int vcs_cart_slot_device::detect_modeUA(UINT8 *cart, UINT32 len) } } } - if (numfound) + if (numfound) return 1; return 0; } @@ -633,7 +633,7 @@ int vcs_cart_slot_device::detect_8K_mode3F(UINT8 *cart, UINT32 len) } } } - if (numfound == 0x03) + if (numfound == 0x03) return 1; return 0; } @@ -653,7 +653,7 @@ int vcs_cart_slot_device::detect_32K_mode3F(UINT8 *cart, UINT32 len) } } } - if (numfound > 1) + if (numfound > 1) return 1; return 0; } @@ -705,33 +705,33 @@ int vcs_cart_slot_device::identify_cart_type(UINT8 *ROM, UINT32 len) int type = 0xff; // auto-detect bank mode - if (detect_modeDC(ROM, len)) + if (detect_modeDC(ROM, len)) type = A26_DC; - else if (detect_mode3E(ROM, len)) + else if (detect_mode3E(ROM, len)) type = A26_3E; - else if (detect_modeFE(ROM, len)) + else if (detect_modeFE(ROM, len)) type = A26_FE; - else if (detect_modeSS(ROM, len)) + else if (detect_modeSS(ROM, len)) type = A26_SS; - else if (detect_modeE0(ROM, len)) + else if (detect_modeE0(ROM, len)) type = A26_E0; else if (detect_modeCV(ROM, len)) type = A26_CV; - else if (detect_modeFV(ROM, len)) + else if (detect_modeFV(ROM, len)) type = A26_FV; - else if (detect_modeJVP(ROM, len)) + else if (detect_modeJVP(ROM, len)) type = A26_JVP; - else if (detect_modeUA(ROM, len)) + else if (detect_modeUA(ROM, len)) type = A26_UA; - else if (detect_8K_mode3F(ROM, len)) + else if (detect_8K_mode3F(ROM, len)) type = A26_3F; - else if (detect_32K_mode3F(ROM, len)) + else if (detect_32K_mode3F(ROM, len)) type = A26_3F; - else if (detect_modeE7(ROM, len)) + else if (detect_modeE7(ROM, len)) type = A26_E7; else if (detect_snowhite(ROM, len)) type = A26_F8SW; - + // otherwise, choose based on size if (type == 0xff) { @@ -771,7 +771,7 @@ int vcs_cart_slot_device::identify_cart_type(UINT8 *ROM, UINT32 len) break; } } - + return type; } @@ -787,14 +787,14 @@ void vcs_cart_slot_device::get_default_card_software(astring &result) UINT32 len = core_fsize(m_file); dynamic_buffer rom(len); int type; - + core_fread(m_file, rom, len); - + type = identify_cart_type(rom, len); slot_string = vcs_get_slot(type); - + clear(); - + result.cpy(slot_string); } else diff --git a/src/emu/bus/vcs/vcs_slot.h b/src/emu/bus/vcs/vcs_slot.h index 18d604b1a69..3d393395f5a 100755 --- a/src/emu/bus/vcs/vcs_slot.h +++ b/src/emu/bus/vcs/vcs_slot.h @@ -18,7 +18,7 @@ enum A26_F8SW, A26_FA, A26_FE, - A26_3E, // to test + A26_3E, // to test A26_3F, A26_E0, A26_E7, @@ -26,7 +26,7 @@ enum A26_DC, A26_CV, A26_FV, - A26_JVP, // to test + A26_JVP, // to test A26_32IN1, A26_8IN1, A26_4IN1, @@ -49,7 +49,7 @@ public: virtual DECLARE_READ8_MEMBER(read_rom) { return 0xff; } // writing to RAM chips (sometimes it is in a different range than write_bank!) virtual DECLARE_WRITE8_MEMBER(write_ram) {} - + // read/write to bankswitch address virtual DECLARE_READ8_MEMBER(read_bank) { return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_bank) {} diff --git a/src/emu/bus/vectrex/rom.h b/src/emu/bus/vectrex/rom.h index a88ba20795d..6515b0227fb 100644 --- a/src/emu/bus/vectrex/rom.h +++ b/src/emu/bus/vectrex/rom.h @@ -31,11 +31,11 @@ class vectrex_rom64k_device : public vectrex_rom_device public: // construction/destruction vectrex_rom64k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_rom); virtual DECLARE_WRITE8_MEMBER(write_bank); @@ -51,7 +51,7 @@ class vectrex_sram_device : public vectrex_rom_device public: // construction/destruction vectrex_sram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // reading and writing virtual DECLARE_WRITE8_MEMBER(write_ram); }; diff --git a/src/emu/bus/vectrex/slot.c b/src/emu/bus/vectrex/slot.c index d4db8b2c047..448b48beebd 100644 --- a/src/emu/bus/vectrex/slot.c +++ b/src/emu/bus/vectrex/slot.c @@ -156,44 +156,44 @@ bool vectrex_cart_slot_device::call_load() { UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); UINT8 *ROM; - + if (size > 0x10000) { seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc((size < 0x1000) ? 0x1000 : size, tag()); ROM = m_cart->get_rom_base(); - + if (software_entry() == NULL) fread(ROM, size); else memcpy(ROM, get_software_region("rom"), size); - + // Verify the file is accepted by the Vectrex bios if (memcmp(ROM, "g GCE", 5)) { seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid image"); return IMAGE_INIT_FAIL; } - + // determine type m_type = VECTREX_STD; if (!memcmp(ROM + 0x06, "SRAM", 4)) - m_type = VECTREX_SRAM; + m_type = VECTREX_SRAM; if (size > 0x8000) m_type = VECTREX_64K; - + //printf("Type: %s\n", vectrex_get_slot(m_type)); // determine 3D setup (to help video setup at machine_start) if (!memcmp(ROM + 0x11, "NARROW", 6) && (ROM[0x39] == 0x0c)) m_vec3d = VEC3D_NARROW; - + if (!memcmp(ROM + 0x11, "CRAZY COASTER", 13)) m_vec3d = VEC3D_CCOAST; - + if (!memcmp(ROM + 0x11, "3D MINE STORM", 13)) m_vec3d = VEC3D_MINEST; @@ -229,9 +229,9 @@ void vectrex_cart_slot_device::get_default_card_software(astring &result) int type = VECTREX_STD; core_fread(m_file, rom, size); - + if (!memcmp(rom + 0x06, "SRAM", 4)) - type = VECTREX_SRAM; + type = VECTREX_SRAM; if (size > 0x8000) type = VECTREX_64K; @@ -278,5 +278,3 @@ WRITE8_MEMBER(vectrex_cart_slot_device::write_bank) if (m_cart) m_cart->write_bank(space, offset, data); } - - diff --git a/src/emu/bus/vectrex/slot.h b/src/emu/bus/vectrex/slot.h index 1fd7b0299cc..10682f7204a 100644 --- a/src/emu/bus/vectrex/slot.h +++ b/src/emu/bus/vectrex/slot.h @@ -111,6 +111,5 @@ extern const device_type VECTREX_CART_SLOT; #define MCFG_VECTREX_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, VECTREX_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/bus/vic20/fe3.c b/src/emu/bus/vic20/fe3.c index 7aeecb9e12c..d7a7616cfca 100644 --- a/src/emu/bus/vic20/fe3.c +++ b/src/emu/bus/vic20/fe3.c @@ -11,11 +11,11 @@ /* - TODO: + TODO: - - fe3diag register error#2 hp=5592 (same error in VICE) - - SD card - - RTC + - fe3diag register error#2 hp=5592 (same error in VICE) + - SD card + - RTC */ @@ -32,25 +32,25 @@ #define ATF1504AS_TAG "ic4" #define REG1_BANK \ - ((m_reg1 & 0x7f) << 15) + ((m_reg1 & 0x7f) << 15) #define LORAM_HIDDEN \ - (m_reg2 & REG2_BLK0) + (m_reg2 & REG2_BLK0) #define BLK1_HIDDEN \ - (m_reg2 & REG2_BLK1) + (m_reg2 & REG2_BLK1) #define BLK2_HIDDEN \ - (m_reg2 & REG2_BLK2) + (m_reg2 & REG2_BLK2) #define BLK3_HIDDEN \ - (m_reg2 & REG2_BLK3) + (m_reg2 & REG2_BLK3) #define BLK5_HIDDEN \ - (m_reg2 & REG2_BLK5) + (m_reg2 & REG2_BLK5) #define REGISTERS_HIDDEN \ - ((m_lockbit && ((m_reg1 & REG1_MODE_MASK) == REG1_START)) || (m_reg2 & REG2_IO3)) + ((m_lockbit && ((m_reg1 & REG1_MODE_MASK) == REG1_START)) || (m_reg2 & REG2_IO3)) @@ -178,7 +178,7 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, { data = m_ram[get_address(0, 0, offset)]; } - + // read from ROM if (!blk1 && !BLK1_HIDDEN) { @@ -203,7 +203,7 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, data = read_register(BIT(offset, 0)); } break; - + case REG1_RAM_1: // read from RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -235,7 +235,7 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, data = read_register(BIT(offset, 0)); } break; - + case REG1_RAM_2: // read from RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -267,7 +267,7 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, data = read_register(BIT(offset, 0)); } break; - + case REG1_SUPER_RAM: // read from RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -299,14 +299,14 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, data = read_register(BIT(offset, 0)); } break; - + case REG1_RAM_ROM: // read from RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) { data = m_ram[get_address(0, 0, offset)]; } - + // read from ROM bank 0 or RAM bank 1 if (!blk1 && !BLK1_HIDDEN) { @@ -331,7 +331,7 @@ UINT8 vic20_final_expansion_3_t::vic20_cd_r(address_space &space, offs_t offset, data = read_register(BIT(offset, 0)); } break; - + case REG1_FLASH: // read from RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -392,7 +392,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_SUPER_ROM: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -424,7 +424,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_RAM_1: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN && REG1_BLK0) @@ -456,7 +456,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_RAM_2: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN && REG1_BLK0) @@ -488,7 +488,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_SUPER_RAM: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) @@ -520,7 +520,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_RAM_ROM: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN && REG1_BLK0) @@ -552,7 +552,7 @@ void vic20_final_expansion_3_t::vic20_cd_w(address_space &space, offs_t offset, write_register(BIT(offset, 0), data); } break; - + case REG1_FLASH: // write to RAM bank 0 if ((!ram1 || !ram2 || !ram3) && !LORAM_HIDDEN) diff --git a/src/emu/bus/vic20/fe3.h b/src/emu/bus/vic20/fe3.h index 81ab92748c6..9a209f44fbe 100644 --- a/src/emu/bus/vic20/fe3.h +++ b/src/emu/bus/vic20/fe3.h @@ -27,7 +27,7 @@ // ======================> vic20_final_expansion_3_t class vic20_final_expansion_3_t : public device_t, - public device_vic20_expansion_card_interface + public device_vic20_expansion_card_interface { public: // construction/destruction diff --git a/src/emu/bus/wswan/rom.c b/src/emu/bus/wswan/rom.c index 4b27d7fe348..1bac91a4a5d 100644 --- a/src/emu/bus/wswan/rom.c +++ b/src/emu/bus/wswan/rom.c @@ -154,7 +154,7 @@ void ws_rom_device::device_timer(emu_timer &timer, device_timer_id id, int param m_rtc_second++; if ((m_rtc_second & 0x0f) > 9) m_rtc_second = (m_rtc_second & 0xf0) + 0x10; - + // check for minute passed if (m_rtc_second >= 0x60) { @@ -163,7 +163,7 @@ void ws_rom_device::device_timer(emu_timer &timer, device_timer_id id, int param if ((m_rtc_minute & 0x0f) > 9) m_rtc_minute = (m_rtc_minute & 0xf0) + 0x10; } - + // check for hour passed if (m_rtc_minute >= 0x60) { @@ -174,7 +174,7 @@ void ws_rom_device::device_timer(emu_timer &timer, device_timer_id id, int param if (m_rtc_hour == 0x12) m_rtc_hour |= 0x80; } - + // check for day passed if (m_rtc_hour >= 0x24) { @@ -217,7 +217,7 @@ READ8_MEMBER(ws_rom_device::read_io) case 0x0b: // RTC data if (!m_has_rtc) break; - + if (m_io_regs[0x0a] == 0x95 && (m_rtc_index < 7)) { switch (m_rtc_index) @@ -307,7 +307,7 @@ WRITE8_MEMBER(ws_rom_device::write_io) case 0x0b: // RTC Data if (!m_has_rtc) break; - + if (m_io_regs[0x0a] == 0x94 && m_rtc_index < 7) { switch (m_rtc_index) @@ -339,7 +339,7 @@ WRITE8_MEMBER(ws_rom_sram_device::write_ram) } WRITE8_MEMBER(ws_rom_sram_device::write_io) -{ +{ switch (offset) { case 0x01: // SRAM bank to select @@ -354,7 +354,7 @@ WRITE8_MEMBER(ws_rom_sram_device::write_io) READ8_MEMBER(ws_rom_eeprom_device::read_io) { UINT8 value = m_io_regs[offset]; - + switch (offset) { case 0x04: @@ -368,29 +368,29 @@ READ8_MEMBER(ws_rom_eeprom_device::read_io) value = ws_rom_device::read_io(space, offset); break; } - + return value; } WRITE8_MEMBER(ws_rom_eeprom_device::write_io) -{ +{ switch (offset) { case 0x06: /* EEPROM address lower bits port/EEPROM address and command port - 1KBit EEPROM: - Bit 0-5 - EEPROM address bit 1-6 - Bit 6-7 - Command - 00 - Extended command address bit 4-5: - 00 - Write disable - 01 - Write all - 10 - Erase all - 11 - Write enable - 01 - Write - 10 - Read - 11 - Erase - 16KBit EEPROM: - Bit 0-7 - EEPROM address bit 1-8 - */ + 1KBit EEPROM: + Bit 0-5 - EEPROM address bit 1-6 + Bit 6-7 - Command + 00 - Extended command address bit 4-5: + 00 - Write disable + 01 - Write all + 10 - Erase all + 11 - Write enable + 01 - Write + 10 - Read + 11 - Erase + 16KBit EEPROM: + Bit 0-7 - EEPROM address bit 1-8 + */ switch (m_eeprom_mode) { case EEPROM_1K: @@ -412,23 +412,23 @@ WRITE8_MEMBER(ws_rom_eeprom_device::write_io) break; case 0x07: /* EEPROM higher bits/command bits port - 1KBit EEPROM: - Bit 0 - Start - Bit 1-7 - Unknown - 16KBit EEPROM: - Bit 0-1 - EEPROM address bit 9-10 - Bit 2-3 - Command - 00 - Extended command address bit 0-1: - 00 - Write disable - 01 - Write all - 10 - Erase all - 11 - Write enable - 01 - Write - 10 - Read - 11 - Erase - Bit 4 - Start - Bit 5-7 - Unknown - */ + 1KBit EEPROM: + Bit 0 - Start + Bit 1-7 - Unknown + 16KBit EEPROM: + Bit 0-1 - EEPROM address bit 9-10 + Bit 2-3 - Command + 00 - Extended command address bit 0-1: + 00 - Write disable + 01 - Write all + 10 - Erase all + 11 - Write enable + 01 - Write + 10 - Read + 11 - Erase + Bit 4 - Start + Bit 5-7 - Unknown + */ switch (m_eeprom_mode) { case EEPROM_1K: @@ -450,7 +450,7 @@ WRITE8_MEMBER(ws_rom_eeprom_device::write_io) m_eeprom_command = m_eeprom_command & 0x0c; m_eeprom_start = (data >> 4) & 0x01; break; - + default: logerror( "Write EEPROM address/command register C7 for unsupported EEPROM type\n" ); break; @@ -458,19 +458,19 @@ WRITE8_MEMBER(ws_rom_eeprom_device::write_io) break; case 0x08: /* EEPROM command - Bit 0 - Read complete (read only) - Bit 1 - Write complete (read only) - Bit 2-3 - Unknown - Bit 4 - Read - Bit 5 - Write - Bit 6 - Protect - Bit 7 - Initialize - */ - if (data & 0x80) // Initialize + Bit 0 - Read complete (read only) + Bit 1 - Write complete (read only) + Bit 2-3 - Unknown + Bit 4 - Read + Bit 5 - Write + Bit 6 - Protect + Bit 7 - Initialize + */ + if (data & 0x80) // Initialize logerror("Unsupported EEPROM command 'Initialize'\n"); - if (data & 0x40) // Protect - { + if (data & 0x40) // Protect + { switch (m_eeprom_command) { case 0x00: @@ -487,7 +487,7 @@ WRITE8_MEMBER(ws_rom_eeprom_device::write_io) } } - if (data & 0x20) // Write + if (data & 0x20) // Write { if (m_eeprom_write_enabled) { @@ -505,7 +505,7 @@ WRITE8_MEMBER(ws_rom_eeprom_device::write_io) } } - if (data & 0x10) // Read + if (data & 0x10) // Read { m_io_regs[0x04] = m_nvram[(m_eeprom_address << 1) + 1]; m_io_regs[0x05] = m_nvram[m_eeprom_address << 1]; diff --git a/src/emu/bus/wswan/rom.h b/src/emu/bus/wswan/rom.h index 2ee51e35d43..7c64f8cda02 100644 --- a/src/emu/bus/wswan/rom.h +++ b/src/emu/bus/wswan/rom.h @@ -53,11 +53,11 @@ class ws_rom_sram_device : public ws_rom_device public: // construction/destruction ws_rom_sram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_ram); virtual DECLARE_WRITE8_MEMBER(write_ram); @@ -75,11 +75,11 @@ class ws_rom_eeprom_device : public ws_rom_device public: // construction/destruction ws_rom_eeprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + // device-level overrides virtual void device_start(); virtual void device_reset(); - + // reading and writing virtual DECLARE_READ8_MEMBER(read_io); virtual DECLARE_WRITE8_MEMBER(write_io); diff --git a/src/emu/bus/wswan/slot.c b/src/emu/bus/wswan/slot.c index 9d5772fd479..72fa3d21677 100644 --- a/src/emu/bus/wswan/slot.c +++ b/src/emu/bus/wswan/slot.c @@ -167,10 +167,10 @@ bool ws_cart_slot_device::call_load() UINT8 *ROM; UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); UINT32 nvram_size = 0; - + m_cart->rom_alloc(size, tag()); ROM = m_cart->get_rom_base(); - + if (software_entry() == NULL) fread(ROM, size); else @@ -261,35 +261,35 @@ int ws_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len, UINT32 &nvram_len { case 0x00: break; - case 0x01: // SRAM 64Kbit + case 0x01: // SRAM 64Kbit type = WS_SRAM; nvram_len = 0x2000; break; - case 0x02: // SRAM 256Kbit + case 0x02: // SRAM 256Kbit type = WS_SRAM; nvram_len = 0x8000; break; - case 0x05: // SRAM 512Kbit + case 0x05: // SRAM 512Kbit type = WS_SRAM; nvram_len = 0x10000; break; - case 0x03: // SRAM 1Mbit + case 0x03: // SRAM 1Mbit type = WS_SRAM; nvram_len = 0x20000; break; - case 0x04: // SRAM 2Mbit + case 0x04: // SRAM 2Mbit type = WS_SRAM; nvram_len = 0x40000; break; - case 0x10: // EEPROM 1Kbit + case 0x10: // EEPROM 1Kbit type = WS_EEPROM; nvram_len = 0x80; break; - case 0x50: // EEPROM 8Kbit + case 0x50: // EEPROM 8Kbit type = WS_EEPROM; nvram_len = 0x400; break; - case 0x20: // EEPROM 16Kbit + case 0x20: // EEPROM 16Kbit type = WS_EEPROM; nvram_len = 0x800; break; @@ -298,7 +298,7 @@ int ws_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len, UINT32 &nvram_len logerror("Unknown RAM size [0x%X]\n", ROM[(chunks - 1) * 0x10000 + 0xfffb]); break; } - + return type; } @@ -315,7 +315,7 @@ void ws_cart_slot_device::get_default_card_software(astring &result) dynamic_buffer rom(size); int type; UINT32 nvram; - + core_fread(m_file, rom, size); // nvram size is not really used here, but we set it up nevertheless @@ -427,9 +427,9 @@ void ws_cart_slot_device::internal_header_logging(UINT8 *ROM, UINT32 offs, UINT3 int sum = 0, banks = len / 0x10000; UINT8 romsize, ramtype, ramsize; romsize = ROM[offs + 0xfffa]; - ramtype = (ROM[offs + 0xfffb] & 0xf0) ? 1 : 0; // 1 = EEPROM, 0 = SRAM + ramtype = (ROM[offs + 0xfffb] & 0xf0) ? 1 : 0; // 1 = EEPROM, 0 = SRAM ramsize = ramtype ? ((ROM[offs + 0xfffb] & 0xf0) >> 4) : (ROM[offs + 0xfffb] & 0x0f); - + logerror( "ROM DETAILS\n" ); logerror( "===========\n\n" ); diff --git a/src/emu/bus/wswan/slot.h b/src/emu/bus/wswan/slot.h index cde3d81c3a6..97e838be793 100644 --- a/src/emu/bus/wswan/slot.h +++ b/src/emu/bus/wswan/slot.h @@ -40,7 +40,7 @@ public: UINT32 get_rom_size() { return m_rom_size; } UINT32 get_nvram_size() { return m_nvram.count(); } - void save_nvram() { device().save_item(NAME(m_nvram)); } + void save_nvram() { device().save_item(NAME(m_nvram)); } void set_has_rtc(bool val) { m_has_rtc = val; } void set_is_rotated(bool val) { m_is_rotated = val; } int get_is_rotated() { return m_is_rotated ? 1 : 0; } @@ -81,7 +81,7 @@ public: int get_cart_type(UINT8 *ROM, UINT32 len, UINT32 &nvram_len); void internal_header_logging(UINT8 *ROM, UINT32 offs, UINT32 len); - void save_nvram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); } + void save_nvram() { if (m_cart && m_cart->get_nvram_size()) m_cart->save_nvram(); } virtual iodevice_t image_type() const { return IO_CARTSLOT; } virtual bool is_readable() const { return 1; } @@ -125,6 +125,5 @@ extern const device_type WS_CART_SLOT; #define MCFG_WSWAN_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ MCFG_DEVICE_ADD(_tag, WS_CART_SLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ - + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) #endif diff --git a/src/emu/cpu/dsp56k/dsp56k.c b/src/emu/cpu/dsp56k/dsp56k.c index ba275d9dc37..33de16f4709 100644 --- a/src/emu/cpu/dsp56k/dsp56k.c +++ b/src/emu/cpu/dsp56k/dsp56k.c @@ -106,13 +106,13 @@ const device_type DSP56156 = &device_creator; * Internal Memory Maps ****************************************************************************/ static ADDRESS_MAP_START( dsp56156_program_map, AS_PROGRAM, 16, dsp56k_device ) - AM_RANGE(0x0000,0x07ff) AM_READWRITE(program_r, program_w) /* 1-5 */ + AM_RANGE(0x0000,0x07ff) AM_READWRITE(program_r, program_w) /* 1-5 */ // AM_RANGE(0x2f00,0x2fff) AM_ROM /* 1-5 PROM reserved memory. Is this the right spot for it? */ ADDRESS_MAP_END static ADDRESS_MAP_START( dsp56156_x_data_map, AS_DATA, 16, dsp56k_device ) - AM_RANGE(0x0000,0x07ff) AM_RAM /* 1-5 */ - AM_RANGE(0xffc0,0xffff) AM_READWRITE(peripheral_register_r, peripheral_register_w) /* 1-5 On-chip peripheral registers memory mapped in data space */ + AM_RANGE(0x0000,0x07ff) AM_RAM /* 1-5 */ + AM_RANGE(0xffc0,0xffff) AM_READWRITE(peripheral_register_r, peripheral_register_w) /* 1-5 On-chip peripheral registers memory mapped in data space */ ADDRESS_MAP_END @@ -288,7 +288,7 @@ void dsp56k_device::device_start() save_item(NAME(m_dsp56k_core.HI.trxh)); save_item(NAME(m_dsp56k_core.HI.trxl)); save_item(NAME(m_dsp56k_core.HI.bootstrap_offset)); - + save_item(NAME(m_dsp56k_core.peripheral_ram)); save_item(NAME(m_dsp56k_core.program_ram)); @@ -514,4 +514,3 @@ offs_t dsp56k_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *o extern CPU_DISASSEMBLE( dsp56k ); return CPU_DISASSEMBLE_NAME(dsp56k)(this, buffer, pc, oprom, opram, options); } - diff --git a/src/emu/cpu/hd61700/hd61700.c b/src/emu/cpu/hd61700/hd61700.c index 8aeee1faad2..21c040851da 100644 --- a/src/emu/cpu/hd61700/hd61700.c +++ b/src/emu/cpu/hd61700/hd61700.c @@ -138,7 +138,7 @@ void hd61700_cpu_device::device_start() m_kb_write_cb.resolve_safe(); m_port_read_cb.resolve_safe(0xff); m_port_write_cb.resolve_safe(); - + // save state save_item(NAME(m_ppc)); save_item(NAME(m_curpc)); diff --git a/src/emu/cpu/hd61700/hd61700.h b/src/emu/cpu/hd61700/hd61700.h index 35ede0a3edc..255fc128aa8 100644 --- a/src/emu/cpu/hd61700/hd61700.h +++ b/src/emu/cpu/hd61700/hd61700.h @@ -76,7 +76,7 @@ public: template static devcb_base &set_kb_read_callback(device_t &device, _Object object) { return downcast(device).m_kb_read_cb.set_callback(object); } template static devcb_base &set_port_write_callback(device_t &device, _Object object) { return downcast(device).m_port_write_cb.set_callback(object); } template static devcb_base &set_port_read_callback(device_t &device, _Object object) { return downcast(device).m_port_read_cb.set_callback(object); } - + protected: // device-level overrides virtual void device_start(); @@ -155,7 +155,7 @@ protected: devcb_write8 m_kb_write_cb; //keyboard matrix write devcb_read8 m_port_read_cb; //8 bit port read devcb_write8 m_port_write_cb; //8 bit port write - + // flag definitions static const int FLAG_Z = 0x80; static const int FLAG_C = 0x40; diff --git a/src/emu/cpu/i86/i186.c b/src/emu/cpu/i86/i186.c index 6d6e418ec7f..801bf76a400 100644 --- a/src/emu/cpu/i86/i186.c +++ b/src/emu/cpu/i86/i186.c @@ -594,14 +594,14 @@ void i80186_cpu_device::device_start() save_item(NAME(m_mem.middle_size)); save_item(NAME(m_mem.peripheral)); save_item(NAME(m_reloc)); - + // zerofill memset(m_timer, 0, sizeof(m_timer)); memset(m_dma, 0, sizeof(m_dma)); memset(&m_intr, 0, sizeof(intr_state)); memset(&m_mem, 0, sizeof(mem_state)); m_reloc = 0; - + m_timer[0].int_timer = timer_alloc(TIMER_INT0); m_timer[1].int_timer = timer_alloc(TIMER_INT1); m_timer[2].int_timer = timer_alloc(TIMER_INT2); @@ -633,7 +633,7 @@ void i80186_cpu_device::device_reset() m_intr.poll_status = 0x0000; m_intr.ext_state = 0x00; m_reloc = 0x20ff; - + for (int i = 0; i < ARRAY_LENGTH(m_dma); i++) { m_dma[i].drq_state = false; @@ -1477,7 +1477,7 @@ READ16_MEMBER(i80186_cpu_device::internal_port_r) WRITE16_MEMBER(i80186_cpu_device::internal_port_w) { int which; - + switch (offset) { case 0x11: diff --git a/src/emu/cpu/mcs96/mcs96.c b/src/emu/cpu/mcs96/mcs96.c index 4212039cc6d..e180a69a9ea 100644 --- a/src/emu/cpu/mcs96/mcs96.c +++ b/src/emu/cpu/mcs96/mcs96.c @@ -112,8 +112,8 @@ void mcs96_device::execute_run() { internal_update(total_cycles()); - // if(inst_substate) - // do_exec_partial(); + // if(inst_substate) + // do_exec_partial(); while(icount > 0) { while(icount > bcount) { @@ -125,8 +125,8 @@ void mcs96_device::execute_run() } while(bcount && icount <= bcount) internal_update(total_cycles() + icount - bcount); - // if(inst_substate) - // do_exec_partial(); + // if(inst_substate) + // do_exec_partial(); } } diff --git a/src/emu/cpu/mips/mips3drc.c b/src/emu/cpu/mips/mips3drc.c index a91465dd494..b8c67dc8694 100644 --- a/src/emu/cpu/mips/mips3drc.c +++ b/src/emu/cpu/mips/mips3drc.c @@ -2483,7 +2483,7 @@ int mips3_device::generate_get_cop0_reg(drcuml_block *block, compiler_state *com void mips3_device::generate_badcop(drcuml_block *block, const int cop) { UML_TEST(block, CPR032(COP0_Status), SR_COP0 << cop); // test [Status], SR_COP0 << cop - UML_EXHc(block, COND_Z, *m_exception[EXCEPTION_BADCOP], cop); // exh badcop,cop,Z + UML_EXHc(block, COND_Z, *m_exception[EXCEPTION_BADCOP], cop); // exh badcop,cop,Z } /*------------------------------------------------------------------------- diff --git a/src/emu/cpu/rsp/rsp.c b/src/emu/cpu/rsp/rsp.c index 939eb069f13..8bd0b6ec454 100644 --- a/src/emu/cpu/rsp/rsp.c +++ b/src/emu/cpu/rsp/rsp.c @@ -466,30 +466,30 @@ void rsp_device::device_start() m_regmap[regnum] = (regnum == 0) ? uml::parameter(0) : uml::parameter::make_memory(&m_rsp_state->r[regnum]); } - /* - drcbe_info beinfo; - m_drcuml->get_backend_info(beinfo); - if (beinfo.direct_iregs > 2) - { - m_regmap[30] = I2; - } - if (beinfo.direct_iregs > 3) - { - m_regmap[31] = I3; - } - if (beinfo.direct_iregs > 4) - { - m_regmap[2] = I4; - } - if (beinfo.direct_iregs > 5) - { - m_regmap[3] = I5; - } - if (beinfo.direct_iregs > 6) - { - m_regmap[4] = I6; - } - */ + /* + drcbe_info beinfo; + m_drcuml->get_backend_info(beinfo); + if (beinfo.direct_iregs > 2) + { + m_regmap[30] = I2; + } + if (beinfo.direct_iregs > 3) + { + m_regmap[31] = I3; + } + if (beinfo.direct_iregs > 4) + { + m_regmap[2] = I4; + } + if (beinfo.direct_iregs > 5) + { + m_regmap[3] = I5; + } + if (beinfo.direct_iregs > 6) + { + m_regmap[4] = I6; + } + */ /* mark the cache dirty so it is updated on next execute */ m_cache_dirty = TRUE; @@ -870,7 +870,7 @@ void rsp_device::device_stop() } if (m_drcfe ) { - auto_free(machine(), m_drcfe); + auto_free(machine(), m_drcfe); } } @@ -3565,5 +3565,3 @@ void rsp_device::execute_run() } } - - diff --git a/src/emu/cpu/rsp/rspdrc.c b/src/emu/cpu/rsp/rspdrc.c index e56f791d595..e2f5e9bb805 100644 --- a/src/emu/cpu/rsp/rspdrc.c +++ b/src/emu/cpu/rsp/rspdrc.c @@ -9029,4 +9029,3 @@ void rsp_device::log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 o block->append_comment("%08X: %s", pc, buffer); // comment #endif } - diff --git a/src/emu/cpu/sh4/sh4.c b/src/emu/cpu/sh4/sh4.c index c231b6cd8b4..0b27614c209 100644 --- a/src/emu/cpu/sh4/sh4.c +++ b/src/emu/cpu/sh4/sh4.c @@ -3080,8 +3080,8 @@ void sh4_base_device::device_reset() inline void sh34_base_device::execute_one_0000(const UINT16 opcode) { - switch(opcode & 0xff) - { + switch(opcode & 0xff) + { // 0x00 case 0x00: NOP(opcode); break; case 0x10: NOP(opcode); break; diff --git a/src/emu/cpu/tlcs90/tlcs90.c b/src/emu/cpu/tlcs90/tlcs90.c index b002cae45f7..c5854ba8a6f 100644 --- a/src/emu/cpu/tlcs90/tlcs90.c +++ b/src/emu/cpu/tlcs90/tlcs90.c @@ -2415,54 +2415,54 @@ TIMER_CALLBACK_MEMBER( tlcs90_device::t90_timer_callback ) if ( (m_internal_registers[ T90_TRUN - T90_IOBASE ] & (1 << i)) == 0 ) return; - timer_fired = 0; + timer_fired = 0; mode = (m_internal_registers[ T90_TMOD - T90_IOBASE ] >> ((i & ~1) + 2)) & 0x03; // Match - switch (mode) - { - case 0x02: // 8bit PPG - case 0x03: // 8bit PWM - logerror("CPU Timer %d expired with unhandled mode %d\n", i, mode); - // TODO: hmm... - case 0x00: // 8bit - m_timer_value[i]++; - if ( m_timer_value[i] == m_internal_registers[ T90_TREG0+i - T90_IOBASE ] ) - timer_fired = 1; - break; - - case 0x01: // 16bit - if(i & 1) - break; - m_timer_value[i]++; - if(m_timer_value[i] == 0) m_timer_value[i+1]++; - if(m_timer_value[i+1] == m_internal_registers[ T90_TREG0+i+1 - T90_IOBASE ]) - if(m_timer_value[i] == m_internal_registers[ T90_TREG0+i - T90_IOBASE ]) - timer_fired = 1; - break; - } - - if(timer_fired) { - // special stuff handling - switch(mode) { - case 0x02: // 8bit PPG - case 0x03: // 8bit PWM - // TODO: hmm... - case 0x00: // 8bit - if(i & 1) - break; - if ( (m_internal_registers[ T90_TCLK - T90_IOBASE ] & (0x0C << (i * 2))) == 0 ) // T0/T1 match signal clocks T1/T3 - t90_timer_callback(ptr, i+1); - break; - case 0x01: // 16bit, only can happen for i=0,2 - m_timer_value[i+1] = 0; - set_irq_line(INTT0 + i+1, 1); - break; - } - // regular handling - m_timer_value[i] = 0; - set_irq_line(INTT0 + i, 1); - } + switch (mode) + { + case 0x02: // 8bit PPG + case 0x03: // 8bit PWM + logerror("CPU Timer %d expired with unhandled mode %d\n", i, mode); + // TODO: hmm... + case 0x00: // 8bit + m_timer_value[i]++; + if ( m_timer_value[i] == m_internal_registers[ T90_TREG0+i - T90_IOBASE ] ) + timer_fired = 1; + break; + + case 0x01: // 16bit + if(i & 1) + break; + m_timer_value[i]++; + if(m_timer_value[i] == 0) m_timer_value[i+1]++; + if(m_timer_value[i+1] == m_internal_registers[ T90_TREG0+i+1 - T90_IOBASE ]) + if(m_timer_value[i] == m_internal_registers[ T90_TREG0+i - T90_IOBASE ]) + timer_fired = 1; + break; + } + + if(timer_fired) { + // special stuff handling + switch(mode) { + case 0x02: // 8bit PPG + case 0x03: // 8bit PWM + // TODO: hmm... + case 0x00: // 8bit + if(i & 1) + break; + if ( (m_internal_registers[ T90_TCLK - T90_IOBASE ] & (0x0C << (i * 2))) == 0 ) // T0/T1 match signal clocks T1/T3 + t90_timer_callback(ptr, i+1); + break; + case 0x01: // 16bit, only can happen for i=0,2 + m_timer_value[i+1] = 0; + set_irq_line(INTT0 + i+1, 1); + break; + } + // regular handling + m_timer_value[i] = 0; + set_irq_line(INTT0 + i, 1); + } } TIMER_CALLBACK_MEMBER( tlcs90_device::t90_timer4_callback ) diff --git a/src/emu/cpu/tms32031/tms32031.h b/src/emu/cpu/tms32031/tms32031.h index 427d0cd6d3d..92e1f35d80c 100644 --- a/src/emu/cpu/tms32031/tms32031.h +++ b/src/emu/cpu/tms32031/tms32031.h @@ -775,7 +775,7 @@ protected: devcb_write8 m_xf0_cb; devcb_write8 m_xf1_cb; devcb_write8 m_iack_cb; - + // tables static void (tms3203x_device::*const s_tms32031ops[])(UINT32 op); static UINT32 (tms3203x_device::*const s_indirect_d[0x20])(UINT32, UINT8); diff --git a/src/emu/cpu/tms32051/tms32051.c b/src/emu/cpu/tms32051/tms32051.c index 5df21dac096..2347ddf0632 100644 --- a/src/emu/cpu/tms32051/tms32051.c +++ b/src/emu/cpu/tms32051/tms32051.c @@ -45,7 +45,7 @@ const device_type TMS32051 = &device_creator; **************************************************************************/ static ADDRESS_MAP_START( internal_pgm, AS_PROGRAM, 16, tms32051_device ) -// AM_RANGE(0x0000, 0x1fff) AM_ROM // ROM TODO: is off-chip if MP/_MC = 0 +// AM_RANGE(0x0000, 0x1fff) AM_ROM // ROM TODO: is off-chip if MP/_MC = 0 AM_RANGE(0x2000, 0x23ff) AM_RAM AM_SHARE("saram") // SARAM TODO: is off-chip if RAM bit = 0 AM_RANGE(0xfe00, 0xffff) AM_RAM AM_SHARE("daram_b0") // DARAM B0 TODO: is off-chip if CNF = 0 ADDRESS_MAP_END @@ -406,7 +406,7 @@ READ16_MEMBER( tms32051_device::cpuregs_r ) case 0x1d: return m_cber2; case 0x1e: return m_cbcr; case 0x1f: return m_bmar; - + case 0x20: return m_serial.drr; case 0x21: return m_serial.dxr; diff --git a/src/emu/cpu/tms32051/tms32051.h b/src/emu/cpu/tms32051/tms32051.h index 97304de2ddf..ee1630311ef 100644 --- a/src/emu/cpu/tms32051/tms32051.h +++ b/src/emu/cpu/tms32051/tms32051.h @@ -134,7 +134,7 @@ private: UINT16 tim; UINT16 prd; } m_timer; - + struct { UINT16 drr; diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index 78e558575a8..22db4ceecad 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -37,7 +37,7 @@ tms340x0_device::tms340x0_device(const machine_config &mconfig, device_type type , m_program_config("program", ENDIANNESS_LITTLE, 16, 32, 3) , m_reset_deferred(FALSE) , m_pixclock(0) - , m_pixperclock(0) + , m_pixperclock(0) , m_output_int_cb(*this) { } @@ -574,7 +574,7 @@ void tms340x0_device::device_start() m_output_int_cb.resolve(); m_to_shiftreg_cb.bind_relative_to(*owner()); m_from_shiftreg_cb.bind_relative_to(*owner()); - + m_external_host_access = FALSE; m_program = &space(AS_PROGRAM); diff --git a/src/emu/cpu/tms34010/tms34010.h b/src/emu/cpu/tms34010/tms34010.h index d890555735e..c2feb5746ef 100644 --- a/src/emu/cpu/tms34010/tms34010.h +++ b/src/emu/cpu/tms34010/tms34010.h @@ -190,29 +190,29 @@ struct tms34010_display_params #define MCFG_TMS340X0_HALT_ON_RESET(_value) \ tms340x0_device::set_halt_on_reset(*device, _value); - + #define MCFG_TMS340X0_PIXEL_CLOCK(_value) \ tms340x0_device::set_pixel_clock(*device, _value); - + #define MCFG_TMS340X0_PIXELS_PER_CLOCK(_value) \ tms340x0_device::set_pixels_per_clock(*device, _value); - + typedef device_delegate scanline_ind16_cb_delegate; #define TMS340X0_SCANLINE_IND16_CB_MEMBER(_name) void _name(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params) - + #define MCFG_TMS340X0_SCANLINE_IND16_CB(_class, _method) \ - tms340x0_device::set_scanline_ind16_callback(*device, scanline_ind16_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); - + tms340x0_device::set_scanline_ind16_callback(*device, scanline_ind16_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + typedef device_delegate scanline_rgb32_cb_delegate; #define TMS340X0_SCANLINE_RGB32_CB_MEMBER(_name) void _name(screen_device &screen, bitmap_rgb32 &bitmap, int scanline, const tms34010_display_params *params) #define MCFG_TMS340X0_SCANLINE_RGB32_CB(_class, _method) \ - tms340x0_device::set_scanline_rgb32_callback(*device, scanline_rgb32_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + tms340x0_device::set_scanline_rgb32_callback(*device, scanline_rgb32_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + - #define MCFG_TMS340X0_OUTPUT_INT_CB(_devcb) \ devcb = &tms340x0_device::set_output_int_callback(*device, DEVCB_##_devcb); @@ -220,21 +220,21 @@ typedef device_delegate to_shiftreg_cb_delegate; #define TMS340X0_TO_SHIFTREG_CB_MEMBER(_name) void _name(address_space &space, offs_t address, UINT16 *shiftreg) - + #define MCFG_TMS340X0_TO_SHIFTREG_CB(_class, _method) \ - tms340x0_device::set_to_shiftreg_callback(*device, to_shiftreg_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); - + tms340x0_device::set_to_shiftreg_callback(*device, to_shiftreg_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + typedef device_delegate from_shiftreg_cb_delegate; #define TMS340X0_FROM_SHIFTREG_CB_MEMBER(_name) void _name(address_space &space, offs_t address, UINT16 *shiftreg) #define MCFG_TMS340X0_FROM_SHIFTREG_CB(_class, _method) \ - tms340x0_device::set_from_shiftreg_callback(*device, from_shiftreg_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + tms340x0_device::set_from_shiftreg_callback(*device, from_shiftreg_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + - class tms340x0_device : public cpu_device, - public device_video_interface + public device_video_interface { public: // construction/destruction @@ -337,9 +337,9 @@ protected: int m_pixperclock; /* pixels per clock */ emu_timer *m_scantimer; int m_icount; - - scanline_ind16_cb_delegate m_scanline_ind16_cb; - scanline_rgb32_cb_delegate m_scanline_rgb32_cb; + + scanline_ind16_cb_delegate m_scanline_ind16_cb; + scanline_rgb32_cb_delegate m_scanline_rgb32_cb; devcb_write_line m_output_int_cb; /* output interrupt callback */ to_shiftreg_cb_delegate m_to_shiftreg_cb; /* shift register write */ from_shiftreg_cb_delegate m_from_shiftreg_cb; /* shift register read */ diff --git a/src/emu/cpu/tms7000/tms7000.c b/src/emu/cpu/tms7000/tms7000.c index ed0b0276012..b6ab60ab9b0 100644 --- a/src/emu/cpu/tms7000/tms7000.c +++ b/src/emu/cpu/tms7000/tms7000.c @@ -899,7 +899,7 @@ void tms70c46_device::device_start() { // init/zerofill m_control = 0; - + // register for savestates save_item(NAME(m_control)); @@ -910,7 +910,7 @@ void tms70c46_device::device_reset() { m_control = 0; m_io->write_byte(TMS7000_PORTE, 0xff); - + tms7000_device::device_reset(); } diff --git a/src/emu/cpu/tms7000/tms7000.h b/src/emu/cpu/tms7000/tms7000.h index 20fa8d9b993..633015fe0bb 100644 --- a/src/emu/cpu/tms7000/tms7000.h +++ b/src/emu/cpu/tms7000/tms7000.h @@ -313,7 +313,7 @@ public: DECLARE_READ8_MEMBER(control_r); DECLARE_WRITE8_MEMBER(control_w); - + DECLARE_READ8_MEMBER(dockbus_status_r); DECLARE_WRITE8_MEMBER(dockbus_status_w); DECLARE_READ8_MEMBER(dockbus_data_r); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 0b8a9d33d51..b05c702b587 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -1931,7 +1931,7 @@ void device_debug::instruction_hook(offs_t curpc) machine.debug_view().flush_osd_updates(); machine.manager().web()->serve(); - + // clear the memory modified flag and wait global->memory_modified = false; if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) diff --git a/src/emu/devcpu.c b/src/emu/devcpu.c index 797a8b49efa..d67752d68a6 100644 --- a/src/emu/devcpu.c +++ b/src/emu/devcpu.c @@ -38,4 +38,3 @@ cpu_device::cpu_device(const machine_config &mconfig, device_type type, const ch cpu_device::~cpu_device() { } - diff --git a/src/emu/diimage.c b/src/emu/diimage.c index a965c5bf5e0..5345db27ec4 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -1229,9 +1229,9 @@ software_part *device_image_interface::find_software_item(const char *path, bool if (swinfo_name == swlistdev->list_name()) { - // ad hoc handling for the case path = swlist_name:swinfo_name (e.g. - // gameboy:sml) which is not handled properly by software_name_split - // since the function cannot distinguish between this and the case + // ad hoc handling for the case path = swlist_name:swinfo_name (e.g. + // gameboy:sml) which is not handled properly by software_name_split + // since the function cannot distinguish between this and the case // path = swinfo_name:swpart_name software_info *info = swlistdev->find(swpart_name); if (info != NULL) diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c index a73463f77b7..bcdf93073fb 100644 --- a/src/emu/imagedev/floppy.c +++ b/src/emu/imagedev/floppy.c @@ -885,7 +885,7 @@ void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist) input_filename = filename; input_format = static_cast(image)->identify(filename); - if (!input_format) + if (!input_format) { popmessage("Error: %s\n", image->error()); ui_menu::stack_pop(machine()); diff --git a/src/emu/machine.c b/src/emu/machine.c index 0c89f6866ca..496becef381 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -379,7 +379,7 @@ int running_machine::run(bool firstrun) #endif manager().web()->serve(); - + // execute CPUs if not paused if (!m_paused) m_scheduler.timeslice(); diff --git a/src/emu/machine/mb8421.c b/src/emu/machine/mb8421.c index 12f912971be..0d3cb819a66 100644 --- a/src/emu/machine/mb8421.c +++ b/src/emu/machine/mb8421.c @@ -4,7 +4,7 @@ Fujitsu MB8421/22/31/32-90/-90L/-90LL/-12/-12L/-12LL CMOS 16K-bit (2KB) dual-port SRAM - + MB84x2 lacks interrupt pins, it's basically as simple as AM_RAM AM_SHARE("x") MB843x is same as MB842x, except that it supports slave mode. It makes sure there are no clashes, with the _BUSY pin. @@ -70,7 +70,7 @@ READ8_MEMBER(mb8421_device::left_r) if (offset == 0x7fe && !space.debugger_access()) m_intl_handler(0); - + return m_ram[offset]; } @@ -89,6 +89,6 @@ READ8_MEMBER(mb8421_device::right_r) if (offset == 0x7ff && !space.debugger_access()) m_intr_handler(0); - + return m_ram[offset]; } diff --git a/src/emu/machine/pit8253.c b/src/emu/machine/pit8253.c index f75e18c6cd0..2b9448582dd 100644 --- a/src/emu/machine/pit8253.c +++ b/src/emu/machine/pit8253.c @@ -103,7 +103,7 @@ void pit8253_device::device_start() for (int timerno = 0; timerno < PIT8253_MAX_TIMER; timerno++) { pit8253_timer *timer = get_timer(timerno); - + /* initialize timer */ timer->updatetimer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pit8253_device::update_timer_cb),this)); timer->updatetimer->adjust(attotime::never, timerno); diff --git a/src/emu/machine/rp5h01.c b/src/emu/machine/rp5h01.c index 40279665ca0..3535cbe0f4e 100644 --- a/src/emu/machine/rp5h01.c +++ b/src/emu/machine/rp5h01.c @@ -7,7 +7,7 @@ with a mask of %1010111. For example if the 8 dummy bits are $7c, bits 64 to 127 are read as $7c $7c $00 $00 $7c $7c $00 $00. To simplify this, our emulation expects 'overdumps', 128bits total. - + TODO: - not sure if the polarity of our PROM dumps (playch10) is correct, same goes for the bit order (note: does not require new dumps) diff --git a/src/emu/machine/smpc.c b/src/emu/machine/smpc.c index 20bde988d77..add9009417c 100644 --- a/src/emu/machine/smpc.c +++ b/src/emu/machine/smpc.c @@ -172,7 +172,7 @@ void saturn_state::stv_select_game(int gameno) memcpy(memregion("abus")->base(), m_cart_reg[gameno]->base(), 0x3000000); else memset(memregion("abus")->base(), 0x00, 0x3000000); - + m_prev_bankswitch = gameno; } } diff --git a/src/emu/machine/wozfdc.c b/src/emu/machine/wozfdc.c index 0f9e79a0a35..a6f2a10167e 100644 --- a/src/emu/machine/wozfdc.c +++ b/src/emu/machine/wozfdc.c @@ -80,7 +80,7 @@ void wozfdc_device::device_start() save_item(NAME(cur_lss.data_reg)); save_item(NAME(cur_lss.address)); save_item(NAME(cur_lss.write_start_time)); -// save_item(NAME(cur_lss.write_buffer)); +// save_item(NAME(cur_lss.write_buffer)); save_item(NAME(cur_lss.write_position)); save_item(NAME(cur_lss.write_line_active)); save_item(NAME(predicted_lss.tm)); @@ -88,7 +88,7 @@ void wozfdc_device::device_start() save_item(NAME(predicted_lss.data_reg)); save_item(NAME(predicted_lss.address)); save_item(NAME(predicted_lss.write_start_time)); -// save_item(NAME(predicted_lss.write_buffer)); +// save_item(NAME(predicted_lss.write_buffer)); save_item(NAME(predicted_lss.write_position)); save_item(NAME(predicted_lss.write_line_active)); save_item(NAME(drvsel)); @@ -582,6 +582,6 @@ void appleiii_fdc::control_dx(int offset) if (offset < 8) { - a3_update_drive_sel(); + a3_update_drive_sel(); } } diff --git a/src/emu/sound/flt_rc.h b/src/emu/sound/flt_rc.h index 8bfdecec973..aed08d8c0fe 100644 --- a/src/emu/sound/flt_rc.h +++ b/src/emu/sound/flt_rc.h @@ -73,7 +73,7 @@ public: // static configuration static void static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C); - + void filter_rc_set_RC(int type, double R1, double R2, double R3, double C); protected: @@ -91,10 +91,10 @@ private: int m_k; int m_memory; int m_type; - double m_R1; - double m_R2; - double m_R3; - double m_C; + double m_R1; + double m_R2; + double m_R3; + double m_C; }; extern const device_type FILTER_RC; diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index b4d0710fd78..32fc2921eb1 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -385,7 +385,7 @@ void k053260_device::KDSC_Voice::key_on() else if (m_start + m_length >= m_device->m_rom_size) logerror("K053260: Attempting to play past the end of the ROM ( start = %06x, length = %06x )\n", - m_start, m_length); + m_start, m_length); else { @@ -464,7 +464,7 @@ UINT8 k053260_device::KDSC_Voice::read_rom() if (offs >= m_device->m_rom_size) { logerror("%s: K053260: Attempting to read past the end of the ROM (offs = %06x, size = %06x)\n", - m_device->machine().describe_context(), offs, m_device->m_rom_size); + m_device->machine().describe_context(), offs, m_device->m_rom_size); return 0; } diff --git a/src/emu/sound/k053260.h b/src/emu/sound/k053260.h index 8e2e4731d29..735978fb32b 100644 --- a/src/emu/sound/k053260.h +++ b/src/emu/sound/k053260.h @@ -60,7 +60,7 @@ private: UINT32 m_rom_size; // live state - UINT8 m_portdata[4]; + UINT8 m_portdata[4]; UINT8 m_keyon; UINT8 m_mode; diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c index 367b5dbcd8e..568d68e536c 100644 --- a/src/emu/sound/samples.c +++ b/src/emu/sound/samples.c @@ -264,7 +264,7 @@ void samples_device::device_start() // initialize any custom handlers m_samples_start_cb.bind_relative_to(*owner()); - + if (!m_samples_start_cb.isnull()) m_samples_start_cb(); } diff --git a/src/emu/sound/samples.h b/src/emu/sound/samples.h index 28639cc6e95..cb436329a0e 100644 --- a/src/emu/sound/samples.h +++ b/src/emu/sound/samples.h @@ -23,11 +23,11 @@ #define MCFG_SAMPLES_NAMES(_names) \ samples_device::static_set_samples_names(*device, _names); - + typedef device_delegate samples_start_cb_delegate; #define SAMPLES_START_CB_MEMBER(_name) void _name() - + #define MCFG_SAMPLES_START_CB(_class, _method) \ samples_device::set_samples_start_callback(*device, samples_start_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); @@ -74,7 +74,7 @@ public: dynamic_array data; // 16-bit signed data }; static bool read_sample(emu_file &file, sample_t &sample); - + // interface UINT8 m_channels; // number of discrete audio channels needed const char *const *m_names; // array of sample names diff --git a/src/emu/sound/speaker.h b/src/emu/sound/speaker.h index cc61ddf1101..ee6b3297f37 100644 --- a/src/emu/sound/speaker.h +++ b/src/emu/sound/speaker.h @@ -26,7 +26,7 @@ class speaker_sound_device : public device_t, public: speaker_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~speaker_sound_device() {} - + // static configuration static void static_set_levels(device_t &device, int num_levels, const INT16 *levels) { downcast(device).m_num_levels = num_levels; downcast(device).m_levels = levels;} @@ -80,7 +80,7 @@ private: // DC blocker state double m_prevx, m_prevy; - + int m_num_levels; /* optional: number of levels (if not two) */ const INT16 *m_levels; /* optional: pointer to level lookup table */ }; diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 93ea2d58c10..1e97e2673d2 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -75,7 +75,7 @@ // default address map static ADDRESS_MAP_START( ymf278b, AS_0, 8, ymf278b_device ) - AM_RANGE(0x000000, 0x3fffff) AM_ROM + AM_RANGE(0x000000, 0x3fffff) AM_ROM ADDRESS_MAP_END diff --git a/src/emu/sound/zsg2.c b/src/emu/sound/zsg2.c index b8d1102b07d..08bff142957 100644 --- a/src/emu/sound/zsg2.c +++ b/src/emu/sound/zsg2.c @@ -142,7 +142,7 @@ void zsg2_device::device_reset() prepare_samples(i); FILE* f; - + f = fopen("zoom_samples.bin","wb"); fwrite(m_mem_copy,1,m_mem_blocks*4,f); fclose(f); diff --git a/src/emu/ui/swlist.c b/src/emu/ui/swlist.c index 95c4a489098..a2b6b7e46c5 100644 --- a/src/emu/ui/swlist.c +++ b/src/emu/ui/swlist.c @@ -68,7 +68,7 @@ void ui_menu_software_parts::populate() entry2->part = 0; item_append("[file manager]", 0, 0, entry2); - + software_part_menu_entry *entry3 = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry3)); entry3->type = T_SWLIST; entry3->part = 0; diff --git a/src/emu/ui/ui.c b/src/emu/ui/ui.c index 8d922696098..0d70c7e774a 100644 --- a/src/emu/ui/ui.c +++ b/src/emu/ui/ui.c @@ -1554,7 +1554,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co machine.pause(); return machine.ui().set_handler(ui_gfx_ui_handler, is_paused); } - + // handle a tape control key if (ui_input_pressed(machine, IPT_UI_TAPE_START)) { @@ -1574,7 +1574,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co return 0; } } - + // handle a save state request if (ui_input_pressed(machine, IPT_UI_SAVE_STATE)) { diff --git a/src/emu/video/315_5124.c b/src/emu/video/315_5124.c index e4a525d41cc..48aa0b670b9 100644 --- a/src/emu/video/315_5124.c +++ b/src/emu/video/315_5124.c @@ -677,7 +677,7 @@ WRITE8_MEMBER( sega315_5124_device::register_write ) reg_num = data & 0x0f; m_reg[reg_num] = m_addr & 0xff; //logerror("%s: %s: setting register %x to %02x\n", machine().describe_context(), tag(), reg_num, m_addr & 0xf ); - + switch (reg_num) { case 0: diff --git a/src/emu/video/epic12.c b/src/emu/video/epic12.c index de5e98e5c2c..3d42c07783f 100644 --- a/src/emu/video/epic12.c +++ b/src/emu/video/epic12.c @@ -41,7 +41,7 @@ void epic12_device::device_start() m_bitmaps = auto_bitmap_rgb32_alloc(machine(), 0x2000, 0x1000); m_clip = m_bitmaps->cliprect(); m_clip.set(0, 0x2000-1, 0, 0x1000-1); - + m_ram16_copy = auto_alloc_array(machine(), UINT16, m_main_ramsize/2); m_blitter_delay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(epic12_device::blitter_delay_callback),this)); diff --git a/src/emu/video/upd7220.c b/src/emu/video/upd7220.c index fd322499047..d9a61c0bbec 100644 --- a/src/emu/video/upd7220.c +++ b/src/emu/video/upd7220.c @@ -764,7 +764,7 @@ void upd7220_device::draw_pixel(int x, int y, int xi, UINT16 tile_data) UINT8 data = readbyte(addr); UINT8 new_pixel = (xi & 8 ? tile_data >> 8 : tile_data & 0xff) & (0x80 >> (xi & 7)); new_pixel = new_pixel ? (0xff & (0x80 >> (x & 7))) : 0; - + switch(m_bitmap_mod) { case 0: //replace diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index bae8fbfbee7..819c285f290 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -1726,8 +1726,8 @@ struct voodoo_state raster_info rasterizer[MAX_RASTERIZERS]; /* array of rasterizers */ raster_info * raster_hash[RASTER_HASH_SIZE]; /* hash table of rasterizers */ - bool send_config; - UINT32 tmu_config; + bool send_config; + UINT32 tmu_config; }; @@ -3646,18 +3646,18 @@ static void raster_##name(void *destbase, INT32 y, const poly_extent *extent, co /* result in texel */ \ /* note that they set LOD min to 8 to "disable" a TMU */ \ if (TMUS >= 1 && v->tmu[0].lodmin < (8 << 8)) \ - { \ + { \ if (!v->send_config) \ - { \ + { \ TEXTURE_PIPELINE(&v->tmu[0], x, dither4, TEXMODE0, texel, \ v->tmu[0].lookup, extra->lodbase0, \ iters0, itert0, iterw0, texel); \ - } \ - else \ - { \ + } \ + else \ + { \ texel.u=v->tmu_config; \ - } \ - } \ + } \ + } \ \ /* colorpath pipeline selects source colors and does blending */ \ CLAMPED_ARGB(iterr, iterg, iterb, itera, FBZCOLORPATH, iterargb); \ diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index b4f38a606a1..d84fef0261f 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -4915,7 +4915,7 @@ void voodoo_device::common_start_voodoo(UINT8 type) } } - v->tmu_config = 0x11; // revision 1 + v->tmu_config = 0x11; // revision 1 /* configure type-specific values */ switch (v->type) @@ -4969,7 +4969,7 @@ void voodoo_device::common_start_voodoo(UINT8 type) assert_always(v->cpu != NULL, "Unable to find CPU attached to voodoo"); if (m_tmumem1 != 0) - v->tmu_config |= 0xc0; // two TMUs + v->tmu_config |= 0xc0; // two TMUs v->chipmask = 0x01; v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq; diff --git a/src/emu/webengine.c b/src/emu/webengine.c index 3b26990fb90..c7fc8952f8a 100644 --- a/src/emu/webengine.c +++ b/src/emu/webengine.c @@ -133,128 +133,128 @@ int web_engine::json_slider_handler(struct mg_connection *conn) } void reg_string(struct lua_State *L, const char *name, const char *val) { - lua_pushstring(L, name); - lua_pushstring(L, val); - lua_rawset(L, -3); + lua_pushstring(L, name); + lua_pushstring(L, val); + lua_rawset(L, -3); } void reg_int(struct lua_State *L, const char *name, int val) { - lua_pushstring(L, name); - lua_pushinteger(L, val); - lua_rawset(L, -3); + lua_pushstring(L, name); + lua_pushinteger(L, val); + lua_rawset(L, -3); } void reg_function(struct lua_State *L, const char *name, - lua_CFunction func, struct mg_connection *conn) { - lua_pushstring(L, name); - lua_pushlightuserdata(L, conn); - lua_pushcclosure(L, func, 1); - lua_rawset(L, -3); + lua_CFunction func, struct mg_connection *conn) { + lua_pushstring(L, name); + lua_pushlightuserdata(L, conn); + lua_pushcclosure(L, func, 1); + lua_rawset(L, -3); } static int lua_write(lua_State *L) { - int i, num_args; - const char *str; - size_t size; - struct mg_connection *conn = (struct mg_connection *) - lua_touserdata(L, lua_upvalueindex(1)); - - num_args = lua_gettop(L); - for (i = 1; i <= num_args; i++) { - if (lua_isstring(L, i)) { - str = lua_tolstring(L, i, &size); - mg_send_data(conn, str, size); - } - } - - return 0; + int i, num_args; + const char *str; + size_t size; + struct mg_connection *conn = (struct mg_connection *) + lua_touserdata(L, lua_upvalueindex(1)); + + num_args = lua_gettop(L); + for (i = 1; i <= num_args; i++) { + if (lua_isstring(L, i)) { + str = lua_tolstring(L, i, &size); + mg_send_data(conn, str, size); + } + } + + return 0; } static int lua_header(lua_State *L) { - struct mg_connection *conn = (struct mg_connection *) - lua_touserdata(L, lua_upvalueindex(1)); + struct mg_connection *conn = (struct mg_connection *) + lua_touserdata(L, lua_upvalueindex(1)); + + const char *header = luaL_checkstring(L,1); + const char *value = luaL_checkstring(L,2); - const char *header = luaL_checkstring(L,1); - const char *value = luaL_checkstring(L,2); - - mg_send_header(conn, header, value); + mg_send_header(conn, header, value); - return 0; + return 0; } static void prepare_lua_environment(struct mg_connection *ri, lua_State *L) { - extern void luaL_openlibs(lua_State *); - int i; - - luaL_openlibs(L); - - if (ri == NULL) return; - - // Register mg module - lua_newtable(L); - reg_function(L, "write", lua_write, ri); - reg_function(L, "header", lua_header, ri); - - // Export request_info - lua_pushstring(L, "request_info"); - lua_newtable(L); - reg_string(L, "request_method", ri->request_method); - reg_string(L, "uri", ri->uri); - reg_string(L, "http_version", ri->http_version); - reg_string(L, "query_string", ri->query_string); - reg_string(L, "remote_ip", ri->remote_ip); - reg_int(L, "remote_port", ri->remote_port); - reg_string(L, "local_ip", ri->local_ip); - reg_int(L, "local_port", ri->local_port); - lua_pushstring(L, "content"); - lua_pushlstring(L, ri->content == NULL ? "" : ri->content, ri->content_len); - lua_rawset(L, -3); - reg_int(L, "num_headers", ri->num_headers); - lua_pushstring(L, "http_headers"); - lua_newtable(L); - for (i = 0; i < ri->num_headers; i++) { - reg_string(L, ri->http_headers[i].name, ri->http_headers[i].value); - } - lua_rawset(L, -3); - lua_rawset(L, -3); - - lua_setglobal(L, "mg"); + extern void luaL_openlibs(lua_State *); + int i; + + luaL_openlibs(L); + + if (ri == NULL) return; + + // Register mg module + lua_newtable(L); + reg_function(L, "write", lua_write, ri); + reg_function(L, "header", lua_header, ri); + + // Export request_info + lua_pushstring(L, "request_info"); + lua_newtable(L); + reg_string(L, "request_method", ri->request_method); + reg_string(L, "uri", ri->uri); + reg_string(L, "http_version", ri->http_version); + reg_string(L, "query_string", ri->query_string); + reg_string(L, "remote_ip", ri->remote_ip); + reg_int(L, "remote_port", ri->remote_port); + reg_string(L, "local_ip", ri->local_ip); + reg_int(L, "local_port", ri->local_port); + lua_pushstring(L, "content"); + lua_pushlstring(L, ri->content == NULL ? "" : ri->content, ri->content_len); + lua_rawset(L, -3); + reg_int(L, "num_headers", ri->num_headers); + lua_pushstring(L, "http_headers"); + lua_newtable(L); + for (i = 0; i < ri->num_headers; i++) { + reg_string(L, ri->http_headers[i].name, ri->http_headers[i].value); + } + lua_rawset(L, -3); + lua_rawset(L, -3); + + lua_setglobal(L, "mg"); } static void lsp(struct mg_connection *conn, const char *p, int len, lua_State *L) { - int i, j, pos = 0; - for (i = 0; i < len; i++) { - if (p[i] == '<' && p[i + 1] == '?') { - for (j = i + 1; j < len ; j++) { - if (p[j] == '?' && p[j + 1] == '>') { - if (i-pos!=0) mg_send_data(conn, p + pos, i - pos); - if (luaL_loadbuffer(L, p + (i + 2), j - (i + 2), "") == 0) { - lua_pcall(L, 0, LUA_MULTRET, 0); - } - pos = j + 2; - i = pos - 1; - break; - } - } - } - } - if (i > pos) { + int i, j, pos = 0; + for (i = 0; i < len; i++) { + if (p[i] == '<' && p[i + 1] == '?') { + for (j = i + 1; j < len ; j++) { + if (p[j] == '?' && p[j + 1] == '>') { + if (i-pos!=0) mg_send_data(conn, p + pos, i - pos); + if (luaL_loadbuffer(L, p + (i + 2), j - (i + 2), "") == 0) { + lua_pcall(L, 0, LUA_MULTRET, 0); + } + pos = j + 2; + i = pos - 1; + break; + } + } + } + } + if (i > pos) { mg_send_data(conn, p + pos, i - pos); - } + } } static int filename_endswith(const char *str, const char *suffix) { - if (!str || !suffix) - return 0; - size_t lenstr = strlen(str); - size_t lensuffix = strlen(suffix); - if (lensuffix > lenstr) - return 0; - return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0; + if (!str || !suffix) + return 0; + size_t lenstr = strlen(str); + size_t lensuffix = strlen(suffix); + if (lensuffix > lenstr) + return 0; + return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0; } // This function will be called by mongoose on every new request. @@ -263,24 +263,24 @@ int web_engine::begin_request_handler(struct mg_connection *conn) astring file_path(mg_get_option(m_server, "document_root"), PATH_SEPARATOR, conn->uri); if (filename_endswith(file_path,".lp")) { - FILE *fp = NULL; - if ((fp = fopen(file_path, "rb")) != NULL) { - fseek (fp, 0, SEEK_END); + FILE *fp = NULL; + if ((fp = fopen(file_path, "rb")) != NULL) { + fseek (fp, 0, SEEK_END); size_t size = ftell(fp); - fseek (fp, 0, SEEK_SET); + fseek (fp, 0, SEEK_SET); char *data = (char*)mg_mmap(fp,size); lua_State *L = luaL_newstate(); - prepare_lua_environment(conn, L); + prepare_lua_environment(conn, L); lsp(conn, data, (int) size, L); if (L != NULL) lua_close(L); mg_munmap(data,size); - fclose(fp); - return MG_TRUE; - } else { - return MG_FALSE; - } - } + fclose(fp); + return MG_TRUE; + } else { + return MG_FALSE; + } + } else if (!strncmp(conn->uri, "/json/",6)) { if (!strcmp(conn->uri, "/json/game")) @@ -295,13 +295,13 @@ int web_engine::begin_request_handler(struct mg_connection *conn) else if (!strncmp(conn->uri, "/keypost",8)) { // Is there any sane way to determine the length of the buffer before getting it? - // A request for a way was previously filed with the mongoose devs, + // A request for a way was previously filed with the mongoose devs, // but it looks like it was never implemented. - - // For now, we'll allow a paste buffer of 32k. + + // For now, we'll allow a paste buffer of 32k. // To-do: Send an error if the paste is too big? char cmd_val[32768]; - + int pastelength = mg_get_var(conn, "val", cmd_val, sizeof(cmd_val)); if (pastelength > 0) { machine().ioport().natkeyboard().post_utf8(cmd_val); @@ -326,10 +326,10 @@ int web_engine::begin_request_handler(struct mg_connection *conn) while ((ofs = mg_parse_multipart(conn->content + ofs, conn->content_len - ofs, var_name, sizeof(var_name), file_name, sizeof(file_name), (const char **)&upload_data, &data_length)) > 0) { mg_printf_data(conn, "File: %s, size: %d bytes", file_name, data_length); } - + // That upload_data contains more than we need. It also has the headers. // We'll need to strip it down to just what we want. - + if ((&data_length > 0) && (sizeof(file_name) > 0)) { // MSVC doesn't yet support variable-length arrays, so chop the string the old-fashioned way diff --git a/src/lib/formats/ap2_dsk.c b/src/lib/formats/ap2_dsk.c index 1e1f81ef1a8..8293ee9e565 100644 --- a/src/lib/formats/ap2_dsk.c +++ b/src/lib/formats/ap2_dsk.c @@ -624,7 +624,7 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im if (!memcmp("PRODOS", §or_data[0x103], 6)) { m_prodos_order = true; - } // check for alternate version ProDOS boot block + } // check for alternate version ProDOS boot block if (!memcmp("PRODOS", §or_data[0x121], 6)) { m_prodos_order = true; @@ -654,7 +654,7 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im else if (!memcmp(dos33_block1, §or_data[0x100], 4)) { m_prodos_order = true; - } // check for a later version of the Pascal boot block + } // check for a later version of the Pascal boot block else if (!memcmp(pascal2_block1, §or_data[0x100], 4)) { m_prodos_order = true; diff --git a/src/lib/formats/dmk_dsk.c b/src/lib/formats/dmk_dsk.c index af1f134f94a..2af453d66fa 100644 --- a/src/lib/formats/dmk_dsk.c +++ b/src/lib/formats/dmk_dsk.c @@ -226,4 +226,3 @@ bool dmk_format::supports_save() const const floppy_format_type FLOPPY_DMK_FORMAT = &floppy_image_format_creator; - diff --git a/src/lib/formats/dmk_dsk.h b/src/lib/formats/dmk_dsk.h index 68c4d8deea3..5167f0502cc 100644 --- a/src/lib/formats/dmk_dsk.h +++ b/src/lib/formats/dmk_dsk.h @@ -31,4 +31,3 @@ public: extern const floppy_format_type FLOPPY_DMK_FORMAT; #endif /* DMK_DSK_H */ - diff --git a/src/lib/formats/mfi_dsk.c b/src/lib/formats/mfi_dsk.c index 8033b0207e4..13a23abe94b 100644 --- a/src/lib/formats/mfi_dsk.c +++ b/src/lib/formats/mfi_dsk.c @@ -99,8 +99,8 @@ int mfi_format::identify(io_generic *io, UINT32 form_factor) io_generic_read(io, &h, 0, sizeof(header)); if(memcmp( h.sign, sign, 16 ) == 0 && - (h.cyl_count & CYLINDER_MASK) <= 84 && - (h.cyl_count >> RESOLUTION_SHIFT) < 3 && + (h.cyl_count & CYLINDER_MASK) <= 84 && + (h.cyl_count >> RESOLUTION_SHIFT) < 3 && h.head_count <= 2 && (!form_factor || !h.form_factor || h.form_factor == form_factor)) return 100; diff --git a/src/lib/web/mongoose.c b/src/lib/web/mongoose.c index 3b2259fd149..e9305981bac 100644 --- a/src/lib/web/mongoose.c +++ b/src/lib/web/mongoose.c @@ -128,7 +128,7 @@ typedef int sock_t; #ifdef NS_ENABLE_DEBUG #define DBG(x) do { printf("%-20s ", __func__); printf x; putchar('\n'); \ - fflush(stdout); } while(0) + fflush(stdout); } while(0) #else #define DBG(x) #endif @@ -150,20 +150,20 @@ extern "C" { #endif // __cplusplus union socket_address { - struct sockaddr sa; - struct sockaddr_in sin; + struct sockaddr sa; + struct sockaddr_in sin; #ifdef NS_ENABLE_IPV6 - struct sockaddr_in6 sin6; + struct sockaddr_in6 sin6; #else - struct sockaddr sin6; + struct sockaddr sin6; #endif }; // IO buffers interface struct iobuf { - char *buf; - size_t len; - size_t size; + char *buf; + size_t len; + size_t size; }; void iobuf_init(struct iobuf *, size_t initial_size); @@ -174,12 +174,12 @@ void iobuf_remove(struct iobuf *, size_t data_size); // Net skeleton interface // Events. Meaning of event parameter (evp) is given in the comment. enum ns_event { - NS_POLL, // Sent to each connection on each call to ns_server_poll() - NS_ACCEPT, // New connection accept()-ed. union socket_address *remote_addr - NS_CONNECT, // connect() succeeded or failed. int *success_status - NS_RECV, // Data has benn received. int *num_bytes - NS_SEND, // Data has been written to a socket. int *num_bytes - NS_CLOSE // Connection is closed. NULL + NS_POLL, // Sent to each connection on each call to ns_server_poll() + NS_ACCEPT, // New connection accept()-ed. union socket_address *remote_addr + NS_CONNECT, // connect() succeeded or failed. int *success_status + NS_RECV, // Data has benn received. int *num_bytes + NS_SEND, // Data has been written to a socket. int *num_bytes + NS_CLOSE // Connection is closed. NULL }; // Callback function (event handler) prototype, must be defined by user. @@ -188,27 +188,27 @@ struct ns_connection; typedef void (*ns_callback_t)(struct ns_connection *, enum ns_event, void *evp); struct ns_server { - void *server_data; - sock_t listening_sock; - struct ns_connection *active_connections; - ns_callback_t callback; - SSL_CTX *ssl_ctx; - SSL_CTX *client_ssl_ctx; - const char *hexdump_file; - sock_t ctl[2]; + void *server_data; + sock_t listening_sock; + struct ns_connection *active_connections; + ns_callback_t callback; + SSL_CTX *ssl_ctx; + SSL_CTX *client_ssl_ctx; + const char *hexdump_file; + sock_t ctl[2]; }; struct ns_connection { - struct ns_connection *prev, *next; - struct ns_server *server; - sock_t sock; - union socket_address sa; - struct iobuf recv_iobuf; - struct iobuf send_iobuf; - SSL *ssl; - void *connection_data; - time_t last_io_time; - unsigned int flags; + struct ns_connection *prev, *next; + struct ns_server *server; + sock_t sock; + union socket_address sa; + struct iobuf recv_iobuf; + struct iobuf send_iobuf; + SSL *ssl; + void *connection_data; + time_t last_io_time; + unsigned int flags; #define NSF_FINISHED_SENDING_DATA (1 << 0) #define NSF_BUFFER_BUT_DONT_SEND (1 << 1) #define NSF_SSL_HANDSHAKE_DONE (1 << 2) @@ -239,7 +239,7 @@ int ns_bind(struct ns_server *, const char *addr); int ns_set_ssl_cert(struct ns_server *, const char *ssl_cert); int ns_set_ssl_ca_cert(struct ns_server *, const char *ssl_ca_cert); struct ns_connection *ns_connect(struct ns_server *, const char *host, - int port, int ssl, void *connection_param); + int port, int ssl, void *connection_param); int ns_send(struct ns_connection *, const void *buf, int len); int ns_printf(struct ns_connection *, const char *fmt, ...); @@ -289,832 +289,832 @@ int ns_avprintf(char **buf, size_t size, const char *fmt, va_list ap); #endif struct ctl_msg { - ns_callback_t callback; - char message[1024 * 8]; + ns_callback_t callback; + char message[1024 * 8]; }; void iobuf_init(struct iobuf *iobuf, size_t size) { - iobuf->len = iobuf->size = 0; - iobuf->buf = NULL; + iobuf->len = iobuf->size = 0; + iobuf->buf = NULL; - if (size > 0 && (iobuf->buf = (char *) NS_MALLOC(size)) != NULL) { - iobuf->size = size; - } + if (size > 0 && (iobuf->buf = (char *) NS_MALLOC(size)) != NULL) { + iobuf->size = size; + } } void iobuf_free(struct iobuf *iobuf) { - if (iobuf != NULL) { - if (iobuf->buf != NULL) NS_FREE(iobuf->buf); - iobuf_init(iobuf, 0); - } + if (iobuf != NULL) { + if (iobuf->buf != NULL) NS_FREE(iobuf->buf); + iobuf_init(iobuf, 0); + } } size_t iobuf_append(struct iobuf *io, const void *buf, size_t len) { - char *p = NULL; + char *p = NULL; - assert(io != NULL); - assert(io->len <= io->size); + assert(io != NULL); + assert(io->len <= io->size); - if (len <= 0) { - } else if (io->len + len <= io->size) { - memcpy(io->buf + io->len, buf, len); - io->len += len; - } else if ((p = (char *) NS_REALLOC(io->buf, io->len + len)) != NULL) { - io->buf = p; - memcpy(io->buf + io->len, buf, len); - io->len += len; - io->size = io->len; - } else { - len = 0; - } + if (len <= 0) { + } else if (io->len + len <= io->size) { + memcpy(io->buf + io->len, buf, len); + io->len += len; + } else if ((p = (char *) NS_REALLOC(io->buf, io->len + len)) != NULL) { + io->buf = p; + memcpy(io->buf + io->len, buf, len); + io->len += len; + io->size = io->len; + } else { + len = 0; + } - return len; + return len; } void iobuf_remove(struct iobuf *io, size_t n) { - if (n > 0 && n <= io->len) { - memmove(io->buf, io->buf + n, io->len - n); - io->len -= n; - } + if (n > 0 && n <= io->len) { + memmove(io->buf, io->buf + n, io->len - n); + io->len -= n; + } } #ifndef NS_DISABLE_THREADS void *ns_start_thread(void *(*f)(void *), void *p) { #ifdef _WIN32 - return (void *) _beginthread((void (__cdecl *)(void *)) f, 0, p); + return (void *) _beginthread((void (__cdecl *)(void *)) f, 0, p); #else - pthread_t thread_id = (pthread_t) 0; - pthread_attr_t attr; + pthread_t thread_id = (pthread_t) 0; + pthread_attr_t attr; - (void) pthread_attr_init(&attr); - (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + (void) pthread_attr_init(&attr); + (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); #if defined(NS_STACK_SIZE) && NS_STACK_SIZE > 1 - (void) pthread_attr_setstacksize(&attr, NS_STACK_SIZE); + (void) pthread_attr_setstacksize(&attr, NS_STACK_SIZE); #endif - pthread_create(&thread_id, &attr, f, p); - pthread_attr_destroy(&attr); + pthread_create(&thread_id, &attr, f, p); + pthread_attr_destroy(&attr); - return (void *) thread_id; + return (void *) thread_id; #endif } #endif // NS_DISABLE_THREADS static void ns_add_conn(struct ns_server *server, struct ns_connection *c) { - c->next = server->active_connections; - server->active_connections = c; - c->prev = NULL; - if (c->next != NULL) c->next->prev = c; + c->next = server->active_connections; + server->active_connections = c; + c->prev = NULL; + if (c->next != NULL) c->next->prev = c; } static void ns_remove_conn(struct ns_connection *conn) { - if (conn->prev == NULL) conn->server->active_connections = conn->next; - if (conn->prev) conn->prev->next = conn->next; - if (conn->next) conn->next->prev = conn->prev; + if (conn->prev == NULL) conn->server->active_connections = conn->next; + if (conn->prev) conn->prev->next = conn->next; + if (conn->next) conn->next->prev = conn->prev; } // Print message to buffer. If buffer is large enough to hold the message, // return buffer. If buffer is to small, allocate large enough buffer on heap, // and return allocated buffer. int ns_avprintf(char **buf, size_t size, const char *fmt, va_list ap) { - va_list ap_copy; - int len; - - va_copy(ap_copy, ap); - len = vsnprintf(*buf, size, fmt, ap_copy); - va_end(ap_copy); - - if (len < 0) { - // eCos and Windows are not standard-compliant and return -1 when - // the buffer is too small. Keep allocating larger buffers until we - // succeed or out of memory. - *buf = NULL; - while (len < 0) { - if (*buf) free(*buf); - size *= 2; - if ((*buf = (char *) NS_MALLOC(size)) == NULL) break; - va_copy(ap_copy, ap); - len = vsnprintf(*buf, size, fmt, ap_copy); - va_end(ap_copy); - } - } else if (len > (int) size) { - // Standard-compliant code path. Allocate a buffer that is large enough. - if ((*buf = (char *) NS_MALLOC(len + 1)) == NULL) { - len = -1; - } else { - va_copy(ap_copy, ap); - len = vsnprintf(*buf, len + 1, fmt, ap_copy); - va_end(ap_copy); - } - } - - return len; + va_list ap_copy; + int len; + + va_copy(ap_copy, ap); + len = vsnprintf(*buf, size, fmt, ap_copy); + va_end(ap_copy); + + if (len < 0) { + // eCos and Windows are not standard-compliant and return -1 when + // the buffer is too small. Keep allocating larger buffers until we + // succeed or out of memory. + *buf = NULL; + while (len < 0) { + if (*buf) free(*buf); + size *= 2; + if ((*buf = (char *) NS_MALLOC(size)) == NULL) break; + va_copy(ap_copy, ap); + len = vsnprintf(*buf, size, fmt, ap_copy); + va_end(ap_copy); + } + } else if (len > (int) size) { + // Standard-compliant code path. Allocate a buffer that is large enough. + if ((*buf = (char *) NS_MALLOC(len + 1)) == NULL) { + len = -1; + } else { + va_copy(ap_copy, ap); + len = vsnprintf(*buf, len + 1, fmt, ap_copy); + va_end(ap_copy); + } + } + + return len; } int ns_vprintf(struct ns_connection *conn, const char *fmt, va_list ap) { - char mem[2000], *buf = mem; - int len; + char mem[2000], *buf = mem; + int len; - if ((len = ns_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) { - iobuf_append(&conn->send_iobuf, buf, len); - } - if (buf != mem && buf != NULL) { - free(buf); - } + if ((len = ns_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) { + iobuf_append(&conn->send_iobuf, buf, len); + } + if (buf != mem && buf != NULL) { + free(buf); + } - return len; + return len; } int ns_printf(struct ns_connection *conn, const char *fmt, ...) { - int len; - va_list ap; - va_start(ap, fmt); - len = ns_vprintf(conn, fmt, ap); - va_end(ap); - return len; + int len; + va_list ap; + va_start(ap, fmt); + len = ns_vprintf(conn, fmt, ap); + va_end(ap); + return len; } static void hexdump(struct ns_connection *nc, const char *path, - int num_bytes, enum ns_event ev) { - const struct iobuf *io = ev == NS_SEND ? &nc->send_iobuf : &nc->recv_iobuf; - FILE *fp; - char *buf, src[60], dst[60]; - int buf_size = num_bytes * 5 + 100; - - if ((fp = fopen(path, "a")) != NULL) { - ns_sock_to_str(nc->sock, src, sizeof(src), 3); - ns_sock_to_str(nc->sock, dst, sizeof(dst), 7); - fprintf(fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL), - nc->connection_data, src, - ev == NS_RECV ? "<-" : ev == NS_SEND ? "->" : - ev == NS_ACCEPT ? "" : "XX", - dst, num_bytes); - if (num_bytes > 0 && (buf = (char *) malloc(buf_size)) != NULL) { - ns_hexdump(io->buf + (ev == NS_SEND ? 0 : io->len) - - (ev == NS_SEND ? 0 : num_bytes), num_bytes, buf, buf_size); - fprintf(fp, "%s", buf); - free(buf); - } - fclose(fp); - } + int num_bytes, enum ns_event ev) { + const struct iobuf *io = ev == NS_SEND ? &nc->send_iobuf : &nc->recv_iobuf; + FILE *fp; + char *buf, src[60], dst[60]; + int buf_size = num_bytes * 5 + 100; + + if ((fp = fopen(path, "a")) != NULL) { + ns_sock_to_str(nc->sock, src, sizeof(src), 3); + ns_sock_to_str(nc->sock, dst, sizeof(dst), 7); + fprintf(fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL), + nc->connection_data, src, + ev == NS_RECV ? "<-" : ev == NS_SEND ? "->" : + ev == NS_ACCEPT ? "" : "XX", + dst, num_bytes); + if (num_bytes > 0 && (buf = (char *) malloc(buf_size)) != NULL) { + ns_hexdump(io->buf + (ev == NS_SEND ? 0 : io->len) - + (ev == NS_SEND ? 0 : num_bytes), num_bytes, buf, buf_size); + fprintf(fp, "%s", buf); + free(buf); + } + fclose(fp); + } } static void ns_call(struct ns_connection *conn, enum ns_event ev, void *p) { - if (conn->server->hexdump_file != NULL && ev != NS_POLL) { - int len = (ev == NS_RECV || ev == NS_SEND) ? * (int *) p : 0; - hexdump(conn, conn->server->hexdump_file, len, ev); - } - if (conn->server->callback) conn->server->callback(conn, ev, p); + if (conn->server->hexdump_file != NULL && ev != NS_POLL) { + int len = (ev == NS_RECV || ev == NS_SEND) ? * (int *) p : 0; + hexdump(conn, conn->server->hexdump_file, len, ev); + } + if (conn->server->callback) conn->server->callback(conn, ev, p); } static void ns_close_conn(struct ns_connection *conn) { - DBG(("%p %d", conn, conn->flags)); - ns_call(conn, NS_CLOSE, NULL); - ns_remove_conn(conn); - closesocket(conn->sock); - iobuf_free(&conn->recv_iobuf); - iobuf_free(&conn->send_iobuf); + DBG(("%p %d", conn, conn->flags)); + ns_call(conn, NS_CLOSE, NULL); + ns_remove_conn(conn); + closesocket(conn->sock); + iobuf_free(&conn->recv_iobuf); + iobuf_free(&conn->send_iobuf); #ifdef NS_ENABLE_SSL - if (conn->ssl != NULL) { - SSL_free(conn->ssl); - } + if (conn->ssl != NULL) { + SSL_free(conn->ssl); + } #endif - NS_FREE(conn); + NS_FREE(conn); } void ns_set_close_on_exec(sock_t sock) { #ifdef _WIN32 - (void) SetHandleInformation((HANDLE) sock, HANDLE_FLAG_INHERIT, 0); + (void) SetHandleInformation((HANDLE) sock, HANDLE_FLAG_INHERIT, 0); #else - fcntl(sock, F_SETFD, FD_CLOEXEC); + fcntl(sock, F_SETFD, FD_CLOEXEC); #endif } static void ns_set_non_blocking_mode(sock_t sock) { #ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(sock, FIONBIO, &on); + unsigned long on = 1; + ioctlsocket(sock, FIONBIO, &on); #else - int flags = fcntl(sock, F_GETFL, 0); - fcntl(sock, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(sock, F_GETFL, 0); + fcntl(sock, F_SETFL, flags | O_NONBLOCK); #endif } #ifndef NS_DISABLE_SOCKETPAIR int ns_socketpair2(sock_t sp[2], int sock_type) { - union socket_address sa; - sock_t sock; - socklen_t len = sizeof(sa.sin); - int ret = 0; - - sp[0] = sp[1] = INVALID_SOCKET; - - (void) memset(&sa, 0, sizeof(sa)); - sa.sin.sin_family = AF_INET; - sa.sin.sin_port = htons(0); - sa.sin.sin_addr.s_addr = htonl(0x7f000001); - - if ((sock = socket(AF_INET, sock_type, 0)) != INVALID_SOCKET && - !bind(sock, &sa.sa, len) && - (sock_type == SOCK_DGRAM || !listen(sock, 1)) && - !getsockname(sock, &sa.sa, &len) && - (sp[0] = socket(AF_INET, sock_type, 0)) != INVALID_SOCKET && - !connect(sp[0], &sa.sa, len) && - (sock_type == SOCK_STREAM || - (!getsockname(sp[0], &sa.sa, &len) && !connect(sock, &sa.sa, len))) && - (sp[1] = (sock_type == SOCK_DGRAM ? sock : - accept(sock, &sa.sa, &len))) != INVALID_SOCKET) { - ns_set_close_on_exec(sp[0]); - ns_set_close_on_exec(sp[1]); - ret = 1; - } else { - if (sp[0] != INVALID_SOCKET) closesocket(sp[0]); - if (sp[1] != INVALID_SOCKET) closesocket(sp[1]); - sp[0] = sp[1] = INVALID_SOCKET; - } - if (sock_type != SOCK_DGRAM) closesocket(sock); - - return ret; + union socket_address sa; + sock_t sock; + socklen_t len = sizeof(sa.sin); + int ret = 0; + + sp[0] = sp[1] = INVALID_SOCKET; + + (void) memset(&sa, 0, sizeof(sa)); + sa.sin.sin_family = AF_INET; + sa.sin.sin_port = htons(0); + sa.sin.sin_addr.s_addr = htonl(0x7f000001); + + if ((sock = socket(AF_INET, sock_type, 0)) != INVALID_SOCKET && + !bind(sock, &sa.sa, len) && + (sock_type == SOCK_DGRAM || !listen(sock, 1)) && + !getsockname(sock, &sa.sa, &len) && + (sp[0] = socket(AF_INET, sock_type, 0)) != INVALID_SOCKET && + !connect(sp[0], &sa.sa, len) && + (sock_type == SOCK_STREAM || + (!getsockname(sp[0], &sa.sa, &len) && !connect(sock, &sa.sa, len))) && + (sp[1] = (sock_type == SOCK_DGRAM ? sock : + accept(sock, &sa.sa, &len))) != INVALID_SOCKET) { + ns_set_close_on_exec(sp[0]); + ns_set_close_on_exec(sp[1]); + ret = 1; + } else { + if (sp[0] != INVALID_SOCKET) closesocket(sp[0]); + if (sp[1] != INVALID_SOCKET) closesocket(sp[1]); + sp[0] = sp[1] = INVALID_SOCKET; + } + if (sock_type != SOCK_DGRAM) closesocket(sock); + + return ret; } int ns_socketpair(sock_t sp[2]) { - return ns_socketpair2(sp, SOCK_STREAM); + return ns_socketpair2(sp, SOCK_STREAM); } #endif // NS_DISABLE_SOCKETPAIR // Valid listening port spec is: [ip_address:]port, e.g. "80", "127.0.0.1:3128" static int ns_parse_port_string(const char *str, union socket_address *sa) { - unsigned int a, b, c, d, port; - int len = 0; + unsigned int a, b, c, d, port; + int len = 0; #ifdef NS_ENABLE_IPV6 - char buf[100]; + char buf[100]; #endif - // MacOS needs that. If we do not zero it, subsequent bind() will fail. - // Also, all-zeroes in the socket address means binding to all addresses - // for both IPv4 and IPv6 (INADDR_ANY and IN6ADDR_ANY_INIT). - memset(sa, 0, sizeof(*sa)); - sa->sin.sin_family = AF_INET; + // MacOS needs that. If we do not zero it, subsequent bind() will fail. + // Also, all-zeroes in the socket address means binding to all addresses + // for both IPv4 and IPv6 (INADDR_ANY and IN6ADDR_ANY_INIT). + memset(sa, 0, sizeof(*sa)); + sa->sin.sin_family = AF_INET; - if (sscanf(str, "%u.%u.%u.%u:%u%n", &a, &b, &c, &d, &port, &len) == 5) { - // Bind to a specific IPv4 address, e.g. 192.168.1.5:8080 - sa->sin.sin_addr.s_addr = htonl((a << 24) | (b << 16) | (c << 8) | d); - sa->sin.sin_port = htons((uint16_t) port); + if (sscanf(str, "%u.%u.%u.%u:%u%n", &a, &b, &c, &d, &port, &len) == 5) { + // Bind to a specific IPv4 address, e.g. 192.168.1.5:8080 + sa->sin.sin_addr.s_addr = htonl((a << 24) | (b << 16) | (c << 8) | d); + sa->sin.sin_port = htons((uint16_t) port); #ifdef NS_ENABLE_IPV6 - } else if (sscanf(str, "[%49[^]]]:%u%n", buf, &port, &len) == 2 && - inet_pton(AF_INET6, buf, &sa->sin6.sin6_addr)) { - // IPv6 address, e.g. [3ffe:2a00:100:7031::1]:8080 - sa->sin6.sin6_family = AF_INET6; - sa->sin6.sin6_port = htons((uint16_t) port); + } else if (sscanf(str, "[%49[^]]]:%u%n", buf, &port, &len) == 2 && + inet_pton(AF_INET6, buf, &sa->sin6.sin6_addr)) { + // IPv6 address, e.g. [3ffe:2a00:100:7031::1]:8080 + sa->sin6.sin6_family = AF_INET6; + sa->sin6.sin6_port = htons((uint16_t) port); #endif - } else if (sscanf(str, "%u%n", &port, &len) == 1) { - // If only port is specified, bind to IPv4, INADDR_ANY - sa->sin.sin_port = htons((uint16_t) port); - } else { - port = 0; // Parsing failure. Make port invalid. - } + } else if (sscanf(str, "%u%n", &port, &len) == 1) { + // If only port is specified, bind to IPv4, INADDR_ANY + sa->sin.sin_port = htons((uint16_t) port); + } else { + port = 0; // Parsing failure. Make port invalid. + } - return port <= 0xffff && str[len] == '\0'; + return port <= 0xffff && str[len] == '\0'; } // 'sa' must be an initialized address to bind to static sock_t ns_open_listening_socket(union socket_address *sa) { - socklen_t len = sizeof(*sa); - sock_t sock = INVALID_SOCKET; + socklen_t len = sizeof(*sa); + sock_t sock = INVALID_SOCKET; #ifndef _WIN32 - int on = 1; + int on = 1; #endif - if ((sock = socket(sa->sa.sa_family, SOCK_STREAM, 6)) != INVALID_SOCKET && + if ((sock = socket(sa->sa.sa_family, SOCK_STREAM, 6)) != INVALID_SOCKET && #ifndef _WIN32 - // SO_RESUSEADDR is not enabled on Windows because the semantics of - // SO_REUSEADDR on UNIX and Windows is different. On Windows, - // SO_REUSEADDR allows to bind a socket to a port without error even if - // the port is already open by another program. This is not the behavior - // SO_REUSEADDR was designed for, and leads to hard-to-track failure - // scenarios. Therefore, SO_REUSEADDR was disabled on Windows. - !setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on)) && + // SO_RESUSEADDR is not enabled on Windows because the semantics of + // SO_REUSEADDR on UNIX and Windows is different. On Windows, + // SO_REUSEADDR allows to bind a socket to a port without error even if + // the port is already open by another program. This is not the behavior + // SO_REUSEADDR was designed for, and leads to hard-to-track failure + // scenarios. Therefore, SO_REUSEADDR was disabled on Windows. + !setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on)) && #endif - !bind(sock, &sa->sa, sa->sa.sa_family == AF_INET ? - sizeof(sa->sin) : sizeof(sa->sin6)) && - !listen(sock, SOMAXCONN)) { - ns_set_non_blocking_mode(sock); - // In case port was set to 0, get the real port number - (void) getsockname(sock, &sa->sa, &len); - } else if (sock != INVALID_SOCKET) { - closesocket(sock); - sock = INVALID_SOCKET; - } + !bind(sock, &sa->sa, sa->sa.sa_family == AF_INET ? + sizeof(sa->sin) : sizeof(sa->sin6)) && + !listen(sock, SOMAXCONN)) { + ns_set_non_blocking_mode(sock); + // In case port was set to 0, get the real port number + (void) getsockname(sock, &sa->sa, &len); + } else if (sock != INVALID_SOCKET) { + closesocket(sock); + sock = INVALID_SOCKET; + } - return sock; + return sock; } // Certificate generation script is at // https://github.com/cesanta/net_skeleton/blob/master/examples/gen_certs.sh int ns_set_ssl_ca_cert(struct ns_server *server, const char *cert) { #ifdef NS_ENABLE_SSL - STACK_OF(X509_NAME) *list = SSL_load_client_CA_file(cert); - if (cert != NULL && server->ssl_ctx != NULL && list != NULL) { - SSL_CTX_set_client_CA_list(server->ssl_ctx, list); - SSL_CTX_set_verify(server->ssl_ctx, SSL_VERIFY_PEER | - SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); - return 0; - } + STACK_OF(X509_NAME) *list = SSL_load_client_CA_file(cert); + if (cert != NULL && server->ssl_ctx != NULL && list != NULL) { + SSL_CTX_set_client_CA_list(server->ssl_ctx, list); + SSL_CTX_set_verify(server->ssl_ctx, SSL_VERIFY_PEER | + SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); + return 0; + } #endif - return server != NULL && cert == NULL ? 0 : -1; + return server != NULL && cert == NULL ? 0 : -1; } int ns_set_ssl_cert(struct ns_server *server, const char *cert) { #ifdef NS_ENABLE_SSL - if (cert != NULL && - (server->ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) { - return -1; - } else if (SSL_CTX_use_certificate_file(server->ssl_ctx, cert, 1) == 0 || - SSL_CTX_use_PrivateKey_file(server->ssl_ctx, cert, 1) == 0) { - return -2; - } else { - SSL_CTX_set_mode(server->ssl_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); - SSL_CTX_use_certificate_chain_file(server->ssl_ctx, cert); - return 0; - } + if (cert != NULL && + (server->ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) { + return -1; + } else if (SSL_CTX_use_certificate_file(server->ssl_ctx, cert, 1) == 0 || + SSL_CTX_use_PrivateKey_file(server->ssl_ctx, cert, 1) == 0) { + return -2; + } else { + SSL_CTX_set_mode(server->ssl_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + SSL_CTX_use_certificate_chain_file(server->ssl_ctx, cert); + return 0; + } #endif - return server != NULL && cert == NULL ? 0 : -3; + return server != NULL && cert == NULL ? 0 : -3; } int ns_bind(struct ns_server *server, const char *str) { - union socket_address sa; - ns_parse_port_string(str, &sa); - if (server->listening_sock != INVALID_SOCKET) { - closesocket(server->listening_sock); - } - server->listening_sock = ns_open_listening_socket(&sa); - return server->listening_sock == INVALID_SOCKET ? -1 : - (int) ntohs(sa.sin.sin_port); + union socket_address sa; + ns_parse_port_string(str, &sa); + if (server->listening_sock != INVALID_SOCKET) { + closesocket(server->listening_sock); + } + server->listening_sock = ns_open_listening_socket(&sa); + return server->listening_sock == INVALID_SOCKET ? -1 : + (int) ntohs(sa.sin.sin_port); } static struct ns_connection *accept_conn(struct ns_server *server) { - struct ns_connection *c = NULL; - union socket_address sa; - socklen_t len = sizeof(sa); - sock_t sock = INVALID_SOCKET; - - // NOTE(lsm): on Windows, sock is always > FD_SETSIZE - if ((sock = accept(server->listening_sock, &sa.sa, &len)) == INVALID_SOCKET) { - } else if ((c = (struct ns_connection *) NS_MALLOC(sizeof(*c))) == NULL || - memset(c, 0, sizeof(*c)) == NULL) { - closesocket(sock); + struct ns_connection *c = NULL; + union socket_address sa; + socklen_t len = sizeof(sa); + sock_t sock = INVALID_SOCKET; + + // NOTE(lsm): on Windows, sock is always > FD_SETSIZE + if ((sock = accept(server->listening_sock, &sa.sa, &len)) == INVALID_SOCKET) { + } else if ((c = (struct ns_connection *) NS_MALLOC(sizeof(*c))) == NULL || + memset(c, 0, sizeof(*c)) == NULL) { + closesocket(sock); #ifdef NS_ENABLE_SSL - } else if (server->ssl_ctx != NULL && - ((c->ssl = SSL_new(server->ssl_ctx)) == NULL || - SSL_set_fd(c->ssl, sock) != 1)) { - DBG(("SSL error")); - closesocket(sock); - free(c); - c = NULL; + } else if (server->ssl_ctx != NULL && + ((c->ssl = SSL_new(server->ssl_ctx)) == NULL || + SSL_set_fd(c->ssl, sock) != 1)) { + DBG(("SSL error")); + closesocket(sock); + free(c); + c = NULL; #endif - } else { - ns_set_close_on_exec(sock); - ns_set_non_blocking_mode(sock); - c->server = server; - c->sock = sock; - c->flags |= NSF_ACCEPTED; + } else { + ns_set_close_on_exec(sock); + ns_set_non_blocking_mode(sock); + c->server = server; + c->sock = sock; + c->flags |= NSF_ACCEPTED; - ns_add_conn(server, c); - ns_call(c, NS_ACCEPT, &sa); - DBG(("%p %d %p %p", c, c->sock, c->ssl, server->ssl_ctx)); - } + ns_add_conn(server, c); + ns_call(c, NS_ACCEPT, &sa); + DBG(("%p %d %p %p", c, c->sock, c->ssl, server->ssl_ctx)); + } - return c; + return c; } static int ns_is_error(int n) { - return n == 0 || - (n < 0 && errno != EINTR && errno != EINPROGRESS && - errno != EAGAIN && errno != EWOULDBLOCK + return n == 0 || + (n < 0 && errno != EINTR && errno != EINPROGRESS && + errno != EAGAIN && errno != EWOULDBLOCK #ifdef _WIN32 - && WSAGetLastError() != WSAEINTR && WSAGetLastError() != WSAEWOULDBLOCK + && WSAGetLastError() != WSAEINTR && WSAGetLastError() != WSAEWOULDBLOCK #endif - ); + ); } void ns_sock_to_str(sock_t sock, char *buf, size_t len, int flags) { - union socket_address sa; - socklen_t slen = sizeof(sa); - - if (buf != NULL && len > 0) { - buf[0] = '\0'; - memset(&sa, 0, sizeof(sa)); - if (flags & 4) { - getpeername(sock, &sa.sa, &slen); - } else { - getsockname(sock, &sa.sa, &slen); - } - if (flags & 1) { + union socket_address sa; + socklen_t slen = sizeof(sa); + + if (buf != NULL && len > 0) { + buf[0] = '\0'; + memset(&sa, 0, sizeof(sa)); + if (flags & 4) { + getpeername(sock, &sa.sa, &slen); + } else { + getsockname(sock, &sa.sa, &slen); + } + if (flags & 1) { #if defined(NS_ENABLE_IPV6) - inet_ntop(sa.sa.sa_family, sa.sa.sa_family == AF_INET ? - (void *) &sa.sin.sin_addr : - (void *) &sa.sin6.sin6_addr, buf, len); + inet_ntop(sa.sa.sa_family, sa.sa.sa_family == AF_INET ? + (void *) &sa.sin.sin_addr : + (void *) &sa.sin6.sin6_addr, buf, len); #elif defined(_WIN32) - // Only Windoze Vista (and newer) have inet_ntop() - strncpy(buf, inet_ntoa(sa.sin.sin_addr), len); + // Only Windoze Vista (and newer) have inet_ntop() + strncpy(buf, inet_ntoa(sa.sin.sin_addr), len); #else - inet_ntop(sa.sa.sa_family, (void *) &sa.sin.sin_addr, buf, len); + inet_ntop(sa.sa.sa_family, (void *) &sa.sin.sin_addr, buf, len); #endif - } - if (flags & 2) { - snprintf(buf + strlen(buf), len - (strlen(buf) + 1), "%s%d", - flags & 1 ? ":" : "", (int) ntohs(sa.sin.sin_port)); - } - } + } + if (flags & 2) { + snprintf(buf + strlen(buf), len - (strlen(buf) + 1), "%s%d", + flags & 1 ? ":" : "", (int) ntohs(sa.sin.sin_port)); + } + } } int ns_hexdump(const void *buf, int len, char *dst, int dst_len) { - const unsigned char *p = (const unsigned char *) buf; - char ascii[17] = ""; - int i, idx, n = 0; + const unsigned char *p = (const unsigned char *) buf; + char ascii[17] = ""; + int i, idx, n = 0; - for (i = 0; i < len; i++) { - idx = i % 16; - if (idx == 0) { - if (i > 0) n += snprintf(dst + n, dst_len - n, " %s\n", ascii); - n += snprintf(dst + n, dst_len - n, "%04x ", i); - } - n += snprintf(dst + n, dst_len - n, " %02x", p[i]); - ascii[idx] = p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i]; - ascii[idx + 1] = '\0'; - } + for (i = 0; i < len; i++) { + idx = i % 16; + if (idx == 0) { + if (i > 0) n += snprintf(dst + n, dst_len - n, " %s\n", ascii); + n += snprintf(dst + n, dst_len - n, "%04x ", i); + } + n += snprintf(dst + n, dst_len - n, " %02x", p[i]); + ascii[idx] = p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i]; + ascii[idx + 1] = '\0'; + } - while (i++ % 16) n += snprintf(dst + n, dst_len - n, "%s", " "); - n += snprintf(dst + n, dst_len - n, " %s\n\n", ascii); + while (i++ % 16) n += snprintf(dst + n, dst_len - n, "%s", " "); + n += snprintf(dst + n, dst_len - n, " %s\n\n", ascii); - return n; + return n; } #ifdef NS_ENABLE_SSL static int ns_ssl_err(struct ns_connection *conn, int res) { - int ssl_err = SSL_get_error(conn->ssl, res); - if (ssl_err == SSL_ERROR_WANT_READ) conn->flags |= NSF_WANT_READ; - if (ssl_err == SSL_ERROR_WANT_WRITE) conn->flags |= NSF_WANT_WRITE; - return ssl_err; + int ssl_err = SSL_get_error(conn->ssl, res); + if (ssl_err == SSL_ERROR_WANT_READ) conn->flags |= NSF_WANT_READ; + if (ssl_err == SSL_ERROR_WANT_WRITE) conn->flags |= NSF_WANT_WRITE; + return ssl_err; } #endif static void ns_read_from_socket(struct ns_connection *conn) { - char buf[2048]; - int n = 0; + char buf[2048]; + int n = 0; - if (conn->flags & NSF_CONNECTING) { - int ok = 1, ret; - socklen_t len = sizeof(ok); + if (conn->flags & NSF_CONNECTING) { + int ok = 1, ret; + socklen_t len = sizeof(ok); - ret = getsockopt(conn->sock, SOL_SOCKET, SO_ERROR, (char *) &ok, &len); - (void) ret; + ret = getsockopt(conn->sock, SOL_SOCKET, SO_ERROR, (char *) &ok, &len); + (void) ret; #ifdef NS_ENABLE_SSL - if (ret == 0 && ok == 0 && conn->ssl != NULL) { - int res = SSL_connect(conn->ssl); - int ssl_err = ns_ssl_err(conn, res); - if (res == 1) { - conn->flags |= NSF_SSL_HANDSHAKE_DONE; - } else if (ssl_err == SSL_ERROR_WANT_READ || - ssl_err == SSL_ERROR_WANT_WRITE) { - return; // Call us again - } else { - ok = 1; - } - } + if (ret == 0 && ok == 0 && conn->ssl != NULL) { + int res = SSL_connect(conn->ssl); + int ssl_err = ns_ssl_err(conn, res); + if (res == 1) { + conn->flags |= NSF_SSL_HANDSHAKE_DONE; + } else if (ssl_err == SSL_ERROR_WANT_READ || + ssl_err == SSL_ERROR_WANT_WRITE) { + return; // Call us again + } else { + ok = 1; + } + } #endif - conn->flags &= ~NSF_CONNECTING; - DBG(("%p ok=%d", conn, ok)); - if (ok != 0) { - conn->flags |= NSF_CLOSE_IMMEDIATELY; - } - ns_call(conn, NS_CONNECT, &ok); - return; - } + conn->flags &= ~NSF_CONNECTING; + DBG(("%p ok=%d", conn, ok)); + if (ok != 0) { + conn->flags |= NSF_CLOSE_IMMEDIATELY; + } + ns_call(conn, NS_CONNECT, &ok); + return; + } #ifdef NS_ENABLE_SSL - if (conn->ssl != NULL) { - if (conn->flags & NSF_SSL_HANDSHAKE_DONE) { - // SSL library may have more bytes ready to read then we ask to read. - // Therefore, read in a loop until we read everything. Without the loop, - // we skip to the next select() cycle which can just timeout. - while ((n = SSL_read(conn->ssl, buf, sizeof(buf))) > 0) { - DBG(("%p %d <- %d bytes (SSL)", conn, conn->flags, n)); - iobuf_append(&conn->recv_iobuf, buf, n); - ns_call(conn, NS_RECV, &n); - } - ns_ssl_err(conn, n); - } else { - int res = SSL_accept(conn->ssl); - int ssl_err = ns_ssl_err(conn, res); - if (res == 1) { - conn->flags |= NSF_SSL_HANDSHAKE_DONE; - } else if (ssl_err == SSL_ERROR_WANT_READ || - ssl_err == SSL_ERROR_WANT_WRITE) { - return; // Call us again - } else { - conn->flags |= NSF_CLOSE_IMMEDIATELY; - } - return; - } - } else + if (conn->ssl != NULL) { + if (conn->flags & NSF_SSL_HANDSHAKE_DONE) { + // SSL library may have more bytes ready to read then we ask to read. + // Therefore, read in a loop until we read everything. Without the loop, + // we skip to the next select() cycle which can just timeout. + while ((n = SSL_read(conn->ssl, buf, sizeof(buf))) > 0) { + DBG(("%p %d <- %d bytes (SSL)", conn, conn->flags, n)); + iobuf_append(&conn->recv_iobuf, buf, n); + ns_call(conn, NS_RECV, &n); + } + ns_ssl_err(conn, n); + } else { + int res = SSL_accept(conn->ssl); + int ssl_err = ns_ssl_err(conn, res); + if (res == 1) { + conn->flags |= NSF_SSL_HANDSHAKE_DONE; + } else if (ssl_err == SSL_ERROR_WANT_READ || + ssl_err == SSL_ERROR_WANT_WRITE) { + return; // Call us again + } else { + conn->flags |= NSF_CLOSE_IMMEDIATELY; + } + return; + } + } else #endif - { - while ((n = recv(conn->sock, buf, sizeof(buf), 0)) > 0) { - DBG(("%p %d <- %d bytes (PLAIN)", conn, conn->flags, n)); - iobuf_append(&conn->recv_iobuf, buf, n); - ns_call(conn, NS_RECV, &n); - } - } + { + while ((n = recv(conn->sock, buf, sizeof(buf), 0)) > 0) { + DBG(("%p %d <- %d bytes (PLAIN)", conn, conn->flags, n)); + iobuf_append(&conn->recv_iobuf, buf, n); + ns_call(conn, NS_RECV, &n); + } + } - if (ns_is_error(n)) { - conn->flags |= NSF_CLOSE_IMMEDIATELY; - } + if (ns_is_error(n)) { + conn->flags |= NSF_CLOSE_IMMEDIATELY; + } } static void ns_write_to_socket(struct ns_connection *conn) { - struct iobuf *io = &conn->send_iobuf; - int n = 0; + struct iobuf *io = &conn->send_iobuf; + int n = 0; #ifdef NS_ENABLE_SSL - if (conn->ssl != NULL) { - n = SSL_write(conn->ssl, io->buf, io->len); - if (n <= 0) { - int ssl_err = ns_ssl_err(conn, n); - if (ssl_err == SSL_ERROR_WANT_READ || ssl_err == SSL_ERROR_WANT_WRITE) { - return; // Call us again - } else { - conn->flags |= NSF_CLOSE_IMMEDIATELY; - } - } - } else + if (conn->ssl != NULL) { + n = SSL_write(conn->ssl, io->buf, io->len); + if (n <= 0) { + int ssl_err = ns_ssl_err(conn, n); + if (ssl_err == SSL_ERROR_WANT_READ || ssl_err == SSL_ERROR_WANT_WRITE) { + return; // Call us again + } else { + conn->flags |= NSF_CLOSE_IMMEDIATELY; + } + } + } else #endif - { n = send(conn->sock, io->buf, io->len, 0); } + { n = send(conn->sock, io->buf, io->len, 0); } - DBG(("%p %d -> %d bytes", conn, conn->flags, n)); + DBG(("%p %d -> %d bytes", conn, conn->flags, n)); - ns_call(conn, NS_SEND, &n); - if (ns_is_error(n)) { - conn->flags |= NSF_CLOSE_IMMEDIATELY; - } else if (n > 0) { - iobuf_remove(io, n); - } + ns_call(conn, NS_SEND, &n); + if (ns_is_error(n)) { + conn->flags |= NSF_CLOSE_IMMEDIATELY; + } else if (n > 0) { + iobuf_remove(io, n); + } } int ns_send(struct ns_connection *conn, const void *buf, int len) { - return iobuf_append(&conn->send_iobuf, buf, len); + return iobuf_append(&conn->send_iobuf, buf, len); } static void ns_add_to_set(sock_t sock, fd_set *set, sock_t *max_fd) { - if (sock != INVALID_SOCKET) { - FD_SET(sock, set); - if (*max_fd == INVALID_SOCKET || sock > *max_fd) { - *max_fd = sock; - } - } + if (sock != INVALID_SOCKET) { + FD_SET(sock, set); + if (*max_fd == INVALID_SOCKET || sock > *max_fd) { + *max_fd = sock; + } + } } int ns_server_poll(struct ns_server *server, int milli) { - struct ns_connection *conn, *tmp_conn; - struct timeval tv; - fd_set read_set, write_set; - int num_active_connections = 0; - sock_t max_fd = INVALID_SOCKET; - time_t current_time = time(NULL); - - if (server->listening_sock == INVALID_SOCKET && - server->active_connections == NULL) return 0; - - FD_ZERO(&read_set); - FD_ZERO(&write_set); - ns_add_to_set(server->listening_sock, &read_set, &max_fd); - ns_add_to_set(server->ctl[1], &read_set, &max_fd); - - for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { - tmp_conn = conn->next; - ns_call(conn, NS_POLL, ¤t_time); - if (!(conn->flags & NSF_WANT_WRITE)) { - //DBG(("%p read_set", conn)); - ns_add_to_set(conn->sock, &read_set, &max_fd); - } - if (((conn->flags & NSF_CONNECTING) && !(conn->flags & NSF_WANT_READ)) || - (conn->send_iobuf.len > 0 && !(conn->flags & NSF_CONNECTING) && - !(conn->flags & NSF_BUFFER_BUT_DONT_SEND))) { - //DBG(("%p write_set", conn)); - ns_add_to_set(conn->sock, &write_set, &max_fd); - } - if (conn->flags & NSF_CLOSE_IMMEDIATELY) { - ns_close_conn(conn); - } - } - - tv.tv_sec = milli / 1000; - tv.tv_usec = (milli % 1000) * 1000; - - if (select((int) max_fd + 1, &read_set, &write_set, NULL, &tv) > 0) { - // select() might have been waiting for a long time, reset current_time - // now to prevent last_io_time being set to the past. - current_time = time(NULL); - - // Accept new connections - if (server->listening_sock != INVALID_SOCKET && - FD_ISSET(server->listening_sock, &read_set)) { - // We're not looping here, and accepting just one connection at - // a time. The reason is that eCos does not respect non-blocking - // flag on a listening socket and hangs in a loop. - if ((conn = accept_conn(server)) != NULL) { - conn->last_io_time = current_time; - } - } - - // Read wakeup messages - if (server->ctl[1] != INVALID_SOCKET && - FD_ISSET(server->ctl[1], &read_set)) { - struct ctl_msg ctl_msg; - int len = recv(server->ctl[1], (char *) &ctl_msg, sizeof(ctl_msg), 0); - send(server->ctl[1], ctl_msg.message, 1, 0); - if (len >= (int) sizeof(ctl_msg.callback) && ctl_msg.callback != NULL) { - ns_iterate(server, ctl_msg.callback, ctl_msg.message); - } - } - - for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { - tmp_conn = conn->next; - if (FD_ISSET(conn->sock, &read_set)) { - conn->last_io_time = current_time; - ns_read_from_socket(conn); - } - if (FD_ISSET(conn->sock, &write_set)) { - if (conn->flags & NSF_CONNECTING) { - ns_read_from_socket(conn); - } else if (!(conn->flags & NSF_BUFFER_BUT_DONT_SEND)) { - conn->last_io_time = current_time; - ns_write_to_socket(conn); - } - } - } - } - - for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { - tmp_conn = conn->next; - num_active_connections++; - if ((conn->flags & NSF_CLOSE_IMMEDIATELY) || - (conn->send_iobuf.len == 0 && - (conn->flags & NSF_FINISHED_SENDING_DATA))) { - ns_close_conn(conn); - } - } - //DBG(("%d active connections", num_active_connections)); - - return num_active_connections; + struct ns_connection *conn, *tmp_conn; + struct timeval tv; + fd_set read_set, write_set; + int num_active_connections = 0; + sock_t max_fd = INVALID_SOCKET; + time_t current_time = time(NULL); + + if (server->listening_sock == INVALID_SOCKET && + server->active_connections == NULL) return 0; + + FD_ZERO(&read_set); + FD_ZERO(&write_set); + ns_add_to_set(server->listening_sock, &read_set, &max_fd); + ns_add_to_set(server->ctl[1], &read_set, &max_fd); + + for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { + tmp_conn = conn->next; + ns_call(conn, NS_POLL, ¤t_time); + if (!(conn->flags & NSF_WANT_WRITE)) { + //DBG(("%p read_set", conn)); + ns_add_to_set(conn->sock, &read_set, &max_fd); + } + if (((conn->flags & NSF_CONNECTING) && !(conn->flags & NSF_WANT_READ)) || + (conn->send_iobuf.len > 0 && !(conn->flags & NSF_CONNECTING) && + !(conn->flags & NSF_BUFFER_BUT_DONT_SEND))) { + //DBG(("%p write_set", conn)); + ns_add_to_set(conn->sock, &write_set, &max_fd); + } + if (conn->flags & NSF_CLOSE_IMMEDIATELY) { + ns_close_conn(conn); + } + } + + tv.tv_sec = milli / 1000; + tv.tv_usec = (milli % 1000) * 1000; + + if (select((int) max_fd + 1, &read_set, &write_set, NULL, &tv) > 0) { + // select() might have been waiting for a long time, reset current_time + // now to prevent last_io_time being set to the past. + current_time = time(NULL); + + // Accept new connections + if (server->listening_sock != INVALID_SOCKET && + FD_ISSET(server->listening_sock, &read_set)) { + // We're not looping here, and accepting just one connection at + // a time. The reason is that eCos does not respect non-blocking + // flag on a listening socket and hangs in a loop. + if ((conn = accept_conn(server)) != NULL) { + conn->last_io_time = current_time; + } + } + + // Read wakeup messages + if (server->ctl[1] != INVALID_SOCKET && + FD_ISSET(server->ctl[1], &read_set)) { + struct ctl_msg ctl_msg; + int len = recv(server->ctl[1], (char *) &ctl_msg, sizeof(ctl_msg), 0); + send(server->ctl[1], ctl_msg.message, 1, 0); + if (len >= (int) sizeof(ctl_msg.callback) && ctl_msg.callback != NULL) { + ns_iterate(server, ctl_msg.callback, ctl_msg.message); + } + } + + for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { + tmp_conn = conn->next; + if (FD_ISSET(conn->sock, &read_set)) { + conn->last_io_time = current_time; + ns_read_from_socket(conn); + } + if (FD_ISSET(conn->sock, &write_set)) { + if (conn->flags & NSF_CONNECTING) { + ns_read_from_socket(conn); + } else if (!(conn->flags & NSF_BUFFER_BUT_DONT_SEND)) { + conn->last_io_time = current_time; + ns_write_to_socket(conn); + } + } + } + } + + for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { + tmp_conn = conn->next; + num_active_connections++; + if ((conn->flags & NSF_CLOSE_IMMEDIATELY) || + (conn->send_iobuf.len == 0 && + (conn->flags & NSF_FINISHED_SENDING_DATA))) { + ns_close_conn(conn); + } + } + //DBG(("%d active connections", num_active_connections)); + + return num_active_connections; } struct ns_connection *ns_connect(struct ns_server *server, const char *host, - int port, int use_ssl, void *param) { - sock_t sock = INVALID_SOCKET; - struct sockaddr_in sin; - struct hostent *he = NULL; - struct ns_connection *conn = NULL; - int connect_ret_val; - - (void) use_ssl; - - if (host == NULL || (he = gethostbyname(host)) == NULL || - (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { - DBG(("gethostbyname(%s) failed: %s", host, strerror(errno))); - return NULL; - } - - sin.sin_family = AF_INET; - sin.sin_port = htons((uint16_t) port); - sin.sin_addr = * (struct in_addr *) he->h_addr_list[0]; - ns_set_non_blocking_mode(sock); - - connect_ret_val = connect(sock, (struct sockaddr *) &sin, sizeof(sin)); - if (ns_is_error(connect_ret_val)) { - closesocket(sock); - return NULL; - } else if ((conn = (struct ns_connection *) - NS_MALLOC(sizeof(*conn))) == NULL) { - closesocket(sock); - return NULL; - } - - memset(conn, 0, sizeof(*conn)); - conn->server = server; - conn->sock = sock; - conn->connection_data = param; - conn->flags = NSF_CONNECTING; - conn->last_io_time = time(NULL); + int port, int use_ssl, void *param) { + sock_t sock = INVALID_SOCKET; + struct sockaddr_in sin; + struct hostent *he = NULL; + struct ns_connection *conn = NULL; + int connect_ret_val; + + (void) use_ssl; + + if (host == NULL || (he = gethostbyname(host)) == NULL || + (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { + DBG(("gethostbyname(%s) failed: %s", host, strerror(errno))); + return NULL; + } + + sin.sin_family = AF_INET; + sin.sin_port = htons((uint16_t) port); + sin.sin_addr = * (struct in_addr *) he->h_addr_list[0]; + ns_set_non_blocking_mode(sock); + + connect_ret_val = connect(sock, (struct sockaddr *) &sin, sizeof(sin)); + if (ns_is_error(connect_ret_val)) { + closesocket(sock); + return NULL; + } else if ((conn = (struct ns_connection *) + NS_MALLOC(sizeof(*conn))) == NULL) { + closesocket(sock); + return NULL; + } + + memset(conn, 0, sizeof(*conn)); + conn->server = server; + conn->sock = sock; + conn->connection_data = param; + conn->flags = NSF_CONNECTING; + conn->last_io_time = time(NULL); #ifdef NS_ENABLE_SSL - if (use_ssl && - (conn->ssl = SSL_new(server->client_ssl_ctx)) != NULL) { - SSL_set_fd(conn->ssl, sock); - } + if (use_ssl && + (conn->ssl = SSL_new(server->client_ssl_ctx)) != NULL) { + SSL_set_fd(conn->ssl, sock); + } #endif - ns_add_conn(server, conn); - DBG(("%p %s:%d %d %p", conn, host, port, conn->sock, conn->ssl)); + ns_add_conn(server, conn); + DBG(("%p %s:%d %d %p", conn, host, port, conn->sock, conn->ssl)); - return conn; + return conn; } struct ns_connection *ns_add_sock(struct ns_server *s, sock_t sock, void *p) { - struct ns_connection *conn; - if ((conn = (struct ns_connection *) NS_MALLOC(sizeof(*conn))) != NULL) { - memset(conn, 0, sizeof(*conn)); - ns_set_non_blocking_mode(sock); - conn->sock = sock; - conn->connection_data = p; - conn->server = s; - conn->last_io_time = time(NULL); - ns_add_conn(s, conn); - DBG(("%p %d", conn, sock)); - } - return conn; + struct ns_connection *conn; + if ((conn = (struct ns_connection *) NS_MALLOC(sizeof(*conn))) != NULL) { + memset(conn, 0, sizeof(*conn)); + ns_set_non_blocking_mode(sock); + conn->sock = sock; + conn->connection_data = p; + conn->server = s; + conn->last_io_time = time(NULL); + ns_add_conn(s, conn); + DBG(("%p %d", conn, sock)); + } + return conn; } struct ns_connection *ns_next(struct ns_server *s, struct ns_connection *conn) { - return conn == NULL ? s->active_connections : conn->next; + return conn == NULL ? s->active_connections : conn->next; } void ns_iterate(struct ns_server *server, ns_callback_t cb, void *param) { - struct ns_connection *conn, *tmp_conn; + struct ns_connection *conn, *tmp_conn; - for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { - tmp_conn = conn->next; - cb(conn, NS_POLL, param); - } + for (conn = server->active_connections; conn != NULL; conn = tmp_conn) { + tmp_conn = conn->next; + cb(conn, NS_POLL, param); + } } void ns_server_wakeup_ex(struct ns_server *server, ns_callback_t cb, - void *data, size_t len) { - struct ctl_msg ctl_msg; - if (server->ctl[0] != INVALID_SOCKET && data != NULL && - len < sizeof(ctl_msg.message)) { - ctl_msg.callback = cb; - memcpy(ctl_msg.message, data, len); - send(server->ctl[0], (char *) &ctl_msg, - offsetof(struct ctl_msg, message) + len, 0); - recv(server->ctl[0], (char *) &len, 1, 0); - } + void *data, size_t len) { + struct ctl_msg ctl_msg; + if (server->ctl[0] != INVALID_SOCKET && data != NULL && + len < sizeof(ctl_msg.message)) { + ctl_msg.callback = cb; + memcpy(ctl_msg.message, data, len); + send(server->ctl[0], (char *) &ctl_msg, + offsetof(struct ctl_msg, message) + len, 0); + recv(server->ctl[0], (char *) &len, 1, 0); + } } void ns_server_wakeup(struct ns_server *server) { - ns_server_wakeup_ex(server, NULL, (void *) "", 0); + ns_server_wakeup_ex(server, NULL, (void *) "", 0); } void ns_server_init(struct ns_server *s, void *server_data, ns_callback_t cb) { - memset(s, 0, sizeof(*s)); - s->listening_sock = s->ctl[0] = s->ctl[1] = INVALID_SOCKET; - s->server_data = server_data; - s->callback = cb; + memset(s, 0, sizeof(*s)); + s->listening_sock = s->ctl[0] = s->ctl[1] = INVALID_SOCKET; + s->server_data = server_data; + s->callback = cb; #ifdef _WIN32 - { WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); } + { WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); } #else - // Ignore SIGPIPE signal, so if client cancels the request, it - // won't kill the whole process. - signal(SIGPIPE, SIG_IGN); + // Ignore SIGPIPE signal, so if client cancels the request, it + // won't kill the whole process. + signal(SIGPIPE, SIG_IGN); #endif #ifndef NS_DISABLE_SOCKETPAIR - do { - ns_socketpair2(s->ctl, SOCK_DGRAM); - } while (s->ctl[0] == INVALID_SOCKET); + do { + ns_socketpair2(s->ctl, SOCK_DGRAM); + } while (s->ctl[0] == INVALID_SOCKET); #endif #ifdef NS_ENABLE_SSL - {static int init_done; if (!init_done) { SSL_library_init(); init_done++; }} - s->client_ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + {static int init_done; if (!init_done) { SSL_library_init(); init_done++; }} + s->client_ssl_ctx = SSL_CTX_new(SSLv23_client_method()); #endif } void ns_server_free(struct ns_server *s) { - struct ns_connection *conn, *tmp_conn; + struct ns_connection *conn, *tmp_conn; - DBG(("%p", s)); - if (s == NULL) return; - // Do one last poll, see https://github.com/cesanta/mongoose/issues/286 - ns_server_poll(s, 0); + DBG(("%p", s)); + if (s == NULL) return; + // Do one last poll, see https://github.com/cesanta/mongoose/issues/286 + ns_server_poll(s, 0); - if (s->listening_sock != INVALID_SOCKET) closesocket(s->listening_sock); - if (s->ctl[0] != INVALID_SOCKET) closesocket(s->ctl[0]); - if (s->ctl[1] != INVALID_SOCKET) closesocket(s->ctl[1]); - s->listening_sock = s->ctl[0] = s->ctl[1] = INVALID_SOCKET; + if (s->listening_sock != INVALID_SOCKET) closesocket(s->listening_sock); + if (s->ctl[0] != INVALID_SOCKET) closesocket(s->ctl[0]); + if (s->ctl[1] != INVALID_SOCKET) closesocket(s->ctl[1]); + s->listening_sock = s->ctl[0] = s->ctl[1] = INVALID_SOCKET; - for (conn = s->active_connections; conn != NULL; conn = tmp_conn) { - tmp_conn = conn->next; - ns_close_conn(conn); - } + for (conn = s->active_connections; conn != NULL; conn = tmp_conn) { + tmp_conn = conn->next; + ns_close_conn(conn); + } #ifdef NS_ENABLE_SSL - if (s->ssl_ctx != NULL) SSL_CTX_free(s->ssl_ctx); - if (s->client_ssl_ctx != NULL) SSL_CTX_free(s->client_ssl_ctx); - s->ssl_ctx = s->client_ssl_ctx = NULL; + if (s->ssl_ctx != NULL) SSL_CTX_free(s->ssl_ctx); + if (s->client_ssl_ctx != NULL) SSL_CTX_free(s->client_ssl_ctx); + s->ssl_ctx = s->client_ssl_ctx = NULL; #endif } // net_skeleton end @@ -1219,119 +1219,119 @@ typedef pid_t process_id_t; #endif struct vec { - const char *ptr; - int len; + const char *ptr; + int len; }; // For directory listing and WevDAV support struct dir_entry { - struct connection *conn; - char *file_name; - file_stat_t st; + struct connection *conn; + char *file_name; + file_stat_t st; }; // NOTE(lsm): this enum shoulds be in sync with the config_options. enum { - ACCESS_CONTROL_LIST, + ACCESS_CONTROL_LIST, #ifndef MONGOOSE_NO_FILESYSTEM - ACCESS_LOG_FILE, + ACCESS_LOG_FILE, #ifndef MONGOOSE_NO_AUTH - AUTH_DOMAIN, + AUTH_DOMAIN, #endif #ifndef MONGOOSE_NO_CGI - CGI_INTERPRETER, - CGI_PATTERN, + CGI_INTERPRETER, + CGI_PATTERN, #endif - DAV_AUTH_FILE, - DOCUMENT_ROOT, + DAV_AUTH_FILE, + DOCUMENT_ROOT, #ifndef MONGOOSE_NO_DIRECTORY_LISTING - ENABLE_DIRECTORY_LISTING, + ENABLE_DIRECTORY_LISTING, #endif #endif - ENABLE_PROXY, - EXTRA_MIME_TYPES, + ENABLE_PROXY, + EXTRA_MIME_TYPES, #if !defined(MONGOOSE_NO_FILESYSTEM) && !defined(MONGOOSE_NO_AUTH) - GLOBAL_AUTH_FILE, + GLOBAL_AUTH_FILE, #endif #ifndef MONGOOSE_NO_FILESYSTEM - HIDE_FILES_PATTERN, - HEXDUMP_FILE, - INDEX_FILES, + HIDE_FILES_PATTERN, + HEXDUMP_FILE, + INDEX_FILES, #endif - LISTENING_PORT, + LISTENING_PORT, #ifndef _WIN32 - RUN_AS_USER, + RUN_AS_USER, #endif #ifndef MONGOOSE_NO_SSI - SSI_PATTERN, + SSI_PATTERN, #endif #ifdef NS_ENABLE_SSL - SSL_CERTIFICATE, - SSL_CA_CERTIFICATE, - SSL_MITM_CERTS, + SSL_CERTIFICATE, + SSL_CA_CERTIFICATE, + SSL_MITM_CERTS, #endif - URL_REWRITES, - NUM_OPTIONS + URL_REWRITES, + NUM_OPTIONS }; static const char *static_config_options[] = { - "access_control_list", NULL, + "access_control_list", NULL, #ifndef MONGOOSE_NO_FILESYSTEM - "access_log_file", NULL, + "access_log_file", NULL, #ifndef MONGOOSE_NO_AUTH - "auth_domain", "mydomain.com", + "auth_domain", "mydomain.com", #endif #ifndef MONGOOSE_NO_CGI - "cgi_interpreter", NULL, - "cgi_pattern", DEFAULT_CGI_PATTERN, + "cgi_interpreter", NULL, + "cgi_pattern", DEFAULT_CGI_PATTERN, #endif - "dav_auth_file", NULL, - "document_root", NULL, + "dav_auth_file", NULL, + "document_root", NULL, #ifndef MONGOOSE_NO_DIRECTORY_LISTING - "enable_directory_listing", "yes", + "enable_directory_listing", "yes", #endif #endif - "enable_proxy", NULL, - "extra_mime_types", NULL, + "enable_proxy", NULL, + "extra_mime_types", NULL, #if !defined(MONGOOSE_NO_FILESYSTEM) && !defined(MONGOOSE_NO_AUTH) - "global_auth_file", NULL, + "global_auth_file", NULL, #endif #ifndef MONGOOSE_NO_FILESYSTEM - "hide_files_patterns", NULL, - "hexdump_file", NULL, - "index_files","index.html,index.htm,index.shtml,index.cgi,index.php,index.lp", + "hide_files_patterns", NULL, + "hexdump_file", NULL, + "index_files","index.html,index.htm,index.shtml,index.cgi,index.php,index.lp", #endif - "listening_port", NULL, + "listening_port", NULL, #ifndef _WIN32 - "run_as_user", NULL, + "run_as_user", NULL, #endif #ifndef MONGOOSE_NO_SSI - "ssi_pattern", "**.shtml$|**.shtm$", + "ssi_pattern", "**.shtml$|**.shtm$", #endif #ifdef NS_ENABLE_SSL - "ssl_certificate", NULL, - "ssl_ca_certificate", NULL, - "ssl_mitm_certs", NULL, + "ssl_certificate", NULL, + "ssl_ca_certificate", NULL, + "ssl_mitm_certs", NULL, #endif - "url_rewrites", NULL, - NULL + "url_rewrites", NULL, + NULL }; struct mg_server { - struct ns_server ns_server; - union socket_address lsa; // Listening socket address - mg_handler_t event_handler; - char *config_options[NUM_OPTIONS]; + struct ns_server ns_server; + union socket_address lsa; // Listening socket address + mg_handler_t event_handler; + char *config_options[NUM_OPTIONS]; }; // Local endpoint representation union endpoint { - int fd; // Opened regular local file - struct ns_connection *nc; // CGI or proxy->target connection + int fd; // Opened regular local file + struct ns_connection *nc; // CGI or proxy->target connection }; enum endpoint_type { - EP_NONE, EP_FILE, EP_CGI, EP_USER, EP_PUT, EP_CLIENT, EP_PROXY + EP_NONE, EP_FILE, EP_CGI, EP_USER, EP_PUT, EP_CLIENT, EP_PROXY }; #define MG_HEADERS_SENT NSF_USER_1 @@ -1341,82 +1341,82 @@ enum endpoint_type { #define MG_PROXY_DONT_PARSE NSF_USER_5 struct connection { - struct ns_connection *ns_conn; // NOTE(lsm): main.c depends on this order - struct mg_connection mg_conn; - struct mg_server *server; - union endpoint endpoint; - enum endpoint_type endpoint_type; - char *path_info; - char *request; - int64_t num_bytes_recv; // Total number of bytes received - int64_t cl; // Reply content length, for Range support - int request_len; // Request length, including last \r\n after last header + struct ns_connection *ns_conn; // NOTE(lsm): main.c depends on this order + struct mg_connection mg_conn; + struct mg_server *server; + union endpoint endpoint; + enum endpoint_type endpoint_type; + char *path_info; + char *request; + int64_t num_bytes_recv; // Total number of bytes received + int64_t cl; // Reply content length, for Range support + int request_len; // Request length, including last \r\n after last header }; #define MG_CONN_2_CONN(c) ((struct connection *) ((char *) (c) - \ - offsetof(struct connection, mg_conn))) + offsetof(struct connection, mg_conn))) static void open_local_endpoint(struct connection *conn, int skip_user); static void close_local_endpoint(struct connection *conn); static const struct { - const char *extension; - size_t ext_len; - const char *mime_type; + const char *extension; + size_t ext_len; + const char *mime_type; } static_builtin_mime_types[] = { - {".html", 5, "text/html"}, - {".htm", 4, "text/html"}, - {".shtm", 5, "text/html"}, - {".shtml", 6, "text/html"}, - {".css", 4, "text/css"}, - {".js", 3, "application/x-javascript"}, - {".ico", 4, "image/x-icon"}, - {".gif", 4, "image/gif"}, - {".jpg", 4, "image/jpeg"}, - {".jpeg", 5, "image/jpeg"}, - {".png", 4, "image/png"}, - {".svg", 4, "image/svg+xml"}, - {".txt", 4, "text/plain"}, - {".torrent", 8, "application/x-bittorrent"}, - {".wav", 4, "audio/x-wav"}, - {".mp3", 4, "audio/x-mp3"}, - {".mid", 4, "audio/mid"}, - {".m3u", 4, "audio/x-mpegurl"}, - {".ogg", 4, "application/ogg"}, - {".ram", 4, "audio/x-pn-realaudio"}, - {".xml", 4, "text/xml"}, - {".json", 5, "application/json"}, - {".xslt", 5, "application/xml"}, - {".xsl", 4, "application/xml"}, - {".ra", 3, "audio/x-pn-realaudio"}, - {".doc", 4, "application/msword"}, - {".exe", 4, "application/octet-stream"}, - {".zip", 4, "application/x-zip-compressed"}, - {".xls", 4, "application/excel"}, - {".tgz", 4, "application/x-tar-gz"}, - {".tar", 4, "application/x-tar"}, - {".gz", 3, "application/x-gunzip"}, - {".arj", 4, "application/x-arj-compressed"}, - {".rar", 4, "application/x-rar-compressed"}, - {".rtf", 4, "application/rtf"}, - {".pdf", 4, "application/pdf"}, - {".swf", 4, "application/x-shockwave-flash"}, - {".mpg", 4, "video/mpeg"}, - {".webm", 5, "video/webm"}, - {".mpeg", 5, "video/mpeg"}, - {".mov", 4, "video/quicktime"}, - {".mp4", 4, "video/mp4"}, - {".m4v", 4, "video/x-m4v"}, - {".asf", 4, "video/x-ms-asf"}, - {".avi", 4, "video/x-msvideo"}, - {".bmp", 4, "image/bmp"}, - {".ttf", 4, "application/x-font-ttf"}, - {NULL, 0, NULL} + {".html", 5, "text/html"}, + {".htm", 4, "text/html"}, + {".shtm", 5, "text/html"}, + {".shtml", 6, "text/html"}, + {".css", 4, "text/css"}, + {".js", 3, "application/x-javascript"}, + {".ico", 4, "image/x-icon"}, + {".gif", 4, "image/gif"}, + {".jpg", 4, "image/jpeg"}, + {".jpeg", 5, "image/jpeg"}, + {".png", 4, "image/png"}, + {".svg", 4, "image/svg+xml"}, + {".txt", 4, "text/plain"}, + {".torrent", 8, "application/x-bittorrent"}, + {".wav", 4, "audio/x-wav"}, + {".mp3", 4, "audio/x-mp3"}, + {".mid", 4, "audio/mid"}, + {".m3u", 4, "audio/x-mpegurl"}, + {".ogg", 4, "application/ogg"}, + {".ram", 4, "audio/x-pn-realaudio"}, + {".xml", 4, "text/xml"}, + {".json", 5, "application/json"}, + {".xslt", 5, "application/xml"}, + {".xsl", 4, "application/xml"}, + {".ra", 3, "audio/x-pn-realaudio"}, + {".doc", 4, "application/msword"}, + {".exe", 4, "application/octet-stream"}, + {".zip", 4, "application/x-zip-compressed"}, + {".xls", 4, "application/excel"}, + {".tgz", 4, "application/x-tar-gz"}, + {".tar", 4, "application/x-tar"}, + {".gz", 3, "application/x-gunzip"}, + {".arj", 4, "application/x-arj-compressed"}, + {".rar", 4, "application/x-rar-compressed"}, + {".rtf", 4, "application/rtf"}, + {".pdf", 4, "application/pdf"}, + {".swf", 4, "application/x-shockwave-flash"}, + {".mpg", 4, "video/mpeg"}, + {".webm", 5, "video/webm"}, + {".mpeg", 5, "video/mpeg"}, + {".mov", 4, "video/quicktime"}, + {".mp4", 4, "video/mp4"}, + {".m4v", 4, "video/x-m4v"}, + {".asf", 4, "video/x-ms-asf"}, + {".avi", 4, "video/x-msvideo"}, + {".bmp", 4, "image/bmp"}, + {".ttf", 4, "application/x-font-ttf"}, + {NULL, 0, NULL} }; #ifndef MONGOOSE_NO_THREADS void *mg_start_thread(void *(*f)(void *), void *p) { - return ns_start_thread(f, p); + return ns_start_thread(f, p); } #endif // MONGOOSE_NO_THREADS @@ -1424,44 +1424,44 @@ void *mg_start_thread(void *(*f)(void *), void *p) { // Encode 'path' which is assumed UTF-8 string, into UNICODE string. // wbuf and wbuf_len is a target buffer and its length. static void to_wchar(const char *path, wchar_t *wbuf, size_t wbuf_len) { - char buf[MAX_PATH_SIZE * 2], buf2[MAX_PATH_SIZE * 2], *p; + char buf[MAX_PATH_SIZE * 2], buf2[MAX_PATH_SIZE * 2], *p; - strncpy(buf, path, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; + strncpy(buf, path, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; - // Trim trailing slashes. Leave backslash for paths like "X:\" - p = buf + strlen(buf) - 1; - while (p > buf && p[-1] != ':' && (p[0] == '\\' || p[0] == '/')) *p-- = '\0'; + // Trim trailing slashes. Leave backslash for paths like "X:\" + p = buf + strlen(buf) - 1; + while (p > buf && p[-1] != ':' && (p[0] == '\\' || p[0] == '/')) *p-- = '\0'; - // Convert to Unicode and back. If doubly-converted string does not - // match the original, something is fishy, reject. - memset(wbuf, 0, wbuf_len * sizeof(wchar_t)); - MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len); - WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2), - NULL, NULL); - if (strcmp(buf, buf2) != 0) { - wbuf[0] = L'\0'; - } + // Convert to Unicode and back. If doubly-converted string does not + // match the original, something is fishy, reject. + memset(wbuf, 0, wbuf_len * sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len); + WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2), + NULL, NULL); + if (strcmp(buf, buf2) != 0) { + wbuf[0] = L'\0'; + } } static int mg_stat(const char *path, file_stat_t *st) { - wchar_t wpath[MAX_PATH_SIZE]; - to_wchar(path, wpath, ARRAY_SIZE(wpath)); - DBG(("[%ls] -> %d", wpath, _wstati64(wpath, st))); - return _wstati64(wpath, st); + wchar_t wpath[MAX_PATH_SIZE]; + to_wchar(path, wpath, ARRAY_SIZE(wpath)); + DBG(("[%ls] -> %d", wpath, _wstati64(wpath, st))); + return _wstati64(wpath, st); } static FILE *mg_fopen(const char *path, const char *mode) { - wchar_t wpath[MAX_PATH_SIZE], wmode[10]; - to_wchar(path, wpath, ARRAY_SIZE(wpath)); - to_wchar(mode, wmode, ARRAY_SIZE(wmode)); - return _wfopen(wpath, wmode); + wchar_t wpath[MAX_PATH_SIZE], wmode[10]; + to_wchar(path, wpath, ARRAY_SIZE(wpath)); + to_wchar(mode, wmode, ARRAY_SIZE(wmode)); + return _wfopen(wpath, wmode); } static int mg_open(const char *path, int flag) { - wchar_t wpath[MAX_PATH_SIZE]; - to_wchar(path, wpath, ARRAY_SIZE(wpath)); - return _wopen(wpath, flag); + wchar_t wpath[MAX_PATH_SIZE]; + to_wchar(path, wpath, ARRAY_SIZE(wpath)); + return _wopen(wpath, flag); } #endif // _WIN32 && !MONGOOSE_NO_FILESYSTEM @@ -1472,60 +1472,60 @@ static int mg_open(const char *path, int flag) { // vector is initialized to point to the "y" part, and val vector length // is adjusted to point only to "x". static const char *next_option(const char *list, struct vec *val, - struct vec *eq_val) { - if (list == NULL || *list == '\0') { - // End of the list - list = NULL; - } else { - val->ptr = list; - if ((list = strchr(val->ptr, ',')) != NULL) { - // Comma found. Store length and shift the list ptr - val->len = list - val->ptr; - list++; - } else { - // This value is the last one - list = val->ptr + strlen(val->ptr); - val->len = list - val->ptr; - } - - if (eq_val != NULL) { - // Value has form "x=y", adjust pointers and lengths - // so that val points to "x", and eq_val points to "y". - eq_val->len = 0; - eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len); - if (eq_val->ptr != NULL) { - eq_val->ptr++; // Skip over '=' character - eq_val->len = val->ptr + val->len - eq_val->ptr; - val->len = (eq_val->ptr - val->ptr) - 1; - } - } - } - - return list; + struct vec *eq_val) { + if (list == NULL || *list == '\0') { + // End of the list + list = NULL; + } else { + val->ptr = list; + if ((list = strchr(val->ptr, ',')) != NULL) { + // Comma found. Store length and shift the list ptr + val->len = list - val->ptr; + list++; + } else { + // This value is the last one + list = val->ptr + strlen(val->ptr); + val->len = list - val->ptr; + } + + if (eq_val != NULL) { + // Value has form "x=y", adjust pointers and lengths + // so that val points to "x", and eq_val points to "y". + eq_val->len = 0; + eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len); + if (eq_val->ptr != NULL) { + eq_val->ptr++; // Skip over '=' character + eq_val->len = val->ptr + val->len - eq_val->ptr; + val->len = (eq_val->ptr - val->ptr) - 1; + } + } + } + + return list; } // Like snprintf(), but never returns negative value, or a value // that is larger than a supplied buffer. static int mg_vsnprintf(char *buf, size_t buflen, const char *fmt, va_list ap) { - int n; - if (buflen < 1) return 0; - n = vsnprintf(buf, buflen, fmt, ap); - if (n < 0) { - n = 0; - } else if (n >= (int) buflen) { - n = (int) buflen - 1; - } - buf[n] = '\0'; - return n; + int n; + if (buflen < 1) return 0; + n = vsnprintf(buf, buflen, fmt, ap); + if (n < 0) { + n = 0; + } else if (n >= (int) buflen) { + n = (int) buflen - 1; + } + buf[n] = '\0'; + return n; } static int mg_snprintf(char *buf, size_t buflen, const char *fmt, ...) { - va_list ap; - int n; - va_start(ap, fmt); - n = mg_vsnprintf(buf, buflen, fmt, ap); - va_end(ap); - return n; + va_list ap; + int n; + va_start(ap, fmt); + n = mg_vsnprintf(buf, buflen, fmt, ap); + va_end(ap); + return n; } // Check whether full request is buffered. Return: @@ -1533,383 +1533,382 @@ static int mg_snprintf(char *buf, size_t buflen, const char *fmt, ...) { // 0 if request is not yet fully buffered // >0 actual request length, including last \r\n\r\n static int get_request_len(const char *s, int buf_len) { - const unsigned char *buf = (unsigned char *) s; - int i; + const unsigned char *buf = (unsigned char *) s; + int i; - for (i = 0; i < buf_len; i++) { - // Control characters are not allowed but >=128 are. - // Abort scan as soon as one malformed character is found. - if (!isprint(buf[i]) && buf[i] != '\r' && buf[i] != '\n' && buf[i] < 128) { - return -1; - } else if (buf[i] == '\n' && i + 1 < buf_len && buf[i + 1] == '\n') { - return i + 2; - } else if (buf[i] == '\n' && i + 2 < buf_len && buf[i + 1] == '\r' && - buf[i + 2] == '\n') { - return i + 3; - } - } + for (i = 0; i < buf_len; i++) { + // Control characters are not allowed but >=128 are. + // Abort scan as soon as one malformed character is found. + if (!isprint(buf[i]) && buf[i] != '\r' && buf[i] != '\n' && buf[i] < 128) { + return -1; + } else if (buf[i] == '\n' && i + 1 < buf_len && buf[i + 1] == '\n') { + return i + 2; + } else if (buf[i] == '\n' && i + 2 < buf_len && buf[i + 1] == '\r' && + buf[i + 2] == '\n') { + return i + 3; + } + } - return 0; + return 0; } // Skip the characters until one of the delimiters characters found. // 0-terminate resulting word. Skip the rest of the delimiters if any. // Advance pointer to buffer to the next word. Return found 0-terminated word. static char *skip(char **buf, const char *delimiters) { - char *p, *begin_word, *end_word, *end_delimiters; + char *p, *begin_word, *end_word, *end_delimiters; - begin_word = *buf; - end_word = begin_word + strcspn(begin_word, delimiters); - end_delimiters = end_word + strspn(end_word, delimiters); + begin_word = *buf; + end_word = begin_word + strcspn(begin_word, delimiters); + end_delimiters = end_word + strspn(end_word, delimiters); - for (p = end_word; p < end_delimiters; p++) { - *p = '\0'; - } + for (p = end_word; p < end_delimiters; p++) { + *p = '\0'; + } - *buf = end_delimiters; + *buf = end_delimiters; - return begin_word; + return begin_word; } // Parse HTTP headers from the given buffer, advance buffer to the point // where parsing stopped. static void parse_http_headers(char **buf, struct mg_connection *ri) { - size_t i; + size_t i; - for (i = 0; i < ARRAY_SIZE(ri->http_headers); i++) { - ri->http_headers[i].name = skip(buf, ": "); - ri->http_headers[i].value = skip(buf, "\r\n"); - if (ri->http_headers[i].name[0] == '\0') - break; - ri->num_headers = i + 1; - } + for (i = 0; i < ARRAY_SIZE(ri->http_headers); i++) { + ri->http_headers[i].name = skip(buf, ": "); + ri->http_headers[i].value = skip(buf, "\r\n"); + if (ri->http_headers[i].name[0] == '\0') + break; + ri->num_headers = i + 1; + } } static const char *status_code_to_str(int status_code) { - switch (status_code) { - - case 100: return "Continue"; - case 101: return "Switching Protocols"; - case 102: return "Processing"; - - case 200: return "OK"; - case 201: return "Created"; - case 202: return "Accepted"; - case 203: return "Non-Authoritative Information"; - case 204: return "No Content"; - case 205: return "Reset Content"; - case 206: return "Partial Content"; - case 207: return "Multi-Status"; - case 208: return "Already Reported"; - case 226: return "IM Used"; - - case 300: return "Multiple Choices"; - case 301: return "Moved Permanently"; - case 302: return "Found"; - case 303: return "See Other"; - case 304: return "Not Modified"; - case 305: return "Use Proxy"; - case 306: return "Switch Proxy"; - case 307: return "Temporary Redirect"; - case 308: return "Permanent Redirect"; - - case 400: return "Bad Request"; - case 401: return "Unauthorized"; - case 402: return "Payment Required"; - case 403: return "Forbidden"; - case 404: return "Not Found"; - case 405: return "Method Not Allowed"; - case 406: return "Not Acceptable"; - case 407: return "Proxy Authentication Required"; - case 408: return "Request Timeout"; - case 409: return "Conflict"; - case 410: return "Gone"; - case 411: return "Length Required"; - case 412: return "Precondition Failed"; - case 413: return "Payload Too Large"; - case 414: return "URI Too Long"; - case 415: return "Unsupported Media Type"; - case 416: return "Requested Range Not Satisfiable"; - case 417: return "Expectation Failed"; - case 418: return "I\'m a teapot"; - case 422: return "Unprocessable Entity"; - case 423: return "Locked"; - case 424: return "Failed Dependency"; - case 426: return "Upgrade Required"; - case 428: return "Precondition Required"; - case 429: return "Too Many Requests"; - case 431: return "Request Header Fields Too Large"; - case 451: return "Unavailable For Legal Reasons"; - - case 500: return "Internal Server Error"; - case 501: return "Not Implemented"; - case 502: return "Bad Gateway"; - case 503: return "Service Unavailable"; - case 504: return "Gateway Timeout"; - case 505: return "HTTP Version Not Supported"; - case 506: return "Variant Also Negotiates"; - case 507: return "Insufficient Storage"; - case 508: return "Loop Detected"; - case 510: return "Not Extended"; - case 511: return "Network Authentication Required"; - - default: return "Server Error"; - } + switch (status_code) { + case 100: return "Continue"; + case 101: return "Switching Protocols"; + case 102: return "Processing"; + + case 200: return "OK"; + case 201: return "Created"; + case 202: return "Accepted"; + case 203: return "Non-Authoritative Information"; + case 204: return "No Content"; + case 205: return "Reset Content"; + case 206: return "Partial Content"; + case 207: return "Multi-Status"; + case 208: return "Already Reported"; + case 226: return "IM Used"; + + case 300: return "Multiple Choices"; + case 301: return "Moved Permanently"; + case 302: return "Found"; + case 303: return "See Other"; + case 304: return "Not Modified"; + case 305: return "Use Proxy"; + case 306: return "Switch Proxy"; + case 307: return "Temporary Redirect"; + case 308: return "Permanent Redirect"; + + case 400: return "Bad Request"; + case 401: return "Unauthorized"; + case 402: return "Payment Required"; + case 403: return "Forbidden"; + case 404: return "Not Found"; + case 405: return "Method Not Allowed"; + case 406: return "Not Acceptable"; + case 407: return "Proxy Authentication Required"; + case 408: return "Request Timeout"; + case 409: return "Conflict"; + case 410: return "Gone"; + case 411: return "Length Required"; + case 412: return "Precondition Failed"; + case 413: return "Payload Too Large"; + case 414: return "URI Too Long"; + case 415: return "Unsupported Media Type"; + case 416: return "Requested Range Not Satisfiable"; + case 417: return "Expectation Failed"; + case 418: return "I\'m a teapot"; + case 422: return "Unprocessable Entity"; + case 423: return "Locked"; + case 424: return "Failed Dependency"; + case 426: return "Upgrade Required"; + case 428: return "Precondition Required"; + case 429: return "Too Many Requests"; + case 431: return "Request Header Fields Too Large"; + case 451: return "Unavailable For Legal Reasons"; + + case 500: return "Internal Server Error"; + case 501: return "Not Implemented"; + case 502: return "Bad Gateway"; + case 503: return "Service Unavailable"; + case 504: return "Gateway Timeout"; + case 505: return "HTTP Version Not Supported"; + case 506: return "Variant Also Negotiates"; + case 507: return "Insufficient Storage"; + case 508: return "Loop Detected"; + case 510: return "Not Extended"; + case 511: return "Network Authentication Required"; + + default: return "Server Error"; + } } static int call_user(struct connection *conn, enum mg_event ev) { - return conn != NULL && conn->server != NULL && - conn->server->event_handler != NULL ? - conn->server->event_handler(&conn->mg_conn, ev) : MG_FALSE; + return conn != NULL && conn->server != NULL && + conn->server->event_handler != NULL ? + conn->server->event_handler(&conn->mg_conn, ev) : MG_FALSE; } static void send_http_error(struct connection *conn, int code, - const char *fmt, ...) { - const char *message = status_code_to_str(code); - const char *rewrites = conn->server->config_options[URL_REWRITES]; - char headers[200], body[200]; - struct vec a, b; - va_list ap; - int body_len, headers_len, match_code; - - conn->mg_conn.status_code = code; - - // Invoke error handler if it is set - if (call_user(conn, MG_HTTP_ERROR) == MG_TRUE) { - close_local_endpoint(conn); - return; - } - - // Handle error code rewrites - while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { - if ((match_code = atoi(a.ptr)) > 0 && match_code == code) { - struct mg_connection *c = &conn->mg_conn; - c->status_code = 302; - mg_printf(c, "HTTP/1.1 %d Moved\r\n" - "Location: %.*s?code=%d&orig_uri=%s&query_string=%s\r\n\r\n", - c->status_code, b.len, b.ptr, code, c->uri, - c->query_string == NULL ? "" : c->query_string); - close_local_endpoint(conn); - return; - } - } - - body_len = mg_snprintf(body, sizeof(body), "%d %s\n", code, message); - if (fmt != NULL) { - va_start(ap, fmt); - body_len += mg_vsnprintf(body + body_len, sizeof(body) - body_len, fmt, ap); - va_end(ap); - } - if ((code >= 300 && code <= 399) || code == 204) { - // 3xx errors do not have body - body_len = 0; - } - headers_len = mg_snprintf(headers, sizeof(headers), - "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n" - "Content-Type: text/plain\r\n\r\n", - code, message, body_len); - ns_send(conn->ns_conn, headers, headers_len); - ns_send(conn->ns_conn, body, body_len); - close_local_endpoint(conn); // This will write to the log file + const char *fmt, ...) { + const char *message = status_code_to_str(code); + const char *rewrites = conn->server->config_options[URL_REWRITES]; + char headers[200], body[200]; + struct vec a, b; + va_list ap; + int body_len, headers_len, match_code; + + conn->mg_conn.status_code = code; + + // Invoke error handler if it is set + if (call_user(conn, MG_HTTP_ERROR) == MG_TRUE) { + close_local_endpoint(conn); + return; + } + + // Handle error code rewrites + while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { + if ((match_code = atoi(a.ptr)) > 0 && match_code == code) { + struct mg_connection *c = &conn->mg_conn; + c->status_code = 302; + mg_printf(c, "HTTP/1.1 %d Moved\r\n" + "Location: %.*s?code=%d&orig_uri=%s&query_string=%s\r\n\r\n", + c->status_code, b.len, b.ptr, code, c->uri, + c->query_string == NULL ? "" : c->query_string); + close_local_endpoint(conn); + return; + } + } + + body_len = mg_snprintf(body, sizeof(body), "%d %s\n", code, message); + if (fmt != NULL) { + va_start(ap, fmt); + body_len += mg_vsnprintf(body + body_len, sizeof(body) - body_len, fmt, ap); + va_end(ap); + } + if ((code >= 300 && code <= 399) || code == 204) { + // 3xx errors do not have body + body_len = 0; + } + headers_len = mg_snprintf(headers, sizeof(headers), + "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n" + "Content-Type: text/plain\r\n\r\n", + code, message, body_len); + ns_send(conn->ns_conn, headers, headers_len); + ns_send(conn->ns_conn, body, body_len); + close_local_endpoint(conn); // This will write to the log file } static void write_chunk(struct connection *conn, const char *buf, int len) { - char chunk_size[50]; - int n = mg_snprintf(chunk_size, sizeof(chunk_size), "%X\r\n", len); - ns_send(conn->ns_conn, chunk_size, n); - ns_send(conn->ns_conn, buf, len); - ns_send(conn->ns_conn, "\r\n", 2); + char chunk_size[50]; + int n = mg_snprintf(chunk_size, sizeof(chunk_size), "%X\r\n", len); + ns_send(conn->ns_conn, chunk_size, n); + ns_send(conn->ns_conn, buf, len); + ns_send(conn->ns_conn, "\r\n", 2); } size_t mg_printf(struct mg_connection *conn, const char *fmt, ...) { - struct connection *c = MG_CONN_2_CONN(conn); - va_list ap; + struct connection *c = MG_CONN_2_CONN(conn); + va_list ap; - va_start(ap, fmt); - ns_vprintf(c->ns_conn, fmt, ap); - va_end(ap); + va_start(ap, fmt); + ns_vprintf(c->ns_conn, fmt, ap); + va_end(ap); - return c->ns_conn->send_iobuf.len; + return c->ns_conn->send_iobuf.len; } static void ns_forward(struct ns_connection *from, struct ns_connection *to) { - DBG(("%p -> %p %lu bytes", from, to, (unsigned long)from->recv_iobuf.len)); - ns_send(to, from->recv_iobuf.buf, from->recv_iobuf.len); - iobuf_remove(&from->recv_iobuf, from->recv_iobuf.len); + DBG(("%p -> %p %lu bytes", from, to, (unsigned long)from->recv_iobuf.len)); + ns_send(to, from->recv_iobuf.buf, from->recv_iobuf.len); + iobuf_remove(&from->recv_iobuf, from->recv_iobuf.len); } #ifndef MONGOOSE_NO_CGI #ifdef _WIN32 struct threadparam { - sock_t s; - HANDLE hPipe; + sock_t s; + HANDLE hPipe; }; static int wait_until_ready(sock_t sock, int for_read) { - fd_set set; - FD_ZERO(&set); - FD_SET(sock, &set); - select(sock + 1, for_read ? &set : 0, for_read ? 0 : &set, 0, 0); - return 1; + fd_set set; + FD_ZERO(&set); + FD_SET(sock, &set); + select(sock + 1, for_read ? &set : 0, for_read ? 0 : &set, 0, 0); + return 1; } static void *push_to_stdin(void *arg) { - struct threadparam *tp = (struct threadparam *)arg; - int n, sent, stop = 0; - DWORD k; - char buf[IOBUF_SIZE]; - - while (!stop && wait_until_ready(tp->s, 1) && - (n = recv(tp->s, buf, sizeof(buf), 0)) > 0) { - if (n == -1 && GetLastError() == WSAEWOULDBLOCK) continue; - for (sent = 0; !stop && sent < n; sent += k) { - if (!WriteFile(tp->hPipe, buf + sent, n - sent, &k, 0)) stop = 1; - } - } - DBG(("%s", "FORWARED EVERYTHING TO CGI")); - CloseHandle(tp->hPipe); - free(tp); - _endthread(); - return NULL; + struct threadparam *tp = (struct threadparam *)arg; + int n, sent, stop = 0; + DWORD k; + char buf[IOBUF_SIZE]; + + while (!stop && wait_until_ready(tp->s, 1) && + (n = recv(tp->s, buf, sizeof(buf), 0)) > 0) { + if (n == -1 && GetLastError() == WSAEWOULDBLOCK) continue; + for (sent = 0; !stop && sent < n; sent += k) { + if (!WriteFile(tp->hPipe, buf + sent, n - sent, &k, 0)) stop = 1; + } + } + DBG(("%s", "FORWARED EVERYTHING TO CGI")); + CloseHandle(tp->hPipe); + free(tp); + _endthread(); + return NULL; } static void *pull_from_stdout(void *arg) { - struct threadparam *tp = (struct threadparam *)arg; - int k = 0, stop = 0; - DWORD n, sent; - char buf[IOBUF_SIZE]; - - while (!stop && ReadFile(tp->hPipe, buf, sizeof(buf), &n, NULL)) { - for (sent = 0; !stop && sent < n; sent += k) { - if (wait_until_ready(tp->s, 0) && - (k = send(tp->s, buf + sent, n - sent, 0)) <= 0) stop = 1; - } - } - DBG(("%s", "EOF FROM CGI")); - CloseHandle(tp->hPipe); - shutdown(tp->s, 2); // Without this, IO thread may get truncated data - closesocket(tp->s); - free(tp); - _endthread(); - return NULL; + struct threadparam *tp = (struct threadparam *)arg; + int k = 0, stop = 0; + DWORD n, sent; + char buf[IOBUF_SIZE]; + + while (!stop && ReadFile(tp->hPipe, buf, sizeof(buf), &n, NULL)) { + for (sent = 0; !stop && sent < n; sent += k) { + if (wait_until_ready(tp->s, 0) && + (k = send(tp->s, buf + sent, n - sent, 0)) <= 0) stop = 1; + } + } + DBG(("%s", "EOF FROM CGI")); + CloseHandle(tp->hPipe); + shutdown(tp->s, 2); // Without this, IO thread may get truncated data + closesocket(tp->s); + free(tp); + _endthread(); + return NULL; } static void spawn_stdio_thread(sock_t sock, HANDLE hPipe, - void *(*func)(void *)) { - struct threadparam *tp = (struct threadparam *)malloc(sizeof(*tp)); - if (tp != NULL) { - tp->s = sock; - tp->hPipe = hPipe; - mg_start_thread(func, tp); - } + void *(*func)(void *)) { + struct threadparam *tp = (struct threadparam *)malloc(sizeof(*tp)); + if (tp != NULL) { + tp->s = sock; + tp->hPipe = hPipe; + mg_start_thread(func, tp); + } } static void abs_path(const char *utf8_path, char *abs_path, size_t len) { - wchar_t buf[MAX_PATH_SIZE], buf2[MAX_PATH_SIZE]; - to_wchar(utf8_path, buf, ARRAY_SIZE(buf)); - GetFullPathNameW(buf, ARRAY_SIZE(buf2), buf2, NULL); - WideCharToMultiByte(CP_UTF8, 0, buf2, wcslen(buf2) + 1, abs_path, len, 0, 0); + wchar_t buf[MAX_PATH_SIZE], buf2[MAX_PATH_SIZE]; + to_wchar(utf8_path, buf, ARRAY_SIZE(buf)); + GetFullPathNameW(buf, ARRAY_SIZE(buf2), buf2, NULL); + WideCharToMultiByte(CP_UTF8, 0, buf2, wcslen(buf2) + 1, abs_path, len, 0, 0); } static process_id_t start_process(char *interp, const char *cmd, - const char *env, const char *envp[], - const char *dir, sock_t sock) { - STARTUPINFOW si; - PROCESS_INFORMATION pi; - HANDLE a[2], b[2], me = GetCurrentProcess(); - wchar_t wcmd[MAX_PATH_SIZE], full_dir[MAX_PATH_SIZE]; - char buf[MAX_PATH_SIZE], buf4[MAX_PATH_SIZE], buf5[MAX_PATH_SIZE], - cmdline[MAX_PATH_SIZE], *p; - DWORD flags = DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS; - FILE *fp; - - memset(&si, 0, sizeof(si)); - memset(&pi, 0, sizeof(pi)); - - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - - CreatePipe(&a[0], &a[1], NULL, 0); - CreatePipe(&b[0], &b[1], NULL, 0); - DuplicateHandle(me, a[0], me, &si.hStdInput, 0, TRUE, flags); - DuplicateHandle(me, b[1], me, &si.hStdOutput, 0, TRUE, flags); - - if (interp == NULL && (fp = fopen(cmd, "r")) != NULL) { - buf[0] = buf[1] = '\0'; - fgets(buf, sizeof(buf), fp); - buf[sizeof(buf) - 1] = '\0'; - if (buf[0] == '#' && buf[1] == '!') { - interp = buf + 2; - for (p = interp + strlen(interp); - isspace(* (uint8_t *) p) && p > interp; p--) *p = '\0'; - } - fclose(fp); - } - - if (interp != NULL) { - abs_path(interp, buf4, ARRAY_SIZE(buf4)); - interp = buf4; - } - abs_path(dir, buf5, ARRAY_SIZE(buf5)); - to_wchar(dir, full_dir, ARRAY_SIZE(full_dir)); - mg_snprintf(cmdline, sizeof(cmdline), "%s%s\"%s\"", - interp ? interp : "", interp ? " " : "", cmd); - to_wchar(cmdline, wcmd, ARRAY_SIZE(wcmd)); - - if (CreateProcessW(NULL, wcmd, NULL, NULL, TRUE, CREATE_NEW_PROCESS_GROUP, - (void *) env, full_dir, &si, &pi) != 0) { - spawn_stdio_thread(sock, a[1], push_to_stdin); - spawn_stdio_thread(sock, b[0], pull_from_stdout); - } else { - CloseHandle(a[1]); - CloseHandle(b[0]); - closesocket(sock); - } - DBG(("CGI command: [%ls] -> %p", wcmd, pi.hProcess)); - - // Not closing a[0] and b[1] because we've used DUPLICATE_CLOSE_SOURCE - CloseHandle(si.hStdOutput); - CloseHandle(si.hStdInput); - //CloseHandle(pi.hThread); - //CloseHandle(pi.hProcess); - - return pi.hProcess; + const char *env, const char *envp[], + const char *dir, sock_t sock) { + STARTUPINFOW si; + PROCESS_INFORMATION pi; + HANDLE a[2], b[2], me = GetCurrentProcess(); + wchar_t wcmd[MAX_PATH_SIZE], full_dir[MAX_PATH_SIZE]; + char buf[MAX_PATH_SIZE], buf4[MAX_PATH_SIZE], buf5[MAX_PATH_SIZE], + cmdline[MAX_PATH_SIZE], *p; + DWORD flags = DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS; + FILE *fp; + + memset(&si, 0, sizeof(si)); + memset(&pi, 0, sizeof(pi)); + + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE; + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + + CreatePipe(&a[0], &a[1], NULL, 0); + CreatePipe(&b[0], &b[1], NULL, 0); + DuplicateHandle(me, a[0], me, &si.hStdInput, 0, TRUE, flags); + DuplicateHandle(me, b[1], me, &si.hStdOutput, 0, TRUE, flags); + + if (interp == NULL && (fp = fopen(cmd, "r")) != NULL) { + buf[0] = buf[1] = '\0'; + fgets(buf, sizeof(buf), fp); + buf[sizeof(buf) - 1] = '\0'; + if (buf[0] == '#' && buf[1] == '!') { + interp = buf + 2; + for (p = interp + strlen(interp); + isspace(* (uint8_t *) p) && p > interp; p--) *p = '\0'; + } + fclose(fp); + } + + if (interp != NULL) { + abs_path(interp, buf4, ARRAY_SIZE(buf4)); + interp = buf4; + } + abs_path(dir, buf5, ARRAY_SIZE(buf5)); + to_wchar(dir, full_dir, ARRAY_SIZE(full_dir)); + mg_snprintf(cmdline, sizeof(cmdline), "%s%s\"%s\"", + interp ? interp : "", interp ? " " : "", cmd); + to_wchar(cmdline, wcmd, ARRAY_SIZE(wcmd)); + + if (CreateProcessW(NULL, wcmd, NULL, NULL, TRUE, CREATE_NEW_PROCESS_GROUP, + (void *) env, full_dir, &si, &pi) != 0) { + spawn_stdio_thread(sock, a[1], push_to_stdin); + spawn_stdio_thread(sock, b[0], pull_from_stdout); + } else { + CloseHandle(a[1]); + CloseHandle(b[0]); + closesocket(sock); + } + DBG(("CGI command: [%ls] -> %p", wcmd, pi.hProcess)); + + // Not closing a[0] and b[1] because we've used DUPLICATE_CLOSE_SOURCE + CloseHandle(si.hStdOutput); + CloseHandle(si.hStdInput); + //CloseHandle(pi.hThread); + //CloseHandle(pi.hProcess); + + return pi.hProcess; } #else static process_id_t start_process(const char *interp, const char *cmd, - const char *env, const char *envp[], - const char *dir, sock_t sock) { - char buf[500]; - process_id_t pid = fork(); - (void) env; - - if (pid == 0) { - (void) chdir(dir); - (void) dup2(sock, 0); - (void) dup2(sock, 1); - closesocket(sock); - - // After exec, all signal handlers are restored to their default values, - // with one exception of SIGCHLD. According to POSIX.1-2001 and Linux's - // implementation, SIGCHLD's handler will leave unchanged after exec - // if it was set to be ignored. Restore it to default action. - signal(SIGCHLD, SIG_DFL); - - if (interp == NULL) { - execle(cmd, cmd, (char *) 0, envp); // Using (char *) 0 to avoid warning - } else { - execle(interp, interp, cmd, (char *) 0, envp); - } - snprintf(buf, sizeof(buf), "Status: 500\r\n\r\n" - "500 Server Error: %s%s%s: %s", interp == NULL ? "" : interp, - interp == NULL ? "" : " ", cmd, strerror(errno)); - send(1, buf, strlen(buf), 0); - exit(EXIT_FAILURE); // exec call failed - } - - return pid; + const char *env, const char *envp[], + const char *dir, sock_t sock) { + char buf[500]; + process_id_t pid = fork(); + (void) env; + + if (pid == 0) { + (void) chdir(dir); + (void) dup2(sock, 0); + (void) dup2(sock, 1); + closesocket(sock); + + // After exec, all signal handlers are restored to their default values, + // with one exception of SIGCHLD. According to POSIX.1-2001 and Linux's + // implementation, SIGCHLD's handler will leave unchanged after exec + // if it was set to be ignored. Restore it to default action. + signal(SIGCHLD, SIG_DFL); + + if (interp == NULL) { + execle(cmd, cmd, (char *) 0, envp); // Using (char *) 0 to avoid warning + } else { + execle(interp, interp, cmd, (char *) 0, envp); + } + snprintf(buf, sizeof(buf), "Status: 500\r\n\r\n" + "500 Server Error: %s%s%s: %s", interp == NULL ? "" : interp, + interp == NULL ? "" : " ", cmd, strerror(errno)); + send(1, buf, strlen(buf), 0); + exit(EXIT_FAILURE); // exec call failed + } + + return pid; } #endif // _WIN32 @@ -1922,337 +1921,337 @@ static process_id_t start_process(const char *interp, const char *cmd, // We satisfy both worlds: we create an envp array (which is vars), all // entries are actually pointers inside buf. struct cgi_env_block { - struct mg_connection *conn; - char buf[CGI_ENVIRONMENT_SIZE]; // Environment buffer - const char *vars[MAX_CGI_ENVIR_VARS]; // char *envp[] - int len; // Space taken - int nvars; // Number of variables in envp[] + struct mg_connection *conn; + char buf[CGI_ENVIRONMENT_SIZE]; // Environment buffer + const char *vars[MAX_CGI_ENVIR_VARS]; // char *envp[] + int len; // Space taken + int nvars; // Number of variables in envp[] }; // Append VARIABLE=VALUE\0 string to the buffer, and add a respective // pointer into the vars array. static char *addenv(struct cgi_env_block *block, const char *fmt, ...) { - int n, space; - char *added; - va_list ap; + int n, space; + char *added; + va_list ap; - // Calculate how much space is left in the buffer - space = sizeof(block->buf) - block->len - 2; - assert(space >= 0); + // Calculate how much space is left in the buffer + space = sizeof(block->buf) - block->len - 2; + assert(space >= 0); - // Make a pointer to the free space int the buffer - added = block->buf + block->len; + // Make a pointer to the free space int the buffer + added = block->buf + block->len; - // Copy VARIABLE=VALUE\0 string into the free space - va_start(ap, fmt); - n = mg_vsnprintf(added, (size_t) space, fmt, ap); - va_end(ap); + // Copy VARIABLE=VALUE\0 string into the free space + va_start(ap, fmt); + n = mg_vsnprintf(added, (size_t) space, fmt, ap); + va_end(ap); - // Make sure we do not overflow buffer and the envp array - if (n > 0 && n + 1 < space && - block->nvars < (int) ARRAY_SIZE(block->vars) - 2) { - // Append a pointer to the added string into the envp array - block->vars[block->nvars++] = added; - // Bump up used length counter. Include \0 terminator - block->len += n + 1; - } + // Make sure we do not overflow buffer and the envp array + if (n > 0 && n + 1 < space && + block->nvars < (int) ARRAY_SIZE(block->vars) - 2) { + // Append a pointer to the added string into the envp array + block->vars[block->nvars++] = added; + // Bump up used length counter. Include \0 terminator + block->len += n + 1; + } - return added; + return added; } static void addenv2(struct cgi_env_block *blk, const char *name) { - const char *s; - if ((s = getenv(name)) != NULL) addenv(blk, "%s=%s", name, s); + const char *s; + if ((s = getenv(name)) != NULL) addenv(blk, "%s=%s", name, s); } static void prepare_cgi_environment(struct connection *conn, - const char *prog, - struct cgi_env_block *blk) { - struct mg_connection *ri = &conn->mg_conn; - const char *s, *slash; - char *p, **opts = conn->server->config_options; - int i; - - blk->len = blk->nvars = 0; - blk->conn = ri; - - if ((s = getenv("SERVER_NAME")) != NULL) { - addenv(blk, "SERVER_NAME=%s", s); - } else { - addenv(blk, "SERVER_NAME=%s", ri->local_ip); - } - addenv(blk, "SERVER_ROOT=%s", opts[DOCUMENT_ROOT]); - addenv(blk, "DOCUMENT_ROOT=%s", opts[DOCUMENT_ROOT]); - addenv(blk, "SERVER_SOFTWARE=%s/%s", "Mongoose", MONGOOSE_VERSION); - - // Prepare the environment block - addenv(blk, "%s", "GATEWAY_INTERFACE=CGI/1.1"); - addenv(blk, "%s", "SERVER_PROTOCOL=HTTP/1.1"); - addenv(blk, "%s", "REDIRECT_STATUS=200"); // For PHP - - // TODO(lsm): fix this for IPv6 case - //addenv(blk, "SERVER_PORT=%d", ri->remote_port); - - addenv(blk, "REQUEST_METHOD=%s", ri->request_method); - addenv(blk, "REMOTE_ADDR=%s", ri->remote_ip); - addenv(blk, "REMOTE_PORT=%d", ri->remote_port); - addenv(blk, "REQUEST_URI=%s%s%s", ri->uri, - ri->query_string == NULL ? "" : "?", - ri->query_string == NULL ? "" : ri->query_string); - - // SCRIPT_NAME - if (conn->path_info != NULL) { - addenv(blk, "SCRIPT_NAME=%.*s", - (int) (strlen(ri->uri) - strlen(conn->path_info)), ri->uri); - addenv(blk, "PATH_INFO=%s", conn->path_info); - } else { - s = strrchr(prog, '/'); - slash = strrchr(ri->uri, '/'); - addenv(blk, "SCRIPT_NAME=%.*s%s", - slash == NULL ? 0 : (int) (slash - ri->uri), ri->uri, - s == NULL ? prog : s); - } - - addenv(blk, "SCRIPT_FILENAME=%s", prog); - addenv(blk, "PATH_TRANSLATED=%s", prog); - addenv(blk, "HTTPS=%s", conn->ns_conn->ssl != NULL ? "on" : "off"); - - if ((s = mg_get_header(ri, "Content-Type")) != NULL) - addenv(blk, "CONTENT_TYPE=%s", s); - - if (ri->query_string != NULL) - addenv(blk, "QUERY_STRING=%s", ri->query_string); - - if ((s = mg_get_header(ri, "Content-Length")) != NULL) - addenv(blk, "CONTENT_LENGTH=%s", s); - - addenv2(blk, "PATH"); - addenv2(blk, "TMP"); - addenv2(blk, "TEMP"); - addenv2(blk, "TMPDIR"); - addenv2(blk, "PERLLIB"); - addenv2(blk, ENV_EXPORT_TO_CGI); + const char *prog, + struct cgi_env_block *blk) { + struct mg_connection *ri = &conn->mg_conn; + const char *s, *slash; + char *p, **opts = conn->server->config_options; + int i; + + blk->len = blk->nvars = 0; + blk->conn = ri; + + if ((s = getenv("SERVER_NAME")) != NULL) { + addenv(blk, "SERVER_NAME=%s", s); + } else { + addenv(blk, "SERVER_NAME=%s", ri->local_ip); + } + addenv(blk, "SERVER_ROOT=%s", opts[DOCUMENT_ROOT]); + addenv(blk, "DOCUMENT_ROOT=%s", opts[DOCUMENT_ROOT]); + addenv(blk, "SERVER_SOFTWARE=%s/%s", "Mongoose", MONGOOSE_VERSION); + + // Prepare the environment block + addenv(blk, "%s", "GATEWAY_INTERFACE=CGI/1.1"); + addenv(blk, "%s", "SERVER_PROTOCOL=HTTP/1.1"); + addenv(blk, "%s", "REDIRECT_STATUS=200"); // For PHP + + // TODO(lsm): fix this for IPv6 case + //addenv(blk, "SERVER_PORT=%d", ri->remote_port); + + addenv(blk, "REQUEST_METHOD=%s", ri->request_method); + addenv(blk, "REMOTE_ADDR=%s", ri->remote_ip); + addenv(blk, "REMOTE_PORT=%d", ri->remote_port); + addenv(blk, "REQUEST_URI=%s%s%s", ri->uri, + ri->query_string == NULL ? "" : "?", + ri->query_string == NULL ? "" : ri->query_string); + + // SCRIPT_NAME + if (conn->path_info != NULL) { + addenv(blk, "SCRIPT_NAME=%.*s", + (int) (strlen(ri->uri) - strlen(conn->path_info)), ri->uri); + addenv(blk, "PATH_INFO=%s", conn->path_info); + } else { + s = strrchr(prog, '/'); + slash = strrchr(ri->uri, '/'); + addenv(blk, "SCRIPT_NAME=%.*s%s", + slash == NULL ? 0 : (int) (slash - ri->uri), ri->uri, + s == NULL ? prog : s); + } + + addenv(blk, "SCRIPT_FILENAME=%s", prog); + addenv(blk, "PATH_TRANSLATED=%s", prog); + addenv(blk, "HTTPS=%s", conn->ns_conn->ssl != NULL ? "on" : "off"); + + if ((s = mg_get_header(ri, "Content-Type")) != NULL) + addenv(blk, "CONTENT_TYPE=%s", s); + + if (ri->query_string != NULL) + addenv(blk, "QUERY_STRING=%s", ri->query_string); + + if ((s = mg_get_header(ri, "Content-Length")) != NULL) + addenv(blk, "CONTENT_LENGTH=%s", s); + + addenv2(blk, "PATH"); + addenv2(blk, "TMP"); + addenv2(blk, "TEMP"); + addenv2(blk, "TMPDIR"); + addenv2(blk, "PERLLIB"); + addenv2(blk, ENV_EXPORT_TO_CGI); #if defined(_WIN32) - addenv2(blk, "COMSPEC"); - addenv2(blk, "SYSTEMROOT"); - addenv2(blk, "SystemDrive"); - addenv2(blk, "ProgramFiles"); - addenv2(blk, "ProgramFiles(x86)"); - addenv2(blk, "CommonProgramFiles(x86)"); + addenv2(blk, "COMSPEC"); + addenv2(blk, "SYSTEMROOT"); + addenv2(blk, "SystemDrive"); + addenv2(blk, "ProgramFiles"); + addenv2(blk, "ProgramFiles(x86)"); + addenv2(blk, "CommonProgramFiles(x86)"); #else - addenv2(blk, "LD_LIBRARY_PATH"); + addenv2(blk, "LD_LIBRARY_PATH"); #endif // _WIN32 - // Add all headers as HTTP_* variables - for (i = 0; i < ri->num_headers; i++) { - p = addenv(blk, "HTTP_%s=%s", - ri->http_headers[i].name, ri->http_headers[i].value); + // Add all headers as HTTP_* variables + for (i = 0; i < ri->num_headers; i++) { + p = addenv(blk, "HTTP_%s=%s", + ri->http_headers[i].name, ri->http_headers[i].value); - // Convert variable name into uppercase, and change - to _ - for (; *p != '=' && *p != '\0'; p++) { - if (*p == '-') - *p = '_'; - *p = (char) toupper(* (unsigned char *) p); - } - } + // Convert variable name into uppercase, and change - to _ + for (; *p != '=' && *p != '\0'; p++) { + if (*p == '-') + *p = '_'; + *p = (char) toupper(* (unsigned char *) p); + } + } - blk->vars[blk->nvars++] = NULL; - blk->buf[blk->len++] = '\0'; + blk->vars[blk->nvars++] = NULL; + blk->buf[blk->len++] = '\0'; - assert(blk->nvars < (int) ARRAY_SIZE(blk->vars)); - assert(blk->len > 0); - assert(blk->len < (int) sizeof(blk->buf)); + assert(blk->nvars < (int) ARRAY_SIZE(blk->vars)); + assert(blk->len > 0); + assert(blk->len < (int) sizeof(blk->buf)); } static const char cgi_status[] = "HTTP/1.1 200 OK\r\n"; static void open_cgi_endpoint(struct connection *conn, const char *prog) { - struct cgi_env_block blk; - char dir[MAX_PATH_SIZE]; - const char *p; - sock_t fds[2]; - - prepare_cgi_environment(conn, prog, &blk); - // CGI must be executed in its own directory. 'dir' must point to the - // directory containing executable program, 'p' must point to the - // executable program name relative to 'dir'. - if ((p = strrchr(prog, '/')) == NULL) { - mg_snprintf(dir, sizeof(dir), "%s", "."); - } else { - mg_snprintf(dir, sizeof(dir), "%.*s", (int) (p - prog), prog); - } - - // Try to create socketpair in a loop until success. ns_socketpair() - // can be interrupted by a signal and fail. - // TODO(lsm): use sigaction to restart interrupted syscall - do { - ns_socketpair(fds); - } while (fds[0] == INVALID_SOCKET); - - if (start_process(conn->server->config_options[CGI_INTERPRETER], - prog, blk.buf, blk.vars, dir, fds[1]) != 0) { - conn->endpoint_type = EP_CGI; - conn->endpoint.nc = ns_add_sock(&conn->server->ns_server, fds[0], conn); - conn->endpoint.nc->flags |= MG_CGI_CONN; - ns_send(conn->ns_conn, cgi_status, sizeof(cgi_status) - 1); - conn->mg_conn.status_code = 200; - conn->ns_conn->flags |= NSF_BUFFER_BUT_DONT_SEND; - // Pass POST data to the CGI process - conn->endpoint.nc->send_iobuf = conn->ns_conn->recv_iobuf; - iobuf_init(&conn->ns_conn->recv_iobuf, 0); - } else { - closesocket(fds[0]); - send_http_error(conn, 500, "start_process(%s) failed", prog); - } + struct cgi_env_block blk; + char dir[MAX_PATH_SIZE]; + const char *p; + sock_t fds[2]; + + prepare_cgi_environment(conn, prog, &blk); + // CGI must be executed in its own directory. 'dir' must point to the + // directory containing executable program, 'p' must point to the + // executable program name relative to 'dir'. + if ((p = strrchr(prog, '/')) == NULL) { + mg_snprintf(dir, sizeof(dir), "%s", "."); + } else { + mg_snprintf(dir, sizeof(dir), "%.*s", (int) (p - prog), prog); + } + + // Try to create socketpair in a loop until success. ns_socketpair() + // can be interrupted by a signal and fail. + // TODO(lsm): use sigaction to restart interrupted syscall + do { + ns_socketpair(fds); + } while (fds[0] == INVALID_SOCKET); + + if (start_process(conn->server->config_options[CGI_INTERPRETER], + prog, blk.buf, blk.vars, dir, fds[1]) != 0) { + conn->endpoint_type = EP_CGI; + conn->endpoint.nc = ns_add_sock(&conn->server->ns_server, fds[0], conn); + conn->endpoint.nc->flags |= MG_CGI_CONN; + ns_send(conn->ns_conn, cgi_status, sizeof(cgi_status) - 1); + conn->mg_conn.status_code = 200; + conn->ns_conn->flags |= NSF_BUFFER_BUT_DONT_SEND; + // Pass POST data to the CGI process + conn->endpoint.nc->send_iobuf = conn->ns_conn->recv_iobuf; + iobuf_init(&conn->ns_conn->recv_iobuf, 0); + } else { + closesocket(fds[0]); + send_http_error(conn, 500, "start_process(%s) failed", prog); + } #ifndef _WIN32 - closesocket(fds[1]); // On Windows, CGI stdio thread closes that socket + closesocket(fds[1]); // On Windows, CGI stdio thread closes that socket #endif } static void on_cgi_data(struct ns_connection *nc) { - struct connection *conn = (struct connection *) nc->connection_data; - const char *status = "500"; - struct mg_connection c; - - if (!conn) return; - - // Copy CGI data from CGI socket to the client send buffer - ns_forward(nc, conn->ns_conn); - - // If reply has not been parsed yet, parse it - if (conn->ns_conn->flags & NSF_BUFFER_BUT_DONT_SEND) { - struct iobuf *io = &conn->ns_conn->send_iobuf; - int s_len = sizeof(cgi_status) - 1; - int len = get_request_len(io->buf + s_len, io->len - s_len); - char buf[MAX_REQUEST_SIZE], *s = buf; - - if (len == 0) return; - - if (len < 0 || len > (int) sizeof(buf)) { - len = io->len; - iobuf_remove(io, io->len); - send_http_error(conn, 500, "CGI program sent malformed headers: [%.*s]", - len, io->buf); - } else { - memset(&c, 0, sizeof(c)); - memcpy(buf, io->buf + s_len, len); - buf[len - 1] = '\0'; - parse_http_headers(&s, &c); - if (mg_get_header(&c, "Location") != NULL) { - status = "302"; - } else if ((status = (char *) mg_get_header(&c, "Status")) == NULL) { - status = "200"; - } - memcpy(io->buf + 9, status, 3); - conn->mg_conn.status_code = atoi(status); - } - conn->ns_conn->flags &= ~NSF_BUFFER_BUT_DONT_SEND; - } + struct connection *conn = (struct connection *) nc->connection_data; + const char *status = "500"; + struct mg_connection c; + + if (!conn) return; + + // Copy CGI data from CGI socket to the client send buffer + ns_forward(nc, conn->ns_conn); + + // If reply has not been parsed yet, parse it + if (conn->ns_conn->flags & NSF_BUFFER_BUT_DONT_SEND) { + struct iobuf *io = &conn->ns_conn->send_iobuf; + int s_len = sizeof(cgi_status) - 1; + int len = get_request_len(io->buf + s_len, io->len - s_len); + char buf[MAX_REQUEST_SIZE], *s = buf; + + if (len == 0) return; + + if (len < 0 || len > (int) sizeof(buf)) { + len = io->len; + iobuf_remove(io, io->len); + send_http_error(conn, 500, "CGI program sent malformed headers: [%.*s]", + len, io->buf); + } else { + memset(&c, 0, sizeof(c)); + memcpy(buf, io->buf + s_len, len); + buf[len - 1] = '\0'; + parse_http_headers(&s, &c); + if (mg_get_header(&c, "Location") != NULL) { + status = "302"; + } else if ((status = (char *) mg_get_header(&c, "Status")) == NULL) { + status = "200"; + } + memcpy(io->buf + 9, status, 3); + conn->mg_conn.status_code = atoi(status); + } + conn->ns_conn->flags &= ~NSF_BUFFER_BUT_DONT_SEND; + } } #endif // !MONGOOSE_NO_CGI static char *mg_strdup(const char *str) { - char *copy = (char *) malloc(strlen(str) + 1); - if (copy != NULL) { - strcpy(copy, str); - } - return copy; + char *copy = (char *) malloc(strlen(str) + 1); + if (copy != NULL) { + strcpy(copy, str); + } + return copy; } static int isbyte(int n) { - return n >= 0 && n <= 255; + return n >= 0 && n <= 255; } static int parse_net(const char *spec, uint32_t *net, uint32_t *mask) { - int n, a, b, c, d, slash = 32, len = 0; + int n, a, b, c, d, slash = 32, len = 0; - if ((sscanf(spec, "%d.%d.%d.%d/%d%n", &a, &b, &c, &d, &slash, &n) == 5 || - sscanf(spec, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4) && - isbyte(a) && isbyte(b) && isbyte(c) && isbyte(d) && - slash >= 0 && slash < 33) { - len = n; - *net = ((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)c << 8) | d; - *mask = slash ? 0xffffffffU << (32 - slash) : 0; - } + if ((sscanf(spec, "%d.%d.%d.%d/%d%n", &a, &b, &c, &d, &slash, &n) == 5 || + sscanf(spec, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4) && + isbyte(a) && isbyte(b) && isbyte(c) && isbyte(d) && + slash >= 0 && slash < 33) { + len = n; + *net = ((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)c << 8) | d; + *mask = slash ? 0xffffffffU << (32 - slash) : 0; + } - return len; + return len; } // Verify given socket address against the ACL. // Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed. static int check_acl(const char *acl, uint32_t remote_ip) { - int allowed, flag; - uint32_t net, mask; - struct vec vec; + int allowed, flag; + uint32_t net, mask; + struct vec vec; - // If any ACL is set, deny by default - allowed = acl == NULL ? '+' : '-'; + // If any ACL is set, deny by default + allowed = acl == NULL ? '+' : '-'; - while ((acl = next_option(acl, &vec, NULL)) != NULL) { - flag = vec.ptr[0]; - if ((flag != '+' && flag != '-') || - parse_net(&vec.ptr[1], &net, &mask) == 0) { - return -1; - } + while ((acl = next_option(acl, &vec, NULL)) != NULL) { + flag = vec.ptr[0]; + if ((flag != '+' && flag != '-') || + parse_net(&vec.ptr[1], &net, &mask) == 0) { + return -1; + } - if (net == (remote_ip & mask)) { - allowed = flag; - } - } + if (net == (remote_ip & mask)) { + allowed = flag; + } + } - return allowed == '+'; + return allowed == '+'; } // Protect against directory disclosure attack by removing '..', // excessive '/' and '\' characters static void remove_double_dots_and_double_slashes(char *s) { - char *p = s; - - while (*s != '\0') { - *p++ = *s++; - if (s[-1] == '/' || s[-1] == '\\') { - // Skip all following slashes, backslashes and double-dots - while (s[0] != '\0') { - if (s[0] == '/' || s[0] == '\\') { s++; } - else if (s[0] == '.' && s[1] == '.') { s += 2; } - else { break; } - } - } - } - *p = '\0'; + char *p = s; + + while (*s != '\0') { + *p++ = *s++; + if (s[-1] == '/' || s[-1] == '\\') { + // Skip all following slashes, backslashes and double-dots + while (s[0] != '\0') { + if (s[0] == '/' || s[0] == '\\') { s++; } + else if (s[0] == '.' && s[1] == '.') { s += 2; } + else { break; } + } + } + } + *p = '\0'; } int mg_url_decode(const char *src, int src_len, char *dst, - int dst_len, int is_form_url_encoded) { - int i, j, a, b; + int dst_len, int is_form_url_encoded) { + int i, j, a, b; #define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') - for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) { - if (src[i] == '%' && i < src_len - 2 && - isxdigit(* (const unsigned char *) (src + i + 1)) && - isxdigit(* (const unsigned char *) (src + i + 2))) { - a = tolower(* (const unsigned char *) (src + i + 1)); - b = tolower(* (const unsigned char *) (src + i + 2)); - dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b)); - i += 2; - } else if (is_form_url_encoded && src[i] == '+') { - dst[j] = ' '; - } else { - dst[j] = src[i]; - } - } + for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) { + if (src[i] == '%' && i < src_len - 2 && + isxdigit(* (const unsigned char *) (src + i + 1)) && + isxdigit(* (const unsigned char *) (src + i + 2))) { + a = tolower(* (const unsigned char *) (src + i + 1)); + b = tolower(* (const unsigned char *) (src + i + 2)); + dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b)); + i += 2; + } else if (is_form_url_encoded && src[i] == '+') { + dst[j] = ' '; + } else { + dst[j] = src[i]; + } + } - dst[j] = '\0'; // Null-terminate the destination + dst[j] = '\0'; // Null-terminate the destination - return i >= src_len ? j : -1; + return i >= src_len ? j : -1; } static int is_valid_http_method(const char *s) { - return !strcmp(s, "GET") || !strcmp(s, "POST") || !strcmp(s, "HEAD") || - !strcmp(s, "CONNECT") || !strcmp(s, "PUT") || !strcmp(s, "DELETE") || - !strcmp(s, "OPTIONS") || !strcmp(s, "PROPFIND") || !strcmp(s, "MKCOL"); + return !strcmp(s, "GET") || !strcmp(s, "POST") || !strcmp(s, "HEAD") || + !strcmp(s, "CONNECT") || !strcmp(s, "PUT") || !strcmp(s, "DELETE") || + !strcmp(s, "OPTIONS") || !strcmp(s, "PROPFIND") || !strcmp(s, "MKCOL"); } // Parse HTTP request, fill in mg_request structure. @@ -2260,120 +2259,120 @@ static int is_valid_http_method(const char *s) { // HTTP request components, header names and header values. // Note that len must point to the last \n of HTTP headers. static int parse_http_message(char *buf, int len, struct mg_connection *ri) { - int is_request, n; - - // Reset the connection. Make sure that we don't touch fields that are - // set elsewhere: remote_ip, remote_port, server_param - ri->request_method = ri->uri = ri->http_version = ri->query_string = NULL; - ri->num_headers = ri->status_code = ri->is_websocket = ri->content_len = 0; - - buf[len - 1] = '\0'; - - // RFC says that all initial whitespaces should be ingored - while (*buf != '\0' && isspace(* (unsigned char *) buf)) { - buf++; - } - ri->request_method = skip(&buf, " "); - ri->uri = skip(&buf, " "); - ri->http_version = skip(&buf, "\r\n"); - - // HTTP message could be either HTTP request or HTTP response, e.g. - // "GET / HTTP/1.0 ...." or "HTTP/1.0 200 OK ..." - is_request = is_valid_http_method(ri->request_method); - if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) || - (!is_request && memcmp(ri->request_method, "HTTP/", 5) != 0)) { - len = -1; - } else { - if (is_request) { - ri->http_version += 5; - } - parse_http_headers(&buf, ri); - - if ((ri->query_string = strchr(ri->uri, '?')) != NULL) { - *(char *) ri->query_string++ = '\0'; - } - n = (int) strlen(ri->uri); - mg_url_decode(ri->uri, n, (char *) ri->uri, n + 1, 0); - if (*ri->uri == '/' || *ri->uri == '.') { - remove_double_dots_and_double_slashes((char *) ri->uri); - } - } - - return len; + int is_request, n; + + // Reset the connection. Make sure that we don't touch fields that are + // set elsewhere: remote_ip, remote_port, server_param + ri->request_method = ri->uri = ri->http_version = ri->query_string = NULL; + ri->num_headers = ri->status_code = ri->is_websocket = ri->content_len = 0; + + buf[len - 1] = '\0'; + + // RFC says that all initial whitespaces should be ingored + while (*buf != '\0' && isspace(* (unsigned char *) buf)) { + buf++; + } + ri->request_method = skip(&buf, " "); + ri->uri = skip(&buf, " "); + ri->http_version = skip(&buf, "\r\n"); + + // HTTP message could be either HTTP request or HTTP response, e.g. + // "GET / HTTP/1.0 ...." or "HTTP/1.0 200 OK ..." + is_request = is_valid_http_method(ri->request_method); + if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) || + (!is_request && memcmp(ri->request_method, "HTTP/", 5) != 0)) { + len = -1; + } else { + if (is_request) { + ri->http_version += 5; + } + parse_http_headers(&buf, ri); + + if ((ri->query_string = strchr(ri->uri, '?')) != NULL) { + *(char *) ri->query_string++ = '\0'; + } + n = (int) strlen(ri->uri); + mg_url_decode(ri->uri, n, (char *) ri->uri, n + 1, 0); + if (*ri->uri == '/' || *ri->uri == '.') { + remove_double_dots_and_double_slashes((char *) ri->uri); + } + } + + return len; } static int lowercase(const char *s) { - return tolower(* (const unsigned char *) s); + return tolower(* (const unsigned char *) s); } static int mg_strcasecmp(const char *s1, const char *s2) { - int diff; + int diff; - do { - diff = lowercase(s1++) - lowercase(s2++); - } while (diff == 0 && s1[-1] != '\0'); + do { + diff = lowercase(s1++) - lowercase(s2++); + } while (diff == 0 && s1[-1] != '\0'); - return diff; + return diff; } static int mg_strncasecmp(const char *s1, const char *s2, size_t len) { - int diff = 0; + int diff = 0; - if (len > 0) - do { - diff = lowercase(s1++) - lowercase(s2++); - } while (diff == 0 && s1[-1] != '\0' && --len > 0); + if (len > 0) + do { + diff = lowercase(s1++) - lowercase(s2++); + } while (diff == 0 && s1[-1] != '\0' && --len > 0); - return diff; + return diff; } // Return HTTP header value, or NULL if not found. const char *mg_get_header(const struct mg_connection *ri, const char *s) { - int i; + int i; - for (i = 0; i < ri->num_headers; i++) - if (!mg_strcasecmp(s, ri->http_headers[i].name)) - return ri->http_headers[i].value; + for (i = 0; i < ri->num_headers; i++) + if (!mg_strcasecmp(s, ri->http_headers[i].name)) + return ri->http_headers[i].value; - return NULL; + return NULL; } // Perform case-insensitive match of string against pattern int mg_match_prefix(const char *pattern, int pattern_len, const char *str) { - const char *or_str; - int len, res, i = 0, j = 0; - - if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) { - res = mg_match_prefix(pattern, or_str - pattern, str); - return res > 0 ? res : mg_match_prefix(or_str + 1, - (pattern + pattern_len) - (or_str + 1), str); - } - - for (; i < pattern_len; i++, j++) { - if (pattern[i] == '?' && str[j] != '\0') { - continue; - } else if (pattern[i] == '$') { - return str[j] == '\0' ? j : -1; - } else if (pattern[i] == '*') { - i++; - if (pattern[i] == '*') { - i++; - len = (int) strlen(str + j); - } else { - len = (int) strcspn(str + j, "/"); - } - if (i == pattern_len) { - return j + len; - } - do { - res = mg_match_prefix(pattern + i, pattern_len - i, str + j + len); - } while (res == -1 && len-- > 0); - return res == -1 ? -1 : j + res + len; - } else if (lowercase(&pattern[i]) != lowercase(&str[j])) { - return -1; - } - } - return j; + const char *or_str; + int len, res, i = 0, j = 0; + + if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) { + res = mg_match_prefix(pattern, or_str - pattern, str); + return res > 0 ? res : mg_match_prefix(or_str + 1, + (pattern + pattern_len) - (or_str + 1), str); + } + + for (; i < pattern_len; i++, j++) { + if (pattern[i] == '?' && str[j] != '\0') { + continue; + } else if (pattern[i] == '$') { + return str[j] == '\0' ? j : -1; + } else if (pattern[i] == '*') { + i++; + if (pattern[i] == '*') { + i++; + len = (int) strlen(str + j); + } else { + len = (int) strcspn(str + j, "/"); + } + if (i == pattern_len) { + return j + len; + } + do { + res = mg_match_prefix(pattern + i, pattern_len - i, str + j + len); + } while (res == -1 && len-- > 0); + return res == -1 ? -1 : j + res + len; + } else if (lowercase(&pattern[i]) != lowercase(&str[j])) { + return -1; + } + } + return j; } // This function prints HTML pages, and expands "{{something}}" blocks @@ -2381,182 +2380,182 @@ int mg_match_prefix(const char *pattern, int pattern_len, const char *str) { // Note that {{@path/to/file}} construct outputs embedded file's contents, // which provides SSI-like functionality. void mg_template(struct mg_connection *conn, const char *s, - struct mg_expansion *expansions) { - int i, j, pos = 0, inside_marker = 0; - - for (i = 0; s[i] != '\0'; i++) { - if (inside_marker == 0 && !memcmp(&s[i], "{{", 2)) { - if (i > pos) { - mg_send_data(conn, &s[pos], i - pos); - } - pos = i; - inside_marker = 1; - } - if (inside_marker == 1 && !memcmp(&s[i], "}}", 2)) { - for (j = 0; expansions[j].keyword != NULL; j++) { - const char *kw = expansions[j].keyword; - if ((int) strlen(kw) == i - (pos + 2) && - memcmp(kw, &s[pos + 2], i - (pos + 2)) == 0) { - expansions[j].handler(conn); - pos = i + 2; - break; - } - } - inside_marker = 0; - } - } - if (i > pos) { - mg_send_data(conn, &s[pos], i - pos); - } + struct mg_expansion *expansions) { + int i, j, pos = 0, inside_marker = 0; + + for (i = 0; s[i] != '\0'; i++) { + if (inside_marker == 0 && !memcmp(&s[i], "{{", 2)) { + if (i > pos) { + mg_send_data(conn, &s[pos], i - pos); + } + pos = i; + inside_marker = 1; + } + if (inside_marker == 1 && !memcmp(&s[i], "}}", 2)) { + for (j = 0; expansions[j].keyword != NULL; j++) { + const char *kw = expansions[j].keyword; + if ((int) strlen(kw) == i - (pos + 2) && + memcmp(kw, &s[pos + 2], i - (pos + 2)) == 0) { + expansions[j].handler(conn); + pos = i + 2; + break; + } + } + inside_marker = 0; + } + } + if (i > pos) { + mg_send_data(conn, &s[pos], i - pos); + } } #ifndef MONGOOSE_NO_FILESYSTEM static int must_hide_file(struct connection *conn, const char *path) { - const char *pw_pattern = "**" PASSWORDS_FILE_NAME "$"; - const char *pattern = conn->server->config_options[HIDE_FILES_PATTERN]; - return mg_match_prefix(pw_pattern, strlen(pw_pattern), path) > 0 || - (pattern != NULL && mg_match_prefix(pattern, strlen(pattern), path) > 0); + const char *pw_pattern = "**" PASSWORDS_FILE_NAME "$"; + const char *pattern = conn->server->config_options[HIDE_FILES_PATTERN]; + return mg_match_prefix(pw_pattern, strlen(pw_pattern), path) > 0 || + (pattern != NULL && mg_match_prefix(pattern, strlen(pattern), path) > 0); } // Return 1 if real file has been found, 0 otherwise static int convert_uri_to_file_name(struct connection *conn, char *buf, - size_t buf_len, file_stat_t *st) { - struct vec a, b; - const char *rewrites = conn->server->config_options[URL_REWRITES]; - const char *root = conn->server->config_options[DOCUMENT_ROOT]; + size_t buf_len, file_stat_t *st) { + struct vec a, b; + const char *rewrites = conn->server->config_options[URL_REWRITES]; + const char *root = conn->server->config_options[DOCUMENT_ROOT]; #ifndef MONGOOSE_NO_CGI - const char *cgi_pat = conn->server->config_options[CGI_PATTERN]; - char *p; + const char *cgi_pat = conn->server->config_options[CGI_PATTERN]; + char *p; #endif - const char *uri = conn->mg_conn.uri; - const char *domain = mg_get_header(&conn->mg_conn, "Host"); - int match_len, root_len = root == NULL ? 0 : strlen(root); - - // Perform virtual hosting rewrites - if (rewrites != NULL && domain != NULL) { - const char *colon = strchr(domain, ':'); - int domain_len = colon == NULL ? (int) strlen(domain) : colon - domain; - - while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { - if (a.len > 1 && a.ptr[0] == '@' && a.len == domain_len + 1 && - mg_strncasecmp(a.ptr + 1, domain, domain_len) == 0) { - root = b.ptr; - root_len = b.len; - break; - } - } - } - - // No filesystem access - if (root == NULL || root_len == 0) return 0; - - // Handle URL rewrites - mg_snprintf(buf, buf_len, "%.*s%s", root_len, root, uri); - rewrites = conn->server->config_options[URL_REWRITES]; // Re-initialize! - while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { - if ((match_len = mg_match_prefix(a.ptr, a.len, uri)) > 0) { - mg_snprintf(buf, buf_len, "%.*s%s", (int) b.len, b.ptr, uri + match_len); - break; - } - } - - if (stat(buf, st) == 0) return 1; + const char *uri = conn->mg_conn.uri; + const char *domain = mg_get_header(&conn->mg_conn, "Host"); + int match_len, root_len = root == NULL ? 0 : strlen(root); + + // Perform virtual hosting rewrites + if (rewrites != NULL && domain != NULL) { + const char *colon = strchr(domain, ':'); + int domain_len = colon == NULL ? (int) strlen(domain) : colon - domain; + + while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { + if (a.len > 1 && a.ptr[0] == '@' && a.len == domain_len + 1 && + mg_strncasecmp(a.ptr + 1, domain, domain_len) == 0) { + root = b.ptr; + root_len = b.len; + break; + } + } + } + + // No filesystem access + if (root == NULL || root_len == 0) return 0; + + // Handle URL rewrites + mg_snprintf(buf, buf_len, "%.*s%s", root_len, root, uri); + rewrites = conn->server->config_options[URL_REWRITES]; // Re-initialize! + while ((rewrites = next_option(rewrites, &a, &b)) != NULL) { + if ((match_len = mg_match_prefix(a.ptr, a.len, uri)) > 0) { + mg_snprintf(buf, buf_len, "%.*s%s", (int) b.len, b.ptr, uri + match_len); + break; + } + } + + if (stat(buf, st) == 0) return 1; #ifndef MONGOOSE_NO_CGI - // Support PATH_INFO for CGI scripts. - for (p = buf + strlen(root) + 2; *p != '\0'; p++) { - if (*p == '/') { - *p = '\0'; - if (mg_match_prefix(cgi_pat, strlen(cgi_pat), buf) > 0 && - !stat(buf, st)) { - DBG(("!!!! [%s]", buf)); - *p = '/'; - conn->path_info = mg_strdup(p); - *p = '\0'; - return 1; - } - *p = '/'; - } - } + // Support PATH_INFO for CGI scripts. + for (p = buf + strlen(root) + 2; *p != '\0'; p++) { + if (*p == '/') { + *p = '\0'; + if (mg_match_prefix(cgi_pat, strlen(cgi_pat), buf) > 0 && + !stat(buf, st)) { + DBG(("!!!! [%s]", buf)); + *p = '/'; + conn->path_info = mg_strdup(p); + *p = '\0'; + return 1; + } + *p = '/'; + } + } #endif - return 0; + return 0; } #endif // MONGOOSE_NO_FILESYSTEM static int should_keep_alive(const struct mg_connection *conn) { - struct connection *c = MG_CONN_2_CONN(conn); - const char *method = conn->request_method; - const char *http_version = conn->http_version; - const char *header = mg_get_header(conn, "Connection"); - return method != NULL && - (!strcmp(method, "GET") || c->endpoint_type == EP_USER) && - ((header != NULL && !mg_strcasecmp(header, "keep-alive")) || - (header == NULL && http_version && !strcmp(http_version, "1.1"))); + struct connection *c = MG_CONN_2_CONN(conn); + const char *method = conn->request_method; + const char *http_version = conn->http_version; + const char *header = mg_get_header(conn, "Connection"); + return method != NULL && + (!strcmp(method, "GET") || c->endpoint_type == EP_USER) && + ((header != NULL && !mg_strcasecmp(header, "keep-alive")) || + (header == NULL && http_version && !strcmp(http_version, "1.1"))); } size_t mg_write(struct mg_connection *c, const void *buf, int len) { - struct connection *conn = MG_CONN_2_CONN(c); - ns_send(conn->ns_conn, buf, len); - return conn->ns_conn->send_iobuf.len; + struct connection *conn = MG_CONN_2_CONN(c); + ns_send(conn->ns_conn, buf, len); + return conn->ns_conn->send_iobuf.len; } void mg_send_status(struct mg_connection *c, int status) { - if (c->status_code == 0) { - c->status_code = status; - mg_printf(c, "HTTP/1.1 %d %s\r\n", status, status_code_to_str(status)); - } + if (c->status_code == 0) { + c->status_code = status; + mg_printf(c, "HTTP/1.1 %d %s\r\n", status, status_code_to_str(status)); + } } void mg_send_header(struct mg_connection *c, const char *name, const char *v) { - if (c->status_code == 0) { - c->status_code = 200; - mg_printf(c, "HTTP/1.1 %d %s\r\n", 200, status_code_to_str(200)); - } - mg_printf(c, "%s: %s\r\n", name, v); + if (c->status_code == 0) { + c->status_code = 200; + mg_printf(c, "HTTP/1.1 %d %s\r\n", 200, status_code_to_str(200)); + } + mg_printf(c, "%s: %s\r\n", name, v); } static void terminate_headers(struct mg_connection *c) { - struct connection *conn = MG_CONN_2_CONN(c); - if (!(conn->ns_conn->flags & MG_HEADERS_SENT)) { - mg_send_header(c, "Transfer-Encoding", "chunked"); - mg_write(c, "\r\n", 2); - conn->ns_conn->flags |= MG_HEADERS_SENT; - } + struct connection *conn = MG_CONN_2_CONN(c); + if (!(conn->ns_conn->flags & MG_HEADERS_SENT)) { + mg_send_header(c, "Transfer-Encoding", "chunked"); + mg_write(c, "\r\n", 2); + conn->ns_conn->flags |= MG_HEADERS_SENT; + } } size_t mg_send_data(struct mg_connection *c, const void *data, int data_len) { - struct connection *conn = MG_CONN_2_CONN(c); - terminate_headers(c); - write_chunk(MG_CONN_2_CONN(c), (const char *) data, data_len); - return conn->ns_conn->send_iobuf.len; + struct connection *conn = MG_CONN_2_CONN(c); + terminate_headers(c); + write_chunk(MG_CONN_2_CONN(c), (const char *) data, data_len); + return conn->ns_conn->send_iobuf.len; } size_t mg_printf_data(struct mg_connection *c, const char *fmt, ...) { - struct connection *conn = MG_CONN_2_CONN(c); - va_list ap; - int len; - char mem[IOBUF_SIZE], *buf = mem; + struct connection *conn = MG_CONN_2_CONN(c); + va_list ap; + int len; + char mem[IOBUF_SIZE], *buf = mem; - terminate_headers(c); + terminate_headers(c); - va_start(ap, fmt); - len = ns_avprintf(&buf, sizeof(mem), fmt, ap); - va_end(ap); + va_start(ap, fmt); + len = ns_avprintf(&buf, sizeof(mem), fmt, ap); + va_end(ap); - if (len >= 0) { - write_chunk((struct connection *) conn, buf, len); - } - if (buf != mem && buf != NULL) { - free(buf); - } - return conn->ns_conn->send_iobuf.len; + if (len >= 0) { + write_chunk((struct connection *) conn, buf, len); + } + if (buf != mem && buf != NULL) { + free(buf); + } + return conn->ns_conn->send_iobuf.len; } #if !defined(MONGOOSE_NO_WEBSOCKET) || !defined(MONGOOSE_NO_AUTH) static int is_big_endian(void) { - static const int n = 1; - return ((char *) &n)[0] == 0; + static const int n = 1; + return ((char *) &n)[0] == 0; } #endif @@ -2573,16 +2572,16 @@ union char64long16 { unsigned char c[64]; uint32_t l[16]; }; #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) static uint32_t blk0(union char64long16 *block, int i) { - // Forrest: SHA expect BIG_ENDIAN, swap if LITTLE_ENDIAN - if (!is_big_endian()) { - block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | - (rol(block->l[i], 8) & 0x00FF00FF); - } - return block->l[i]; + // Forrest: SHA expect BIG_ENDIAN, swap if LITTLE_ENDIAN + if (!is_big_endian()) { + block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | + (rol(block->l[i], 8) & 0x00FF00FF); + } + return block->l[i]; } #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) + ^block->l[(i+2)&15]^block->l[i&15],1)) #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(block, i)+0x5A827999+rol(v,5);w=rol(w,30); #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); @@ -2590,1056 +2589,1055 @@ static uint32_t blk0(union char64long16 *block, int i) { #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); typedef struct { - uint32_t state[5]; - uint32_t count[2]; - unsigned char buffer[64]; + uint32_t state[5]; + uint32_t count[2]; + unsigned char buffer[64]; } SHA1_CTX; static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) { - uint32_t a, b, c, d, e; - union char64long16 block[1]; - - memcpy(block, buffer, 64); - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - // Erase working structures. The order of operations is important, - // used to ensure that compiler doesn't optimize those out. - memset(block, 0, sizeof(block)); - a = b = c = d = e = 0; - (void) a; (void) b; (void) c; (void) d; (void) e; + uint32_t a, b, c, d, e; + union char64long16 block[1]; + + memcpy(block, buffer, 64); + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + // Erase working structures. The order of operations is important, + // used to ensure that compiler doesn't optimize those out. + memset(block, 0, sizeof(block)); + a = b = c = d = e = 0; + (void) a; (void) b; (void) c; (void) d; (void) e; } static void SHA1Init(SHA1_CTX *context) { - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; - context->count[0] = context->count[1] = 0; + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; } static void SHA1Update(SHA1_CTX *context, const unsigned char *data, - uint32_t len) { - uint32_t i, j; - - j = context->count[0]; - if ((context->count[0] += len << 3) < j) - context->count[1]++; - context->count[1] += (len>>29); - j = (j >> 3) & 63; - if ((j + len) > 63) { - memcpy(&context->buffer[j], data, (i = 64-j)); - SHA1Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) { - SHA1Transform(context->state, &data[i]); - } - j = 0; - } - else i = 0; - memcpy(&context->buffer[j], &data[i], len - i); + uint32_t len) { + uint32_t i, j; + + j = context->count[0]; + if ((context->count[0] += len << 3) < j) + context->count[1]++; + context->count[1] += (len>>29); + j = (j >> 3) & 63; + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); } static void SHA1Final(unsigned char digest[20], SHA1_CTX *context) { - unsigned i; - unsigned char finalcount[8], c; - - for (i = 0; i < 8; i++) { - finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] - >> ((3-(i & 3)) * 8) ) & 255); - } - c = 0200; - SHA1Update(context, &c, 1); - while ((context->count[0] & 504) != 448) { - c = 0000; - SHA1Update(context, &c, 1); - } - SHA1Update(context, finalcount, 8); - for (i = 0; i < 20; i++) { - digest[i] = (unsigned char) - ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); - } - memset(context, '\0', sizeof(*context)); - memset(&finalcount, '\0', sizeof(finalcount)); + unsigned i; + unsigned char finalcount[8], c; + + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); + } + c = 0200; + SHA1Update(context, &c, 1); + while ((context->count[0] & 504) != 448) { + c = 0000; + SHA1Update(context, &c, 1); + } + SHA1Update(context, finalcount, 8); + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + memset(context, '\0', sizeof(*context)); + memset(&finalcount, '\0', sizeof(finalcount)); } // END OF SHA1 CODE static void base64_encode(const unsigned char *src, int src_len, char *dst) { - static const char *b64 = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - int i, j, a, b, c; - - for (i = j = 0; i < src_len; i += 3) { - a = src[i]; - b = i + 1 >= src_len ? 0 : src[i + 1]; - c = i + 2 >= src_len ? 0 : src[i + 2]; - - dst[j++] = b64[a >> 2]; - dst[j++] = b64[((a & 3) << 4) | (b >> 4)]; - if (i + 1 < src_len) { - dst[j++] = b64[(b & 15) << 2 | (c >> 6)]; - } - if (i + 2 < src_len) { - dst[j++] = b64[c & 63]; - } - } - while (j % 4 != 0) { - dst[j++] = '='; - } - dst[j++] = '\0'; + static const char *b64 = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + int i, j, a, b, c; + + for (i = j = 0; i < src_len; i += 3) { + a = src[i]; + b = i + 1 >= src_len ? 0 : src[i + 1]; + c = i + 2 >= src_len ? 0 : src[i + 2]; + + dst[j++] = b64[a >> 2]; + dst[j++] = b64[((a & 3) << 4) | (b >> 4)]; + if (i + 1 < src_len) { + dst[j++] = b64[(b & 15) << 2 | (c >> 6)]; + } + if (i + 2 < src_len) { + dst[j++] = b64[c & 63]; + } + } + while (j % 4 != 0) { + dst[j++] = '='; + } + dst[j++] = '\0'; } static void send_websocket_handshake(struct mg_connection *conn, - const char *key) { - static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - char buf[500], sha[20], b64_sha[sizeof(sha) * 2]; - SHA1_CTX sha_ctx; + const char *key) { + static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + char buf[500], sha[20], b64_sha[sizeof(sha) * 2]; + SHA1_CTX sha_ctx; - mg_snprintf(buf, sizeof(buf), "%s%s", key, magic); - SHA1Init(&sha_ctx); - SHA1Update(&sha_ctx, (unsigned char *) buf, strlen(buf)); - SHA1Final((unsigned char *) sha, &sha_ctx); - base64_encode((unsigned char *) sha, sizeof(sha), b64_sha); - mg_snprintf(buf, sizeof(buf), "%s%s%s", - "HTTP/1.1 101 Switching Protocols\r\n" - "Upgrade: websocket\r\n" - "Connection: Upgrade\r\n" - "Sec-WebSocket-Accept: ", b64_sha, "\r\n\r\n"); + mg_snprintf(buf, sizeof(buf), "%s%s", key, magic); + SHA1Init(&sha_ctx); + SHA1Update(&sha_ctx, (unsigned char *) buf, strlen(buf)); + SHA1Final((unsigned char *) sha, &sha_ctx); + base64_encode((unsigned char *) sha, sizeof(sha), b64_sha); + mg_snprintf(buf, sizeof(buf), "%s%s%s", + "HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Accept: ", b64_sha, "\r\n\r\n"); - mg_write(conn, buf, strlen(buf)); + mg_write(conn, buf, strlen(buf)); } static int deliver_websocket_frame(struct connection *conn) { - // Having buf unsigned char * is important, as it is used below in arithmetic - unsigned char *buf = (unsigned char *) conn->ns_conn->recv_iobuf.buf; - int i, len, buf_len = conn->ns_conn->recv_iobuf.len, frame_len = 0, - mask_len = 0, header_len = 0, data_len = 0, buffered = 0; - - if (buf_len >= 2) { - len = buf[1] & 127; - mask_len = buf[1] & 128 ? 4 : 0; - if (len < 126 && buf_len >= mask_len) { - data_len = len; - header_len = 2 + mask_len; - } else if (len == 126 && buf_len >= 4 + mask_len) { - header_len = 4 + mask_len; - data_len = ((((int) buf[2]) << 8) + buf[3]); - } else if (buf_len >= 10 + mask_len) { - header_len = 10 + mask_len; - data_len = (int) (((uint64_t) htonl(* (uint32_t *) &buf[2])) << 32) + - htonl(* (uint32_t *) &buf[6]); - } - } - - frame_len = header_len + data_len; - buffered = frame_len > 0 && frame_len <= buf_len; - - if (buffered) { - conn->mg_conn.content_len = data_len; - conn->mg_conn.content = (char *) buf + header_len; - conn->mg_conn.wsbits = buf[0]; - - // Apply mask if necessary - if (mask_len > 0) { - for (i = 0; i < data_len; i++) { - buf[i + header_len] ^= (buf + header_len - mask_len)[i % 4]; - } - } - - // Call the handler and remove frame from the iobuf - if (call_user(conn, MG_REQUEST) == MG_FALSE) { - conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; - } - iobuf_remove(&conn->ns_conn->recv_iobuf, frame_len); - } - - return buffered; + // Having buf unsigned char * is important, as it is used below in arithmetic + unsigned char *buf = (unsigned char *) conn->ns_conn->recv_iobuf.buf; + int i, len, buf_len = conn->ns_conn->recv_iobuf.len, frame_len = 0, + mask_len = 0, header_len = 0, data_len = 0, buffered = 0; + + if (buf_len >= 2) { + len = buf[1] & 127; + mask_len = buf[1] & 128 ? 4 : 0; + if (len < 126 && buf_len >= mask_len) { + data_len = len; + header_len = 2 + mask_len; + } else if (len == 126 && buf_len >= 4 + mask_len) { + header_len = 4 + mask_len; + data_len = ((((int) buf[2]) << 8) + buf[3]); + } else if (buf_len >= 10 + mask_len) { + header_len = 10 + mask_len; + data_len = (int) (((uint64_t) htonl(* (uint32_t *) &buf[2])) << 32) + + htonl(* (uint32_t *) &buf[6]); + } + } + + frame_len = header_len + data_len; + buffered = frame_len > 0 && frame_len <= buf_len; + + if (buffered) { + conn->mg_conn.content_len = data_len; + conn->mg_conn.content = (char *) buf + header_len; + conn->mg_conn.wsbits = buf[0]; + + // Apply mask if necessary + if (mask_len > 0) { + for (i = 0; i < data_len; i++) { + buf[i + header_len] ^= (buf + header_len - mask_len)[i % 4]; + } + } + + // Call the handler and remove frame from the iobuf + if (call_user(conn, MG_REQUEST) == MG_FALSE) { + conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; + } + iobuf_remove(&conn->ns_conn->recv_iobuf, frame_len); + } + + return buffered; } size_t mg_websocket_write(struct mg_connection *conn, int opcode, - const char *data, size_t data_len) { - unsigned char mem[4192], *copy = mem; - size_t copy_len = 0; - - if (data_len + 10 > sizeof(mem) && - (copy = (unsigned char *) malloc(data_len + 10)) == NULL) { - return 0; - } - - copy[0] = 0x80 + (opcode & 0x0f); - - // Frame format: http://tools.ietf.org/html/rfc6455#section-5.2 - if (data_len < 126) { - // Inline 7-bit length field - copy[1] = data_len; - memcpy(copy + 2, data, data_len); - copy_len = 2 + data_len; - } else if (data_len <= 0xFFFF) { - // 16-bit length field - copy[1] = 126; - * (uint16_t *) (copy + 2) = (uint16_t) htons((uint16_t) data_len); - memcpy(copy + 4, data, data_len); - copy_len = 4 + data_len; - } else { - // 64-bit length field - copy[1] = 127; - * (uint32_t *) (copy + 2) = (uint32_t) - htonl((uint32_t) ((uint64_t) data_len >> 32)); - * (uint32_t *) (copy + 6) = (uint32_t) htonl(data_len & 0xffffffff); - memcpy(copy + 10, data, data_len); - copy_len = 10 + data_len; - } - - if (copy_len > 0) { - mg_write(conn, copy, copy_len); - } - if (copy != mem) { - free(copy); - } - - // If we send closing frame, schedule a connection to be closed after - // data is drained to the client. - if (opcode == WEBSOCKET_OPCODE_CONNECTION_CLOSE) { - MG_CONN_2_CONN(conn)->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; - } - - return MG_CONN_2_CONN(conn)->ns_conn->send_iobuf.len; + const char *data, size_t data_len) { + unsigned char mem[4192], *copy = mem; + size_t copy_len = 0; + + if (data_len + 10 > sizeof(mem) && + (copy = (unsigned char *) malloc(data_len + 10)) == NULL) { + return 0; + } + + copy[0] = 0x80 + (opcode & 0x0f); + + // Frame format: http://tools.ietf.org/html/rfc6455#section-5.2 + if (data_len < 126) { + // Inline 7-bit length field + copy[1] = data_len; + memcpy(copy + 2, data, data_len); + copy_len = 2 + data_len; + } else if (data_len <= 0xFFFF) { + // 16-bit length field + copy[1] = 126; + * (uint16_t *) (copy + 2) = (uint16_t) htons((uint16_t) data_len); + memcpy(copy + 4, data, data_len); + copy_len = 4 + data_len; + } else { + // 64-bit length field + copy[1] = 127; + * (uint32_t *) (copy + 2) = (uint32_t) + htonl((uint32_t) ((uint64_t) data_len >> 32)); + * (uint32_t *) (copy + 6) = (uint32_t) htonl(data_len & 0xffffffff); + memcpy(copy + 10, data, data_len); + copy_len = 10 + data_len; + } + + if (copy_len > 0) { + mg_write(conn, copy, copy_len); + } + if (copy != mem) { + free(copy); + } + + // If we send closing frame, schedule a connection to be closed after + // data is drained to the client. + if (opcode == WEBSOCKET_OPCODE_CONNECTION_CLOSE) { + MG_CONN_2_CONN(conn)->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; + } + + return MG_CONN_2_CONN(conn)->ns_conn->send_iobuf.len; } size_t mg_websocket_printf(struct mg_connection *conn, int opcode, - const char *fmt, ...) { - char mem[4192], *buf = mem; - va_list ap; - int len; + const char *fmt, ...) { + char mem[4192], *buf = mem; + va_list ap; + int len; - va_start(ap, fmt); - if ((len = ns_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) { - mg_websocket_write(conn, opcode, buf, len); - } - va_end(ap); + va_start(ap, fmt); + if ((len = ns_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) { + mg_websocket_write(conn, opcode, buf, len); + } + va_end(ap); - if (buf != mem && buf != NULL) { - free(buf); - } + if (buf != mem && buf != NULL) { + free(buf); + } - return MG_CONN_2_CONN(conn)->ns_conn->send_iobuf.len; + return MG_CONN_2_CONN(conn)->ns_conn->send_iobuf.len; } static void send_websocket_handshake_if_requested(struct mg_connection *conn) { - const char *ver = mg_get_header(conn, "Sec-WebSocket-Version"), - *key = mg_get_header(conn, "Sec-WebSocket-Key"); - if (ver != NULL && key != NULL) { - conn->is_websocket = 1; - if (call_user(MG_CONN_2_CONN(conn), MG_WS_HANDSHAKE) == MG_FALSE) { - send_websocket_handshake(conn, key); - } - call_user(MG_CONN_2_CONN(conn), MG_WS_CONNECT); - } + const char *ver = mg_get_header(conn, "Sec-WebSocket-Version"), + *key = mg_get_header(conn, "Sec-WebSocket-Key"); + if (ver != NULL && key != NULL) { + conn->is_websocket = 1; + if (call_user(MG_CONN_2_CONN(conn), MG_WS_HANDSHAKE) == MG_FALSE) { + send_websocket_handshake(conn, key); + } + call_user(MG_CONN_2_CONN(conn), MG_WS_CONNECT); + } } static void ping_idle_websocket_connection(struct connection *conn, time_t t) { - if (t - conn->ns_conn->last_io_time > MONGOOSE_USE_WEBSOCKET_PING_INTERVAL) { - mg_websocket_write(&conn->mg_conn, WEBSOCKET_OPCODE_PING, "", 0); - } + if (t - conn->ns_conn->last_io_time > MONGOOSE_USE_WEBSOCKET_PING_INTERVAL) { + mg_websocket_write(&conn->mg_conn, WEBSOCKET_OPCODE_PING, "", 0); + } } #else #define ping_idle_websocket_connection(conn, t) #endif // !MONGOOSE_NO_WEBSOCKET static void write_terminating_chunk(struct connection *conn) { - mg_write(&conn->mg_conn, "0\r\n\r\n", 5); + mg_write(&conn->mg_conn, "0\r\n\r\n", 5); } static int call_request_handler(struct connection *conn) { - int result; - conn->mg_conn.content = conn->ns_conn->recv_iobuf.buf; - if ((result = call_user(conn, MG_REQUEST)) == MG_TRUE) { - if (conn->ns_conn->flags & MG_HEADERS_SENT) { - write_terminating_chunk(conn); - } - close_local_endpoint(conn); - } - return result; + int result; + conn->mg_conn.content = conn->ns_conn->recv_iobuf.buf; + if ((result = call_user(conn, MG_REQUEST)) == MG_TRUE) { + if (conn->ns_conn->flags & MG_HEADERS_SENT) { + write_terminating_chunk(conn); + } + close_local_endpoint(conn); + } + return result; } const char *mg_get_mime_type(const char *path, const char *default_mime_type) { - const char *ext; - size_t i, path_len; + const char *ext; + size_t i, path_len; - path_len = strlen(path); + path_len = strlen(path); - for (i = 0; static_builtin_mime_types[i].extension != NULL; i++) { - ext = path + (path_len - static_builtin_mime_types[i].ext_len); - if (path_len > static_builtin_mime_types[i].ext_len && - mg_strcasecmp(ext, static_builtin_mime_types[i].extension) == 0) { - return static_builtin_mime_types[i].mime_type; - } - } + for (i = 0; static_builtin_mime_types[i].extension != NULL; i++) { + ext = path + (path_len - static_builtin_mime_types[i].ext_len); + if (path_len > static_builtin_mime_types[i].ext_len && + mg_strcasecmp(ext, static_builtin_mime_types[i].extension) == 0) { + return static_builtin_mime_types[i].mime_type; + } + } - return default_mime_type; + return default_mime_type; } #ifndef MONGOOSE_NO_FILESYSTEM // Convert month to the month number. Return -1 on error, or month number static int get_month_index(const char *s) { - static const char *month_names[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - int i; + static const char *month_names[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + int i; - for (i = 0; i < (int) ARRAY_SIZE(month_names); i++) - if (!strcmp(s, month_names[i])) - return i; + for (i = 0; i < (int) ARRAY_SIZE(month_names); i++) + if (!strcmp(s, month_names[i])) + return i; - return -1; + return -1; } static int num_leap_years(int year) { - return year / 4 - year / 100 + year / 400; + return year / 4 - year / 100 + year / 400; } // Parse UTC date-time string, and return the corresponding time_t value. static time_t parse_date_string(const char *datetime) { - static const unsigned short days_before_month[] = { - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 - }; - char month_str[32]; - int second, minute, hour, day, month, year, leap_days, days; - time_t result = (time_t) 0; - - if (((sscanf(datetime, "%d/%3s/%d %d:%d:%d", - &day, month_str, &year, &hour, &minute, &second) == 6) || - (sscanf(datetime, "%d %3s %d %d:%d:%d", - &day, month_str, &year, &hour, &minute, &second) == 6) || - (sscanf(datetime, "%*3s, %d %3s %d %d:%d:%d", - &day, month_str, &year, &hour, &minute, &second) == 6) || - (sscanf(datetime, "%d-%3s-%d %d:%d:%d", - &day, month_str, &year, &hour, &minute, &second) == 6)) && - year > 1970 && - (month = get_month_index(month_str)) != -1) { - leap_days = num_leap_years(year) - num_leap_years(1970); - year -= 1970; - days = year * 365 + days_before_month[month] + (day - 1) + leap_days; - result = days * 24 * 3600 + hour * 3600 + minute * 60 + second; - } - - return result; + static const unsigned short days_before_month[] = { + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + }; + char month_str[32]; + int second, minute, hour, day, month, year, leap_days, days; + time_t result = (time_t) 0; + + if (((sscanf(datetime, "%d/%3s/%d %d:%d:%d", + &day, month_str, &year, &hour, &minute, &second) == 6) || + (sscanf(datetime, "%d %3s %d %d:%d:%d", + &day, month_str, &year, &hour, &minute, &second) == 6) || + (sscanf(datetime, "%*3s, %d %3s %d %d:%d:%d", + &day, month_str, &year, &hour, &minute, &second) == 6) || + (sscanf(datetime, "%d-%3s-%d %d:%d:%d", + &day, month_str, &year, &hour, &minute, &second) == 6)) && + year > 1970 && + (month = get_month_index(month_str)) != -1) { + leap_days = num_leap_years(year) - num_leap_years(1970); + year -= 1970; + days = year * 365 + days_before_month[month] + (day - 1) + leap_days; + result = days * 24 * 3600 + hour * 3600 + minute * 60 + second; + } + + return result; } // Look at the "path" extension and figure what mime type it has. // Store mime type in the vector. static void get_mime_type(const struct mg_server *server, const char *path, - struct vec *vec) { - struct vec ext_vec, mime_vec; - const char *list, *ext; - size_t path_len; + struct vec *vec) { + struct vec ext_vec, mime_vec; + const char *list, *ext; + size_t path_len; - path_len = strlen(path); + path_len = strlen(path); - // Scan user-defined mime types first, in case user wants to - // override default mime types. - list = server->config_options[EXTRA_MIME_TYPES]; - while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) { - // ext now points to the path suffix - ext = path + path_len - ext_vec.len; - if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) { - *vec = mime_vec; - return; - } - } + // Scan user-defined mime types first, in case user wants to + // override default mime types. + list = server->config_options[EXTRA_MIME_TYPES]; + while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) { + // ext now points to the path suffix + ext = path + path_len - ext_vec.len; + if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) { + *vec = mime_vec; + return; + } + } - vec->ptr = mg_get_mime_type(path, "text/plain"); - vec->len = strlen(vec->ptr); + vec->ptr = mg_get_mime_type(path, "text/plain"); + vec->len = strlen(vec->ptr); } static const char *suggest_connection_header(const struct mg_connection *conn) { - return should_keep_alive(conn) ? "keep-alive" : "close"; + return should_keep_alive(conn) ? "keep-alive" : "close"; } static void construct_etag(char *buf, size_t buf_len, const file_stat_t *st) { - mg_snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"", - (unsigned long) st->st_mtime, (int64_t) st->st_size); + mg_snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"", + (unsigned long) st->st_mtime, (int64_t) st->st_size); } // Return True if we should reply 304 Not Modified. static int is_not_modified(const struct connection *conn, - const file_stat_t *stp) { - char etag[64]; - const char *ims = mg_get_header(&conn->mg_conn, "If-Modified-Since"); - const char *inm = mg_get_header(&conn->mg_conn, "If-None-Match"); - construct_etag(etag, sizeof(etag), stp); - return (inm != NULL && !mg_strcasecmp(etag, inm)) || - (ims != NULL && stp->st_mtime <= parse_date_string(ims)); + const file_stat_t *stp) { + char etag[64]; + const char *ims = mg_get_header(&conn->mg_conn, "If-Modified-Since"); + const char *inm = mg_get_header(&conn->mg_conn, "If-None-Match"); + construct_etag(etag, sizeof(etag), stp); + return (inm != NULL && !mg_strcasecmp(etag, inm)) || + (ims != NULL && stp->st_mtime <= parse_date_string(ims)); } // For given directory path, substitute it to valid index file. // Return 0 if index file has been found, -1 if not found. // If the file is found, it's stats is returned in stp. static int find_index_file(struct connection *conn, char *path, - size_t path_len, file_stat_t *stp) { - const char *list = conn->server->config_options[INDEX_FILES]; - file_stat_t st; - struct vec filename_vec; - size_t n = strlen(path), found = 0; - - // The 'path' given to us points to the directory. Remove all trailing - // directory separator characters from the end of the path, and - // then append single directory separator character. - while (n > 0 && path[n - 1] == '/') { - n--; - } - path[n] = '/'; - - // Traverse index files list. For each entry, append it to the given - // path and see if the file exists. If it exists, break the loop - while ((list = next_option(list, &filename_vec, NULL)) != NULL) { - - // Ignore too long entries that may overflow path buffer - if (filename_vec.len > (int) (path_len - (n + 2))) - continue; - - // Prepare full path to the index file - strncpy(path + n + 1, filename_vec.ptr, filename_vec.len); - path[n + 1 + filename_vec.len] = '\0'; - - //DBG(("[%s]", path)); - - // Does it exist? - if (!stat(path, &st)) { - // Yes it does, break the loop - *stp = st; - found = 1; - break; - } - } - - // If no index file exists, restore directory path - if (!found) { - path[n] = '\0'; - } - - return found; + size_t path_len, file_stat_t *stp) { + const char *list = conn->server->config_options[INDEX_FILES]; + file_stat_t st; + struct vec filename_vec; + size_t n = strlen(path), found = 0; + + // The 'path' given to us points to the directory. Remove all trailing + // directory separator characters from the end of the path, and + // then append single directory separator character. + while (n > 0 && path[n - 1] == '/') { + n--; + } + path[n] = '/'; + + // Traverse index files list. For each entry, append it to the given + // path and see if the file exists. If it exists, break the loop + while ((list = next_option(list, &filename_vec, NULL)) != NULL) { + // Ignore too long entries that may overflow path buffer + if (filename_vec.len > (int) (path_len - (n + 2))) + continue; + + // Prepare full path to the index file + strncpy(path + n + 1, filename_vec.ptr, filename_vec.len); + path[n + 1 + filename_vec.len] = '\0'; + + //DBG(("[%s]", path)); + + // Does it exist? + if (!stat(path, &st)) { + // Yes it does, break the loop + *stp = st; + found = 1; + break; + } + } + + // If no index file exists, restore directory path + if (!found) { + path[n] = '\0'; + } + + return found; } static int parse_range_header(const char *header, int64_t *a, int64_t *b) { - return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b); + return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b); } static void gmt_time_string(char *buf, size_t buf_len, time_t *t) { - strftime(buf, buf_len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(t)); + strftime(buf, buf_len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(t)); } static void open_file_endpoint(struct connection *conn, const char *path, - file_stat_t *st) { - char date[64], lm[64], etag[64], range[64], headers[500]; - const char *msg = "OK", *hdr; - time_t curtime = time(NULL); - int64_t r1, r2; - struct vec mime_vec; - int n; - - conn->endpoint_type = EP_FILE; - ns_set_close_on_exec(conn->endpoint.fd); - conn->mg_conn.status_code = 200; - - get_mime_type(conn->server, path, &mime_vec); - conn->cl = st->st_size; - range[0] = '\0'; - - // If Range: header specified, act accordingly - r1 = r2 = 0; - hdr = mg_get_header(&conn->mg_conn, "Range"); - if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0 && - r1 >= 0 && r2 >= 0) { - conn->mg_conn.status_code = 206; - conn->cl = n == 2 ? (r2 > conn->cl ? conn->cl : r2) - r1 + 1: conn->cl - r1; - mg_snprintf(range, sizeof(range), "Content-Range: bytes " - "%" INT64_FMT "-%" INT64_FMT "/%" INT64_FMT "\r\n", - r1, r1 + conn->cl - 1, (int64_t) st->st_size); - msg = "Partial Content"; - lseek(conn->endpoint.fd, r1, SEEK_SET); - } - - // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 - gmt_time_string(date, sizeof(date), &curtime); - gmt_time_string(lm, sizeof(lm), &st->st_mtime); - construct_etag(etag, sizeof(etag), st); - - n = mg_snprintf(headers, sizeof(headers), - "HTTP/1.1 %d %s\r\n" - "Date: %s\r\n" - "Last-Modified: %s\r\n" - "Etag: %s\r\n" - "Content-Type: %.*s\r\n" - "Content-Length: %" INT64_FMT "\r\n" - "Connection: %s\r\n" - "Accept-Ranges: bytes\r\n" - "%s%s\r\n", - conn->mg_conn.status_code, msg, date, lm, etag, - (int) mime_vec.len, mime_vec.ptr, conn->cl, - suggest_connection_header(&conn->mg_conn), - range, MONGOOSE_USE_EXTRA_HTTP_HEADERS); - ns_send(conn->ns_conn, headers, n); - - if (!strcmp(conn->mg_conn.request_method, "HEAD")) { - conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; - close(conn->endpoint.fd); - conn->endpoint_type = EP_NONE; - } + file_stat_t *st) { + char date[64], lm[64], etag[64], range[64], headers[500]; + const char *msg = "OK", *hdr; + time_t curtime = time(NULL); + int64_t r1, r2; + struct vec mime_vec; + int n; + + conn->endpoint_type = EP_FILE; + ns_set_close_on_exec(conn->endpoint.fd); + conn->mg_conn.status_code = 200; + + get_mime_type(conn->server, path, &mime_vec); + conn->cl = st->st_size; + range[0] = '\0'; + + // If Range: header specified, act accordingly + r1 = r2 = 0; + hdr = mg_get_header(&conn->mg_conn, "Range"); + if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0 && + r1 >= 0 && r2 >= 0) { + conn->mg_conn.status_code = 206; + conn->cl = n == 2 ? (r2 > conn->cl ? conn->cl : r2) - r1 + 1: conn->cl - r1; + mg_snprintf(range, sizeof(range), "Content-Range: bytes " + "%" INT64_FMT "-%" INT64_FMT "/%" INT64_FMT "\r\n", + r1, r1 + conn->cl - 1, (int64_t) st->st_size); + msg = "Partial Content"; + lseek(conn->endpoint.fd, r1, SEEK_SET); + } + + // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to + // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 + gmt_time_string(date, sizeof(date), &curtime); + gmt_time_string(lm, sizeof(lm), &st->st_mtime); + construct_etag(etag, sizeof(etag), st); + + n = mg_snprintf(headers, sizeof(headers), + "HTTP/1.1 %d %s\r\n" + "Date: %s\r\n" + "Last-Modified: %s\r\n" + "Etag: %s\r\n" + "Content-Type: %.*s\r\n" + "Content-Length: %" INT64_FMT "\r\n" + "Connection: %s\r\n" + "Accept-Ranges: bytes\r\n" + "%s%s\r\n", + conn->mg_conn.status_code, msg, date, lm, etag, + (int) mime_vec.len, mime_vec.ptr, conn->cl, + suggest_connection_header(&conn->mg_conn), + range, MONGOOSE_USE_EXTRA_HTTP_HEADERS); + ns_send(conn->ns_conn, headers, n); + + if (!strcmp(conn->mg_conn.request_method, "HEAD")) { + conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; + close(conn->endpoint.fd); + conn->endpoint_type = EP_NONE; + } } void mg_send_file_data(struct mg_connection *c, int fd) { - struct connection *conn = MG_CONN_2_CONN(c); - conn->endpoint_type = EP_FILE; - conn->endpoint.fd = fd; - ns_set_close_on_exec(conn->endpoint.fd); + struct connection *conn = MG_CONN_2_CONN(c); + conn->endpoint_type = EP_FILE; + conn->endpoint.fd = fd; + ns_set_close_on_exec(conn->endpoint.fd); } #endif // MONGOOSE_NO_FILESYSTEM static void call_request_handler_if_data_is_buffered(struct connection *conn) { #ifndef MONGOOSE_NO_WEBSOCKET - if (conn->mg_conn.is_websocket) { - do { } while (deliver_websocket_frame(conn)); - } else + if (conn->mg_conn.is_websocket) { + do { } while (deliver_websocket_frame(conn)); + } else #endif - if (conn->num_bytes_recv >= (conn->cl + conn->request_len) && - call_request_handler(conn) == MG_FALSE) { - open_local_endpoint(conn, 1); - } + if (conn->num_bytes_recv >= (conn->cl + conn->request_len) && + call_request_handler(conn) == MG_FALSE) { + open_local_endpoint(conn, 1); + } } #if !defined(MONGOOSE_NO_DIRECTORY_LISTING) || !defined(MONGOOSE_NO_DAV) #ifdef _WIN32 struct dirent { - char d_name[MAX_PATH_SIZE]; + char d_name[MAX_PATH_SIZE]; }; typedef struct DIR { - HANDLE handle; - WIN32_FIND_DATAW info; - struct dirent result; + HANDLE handle; + WIN32_FIND_DATAW info; + struct dirent result; } DIR; // Implementation of POSIX opendir/closedir/readdir for Windows. static DIR *opendir(const char *name) { - DIR *dir = NULL; - wchar_t wpath[MAX_PATH_SIZE]; - DWORD attrs; - - if (name == NULL) { - SetLastError(ERROR_BAD_ARGUMENTS); - } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } else { - to_wchar(name, wpath, ARRAY_SIZE(wpath)); - attrs = GetFileAttributesW(wpath); - if (attrs != 0xFFFFFFFF && - ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) { - (void) wcscat(wpath, L"\\*"); - dir->handle = FindFirstFileW(wpath, &dir->info); - dir->result.d_name[0] = '\0'; - } else { - free(dir); - dir = NULL; - } - } - - return dir; + DIR *dir = NULL; + wchar_t wpath[MAX_PATH_SIZE]; + DWORD attrs; + + if (name == NULL) { + SetLastError(ERROR_BAD_ARGUMENTS); + } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + } else { + to_wchar(name, wpath, ARRAY_SIZE(wpath)); + attrs = GetFileAttributesW(wpath); + if (attrs != 0xFFFFFFFF && + ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) { + (void) wcscat(wpath, L"\\*"); + dir->handle = FindFirstFileW(wpath, &dir->info); + dir->result.d_name[0] = '\0'; + } else { + free(dir); + dir = NULL; + } + } + + return dir; } static int closedir(DIR *dir) { - int result = 0; + int result = 0; - if (dir != NULL) { - if (dir->handle != INVALID_HANDLE_VALUE) - result = FindClose(dir->handle) ? 0 : -1; + if (dir != NULL) { + if (dir->handle != INVALID_HANDLE_VALUE) + result = FindClose(dir->handle) ? 0 : -1; - free(dir); - } else { - result = -1; - SetLastError(ERROR_BAD_ARGUMENTS); - } + free(dir); + } else { + result = -1; + SetLastError(ERROR_BAD_ARGUMENTS); + } - return result; + return result; } static struct dirent *readdir(DIR *dir) { - struct dirent *result = 0; + struct dirent *result = 0; - if (dir) { - if (dir->handle != INVALID_HANDLE_VALUE) { - result = &dir->result; - (void) WideCharToMultiByte(CP_UTF8, 0, - dir->info.cFileName, -1, result->d_name, - sizeof(result->d_name), NULL, NULL); + if (dir) { + if (dir->handle != INVALID_HANDLE_VALUE) { + result = &dir->result; + (void) WideCharToMultiByte(CP_UTF8, 0, + dir->info.cFileName, -1, result->d_name, + sizeof(result->d_name), NULL, NULL); - if (!FindNextFileW(dir->handle, &dir->info)) { - (void) FindClose(dir->handle); - dir->handle = INVALID_HANDLE_VALUE; - } + if (!FindNextFileW(dir->handle, &dir->info)) { + (void) FindClose(dir->handle); + dir->handle = INVALID_HANDLE_VALUE; + } - } else { - SetLastError(ERROR_FILE_NOT_FOUND); - } - } else { - SetLastError(ERROR_BAD_ARGUMENTS); - } + } else { + SetLastError(ERROR_FILE_NOT_FOUND); + } + } else { + SetLastError(ERROR_BAD_ARGUMENTS); + } - return result; + return result; } #endif // _WIN32 POSIX opendir/closedir/readdir implementation static int scan_directory(struct connection *conn, const char *dir, - struct dir_entry **arr) { - char path[MAX_PATH_SIZE]; - struct dir_entry *p; - struct dirent *dp; - int arr_size = 0, arr_ind = 0, inc = 100; - DIR *dirp; - - *arr = NULL; - if ((dirp = (opendir(dir))) == NULL) return 0; - - while ((dp = readdir(dirp)) != NULL) { - // Do not show current dir and hidden files - if (!strcmp(dp->d_name, ".") || - !strcmp(dp->d_name, "..") || - must_hide_file(conn, dp->d_name)) { - continue; - } - mg_snprintf(path, sizeof(path), "%s%c%s", dir, '/', dp->d_name); - - // Resize the array if nesessary - if (arr_ind >= arr_size) { - if ((p = (struct dir_entry *) - realloc(*arr, (inc + arr_size) * sizeof(**arr))) != NULL) { - // Memset new chunk to zero, otherwize st_mtime will have garbage which - // can make strftime() segfault, see - // http://code.google.com/p/mongoose/issues/detail?id=79 - memset(p + arr_size, 0, sizeof(**arr) * inc); - - *arr = p; - arr_size += inc; - } - } - - if (arr_ind < arr_size) { - (*arr)[arr_ind].conn = conn; - (*arr)[arr_ind].file_name = strdup(dp->d_name); - stat(path, &(*arr)[arr_ind].st); - arr_ind++; - } - } - closedir(dirp); - - return arr_ind; + struct dir_entry **arr) { + char path[MAX_PATH_SIZE]; + struct dir_entry *p; + struct dirent *dp; + int arr_size = 0, arr_ind = 0, inc = 100; + DIR *dirp; + + *arr = NULL; + if ((dirp = (opendir(dir))) == NULL) return 0; + + while ((dp = readdir(dirp)) != NULL) { + // Do not show current dir and hidden files + if (!strcmp(dp->d_name, ".") || + !strcmp(dp->d_name, "..") || + must_hide_file(conn, dp->d_name)) { + continue; + } + mg_snprintf(path, sizeof(path), "%s%c%s", dir, '/', dp->d_name); + + // Resize the array if nesessary + if (arr_ind >= arr_size) { + if ((p = (struct dir_entry *) + realloc(*arr, (inc + arr_size) * sizeof(**arr))) != NULL) { + // Memset new chunk to zero, otherwize st_mtime will have garbage which + // can make strftime() segfault, see + // http://code.google.com/p/mongoose/issues/detail?id=79 + memset(p + arr_size, 0, sizeof(**arr) * inc); + + *arr = p; + arr_size += inc; + } + } + + if (arr_ind < arr_size) { + (*arr)[arr_ind].conn = conn; + (*arr)[arr_ind].file_name = strdup(dp->d_name); + stat(path, &(*arr)[arr_ind].st); + arr_ind++; + } + } + closedir(dirp); + + return arr_ind; } int mg_url_encode(const char *src, size_t s_len, char *dst, size_t dst_len) { - static const char *dont_escape = "._-$,;~()"; - static const char *hex = "0123456789abcdef"; - size_t i = 0, j = 0; - - for (i = j = 0; dst_len > 0 && i < s_len && j + 2 < dst_len - 1; i++, j++) { - if (isalnum(* (const unsigned char *) (src + i)) || - strchr(dont_escape, * (const unsigned char *) (src + i)) != NULL) { - dst[j] = src[i]; - } else if (j + 3 < dst_len) { - dst[j] = '%'; - dst[j + 1] = hex[(* (const unsigned char *) (src + i)) >> 4]; - dst[j + 2] = hex[(* (const unsigned char *) (src + i)) & 0xf]; - j += 2; - } - } - - dst[j] = '\0'; - return j; + static const char *dont_escape = "._-$,;~()"; + static const char *hex = "0123456789abcdef"; + size_t i = 0, j = 0; + + for (i = j = 0; dst_len > 0 && i < s_len && j + 2 < dst_len - 1; i++, j++) { + if (isalnum(* (const unsigned char *) (src + i)) || + strchr(dont_escape, * (const unsigned char *) (src + i)) != NULL) { + dst[j] = src[i]; + } else if (j + 3 < dst_len) { + dst[j] = '%'; + dst[j + 1] = hex[(* (const unsigned char *) (src + i)) >> 4]; + dst[j + 2] = hex[(* (const unsigned char *) (src + i)) & 0xf]; + j += 2; + } + } + + dst[j] = '\0'; + return j; } #endif // !NO_DIRECTORY_LISTING || !MONGOOSE_NO_DAV #ifndef MONGOOSE_NO_DIRECTORY_LISTING static void print_dir_entry(const struct dir_entry *de) { - char size[64], mod[64], href[MAX_PATH_SIZE * 3]; - int64_t fsize = de->st.st_size; - int is_dir = S_ISDIR(de->st.st_mode); - const char *slash = is_dir ? "/" : ""; - - if (is_dir) { - mg_snprintf(size, sizeof(size), "%s", "[DIRECTORY]"); - } else { - // We use (signed) cast below because MSVC 6 compiler cannot - // convert unsigned __int64 to double. - if (fsize < 1024) { - mg_snprintf(size, sizeof(size), "%d", (int) fsize); - } else if (fsize < 0x100000) { - mg_snprintf(size, sizeof(size), "%.1fk", (double) fsize / 1024.0); - } else if (fsize < 0x40000000) { - mg_snprintf(size, sizeof(size), "%.1fM", (double) fsize / 1048576); - } else { - mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824); - } - } - strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&de->st.st_mtime)); - mg_url_encode(de->file_name, strlen(de->file_name), href, sizeof(href)); - mg_printf_data(&de->conn->mg_conn, - "%s%s" - " %s  %s\n", - href, slash, de->file_name, slash, mod, size); + char size[64], mod[64], href[MAX_PATH_SIZE * 3]; + int64_t fsize = de->st.st_size; + int is_dir = S_ISDIR(de->st.st_mode); + const char *slash = is_dir ? "/" : ""; + + if (is_dir) { + mg_snprintf(size, sizeof(size), "%s", "[DIRECTORY]"); + } else { + // We use (signed) cast below because MSVC 6 compiler cannot + // convert unsigned __int64 to double. + if (fsize < 1024) { + mg_snprintf(size, sizeof(size), "%d", (int) fsize); + } else if (fsize < 0x100000) { + mg_snprintf(size, sizeof(size), "%.1fk", (double) fsize / 1024.0); + } else if (fsize < 0x40000000) { + mg_snprintf(size, sizeof(size), "%.1fM", (double) fsize / 1048576); + } else { + mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824); + } + } + strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&de->st.st_mtime)); + mg_url_encode(de->file_name, strlen(de->file_name), href, sizeof(href)); + mg_printf_data(&de->conn->mg_conn, + "%s%s" + " %s  %s\n", + href, slash, de->file_name, slash, mod, size); } // Sort directory entries by size, or name, or modification time. // On windows, __cdecl specification is needed in case if project is built // with __stdcall convention. qsort always requires __cdels callback. static int __cdecl compare_dir_entries(const void *p1, const void *p2) { - const struct dir_entry *a = (const struct dir_entry *) p1, - *b = (const struct dir_entry *) p2; - const char *qs = a->conn->mg_conn.query_string ? - a->conn->mg_conn.query_string : "na"; - int cmp_result = 0; - - if (S_ISDIR(a->st.st_mode) && !S_ISDIR(b->st.st_mode)) { - return -1; // Always put directories on top - } else if (!S_ISDIR(a->st.st_mode) && S_ISDIR(b->st.st_mode)) { - return 1; // Always put directories on top - } else if (*qs == 'n') { - cmp_result = strcmp(a->file_name, b->file_name); - } else if (*qs == 's') { - cmp_result = a->st.st_size == b->st.st_size ? 0 : - a->st.st_size > b->st.st_size ? 1 : -1; - } else if (*qs == 'd') { - cmp_result = a->st.st_mtime == b->st.st_mtime ? 0 : - a->st.st_mtime > b->st.st_mtime ? 1 : -1; - } - - return qs[1] == 'd' ? -cmp_result : cmp_result; + const struct dir_entry *a = (const struct dir_entry *) p1, + *b = (const struct dir_entry *) p2; + const char *qs = a->conn->mg_conn.query_string ? + a->conn->mg_conn.query_string : "na"; + int cmp_result = 0; + + if (S_ISDIR(a->st.st_mode) && !S_ISDIR(b->st.st_mode)) { + return -1; // Always put directories on top + } else if (!S_ISDIR(a->st.st_mode) && S_ISDIR(b->st.st_mode)) { + return 1; // Always put directories on top + } else if (*qs == 'n') { + cmp_result = strcmp(a->file_name, b->file_name); + } else if (*qs == 's') { + cmp_result = a->st.st_size == b->st.st_size ? 0 : + a->st.st_size > b->st.st_size ? 1 : -1; + } else if (*qs == 'd') { + cmp_result = a->st.st_mtime == b->st.st_mtime ? 0 : + a->st.st_mtime > b->st.st_mtime ? 1 : -1; + } + + return qs[1] == 'd' ? -cmp_result : cmp_result; } static void send_directory_listing(struct connection *conn, const char *dir) { - struct dir_entry *arr = NULL; - int i, num_entries, sort_direction = conn->mg_conn.query_string != NULL && - conn->mg_conn.query_string[1] == 'd' ? 'a' : 'd'; - - mg_send_header(&conn->mg_conn, "Transfer-Encoding", "chunked"); - mg_send_header(&conn->mg_conn, "Content-Type", "text/html; charset=utf-8"); - - mg_printf_data(&conn->mg_conn, - "Index of %s" - "" - "

Index of %s

"
-              ""
-              ""
-              ""
-              "",
-              conn->mg_conn.uri, conn->mg_conn.uri,
-              sort_direction, sort_direction, sort_direction);
-
-  num_entries = scan_directory(conn, dir, &arr);
-  qsort(arr, num_entries, sizeof(arr[0]), compare_dir_entries);
-  for (i = 0; i < num_entries; i++) {
-    print_dir_entry(&arr[i]);
-    free(arr[i].file_name);
-  }
-  free(arr);
-
-  write_terminating_chunk(conn);
-  close_local_endpoint(conn);
+	struct dir_entry *arr = NULL;
+	int i, num_entries, sort_direction = conn->mg_conn.query_string != NULL &&
+	conn->mg_conn.query_string[1] == 'd' ? 'a' : 'd';
+
+	mg_send_header(&conn->mg_conn, "Transfer-Encoding", "chunked");
+	mg_send_header(&conn->mg_conn, "Content-Type", "text/html; charset=utf-8");
+
+	mg_printf_data(&conn->mg_conn,
+				"Index of %s"
+				""
+				"

Index of %s

NameModifiedSize

" + "" + "" + "" + "", + conn->mg_conn.uri, conn->mg_conn.uri, + sort_direction, sort_direction, sort_direction); + + num_entries = scan_directory(conn, dir, &arr); + qsort(arr, num_entries, sizeof(arr[0]), compare_dir_entries); + for (i = 0; i < num_entries; i++) { + print_dir_entry(&arr[i]); + free(arr[i].file_name); + } + free(arr); + + write_terminating_chunk(conn); + close_local_endpoint(conn); } #endif // MONGOOSE_NO_DIRECTORY_LISTING #ifndef MONGOOSE_NO_DAV static void print_props(struct connection *conn, const char *uri, - file_stat_t *stp) { - char mtime[64]; - - gmt_time_string(mtime, sizeof(mtime), &stp->st_mtime); - mg_printf(&conn->mg_conn, - "" - "%s" - "" - "" - "%s" - "%" INT64_FMT "" - "%s" - "" - "HTTP/1.1 200 OK" - "" - "\n", - uri, S_ISDIR(stp->st_mode) ? "" : "", - (int64_t) stp->st_size, mtime); + file_stat_t *stp) { + char mtime[64]; + + gmt_time_string(mtime, sizeof(mtime), &stp->st_mtime); + mg_printf(&conn->mg_conn, + "" + "%s" + "" + "" + "%s" + "%" INT64_FMT "" + "%s" + "" + "HTTP/1.1 200 OK" + "" + "\n", + uri, S_ISDIR(stp->st_mode) ? "" : "", + (int64_t) stp->st_size, mtime); } static void handle_propfind(struct connection *conn, const char *path, - file_stat_t *stp, int exists) { - static const char header[] = "HTTP/1.1 207 Multi-Status\r\n" - "Connection: close\r\n" - "Content-Type: text/xml; charset=utf-8\r\n\r\n" - "" - "\n"; - static const char footer[] = ""; - const char *depth = mg_get_header(&conn->mg_conn, "Depth"), - *list_dir = conn->server->config_options[ENABLE_DIRECTORY_LISTING]; - - conn->mg_conn.status_code = 207; - - // Print properties for the requested resource itself - if (!exists) { - conn->mg_conn.status_code = 404; - mg_printf(&conn->mg_conn, "%s", "HTTP/1.1 404 Not Found\r\n\r\n"); - } else if (S_ISDIR(stp->st_mode) && mg_strcasecmp(list_dir, "yes") != 0) { - conn->mg_conn.status_code = 403; - mg_printf(&conn->mg_conn, "%s", - "HTTP/1.1 403 Directory Listing Denied\r\n\r\n"); - } else { - ns_send(conn->ns_conn, header, sizeof(header) - 1); - print_props(conn, conn->mg_conn.uri, stp); - - if (S_ISDIR(stp->st_mode) && - (depth == NULL || strcmp(depth, "0") != 0)) { - struct dir_entry *arr = NULL; - int i, num_entries = scan_directory(conn, path, &arr); - - for (i = 0; i < num_entries; i++) { - char buf[MAX_PATH_SIZE * 3]; - struct dir_entry *de = &arr[i]; - mg_url_encode(de->file_name, strlen(de->file_name), buf, sizeof(buf)); - print_props(conn, buf, &de->st); - free(de->file_name); - } - free(arr); - } - ns_send(conn->ns_conn, footer, sizeof(footer) - 1); - } - - close_local_endpoint(conn); + file_stat_t *stp, int exists) { + static const char header[] = "HTTP/1.1 207 Multi-Status\r\n" + "Connection: close\r\n" + "Content-Type: text/xml; charset=utf-8\r\n\r\n" + "" + "\n"; + static const char footer[] = ""; + const char *depth = mg_get_header(&conn->mg_conn, "Depth"), + *list_dir = conn->server->config_options[ENABLE_DIRECTORY_LISTING]; + + conn->mg_conn.status_code = 207; + + // Print properties for the requested resource itself + if (!exists) { + conn->mg_conn.status_code = 404; + mg_printf(&conn->mg_conn, "%s", "HTTP/1.1 404 Not Found\r\n\r\n"); + } else if (S_ISDIR(stp->st_mode) && mg_strcasecmp(list_dir, "yes") != 0) { + conn->mg_conn.status_code = 403; + mg_printf(&conn->mg_conn, "%s", + "HTTP/1.1 403 Directory Listing Denied\r\n\r\n"); + } else { + ns_send(conn->ns_conn, header, sizeof(header) - 1); + print_props(conn, conn->mg_conn.uri, stp); + + if (S_ISDIR(stp->st_mode) && + (depth == NULL || strcmp(depth, "0") != 0)) { + struct dir_entry *arr = NULL; + int i, num_entries = scan_directory(conn, path, &arr); + + for (i = 0; i < num_entries; i++) { + char buf[MAX_PATH_SIZE * 3]; + struct dir_entry *de = &arr[i]; + mg_url_encode(de->file_name, strlen(de->file_name), buf, sizeof(buf)); + print_props(conn, buf, &de->st); + free(de->file_name); + } + free(arr); + } + ns_send(conn->ns_conn, footer, sizeof(footer) - 1); + } + + close_local_endpoint(conn); } static void handle_mkcol(struct connection *conn, const char *path) { - int status_code = 500; - - if (conn->mg_conn.content_len > 0) { - status_code = 415; - } else if (!mkdir(path, 0755)) { - status_code = 201; - } else if (errno == EEXIST) { - status_code = 405; - } else if (errno == EACCES) { - status_code = 403; - } else if (errno == ENOENT) { - status_code = 409; - } - send_http_error(conn, status_code, NULL); + int status_code = 500; + + if (conn->mg_conn.content_len > 0) { + status_code = 415; + } else if (!mkdir(path, 0755)) { + status_code = 201; + } else if (errno == EEXIST) { + status_code = 405; + } else if (errno == EACCES) { + status_code = 403; + } else if (errno == ENOENT) { + status_code = 409; + } + send_http_error(conn, status_code, NULL); } static int remove_directory(const char *dir) { - char path[MAX_PATH_SIZE]; - struct dirent *dp; - file_stat_t st; - DIR *dirp; + char path[MAX_PATH_SIZE]; + struct dirent *dp; + file_stat_t st; + DIR *dirp; - if ((dirp = opendir(dir)) == NULL) return 0; + if ((dirp = opendir(dir)) == NULL) return 0; - while ((dp = readdir(dirp)) != NULL) { - if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue; - mg_snprintf(path, sizeof(path), "%s%c%s", dir, '/', dp->d_name); - stat(path, &st); - if (S_ISDIR(st.st_mode)) { - remove_directory(path); - } else { - remove(path); - } - } - closedir(dirp); - rmdir(dir); + while ((dp = readdir(dirp)) != NULL) { + if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue; + mg_snprintf(path, sizeof(path), "%s%c%s", dir, '/', dp->d_name); + stat(path, &st); + if (S_ISDIR(st.st_mode)) { + remove_directory(path); + } else { + remove(path); + } + } + closedir(dirp); + rmdir(dir); - return 1; + return 1; } static void handle_delete(struct connection *conn, const char *path) { - file_stat_t st; + file_stat_t st; - if (stat(path, &st) != 0) { - send_http_error(conn, 404, NULL); - } else if (S_ISDIR(st.st_mode)) { - remove_directory(path); - send_http_error(conn, 204, NULL); - } else if (remove(path) == 0) { - send_http_error(conn, 204, NULL); - } else { - send_http_error(conn, 423, NULL); - } + if (stat(path, &st) != 0) { + send_http_error(conn, 404, NULL); + } else if (S_ISDIR(st.st_mode)) { + remove_directory(path); + send_http_error(conn, 204, NULL); + } else if (remove(path) == 0) { + send_http_error(conn, 204, NULL); + } else { + send_http_error(conn, 423, NULL); + } } // For a given PUT path, create all intermediate subdirectories // for given path. Return 0 if the path itself is a directory, // or -1 on error, 1 if OK. static int put_dir(const char *path) { - char buf[MAX_PATH_SIZE]; - const char *s, *p; - file_stat_t st; + char buf[MAX_PATH_SIZE]; + const char *s, *p; + file_stat_t st; - // Create intermediate directories if they do not exist - for (s = p = path + 1; (p = strchr(s, '/')) != NULL; s = ++p) { - if (p - path >= (int) sizeof(buf)) return -1; // Buffer overflow - memcpy(buf, path, p - path); - buf[p - path] = '\0'; - if (stat(buf, &st) != 0 && mkdir(buf, 0755) != 0) return -1; - if (p[1] == '\0') return 0; // Path is a directory itself - } + // Create intermediate directories if they do not exist + for (s = p = path + 1; (p = strchr(s, '/')) != NULL; s = ++p) { + if (p - path >= (int) sizeof(buf)) return -1; // Buffer overflow + memcpy(buf, path, p - path); + buf[p - path] = '\0'; + if (stat(buf, &st) != 0 && mkdir(buf, 0755) != 0) return -1; + if (p[1] == '\0') return 0; // Path is a directory itself + } - return 1; + return 1; } static void handle_put(struct connection *conn, const char *path) { - file_stat_t st; - const char *range, *cl_hdr = mg_get_header(&conn->mg_conn, "Content-Length"); - int64_t r1, r2; - int rc; - - conn->mg_conn.status_code = !stat(path, &st) ? 200 : 201; - if ((rc = put_dir(path)) == 0) { - mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\n\r\n", - conn->mg_conn.status_code); - close_local_endpoint(conn); - } else if (rc == -1) { - send_http_error(conn, 500, "put_dir: %s", strerror(errno)); - } else if (cl_hdr == NULL) { - send_http_error(conn, 411, NULL); + file_stat_t st; + const char *range, *cl_hdr = mg_get_header(&conn->mg_conn, "Content-Length"); + int64_t r1, r2; + int rc; + + conn->mg_conn.status_code = !stat(path, &st) ? 200 : 201; + if ((rc = put_dir(path)) == 0) { + mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\n\r\n", + conn->mg_conn.status_code); + close_local_endpoint(conn); + } else if (rc == -1) { + send_http_error(conn, 500, "put_dir: %s", strerror(errno)); + } else if (cl_hdr == NULL) { + send_http_error(conn, 411, NULL); #ifdef _WIN32 - //On Windows, open() is a macro with 2 params - } else if ((conn->endpoint.fd = - open(path, O_RDWR | O_CREAT | O_TRUNC)) < 0) { + //On Windows, open() is a macro with 2 params + } else if ((conn->endpoint.fd = + open(path, O_RDWR | O_CREAT | O_TRUNC)) < 0) { #else - } else if ((conn->endpoint.fd = - open(path, O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0) { + } else if ((conn->endpoint.fd = + open(path, O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0) { #endif - send_http_error(conn, 500, "open(%s): %s", path, strerror(errno)); - } else { - DBG(("PUT [%s] %lu", path, (unsigned long) conn->ns_conn->recv_iobuf.len)); - conn->endpoint_type = EP_PUT; - ns_set_close_on_exec(conn->endpoint.fd); - range = mg_get_header(&conn->mg_conn, "Content-Range"); - conn->cl = to64(cl_hdr); - r1 = r2 = 0; - if (range != NULL && parse_range_header(range, &r1, &r2) > 0) { - conn->mg_conn.status_code = 206; - lseek(conn->endpoint.fd, r1, SEEK_SET); - conn->cl = r2 > r1 ? r2 - r1 + 1: conn->cl - r1; - } - mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n", - conn->mg_conn.status_code); - } + send_http_error(conn, 500, "open(%s): %s", path, strerror(errno)); + } else { + DBG(("PUT [%s] %lu", path, (unsigned long) conn->ns_conn->recv_iobuf.len)); + conn->endpoint_type = EP_PUT; + ns_set_close_on_exec(conn->endpoint.fd); + range = mg_get_header(&conn->mg_conn, "Content-Range"); + conn->cl = to64(cl_hdr); + r1 = r2 = 0; + if (range != NULL && parse_range_header(range, &r1, &r2) > 0) { + conn->mg_conn.status_code = 206; + lseek(conn->endpoint.fd, r1, SEEK_SET); + conn->cl = r2 > r1 ? r2 - r1 + 1: conn->cl - r1; + } + mg_printf(&conn->mg_conn, "HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n", + conn->mg_conn.status_code); + } } static void forward_put_data(struct connection *conn) { - struct iobuf *io = &conn->ns_conn->recv_iobuf; - size_t k = conn->cl < (int64_t) io->len ? conn->cl : (int64_t) io->len; // To write - int n = write(conn->endpoint.fd, io->buf, k); // Write them! - if (n > 0) { - iobuf_remove(io, n); - conn->cl -= n; - } - if (conn->cl <= 0) { - close_local_endpoint(conn); - } + struct iobuf *io = &conn->ns_conn->recv_iobuf; + size_t k = conn->cl < (int64_t) io->len ? conn->cl : (int64_t) io->len; // To write + int n = write(conn->endpoint.fd, io->buf, k); // Write them! + if (n > 0) { + iobuf_remove(io, n); + conn->cl -= n; + } + if (conn->cl <= 0) { + close_local_endpoint(conn); + } } #endif // MONGOOSE_NO_DAV static void send_options(struct connection *conn) { - conn->mg_conn.status_code = 200; - mg_printf(&conn->mg_conn, "%s", - "HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, PUT, " - "DELETE, OPTIONS, PROPFIND, MKCOL\r\nDAV: 1\r\n\r\n"); - close_local_endpoint(conn); + conn->mg_conn.status_code = 200; + mg_printf(&conn->mg_conn, "%s", + "HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, PUT, " + "DELETE, OPTIONS, PROPFIND, MKCOL\r\nDAV: 1\r\n\r\n"); + close_local_endpoint(conn); } #ifndef MONGOOSE_NO_AUTH void mg_send_digest_auth_request(struct mg_connection *c) { - struct connection *conn = MG_CONN_2_CONN(c); - c->status_code = 401; - mg_printf(c, - "HTTP/1.1 401 Unauthorized\r\n" - "WWW-Authenticate: Digest qop=\"auth\", " - "realm=\"%s\", nonce=\"%lu\"\r\n\r\n", - conn->server->config_options[AUTH_DOMAIN], - (unsigned long) time(NULL)); - close_local_endpoint(conn); + struct connection *conn = MG_CONN_2_CONN(c); + c->status_code = 401; + mg_printf(c, + "HTTP/1.1 401 Unauthorized\r\n" + "WWW-Authenticate: Digest qop=\"auth\", " + "realm=\"%s\", nonce=\"%lu\"\r\n\r\n", + conn->server->config_options[AUTH_DOMAIN], + (unsigned long) time(NULL)); + close_local_endpoint(conn); } // Use the global passwords file, if specified by auth_gpass option, // or search for .htpasswd in the requested directory. static FILE *open_auth_file(struct connection *conn, const char *path, - int is_directory) { - char name[MAX_PATH_SIZE]; - const char *p, *gpass = conn->server->config_options[GLOBAL_AUTH_FILE]; - FILE *fp = NULL; - - if (gpass != NULL) { - // Use global passwords file - fp = fopen(gpass, "r"); - } else if (is_directory) { - mg_snprintf(name, sizeof(name), "%s%c%s", path, '/', PASSWORDS_FILE_NAME); - fp = fopen(name, "r"); - } else { - // Try to find .htpasswd in requested directory. - if ((p = strrchr(path, '/')) == NULL) p = path; - mg_snprintf(name, sizeof(name), "%.*s%c%s", - (int) (p - path), path, '/', PASSWORDS_FILE_NAME); - fp = fopen(name, "r"); - } - - return fp; + int is_directory) { + char name[MAX_PATH_SIZE]; + const char *p, *gpass = conn->server->config_options[GLOBAL_AUTH_FILE]; + FILE *fp = NULL; + + if (gpass != NULL) { + // Use global passwords file + fp = fopen(gpass, "r"); + } else if (is_directory) { + mg_snprintf(name, sizeof(name), "%s%c%s", path, '/', PASSWORDS_FILE_NAME); + fp = fopen(name, "r"); + } else { + // Try to find .htpasswd in requested directory. + if ((p = strrchr(path, '/')) == NULL) p = path; + mg_snprintf(name, sizeof(name), "%.*s%c%s", + (int) (p - path), path, '/', PASSWORDS_FILE_NAME); + fp = fopen(name, "r"); + } + + return fp; } #if !defined(HAVE_MD5) && !defined(MONGOOSE_NO_AUTH) typedef struct MD5Context { - uint32_t buf[4]; - uint32_t bits[2]; - unsigned char in[64]; + uint32_t buf[4]; + uint32_t bits[2]; + unsigned char in[64]; } MD5_CTX; static void byteReverse(unsigned char *buf, unsigned longs) { - uint32_t t; + uint32_t t; - // Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN - if (is_big_endian()) { - do { - t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - * (uint32_t *) buf = t; - buf += 4; - } while (--longs); - } + // Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN + if (is_big_endian()) { + do { + t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + * (uint32_t *) buf = t; + buf += 4; + } while (--longs); + } } #define F1(x, y, z) (z ^ (x & (y ^ z))) @@ -3648,166 +3646,166 @@ static void byteReverse(unsigned char *buf, unsigned longs) { #define F4(x, y, z) (y ^ (x | ~z)) #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) + ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) // Start MD5 accumulation. Set bit count to 0 and buffer to mysterious // initialization constants. static void MD5Init(MD5_CTX *ctx) { - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - ctx->bits[0] = 0; - ctx->bits[1] = 0; + ctx->bits[0] = 0; + ctx->bits[1] = 0; } static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) { - register uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + register uint32_t a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } static void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len) { - uint32_t t; + uint32_t t; - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; - ctx->bits[1] += len >> 29; + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) + ctx->bits[1]++; + ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; + t = (t >> 3) & 0x3f; - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; + if (t) { + unsigned char *p = (unsigned char *) ctx->in + t; - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += t; - len -= t; - } + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + buf += t; + len -= t; + } - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += 64; - len -= 64; - } + while (len >= 64) { + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + buf += 64; + len -= 64; + } - memcpy(ctx->in, buf, len); + memcpy(ctx->in, buf, len); } static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) { - unsigned count; - unsigned char *p; - uint32_t *a; - - count = (ctx->bits[0] >> 3) & 0x3F; - - p = ctx->in + count; - *p++ = 0x80; - count = 64 - 1 - count; - if (count < 8) { - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - memset(ctx->in, 0, 56); - } else { - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - a = (uint32_t *)ctx->in; - a[14] = ctx->bits[0]; - a[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset((char *) ctx, 0, sizeof(*ctx)); + unsigned count; + unsigned char *p; + uint32_t *a; + + count = (ctx->bits[0] >> 3) & 0x3F; + + p = ctx->in + count; + *p++ = 0x80; + count = 64 - 1 - count; + if (count < 8) { + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + memset(ctx->in, 0, 56); + } else { + memset(p, 0, count - 8); + } + byteReverse(ctx->in, 14); + + a = (uint32_t *)ctx->in; + a[14] = ctx->bits[0]; + a[15] = ctx->bits[1]; + + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + byteReverse((unsigned char *) ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset((char *) ctx, 0, sizeof(*ctx)); } #endif // !HAVE_MD5 @@ -3816,1340 +3814,1339 @@ static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) { // Stringify binary data. Output buffer must be twice as big as input, // because each byte takes 2 bytes in string representation static void bin2str(char *to, const unsigned char *p, size_t len) { - static const char *hex = "0123456789abcdef"; + static const char *hex = "0123456789abcdef"; - for (; len--; p++) { - *to++ = hex[p[0] >> 4]; - *to++ = hex[p[0] & 0x0f]; - } - *to = '\0'; + for (; len--; p++) { + *to++ = hex[p[0] >> 4]; + *to++ = hex[p[0] & 0x0f]; + } + *to = '\0'; } // Return stringified MD5 hash for list of strings. Buffer must be 33 bytes. char *mg_md5(char buf[33], ...) { - unsigned char hash[16]; - const char *p; - va_list ap; - MD5_CTX ctx; + unsigned char hash[16]; + const char *p; + va_list ap; + MD5_CTX ctx; - MD5Init(&ctx); + MD5Init(&ctx); - va_start(ap, buf); - while ((p = va_arg(ap, const char *)) != NULL) { - MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p)); - } - va_end(ap); + va_start(ap, buf); + while ((p = va_arg(ap, const char *)) != NULL) { + MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p)); + } + va_end(ap); - MD5Final(hash, &ctx); - bin2str(buf, hash, sizeof(hash)); - return buf; + MD5Final(hash, &ctx); + bin2str(buf, hash, sizeof(hash)); + return buf; } // Check the user's password, return 1 if OK static int check_password(const char *method, const char *ha1, const char *uri, - const char *nonce, const char *nc, const char *cnonce, - const char *qop, const char *response) { - char ha2[32 + 1], expected_response[32 + 1]; + const char *nonce, const char *nc, const char *cnonce, + const char *qop, const char *response) { + char ha2[32 + 1], expected_response[32 + 1]; #if 0 - // Check for authentication timeout - if ((unsigned long) time(NULL) - (unsigned long) to64(nonce) > 3600 * 2) { - return 0; - } + // Check for authentication timeout + if ((unsigned long) time(NULL) - (unsigned long) to64(nonce) > 3600 * 2) { + return 0; + } #endif - mg_md5(ha2, method, ":", uri, NULL); - mg_md5(expected_response, ha1, ":", nonce, ":", nc, - ":", cnonce, ":", qop, ":", ha2, NULL); + mg_md5(ha2, method, ":", uri, NULL); + mg_md5(expected_response, ha1, ":", nonce, ":", nc, + ":", cnonce, ":", qop, ":", ha2, NULL); - return mg_strcasecmp(response, expected_response) == 0 ? MG_TRUE : MG_FALSE; + return mg_strcasecmp(response, expected_response) == 0 ? MG_TRUE : MG_FALSE; } // Authorize against the opened passwords file. Return 1 if authorized. int mg_authorize_digest(struct mg_connection *c, FILE *fp) { - struct connection *conn = MG_CONN_2_CONN(c); - const char *hdr; - char line[256], f_user[256], ha1[256], f_domain[256], user[100], nonce[100], - uri[MAX_REQUEST_SIZE], cnonce[100], resp[100], qop[100], nc[100]; - - if (c == NULL || fp == NULL) return 0; - if ((hdr = mg_get_header(c, "Authorization")) == NULL || - mg_strncasecmp(hdr, "Digest ", 7) != 0) return 0; - if (!mg_parse_header(hdr, "username", user, sizeof(user))) return 0; - if (!mg_parse_header(hdr, "cnonce", cnonce, sizeof(cnonce))) return 0; - if (!mg_parse_header(hdr, "response", resp, sizeof(resp))) return 0; - if (!mg_parse_header(hdr, "uri", uri, sizeof(uri))) return 0; - if (!mg_parse_header(hdr, "qop", qop, sizeof(qop))) return 0; - if (!mg_parse_header(hdr, "nc", nc, sizeof(nc))) return 0; - if (!mg_parse_header(hdr, "nonce", nonce, sizeof(nonce))) return 0; - - while (fgets(line, sizeof(line), fp) != NULL) { - if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) == 3 && - !strcmp(user, f_user) && - // NOTE(lsm): due to a bug in MSIE, we do not compare URIs - !strcmp(conn->server->config_options[AUTH_DOMAIN], f_domain)) - return check_password(c->request_method, ha1, uri, - nonce, nc, cnonce, qop, resp); - } - return MG_FALSE; + struct connection *conn = MG_CONN_2_CONN(c); + const char *hdr; + char line[256], f_user[256], ha1[256], f_domain[256], user[100], nonce[100], + uri[MAX_REQUEST_SIZE], cnonce[100], resp[100], qop[100], nc[100]; + + if (c == NULL || fp == NULL) return 0; + if ((hdr = mg_get_header(c, "Authorization")) == NULL || + mg_strncasecmp(hdr, "Digest ", 7) != 0) return 0; + if (!mg_parse_header(hdr, "username", user, sizeof(user))) return 0; + if (!mg_parse_header(hdr, "cnonce", cnonce, sizeof(cnonce))) return 0; + if (!mg_parse_header(hdr, "response", resp, sizeof(resp))) return 0; + if (!mg_parse_header(hdr, "uri", uri, sizeof(uri))) return 0; + if (!mg_parse_header(hdr, "qop", qop, sizeof(qop))) return 0; + if (!mg_parse_header(hdr, "nc", nc, sizeof(nc))) return 0; + if (!mg_parse_header(hdr, "nonce", nonce, sizeof(nonce))) return 0; + + while (fgets(line, sizeof(line), fp) != NULL) { + if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) == 3 && + !strcmp(user, f_user) && + // NOTE(lsm): due to a bug in MSIE, we do not compare URIs + !strcmp(conn->server->config_options[AUTH_DOMAIN], f_domain)) + return check_password(c->request_method, ha1, uri, + nonce, nc, cnonce, qop, resp); + } + return MG_FALSE; } // Return 1 if request is authorised, 0 otherwise. static int is_authorized(struct connection *conn, const char *path, - int is_directory) { - FILE *fp; - int authorized = MG_TRUE; + int is_directory) { + FILE *fp; + int authorized = MG_TRUE; - if ((fp = open_auth_file(conn, path, is_directory)) != NULL) { - authorized = mg_authorize_digest(&conn->mg_conn, fp); - fclose(fp); - } + if ((fp = open_auth_file(conn, path, is_directory)) != NULL) { + authorized = mg_authorize_digest(&conn->mg_conn, fp); + fclose(fp); + } - return authorized; + return authorized; } static int is_authorized_for_dav(struct connection *conn) { - const char *auth_file = conn->server->config_options[DAV_AUTH_FILE]; - const char *method = conn->mg_conn.request_method; - FILE *fp; - int authorized = MG_FALSE; + const char *auth_file = conn->server->config_options[DAV_AUTH_FILE]; + const char *method = conn->mg_conn.request_method; + FILE *fp; + int authorized = MG_FALSE; - // If dav_auth_file is not set, allow non-authorized PROPFIND - if (method != NULL && !strcmp(method, "PROPFIND") && auth_file == NULL) { - authorized = MG_TRUE; - } else if (auth_file != NULL && (fp = fopen(auth_file, "r")) != NULL) { - authorized = mg_authorize_digest(&conn->mg_conn, fp); - fclose(fp); - } + // If dav_auth_file is not set, allow non-authorized PROPFIND + if (method != NULL && !strcmp(method, "PROPFIND") && auth_file == NULL) { + authorized = MG_TRUE; + } else if (auth_file != NULL && (fp = fopen(auth_file, "r")) != NULL) { + authorized = mg_authorize_digest(&conn->mg_conn, fp); + fclose(fp); + } - return authorized; + return authorized; } static int is_dav_request(const struct connection *conn) { - const char *s = conn->mg_conn.request_method; - return !strcmp(s, "PUT") || !strcmp(s, "DELETE") || - !strcmp(s, "MKCOL") || !strcmp(s, "PROPFIND"); + const char *s = conn->mg_conn.request_method; + return !strcmp(s, "PUT") || !strcmp(s, "DELETE") || + !strcmp(s, "MKCOL") || !strcmp(s, "PROPFIND"); } #endif // MONGOOSE_NO_AUTH static int parse_header(const char *str, int str_len, const char *var_name, - char *buf, size_t buf_size) { - int ch = ' ', len = 0, n = strlen(var_name); - const char *p, *end = str + str_len, *s = NULL; - - if (buf != NULL && buf_size > 0) buf[0] = '\0'; - - // Find where variable starts - for (s = str; s != NULL && s + n < end; s++) { - if ((s == str || s[-1] == ' ' || s[-1] == ',') && s[n] == '=' && - !memcmp(s, var_name, n)) break; - } - - if (s != NULL && &s[n + 1] < end) { - s += n + 1; - if (*s == '"' || *s == '\'') ch = *s++; - p = s; - while (p < end && p[0] != ch && p[0] != ',' && len < (int) buf_size) { - if (p[0] == '\\' && p[1] == ch) p++; - buf[len++] = *p++; - } - if (len >= (int) buf_size || (ch != ' ' && *p != ch)) { - len = 0; - } else { - if (len > 0 && s[len - 1] == ',') len--; - if (len > 0 && s[len - 1] == ';') len--; - buf[len] = '\0'; - } - } - - return len; + char *buf, size_t buf_size) { + int ch = ' ', len = 0, n = strlen(var_name); + const char *p, *end = str + str_len, *s = NULL; + + if (buf != NULL && buf_size > 0) buf[0] = '\0'; + + // Find where variable starts + for (s = str; s != NULL && s + n < end; s++) { + if ((s == str || s[-1] == ' ' || s[-1] == ',') && s[n] == '=' && + !memcmp(s, var_name, n)) break; + } + + if (s != NULL && &s[n + 1] < end) { + s += n + 1; + if (*s == '"' || *s == '\'') ch = *s++; + p = s; + while (p < end && p[0] != ch && p[0] != ',' && len < (int) buf_size) { + if (p[0] == '\\' && p[1] == ch) p++; + buf[len++] = *p++; + } + if (len >= (int) buf_size || (ch != ' ' && *p != ch)) { + len = 0; + } else { + if (len > 0 && s[len - 1] == ',') len--; + if (len > 0 && s[len - 1] == ';') len--; + buf[len] = '\0'; + } + } + + return len; } int mg_parse_header(const char *s, const char *var_name, char *buf, - size_t buf_size) { - return parse_header(s, s == NULL ? 0 : strlen(s), var_name, buf, buf_size); + size_t buf_size) { + return parse_header(s, s == NULL ? 0 : strlen(s), var_name, buf, buf_size); } #ifndef MONGOOSE_NO_SSI static void send_ssi_file(struct mg_connection *, const char *, FILE *, int); static void send_file_data(struct mg_connection *conn, FILE *fp) { - char buf[IOBUF_SIZE]; - int n; - while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) { - mg_write(conn, buf, n); - } + char buf[IOBUF_SIZE]; + int n; + while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) { + mg_write(conn, buf, n); + } } static void do_ssi_include(struct mg_connection *conn, const char *ssi, - char *tag, int include_level) { - char file_name[IOBUF_SIZE], path[MAX_PATH_SIZE], *p; - char **opts = (MG_CONN_2_CONN(conn))->server->config_options; - FILE *fp; - - // sscanf() is safe here, since send_ssi_file() also uses buffer - // of size MG_BUF_LEN to get the tag. So strlen(tag) is always < MG_BUF_LEN. - if (sscanf(tag, " virtual=\"%[^\"]\"", file_name) == 1) { - // File name is relative to the webserver root - mg_snprintf(path, sizeof(path), "%s%c%s", - opts[DOCUMENT_ROOT], '/', file_name); - } else if (sscanf(tag, " abspath=\"%[^\"]\"", file_name) == 1) { - // File name is relative to the webserver working directory - // or it is absolute system path - mg_snprintf(path, sizeof(path), "%s", file_name); - } else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1 || - sscanf(tag, " \"%[^\"]\"", file_name) == 1) { - // File name is relative to the currect document - mg_snprintf(path, sizeof(path), "%s", ssi); - if ((p = strrchr(path, '/')) != NULL) { - p[1] = '\0'; - } - mg_snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s", - file_name); - } else { - mg_printf(conn, "Bad SSI #include: [%s]", tag); - return; - } - - if ((fp = fopen(path, "rb")) == NULL) { - mg_printf(conn, "Cannot open SSI #include: [%s]: fopen(%s): %s", - tag, path, strerror(errno)); - } else { - ns_set_close_on_exec(fileno(fp)); - if (mg_match_prefix(opts[SSI_PATTERN], strlen(opts[SSI_PATTERN]), - path) > 0) { - send_ssi_file(conn, path, fp, include_level + 1); - } else { - send_file_data(conn, fp); - } - fclose(fp); - } + char *tag, int include_level) { + char file_name[IOBUF_SIZE], path[MAX_PATH_SIZE], *p; + char **opts = (MG_CONN_2_CONN(conn))->server->config_options; + FILE *fp; + + // sscanf() is safe here, since send_ssi_file() also uses buffer + // of size MG_BUF_LEN to get the tag. So strlen(tag) is always < MG_BUF_LEN. + if (sscanf(tag, " virtual=\"%[^\"]\"", file_name) == 1) { + // File name is relative to the webserver root + mg_snprintf(path, sizeof(path), "%s%c%s", + opts[DOCUMENT_ROOT], '/', file_name); + } else if (sscanf(tag, " abspath=\"%[^\"]\"", file_name) == 1) { + // File name is relative to the webserver working directory + // or it is absolute system path + mg_snprintf(path, sizeof(path), "%s", file_name); + } else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1 || + sscanf(tag, " \"%[^\"]\"", file_name) == 1) { + // File name is relative to the currect document + mg_snprintf(path, sizeof(path), "%s", ssi); + if ((p = strrchr(path, '/')) != NULL) { + p[1] = '\0'; + } + mg_snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s", + file_name); + } else { + mg_printf(conn, "Bad SSI #include: [%s]", tag); + return; + } + + if ((fp = fopen(path, "rb")) == NULL) { + mg_printf(conn, "Cannot open SSI #include: [%s]: fopen(%s): %s", + tag, path, strerror(errno)); + } else { + ns_set_close_on_exec(fileno(fp)); + if (mg_match_prefix(opts[SSI_PATTERN], strlen(opts[SSI_PATTERN]), + path) > 0) { + send_ssi_file(conn, path, fp, include_level + 1); + } else { + send_file_data(conn, fp); + } + fclose(fp); + } } #ifndef MONGOOSE_NO_POPEN static void do_ssi_exec(struct mg_connection *conn, char *tag) { - char cmd[IOBUF_SIZE]; - FILE *fp; - - if (sscanf(tag, " \"%[^\"]\"", cmd) != 1) { - mg_printf(conn, "Bad SSI #exec: [%s]", tag); - } else if ((fp = popen(cmd, "r")) == NULL) { - mg_printf(conn, "Cannot SSI #exec: [%s]: %s", cmd, strerror(errno)); - } else { - send_file_data(conn, fp); - pclose(fp); - } + char cmd[IOBUF_SIZE]; + FILE *fp; + + if (sscanf(tag, " \"%[^\"]\"", cmd) != 1) { + mg_printf(conn, "Bad SSI #exec: [%s]", tag); + } else if ((fp = popen(cmd, "r")) == NULL) { + mg_printf(conn, "Cannot SSI #exec: [%s]: %s", cmd, strerror(errno)); + } else { + send_file_data(conn, fp); + pclose(fp); + } } #endif // !MONGOOSE_NO_POPEN static void send_ssi_file(struct mg_connection *conn, const char *path, - FILE *fp, int include_level) { - char buf[IOBUF_SIZE]; - int ch, offset, len, in_ssi_tag; - - if (include_level > 10) { - mg_printf(conn, "SSI #include level is too deep (%s)", path); - return; - } - - in_ssi_tag = len = offset = 0; - while ((ch = fgetc(fp)) != EOF) { - if (in_ssi_tag && ch == '>') { - in_ssi_tag = 0; - buf[len++] = (char) ch; - buf[len] = '\0'; - assert(len <= (int) sizeof(buf)); - if (len < 6 || memcmp(buf, " @@ -74,7 +74,7 @@ - + @@ -103,8 +103,8 @@ - - + + @@ -113,11 +113,11 @@ - + - - + + @@ -126,7 +126,7 @@ - + @@ -139,7 +139,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -159,7 +159,7 @@ - + @@ -168,7 +168,7 @@ - + @@ -180,7 +180,7 @@ - + @@ -191,9 +191,9 @@ - - - + + + @@ -219,29 +219,29 @@ - + - + - - + + - + - - + + + + - - diff --git a/src/mame/layout/s11a.lay b/src/mame/layout/s11a.lay index d1a94daef50..b8179ca88de 100644 --- a/src/mame/layout/s11a.lay +++ b/src/mame/layout/s11a.lay @@ -1,7 +1,7 @@ + 2012-12-19: Rearranged layout, replaced diagnostic 7-digit LED with 3 single LEDs [Barry Rodewald]--> diff --git a/src/mame/machine/315_5296.c b/src/mame/machine/315_5296.c index 1b02a9c0f2f..638c270d7c7 100644 --- a/src/mame/machine/315_5296.c +++ b/src/mame/machine/315_5296.c @@ -1,7 +1,7 @@ /********************************************************************** Sega 315-5296 I/O chip - + Sega 100-pin QFP, with 8 bidirectional I/O ports, and 3 output pins. It also has chip select(/FMCS) and clock(CKOT) for a peripheral device. Commonly used from the late 80s up until Sega Model 2. @@ -68,7 +68,7 @@ void sega_315_5296_device::device_start() m_in_pf_cb.resolve_safe(0xff); m_in_port_cb[5] = &m_in_pf_cb; m_in_pg_cb.resolve_safe(0xff); m_in_port_cb[6] = &m_in_pg_cb; m_in_ph_cb.resolve_safe(0xff); m_in_port_cb[7] = &m_in_ph_cb; - + m_out_pa_cb.resolve_safe(); m_out_port_cb[0] = &m_out_pa_cb; m_out_pb_cb.resolve_safe(); m_out_port_cb[1] = &m_out_pb_cb; m_out_pc_cb.resolve_safe(); m_out_port_cb[2] = &m_out_pc_cb; @@ -77,11 +77,11 @@ void sega_315_5296_device::device_start() m_out_pf_cb.resolve_safe(); m_out_port_cb[5] = &m_out_pf_cb; m_out_pg_cb.resolve_safe(); m_out_port_cb[6] = &m_out_pg_cb; m_out_ph_cb.resolve_safe(); m_out_port_cb[7] = &m_out_ph_cb; - + m_out_cnt0_cb.resolve_safe(); m_out_cnt_cb[0] = &m_out_cnt0_cb; m_out_cnt1_cb.resolve_safe(); m_out_cnt_cb[1] = &m_out_cnt1_cb; m_out_cnt2_cb.resolve_safe(); m_out_cnt_cb[2] = &m_out_cnt2_cb; - + // register for savestates save_item(NAME(m_output_latch)); save_item(NAME(m_cnt)); @@ -96,7 +96,7 @@ void sega_315_5296_device::device_reset() { // all ports are set to input m_dir = 0; - + // clear output ports memset(m_output_latch, 0, sizeof(m_output_latch)); m_cnt = 0; @@ -113,7 +113,7 @@ void sega_315_5296_device::device_reset() READ8_MEMBER( sega_315_5296_device::read ) { offset &= 0x3f; - + switch (offset) { // port A to H @@ -121,10 +121,10 @@ READ8_MEMBER( sega_315_5296_device::read ) // if the port is configured as an output, return the last thing written if (m_dir & 1 << offset) return m_output_latch[offset]; - + // otherwise, return an input port return (*m_in_port_cb[offset])(offset); - + // 'SEGA' protection case 0x8: return 'S'; @@ -142,11 +142,11 @@ READ8_MEMBER( sega_315_5296_device::read ) // port direction register & mirror case 0xd: case 0xf: return m_dir; - + default: break; } - + return 0xff; } @@ -165,7 +165,7 @@ WRITE8_MEMBER( sega_315_5296_device::write ) m_output_latch[offset] = data; break; - + // CNT register case 0xe: // d0-2: CNT0-2 output pins @@ -173,7 +173,7 @@ WRITE8_MEMBER( sega_315_5296_device::write ) // no effect on the output level of CNT2. for (int i = 0; i < 3; i++) (*m_out_cnt_cb[i])(data >> i & 1); - + // d3: CNT2 output mode (1= Clock output, 0= Programmable output) // d4,5: CNT2 clock divider (0= CLK/4, 1= CLK/8, 2= CLK/16, 3= CLK/2) // d6,7: CKOT clock divider (0= CLK/4, 1= CLK/8, 2= CLK/16, 3= CLK/2) @@ -189,10 +189,10 @@ WRITE8_MEMBER( sega_315_5296_device::write ) if ((m_dir ^ data) & (1 << i)) (*m_out_port_cb[i])((offs_t)i, (data & 1 << i) ? m_output_latch[i] : 0); } - + m_dir = data; break; - + default: break; } diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 42f365c7b1b..7bf026f9ca0 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -358,7 +358,7 @@ TIMER_CALLBACK_MEMBER( amiga_state::scanline_callback ) m_pot1y += !(m_potgo_port->read() & 0x4000); } } - + // render up to this scanline if (!m_screen->update_partial(scanline)) { diff --git a/src/mame/machine/asic65.c b/src/mame/machine/asic65.c index 08954aca6d2..075e29ab356 100644 --- a/src/mame/machine/asic65.c +++ b/src/mame/machine/asic65.c @@ -251,7 +251,7 @@ READ16_MEMBER( asic65_device::read ) } int command = (m_command < MAX_COMMANDS) ? command_map[m_asic65_type][m_command] : OP_UNKNOWN; - + /* update results */ switch (command) { diff --git a/src/mame/machine/atari.c b/src/mame/machine/atari.c index 2d4334fe846..7a0a29f692d 100644 --- a/src/mame/machine/atari.c +++ b/src/mame/machine/atari.c @@ -167,7 +167,7 @@ POKEY_KEYBOARD_CB_MEMBER(atari_common_state::a5200_keypads) case pokey_device::POK_KEY_SHIFT: // button 2 from joypads ipt = m_djoy_b->read() & (0x10 << ((k543210 >> 3) & 0x03)); - ret |= !ipt ? 0x02 : 0; + ret |= !ipt ? 0x02 : 0; break; } diff --git a/src/mame/machine/awboard.h b/src/mame/machine/awboard.h index daf9b002c91..6e11a11061d 100644 --- a/src/mame/machine/awboard.h +++ b/src/mame/machine/awboard.h @@ -22,8 +22,8 @@ public: DECLARE_WRITE16_MEMBER(mpr_first_file_index_w); // 5f7010 DECLARE_WRITE16_MEMBER(mpr_file_offsetl_w); // 5f7014 DECLARE_WRITE16_MEMBER(mpr_file_offseth_w); // 5f7018 - DECLARE_READ16_MEMBER(adj_offset_r); // 5f7080 - DECLARE_WRITE16_MEMBER(adj_offset_w); // 5f7080 + DECLARE_READ16_MEMBER(adj_offset_r); // 5f7080 + DECLARE_WRITE16_MEMBER(adj_offset_w); // 5f7080 protected: virtual void device_start(); diff --git a/src/mame/machine/inder_vid.c b/src/mame/machine/inder_vid.c index 9dd4294bbb3..3862b4ab5f8 100644 --- a/src/mame/machine/inder_vid.c +++ b/src/mame/machine/inder_vid.c @@ -90,7 +90,7 @@ static MACHINE_CONFIG_FRAGMENT( inder_vid ) MCFG_CPU_PROGRAM_MAP(megaphx_tms_map) MCFG_TMS340X0_HALT_ON_RESET(TRUE) /* halt on reset */ MCFG_TMS340X0_PIXEL_CLOCK(XTAL_40MHz/12) /* pixel clock */ - MCFG_TMS340X0_PIXELS_PER_CLOCK(2) /* pixels per clock */ + MCFG_TMS340X0_PIXELS_PER_CLOCK(2) /* pixels per clock */ MCFG_TMS340X0_SCANLINE_RGB32_CB(inder_vid_device, scanline) /* scanline updater (RGB32) */ MCFG_TMS340X0_OUTPUT_INT_CB(WRITELINE(inder_vid_device, m68k_gen_int)) MCFG_TMS340X0_TO_SHIFTREG_CB(inder_vid_device, to_shiftreg) /* write to shiftreg function */ diff --git a/src/mame/machine/inder_vid.h b/src/mame/machine/inder_vid.h index 7d4375a2855..4975e12e859 100644 --- a/src/mame/machine/inder_vid.h +++ b/src/mame/machine/inder_vid.h @@ -29,7 +29,7 @@ public: required_shared_ptr m_vram; required_device m_palette; required_device m_tms; - + DECLARE_WRITE_LINE_MEMBER(m68k_gen_int); int m_shiftfull; // this might be a driver specific hack for a TMS bug. @@ -41,7 +41,7 @@ protected: virtual machine_config_constructor device_mconfig_additions() const; virtual void device_start(); virtual void device_reset(); - + private: }; diff --git a/src/mame/machine/kaneko_calc3.h b/src/mame/machine/kaneko_calc3.h index bc5afffad6d..3ad16702c4a 100644 --- a/src/mame/machine/kaneko_calc3.h +++ b/src/mame/machine/kaneko_calc3.h @@ -16,7 +16,7 @@ public: void reset_run_timer(); void mcu_run(); - + protected: virtual void device_start(); virtual void device_reset(); @@ -43,12 +43,12 @@ private: UINT16 m_poll_addr; UINT16 m_checksumaddress; emu_timer* m_runtimer; - + enum { MCU_RUN_TIMER }; - + void mcu_init(); void initial_scan_tables(); void mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_); diff --git a/src/mame/machine/kaneko_toybox.h b/src/mame/machine/kaneko_toybox.h index 5f3b9bfce47..e3a72e4c99b 100644 --- a/src/mame/machine/kaneko_toybox.h +++ b/src/mame/machine/kaneko_toybox.h @@ -353,7 +353,7 @@ private: UINT16 m_mcu_com[4]; int m_gametype; int m_tabletype; - + void mcu_com_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_); void decrypt_rom(); void handle_04_subcommand(UINT8 mcu_subcmd, UINT16 *mcu_ram); @@ -366,6 +366,6 @@ extern const device_type KANEKO_TOYBOX; #define MCFG_TOYBOX_TABLE_TYPE(_type) \ kaneko_toybox_device::set_table(*device, _type); - + #define MCFG_TOYBOX_GAME_TYPE(_type) \ kaneko_toybox_device::set_game_type(*device, _type); diff --git a/src/mame/machine/konppc.c b/src/mame/machine/konppc.c index f470aab3d2d..dd631ad6401 100644 --- a/src/mame/machine/konppc.c +++ b/src/mame/machine/konppc.c @@ -18,7 +18,7 @@ konppc_device::konppc_device(const machine_config &mconfig, const char *tag, dev : device_t(mconfig, KONPPC, "Konami PowerPC Common Functions", tag, owner, clock, "konppc", __FILE__), cgboard_type(0), num_cgboards(0)/*, - cgboard_id(MAX_CG_BOARDS)*/ + cgboard_id(MAX_CG_BOARDS)*/ { } diff --git a/src/mame/machine/model1.c b/src/mame/machine/model1.c index 1b26ea2584b..b3499d7116d 100644 --- a/src/mame/machine/model1.c +++ b/src/mame/machine/model1.c @@ -1584,15 +1584,15 @@ const struct model1_state::function model1_state::ftab_vf[] = { { &model1_state::fsub, 2 }, { &model1_state::fmul, 2 }, { &model1_state::fdiv, 2 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::matrix_push, 0 }, { &model1_state::matrix_pop, 0 }, { &model1_state::matrix_write, 12 }, { &model1_state::clear_stack, 0 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::anglev, 2 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::track_select, 1 }, { &model1_state::f14, 4 }, { &model1_state::anglep, 4 }, @@ -1604,9 +1604,9 @@ const struct model1_state::function model1_state::ftab_vf[] = { { &model1_state::matrix_rotx, 1 }, { &model1_state::matrix_roty, 1 }, { &model1_state::matrix_rotz, 1 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::track_read_quad, 1 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::transform_point, 3 }, { &model1_state::fsin_m1, 1 }, { &model1_state::fcos_m1, 1 }, @@ -1614,10 +1614,10 @@ const struct model1_state::function model1_state::ftab_vf[] = { { &model1_state::fcosm_m1, 2 }, { &model1_state::distance3, 6 }, - { NULL, 0 }, /* 0x20 */ - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, /* 0x20 */ + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::acc_set, 1 }, { &model1_state::acc_get, 0 }, { &model1_state::acc_add, 1 }, @@ -1629,54 +1629,54 @@ const struct model1_state::function model1_state::ftab_vf[] = { { &model1_state::f44, 1 }, { &model1_state::f45, 1 }, { &model1_state::vlength, 3 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::track_read_info, 1 }, /* 0x30 */ { &model1_state::colbox_set, 12 }, { &model1_state::colbox_test, 3 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::track_lookup, 4 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::col_setcirc, 3 }, /* 0x40 */ { &model1_state::col_testpt, 2 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::distance, 4 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::car_move, 4 }, { &model1_state::cpa, 12 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::vmat_store, 1 }, { &model1_state::vmat_restore, 1 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::vmat_mul, 2 }, { &model1_state::vmat_read, 1 }, { &model1_state::matrix_unrot, 0 }, { &model1_state::f80, 0 }, /* 0x50 */ - { NULL, 0 }, + { NULL, 0 }, { &model1_state::matrix_rtrans, 0 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::vmat_save, 1 }, { &model1_state::vmat_load, 1 }, { &model1_state::ram_setadr, 1 }, { &model1_state::groundbox_test, 3 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::f89, 4 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::f92, 4 }, { &model1_state::f93, 1 }, { &model1_state::f94, 1 }, @@ -1702,7 +1702,7 @@ const struct model1_state::function model1_state::ftab_swa[] = { { &model1_state::fsub, 2 }, { &model1_state::fmul, 2 }, { &model1_state::fdiv, 2 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::matrix_push, 0 }, { &model1_state::matrix_pop, 0 }, { &model1_state::matrix_write, 12 }, @@ -1722,9 +1722,9 @@ const struct model1_state::function model1_state::ftab_swa[] = { { &model1_state::matrix_rotx, 1 }, { &model1_state::matrix_roty, 1 }, { &model1_state::matrix_rotz, 1 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::f24_swa, 7 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::transform_point, 3 }, { &model1_state::fsin_m1, 1 }, { &model1_state::fcos_m1, 1 }, @@ -1732,8 +1732,8 @@ const struct model1_state::function model1_state::ftab_swa[] = { { &model1_state::fcosm_m1, 2 }, { &model1_state::distance3, 6 }, - { NULL, 0 }, /* 0x20 */ - { NULL, 0 }, + { NULL, 0 }, /* 0x20 */ + { NULL, 0 }, { &model1_state::ftoi, 1 }, { &model1_state::itof, 1 }, { &model1_state::acc_set, 1 }, @@ -1749,26 +1749,26 @@ const struct model1_state::function model1_state::ftab_swa[] = { { &model1_state::vlength, 3 }, { &model1_state::f47, 3 }, - { NULL, 0 }, /* 0x30 */ + { NULL, 0 }, /* 0x30 */ { &model1_state::f49_swa, 6 }, { &model1_state::f50_swa, 4 }, - { NULL, 0 }, + { NULL, 0 }, { &model1_state::f52, 0 }, { &model1_state::matrix_rdir, 3 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::f56, 7 }, { &model1_state::f57, 0 }, { &model1_state::matrix_readt, 0 }, { &model1_state::acc_geti, 0 }, { &model1_state::f60, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, { &model1_state::push_and_ident, 0 }, /* 0x40 */ - { NULL, 0 }, + { NULL, 0 }, { &model1_state::catmull_rom, 13 } }; diff --git a/src/mame/machine/nmk004.c b/src/mame/machine/nmk004.c index 2b0523f53ef..297345f7382 100644 --- a/src/mame/machine/nmk004.c +++ b/src/mame/machine/nmk004.c @@ -25,7 +25,7 @@ WRITE8_MEMBER(nmk004_device::nmk004_port4_w) { // bit 0x08 toggles frequently but is connected to nothing? - // bit 0x01 is set to reset the 68k + // bit 0x01 is set to reset the 68k m_systemcpu->set_input_line(INPUT_LINE_RESET, (data & 1) ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/machine/raiden2cop.c b/src/mame/machine/raiden2cop.c index 06b8410db62..c9eebf52f4e 100644 --- a/src/mame/machine/raiden2cop.c +++ b/src/mame/machine/raiden2cop.c @@ -27,7 +27,7 @@ raiden2cop_device::raiden2cop_device(const machine_config &mconfig, const char * cop_latch_addr(0), cop_latch_trigger(0), cop_latch_value(0), - cop_latch_mask(0), + cop_latch_mask(0), cop_dma_v1(0), cop_dma_v2(0), cop_dma_mode(0), @@ -78,7 +78,7 @@ raiden2cop_device::raiden2cop_device(const machine_config &mconfig, const char * memset(cop_func_value, 0, sizeof(UINT16)*(0x100/8)); memset(cop_func_mask, 0, sizeof(UINT16)*(0x100/8)); memset(cop_program, 0, sizeof(UINT16)*(0x100)); - + memset(cop_dma_src, 0, sizeof(UINT16)*(0x200)); memset(cop_dma_dst, 0, sizeof(UINT16)*(0x200)); memset(cop_dma_size, 0, sizeof(UINT16)*(0x200)); @@ -362,7 +362,7 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) /* search the uploaded 'trigger' table for a matching trigger*/ /* note, I don't know what the 'mask' or 'value' tables are... probably important, might determine what actually gets executed! */ /* note: Zero Team triggers macro 0x904 instead of 0x905, Seibu Cup Soccer triggers 0xe30e instead of 0xe38e. I highly doubt that AT LEAST - it isn't supposed to do anything, especially in the former case (it definitely NEEDS that sprites have an arc movement when they are knocked down). */ + it isn't supposed to do anything, especially in the former case (it definitely NEEDS that sprites have an arc movement when they are knocked down). */ // we currently pass in mask 0xff00 to look at only match the top bits, but this is wrong, only specific bits are ignored (maybe depends on the 'mask' value uploaded with each trigger?) int matched = 0; int command = -1; @@ -374,7 +374,7 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) if ((triggerval & mask) == (cop_func_trigger[i] & mask) && cop_func_trigger[i] != 0) /* cop_func_trigger[i] != 0 is just being used to prevent matching against empty / unused slots */ { int otherlog = 1; - + // just some per-game debug code so that we have a record of exactly which triggers each game is known to use @@ -382,7 +382,7 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) { // enemies often walk on the spot, bosses often walk above / below playable game area (the >>16 in the sqrt commands seems responsible) // player doesn't walk off screen after end of level (walks on spot, different cause?) - if (triggerval == 0x0205 || triggerval == 0x0905 || + if (triggerval == 0x0205 || triggerval == 0x0905 || triggerval == 0x8100 || triggerval == 0x8900 || /* sin / cos */ triggerval == 0x138e || // atan? triggerval == 0x3bb0 || // distance? @@ -413,7 +413,7 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) if (triggerval == 0x0205 || triggerval == 0x8100 || triggerval == 0x8900 || /* sin / cos */ - triggerval == 0x138e || + triggerval == 0x138e || triggerval == 0x3bb0 || triggerval == 0x42c2 || triggerval == 0xa100 || triggerval == 0xa900 || triggerval == 0xb080 || triggerval == 0xb880) /* collisions */ @@ -494,13 +494,13 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) { if (triggerval == 0x0205 || triggerval == 0x0905 || triggerval == 0x8100 || triggerval == 0x8900 || /* sin / cos */ - triggerval == 0x130e || triggerval == 0x138e || + triggerval == 0x130e || triggerval == 0x138e || triggerval == 0x2a05 || - triggerval == 0x2208 || triggerval == 0x2288 || + triggerval == 0x2208 || triggerval == 0x2288 || triggerval == 0x338e || - triggerval == 0x39b0 || triggerval == 0x3bb0 || - triggerval == 0x4aa0 || - triggerval == 0x42c2 || + triggerval == 0x39b0 || triggerval == 0x3bb0 || + triggerval == 0x4aa0 || + triggerval == 0x42c2 || triggerval == 0x5205 || triggerval == 0x5a05 || triggerval == 0x6200 || @@ -508,7 +508,7 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) triggerval == 0xa100 || triggerval == 0xa900 || triggerval == 0xb100 || triggerval == 0xb900 /* collisions */ ) otherlog = 0; - } + } else { otherlog = 0; @@ -525,7 +525,6 @@ int raiden2cop_device::find_trigger_match(UINT16 triggerval, UINT16 mask) if (matched == 1) { - int j; seibu_cop_log(" Sequence: "); for (j=0;j<0x8;j++) @@ -554,9 +553,9 @@ int raiden2cop_device::check_command_matches(int command, UINT16 seq0, UINT16 se command *= 8; if (cop_program[command+0] == seq0 && cop_program[command+1] == seq1 && cop_program[command+2] == seq2 && cop_program[command+3] == seq3 && - cop_program[command+4] == seq4 && cop_program[command+5] == seq5 && cop_program[command+6] == seq6 && cop_program[command+7] == seq7 && - cop_func_value[command/8] == _funcval_ && - cop_func_mask[command/8] == _funcmask_) + cop_program[command+4] == seq4 && cop_program[command+5] == seq5 && cop_program[command+6] == seq6 && cop_program[command+7] == seq7 && + cop_func_value[command/8] == _funcval_ && + cop_func_mask[command/8] == _funcmask_) return 1; else return 0; @@ -877,7 +876,7 @@ WRITE16_MEMBER(raiden2cop_device::cop_dma_trigger_w) /* Number Conversion */ -// according to score display in https://www.youtube.com/watch?v=T1M8sxYgt9A +// according to score display in https://www.youtube.com/watch?v=T1M8sxYgt9A // we should return 0x30 for unused digits? according to Raiden 2 and Zero // Team the value should be 0x20, can this be configured? // grainbow doesn't like this implementation at all (21 credits, 2 digit high scores etc.) @@ -890,7 +889,7 @@ WRITE16_MEMBER(raiden2cop_device::cop_itoa_low_w) if(digits > 9) digits = 9; - + for (int i = 0; i < digits; i++) { if (!val && i) @@ -903,7 +902,7 @@ WRITE16_MEMBER(raiden2cop_device::cop_itoa_low_w) val = val / 10; } } - + cop_itoa_digits[9] = 0; } @@ -1106,7 +1105,7 @@ void raiden2cop_device::execute_338e(address_space &space, int offset, UINT16 da /* ## - trig (up5) (low11) : (sq0, sq1, sq2, sq3, sq4, sq5, sq6, sq7) valu mask -07 - 3bb0 ( 07) ( 3b0) : (f9c, b9c, b9c, b9c, b9c, b9c, b9c, 99c) 4 007f (legionna, heatbrl, cupsoc, grainbow, godzilla, denjinmk, raiden2, raidendx, +07 - 3bb0 ( 07) ( 3b0) : (f9c, b9c, b9c, b9c, b9c, b9c, b9c, 99c) 4 007f (legionna, heatbrl, cupsoc, grainbow, godzilla, denjinmk, raiden2, raidendx, 07 - 3b30 ( 07) ( 330) : (f9c, b9c, b9c, b9c, b9c, b9c, b9c, 99c) 4 007f (zeroteam, xsedae) */ @@ -1262,7 +1261,7 @@ void raiden2cop_device::execute_6200(address_space &space, int offset, UINT16 da else angle -= cop_angle_step; } - + cop_write_word(space, cop_regs[primary_reg], flags); if (!m_cpu_is_68k) @@ -1304,7 +1303,7 @@ void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UI else angle -= cop_angle_step; } - + cop_write_word(space, cop_regs[primary_reg], flags); if (!m_cpu_is_68k) @@ -1716,7 +1715,7 @@ void raiden2cop_device::cop_collision_update_hitbox(address_space &space, UINT1 //printf("%02x %02x %02x %02x %02x %02x\n", (UINT8)size[i], (UINT8)dx[i], (UINT8)size[1], (UINT8)dx[1], (UINT8)size[2], (UINT8)dx[2]); int j = slot; - + UINT8 res; if (num_axis==3) res = 7; @@ -1791,7 +1790,7 @@ WRITE16_MEMBER( raiden2cop_device::cop_cmd_w) case 0x39b0: case 0x3b30: case 0x3bb0: { // 3bb0 0004 007f 0038 - 0f9c 0b9c 0b9c 0b9c 0b9c 0b9c 0b9c 099c - execute_3b30(space, offset, data); + execute_3b30(space, offset, data); break; } @@ -1829,7 +1828,7 @@ WRITE16_MEMBER( raiden2cop_device::cop_cmd_w) case 0x5a05: // 5a05 0006 fff7 0058 - 0180 02e0 03a0 00a0 03a0 0000 0000 0000 // fprintf(stderr, "sprcpt 5a05 %04x %04x %04x %08x %08x\n", cop_regs[0], cop_regs[1], cop_regs[3], space.read_dword(cop_regs[0]), space.read_dword(cop_regs[3])); execute_5a05(space, offset, data); - + break; case 0xf205: // f205 0006 fff7 00f0 - 0182 02e0 03c0 00c0 03c0 0000 0000 0000 @@ -2064,7 +2063,7 @@ WRITE16_MEMBER(raiden2cop_device::cop_sprite_dma_abs_x_w) WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) { int command; - + seibu_cop_log("%06x: COPX execute table macro command %04x | regs %08x %08x %08x %08x %08x\n", space.device().safe_pc(), data, cop_regs[0], cop_regs[1], cop_regs[2], cop_regs[3], cop_regs[4]); @@ -2117,16 +2116,16 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) /* SINE math - 0x8100 */ /* - 00000-0ffff: - amp = x/256 - ang = x & 255 - s = sin(ang*2*pi/256) - val = trunc(s*amp) - if(s<0) - val-- - if(s == 192) - val = -2*amp - */ + 00000-0ffff: + amp = x/256 + ang = x & 255 + s = sin(ang*2*pi/256) + val = trunc(s*amp) + if(s<0) + val-- + if(s == 192) + val = -2*amp + */ if (check_command_matches(command, 0xb9a, 0xb88, 0x888, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb)) { executed = 1; @@ -2136,16 +2135,16 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) /* COSINE math - 0x8900 */ /* - 10000-1ffff: - amp = x/256 - ang = x & 255 - s = cos(ang*2*pi/256) - val = trunc(s*amp) - if(s<0) - val-- - if(s == 128) - val = -2*amp - */ + 10000-1ffff: + amp = x/256 + ang = x & 255 + s = cos(ang*2*pi/256) + val = trunc(s*amp) + if(s<0) + val-- + if(s == 128) + val = -2*amp + */ if (check_command_matches(command, 0xb9a, 0xb8a, 0x88a, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb)) { executed = 1; @@ -2173,11 +2172,11 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) /* Pythagorean theorem, hypotenuse length - 0x3bb0 */ //(grainbow) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c /* - 40000-7ffff: - v1 = (x / 32768)*64 - v2 = (x & 255)*32767/255 - val = sqrt(v1*v1+v2*v2) (unsigned) - */ + 40000-7ffff: + v1 = (x / 32768)*64 + v2 = (x & 255)*32767/255 + val = sqrt(v1*v1+v2*v2) (unsigned) + */ if (check_command_matches(command, 0xf9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0x99c, 4, 0x007f)) { executed = 1; @@ -2187,15 +2186,15 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) /* Division - 0x42c2 */ /* - 20000-2ffff: - v1 = x / 1024 - v2 = x & 1023 - val = !v1 ? 32767 : trunc(v2/v1+0.5) - 30000-3ffff: - v1 = x / 1024 - v2 = (x & 1023)*32 - val = !v1 ? 32767 : trunc(v2/v1+0.5) - */ + 20000-2ffff: + v1 = x / 1024 + v2 = x & 1023 + val = !v1 ? 32767 : trunc(v2/v1+0.5) + 30000-3ffff: + v1 = x / 1024 + v2 = (x & 1023)*32 + val = !v1 ? 32767 : trunc(v2/v1+0.5) + */ if (check_command_matches(command, 0xf9a, 0xb9a, 0xb9c, 0xb9c, 0xb9c, 0x29c, 0x000, 0x000, 5, 0xfcdd)) { executed = 1; @@ -2204,17 +2203,17 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) } /* - collision detection: + collision detection: - int dy_0 = space.read_dword(cop_regs[0]+4); - int dx_0 = space.read_dword(cop_regs[0]+8); - int dy_1 = space.read_dword(cop_regs[1]+4); - int dx_1 = space.read_dword(cop_regs[1]+8); - int hitbox_param1 = space.read_dword(cop_regs[2]); - int hitbox_param2 = space.read_dword(cop_regs[3]); + int dy_0 = space.read_dword(cop_regs[0]+4); + int dx_0 = space.read_dword(cop_regs[0]+8); + int dy_1 = space.read_dword(cop_regs[1]+4); + int dx_1 = space.read_dword(cop_regs[1]+8); + int hitbox_param1 = space.read_dword(cop_regs[2]); + int hitbox_param2 = space.read_dword(cop_regs[3]); - TODO: we are ignoring the funcval / funcmask params for now - */ + TODO: we are ignoring the funcval / funcmask params for now + */ if (check_command_matches(command, 0xb80, 0xb82, 0xb84, 0xb86, 0x000, 0x000, 0x000, 0x000, funcval, funcmask)) { @@ -2287,7 +2286,7 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) if (check_command_matches(command, 0x380, 0x39a, 0x380, 0xa80, 0x29a, 0x000, 0x000, 0x000, 8, 0xf3e7)) { executed = 1; - execute_6200(space, offset, data); + execute_6200(space, offset, data); return; } @@ -2311,7 +2310,3 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w) if (executed == 0) printf("did not execute %04x\n", data); // cup soccer triggers this a lot (and others) } - - - - diff --git a/src/mame/machine/raiden2cop.h b/src/mame/machine/raiden2cop.h index 91ff1e7b41e..63db2eab45c 100644 --- a/src/mame/machine/raiden2cop.h +++ b/src/mame/machine/raiden2cop.h @@ -87,7 +87,7 @@ public: DECLARE_WRITE16_MEMBER( cop_itoa_high_w ); DECLARE_WRITE16_MEMBER( cop_itoa_digit_count_w ); DECLARE_READ16_MEMBER ( cop_itoa_digits_r ); - + UINT32 cop_itoa; UINT16 cop_itoa_digit_count; UINT8 cop_itoa_digits[10]; @@ -122,14 +122,13 @@ public: UINT32 cop_regs[8]; UINT16 cop_status, cop_scale, cop_angle, cop_dist; - + UINT16 cop_angle_target; UINT16 cop_angle_step; struct colinfo { - colinfo() { pos[0] = pos[1] = pos[2] = 0; @@ -140,7 +139,7 @@ public: spradr = 0; min[0] = min[1] = min[2] = 0; max[0] = max[1] = max[2] = 0; - + } diff --git a/src/mame/machine/seicop.c b/src/mame/machine/seicop.c index 664c8cca9d2..edcaf1e7387 100644 --- a/src/mame/machine/seicop.c +++ b/src/mame/machine/seicop.c @@ -3,7 +3,7 @@ OLD Seibu Cop simulation code. this is currently only used by the Seibu Cup Soccer BOOTLEG - + */ /******************************************************************************************** @@ -25,8 +25,6 @@ seibu_cop_bootleg_device::seibu_cop_bootleg_device(const machine_config &mconfig m_cop_mcu_ram(NULL), m_raiden2cop(*this, ":raiden2cop") { - - } #define seibu_cop_log logerror @@ -101,7 +99,7 @@ WRITE16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_w ) break; } - + case (0x500/2): case (0x502/2): case (0x504/2): @@ -152,7 +150,7 @@ WRITE16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_w ) space.write_dword(m_raiden2cop->cop_regs[0] + 4 + offs, npos); space.write_word(m_raiden2cop->cop_regs[0] + 0x1c + offs, space.read_word(m_raiden2cop->cop_regs[0] + 0x1c + offs) + delta); - + break; } case 0x130e: @@ -199,7 +197,7 @@ WRITE16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_w ) break; } break; - + /*TODO: kludge on x-axis.*/ case (0x660/2): { state->m_scrollram16[0] = m_cop_mcu_ram[offset] - 0x1f0; break; } case (0x662/2): { state->m_scrollram16[1] = m_cop_mcu_ram[offset]; break; } @@ -218,5 +216,3 @@ WRITE16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_w ) } } } - - diff --git a/src/mame/machine/seicop.h b/src/mame/machine/seicop.h index 90419a5b290..f19b96e3312 100644 --- a/src/mame/machine/seicop.h +++ b/src/mame/machine/seicop.h @@ -30,4 +30,3 @@ extern const device_type SEIBU_COP_BOOTLEG; #define MCFG_SEIBU_COP_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SEIBU_COP_BOOTLEG, 0) - diff --git a/src/mame/machine/st0016.c b/src/mame/machine/st0016.c index e3da9499158..cc7c871c385 100644 --- a/src/mame/machine/st0016.c +++ b/src/mame/machine/st0016.c @@ -9,7 +9,7 @@ UINT8 macs_cart_slot; static ADDRESS_MAP_START(st0016_cpu_internal_map, AS_PROGRAM, 8, st0016_cpu_device) AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) - AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) + AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) AM_RANGE(0xe900, 0xe9ff) AM_DEVREADWRITE("stsnd", st0016_device, st0016_snd_r, st0016_snd_w) /* sound regs 8 x $20 bytes, see notes */ @@ -29,22 +29,22 @@ ADDRESS_MAP_END st0016_cpu_device::st0016_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : z80_device(mconfig, ST0016_CPU, "ST0016", tag, owner, clock, "st0016_cpu", __FILE__), - st0016_game(-1), - st0016_spr_bank(0), - st0016_spr2_bank(0), - st0016_pal_bank(0), - st0016_char_bank(0), - spr_dx(0), - spr_dy(0), - st0016_ramgfx(0), - - m_io_space_config("io", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_io_map)), - m_space_config("regs", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_map)), - - - m_screen(*this, ":screen"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") + st0016_game(-1), + st0016_spr_bank(0), + st0016_spr2_bank(0), + st0016_pal_bank(0), + st0016_char_bank(0), + spr_dx(0), + spr_dy(0), + st0016_ramgfx(0), + + m_io_space_config("io", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_io_map)), + m_space_config("regs", ENDIANNESS_LITTLE, 8, 16, 0, ADDRESS_MAP_NAME(st0016_cpu_internal_map)), + + + m_screen(*this, ":screen"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette") { for (int i = 0; i < 0xc0; i++) @@ -302,7 +302,7 @@ WRITE8_MEMBER(st0016_cpu_device::st0016_vregs_w) UINT32 srcadr=(st0016_vregs[0xa0]|(st0016_vregs[0xa1]<<8)|(st0016_vregs[0xa2]<<16))<<1; UINT32 dstadr=(st0016_vregs[0xa3]|(st0016_vregs[0xa4]<<8)|(st0016_vregs[0xa5]<<16))<<1; UINT32 length=((st0016_vregs[0xa6]|(st0016_vregs[0xa7]<<8)|((st0016_vregs[0xa8]&0x1f)<<16))+1)<<1; - + // todo : dma callback so macs_cart_slot can be local to MACs driver? UINT32 srclen = (memregion(":maincpu")->bytes()); @@ -354,7 +354,7 @@ void st0016_cpu_device::draw_sprites(bitmap_ind16 &bitmap, const rectangle &clip o - sublist offset (*8 to get real offset) f - end of list flag x,y - sprite coords - + (complete guess) g - use tile sizes specified in list (global / fixed ones if not set?) (gostop) X = global X size? @@ -455,7 +455,7 @@ void st0016_cpu_device::draw_sprites(bitmap_ind16 &bitmap, const rectangle &clip sx += x; sy += y; color = st0016_spriteram[offset + 2] & 0x3f; - + if (use_sizes) { lx = (st0016_spriteram[offset + 5] >> 2) & 3; @@ -469,12 +469,12 @@ void st0016_cpu_device::draw_sprites(bitmap_ind16 &bitmap, const rectangle &clip } /* - if(plx |ply) //parent - { - lx=plx; - ly=ply; - } - */ + if(plx |ply) //parent + { + lx=plx; + ly=ply; + } + */ flipx = st0016_spriteram[offset + 3] & 0x80; flipy = st0016_spriteram[offset + 3] & 0x40; @@ -737,4 +737,3 @@ UINT32 st0016_cpu_device::update(screen_device &screen, bitmap_ind16 &bitmap, co st0016_draw_screen(screen, bitmap, cliprect); return 0; } - diff --git a/src/mame/machine/st0016.h b/src/mame/machine/st0016.h index 3b01ee9a290..3e137bcee47 100644 --- a/src/mame/machine/st0016.h +++ b/src/mame/machine/st0016.h @@ -53,7 +53,7 @@ public: DECLARE_WRITE8_MEMBER(st0016_vregs_w); DECLARE_READ8_MEMBER(soundram_read); - + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); void st0016_save_init(); void draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority); diff --git a/src/mame/machine/vectrex.c b/src/mame/machine/vectrex.c index 4a5bbc5fb08..4cfd14046e9 100644 --- a/src/mame/machine/vectrex.c +++ b/src/mame/machine/vectrex.c @@ -328,11 +328,11 @@ void vectrex_state::machine_start() m_maincpu->space(AS_PROGRAM).install_read_handler(0x0000, 0x7fff, read8_delegate(FUNC(vectrex_cart_slot_device::read_rom),(vectrex_cart_slot_device*)m_cart)); // setup 3d imager and refresh timer - + // If VIA T2 starts, reset refresh timer. This is the best strategy for most games. m_reset_refresh = 1; m_imager_angles = narrow_escape_angles; - + // let's do this 3D detection switch (m_cart->get_vec3d()) { diff --git a/src/mame/mame.lst b/src/mame/mame.lst index d618ddba1a3..41fb7942cf1 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -48,7 +48,7 @@ pacman // (c) 1980 Midway pacmanf // hack puckmod // (c) 1981 Namco pacmod // (c) 1981 Midway -pacmanjpm // bootleg +pacmanjpm // bootleg newpuc2 // hack newpuc2b // hack pacuman // bootleg @@ -103,7 +103,7 @@ msheartb // hack mspacmanbg // bootleg mspacmanbgd // bootleg mspacmanbcc // bootleg -mspacmanblt // bootleg +mspacmanblt // bootleg woodpeck // (c) 1981 Amenip (Palcom Queen River) woodpeca // (c) 1981 Amenip Nova Games Ltd. mspacmab // bootleg @@ -136,8 +136,8 @@ mschamps // hack (hack of the Rayglo hack?) cannonbp // hack superabc // hack superabco // hack -pengojpm // bootleg -pengopac // bootleg +pengojpm // bootleg +pengopac // bootleg // S2650 Pacman Kits drivfrcp // (c) 1984 Shinkai Inc. (Magic Eletronics Inc. license) @@ -333,7 +333,7 @@ ckongs // bootleg froggers // bootleg frogf // bootleg quaak // bootleg -froggeram // bootleg +froggeram // bootleg amidars // GX337 (c) 1982 Konami triplep // (c) 1982 KKI / made by Sanritsu? triplepa // (c) 1982 KKI / made by Sanritsu? @@ -471,7 +471,7 @@ kickboy // (c) 1983 itaten // (c) 1984 + Alice friskyt // (c) 1981 friskyta // (c) 1981 -friskytb // (c) 1981 +friskytb // (c) 1981 radrad // (c) 1982 Nichibutsu USA seicross // (c) 1984 + Alice sectrzon // (c) 1984 + Alice @@ -693,7 +693,7 @@ phoenixb // (c) 1980 Amstar + Centuri license phoenixt // (c) 1980 Taito phoenixj // (c) 1980 Taito phoenix3 // bootleg -phoenixdal // bootleg D&L (No copyright/title) +phoenixdal // bootleg D&L (No copyright/title) phoenixc // bootleg phoenixc2 // bootleg phoenixc3 // bootleg @@ -810,7 +810,7 @@ grobda3 // (c) 1984 gaplus // (c) 1984 gaplusa // (c) 1984 gaplusd // (c) 1984 -gaplust // (c) 1984 +gaplust // (c) 1984 galaga3 // (c) 1984 galaga3a // (c) 1984 galaga3b // (c) 1984 @@ -876,7 +876,7 @@ blazer // (c) 1987 (Japan) quester // (c) 1987 (Japan) questers // (c) 1987 (Japan) pacmania // (c) 1987 -pacmaniao // (c) 1987 +pacmaniao // (c) 1987 pacmaniaj // (c) 1987 (Japan) galaga88 // (c) 1987 galaga88a // (c) 1987 @@ -1166,7 +1166,7 @@ devzone2 // 8022 (c) [1980] cheekyms // 8004 (c) [1980?] zerohour // 8011 (c) Universal zerohoura // 8011 (c) Universal -zerohouri // +zerohouri // redclash // (c) 1981 Tehkan redclasha // (c) 1981 Tehkan redclashk // (c) Kaneko (bootleg?) @@ -1244,8 +1244,8 @@ marioe // (c) 1983 Nintendo of America marioo // (c) 1983 Nintendo of America marioj // (c) 1983 Nintendo masao // bootleg -mariobl // bootleg -dkong3abl // +mariobl // bootleg +dkong3abl // pestplce // bootleg on donkey kong hw spclforc // (c) 1985 Senko Industries (Magic Eletronics Inc. license) spcfrcii // (c) 1985 Senko Industries (Magic Eletronics Inc. license) @@ -1765,7 +1765,7 @@ motorace // (c) 1983 Williams license mototour // (c) 1983 Tecfri shtrider // (c) 1984 Seibu Kaihatsu shtridera // (c) 1984 Seibu Kaihatsu -shtriderb // bootleg +shtriderb // bootleg wilytowr // M63 (c) 1984 atomboy // M63 (c) 1985 Irem + Memetron license atomboya // M63 (c) 1985 Irem + Memetron license @@ -2133,7 +2133,7 @@ arktayt2 // bootleg arkatour // ??? (c) 1987 Taito America Corporation + Romstar license (US) tetrsark // ??? (c) D.R.Korea hexa // D. R. Korea -hexaa // +hexaa // brixian // (c) 1993 Cheil Computer System sqix // B03 1987 sqixr1 // B03 1987 @@ -2678,7 +2678,7 @@ pzlbreak // (c) 1997 SemiCom 3in1semi // (c) 1998 SemiCom moremore // (c) 1999 SemiCom + Exit moremorp // (c) 1999 SemiCom + Exit -suhosong // (c) 199? SemiCom +suhosong // (c) 199? SemiCom 4in1boot // (c) 2002 KISoft (includes hacks of Semicom games + Snowbros) // More Toaplan Games @@ -3039,7 +3039,7 @@ toramich // 11/1987 (c) 1987 (Japan tigeroadb // bootleg f1dream // 4/1988 (c) 1988 + Romstar f1dreamb // bootleg -f1dreamba // bootleg +f1dreamba // bootleg 1943kai // 6/1988 (c) 1987 (Japan) lastduel // 7/1988 (c) 1988 (US) lastduelo // 7/1988 (c) 1988 (US) @@ -3364,7 +3364,7 @@ sfzhr1 // 27/06/1995 (c) 1995 (Hispanic) sfzb // 09/11/1995 (c) 1995 (Brazil) sfzbr1 // 27/07/1995 (c) 1995 (Brazil) mmancp2u // 06/10/1995 (c) 1995 (USA) -mmancp2ur1 // 26/09/1995 (c) 1995 (USA) +mmancp2ur1 // 26/09/1995 (c) 1995 (USA) rmancp2j // 22/09/1995 (c) 1995 (Japan) msh // 24/10/1995 (c) 1995 (Euro) mshu // 24/10/1995 (c) 1995 (USA) @@ -4687,7 +4687,7 @@ pontoon astormbl // BOOTLEG astormb2 // BOOTLEG shdancbl // BOOTLEG -shdancbla // BOOTLEG +shdancbla // BOOTLEG mwalkbl // BOOTLEG @@ -4812,7 +4812,7 @@ spidman // 1991.?? Spiderman (World) spidmanu // 1991.09 Spiderman (US) spidmanj // 1991.09 Spiderman (Japan) f1en // 1991.?? F-1 Exhaust Note (World) -f1enu // 1992.01 F-1 Exhaust Note (US) +f1enu // 1992.01 F-1 Exhaust Note (US) // 1991.11 F-1 Exhaust Note (Japan) arabfgt // 1992.?? Arabian Fight (World) arabfgtu // 1992.03 Arabian Fight (US) @@ -5423,7 +5423,7 @@ radirgya // 2005.12.04 Radirgy (Rev A) mushik2e // 2005.?? Mushiking The King Of Beetles II ENG (Ver. 1.001) mushi2ea // 2005.?? Mushiking The King Of Beetles II ENG (Ver. 2.001) // 2005.?? MushiKing The King Of Beetle III -mushi2k5 // 2005.?? MushiKing The King Of Beetle 2K5 1st +mushi2k5 // 2005.?? MushiKing The King Of Beetle 2K5 1st kurucham // 2006.03 Kurukuru Chameleon trgheart // 2006.05 Trigger Heart Exelica (Rev A) zunou // 2006.07 Touch de Zunou @@ -5482,7 +5482,7 @@ vf4c // 2002.01.31 Virtua Fighter 4 (Rev C) (cartridge) kingrt66 // 2002.02 The King of Route 66 (Rev A) // 2002.02.14 Initial D Arcade Stage (Japan) initd // 2002.03 Initial D Arcade Stage (Japan) (Rev B) -initdo // 2002.03 Initial D Arcade Stage (Japan) +initdo // 2002.03 Initial D Arcade Stage (Japan) // 2002.06 World Club Champion Football Serie A 2001-2002 soulsurf // 2002.07 Soul Surfer initdexp // 2002.07.18 Initial D Arcade Stage (Export) (Rev A) @@ -5893,8 +5893,8 @@ wndrplnt // (c) 1987 Data East Corporation (Japan) chelnov // (c) 1988 Data East USA (World) chelnovu // (c) 1988 Data East USA (US) chelnovj // (c) 1988 Data East Corporation (Japan) -chelnovjbl // bootleg -chelnovjbla // bootleg +chelnovjbl // bootleg +chelnovjbla // bootleg // the following ones all run on similar hardware hbarrel // (c) 1987 Data East USA (US) hbarrelw // (c) 1987 Data East Corporation (World) @@ -6356,7 +6356,7 @@ simpsons // GX072 (c) 1991 simpsons4pa // GX072 (c) 1991 simpsons2p // GX072 (c) 1991 simpsons2p2 // GX072 (c) 1991 -simpsons2p3 // GX072 (c) 1991 +simpsons2p3 // GX072 (c) 1991 simpsons2pa // GX072 (c) 1991 (Asia) simpsons2pj // GX072 (c) 1991 (Japan) esckids // GX975 (c) 1991 (Asia) @@ -6364,7 +6364,7 @@ esckidsj // GX975 (c) 1991 (Japan) vendetta // GX081 (c) 1991 (World) vendettar // GX081 (c) 1991 (World) vendetta2p // GX081 (c) 1991 (World) -vendetta2peba // GX081 (c) 1991 (World) +vendetta2peba // GX081 (c) 1991 (World) vendetta2pu // GX081 (c) 1991 (Asia) vendetta2pd // GX081 (c) 1991 (Asia) vendettaj // GX081 (c) 1991 (Japan) @@ -7936,7 +7936,7 @@ bigbang // UPL-93091 (c) 1993 NMK tdragon // (c) 1991 NMK / Tecmo tdragon1 // (c) 1991 NMK / Tecmo hachamf // (c) 1991 NMK -hachamfb // bootleg +hachamfb // bootleg macross // (c) 1992 Banpresto riot // (c) 1992 NMK gunnail // (c) 1993 NMK / Tecmo @@ -8345,7 +8345,7 @@ goodejan // (c) 1991 Seibu/Tecmo goodejana // (c) 1991 Seibu/Tecmo raiden2 // (c) 1993 Seibu Kaihatsu + Fabtek license -raiden2u // (c) 1993 Seibu Kaihatsu + Fabtek license +raiden2u // (c) 1993 Seibu Kaihatsu + Fabtek license raiden2hk // (c) 1993 Seibu Kaihatsu + Metrotainment license raiden2j // (c) 1993 Seibu Kaihatsu raiden2i // (c) 1993 Seibu Kaihatsu @@ -8354,8 +8354,8 @@ raiden2ea // (c) 1993 Seibu Kaihatsu raiden2eu // (c) 1993 Seibu Kaihatsu + Fabtek license raiden2eua // (c) 1993 Seibu Kaihatsu + Fabtek license raiden2nl // (c) 1993 Seibu Kaihatsu -raiden2g // (c) 1993 Seibu Kaihatsu + Tuning license -raiden2dx // (c) 1993 Seibu Kaihatsu +raiden2g // (c) 1993 Seibu Kaihatsu + Tuning license +raiden2dx // (c) 1993 Seibu Kaihatsu raidendx // (c) 1994 Seibu Kaihatsu raidendxk // (c) 1994 Seibu Kaihatsu @@ -8377,7 +8377,7 @@ xsedae // (c) 1995 Dream Island // Newer V33 PCB with COP3 protection r2dx_v33 // (c) 1996 Seibu Kaihatsu -r2dx_v33_r2 // (c) 1996 Seibu Kaihatsu +r2dx_v33_r2 // (c) 1996 Seibu Kaihatsu nzeroteam // (c) 1997 Seibu Kaihatsu zerotm2k // (c) 2000 Seibu Kaihatsu @@ -8687,7 +8687,7 @@ tengai // (c) 1996 tengaij // (c) 1996 // Semicom games on "Psikyo 68020"-like hardware baryon // (c) 1997 SemiCom -baryona // (c) 1997 SemiCom +baryona // (c) 1997 SemiCom dreamwld // (c) 2000 SemiCom rolcrush // (c) 1999 Trust @@ -9061,7 +9061,7 @@ koikois // (c) 1995 Seta nratechu // (c) 1996 Seta dcrown // 199? unknown dcrowna // 199? unknown -gostop // 2001 Visco +gostop // 2001 Visco // R3000 + ST-0016 srmp5 // (c) 199? Seta speglsht // (c) 1994 Seta @@ -9223,7 +9223,7 @@ fantasia // (c) 1994 Comad & New Japan System fantasiaa // (c) 1994 Comad & New Japan System fantasiab // (c) 1994 Comad & New Japan System supmodel // (c) 1994 Comad & New Japan System -fantasian // +fantasian // newfant // (c) 1994 Comad & New Japan System newfanta // (c) 1995 Comad & New Japan System fantsy95 // (c) 1995 Hi-max Technology Inc. @@ -9708,7 +9708,7 @@ orlegende // orlegendc // orlegendca // orlegend111c // -orlegend111t // +orlegend111t // orlegend105k // drgw2 // (c) 1997 Dragon World 2 dw2v100x // @@ -10312,9 +10312,9 @@ eggventr7 // (c) 1997 The Game Room eggventr2 // (c) 1997 The Game Room eggventra // (c) 1997 The Game Room (Allied Leisure license) eggventrd // (c) 1997 The Game Room -hostinv // (c) 1998 The Game Room +hostinv // (c) 1998 The Game Room calchase // (c) 1999 The Game Room -eggsplc // (c) 2002 The Game Room +eggsplc // (c) 2002 The Game Room ripribit // (c) 1997 LAI Games cfarm // (c) 1999 LAI Games cclownz // (c) 1999 LAI Games diff --git a/src/mame/mame.mak b/src/mame/mame.mak index 9682fa710cf..a316b3493d3 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1210,7 +1210,7 @@ $(MAMEOBJ)/igs.a: \ $(DRIVERS)/igs_m036.o \ $(DRIVERS)/iqblock.o $(VIDEO)/iqblock.o \ $(DRIVERS)/lordgun.o $(VIDEO)/lordgun.o \ - $(DRIVERS)/pgm.o $(VIDEO)/pgm.o $(MACHINE)/pgmprot_igs027a_type1.o $(MACHINE)/pgmprot_igs027a_type2.o $(MACHINE)/pgmprot_igs027a_type3.o $(MACHINE)/pgmprot_igs025_igs012.o $(MACHINE)/pgmprot_igs025_igs022.o $(MACHINE)/pgmprot_igs025_igs028.o $(MACHINE)/pgmprot_orlegend.o \ + $(DRIVERS)/pgm.o $(VIDEO)/pgm.o $(MACHINE)/pgmprot_igs027a_type1.o $(MACHINE)/pgmprot_igs027a_type2.o $(MACHINE)/pgmprot_igs027a_type3.o $(MACHINE)/pgmprot_igs025_igs012.o $(MACHINE)/pgmprot_igs025_igs022.o $(MACHINE)/pgmprot_igs025_igs028.o $(MACHINE)/pgmprot_orlegend.o \ $(DRIVERS)/pgm2.o \ $(DRIVERS)/spoker.o \ $(MACHINE)/igs036crypt.o \ diff --git a/src/mame/video/antic.c b/src/mame/video/antic.c index ae247c135fe..f6db0390f6d 100644 --- a/src/mame/video/antic.c +++ b/src/mame/video/antic.c @@ -58,11 +58,11 @@ void antic_device::device_start() { m_gtia = machine().device(m_gtia_tag); assert(m_gtia); - + m_bitmap = auto_bitmap_ind16_alloc(machine(), machine().first_screen()->width(), machine().first_screen()->height()); - + m_cclk_expand = auto_alloc_array_clear(machine(), UINT32, 21 * 256); - + m_pf_21 = &m_cclk_expand[ 0 * 256]; m_pf_x10b = &m_cclk_expand[ 1 * 256]; m_pf_3210b2 = &m_cclk_expand[ 3 * 256]; @@ -72,11 +72,11 @@ void antic_device::device_start() m_pf_gtia1 = &m_cclk_expand[18 * 256]; m_pf_gtia2 = &m_cclk_expand[19 * 256]; m_pf_gtia3 = &m_cclk_expand[20 * 256]; - + m_used_colors = auto_alloc_array(machine(), UINT8, 21 * 256); - + memset(m_used_colors, 0, 21 * 256 * sizeof(UINT8)); - + m_uc_21 = &m_used_colors[ 0 * 256]; m_uc_x10b = &m_used_colors[ 1 * 256]; m_uc_3210b2 = &m_used_colors[ 3 * 256]; @@ -86,24 +86,24 @@ void antic_device::device_start() m_uc_g1 = &m_used_colors[18 * 256]; m_uc_g2 = &m_used_colors[19 * 256]; m_uc_g3 = &m_used_colors[20 * 256]; - + LOG(("atari cclk_init\n")); cclk_init(); - + for (int i = 0; i < 64; i++) m_prio_table[i] = auto_alloc_array_clear(machine(), UINT8, 8*256); - + LOG(("atari prio_init\n")); prio_init(); - + for (int i = 0; i < machine().first_screen()->height(); i++) m_video[i] = auto_alloc_clear(machine(), VIDEO); - + /* save states */ save_pointer(NAME((UINT8 *) &m_r), sizeof(m_r)); save_pointer(NAME((UINT8 *) &m_w), sizeof(m_w)); // TODO: save VIDEO items - + save_item(NAME(m_tv_artifacts)); save_item(NAME(m_render1)); save_item(NAME(m_render2)); @@ -556,7 +556,7 @@ void antic_device::prio_init() { int i, j, pm, p, c; const UINT8 * prio; - + /* 32 priority bit combinations */ for( i = 0; i < 32; i++ ) { @@ -575,10 +575,10 @@ void antic_device::prio_init() } m_prio_table[i][(j << 8) + pm] = c; if( (c==PL0 || c==P000 || c==P001 || c==P010 || c==P011) && - (pm & (P0+P1))==(P0+P1)) + (pm & (P0+P1))==(P0+P1)) c = EOR; if( (c==PL2 || c==P200 || c==P201 || c==P210 || c==P211) && - (pm & (P2+P3))==(P2+P3)) + (pm & (P2+P3))==(P2+P3)) c = EOR; m_prio_table[32 + i][(j << 8) + pm] = c; } @@ -598,7 +598,7 @@ void antic_device::cclk_init() static const UINT8 _pf_310b[4] = {PBK,PF0,PF1,PF3}; int i; UINT8 * dst; - + /* setup color translation for the ANTIC modes */ for( i = 0; i < 256; i++ ) { @@ -608,7 +608,7 @@ void antic_device::cclk_init() *dst++ = _pf_21[(i>>4)&3]; *dst++ = _pf_21[(i>>2)&3]; *dst++ = _pf_21[(i>>0)&3]; - + /****** 4 color text (4,5) with pf2, D, E **********/ dst = (UINT8 *)&m_pf_x10b[0x000+i]; *dst++ = _pf_210b[(i>>6)&3]; @@ -620,7 +620,7 @@ void antic_device::cclk_init() *dst++ = _pf_310b[(i>>4)&3]; *dst++ = _pf_310b[(i>>2)&3]; *dst++ = _pf_310b[(i>>0)&3]; - + /****** pf0 color text (6,7), 9, B, C **********/ dst = (UINT8 *)&m_pf_3210b2[0x000+i*2]; *dst++ = (i&0x80)?PF0:PBK; @@ -631,7 +631,7 @@ void antic_device::cclk_init() *dst++ = (i&0x04)?PF0:PBK; *dst++ = (i&0x02)?PF0:PBK; *dst++ = (i&0x01)?PF0:PBK; - + /****** pf1 color text (6,7), 9, B, C **********/ dst = (UINT8 *)&m_pf_3210b2[0x200+i*2]; *dst++ = (i&0x80)?PF1:PBK; @@ -642,7 +642,7 @@ void antic_device::cclk_init() *dst++ = (i&0x04)?PF1:PBK; *dst++ = (i&0x02)?PF1:PBK; *dst++ = (i&0x01)?PF1:PBK; - + /****** pf2 color text (6,7), 9, B, C **********/ dst = (UINT8 *)&m_pf_3210b2[0x400+i*2]; *dst++ = (i&0x80)?PF2:PBK; @@ -653,7 +653,7 @@ void antic_device::cclk_init() *dst++ = (i&0x04)?PF2:PBK; *dst++ = (i&0x02)?PF2:PBK; *dst++ = (i&0x01)?PF2:PBK; - + /****** pf3 color text (6,7), 9, B, C **********/ dst = (UINT8 *)&m_pf_3210b2[0x600+i*2]; *dst++ = (i&0x80)?PF3:PBK; @@ -664,7 +664,7 @@ void antic_device::cclk_init() *dst++ = (i&0x04)?PF3:PBK; *dst++ = (i&0x02)?PF3:PBK; *dst++ = (i&0x01)?PF3:PBK; - + /****** 4 color graphics 4 cclks (8) **********/ dst = (UINT8 *)&m_pf_210b4[i*4]; *dst++ = _pf_210b[(i>>6)&3]; @@ -683,7 +683,7 @@ void antic_device::cclk_init() *dst++ = _pf_210b[(i>>0)&3]; *dst++ = _pf_210b[(i>>0)&3]; *dst++ = _pf_210b[(i>>0)&3]; - + /****** 4 color graphics 2 cclks (A) **********/ dst = (UINT8 *)&m_pf_210b2[i*2]; *dst++ = _pf_210b[(i>>6)&3]; @@ -694,43 +694,43 @@ void antic_device::cclk_init() *dst++ = _pf_210b[(i>>2)&3]; *dst++ = _pf_210b[(i>>0)&3]; *dst++ = _pf_210b[(i>>0)&3]; - + /****** high resolution graphics (F) **********/ dst = (UINT8 *)&m_pf_1b[i]; *dst++ = _pf_1b[(i>>6)&3]; *dst++ = _pf_1b[(i>>4)&3]; *dst++ = _pf_1b[(i>>2)&3]; *dst++ = _pf_1b[(i>>0)&3]; - + /****** gtia mode 1 **********/ dst = (UINT8 *)&m_pf_gtia1[i]; *dst++ = GT1+((i>>4)&15); *dst++ = GT1+((i>>4)&15); *dst++ = GT1+(i&15); *dst++ = GT1+(i&15); - + /****** gtia mode 2 **********/ dst = (UINT8 *)&m_pf_gtia2[i]; *dst++ = GT2+((i>>4)&15); *dst++ = GT2+((i>>4)&15); *dst++ = GT2+(i&15); *dst++ = GT2+(i&15); - + /****** gtia mode 3 **********/ dst = (UINT8 *)&m_pf_gtia3[i]; *dst++ = GT3+((i>>4)&15); *dst++ = GT3+((i>>4)&15); *dst++ = GT3+(i&15); *dst++ = GT3+(i&15); - + } - + /* setup used color tables */ for( i = 0; i < 256; i++ ) { /* used colors in text modes 2,3 */ m_uc_21[i] = (i) ? PF2 | PF1 : PF2; - + /* used colors in text modes 4,5 and graphics modes D,E */ switch( i & 0x03 ) { @@ -756,7 +756,7 @@ void antic_device::cclk_init() case 0x80: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break; case 0xc0: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break; } - + /* used colors in text modes 6,7 and graphics modes 9,B,C */ if( i ) { @@ -765,7 +765,7 @@ void antic_device::cclk_init() m_uc_3210b2[0x400+i*2] |= PF2; m_uc_3210b2[0x600+i*2] |= PF3; } - + /* used colors in graphics mode 8 */ switch( i & 0x03 ) { @@ -791,7 +791,7 @@ void antic_device::cclk_init() case 0x80: m_uc_210b4[i*4] |= PF1; break; case 0xc0: m_uc_210b4[i*4] |= PF2; break; } - + /* used colors in graphics mode A */ switch( i & 0x03 ) { @@ -817,11 +817,11 @@ void antic_device::cclk_init() case 0x80: m_uc_210b2[i*2] |= PF1; break; case 0xc0: m_uc_210b2[i*2] |= PF2; break; } - + /* used colors in graphics mode F */ if( i ) m_uc_1b[i] |= PF1; - + /* used colors in GTIA graphics modes */ /* GTIA 1 is 16 different luminances with hue of colbk */ m_uc_g1[i] = 0x00; @@ -838,7 +838,7 @@ void antic_device::cclk_init() case 0x07: m_uc_g2[i] = 0x08; break; default: m_uc_g2[i] = 0x00; } - + /* GTIA 3 is 16 different hues with luminance of colbk */ m_uc_g3[i] = 0x00; } @@ -1293,16 +1293,16 @@ void antic_device::render(address_space &space, int param1, int param2, int para { VIDEO *video = m_video[m_scanline]; int add_bytes = 0, erase = 0; - + if (param3 == 0 || param2 <= 1) { mode_0(space, video); return; } - + if ((param3 == 1 || param3 == 2) && param1) param3++; - + switch (param3) { case 1: @@ -1318,7 +1318,7 @@ void antic_device::render(address_space &space, int param1, int param2, int para erase = 0; break; } - + switch (param2) { case 0x02: @@ -1387,10 +1387,10 @@ UINT32 antic_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, { UINT32 new_tv_artifacts = screen.ioport("artifacts")->read_safe(0); copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect); - + if (m_tv_artifacts != new_tv_artifacts) m_tv_artifacts = new_tv_artifacts; - + return 0; } @@ -1404,7 +1404,7 @@ void antic_device::artifacts_gfx(UINT8 *src, UINT8 *dst, int width) UINT8 atari_C = b + c; UINT8 atari_D = m_gtia->get_w_colbk(); UINT16 *color_lookup = m_gtia->get_color_lookup(); - + for (int x = 0; x < width * 4; x++) { n = *src++; @@ -1478,7 +1478,7 @@ void antic_device::artifacts_txt(UINT8 * src, UINT8 * dst, int width) UINT8 atari_C = b+c; UINT8 atari_D = m_gtia->get_w_colpf2(); UINT16 *color_lookup = m_gtia->get_color_lookup(); - + for (int x = 0; x < width * 4; x++) { n = *src++; @@ -1550,7 +1550,7 @@ void antic_device::linerefresh() UINT32 *dst; UINT32 scanline[4 + (HCHARS * 2) + 4]; UINT16 *color_lookup = m_gtia->get_color_lookup(); - + /* increment the scanline */ if( ++m_scanline == machine().first_screen()->height() ) { @@ -1560,14 +1560,14 @@ void antic_device::linerefresh() /* count frames gone since last write to hitclr */ m_gtia->count_hitclr_frames(); } - + if( m_scanline < MIN_Y || m_scanline > MAX_Y ) return; - + y = m_scanline - MIN_Y; src = &m_cclock[PMOFFSET - m_hscrol_old + 12]; dst = scanline; - + if( m_tv_artifacts ) { if( (m_cmd & 0x0f) == 2 || (m_cmd & 0x0f) == 3 ) @@ -1648,12 +1648,12 @@ void antic_device::linerefresh() dst[1] = color_lookup[PBK] | color_lookup[PBK] << 16; dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16; dst[3] = color_lookup[PBK] | color_lookup[PBK] << 16; - + draw_scanline8(*m_bitmap, 12, y, MIN(m_bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL); } -#define ANTIC_TIME_FROM_CYCLES(cycles) \ +#define ANTIC_TIME_FROM_CYCLES(cycles) \ (attotime)(machine().first_screen()->scan_period() * (cycles) / CYCLES_PER_LINE) void antic_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) @@ -1714,7 +1714,7 @@ TIMER_CALLBACK_MEMBER( antic_device::line_done ) LOG((" @cycle #%3d release CPU\n", cycle())); /* release the CPU (held for emulating cycles stolen by ANTIC DMA) */ machine().scheduler().trigger(TRIGGER_STEAL); - + /* refresh the display (translate color clocks to pixels) */ linerefresh(); } @@ -1748,11 +1748,11 @@ TIMER_CALLBACK_MEMBER( antic_device::steal_cycles ) TIMER_CALLBACK_MEMBER( antic_device::scanline_render ) { address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); - + LOG((" @cycle #%3d render mode $%X lines to go #%d\n", cycle(), (m_cmd & 0x0f), m_modelines)); - + render(space, m_render1, m_render2, m_render3); - + /* if player/missile graphics is enabled */ if( m_scanline < 256 && (m_w.dmactl & (DMA_PLAYER|DMA_MISSILE)) ) { @@ -1796,10 +1796,10 @@ TIMER_CALLBACK_MEMBER( antic_device::scanline_render ) } } } - + if (m_scanline >= VBL_END && m_scanline < 256) m_gtia->render((UINT8 *)m_pmbits + PMOFFSET, (UINT8 *)m_cclock + PMOFFSET - m_hscrol_old, (UINT8 *)m_prio_table[m_gtia->get_w_prior() & 0x3f], (UINT8 *)&m_pmbits); - + m_steal_cycles += CYCLES_REFRESH; LOG((" run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles)); timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles), TIMER_CYCLE_STEAL); @@ -1856,7 +1856,7 @@ void antic_device::scanline_dma(int param) m_render3 = m_w.dmactl & 3; UINT8 vscrol_subtract = 0; UINT8 new_cmd; - + new_cmd = RDANTIC(space); m_doffs = (m_doffs + 1) & DOFFS; /* steal at one clock cycle from the CPU for fetching the command */ @@ -1894,7 +1894,7 @@ void antic_device::scanline_dma(int param) } /* Set the ANTIC mode renderer function */ m_render2 = new_cmd & ANTIC_MODE; - + switch( new_cmd & ANTIC_MODE ) { case 0x00: @@ -2048,11 +2048,11 @@ void antic_device::scanline_dma(int param) m_render2 = 0; m_render3 = 0; } - + m_r.nmist &= ~DLI_NMI; if (m_modelines == 1 && (m_cmd & m_w.nmien & DLI_NMI)) timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_DLI_NMI), TIMER_ISSUE_DLI); - + timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSTART), TIMER_LINE_REND); } @@ -2068,24 +2068,24 @@ void antic_device::scanline_dma(int param) void antic_device::generic_interrupt(int button_count) { LOG(("ANTIC #%3d @cycle #%d scanline interrupt\n", m_scanline, cycle())); - + if( m_scanline < VBL_START ) { scanline_dma(0); return; } - + if( m_scanline == VBL_START ) { /* specify buttons relevant to this Atari variant */ m_gtia->button_interrupt(button_count, machine().root_device().ioport("djoy_b")->read_safe(0)); - + /* do nothing new for the rest of the frame */ m_modelines = machine().first_screen()->height() - VBL_START; m_render1 = 0; m_render2 = 0; m_render3 = 0; - + /* if the CPU want's to be interrupted at vertical blank... */ if( m_w.nmien & VBL_NMI ) { @@ -2095,8 +2095,7 @@ void antic_device::generic_interrupt(int button_count) machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); } } - + /* refresh the display (translate color clocks to pixels) */ linerefresh(); } - diff --git a/src/mame/video/antic.h b/src/mame/video/antic.h index 2c9bc380720..bc042ea6238 100644 --- a/src/mame/video/antic.h +++ b/src/mame/video/antic.h @@ -3,7 +3,7 @@ Atari 400/800 ANTIC video controller - + Juergen Buchmueller, June 1998 ***************************************************************************/ @@ -293,12 +293,11 @@ m_w.chbasl++ /* erase a number of color clocks to background color PBK */ -#define ERASE(size) \ - for (int i = 0; i < size; i++) \ - { \ +#define ERASE(size) \ + for (int i = 0; i < size; i++) \ + { \ *dst++ = (PBK << 24) | (PBK << 16) | (PBK << 8) | PBK; \ - } \ - + } #define ZAP48() \ dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ dst[ 0] = (PBK << 24) | (PBK << 16) | (PBK << 8) | PBK; \ @@ -309,11 +308,10 @@ dst[47] = (PBK << 24) | (PBK << 16) | (PBK << 8) | PBK #define REP(FUNC, size) \ - for (int i = 0; i < size; i++) \ - { \ - FUNC(i); \ - } \ - + for (int i = 0; i < size; i++) \ + { \ + FUNC(i); \ + } struct ANTIC_R { @@ -379,7 +377,7 @@ public: UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void generic_interrupt(int button_count); - + private: static const device_timer_id TIMER_CYCLE_STEAL = 0; static const device_timer_id TIMER_ISSUE_DLI = 1; @@ -454,7 +452,7 @@ private: UINT8 *m_uc_g2; /* used colors for gfx GTIA 2 */ UINT8 *m_uc_g3; /* used colors for gfx GTIA 3 */ bitmap_ind16 *m_bitmap; - + void prio_init(); void cclk_init(); diff --git a/src/mame/video/battlera.c b/src/mame/video/battlera.c index c1a0e45c95f..1187f6fbc2e 100644 --- a/src/mame/video/battlera.c +++ b/src/mame/video/battlera.c @@ -1,2 +1 @@ // delete me - diff --git a/src/mame/video/decmxc06.h b/src/mame/video/decmxc06.h index 54405fb3683..e7d5013b03f 100644 --- a/src/mame/video/decmxc06.h +++ b/src/mame/video/decmxc06.h @@ -16,7 +16,7 @@ public: void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram16, int pri_mask, int pri_val, int col_mask ); void draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram, int pri_mask, int pri_val, int col_mask ); void set_pri_type( int type ) { m_priority_type = type; } - + protected: virtual void device_start(); virtual void device_reset(); diff --git a/src/mame/video/dooyong.c b/src/mame/video/dooyong.c index e211fc004bf..96c913041dd 100644 --- a/src/mame/video/dooyong.c +++ b/src/mame/video/dooyong.c @@ -224,8 +224,7 @@ inline void dooyong_state::lastday_get_tile_info(tile_data &tileinfo, int tile_i flags = ((attr & 0x02) ? TILE_FLIPX : 0) | ((attr & 0x04) ? TILE_FLIPY : 0); } else - { - + { /* primella */ /* Tiles take two bytes in ROM: MSB LSB @@ -237,7 +236,7 @@ inline void dooyong_state::lastday_get_tile_info(tile_data &tileinfo, int tile_i Y = y flip */ int codemask = 0x03; int palmask = 0x3c; - + if (m_gfxdecode->gfx(1)->depth() == 256) // pop bingo has an 8bpp layer and uses what would be the low palette bit to address more tiles (girls 4,5,6 in bonus game) { codemask = 0x07; diff --git a/src/mame/video/fuukifg.c b/src/mame/video/fuukifg.c index 017dc061065..eeb0ee29454 100644 --- a/src/mame/video/fuukifg.c +++ b/src/mame/video/fuukifg.c @@ -1,4 +1,4 @@ -/* +/* */ #include "emu.h" @@ -65,7 +65,7 @@ void fuukivid_device::device_reset() 6.w Tile Code - for FG3 hardware + for FG3 hardware 6.w fe-- ---- ---- ---- Tile Bank --dc ba98 7654 3210 Tile Code @@ -180,4 +180,4 @@ void fuukivid_device::buffer_sprites(void) { memcpy(m_sprram_old2, m_sprram_old, 0x2000); memcpy(m_sprram_old, m_sprram, 0x2000); -} \ No newline at end of file +} diff --git a/src/mame/video/fuukifg.h b/src/mame/video/fuukifg.h index fd7a86714df..8db1c87353c 100644 --- a/src/mame/video/fuukifg.h +++ b/src/mame/video/fuukifg.h @@ -9,10 +9,10 @@ public: // static configuration static void static_set_gfxdecode_tag(device_t &device, const char *tag); - + void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip_screen, UINT32* tilebank); UINT16* m_sprram; - UINT16* m_sprram_old; + UINT16* m_sprram_old; UINT16* m_sprram_old2; @@ -25,7 +25,7 @@ public: { return m_sprram[offset]; } - + void buffer_sprites(void); protected: @@ -40,4 +40,3 @@ extern const device_type FUUKI_VIDEO; #define MCFG_FUUKI_VIDEO_GFXDECODE(_gfxtag) \ fuukivid_device::static_set_gfxdecode_tag(*device, "^" _gfxtag); - diff --git a/src/mame/video/fuukifg3.c b/src/mame/video/fuukifg3.c index 1337c149d2a..1cc275caa40 100644 --- a/src/mame/video/fuukifg3.c +++ b/src/mame/video/fuukifg3.c @@ -90,8 +90,8 @@ WRITE32_MEMBER(fuuki32_state::fuuki32_vram_3_w){ fuuki32_vram_w(offset, data, me void fuuki32_state::video_start() { -// m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); -// m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); +// m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); +// m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); diff --git a/src/mame/video/gtia.c b/src/mame/video/gtia.c index ec73fb16f15..d4cfab69181 100644 --- a/src/mame/video/gtia.c +++ b/src/mame/video/gtia.c @@ -131,7 +131,7 @@ void gtia_device::device_start() { m_read_cb.resolve(); m_write_cb.resolve(); - + save_item(NAME(m_r.m0pf)); save_item(NAME(m_r.m1pf)); save_item(NAME(m_r.m2pf)); @@ -218,7 +218,7 @@ void gtia_device::device_start() save_item(NAME(m_h.vdelay_p1)); save_item(NAME(m_h.vdelay_p2)); save_item(NAME(m_h.vdelay_p3)); - + save_item(NAME(m_lumpf1)); save_item(NAME(m_huepm0)); save_item(NAME(m_huepm1)); @@ -226,9 +226,9 @@ void gtia_device::device_start() save_item(NAME(m_huepm3)); save_item(NAME(m_huepm4)); save_item(NAME(m_huepf2)); - save_item(NAME(m_huebk)); + save_item(NAME(m_huebk)); - save_item(NAME(m_color_lookup)); + save_item(NAME(m_color_lookup)); machine().save().register_postload(save_prepost_delegate(FUNC(gtia_device::gtia_postload), this)); } @@ -291,14 +291,14 @@ void gtia_device::button_interrupt(int button_count, UINT8 button_port) m_r.but[i] = 1; m_r.but[i] &= BIT(button_port, i); } - + /* button registers for xl/xe */ if (button_count == 2) { m_r.but[2] = 1; /* not used on xl/xe */ m_r.but[3] = 0; /* 1 if external cartridge is inserted */ } - + } @@ -967,7 +967,7 @@ void gtia_device::render(UINT8 *src, UINT8 *dst, UINT8 *prio, UINT8 *pmbits) player_render(m_h.grafp2, m_w.sizep2 + 1, GTIA_P2, &pmbits[m_w.hposp2]); if (m_h.grafp3) player_render(m_h.grafp3, m_w.sizep3 + 1, GTIA_P3, &pmbits[m_w.hposp3]); - + if (m_h.grafm0) missile_render(m_h.grafm0, m_w.sizem + 1, GTIA_M0, &pmbits[m_w.hposm0]); if (m_h.grafm1) diff --git a/src/mame/video/gtia.h b/src/mame/video/gtia.h index 7787e1a6588..26455895028 100644 --- a/src/mame/video/gtia.h +++ b/src/mame/video/gtia.h @@ -127,10 +127,10 @@ class gtia_device : public device_t public: // construction/destruction gtia_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + template static devcb_base &set_read_callback(device_t &device, _Object object) { return downcast(device).m_read_cb.set_callback(object); } template static devcb_base &set_write_callback(device_t &device, _Object object) { return downcast(device).m_write_cb.set_callback(object); } - + DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); @@ -143,16 +143,16 @@ public: UINT8 get_w_prior() { return m_w.prior; } void count_hitclr_frames() { m_h.hitclr_frames++; } void button_interrupt(int button_count, UINT8 button_port); - + void render(UINT8 *src, UINT8 *dst, UINT8 *pmbits, UINT8 *prio); - + protected: // device-level overrides virtual void device_start(); virtual void device_reset(); - + void gtia_postload(); - + int is_ntsc(); void recalc_p0(); void recalc_p1(); @@ -162,21 +162,21 @@ protected: void recalc_m1(); void recalc_m2(); void recalc_m3(); - + inline void player_render(UINT8 gfx, int size, UINT8 color, UINT8 *dst); inline void missile_render(UINT8 gfx, int size, UINT8 color, UINT8 *dst); - + private: gtia_readregs m_r; /* read registers */ gtia_writeregs m_w; /* write registers */ gtia_helpervars m_h; /* helper variables */ - + UINT8 m_lumpf1; UINT8 m_huepm0, m_huepm1, m_huepm2, m_huepm3, m_huepm4; UINT8 m_huepf2, m_huebk; - - UINT16 m_color_lookup[256]; /* color lookup table */ // probably better fit to ANTIC, but it remains here for the moment... - + + UINT16 m_color_lookup[256]; /* color lookup table */ // probably better fit to ANTIC, but it remains here for the moment... + devcb_read8 m_read_cb; devcb_write8 m_write_cb; }; diff --git a/src/mame/video/k054156_k054157_k056832.c b/src/mame/video/k054156_k054157_k056832.c index 7e3aa03de1e..1fc1f05ce21 100644 --- a/src/mame/video/k054156_k054157_k056832.c +++ b/src/mame/video/k054156_k054157_k056832.c @@ -1269,7 +1269,7 @@ int k056832_device::update_linemap( screen_device &screen, _BitmapClass &bitmap, */ { bitmap_ind16 *pixmap; - + UINT8 code_transparent, code_opaque; const pen_t *pal_ptr; const UINT8 *src_ptr; diff --git a/src/mame/video/legionna.c b/src/mame/video/legionna.c index 00bc607b293..60bdc8c2fee 100644 --- a/src/mame/video/legionna.c +++ b/src/mame/video/legionna.c @@ -63,10 +63,10 @@ WRITE16_MEMBER(legionna_state::denjinmk_setgfxbank) WRITE16_MEMBER(legionna_state::videowrite_cb_w) { - // AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data") - // AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data") - // AM_RANGE(0x102000, 0x1027ff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data") - // AM_RANGE(0x102800, 0x1037ff) AM_RAM // _WRITE(legionna_text_w) AM_SHARE("textram") + // AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data") + // AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data") + // AM_RANGE(0x102000, 0x1027ff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data") + // AM_RANGE(0x102800, 0x1037ff) AM_RAM // _WRITE(legionna_text_w) AM_SHARE("textram") if (offset < 0x800 / 2) { @@ -194,7 +194,6 @@ TILE_GET_INFO_MEMBER(legionna_state::get_text_tile_info) VIDEO_START_MEMBER(legionna_state,legionna) { - m_back_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); m_fore_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); m_mid_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); @@ -220,7 +219,6 @@ VIDEO_START_MEMBER(legionna_state,legionna) VIDEO_START_MEMBER(legionna_state,denjinmk) { - m_back_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); m_fore_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); m_mid_data = auto_alloc_array_clear(machine(), UINT16, 0x800/2); @@ -499,9 +497,6 @@ UINT32 legionna_state::screen_update_legionna(screen_device &screen, bitmap_ind1 UINT32 legionna_state::screen_update_godzilla(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - - - bitmap.fill(0x0200, cliprect); screen.priority().fill(0, cliprect); @@ -521,8 +516,6 @@ UINT32 legionna_state::screen_update_godzilla(screen_device &screen, bitmap_ind1 UINT32 legionna_state::screen_update_grainbow(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - - bitmap.fill(m_palette->black_pen(), cliprect); screen.priority().fill(0, cliprect); diff --git a/src/mame/video/mario.c b/src/mame/video/mario.c index e8fce38b271..d5970aaef1f 100644 --- a/src/mame/video/mario.c +++ b/src/mame/video/mario.c @@ -193,7 +193,7 @@ void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ - + code = m_spriteram[offs + 2]; color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; flipx = (m_spriteram[offs + 1] & 0x80); @@ -216,8 +216,8 @@ void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, x = m_spriteram[offs + 0]; y = 240 - y; /* logical screen position */ - // y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ - // x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ + // y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ + // x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ code = (m_spriteram[offs + 2] & 0x7f) | ((m_spriteram[offs + 1] & 0x40) << 1); // upper tile bit is where the flipy bit goes on mario color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; @@ -237,7 +237,6 @@ void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, } else { - m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, code, color, diff --git a/src/mame/video/model3.c b/src/mame/video/model3.c index b8207e25eb3..b8a86feecf0 100644 --- a/src/mame/video/model3.c +++ b/src/mame/video/model3.c @@ -3,7 +3,7 @@ #include "video/rgbutil.h" #include "includes/model3.h" -#define ENABLE_BILINEAR 1 +#define ENABLE_BILINEAR 1 #define TRI_PARAM_TEXTURE_PAGE 0x1 #define TRI_PARAM_TEXTURE_MIRROR_U 0x2 @@ -27,7 +27,7 @@ public: : poly_manager(state.machine())//, m_state(state) { m_fb = auto_bitmap_rgb32_alloc(state.machine(), width, height); - m_zb = auto_bitmap_ind32_alloc(state.machine(), width, height); + m_zb = auto_bitmap_ind32_alloc(state.machine(), width, height); } void draw(bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -67,61 +67,61 @@ void model3_state::model3_exit() FILE* file; int i; file = fopen("m3_texture_ram.bin","wb"); - for (i=0; i < 0x200000; i++) - { - fputc((UINT8)(m_texture_ram[0][i] >> 8), file); - fputc((UINT8)(m_texture_ram[0][i] >> 0), file); - } for (i=0; i < 0x200000; i++) - { - fputc((UINT8)(m_texture_ram[1][i] >> 8), file); - fputc((UINT8)(m_texture_ram[1][i] >> 0), file); - } - fclose(file); - - file = fopen("m3_displist.bin","wb"); - for (i=0; i < 0x40000; i++) - { - fputc((UINT8)(m_display_list_ram[i] >> 24), file); - fputc((UINT8)(m_display_list_ram[i] >> 16), file); - fputc((UINT8)(m_display_list_ram[i] >> 8), file); - fputc((UINT8)(m_display_list_ram[i] >> 0), file); - } - fclose(file); + { + fputc((UINT8)(m_texture_ram[0][i] >> 8), file); + fputc((UINT8)(m_texture_ram[0][i] >> 0), file); + } + for (i=0; i < 0x200000; i++) + { + fputc((UINT8)(m_texture_ram[1][i] >> 8), file); + fputc((UINT8)(m_texture_ram[1][i] >> 0), file); + } + fclose(file); + + file = fopen("m3_displist.bin","wb"); + for (i=0; i < 0x40000; i++) + { + fputc((UINT8)(m_display_list_ram[i] >> 24), file); + fputc((UINT8)(m_display_list_ram[i] >> 16), file); + fputc((UINT8)(m_display_list_ram[i] >> 8), file); + fputc((UINT8)(m_display_list_ram[i] >> 0), file); + } + fclose(file); file = fopen("m3_culling_ram.bin","wb"); - for (i=0; i < 0x100000; i++) - { - fputc((UINT8)(m_culling_ram[i] >> 24), file); - fputc((UINT8)(m_culling_ram[i] >> 16), file); - fputc((UINT8)(m_culling_ram[i] >> 8), file); - fputc((UINT8)(m_culling_ram[i] >> 0), file); - } - fclose(file); + for (i=0; i < 0x100000; i++) + { + fputc((UINT8)(m_culling_ram[i] >> 24), file); + fputc((UINT8)(m_culling_ram[i] >> 16), file); + fputc((UINT8)(m_culling_ram[i] >> 8), file); + fputc((UINT8)(m_culling_ram[i] >> 0), file); + } + fclose(file); file = fopen("m3_polygon_ram.bin","wb"); - for (i=0; i < 0x100000; i++) - { - fputc((UINT8)(m_polygon_ram[i] >> 24), file); - fputc((UINT8)(m_polygon_ram[i] >> 16), file); - fputc((UINT8)(m_polygon_ram[i] >> 8), file); - fputc((UINT8)(m_polygon_ram[i] >> 0), file); - } - fclose(file); + for (i=0; i < 0x100000; i++) + { + fputc((UINT8)(m_polygon_ram[i] >> 24), file); + fputc((UINT8)(m_polygon_ram[i] >> 16), file); + fputc((UINT8)(m_polygon_ram[i] >> 8), file); + fputc((UINT8)(m_polygon_ram[i] >> 0), file); + } + fclose(file); file = fopen("m3_vrom.bin","wb"); - for (i=0; i < 0x1000000; i++) - { - fputc((UINT8)(m_vrom[i] >> 24), file); - fputc((UINT8)(m_vrom[i] >> 16), file); - fputc((UINT8)(m_vrom[i] >> 8), file); - fputc((UINT8)(m_vrom[i] >> 0), file); - } - fclose(file); + for (i=0; i < 0x1000000; i++) + { + fputc((UINT8)(m_vrom[i] >> 24), file); + fputc((UINT8)(m_vrom[i] >> 16), file); + fputc((UINT8)(m_vrom[i] >> 8), file); + fputc((UINT8)(m_vrom[i] >> 0), file); + } + fclose(file); #endif -// invalidate_texture(0, 0, 0, 6, 5); -// invalidate_texture(1, 0, 0, 6, 5); +// invalidate_texture(0, 0, 0, 6, 5); +// invalidate_texture(1, 0, 0, 6, 5); } void model3_state::video_start() @@ -197,18 +197,18 @@ void model3_state::video_start() init_matrix_stack(); } -#define MODEL3_TILE_INFO4(address) \ +#define MODEL3_TILE_INFO4(address) \ do { \ - UINT16 *tiles = (UINT16*)&m_m3_tile_ram[address + (tile_index / 4)]; \ + UINT16 *tiles = (UINT16*)&m_m3_tile_ram[address + (tile_index / 4)]; \ UINT16 t = BYTE_REVERSE16(tiles[(tile_index & 3) ^ NATIVE_ENDIAN_VALUE_LE_BE(2,0)]); \ int tile = ((t << 1) & 0x7ffe) | ((t >> 15) & 0x1); \ int color = (t & 0x7ff0) >> 4; \ SET_TILE_INFO_MEMBER(0, tile, color, 0); \ } while (0) -#define MODEL3_TILE_INFO8(address) \ +#define MODEL3_TILE_INFO8(address) \ do { \ - UINT16 *tiles = (UINT16*)&m_m3_tile_ram[address + (tile_index / 4)]; \ + UINT16 *tiles = (UINT16*)&m_m3_tile_ram[address + (tile_index / 4)]; \ UINT16 t = BYTE_REVERSE16(tiles[(tile_index & 3) ^ NATIVE_ENDIAN_VALUE_LE_BE(2,0)]); \ int tile = ((t << 1) & 0x7ffe) | ((t >> 15) & 0x1); \ int color = (t & 0x7f00) >> 8; \ @@ -400,48 +400,48 @@ WRITE64_MEMBER(model3_state::model3_tile_w) } /* - Video registers: - - 0xF1180000: ? - 0xF1180004: ? - 0xF1180008: ? - - 0xF1180010: VBL IRQ acknowledge - - 0xF1180020: -------- x------- -------- -------- Layer 3 bitdepth (0 = 8-bit, 1 = 4-bit) - -------- -x------ -------- -------- Layer 2 bitdepth (0 = 8-bit, 1 = 4-bit) - -------- --x----- -------- -------- Layer 1 bitdepth (0 = 8-bit, 1 = 4-bit) - -------- ---x---- -------- -------- Layer 0 bitdepth (0 = 8-bit, 1 = 4-bit) - -------- ----x--- -------- -------- Layer 3 priority (0 = below 3D, 1 = above 3D) - -------- -----x-- -------- -------- Layer 2 priority (0 = below 3D, 1 = above 3D) - -------- ------x- -------- -------- Layer 1 priority (0 = below 3D, 1 = above 3D) - -------- -------x -------- -------- Layer 0 priority (0 = below 3D, 1 = above 3D) - - 0xF1180040: Foreground layer color modulation? - -------- xxxxxxxx -------- -------- Red component - -------- -------- xxxxxxxx -------- Green component - -------- -------- -------- xxxxxxxx Blue component - - 0xF1180044: Background layer color modulation? - -------- xxxxxxxx -------- -------- Red component - -------- -------- xxxxxxxx -------- Green component - -------- -------- -------- xxxxxxxx Blue component - - 0xF1180060: x------- -------- -------- -------- Layer 0 enable - -------x xxxxxxxx -------- -------- Layer 0 Y scroll position - -------- -------- -------x xxxxxxxx Layer 0 X scroll position - - 0xF1180064: x------- -------- -------- -------- Layer 1 enable - -------x xxxxxxxx -------- -------- Layer 1 Y scroll position - -------- -------- -------x xxxxxxxx Layer 1 X scroll position - - 0xF1180068: x------- -------- -------- -------- Layer 2 enable - -------x xxxxxxxx -------- -------- Layer 2 Y scroll position - -------- -------- -------x xxxxxxxx Layer 2 X scroll position - - 0xF118006C: x------- -------- -------- -------- Layer 3 enable - -------x xxxxxxxx -------- -------- Layer 3 Y scroll position - -------- -------- -------x xxxxxxxx Layer 3 X scroll position + Video registers: + + 0xF1180000: ? + 0xF1180004: ? + 0xF1180008: ? + + 0xF1180010: VBL IRQ acknowledge + + 0xF1180020: -------- x------- -------- -------- Layer 3 bitdepth (0 = 8-bit, 1 = 4-bit) + -------- -x------ -------- -------- Layer 2 bitdepth (0 = 8-bit, 1 = 4-bit) + -------- --x----- -------- -------- Layer 1 bitdepth (0 = 8-bit, 1 = 4-bit) + -------- ---x---- -------- -------- Layer 0 bitdepth (0 = 8-bit, 1 = 4-bit) + -------- ----x--- -------- -------- Layer 3 priority (0 = below 3D, 1 = above 3D) + -------- -----x-- -------- -------- Layer 2 priority (0 = below 3D, 1 = above 3D) + -------- ------x- -------- -------- Layer 1 priority (0 = below 3D, 1 = above 3D) + -------- -------x -------- -------- Layer 0 priority (0 = below 3D, 1 = above 3D) + + 0xF1180040: Foreground layer color modulation? + -------- xxxxxxxx -------- -------- Red component + -------- -------- xxxxxxxx -------- Green component + -------- -------- -------- xxxxxxxx Blue component + + 0xF1180044: Background layer color modulation? + -------- xxxxxxxx -------- -------- Red component + -------- -------- xxxxxxxx -------- Green component + -------- -------- -------- xxxxxxxx Blue component + + 0xF1180060: x------- -------- -------- -------- Layer 0 enable + -------x xxxxxxxx -------- -------- Layer 0 Y scroll position + -------- -------- -------x xxxxxxxx Layer 0 X scroll position + + 0xF1180064: x------- -------- -------- -------- Layer 1 enable + -------x xxxxxxxx -------- -------- Layer 1 Y scroll position + -------- -------- -------x xxxxxxxx Layer 1 X scroll position + + 0xF1180068: x------- -------- -------- -------- Layer 2 enable + -------x xxxxxxxx -------- -------- Layer 2 Y scroll position + -------- -------- -------x xxxxxxxx Layer 2 X scroll position + + 0xF118006C: x------- -------- -------- -------- Layer 3 enable + -------x xxxxxxxx -------- -------- Layer 3 Y scroll position + -------- -------- -------x xxxxxxxx Layer 3 X scroll position */ @@ -634,233 +634,233 @@ cached_texture *model3_state::get_texture(int page, int texx, int texy, int texw /* Real3D Graphics stuff */ /* - Real3D Pro-1000 capabilities: + Real3D Pro-1000 capabilities: - Coordinate sets - - 4096 matrices (matrix base pointer in viewport node) + Coordinate sets + - 4096 matrices (matrix base pointer in viewport node) - Polygons - - 32MB max polygon memory. VROM in Model 3, the low 4MB of VROM is overlaid by Polygon RAM for runtime generated content. + Polygons + - 32MB max polygon memory. VROM in Model 3, the low 4MB of VROM is overlaid by Polygon RAM for runtime generated content. - Texture - - 2 texture sheets of 2048x1024 - - Mipmaps located in the bottom right corner - - Texture size 32x32 to 1024x1024 - - Microtextures (is this featured in Model 3?) + Texture + - 2 texture sheets of 2048x1024 + - Mipmaps located in the bottom right corner + - Texture size 32x32 to 1024x1024 + - Microtextures (is this featured in Model 3?) - LODs - - 127 blend types per viewport with 4 sets of min/max angle or range (where is this in the viewport node?) + LODs + - 127 blend types per viewport with 4 sets of min/max angle or range (where is this in the viewport node?) - Lighting - - Self-luminous lighting (enable and luminosity parameter in polygon structure) - - Fixed polygon shading, fixed shading weight per vertex (not found in Model 3, yet) - - Flat sun shading (lighting parameters in viewport node) needs a separate enable? - - Smooth polygon shading (lighting parameters in viewport, use vertex normals) + Lighting + - Self-luminous lighting (enable and luminosity parameter in polygon structure) + - Fixed polygon shading, fixed shading weight per vertex (not found in Model 3, yet) + - Flat sun shading (lighting parameters in viewport node) needs a separate enable? + - Smooth polygon shading (lighting parameters in viewport, use vertex normals) - Gamma table - - 256 entry 8-bit table, possibly in Polygon RAM + Gamma table + - 256 entry 8-bit table, possibly in Polygon RAM */ /* - Real3D Memory Structures: - - Culling Nodes: - - Located in Culling RAM (0x8E000000) - - Limit of 15 child nodes (nesting), not including polygon nodes - - Color table (is this featured in Model 3?) - - 0x00: -------- -------- ------xx -------- Viewport number 0-3 - -------- -------- -------- ---xx--- Viewport priority - - 0x01: Child node pointer (inherits parameters from this node) - 0x02: Sibling node pointer - 0x03: Unknown (float) - 0x04: Sun light vector Z-component (float) - 0x05: Sun light vector X-component (float) - 0x06: Sun light vector Y-component (float) - 0x07: Sun light intensity (float) - 0x08: Far Clip plane Z - 0x09: Far Clip plane Distance - 0x0a: Near Clip plane Z - 0x0b: Near Clip plane Distance - 0x0c: Left Clip plane Z - 0x0d: Left Clip plane X - 0x0e: Top Clip plane Z - 0x0f: Top Clip plane Y - 0x10: Right Clip plane Z - 0x11: Right Clip plane X - 0x12: Bottom Clip plane Z - 0x13: Bottom Clip plane Y - - 0x14: xxxxxxxx xxxxxxxx -------- -------- Viewport height (14.2 fixed-point) - -------- -------- xxxxxxxx xxxxxxxx Viewport width (14.2 fixed-point) - - 0x15: ? - 0x16: Matrix base pointer - 0x17: LOD blend type table pointer? (seems to be 8x float per entry) - 0x18: ? - 0x19: ? - - 0x1a: xxxxxxxx xxxxxxxx -------- -------- Viewport Y coordinate (12.4 fixed-point) - -------- -------- xxxxxxxx xxxxxxxx Viewport X coordinate (12.4 fixed-point) - - 0x1b: Copy of word 0x00 - 0x1c: ? - - 0x1d: xxxxxxxx xxxxxxxx -------- -------- Spotlight Y size - -------- -------- xxxxxxxx xxxxxxxx Spotlight Y position (13.3 fixed-point?) - - 0x1e: xxxxxxxx xxxxxxxx -------- -------- Spotlight X size - -------- -------- xxxxxxxx xxxxxxxx Spotlight X position (13.3 fixed-point?) - - 0x1f: Light extent (float) - - 0x20: xxxxxxxx -------- -------- -------- ? - -------- xxxxxxxx -------- -------- ? - -------- -------- --xxx--- -------- Light RGB (RGB111?) - -------- -------- -----xxx -------- Light RGB Fog (RGB111?) - -------- -------- -------- xxxxxxxx Scroll Fog (0.8 fixed-point?) What is this??? - - 0x21: ? - 0x22: Fog Color (RGB888) - 0x23: Fog Density (float) - - 0x24: xxxxxxxx xxxxxxxx -------- -------- ? - -------- -------- xxxxxxxx -------- Sun light ambient (0.8 fixed-point) - -------- -------- -------- xxxxxxxx Scroll attenuation (0.8 fixed-point) What is this??? - - 0x25: Fog offset - 0x26: ? - 0x27: ? - 0x28: ? - 0x29: ? - 0x2a: ? - 0x2b: ? - 0x2c: ? - 0x2d: ? - 0x2e: ? - 0x2f: ? - - - Sub types: - LOD Culling Node. Up to 4 LODs. - - Articulated Part Culling Node (is this used by Model 3?) - - An Articulated Part culling node, or six degreeoffreedom node, is used to define + Real3D Memory Structures: + + Culling Nodes: + - Located in Culling RAM (0x8E000000) + - Limit of 15 child nodes (nesting), not including polygon nodes + - Color table (is this featured in Model 3?) + + 0x00: -------- -------- ------xx -------- Viewport number 0-3 + -------- -------- -------- ---xx--- Viewport priority + + 0x01: Child node pointer (inherits parameters from this node) + 0x02: Sibling node pointer + 0x03: Unknown (float) + 0x04: Sun light vector Z-component (float) + 0x05: Sun light vector X-component (float) + 0x06: Sun light vector Y-component (float) + 0x07: Sun light intensity (float) + 0x08: Far Clip plane Z + 0x09: Far Clip plane Distance + 0x0a: Near Clip plane Z + 0x0b: Near Clip plane Distance + 0x0c: Left Clip plane Z + 0x0d: Left Clip plane X + 0x0e: Top Clip plane Z + 0x0f: Top Clip plane Y + 0x10: Right Clip plane Z + 0x11: Right Clip plane X + 0x12: Bottom Clip plane Z + 0x13: Bottom Clip plane Y + + 0x14: xxxxxxxx xxxxxxxx -------- -------- Viewport height (14.2 fixed-point) + -------- -------- xxxxxxxx xxxxxxxx Viewport width (14.2 fixed-point) + + 0x15: ? + 0x16: Matrix base pointer + 0x17: LOD blend type table pointer? (seems to be 8x float per entry) + 0x18: ? + 0x19: ? + + 0x1a: xxxxxxxx xxxxxxxx -------- -------- Viewport Y coordinate (12.4 fixed-point) + -------- -------- xxxxxxxx xxxxxxxx Viewport X coordinate (12.4 fixed-point) + + 0x1b: Copy of word 0x00 + 0x1c: ? + + 0x1d: xxxxxxxx xxxxxxxx -------- -------- Spotlight Y size + -------- -------- xxxxxxxx xxxxxxxx Spotlight Y position (13.3 fixed-point?) + + 0x1e: xxxxxxxx xxxxxxxx -------- -------- Spotlight X size + -------- -------- xxxxxxxx xxxxxxxx Spotlight X position (13.3 fixed-point?) + + 0x1f: Light extent (float) + + 0x20: xxxxxxxx -------- -------- -------- ? + -------- xxxxxxxx -------- -------- ? + -------- -------- --xxx--- -------- Light RGB (RGB111?) + -------- -------- -----xxx -------- Light RGB Fog (RGB111?) + -------- -------- -------- xxxxxxxx Scroll Fog (0.8 fixed-point?) What is this??? + + 0x21: ? + 0x22: Fog Color (RGB888) + 0x23: Fog Density (float) + + 0x24: xxxxxxxx xxxxxxxx -------- -------- ? + -------- -------- xxxxxxxx -------- Sun light ambient (0.8 fixed-point) + -------- -------- -------- xxxxxxxx Scroll attenuation (0.8 fixed-point) What is this??? + + 0x25: Fog offset + 0x26: ? + 0x27: ? + 0x28: ? + 0x29: ? + 0x2a: ? + 0x2b: ? + 0x2c: ? + 0x2d: ? + 0x2e: ? + 0x2f: ? + + + Sub types: + LOD Culling Node. Up to 4 LODs. + + Articulated Part Culling Node (is this used by Model 3?) + - An Articulated Part culling node, or six degree?of?freedom node, is used to define geometry that can move relative to the parent coordinate set to which it is attached. Fifteen levels of coordinate set nesting (levels of articulation) are supported. - - Animation Culling Node - - Animation culling nodes are used to build a culling hierarchy for an object with different + + Animation Culling Node + - Animation culling nodes are used to build a culling hierarchy for an object with different representations, or animation frames. which can be turned on and off by the application. Each child (culling node or polygon) added to an Animation culling node specifies the frame for which the child is valid. - - Instance Culling Node - - Instance culling nodes define the top of a shared display list segment that can be - referenced from other parts of the scene display list. - - Instance Reference Culling Node - - An Instance Reference node is considered a leaf node; its - "child" is the shared geometry segment. An Instance Reference may be attached to - a parent node and may not have any other children, but may have siblings. - - Point Light - - A Point Light is used to create an instance of a point luminous feature. The size, + + Instance Culling Node + - Instance culling nodes define the top of a shared display list segment that can be + referenced from other parts of the scene display list. + + Instance Reference Culling Node + - An Instance Reference node is considered a leaf node; its + "child" is the shared geometry segment. An Instance Reference may be attached to + a parent node and may not have any other children, but may have siblings. + + Point Light + - A Point Light is used to create an instance of a point luminous feature. The size, feature type, and number of sides of the point light model may be customized. - Instance Set - - An Instance Set is a culling node which defines a set of point features. Each feature + Instance Set + - An Instance Set is a culling node which defines a set of point features. Each feature is positioned individually. This type of culling node can be used to simulate particles. - Instance Node? + Instance Node? + + 0x00: xxxxxxxx xxxxxxxx xxxxxx-- -------- Node number/ID?, num of bits unknown + -------- -------- -------- ---x---- This node applies translation, else matrix + -------- -------- -------- ----x--- LOD enable? + -------- -------- -------- -----x-- ? + -------- -------- -------- ------x- ? + -------- -------- -------- -------x ? - 0x00: xxxxxxxx xxxxxxxx xxxxxx-- -------- Node number/ID?, num of bits unknown - -------- -------- -------- ---x---- This node applies translation, else matrix - -------- -------- -------- ----x--- LOD enable? - -------- -------- -------- -----x-- ? - -------- -------- -------- ------x- ? - -------- -------- -------- -------x ? - - 0x01: ? (not present on Step 1.0) - 0x02: ? (not present on Step 1.0) Scud Race has 0x00000101 + 0x01: ? (not present on Step 1.0) + 0x02: ? (not present on Step 1.0) Scud Race has 0x00000101 - 0x03: --x----- -------- -------- -------- ? - -------- -xxxxxxx xxxx---- -------- LOD? - -------- -------- ----xxxx xxxxxxxx Node matrix - - 0x04: Translation X coordinate - 0x05: Translation Y coordinate - 0x06: Translation Z coordinate - 0x07: Child node pointer - 0x08: Sibling node pointer + 0x03: --x----- -------- -------- -------- ? + -------- -xxxxxxx xxxx---- -------- LOD? + -------- -------- ----xxxx xxxxxxxx Node matrix - 0x09: xxxxxxxx xxxxxxxx -------- -------- Culling or sorting related? - -------- -------- xxxxxxxx xxxxxxxx Culling or sorting related? + 0x04: Translation X coordinate + 0x05: Translation Y coordinate + 0x06: Translation Z coordinate + 0x07: Child node pointer + 0x08: Sibling node pointer + 0x09: xxxxxxxx xxxxxxxx -------- -------- Culling or sorting related? + -------- -------- xxxxxxxx xxxxxxxx Culling or sorting related? - Polygon Data - 0x00: -------- xxxxxxxx xxxxxx-- -------- Polygon ID - -------- -------- -------- -x------ 0 = Triangle, 1 = Quad - -------- -------- -------- ----x--- Vertex 3 shared from previous polygon - -------- -------- -------- -----x-- Vertex 2 shared from previous polygon - -------- -------- -------- ------x- Vertex 1 shared from previous polygon - -------- -------- -------- -------x Vertex 0 shared from previous polygon - xxxxxxxx -------- -------- x-xx---- ? - -------- -------- ------xx -------- Broken polygons in srally2 set these (a way to mark them for HW to not render?) + Polygon Data - 0x01: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal X coordinate (2.22 fixed point) - -------- -------- -------- -x------ UV format (0 = 13.3, 1 = 16.0) - -------- -------- -------- -----x-- If set, this is the last polygon - -------- -------- -------- x-xxx-xx ? + 0x00: -------- xxxxxxxx xxxxxx-- -------- Polygon ID + -------- -------- -------- -x------ 0 = Triangle, 1 = Quad + -------- -------- -------- ----x--- Vertex 3 shared from previous polygon + -------- -------- -------- -----x-- Vertex 2 shared from previous polygon + -------- -------- -------- ------x- Vertex 1 shared from previous polygon + -------- -------- -------- -------x Vertex 0 shared from previous polygon + xxxxxxxx -------- -------- x-xx---- ? + -------- -------- ------xx -------- Broken polygons in srally2 set these (a way to mark them for HW to not render?) - 0x02: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate (2.22 fixed point) - -------- -------- -------- ------x- Texture U mirror enable - -------- -------- -------- -------x Texture V mirror enable - -------- -------- -------- xxxxxx-- ? + 0x01: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal X coordinate (2.22 fixed point) + -------- -------- -------- -x------ UV format (0 = 13.3, 1 = 16.0) + -------- -------- -------- -----x-- If set, this is the last polygon + -------- -------- -------- x-xxx-xx ? - 0x03: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate (2.22 fixed point) - -------- -------- -------- --xxx--- Texture width (in 8-pixel tiles) - -------- -------- -------- -----xxx Texture height (in 8-pixel tiles) + 0x02: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate (2.22 fixed point) + -------- -------- -------- ------x- Texture U mirror enable + -------- -------- -------- -------x Texture V mirror enable + -------- -------- -------- xxxxxx-- ? - 0x04: xxxxxxxx xxxxxxxx xxxxxxxx -------- Color (RGB888) - -------- -------- -------- -x------ Texture page - -------- -------- -------- ---xxxxx Upper 5 bits of texture U coordinate - -------- -------- -------- x-x----- ? + 0x03: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate (2.22 fixed point) + -------- -------- -------- --xxx--- Texture width (in 8-pixel tiles) + -------- -------- -------- -----xxx Texture height (in 8-pixel tiles) - 0x05: xxxxxxxx xxxxxxxx xxxxxxxx -------- Specular color? - -------- -------- -------- x------- Low bit of texture U coordinate - -------- -------- -------- ---xxxxx Low 5 bits of texture V coordinate - -------- -------- -------- -xx----- ? + 0x04: xxxxxxxx xxxxxxxx xxxxxxxx -------- Color (RGB888) + -------- -------- -------- -x------ Texture page + -------- -------- -------- ---xxxxx Upper 5 bits of texture U coordinate + -------- -------- -------- x-x----- ? - 0x06: x------- -------- -------- -------- Texture contour enable - -----x-- -------- -------- -------- Texture enable - -------- x------- -------- -------- 1 = disable transparency? - -------- -xxxxx-- -------- -------- Polygon transparency (0 = fully transparent) - -------- -------x -------- -------- 1 = disable lighting - -------- -------- xxxxx--- -------- Polygon luminosity - -------- -------- ------xx x------- Texture format - -------- -------- -------- -------x Alpha enable? - -xxxx-xx ------x- -----x-- -xxxxxx- ? + 0x05: xxxxxxxx xxxxxxxx xxxxxxxx -------- Specular color? + -------- -------- -------- x------- Low bit of texture U coordinate + -------- -------- -------- ---xxxxx Low 5 bits of texture V coordinate + -------- -------- -------- -xx----- ? + 0x06: x------- -------- -------- -------- Texture contour enable + -----x-- -------- -------- -------- Texture enable + -------- x------- -------- -------- 1 = disable transparency? + -------- -xxxxx-- -------- -------- Polygon transparency (0 = fully transparent) + -------- -------x -------- -------- 1 = disable lighting + -------- -------- xxxxx--- -------- Polygon luminosity + -------- -------- ------xx x------- Texture format + -------- -------- -------- -------x Alpha enable? + -xxxx-xx ------x- -----x-- -xxxxxx- ? - Vertex entry - 0x00: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex X coordinate (17.7 fixed-point in Step 1.0, 13.11 otherwise) - -------- -------- -------- xxxxxxxx Vertex normal X (offset from polygon normal) + Vertex entry - 0x01: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex Y coordinate - -------- -------- -------- xxxxxxxx Vertex normal Y + 0x00: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex X coordinate (17.7 fixed-point in Step 1.0, 13.11 otherwise) + -------- -------- -------- xxxxxxxx Vertex normal X (offset from polygon normal) - 0x02: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex Z coordinate - -------- -------- -------- xxxxxxxx Vertex normal Z + 0x01: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex Y coordinate + -------- -------- -------- xxxxxxxx Vertex normal Y - 0x03: xxxxxxxx xxxxxxxx -------- -------- Vertex U coordinate - -------- -------- xxxxxxxx xxxxxxxx Vertex V coordinate + 0x02: xxxxxxxx xxxxxxxx xxxxxxxx -------- Vertex Z coordinate + -------- -------- -------- xxxxxxxx Vertex normal Z + + 0x03: xxxxxxxx xxxxxxxx -------- -------- Vertex U coordinate + -------- -------- xxxxxxxx xxxxxxxx Vertex V coordinate */ @@ -891,8 +891,8 @@ WRITE64_MEMBER(model3_state::real3d_polygon_ram_w) static const UINT8 texture_decode[64] = { - 0, 1, 4, 5, 8, 9, 12, 13, - 2, 3, 6, 7, 10, 11, 14, 15, + 0, 1, 4, 5, 8, 9, 12, 13, + 2, 3, 6, 7, 10, 11, 14, 15, 16, 17, 20, 21, 24, 25, 28, 29, 18, 19, 22, 23, 26, 27, 30, 31, 32, 33, 36, 37, 40, 41, 44, 45, @@ -1003,8 +1003,8 @@ void model3_state::real3d_display_list_end() m_texture_fifo_pos = 0; m_renderer->clear_buffers(); - - real3d_traverse_display_list(); + + real3d_traverse_display_list(); } void model3_state::real3d_display_list1_dma(UINT32 src, UINT32 dst, int length, int byteswap) @@ -1041,7 +1041,7 @@ void model3_state::real3d_display_list2_dma(UINT32 src, UINT32 dst, int length, void model3_state::real3d_vrom_texture_dma(UINT32 src, UINT32 dst, int length, int byteswap) { - address_space &space = m_maincpu->space(AS_PROGRAM); + address_space &space = m_maincpu->space(AS_PROGRAM); if ((dst & 0xff) == 0) { for (int i=0; i < length; i+=12) @@ -1286,11 +1286,11 @@ void model3_state::draw_model(UINT32 addr) MATRIX transform_matrix; float center_x, center_y; - if (m_step < 0x15) // position coordinates are 17.7 fixed-point in Step 1.0 + if (m_step < 0x15) // position coordinates are 17.7 fixed-point in Step 1.0 fixed_point_fraction = 1.0f / 128.0f; - else // 13.11 fixed-point in other Steps + else // 13.11 fixed-point in other Steps fixed_point_fraction = 1.0f / 2048.0f; - + get_top_matrix(&transform_matrix); /* current viewport center coordinates on screen */ @@ -1323,7 +1323,7 @@ void model3_state::draw_model(UINT32 addr) if (header[1] & 0x4) last_polygon = TRUE; - if ((header[0] & 0x300) == 0x300) // TODO: broken polygons in srally2 have these bits set + if ((header[0] & 0x300) == 0x300) // TODO: broken polygons in srally2 have these bits set return; num_vertices = (header[0] & 0x40) ? 4 : 3; @@ -1354,9 +1354,9 @@ void model3_state::draw_model(UINT32 addr) vertex[vi].z = (float)((INT32)(zw) >> 8) * fixed_point_fraction; vertex[vi].u = (UINT16)(model[index] >> 16); vertex[vi].v = (UINT16)(model[index++]); -// vertex[vi].nx = normal[0] + ((float)((INT8)(xw)) / 127.0f); -// vertex[vi].ny = normal[1] + ((float)((INT8)(yw)) / 127.0f); -// vertex[vi].nz = normal[2] + ((float)((INT8)(zw)) / 127.0f); +// vertex[vi].nx = normal[0] + ((float)((INT8)(xw)) / 127.0f); +// vertex[vi].ny = normal[1] + ((float)((INT8)(yw)) / 127.0f); +// vertex[vi].nz = normal[2] + ((float)((INT8)(zw)) / 127.0f); vertex[vi].nx = ((float)((INT8)(xw)) / 127.0f); vertex[vi].ny = ((float)((INT8)(yw)) / 127.0f); @@ -1408,16 +1408,16 @@ void model3_state::draw_model(UINT32 addr) // transform vertex normal VECTOR3 n; n[0] = (vertex[i].nx * transform_matrix[0][0]) + - (vertex[i].ny * transform_matrix[1][0]) + - (vertex[i].nz * transform_matrix[2][0]); + (vertex[i].ny * transform_matrix[1][0]) + + (vertex[i].nz * transform_matrix[2][0]); n[0] *= m_coordinate_system[0][1]; n[1] = (vertex[i].nx * transform_matrix[0][1]) + - (vertex[i].ny * transform_matrix[1][1]) + - (vertex[i].nz * transform_matrix[2][1]); + (vertex[i].ny * transform_matrix[1][1]) + + (vertex[i].nz * transform_matrix[2][1]); n[1] *= m_coordinate_system[1][2]; n[2] = (vertex[i].nx * transform_matrix[0][2]) + - (vertex[i].ny * transform_matrix[1][2]) + - (vertex[i].nz * transform_matrix[2][2]); + (vertex[i].ny * transform_matrix[1][2]) + + (vertex[i].nz * transform_matrix[2][2]); n[2] *= m_coordinate_system[2][0]; // lighting @@ -1484,7 +1484,7 @@ void model3_state::draw_model(UINT32 addr) int tex_height = (header[3] & 0x7); int tex_format = (header[6] >> 7) & 0x7; - if (tex_width >= 6 || tex_height >= 6) // srally2 poly ram has degenerate polys with 2k tex size (cpu bug or intended?) + if (tex_width >= 6 || tex_height >= 6) // srally2 poly ram has degenerate polys with 2k tex size (cpu bug or intended?) return; texture = get_texture((header[4] & 0x40) ? 1 : 0, tex_x, tex_y, tex_width, tex_height, tex_format); @@ -1761,7 +1761,7 @@ void model3_renderer::clear_buffers() cliprect.max_y = 383; m_fb->fill(0x00000000, cliprect); - + float zvalue = 10000000000.0f; m_zb->fill(*(int*)&zvalue, cliprect); } @@ -1779,14 +1779,14 @@ void model3_renderer::draw_triangle(const m3_triangle *tri) if (tri->param & TRI_PARAM_TEXTURE_ENABLE) { for (int i=0; i < 3; i++) - { + { v[i].x = tri->v[i].x; v[i].y = tri->v[i].y; v[i].p[0] = tri->v[i].z; v[i].p[1] = 1.0f / tri->v[i].z; - v[i].p[2] = tri->v[i].u * 256.0f; // 8 bits of subtexel precision for bilinear filtering + v[i].p[2] = tri->v[i].u * 256.0f; // 8 bits of subtexel precision for bilinear filtering v[i].p[3] = tri->v[i].v * 256.0f; - v[i].p[4] = tri->v[i].i; + v[i].p[4] = tri->v[i].i; } model3_polydata &extra = object_data_alloc(); @@ -1821,7 +1821,7 @@ void model3_renderer::draw_triangle(const m3_triangle *tri) v[i].x = tri->v[i].x; v[i].y = tri->v[i].y; v[i].p[0] = tri->v[i].z; - v[i].p[1] = tri->v[i].i; + v[i].p[1] = tri->v[i].i; } model3_polydata &extra = object_data_alloc(); @@ -1881,30 +1881,30 @@ void model3_renderer::draw_scanline_solid(INT32 scanline, const extent_t &extent } } -#define TEX_FETCH_NOFILTER() \ -do { \ - float intz = 1.0f / ooz; \ - UINT32 u = uoz * intz; \ - UINT32 v = voz * intz; \ - UINT32 u1 = (u >> 8) & umask; \ - UINT32 v1 = (v >> 8) & vmask; \ - texel = texture->data[(v1 << width) + u1]; \ +#define TEX_FETCH_NOFILTER() \ +do { \ + float intz = 1.0f / ooz; \ + UINT32 u = uoz * intz; \ + UINT32 v = voz * intz; \ + UINT32 u1 = (u >> 8) & umask; \ + UINT32 v1 = (v >> 8) & vmask; \ + texel = texture->data[(v1 << width) + u1]; \ } while(0); -#define TEX_FETCH_BILINEAR() \ -do { \ - float intz = 1.0f / ooz; \ - UINT32 u = uoz * intz; \ - UINT32 v = voz * intz; \ - UINT32 u1 = (u >> 8) & umask; \ - UINT32 v1 = (v >> 8) & vmask; \ - UINT32 u2 = (u1 + 1) & umask; \ - UINT32 v2 = (v1 + 1) & vmask; \ - UINT32 pix00 = texture->data[(v1 << width) + u1]; \ - UINT32 pix01 = texture->data[(v1 << width) + u2]; \ - UINT32 pix10 = texture->data[(v2 << width) + u1]; \ - UINT32 pix11 = texture->data[(v2 << width) + u2]; \ - texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v); \ +#define TEX_FETCH_BILINEAR() \ +do { \ + float intz = 1.0f / ooz; \ + UINT32 u = uoz * intz; \ + UINT32 v = voz * intz; \ + UINT32 u1 = (u >> 8) & umask; \ + UINT32 v1 = (v >> 8) & vmask; \ + UINT32 u2 = (u1 + 1) & umask; \ + UINT32 v2 = (v1 + 1) & vmask; \ + UINT32 pix00 = texture->data[(v1 << width) + u1]; \ + UINT32 pix01 = texture->data[(v1 << width) + u2]; \ + UINT32 pix10 = texture->data[(v2 << width) + u1]; \ + UINT32 pix11 = texture->data[(v2 << width) + u2]; \ + texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v); \ } while(0); #if ENABLE_BILINEAR @@ -1989,19 +1989,19 @@ void model3_renderer::draw_scanline_contour(INT32 scanline, const extent_t &exte UINT32 fa = texel >> 24; if (fa >= 0xf8) - { + { UINT32 r = ((texel & 0x00ff0000) * fa) >> 8; UINT32 g = ((texel & 0x0000ff00) * fa) >> 8; UINT32 b = ((texel & 0x000000ff) * fa) >> 8; - + UINT32 orig = fb[x]; - + int minalpha = 255 - fa; - + r += ((orig & 0x00ff0000) * minalpha) >> 8; g += ((orig & 0x0000ff00) * minalpha) >> 8; b += ((orig & 0x000000ff) * minalpha) >> 8; - + fb[x] = 0xff000000 | (r & 0xff0000) | (g & 0xff00) | (b & 0xff); zb[x] = z; } @@ -2055,9 +2055,9 @@ void model3_renderer::draw_scanline_tex_trans(INT32 scanline, const extent_t &ex r = (r * srctrans) >> 5; g = (g * srctrans) >> 5; b = (b * srctrans) >> 5; - + UINT32 orig = fb[x]; - + r += ((orig & 0x00ff0000) * desttrans) >> 5; g += ((orig & 0x0000ff00) * desttrans) >> 5; b += ((orig & 0x000000ff) * desttrans) >> 5; @@ -2091,8 +2091,8 @@ void model3_renderer::draw_scanline_tex_alpha(INT32 scanline, const extent_t &ex float in = extent.param[4].start; float inz = extent.param[4].dpdx; -// int srctrans = polydata.transparency; -// int desttrans = 32 - polydata.transparency; +// int srctrans = polydata.transparency; +// int desttrans = 32 - polydata.transparency; UINT32 umask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_U) ? 64 : 32) << texture->width) - 1; UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1; @@ -2136,4 +2136,4 @@ void model3_renderer::draw_scanline_tex_alpha(INT32 scanline, const extent_t &ex in += inz; z += dz; } -} \ No newline at end of file +} diff --git a/src/mame/video/seibuspi.c b/src/mame/video/seibuspi.c index 3d0186e56f0..4495c479532 100644 --- a/src/mame/video/seibuspi.c +++ b/src/mame/video/seibuspi.c @@ -26,7 +26,7 @@ void seibuspi_state::set_layer_offsets() m_midl_layer_offset = 0x2000 / 4 / 2; m_text_layer_offset = 0x3000 / 4 / 2; } - + m_fore_layer_d13 = m_layer_bank >> 14 & 0x2000; m_back_layer_d14 = m_rf2_layer_bank << 14 & 0x4000; m_midl_layer_d14 = m_rf2_layer_bank << 13 & 0x4000; @@ -657,7 +657,7 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f) m_rf2_layer_bank = 0; m_rowscroll_enable = 0; set_layer_offsets(); - + m_tilemap_ram_size = 0; m_palette_ram_size = 0x4000; m_sprite_ram_size = 0x2000; diff --git a/src/mame/video/sknsspr.h b/src/mame/video/sknsspr.h index 4701e865093..3145755c487 100644 --- a/src/mame/video/sknsspr.h +++ b/src/mame/video/sknsspr.h @@ -4,7 +4,7 @@ class sknsspr_device : public device_t, { public: sknsspr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + void skns_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32* spriteram_source, size_t spriteram_size, UINT8* gfx_source, size_t gfx_length, UINT32* sprite_regs); void skns_sprite_kludge(int x, int y); diff --git a/src/mame/video/skyfox.c b/src/mame/video/skyfox.c index bf3da646609..bb42d541163 100644 --- a/src/mame/video/skyfox.c +++ b/src/mame/video/skyfox.c @@ -173,7 +173,7 @@ void skyfox_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect for (dx = xstart; dx != xend; dx += xinc, code++) { gfx->transpen(bitmap, cliprect, code, 0, flipx, flipy, dx*8 + x, dy*8 + y, 0xff); - + // wraparound y - BTANB: large sprites exiting the screen sometimes reappear on the other edge gfx->transpen(bitmap, cliprect, code, 0, flipx, flipy, dx*8 + x, dy*8 + y - 256, 0xff); } diff --git a/src/mame/video/snk.c b/src/mame/video/snk.c index a9dcd0b3b38..1ed8b441bad 100644 --- a/src/mame/video/snk.c +++ b/src/mame/video/snk.c @@ -835,7 +835,7 @@ byte3: attributes -xx-x--- (bank number) x------- (x offset bit8) */ -void snk_state::tdfever_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, const int xscroll, const int yscroll, const UINT8 *source, const int gfxnum, +void snk_state::tdfever_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, const int xscroll, const int yscroll, const UINT8 *source, const int gfxnum, const int hw_xflip, const int from, const int to) { gfx_element *gfx = m_gfxdecode->gfx(gfxnum); diff --git a/src/mame/video/taito_f3.c b/src/mame/video/taito_f3.c index 05efc3bd1a1..a79ba38f94e 100644 --- a/src/mame/video/taito_f3.c +++ b/src/mame/video/taito_f3.c @@ -1398,7 +1398,7 @@ void taito_f3_state::init_alpha_blend_func() /*============================================================================*/ -inline void taito_f3_state::draw_scanlines( +inline void taito_f3_state::draw_scanlines( bitmap_rgb32 &bitmap,int xsize,INT16 *draw_line_num, const struct f3_playfield_line_inf **line_t, const int *sprite, diff --git a/src/mame/video/tc0480scp.c b/src/mame/video/tc0480scp.c index 2399025a049..4418ad3c4db 100644 --- a/src/mame/video/tc0480scp.c +++ b/src/mame/video/tc0480scp.c @@ -156,7 +156,7 @@ tc0480scp_device::tc0480scp_device(const machine_config &mconfig, const char *ta m_palette(*this) { memset(m_ctrl, 0, sizeof(m_ctrl)); - + for (int i = 0; i < 4; i++) { m_bg_ram[i] = NULL; diff --git a/src/mess/audio/vc4000snd.h b/src/mess/audio/vc4000snd.h index 531556084f0..097c247538a 100644 --- a/src/mess/audio/vc4000snd.h +++ b/src/mess/audio/vc4000snd.h @@ -21,17 +21,17 @@ class vc4000_sound_device : public device_t, public: vc4000_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~vc4000_sound_device() { } - + protected: // device-level overrides virtual void device_start(); - + // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - + public: void soundport_w(int mode, int data); - + private: sound_stream *m_channel; UINT8 m_reg[1]; diff --git a/src/mess/audio/wswan_snd.h b/src/mess/audio/wswan_snd.h index a586a002cd3..253308b0520 100644 --- a/src/mess/audio/wswan_snd.h +++ b/src/mess/audio/wswan_snd.h @@ -25,7 +25,7 @@ struct CHAN vol_right(0), on(0), signal(0) { } - + UINT16 freq; /* frequency */ UINT32 period; /* period */ UINT32 pos; /* position */ @@ -44,21 +44,21 @@ class wswan_sound_device : public device_t, public: wswan_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~wswan_sound_device() { } - + protected: // device-level overrides virtual void device_start(); virtual void device_reset(); - + // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - + public: DECLARE_WRITE8_MEMBER( port_w ); - + private: void wswan_ch_set_freq( CHAN *ch, UINT16 freq ); - + private: sound_stream *m_channel; CHAN m_audio1; /* Audio channel 1 */ diff --git a/src/mess/drivers/a2600.c b/src/mess/drivers/a2600.c index 3b1b52beb5b..1d0d6a47d5d 100644 --- a/src/mess/drivers/a2600.c +++ b/src/mess/drivers/a2600.c @@ -244,14 +244,14 @@ WRITE8_MEMBER(a2600_state::cart_over_riot_w) { m_cart->write_bank(space, offset, 0); m_riot_ram[0x20 + offset] = data; - + } WRITE8_MEMBER(a2600_state::cart_over_tia_w) { // Both Cart & TIA see these addresses m_cart->write_bank(space, offset, data); - m_tia->write(space, offset, data); + m_tia->write(space, offset, data); } MACHINE_START_MEMBER(a2600_state,a2600) @@ -313,7 +313,7 @@ MACHINE_START_MEMBER(a2600_state,a2600) m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); break; } - + /* Banks may have changed, reset the cpu so it uses the correct reset vector */ m_maincpu->reset(); } diff --git a/src/mess/drivers/a7800.c b/src/mess/drivers/a7800.c index 6c5ba9c3b19..8352d1ab71f 100644 --- a/src/mess/drivers/a7800.c +++ b/src/mess/drivers/a7800.c @@ -9,7 +9,7 @@ 2002/05/13 kubecj added more banks for bankswitching added PAL machine description changed clock to be precise - improved cart emulation (in machine/) + improved cart emulation (in machine/) 2012/10/25 Robert Tuccitto NTSC Color Generator utilized for color palette with hue shift/start @@ -88,10 +88,10 @@ 2014/05/06 Mike Saarna/Robert Tuccitto Brought initial Maria cycle counts inline from measurements taken with logic analyzer and tests. - + 2014/08/25 Fabio Priuli Converted carts to be slot devices and cleaned up the driver (removed the pokey, cleaned up rom regions, etc.) - + ***************************************************************************/ #include "emu.h" @@ -121,19 +121,19 @@ public: m_io_console_buttons(*this, "console_buttons"), m_cart(*this, "cartslot"), m_screen(*this, "screen") { } - + int m_lines; int m_ispal; - + int m_ctrl_lock; int m_ctrl_reg; int m_maria_flag; int m_p1_one_button; int m_p2_one_button; int m_bios_enabled; - + UINT8 *m_bios; - + DECLARE_READ8_MEMBER(bios_or_cart_r); DECLARE_WRITE8_MEMBER(ram0_w); DECLARE_READ8_MEMBER(tia_r); @@ -151,7 +151,7 @@ public: DECLARE_READ8_MEMBER(riot_joystick_r); DECLARE_READ8_MEMBER(riot_console_button_r); DECLARE_WRITE8_MEMBER(riot_button_pullup_w); - + protected: required_device m_maincpu; required_device m_tia; @@ -223,7 +223,7 @@ READ8_MEMBER(a7800_state::tia_r) return 0x80; default: logerror("undefined TIA read %x\n",offset); - + } return 0xff; } @@ -231,7 +231,7 @@ READ8_MEMBER(a7800_state::tia_r) // TIA WRITE8_MEMBER(a7800_state::tia_w) { - if (offset < 0x20) + if (offset < 0x20) { //INPTCTRL covers TIA registers 0x00-0x1F until locked if (data & 0x01) { @@ -291,12 +291,12 @@ static ADDRESS_MAP_START( a7800_mem, AS_PROGRAM, 8, a7800_state ) AM_RANGE(0x2040, 0x20ff) AM_RAMBANK("ram0") // mirror (6116 block 0) AM_RANGE(0x2140, 0x21ff) AM_RAMBANK("ram1") // mirror (6116 block 1) - AM_RANGE(0x2800, 0x2fff) AM_RAMBANK("mirror") // these should mirror "main_ram" (according to docs) + AM_RANGE(0x2800, 0x2fff) AM_RAMBANK("mirror") // these should mirror "main_ram" (according to docs) AM_RANGE(0x3000, 0x37ff) AM_RAMBANK("mirror") // but system have issues in such case... AM_RANGE(0x3800, 0x3fff) AM_RAMBANK("mirror") AM_RANGE(0x4000, 0xffff) AM_DEVWRITE("cartslot", a78_cart_slot_device, write_40xx) AM_RANGE(0x4000, 0xbfff) AM_DEVREAD("cartslot", a78_cart_slot_device, read_40xx) - AM_RANGE(0xc000, 0xffff) AM_READ(bios_or_cart_r) // here also the BIOS can be accessed + AM_RANGE(0xc000, 0xffff) AM_READ(bios_or_cart_r) // here also the BIOS can be accessed ADDRESS_MAP_END @@ -1313,7 +1313,7 @@ void a7800_state::machine_start() save_item(NAME(m_ctrl_lock)); save_item(NAME(m_ctrl_reg)); save_item(NAME(m_maria_flag)); - + // install additional handlers, if needed if (m_cart->exists()) { diff --git a/src/mess/drivers/aim65.c b/src/mess/drivers/aim65.c index 305b61a8ca5..6f48b026494 100644 --- a/src/mess/drivers/aim65.c +++ b/src/mess/drivers/aim65.c @@ -158,7 +158,7 @@ int aim65_state::load_cart(device_image_interface &image, generic_slot_device *s { astring errmsg; errmsg.printf("Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension", - slot_tag, slot_tag); + slot_tag, slot_tag); image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr()); return IMAGE_INIT_FAIL; } diff --git a/src/mess/drivers/apf.c b/src/mess/drivers/apf.c index a5d21ac78e9..1ad3d9c15eb 100644 --- a/src/mess/drivers/apf.c +++ b/src/mess/drivers/apf.c @@ -246,7 +246,7 @@ void apf_state::machine_start() m_has_cart_ram = true; break; } - + m_cart->save_ram(); } } @@ -310,7 +310,7 @@ static ADDRESS_MAP_START( apfm1000_map, AS_PROGRAM, 8, apf_state ) AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM AM_SHARE("videoram") AM_RANGE(0x2000, 0x3fff) AM_MIRROR(0x1ffc) AM_DEVREADWRITE("pia0", pia6821_device, read, write) AM_RANGE(0x4000, 0x4fff) AM_MIRROR(0x1000) AM_ROM AM_REGION("roms", 0) - AM_RANGE(0x6800, 0x7fff) AM_NOP // BASIC accesses ROM here too, but this is installed at machine_start + AM_RANGE(0x6800, 0x7fff) AM_NOP // BASIC accesses ROM here too, but this is installed at machine_start AM_RANGE(0x8000, 0x9fff) AM_DEVREAD("cartslot", apf_cart_slot_device, read_rom) AM_RANGE(0xe000, 0xefff) AM_MIRROR(0x1000) AM_ROM AM_REGION("roms", 0) ADDRESS_MAP_END diff --git a/src/mess/drivers/apple2.c b/src/mess/drivers/apple2.c index 5da2149d2f8..e69ecef172c 100644 --- a/src/mess/drivers/apple2.c +++ b/src/mess/drivers/apple2.c @@ -177,14 +177,14 @@ UniDisk 3.5 drive!) The external drive port supports not only 5.25 drives but also UniDisk and Apple 3.5 drives, allowing via daisy-chaining any combination of UniDisk, Apple 3.5 and Apple 5.25 drives - up to three devices - ----------------------------------- - -TK3000 keyboard matrix - -Data bus D0-D7 is X0-X7 -Address bus A0-A11 is Y0-Y11 - + +---------------------------------- + +TK3000 keyboard matrix + +Data bus D0-D7 is X0-X7 +Address bus A0-A11 is Y0-Y11 + ***************************************************************************/ @@ -267,16 +267,16 @@ static ADDRESS_MAP_START( apple2_map, AS_PROGRAM, 8, apple2_state ) ADDRESS_MAP_END /* - + LS259 at H12 - + A8 = D A9 = A A10 = B A11 = C - - 374/259 outputs to 65C02 c000/c010 selected by Z80 WR OR Z80 IORQ? (schematic is not super legible) - + + 374/259 outputs to 65C02 c000/c010 selected by Z80 WR OR Z80 IORQ? (schematic is not super legible) + */ // RAM and ROM alternate in 8K blocks: ROM at 0/4/8/c, RAM at 2/6/a/e (RAM is only 1k and further mirrors inside those locations) @@ -1028,9 +1028,9 @@ static SLOT_INTERFACE_START(apple2_cards) SLOT_INTERFACE("mcms1", A2BUS_MCMS1) /* Mountain Computer Music System, card 1 of 2 */ SLOT_INTERFACE("mcms2", A2BUS_MCMS2) /* Mountain Computer Music System, card 2 of 2. must be in card 1's slot + 1! */ SLOT_INTERFACE("dx1", A2BUS_DX1) /* Decillonix DX-1 sampler card */ - SLOT_INTERFACE("tm2ho", A2BUS_TIMEMASTERHO) /* Applied Engineering TimeMaster II H.O. */ - SLOT_INTERFACE("mouse", A2BUS_MOUSE) /* Apple II Mouse Card */ -// SLOT_INTERFACE("magicmusician", A2BUS_MAGICMUSICIAN) /* Magic Musician Card */ + SLOT_INTERFACE("tm2ho", A2BUS_TIMEMASTERHO) /* Applied Engineering TimeMaster II H.O. */ + SLOT_INTERFACE("mouse", A2BUS_MOUSE) /* Apple II Mouse Card */ +// SLOT_INTERFACE("magicmusician", A2BUS_MAGICMUSICIAN) /* Magic Musician Card */ SLOT_INTERFACE_END static SLOT_INTERFACE_START(apple2eaux_cards) @@ -1197,7 +1197,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( tk3000, apple2e ) MCFG_CPU_REPLACE("maincpu", M65C02, 1021800) /* close to actual CPU frequency of 1.020484 MHz */ - MCFG_CPU_ADD("subcpu", Z80, 1021800) // schematics are illegible on where the clock comes from, but it *seems* to be the same as the 65C02 clock + MCFG_CPU_ADD("subcpu", Z80, 1021800) // schematics are illegible on where the clock comes from, but it *seems* to be the same as the 65C02 clock MCFG_CPU_PROGRAM_MAP(tk3000_kbd_map) MACHINE_CONFIG_END @@ -1330,7 +1330,7 @@ static MACHINE_CONFIG_DERIVED( laser128ex2, apple2c ) MCFG_A2BUS_ONBOARD_ADD("a2bus", "sl4", A2BUS_LASER128, NULL) MCFG_A2BUS_ONBOARD_ADD("a2bus", "sl5", A2BUS_LASER128, NULL) MCFG_A2BUS_ONBOARD_ADD("a2bus", "sl6", A2BUS_LASER128, NULL) - MCFG_A2BUS_ONBOARD_ADD("a2bus", "sl7", A2BUS_LASER128, NULL) + MCFG_A2BUS_ONBOARD_ADD("a2bus", "sl7", A2BUS_LASER128, NULL) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( space84, apple2p ) @@ -1672,7 +1672,7 @@ ROM_START(las128e2) ROM_LOAD ( "341-0265-a.chr", 0x1000, 0x1000, BAD_DUMP CRC(2651014d) SHA1(b2b5d87f52693817fc747df087a4aa1ddcdb1f10)) // need to dump real laser rom ROM_REGION(0x8000,"maincpu",0) - ROM_LOAD( "laser 128ex2 rom version 6.1.bin", 0x000000, 0x008000, CRC(7f911c90) SHA1(125754c1bd777d4c510f5239b96178c6f2e3236b) ) + ROM_LOAD( "laser 128ex2 rom version 6.1.bin", 0x000000, 0x008000, CRC(7f911c90) SHA1(125754c1bd777d4c510f5239b96178c6f2e3236b) ) ROM_REGION( 0x800, "keyboard", ROMREGION_ERASE00 ) ROM_LOAD( "342-0132-c.e12", 0x000, 0x800, BAD_DUMP CRC(e47045f4) SHA1(12a2e718f5f4acd69b6c33a45a4a940b1440a481) ) // need to dump real laser rom diff --git a/src/mess/drivers/apple2gs.c b/src/mess/drivers/apple2gs.c index b4bc5f463ce..485dce64382 100644 --- a/src/mess/drivers/apple2gs.c +++ b/src/mess/drivers/apple2gs.c @@ -576,7 +576,7 @@ ROM_START(apple2gsr0p2) // 3/10/1986 Cortland prototype, boots as "Apple //'ing ROM_LOAD ( "apple2gs.chr", 0x0000, 0x1000, CRC(91e53cd8) SHA1(34e2443e2ef960a36c047a09ed5a93f471797f89)) ROM_REGION(0x20000,"maincpu",0) - ROM_LOAD( "apple iigs alpha rom 2.0 19860310.bin", 0x000000, 0x020000, CRC(a47d275f) SHA1(c5836adcfc8be69c7351b84afa94c814e8d92b81) ) + ROM_LOAD( "apple iigs alpha rom 2.0 19860310.bin", 0x000000, 0x020000, CRC(a47d275f) SHA1(c5836adcfc8be69c7351b84afa94c814e8d92b81) ) ROM_REGION(0x20000, "es5503", ROMREGION_ERASE00) diff --git a/src/mess/drivers/apple3.c b/src/mess/drivers/apple3.c index 2edb7caafa7..9035551bd09 100644 --- a/src/mess/drivers/apple3.c +++ b/src/mess/drivers/apple3.c @@ -33,7 +33,7 @@ static SLOT_INTERFACE_START(apple3_cards) SLOT_INTERFACE("cffa2", A2BUS_CFFA2_6502) /* CFFA2000 Compact Flash for Apple II (www.dreher.net), 6502 firmware */ SLOT_INTERFACE("applicard", A2BUS_APPLICARD) /* PCPI Applicard */ SLOT_INTERFACE("thclock", A2BUS_THUNDERCLOCK) /* ThunderWare ThunderClock Plus - driver assumes slot 2 by default */ - SLOT_INTERFACE("mouse", A2BUS_MOUSE) /* Apple II Mouse Card */ + SLOT_INTERFACE("mouse", A2BUS_MOUSE) /* Apple II Mouse Card */ SLOT_INTERFACE_END static SLOT_INTERFACE_START( a3_floppies ) diff --git a/src/mess/drivers/atari400.c b/src/mess/drivers/atari400.c index 78c9667e54d..5cd907f2368 100644 --- a/src/mess/drivers/atari400.c +++ b/src/mess/drivers/atari400.c @@ -252,7 +252,7 @@ public: m_8000(*this, "8000"), m_a000(*this, "a000"), m_cart(*this, "cartleft"), - m_cart2(*this, "cartright") { } + m_cart2(*this, "cartright") { } DECLARE_MACHINE_START(a400); DECLARE_MACHINE_START(a800); @@ -267,7 +267,7 @@ public: DECLARE_WRITE8_MEMBER(a600xl_pia_pb_w); DECLARE_WRITE8_MEMBER(a800xl_pia_pb_w); - DECLARE_READ8_MEMBER(read_d5xx); // at least one cart type can enable/disable roms when reading + DECLARE_READ8_MEMBER(read_d5xx); // at least one cart type can enable/disable roms when reading DECLARE_WRITE8_MEMBER(disable_cart); // these are needed to handle carts which can disable ROM without @@ -290,13 +290,13 @@ public: DECLARE_WRITE8_MEMBER(xegs_low_w); DECLARE_READ8_MEMBER(xegs_high_r); DECLARE_WRITE8_MEMBER(xegs_high_w); - + TIMER_DEVICE_CALLBACK_MEMBER(a400_interrupt); TIMER_DEVICE_CALLBACK_MEMBER(a800xl_interrupt); TIMER_DEVICE_CALLBACK_MEMBER(a5200_interrupt); - + protected: - //required_device m_maincpu; // maincpu is already contained in atari_common_state + //required_device m_maincpu; // maincpu is already contained in atari_common_state required_device m_ram; required_device m_pia; optional_device m_dac; @@ -310,7 +310,7 @@ protected: int m_cart_disabled, m_cart_helper; int m_last_offs; UINT8 m_mmu, m_ext_bank; - + void setup_ram(int bank,UINT32 size); void setup_cart(a800_cart_slot_device *slot); }; @@ -334,18 +334,18 @@ READ8_MEMBER(a400_state::a600xl_low_r) READ8_MEMBER(a400_state::a1200xl_low_r) { - if (offset < 0x5000) // 0x0000-0x4fff + if (offset < 0x5000) // 0x0000-0x4fff return m_ram->pointer()[offset]; - else if (offset < 0x5800) // 0x5000-0x57ff + else if (offset < 0x5800) // 0x5000-0x57ff { if (m_mmu & 0x80) return m_ram->pointer()[offset]; else return m_region_maincpu->base()[0xd000 + (offset & 0x7ff)]; } - else if (offset < 0xc000) // 0x5800-0xbfff + else if (offset < 0xc000) // 0x5800-0xbfff return m_ram->pointer()[offset]; - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) return m_ram->pointer()[offset]; @@ -356,25 +356,25 @@ READ8_MEMBER(a400_state::a1200xl_low_r) READ8_MEMBER(a400_state::a800xl_low_r) { - if (offset < 0x5000) // 0x0000-0x4fff + if (offset < 0x5000) // 0x0000-0x4fff return m_ram->pointer()[offset]; - else if (offset < 0x5800) // 0x5000-0x57ff + else if (offset < 0x5800) // 0x5000-0x57ff { if (m_mmu & 0x80) return m_ram->pointer()[offset]; else return m_region_maincpu->base()[0xd000 + (offset & 0x7ff)]; } - else if (offset < 0xa000) // 0x5800-0x9fff + else if (offset < 0xa000) // 0x5800-0x9fff return m_ram->pointer()[offset]; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff { if (m_mmu & 0x02) return m_ram->pointer()[offset]; else return m_region_maincpu->base()[(offset & 0x1fff) + 0xa000]; } - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) return m_ram->pointer()[offset]; @@ -385,21 +385,21 @@ READ8_MEMBER(a400_state::a800xl_low_r) WRITE8_MEMBER(a400_state::a800xl_low_w) { - if (offset < 0x5000) // 0x0000-0x4fff + if (offset < 0x5000) // 0x0000-0x4fff m_ram->pointer()[offset] = data; - else if (offset < 0x5800) // 0x5000-0x57ff + else if (offset < 0x5800) // 0x5000-0x57ff { if (m_mmu & 0x80) m_ram->pointer()[offset] = data; } - else if (offset < 0xa000) // 0x5800-0x7fff + else if (offset < 0xa000) // 0x5800-0x7fff m_ram->pointer()[offset] = data; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff { if (m_mmu & 0x02) m_ram->pointer()[offset] = data; } - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) m_ram->pointer()[offset] = data; @@ -422,9 +422,9 @@ WRITE8_MEMBER(a400_state::a800xl_high_w) READ8_MEMBER(a400_state::a130xe_low_r) { - if (offset < 0x4000) // 0x0000-0x3fff + if (offset < 0x4000) // 0x0000-0x3fff return m_ram->pointer()[offset]; - else if (offset < 0x8000) // 0x4000-0x7fff + else if (offset < 0x8000) // 0x4000-0x7fff { // NOTE: ANTIC accesses to extra RAM are not supported yet! if (!(m_mmu & 0x80) && offset >= 0x5000 && offset < 0x5800) @@ -434,16 +434,16 @@ READ8_MEMBER(a400_state::a130xe_low_r) else return m_ram->pointer()[offset]; } - else if (offset < 0xa000) // 0x8000-0x9fff + else if (offset < 0xa000) // 0x8000-0x9fff return m_ram->pointer()[offset]; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff { if (m_mmu & 0x02) return m_ram->pointer()[offset]; else return m_region_maincpu->base()[(offset & 0x1fff) + 0xa000]; } - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) return m_ram->pointer()[offset]; @@ -454,9 +454,9 @@ READ8_MEMBER(a400_state::a130xe_low_r) WRITE8_MEMBER(a400_state::a130xe_low_w) { - if (offset < 0x4000) // 0x0000-0x3fff + if (offset < 0x4000) // 0x0000-0x3fff m_ram->pointer()[offset] = data; - else if (offset < 0x8000) // 0x4000-0x7fff + else if (offset < 0x8000) // 0x4000-0x7fff { // NOTE: ANTIC accesses to extra RAM are not supported yet! if (!(m_mmu & 0x80) && offset >= 0x5000 && offset < 0x5800) @@ -466,14 +466,14 @@ WRITE8_MEMBER(a400_state::a130xe_low_w) else m_ram->pointer()[offset] = data; } - else if (offset < 0xa000) // 0x5800-0x7fff + else if (offset < 0xa000) // 0x5800-0x7fff m_ram->pointer()[offset] = data; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff { if (m_mmu & 0x02) m_ram->pointer()[offset] = data; } - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) m_ram->pointer()[offset] = data; @@ -482,22 +482,22 @@ WRITE8_MEMBER(a400_state::a130xe_low_w) READ8_MEMBER(a400_state::xegs_low_r) { - if (offset < 0x5000) // 0x0000-0x4fff + if (offset < 0x5000) // 0x0000-0x4fff return m_ram->pointer()[offset]; - else if (offset < 0x5800) // 0x5000-0x57ff + else if (offset < 0x5800) // 0x5000-0x57ff { if (m_mmu & 0x80) return m_ram->pointer()[offset]; else return m_region_maincpu->base()[0xd000 + (offset & 0x7ff)]; } - else if (offset < 0x8000) // 0x5800-0x7fff + else if (offset < 0x8000) // 0x5800-0x7fff return m_ram->pointer()[offset]; - else if (offset < 0xa000) // 0x8000-0x9fff + else if (offset < 0xa000) // 0x8000-0x9fff return m_region_maincpu->base()[0x8000 + (offset & 0x1fff)]; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff return m_region_maincpu->base()[0x8000 + (offset & 0x1fff)]; - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) return m_ram->pointer()[offset]; @@ -508,18 +508,18 @@ READ8_MEMBER(a400_state::xegs_low_r) WRITE8_MEMBER(a400_state::xegs_low_w) { - if (offset < 0x5000) // 0x0000-0x4fff + if (offset < 0x5000) // 0x0000-0x4fff m_ram->pointer()[offset] = data; - else if (offset < 0x5800) // 0x5000-0x57ff + else if (offset < 0x5800) // 0x5000-0x57ff { if (m_mmu & 0x80) m_ram->pointer()[offset] = data; } - else if (offset < 0x8000) // 0x5800-0x7fff + else if (offset < 0x8000) // 0x5800-0x7fff m_ram->pointer()[offset] = data; - else if (offset < 0xc000) // 0xa000-0xbfff + else if (offset < 0xc000) // 0xa000-0xbfff return; - else // 0xc000-0xcfff + else // 0xc000-0xcfff { if (!(m_mmu & 0x01)) m_ram->pointer()[offset] = data; @@ -1705,14 +1705,14 @@ void a400_state::setup_ram(int bank, UINT32 size) switch (bank) { - case 0: // 0x0000-0x7fff + case 0: // 0x0000-0x7fff ram_top = MIN(size, 0x8000) - 1; m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x0000, ram_top, "0000"); if (m_0000 == NULL) m_0000.findit(); m_0000->set_base(m_ram->pointer()); break; - case 1: // 0x8000-0x9fff + case 1: // 0x8000-0x9fff ram_top = MIN(size, 0xa000) - 1; if (ram_top > 0x8000) { @@ -1720,9 +1720,9 @@ void a400_state::setup_ram(int bank, UINT32 size) if (m_8000 == NULL) m_8000.findit(); m_8000->set_base(m_ram->pointer() + 0x8000); - } + } break; - case 2: // 0xa000-0xbfff + case 2: // 0xa000-0xbfff ram_top = MIN(size, 0xc000) - 1; if (ram_top > 0xa000) { @@ -1730,7 +1730,7 @@ void a400_state::setup_ram(int bank, UINT32 size) if (m_a000 == NULL) m_a000.findit(); m_a000->set_base(m_ram->pointer() + 0xa000); - } + } break; } } @@ -1745,7 +1745,7 @@ READ8_MEMBER(a400_state::special_read_8000) { offset += 0x8000; if (m_ram->size() < offset) - return 0; + return 0; else return m_ram->pointer()[offset]; } @@ -1769,7 +1769,7 @@ READ8_MEMBER(a400_state::special_read_a000) { offset += 0xa000; if (m_ram->size() < offset) - return 0; + return 0; else return m_ram->pointer()[offset]; } @@ -1808,7 +1808,7 @@ WRITE8_MEMBER(a400_state::disable_cart) case A800_EXPRESS: case A800_DIAMOND: case A800_WILLIAMS: - // use m_cart_disabled & m_last_offs to avoid continuous remapping of + // use m_cart_disabled & m_last_offs to avoid continuous remapping of // the memory space in some games (e.g. dropzone) if (offset & 0x8 && !m_cart_disabled) m_cart_disabled = 1; @@ -1816,7 +1816,7 @@ WRITE8_MEMBER(a400_state::disable_cart) { if (m_cart_disabled) m_cart_disabled = 0; - + if ((offset & 0x7) != m_last_offs) { // we enter here only if we are writing to a different offset than last time @@ -1833,7 +1833,7 @@ WRITE8_MEMBER(a400_state::disable_cart) { if (m_cart_disabled) m_cart_disabled = 0; - + if ((offset & 0x0f) != m_last_offs) { // we enter here only if we are writing to a different offset than last time @@ -1845,7 +1845,7 @@ WRITE8_MEMBER(a400_state::disable_cart) case A800_SPARTADOS: // writes with offset & 8 are also used to enable/disable the subcart, so they go through! m_cart->write_d5xx(space, offset, data); - break; + break; case A800_OSSM091: case A800_OSS8K: if ((offset & 0x9) == 0x08) @@ -1868,7 +1868,7 @@ WRITE8_MEMBER(a400_state::disable_cart) break; default: break; - } + } } } @@ -1958,7 +1958,7 @@ void a400_state::setup_cart(a800_cart_slot_device *slot) m_maincpu->space(AS_PROGRAM).install_write_handler(0x4000, 0x5fff, write8_delegate(FUNC(a800_cart_slot_device::write_80xx),(a800_cart_slot_device*)slot)); m_maincpu->space(AS_PROGRAM).unmap_write(0x6000, 0xbfff); break; - } + } } } @@ -2014,7 +2014,7 @@ MACHINE_START_MEMBER( a400_state, a800 ) MACHINE_START_MEMBER( a400_state, a800xl ) { m_mmu = 0xfd; - m_ext_bank = 0x03; // only used by a130xe + m_ext_bank = 0x03; // only used by a130xe setup_cart(m_cart); save_item(NAME(m_cart_disabled)); @@ -2056,8 +2056,8 @@ WRITE8_MEMBER(a400_state::gtia_cb) **************************************************************/ WRITE8_MEMBER(a400_state::a600xl_pia_pb_w) -{ - m_mmu = data; +{ + m_mmu = data; } WRITE8_MEMBER(a400_state::a800xl_pia_pb_w) diff --git a/src/mess/drivers/atarist.c b/src/mess/drivers/atarist.c index 329213a6ed1..86ac1af97da 100644 --- a/src/mess/drivers/atarist.c +++ b/src/mess/drivers/atarist.c @@ -1228,7 +1228,7 @@ static ADDRESS_MAP_START( st_map, AS_PROGRAM, 16, st_state ) AM_RANGE(0x000008, 0x1fffff) AM_RAM AM_RANGE(0x200000, 0x3fffff) AM_RAM AM_RANGE(0x400000, 0xf9ffff) AM_READWRITE(berr_r, berr_w) - //AM_RANGE(0xfa0000, 0xfbffff) // mapped by the cartslot + //AM_RANGE(0xfa0000, 0xfbffff) // mapped by the cartslot AM_RANGE(0xfc0000, 0xfeffff) AM_ROM AM_REGION(M68000_TAG, 0) AM_WRITE(berr_w) AM_RANGE(0xff8000, 0xff8001) AM_READWRITE8(mmu_r, mmu_w, 0x00ff) AM_RANGE(0xff8200, 0xff8203) AM_READWRITE8(shifter_base_r, shifter_base_w, 0x00ff) @@ -1272,7 +1272,7 @@ static ADDRESS_MAP_START( megast_map, AS_PROGRAM, 16, megast_state ) AM_RANGE(0x000000, 0x000007) AM_ROM AM_REGION(M68000_TAG, 0) AM_RANGE(0x000008, 0x1fffff) AM_RAM AM_RANGE(0x200000, 0x3fffff) AM_RAM - //AM_RANGE(0xfa0000, 0xfbffff) // mapped by the cartslot + //AM_RANGE(0xfa0000, 0xfbffff) // mapped by the cartslot AM_RANGE(0xfc0000, 0xfeffff) AM_ROM AM_REGION(M68000_TAG, 0) // AM_RANGE(0xff7f30, 0xff7f31) AM_READWRITE(blitter_dst_inc_y_r, blitter_dst_inc_y_w) // for TOS 1.02 AM_RANGE(0xff8000, 0xff8001) AM_READWRITE8(mmu_r, mmu_w, 0x00ff) diff --git a/src/mess/drivers/atom.c b/src/mess/drivers/atom.c index 33da05e91d1..c3d6e1cc723 100644 --- a/src/mess/drivers/atom.c +++ b/src/mess/drivers/atom.c @@ -250,7 +250,7 @@ static ADDRESS_MAP_START( atom_mem, AS_PROGRAM, 8, atom_state ) AM_RANGE(0x0a05, 0x7fff) AM_RAM AM_RANGE(0x8000, 0x97ff) AM_RAM AM_SHARE("video_ram") AM_RANGE(0x9800, 0x9fff) AM_RAM -// AM_RANGE(0xa000, 0xafff) // mapped by the cartslot +// AM_RANGE(0xa000, 0xafff) // mapped by the cartslot AM_RANGE(0xb000, 0xb003) AM_MIRROR(0x3fc) AM_DEVREADWRITE(INS8255_TAG, i8255_device, read, write) // AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE(MC6854_TAG, mc6854_device, read, write) // AM_RANGE(0xb404, 0xb404) AM_READ_PORT("ECONET") @@ -680,7 +680,7 @@ int atom_state::load_cart(device_image_interface &image, generic_slot_device *sl } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - slot->common_load_rom(slot->get_rom_base(), size, "rom"); + slot->common_load_rom(slot->get_rom_base(), size, "rom"); return IMAGE_INIT_PASS; } @@ -882,12 +882,12 @@ ROM_END DRIVER_INIT_MEMBER(atomeb_state, atomeb) { // these have to be set here, so that we can pass m_ext[*] to device_image_load! - char str[8]; + char str[8]; for (int i = 0; i < 16; i++) { sprintf(str,"rom_a%x", i); m_ext[i] = machine().device(str); - } + } } diff --git a/src/mess/drivers/bbcbc.c b/src/mess/drivers/bbcbc.c index af1a7a703c7..a67db079108 100644 --- a/src/mess/drivers/bbcbc.c +++ b/src/mess/drivers/bbcbc.c @@ -42,7 +42,7 @@ public: static ADDRESS_MAP_START( bbcbc_prg, AS_PROGRAM, 8, bbcbc_state ) AM_RANGE(0x0000, 0x3fff) AM_ROM - //AM_RANGE(0x4000, 0xbfff) // mapped by the cartslot + //AM_RANGE(0x4000, 0xbfff) // mapped by the cartslot AM_RANGE(0xe000, 0xe02f) AM_RAM AM_RANGE(0xe030, 0xe030) AM_READ_PORT("LINE01") AM_RANGE(0xe031, 0xe031) AM_READ_PORT("LINE02") diff --git a/src/mess/drivers/beta.c b/src/mess/drivers/beta.c index daec10b2c1c..14799269d79 100644 --- a/src/mess/drivers/beta.c +++ b/src/mess/drivers/beta.c @@ -60,7 +60,7 @@ public: m_q8(*this, "Q8"), m_q9(*this, "Q9") { } - + required_device m_maincpu; required_device m_speaker; required_device m_eprom; @@ -68,18 +68,18 @@ public: required_ioport m_q7; required_ioport m_q8; required_ioport m_q9; - + virtual void machine_start(); - + DECLARE_READ8_MEMBER( riot_pa_r ); DECLARE_WRITE8_MEMBER( riot_pa_w ); DECLARE_READ8_MEMBER( riot_pb_r ); DECLARE_WRITE8_MEMBER( riot_pb_w ); DECLARE_INPUT_CHANGED_MEMBER( trigger_reset ); - + DECLARE_DEVICE_IMAGE_LOAD_MEMBER( beta_eprom ); DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( beta_eprom ); - + /* EPROM state */ int m_eprom_oe; int m_eprom_ce; @@ -87,11 +87,11 @@ public: UINT8 m_eprom_data; UINT8 m_old_data; dynamic_buffer m_eprom_rom; - + /* display state */ UINT8 m_ls145_p; UINT8 m_segment; - + emu_timer *m_led_refresh_timer; TIMER_CALLBACK_MEMBER(led_refresh); }; @@ -285,16 +285,16 @@ WRITE8_MEMBER( beta_state::riot_pb_w ) DEVICE_IMAGE_LOAD_MEMBER( beta_state, beta_eprom ) { UINT32 size = m_eprom->common_get_size("rom"); - + if (size != 0x800) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_eprom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_eprom->common_load_rom(m_eprom->get_rom_base(), size, "rom"); - + m_eprom->common_load_rom(m_eprom->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/casloopy.c b/src/mess/drivers/casloopy.c index 5490c6f131c..51e7eb991d7 100644 --- a/src/mess/drivers/casloopy.c +++ b/src/mess/drivers/casloopy.c @@ -478,13 +478,13 @@ DEVICE_IMAGE_LOAD_MEMBER( casloopy_state, loopy_cart ) UINT8 *SRC, *DST; dynamic_buffer temp; temp.resize(0x200000); - + m_cart->rom_alloc(size, GENERIC_ROM32_WIDTH, ENDIANNESS_LITTLE); SRC = temp; DST = m_cart->get_rom_base(); - m_cart->common_load_rom(temp, size, "rom"); - + m_cart->common_load_rom(temp, size, "rom"); + // fix endianness for (int i = 0; i < 0x200000; i += 4) { @@ -495,7 +495,7 @@ DEVICE_IMAGE_LOAD_MEMBER( casloopy_state, loopy_cart ) DST[i + 2] = tempa; DST[i + 3] = tempb; } - + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/cc40.c b/src/mess/drivers/cc40.c index 2211b16efb1..185fcb60b5b 100644 --- a/src/mess/drivers/cc40.c +++ b/src/mess/drivers/cc40.c @@ -51,7 +51,7 @@ provided that the machine is turned off properly. If a program is running, you may have to press [BREAK] before turning the CC-40 off. If RAM contents ends up dodgy somehow, just delete the nvram files. - + Officially, minimum total RAM size is 6KB. The system will still boot with less, but don't expect all software to work properly. @@ -114,7 +114,7 @@ public: UINT8 m_clock_control; UINT8 m_clock_divider; UINT8 m_key_select; - + UINT8 *m_sysram[2]; UINT16 m_sysram_size[2]; UINT16 m_sysram_end[2]; @@ -165,8 +165,8 @@ DEVICE_IMAGE_LOAD_MEMBER(cc40_state, cc40_cartridge) return IMAGE_INIT_FAIL; } - 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"); + 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_PASS; } @@ -265,7 +265,7 @@ WRITE8_MEMBER(cc40_state::bus_control_w) m_sysram_mask[0] = d3 - 1; m_sysram_end[1] = d3 + d2; m_sysram_mask[1] = d2 - 1; - + // d4,d5: cartridge memory addressing // 00: 2K @ $5000-$57ff & $5800-$5fff // 01: 8K @ $5000-$6fff & $7000-$8fff @@ -524,12 +524,12 @@ void cc40_state::init_sysram(int chip, UINT16 size) // init to largest possible m_sysram[chip] = auto_alloc_array(machine(), UINT8, 0x2000); save_pointer(NAME(m_sysram[chip]), 0x2000, chip); - + save_item(NAME(m_sysram_size[chip]), chip); save_item(NAME(m_sysram_end[chip]), chip); save_item(NAME(m_sysram_mask[chip]), chip); } - + m_nvram[chip]->set_base(m_sysram[chip], size); m_sysram_size[chip] = size; } diff --git a/src/mess/drivers/cgenie.c b/src/mess/drivers/cgenie.c index 7e2422f466f..990e8fe3fec 100644 --- a/src/mess/drivers/cgenie.c +++ b/src/mess/drivers/cgenie.c @@ -492,16 +492,16 @@ static const floppy_interface cgenie_floppy_interface = DEVICE_IMAGE_LOAD_MEMBER( cgenie_state, cgenie_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/channelf.c b/src/mess/drivers/channelf.c index e555fafdb34..360026065b6 100644 --- a/src/mess/drivers/channelf.c +++ b/src/mess/drivers/channelf.c @@ -178,7 +178,7 @@ void channelf_state::machine_start() m_maincpu->space(AS_PROGRAM).install_write_handler(0x3000, 0x3fff, write8_delegate(FUNC(channelf_cart_slot_device::write_bank),(channelf_cart_slot_device*)m_cart)); break; } - + m_cart->save_ram(); } } diff --git a/src/mess/drivers/concept.c b/src/mess/drivers/concept.c index 2de213bad24..ade1949db95 100644 --- a/src/mess/drivers/concept.c +++ b/src/mess/drivers/concept.c @@ -196,8 +196,8 @@ INPUT_PORTS_END SLOT_INTERFACE_START( concept_a2_cards ) SLOT_INTERFACE("fchdd", A2BUS_CORVUS) /* Corvus flat-cable HDD interface (see notes in a2corvus.c) */ - SLOT_INTERFACE("fdc01", A2BUS_CORVFDC01) /* Corvus WD1793 floppy controller */ - SLOT_INTERFACE("fdc02", A2BUS_CORVFDC02) /* Corvus NEC765 buffered floppy controller */ + SLOT_INTERFACE("fdc01", A2BUS_CORVFDC01) /* Corvus WD1793 floppy controller */ + SLOT_INTERFACE("fdc02", A2BUS_CORVFDC02) /* Corvus NEC765 buffered floppy controller */ SLOT_INTERFACE_END diff --git a/src/mess/drivers/crvision.c b/src/mess/drivers/crvision.c index 269d832135f..c984a021d63 100644 --- a/src/mess/drivers/crvision.c +++ b/src/mess/drivers/crvision.c @@ -712,7 +712,7 @@ void crvision_pal_state::machine_start() // state saving save_item(NAME(m_keylatch)); save_item(NAME(m_joylatch)); - + if (m_cart->exists()) { m_maincpu->space(AS_PROGRAM).install_read_handler(0x4000, 0x7fff, read8_delegate(FUNC(crvision_cart_slot_device::read_rom40),(crvision_cart_slot_device*)m_cart)); @@ -729,7 +729,7 @@ void laser2001_state::machine_start() // state saving save_item(NAME(m_keylatch)); save_item(NAME(m_joylatch)); - + if (m_cart->exists()) { m_maincpu->space(AS_PROGRAM).install_read_handler(0x4000, 0x7fff, read8_delegate(FUNC(crvision_cart_slot_device::read_rom40),(crvision_cart_slot_device*)m_cart)); diff --git a/src/mess/drivers/electron.c b/src/mess/drivers/electron.c index c8bebb637b3..b42f5a94270 100644 --- a/src/mess/drivers/electron.c +++ b/src/mess/drivers/electron.c @@ -194,7 +194,7 @@ ROM_START(electron) /* 24000 9 keyboard mirror */ /* 28000 10 Basic rom */ ROM_LOAD( "basic.rom", 0x28000, 0x4000, CRC(79434781) SHA1(4a7393f3a45ea309f744441c16723e2ef447a281) ) - /* 2c000 11 Basic rom mirror */ + /* 2c000 11 Basic rom mirror */ ROM_COPY( "user1", 0x28000, 0x2c000, 0x4000 ) /* 30000 12 available for cartridges with a language ROM */ /* 34000 13 available for cartridges with a language ROM */ diff --git a/src/mess/drivers/ep64.c b/src/mess/drivers/ep64.c index 0471c5b17b5..4ef1f30fb7c 100644 --- a/src/mess/drivers/ep64.c +++ b/src/mess/drivers/ep64.c @@ -320,7 +320,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( dave_64k_mem, AS_PROGRAM, 8, ep64_state ) AM_RANGE(0x000000, 0x007fff) AM_ROM AM_REGION(Z80_TAG, 0) - //AM_RANGE(0x010000, 0x01ffff) // mapped by the cartslot + //AM_RANGE(0x010000, 0x01ffff) // mapped by the cartslot AM_RANGE(0x3f0000, 0x3fffff) AM_DEVICE(NICK_TAG, nick_device, vram_map) ADDRESS_MAP_END diff --git a/src/mess/drivers/exelv.c b/src/mess/drivers/exelv.c index 6dc28b4d4c9..f59fda313a6 100644 --- a/src/mess/drivers/exelv.c +++ b/src/mess/drivers/exelv.c @@ -361,7 +361,7 @@ WRITE8_MEMBER(exelv_state::tms7041_portd_w) /* - CARTRIDGE ACCESS + CARTRIDGE ACCESS */ READ8_MEMBER(exelv_state::rom_r) { @@ -466,7 +466,7 @@ PALETTE_INIT_MEMBER(exelv_state, exelv) /* Machine Initialization */ MACHINE_START_MEMBER( exelv_state, exl100) -{ +{ /* register for state saving */ save_item(NAME(m_tms7020_portb)); save_item(NAME(m_tms7041_portb)); @@ -481,7 +481,7 @@ MACHINE_START_MEMBER( exelv_state, exeltel) UINT8 *rom = memregion("user1")->base() + 0x0200; membank("bank1")->configure_entry(0, rom); membank("bank1")->set_entry(0); - + /* register for state saving */ save_item(NAME(m_tms7020_portb)); save_item(NAME(m_tms7041_portb)); diff --git a/src/mess/drivers/fc100.c b/src/mess/drivers/fc100.c index 1b3a6e18335..b3c600750c0 100644 --- a/src/mess/drivers/fc100.c +++ b/src/mess/drivers/fc100.c @@ -114,7 +114,7 @@ private: static ADDRESS_MAP_START( fc100_mem, AS_PROGRAM, 8, fc100_state ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE( 0x0000, 0x5fff ) AM_ROM AM_REGION("roms", 0) - //AM_RANGE(0x6000, 0x6fff) // mapped by the cartslot + //AM_RANGE(0x6000, 0x6fff) // mapped by the cartslot AM_RANGE( 0x7800, 0x7fff ) AM_READ_BANK("bankr") AM_WRITE_BANK("bankw") // Banked RAM/ROM AM_RANGE( 0x8000, 0xbfff ) AM_RAM // expansion ram pack - if omitted you get a 'Pages?' prompt at boot AM_RANGE( 0xc000, 0xffff ) AM_RAM AM_SHARE("videoram") diff --git a/src/mess/drivers/fm7.c b/src/mess/drivers/fm7.c index 591058ab112..4d0aa7f1ab3 100644 --- a/src/mess/drivers/fm7.c +++ b/src/mess/drivers/fm7.c @@ -1001,105 +1001,105 @@ void fm7_state::fm7_update_bank(address_space & space, int bank, UINT8 physical) , m_avbank8, m_avbank9, m_avbank10, m_avbank11, m_avbank12, m_avbank13, m_avbank14, m_avbank15, m_avbank16 }; avbank[bank]->set_bank(physical); -/* UINT8* RAM = memregion("maincpu")->base(); - UINT16 size = 0xfff; - char bank_name[10]; - - if(bank == 15) - size = 0xbff; - - sprintf(bank_name,"bank%d",bank+1); - - if(physical >= 0x10 && physical <= 0x1b) - { - switch(physical) - { - case 0x10: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram0_r),this),write8_delegate(FUNC(fm7_state::fm7_vram0_w),this)); - break; - case 0x11: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram1_r),this),write8_delegate(FUNC(fm7_state::fm7_vram1_w),this)); - break; - case 0x12: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram2_r),this),write8_delegate(FUNC(fm7_state::fm7_vram2_w),this)); - break; - case 0x13: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram3_r),this),write8_delegate(FUNC(fm7_state::fm7_vram3_w),this)); - break; - case 0x14: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram4_r),this),write8_delegate(FUNC(fm7_state::fm7_vram4_w),this)); - break; - case 0x15: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram5_r),this),write8_delegate(FUNC(fm7_state::fm7_vram5_w),this)); - break; - case 0x16: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram6_r),this),write8_delegate(FUNC(fm7_state::fm7_vram6_w),this)); - break; - case 0x17: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram7_r),this),write8_delegate(FUNC(fm7_state::fm7_vram7_w),this)); - break; - case 0x18: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram8_r),this),write8_delegate(FUNC(fm7_state::fm7_vram8_w),this)); - break; - case 0x19: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram9_r),this),write8_delegate(FUNC(fm7_state::fm7_vram9_w),this)); - break; - case 0x1a: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vramA_r),this),write8_delegate(FUNC(fm7_state::fm7_vramA_w),this)); - break; - case 0x1b: - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vramB_r),this),write8_delegate(FUNC(fm7_state::fm7_vramB_w),this)); - break; - } +/* UINT8* RAM = memregion("maincpu")->base(); + UINT16 size = 0xfff; + char bank_name[10]; + + if(bank == 15) + size = 0xbff; + + sprintf(bank_name,"bank%d",bank+1); + + if(physical >= 0x10 && physical <= 0x1b) + { + switch(physical) + { + case 0x10: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram0_r),this),write8_delegate(FUNC(fm7_state::fm7_vram0_w),this)); + break; + case 0x11: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram1_r),this),write8_delegate(FUNC(fm7_state::fm7_vram1_w),this)); + break; + case 0x12: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram2_r),this),write8_delegate(FUNC(fm7_state::fm7_vram2_w),this)); + break; + case 0x13: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram3_r),this),write8_delegate(FUNC(fm7_state::fm7_vram3_w),this)); + break; + case 0x14: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram4_r),this),write8_delegate(FUNC(fm7_state::fm7_vram4_w),this)); + break; + case 0x15: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram5_r),this),write8_delegate(FUNC(fm7_state::fm7_vram5_w),this)); + break; + case 0x16: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram6_r),this),write8_delegate(FUNC(fm7_state::fm7_vram6_w),this)); + break; + case 0x17: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram7_r),this),write8_delegate(FUNC(fm7_state::fm7_vram7_w),this)); + break; + case 0x18: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram8_r),this),write8_delegate(FUNC(fm7_state::fm7_vram8_w),this)); + break; + case 0x19: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vram9_r),this),write8_delegate(FUNC(fm7_state::fm7_vram9_w),this)); + break; + case 0x1a: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vramA_r),this),write8_delegate(FUNC(fm7_state::fm7_vramA_w),this)); + break; + case 0x1b: + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_vramB_r),this),write8_delegate(FUNC(fm7_state::fm7_vramB_w),this)); + break; + } // membank(bank+1)->set_base(RAM+(physical<<12)-0x10000); - return; - } - if(physical == 0x1c) - { - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_console_ram_banked_r),this),write8_delegate(FUNC(fm7_state::fm7_console_ram_banked_w),this)); - return; - } - if(physical == 0x1d) - { - space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_sub_ram_ports_banked_r),this),write8_delegate(FUNC(fm7_state::fm7_sub_ram_ports_banked_w),this)); - return; - } - if(physical == 0x35) - { - if(m_init_rom_en && (m_type == SYS_FM11 || m_type == SYS_FM16)) - { - RAM = memregion("init")->base(); - space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); - space.nop_write(bank*0x1000,(bank*0x1000)+size); - membank(bank_name)->set_base(RAM+(physical<<12)-0x35000); - return; - } - } - if(physical == 0x36 || physical == 0x37) - { - if(m_init_rom_en && (m_type != SYS_FM11 && m_type != SYS_FM16)) - { - RAM = memregion("init")->base(); - space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); - space.nop_write(bank*0x1000,(bank*0x1000)+size); - membank(bank_name)->set_base(RAM+(physical<<12)-0x36000); - return; - } - } - if(physical > 0x37 && physical <= 0x3f) - { - if(m_basic_rom_en && (m_type != SYS_FM11 && m_type != SYS_FM16)) - { - RAM = memregion("fbasic")->base(); - space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); - space.nop_write(bank*0x1000,(bank*0x1000)+size); - membank(bank_name)->set_base(RAM+(physical<<12)-0x38000); - return; - } - } - space.install_readwrite_bank(bank*0x1000,(bank*0x1000)+size,bank_name); - membank(bank_name)->set_base(RAM+(physical<<12)); - */ + return; + } + if(physical == 0x1c) + { + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_console_ram_banked_r),this),write8_delegate(FUNC(fm7_state::fm7_console_ram_banked_w),this)); + return; + } + if(physical == 0x1d) + { + space.install_readwrite_handler(bank*0x1000,(bank*0x1000)+size,read8_delegate(FUNC(fm7_state::fm7_sub_ram_ports_banked_r),this),write8_delegate(FUNC(fm7_state::fm7_sub_ram_ports_banked_w),this)); + return; + } + if(physical == 0x35) + { + if(m_init_rom_en && (m_type == SYS_FM11 || m_type == SYS_FM16)) + { + RAM = memregion("init")->base(); + space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); + space.nop_write(bank*0x1000,(bank*0x1000)+size); + membank(bank_name)->set_base(RAM+(physical<<12)-0x35000); + return; + } + } + if(physical == 0x36 || physical == 0x37) + { + if(m_init_rom_en && (m_type != SYS_FM11 && m_type != SYS_FM16)) + { + RAM = memregion("init")->base(); + space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); + space.nop_write(bank*0x1000,(bank*0x1000)+size); + membank(bank_name)->set_base(RAM+(physical<<12)-0x36000); + return; + } + } + if(physical > 0x37 && physical <= 0x3f) + { + if(m_basic_rom_en && (m_type != SYS_FM11 && m_type != SYS_FM16)) + { + RAM = memregion("fbasic")->base(); + space.install_read_bank(bank*0x1000,(bank*0x1000)+size,bank_name); + space.nop_write(bank*0x1000,(bank*0x1000)+size); + membank(bank_name)->set_base(RAM+(physical<<12)-0x38000); + return; + } + } + space.install_readwrite_bank(bank*0x1000,(bank*0x1000)+size,bank_name); + membank(bank_name)->set_base(RAM+(physical<<12)); + */ } void fm7_state::fm7_mmr_refresh(address_space& space) diff --git a/src/mess/drivers/gameking.c b/src/mess/drivers/gameking.c index 6cc3cef8bb7..60b6960f3c8 100644 --- a/src/mess/drivers/gameking.c +++ b/src/mess/drivers/gameking.c @@ -103,16 +103,16 @@ DRIVER_INIT_MEMBER(gameking_state, gameking) DEVICE_IMAGE_LOAD_MEMBER( gameking_state, gameking_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size > 0x20000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/gamepock.c b/src/mess/drivers/gamepock.c index b65aee1d8f1..cb9816771dc 100644 --- a/src/mess/drivers/gamepock.c +++ b/src/mess/drivers/gamepock.c @@ -12,7 +12,7 @@ static ADDRESS_MAP_START(gamepock_mem, AS_PROGRAM, 8, gamepock_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000,0x0fff) AM_ROM AM_RANGE(0x1000,0x3fff) AM_NOP - //AM_RANGE(0x4000,0xbfff) AM_ROM // mapped by the cartslot + //AM_RANGE(0x4000,0xbfff) AM_ROM // mapped by the cartslot AM_RANGE(0xc000,0xc7ff) AM_MIRROR(0x0800) AM_RAM AM_RANGE(0xff80,0xffff) AM_RAM /* 128 bytes microcontroller RAM */ ADDRESS_MAP_END diff --git a/src/mess/drivers/gba.c b/src/mess/drivers/gba.c index 6a1190ce14d..c66e8987a14 100644 --- a/src/mess/drivers/gba.c +++ b/src/mess/drivers/gba.c @@ -1896,7 +1896,7 @@ READ32_MEMBER(gba_state::gba_bios_r) if (m_bios_protected != 0) offset = (m_bios_last_address + 8) / 4; - + return rom[offset & 0x3fff]; } diff --git a/src/mess/drivers/geniusiq.c b/src/mess/drivers/geniusiq.c index 63f5d3dcb01..b86ab54fa9f 100644 --- a/src/mess/drivers/geniusiq.c +++ b/src/mess/drivers/geniusiq.c @@ -759,10 +759,10 @@ void geniusiq_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER(geniusiq_state,iq128_cart) { UINT32 size = m_cart->common_get_size("rom"); - + // we always a 0x100000 region, for easier mapping in the memory map m_cart->rom_alloc(0x100000, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); m_cart_state = IQ128_ROM_CART; diff --git a/src/mess/drivers/gmaster.c b/src/mess/drivers/gmaster.c index d9ea92780a5..9c7cf293929 100644 --- a/src/mess/drivers/gmaster.c +++ b/src/mess/drivers/gmaster.c @@ -182,7 +182,7 @@ WRITE8_MEMBER(gmaster_state::gmaster_port_w) static ADDRESS_MAP_START( gmaster_mem, AS_PROGRAM, 8, gmaster_state ) AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w) - //AM_RANGE(0x8000, 0xfeff) // mapped by the cartslot + //AM_RANGE(0x8000, 0xfeff) // mapped by the cartslot AM_RANGE(0xff00, 0xffff) AM_RAM ADDRESS_MAP_END diff --git a/src/mess/drivers/ibmpcjr.c b/src/mess/drivers/ibmpcjr.c index e7ce6c289d9..7de1bf95ddf 100644 --- a/src/mess/drivers/ibmpcjr.c +++ b/src/mess/drivers/ibmpcjr.c @@ -464,7 +464,7 @@ int pcjr_state::load_cart(device_image_interface &image, generic_slot_device *sl size -= header_size; image.fseek(header_size, SEEK_SET); } - + slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, "rom"); diff --git a/src/mess/drivers/intv.c b/src/mess/drivers/intv.c index 905f99787a1..9beeae578ce 100644 --- a/src/mess/drivers/intv.c +++ b/src/mess/drivers/intv.c @@ -380,11 +380,11 @@ static ADDRESS_MAP_START( intv_mem, AS_PROGRAM, 16, intv_state ) AM_RANGE(0x01f0, 0x01ff) AM_DEVREADWRITE8("ay8914", ay8914_device, read, write, 0x00ff) AM_RANGE(0x0200, 0x035f) AM_READWRITE(intv_ram16_r, intv_ram16_w) AM_RANGE(0x0400, 0x04ff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom04) - AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide + AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide AM_RANGE(0x2000, 0x2fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom20) AM_RANGE(0x3000, 0x37ff) AM_DEVREAD("stic", stic_device, grom_read) // GROM, 8-bits wide - AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide - AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide + AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide + AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide AM_RANGE(0x4000, 0x47ff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom40) AM_RANGE(0x4800, 0x4fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom48) AM_RANGE(0x5000, 0x5fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom50) @@ -407,11 +407,11 @@ static ADDRESS_MAP_START( intvoice_mem, AS_PROGRAM, 16, intv_state ) AM_RANGE(0x01f0, 0x01ff) AM_DEVREADWRITE8("ay8914", ay8914_device, read, write, 0x00ff) AM_RANGE(0x0200, 0x035f) AM_READWRITE(intv_ram16_r, intv_ram16_w) AM_RANGE(0x0400, 0x04ff) AM_DEVREAD("voice", intv_voice_device, read_rom04) - AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide + AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide AM_RANGE(0x2000, 0x2fff) AM_DEVREAD("voice", intv_voice_device, read_rom20) AM_RANGE(0x3000, 0x37ff) AM_DEVREAD("stic", stic_device, grom_read) // GROM, 8-bits wide - AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide - AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide + AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide + AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide AM_RANGE(0x4000, 0x47ff) AM_DEVREAD("voice", intv_voice_device, read_rom40) AM_RANGE(0x4800, 0x4fff) AM_DEVREAD("voice", intv_voice_device, read_rom48) AM_RANGE(0x5000, 0x5fff) AM_DEVREAD("voice", intv_voice_device, read_rom50) @@ -432,12 +432,12 @@ static ADDRESS_MAP_START( intv2_mem , AS_PROGRAM, 16, intv_state ) AM_RANGE(0x0100, 0x01ef) AM_READWRITE(intv_ram8_r, intv_ram8_w) AM_RANGE(0x01f0, 0x01ff) AM_DEVREADWRITE8("ay8914", ay8914_device, read, write, 0x00ff) AM_RANGE(0x0200, 0x035f) AM_READWRITE(intv_ram16_r, intv_ram16_w) - AM_RANGE(0x0400, 0x04ff) AM_ROM AM_REGION("maincpu", 0x400 << 1) // Exec ROM, 10-bits wide - AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide + AM_RANGE(0x0400, 0x04ff) AM_ROM AM_REGION("maincpu", 0x400 << 1) // Exec ROM, 10-bits wide + AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0x1000 << 1) // Exec ROM, 10-bits wide AM_RANGE(0x2000, 0x2fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom20) - AM_RANGE(0x3000, 0x37ff) AM_DEVREAD("stic", stic_device, grom_read) // GROM, 8-bits wide - AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide - AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide + AM_RANGE(0x3000, 0x37ff) AM_DEVREAD("stic", stic_device, grom_read) // GROM, 8-bits wide + AM_RANGE(0x3800, 0x39ff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM, 8-bits wide + AM_RANGE(0x3a00, 0x3bff) AM_READWRITE(intv_gram_r, intv_gram_w) // GRAM Alias, 8-bits wide AM_RANGE(0x4000, 0x47ff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom40) AM_RANGE(0x4800, 0x4fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom48) AM_RANGE(0x5000, 0x5fff) AM_DEVREAD("cartslot", intv_cart_slot_device, read_rom50) diff --git a/src/mess/drivers/itt3030.c b/src/mess/drivers/itt3030.c index e6a748c3332..5d9aa417b6c 100644 --- a/src/mess/drivers/itt3030.c +++ b/src/mess/drivers/itt3030.c @@ -324,18 +324,18 @@ READ8_MEMBER(itt3030_state::i8078_r) { if (offset) { -// printf("Read 8078 status\n"); +// printf("Read 8078 status\n"); if (!m_keyskip) { - return 0x10; + return 0x10; } } else { -// printf("Read 8078 data\n"); +// printf("Read 8078 data\n"); if (!m_keyskip) { - m_keyskip = true; // don't keep reporting the 'b' key, just the once to trick the boot ROM + m_keyskip = true; // don't keep reporting the 'b' key, just the once to trick the boot ROM return 0x0c; } } @@ -433,21 +433,21 @@ WRITE_LINE_MEMBER(itt3030_state::fdchld_w) } /* - 7 Data Request (DRQ - inverted 1791-Signal) - 6 Interrupt Request (INTRQ - 1791-Signal) - 5 Head Load (HLD - inverted 1791-Signal) - 4 Ready 3 (Drive 3 ready) - 3 Ready 2 (Drive 2 ready) - 2 Ready l (Drive 1 ready) - 1 Write protect (the disk in the selected drive is write protected) - 0 HLT (Halt signal during head load and track change) + 7 Data Request (DRQ - inverted 1791-Signal) + 6 Interrupt Request (INTRQ - 1791-Signal) + 5 Head Load (HLD - inverted 1791-Signal) + 4 Ready 3 (Drive 3 ready) + 3 Ready 2 (Drive 2 ready) + 2 Ready l (Drive 1 ready) + 1 Write protect (the disk in the selected drive is write protected) + 0 HLT (Halt signal during head load and track change) */ READ8_MEMBER(itt3030_state::fdc_stat_r) { UINT8 res = 0; - floppy_image_device *floppy1 = m_con1 ? m_con1->get_device() : 0; - floppy_image_device *floppy2 = m_con2 ? m_con2->get_device() : 0; - floppy_image_device *floppy3 = m_con3 ? m_con3->get_device() : 0; + floppy_image_device *floppy1 = m_con1 ? m_con1->get_device() : 0; + floppy_image_device *floppy2 = m_con2 ? m_con2->get_device() : 0; + floppy_image_device *floppy3 = m_con3 ? m_con3->get_device() : 0; res = m_fdc_drq ? 0x80 : 0x00; res |= m_fdc_irq ? 0x40 : 0x00; @@ -472,14 +472,14 @@ WRITE8_MEMBER(itt3030_state::fdc_w) } /* - 7 SEL1 - Select drive 1 - 6 SEL2 - Select drive 2 - 5 SEL3 - Select drive 3 - 4 MOTOR - Motor on - 3 DOOR - Drive door lock drives 1 + 2 (not possible with all drives) - 2 SIDESEL - Select disk side - 1 KOMP - write comp on/off - 0 RG J - Change separator stage to read + 7 SEL1 - Select drive 1 + 6 SEL2 - Select drive 2 + 5 SEL3 - Select drive 3 + 4 MOTOR - Motor on + 3 DOOR - Drive door lock drives 1 + 2 (not possible with all drives) + 2 SIDESEL - Select disk side + 1 KOMP - write comp on/off + 0 RG J - Change separator stage to read */ WRITE8_MEMBER(itt3030_state::fdc_cmd_w) { diff --git a/src/mess/drivers/kyocera.c b/src/mess/drivers/kyocera.c index b83fee74748..3adb9ba6ac7 100644 --- a/src/mess/drivers/kyocera.c +++ b/src/mess/drivers/kyocera.c @@ -1167,10 +1167,10 @@ WRITE_LINE_MEMBER( tandy200_state::i8155_to_w ) void kc85_state::machine_start() { address_space &program = m_maincpu->space(AS_PROGRAM); - + astring region_tag; m_opt_region = memregion(region_tag.cpy(m_opt_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + /* initialize RTC */ m_rtc->cs_w(1); m_rtc->oe_w(1); @@ -1210,10 +1210,10 @@ void kc85_state::machine_start() void pc8201_state::machine_start() { UINT8 *ram = m_ram->pointer(); - + astring region_tag; m_opt_region = memregion(region_tag.cpy(m_opt_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + /* initialize RTC */ m_rtc->cs_w(1); m_rtc->oe_w(1); @@ -1244,10 +1244,10 @@ void pc8201_state::machine_start() void trsm100_state::machine_start() { address_space &program = m_maincpu->space(AS_PROGRAM); - + astring region_tag; m_opt_region = memregion(region_tag.cpy(m_opt_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + /* initialize RTC */ m_rtc->cs_w(1); m_rtc->oe_w(1); diff --git a/src/mess/drivers/laser3k.c b/src/mess/drivers/laser3k.c index 3b0d6632ca3..b07f74daef9 100644 --- a/src/mess/drivers/laser3k.c +++ b/src/mess/drivers/laser3k.c @@ -1,31 +1,31 @@ /*************************************************************************** - + laser3k.c Driver for VTech Laser 3000 / Dick Smith Electronics "The Cat" - + This machine is somewhat similar to a 48K Apple II if you blur your eyes a lot, but it generally fits in poorly with 100% compatible machines (no chance of a compatible language card or auxmem) so it gets its own driver. - + An "emulation cartridge" is required to run Apple II software; it's unclear what that consists of. - + Banking theory: - 6502 has 4 banking windows, 0000-3FFF, 4000-7FFF, 8000-BFFF, C000-FFFF - Physical address space is 0x00000-0x3FFFF. ROM and I/O at the top, RAM up to 0x2FFFF (192k max). - Each window has a bank number register at physical 3C07C/D/E/F - + Technical manual at: http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Computers/LASER/LASER%203000/Manuals/The%20Cat%20Technical%20Reference%20Manual.pdf - + TODO: - Finish keyboard - RGB graphics mode - FDC C800 page appears to be inside the FDC cartridge, need a dump :( (can hack to use IWM in the meantime) - Centronics printer port (data at 3c090, read ack at 3c1c0, read busy at 3c1c2) - cassette - + ***************************************************************************/ #include "emu.h" @@ -248,78 +248,78 @@ void laser3k_state::do_io(int offset) { switch (offset) { - case 0x08: // set border color to black + case 0x08: // set border color to black m_border_color = 0; break; - case 0x09: // set border color to red + case 0x09: // set border color to red m_border_color = 1; break; - case 0x0a: // set border color to green + case 0x0a: // set border color to green m_border_color = 12; break; - case 0x0b: // set border color to yellow + case 0x0b: // set border color to yellow m_border_color = 13; break; - case 0x0c: // set border color to blue + case 0x0c: // set border color to blue m_border_color = 6; break; - case 0x0d: // set border color to magenta + case 0x0d: // set border color to magenta m_border_color = 3; break; - case 0x0e: // set border color to cyan + case 0x0e: // set border color to cyan m_border_color = 14; break; - case 0x0f: // set border color to white + case 0x0f: // set border color to white m_border_color = 15; break; - case 0x18: // set bg color to black + case 0x18: // set bg color to black m_bg_color = 0; break; - case 0x19: // set bg color to red + case 0x19: // set bg color to red m_bg_color = 1; break; - case 0x1a: // set bg color to green + case 0x1a: // set bg color to green m_bg_color = 12; break; - case 0x1b: // set bg color to yellow + case 0x1b: // set bg color to yellow m_bg_color = 13; break; - case 0x1c: // set bg color to blue + case 0x1c: // set bg color to blue m_bg_color = 6; break; - case 0x1d: // set bg color to magenta + case 0x1d: // set bg color to magenta m_bg_color = 3; break; - case 0x1e: // set bg color to cyan + case 0x1e: // set bg color to cyan m_bg_color = 14; break; - case 0x1f: // set bg color to white + case 0x1f: // set bg color to white m_bg_color = 15; break; - case 0x28: // set fg color to normal + case 0x28: // set fg color to normal m_fg_color = 15; break; - case 0x29: // set fg color to red + case 0x29: // set fg color to red m_fg_color = 1; break; - case 0x2a: // set fg color to green + case 0x2a: // set fg color to green m_fg_color = 12; break; - case 0x2b: // set fg color to yellow + case 0x2b: // set fg color to yellow m_fg_color = 13; break; - case 0x2c: // set fg color to blue + case 0x2c: // set fg color to blue m_fg_color = 6; break; - case 0x2d: // set fg color to magenta + case 0x2d: // set fg color to magenta m_fg_color = 3; break; - case 0x2e: // set fg color to cyan + case 0x2e: // set fg color to cyan m_fg_color = 14; break; - case 0x2f: // set fg color to white + case 0x2f: // set fg color to white m_fg_color = 15; break; @@ -328,51 +328,51 @@ void laser3k_state::do_io(int offset) m_speaker->level_w(m_speaker_state); break; - case 0x4c: // low resolution (40 column) + case 0x4c: // low resolution (40 column) m_80col = false; m_maincpu->set_unscaled_clock(1021800); break; - case 0x4d: // RGB mode + case 0x4d: // RGB mode m_gfxmode = RGB; break; - case 0x4e: // double hi-res + case 0x4e: // double hi-res m_80col = true; m_gfxmode = DHIRES; m_maincpu->set_unscaled_clock(1021800*2); break; - - case 0x4f: // high resolution (80 column). Yes, the CPU clock also doubles when the pixel clock does (!) + + case 0x4f: // high resolution (80 column). Yes, the CPU clock also doubles when the pixel clock does (!) m_80col = true; m_maincpu->set_unscaled_clock(1021800*2); break; - case 0x50: // graphics mode + case 0x50: // graphics mode m_gfxmode = HIRES; break; - case 0x51: // text mode + case 0x51: // text mode m_gfxmode = TEXT; break; - case 0x52: // no mix + case 0x52: // no mix m_mix = false; break; - case 0x53: // mixed mode + case 0x53: // mixed mode m_mix = true; break; - case 0x54: // set page 1 + case 0x54: // set page 1 m_disp_page = 0; break; - case 0x55: // set page 2 + case 0x55: // set page 2 m_disp_page = 1; break; - case 0x56: // disable emulation (?) + case 0x56: // disable emulation (?) break; default: @@ -385,10 +385,10 @@ READ8_MEMBER( laser3k_state::io_r ) { switch (offset) { - case 0x00: // keyboard latch + case 0x00: // keyboard latch return m_transchar | m_strobe; - case 0x10: // keyboard strobe + case 0x10: // keyboard strobe { UINT8 rv = m_transchar | m_strobe; m_strobe = 0; @@ -397,16 +397,16 @@ READ8_MEMBER( laser3k_state::io_r ) case 0x7c: return m_bank0val; - + case 0x7d: return m_bank1val; - + case 0x7e: return m_bank2val; - + case 0x7f: return m_bank3val; - + default: do_io(offset); break; @@ -419,18 +419,18 @@ WRITE8_MEMBER( laser3k_state::io_w ) { switch (offset) { - case 0x10: // clear keyboard latch + case 0x10: // clear keyboard latch m_strobe = 0; break; - case 0x68: // SN76489 sound + case 0x68: // SN76489 sound m_sn->write(space, 0, data); break; - case 0x78: // called "SYSTEM" in the boot ROM listing, but unsure what it does + case 0x78: // called "SYSTEM" in the boot ROM listing, but unsure what it does break; - case 0x7c: // bank 0 + case 0x7c: // bank 0 m_bank0val = data & 0xf; m_bank0->set_bank(m_bank0val); break; @@ -440,12 +440,12 @@ WRITE8_MEMBER( laser3k_state::io_w ) m_bank1->set_bank(m_bank1val); break; - case 0x7e: // bank 2 + case 0x7e: // bank 2 m_bank2val = data & 0xf; m_bank2->set_bank(m_bank2val); break; - case 0x7f: // bank 3 + case 0x7f: // bank 3 m_bank3val = data & 0xf; m_bank3->set_bank(m_bank3val); break; @@ -460,15 +460,15 @@ READ8_MEMBER( laser3k_state::io2_r ) { switch (offset) { - case 0xc2: // h-blank status + case 0xc2: // h-blank status return space.machine().first_screen()->hblank() ? 0x80 : 0x00; - case 0xc3: // v-blank status + case 0xc3: // v-blank status return space.machine().first_screen()->vblank() ? 0x80 : 0x00; - case 0xc5: // CPU 1/2 MHz status? + case 0xc5: // CPU 1/2 MHz status? return 0x00; - + default: printf("io2_r @ unknown %x\n", offset); break; @@ -505,7 +505,7 @@ void laser3k_state::plot_text_character(bitmap_ind16 &bitmap, int xpos, int ypos for (i = 0; i < xscale; i++) { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; + bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; } } } @@ -520,11 +520,11 @@ void laser3k_state::text_update(screen_device &screen, bitmap_ind16 &bitmap, con if (m_80col) { - start_address = (m_disp_page == 0) ? 0x1000 : 0x1800; + start_address = (m_disp_page == 0) ? 0x1000 : 0x1800; } else { - start_address = (m_disp_page == 0) ? 0x400 : 0x800; + start_address = (m_disp_page == 0) ? 0x400 : 0x800; } m_flash = ((machine().time() * 4).seconds & 1) ? 1 : 0; @@ -541,9 +541,9 @@ void laser3k_state::text_update(screen_device &screen, bitmap_ind16 &bitmap, con /* calculate address */ address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - plot_text_character(bitmap, col * 7, row, 1, m_a2_videoram[address], + plot_text_character(bitmap, col * 7, row, 1, m_a2_videoram[address], memregion("gfx1")->base(), memregion("gfx1")->bytes()); - plot_text_character(bitmap, (col + 40) * 7, row, 1, m_a2_videoram[address+0x400], + plot_text_character(bitmap, (col + 40) * 7, row, 1, m_a2_videoram[address+0x400], memregion("gfx1")->base(), memregion("gfx1")->bytes()); } } @@ -553,7 +553,7 @@ void laser3k_state::text_update(screen_device &screen, bitmap_ind16 &bitmap, con { /* calculate address */ address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - plot_text_character(bitmap, col * 14, row, 2, m_a2_videoram[address], + plot_text_character(bitmap, col * 14, row, 2, m_a2_videoram[address], memregion("gfx1")->base(), memregion("gfx1")->bytes()); } } @@ -565,7 +565,7 @@ void laser3k_state::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, cons const UINT8 *vram; int row, col, b; int offset; - UINT8 vram_row[42] ; + UINT8 vram_row[42] ; UINT16 v; UINT16 *p; UINT32 w; @@ -601,7 +601,7 @@ void laser3k_state::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, cons | (((UINT32) vram_row[col+2] & 0x7f) << 14); artifact_map_ptr = &m_hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; *(p++) = v; @@ -629,7 +629,7 @@ void laser3k_state::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, con if (endrow < beginrow) return; - vram = m_ram->pointer() + (m_disp_page ? 0x8000 : 0x4000); + vram = m_ram->pointer() + (m_disp_page ? 0x8000 : 0x4000); vram_row[0] = 0; vram_row[81] = 0; @@ -641,12 +641,12 @@ void laser3k_state::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, con offset = ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)) | ((row & 7) << 10); if (col < 40) { - vram_row[1+(col*2)+0] = vram[offset]; + vram_row[1+(col*2)+0] = vram[offset]; vram_row[1+(col*2)+1] = vram[offset+1]; } else { - vram_row[1+(col*2)+0] = vram[offset+0x2000]; + vram_row[1+(col*2)+0] = vram[offset+0x2000]; vram_row[1+(col*2)+1] = vram[offset+0x2001]; } } @@ -659,7 +659,7 @@ void laser3k_state::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, con | (((UINT32) vram_row[col+1] & 0x7f) << 7) | (((UINT32) vram_row[col+2] & 0x7f) << 14); - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = m_dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; *(p++) = v; @@ -673,18 +673,18 @@ UINT32 laser3k_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, switch (m_gfxmode) { case TEXT: - text_update(screen, bitmap, cliprect, 0, 191); + text_update(screen, bitmap, cliprect, 0, 191); break; case HIRES: if (m_mix) { - hgr_update(screen, bitmap, cliprect, 0, 159); - text_update(screen, bitmap, cliprect, 160, 191); + hgr_update(screen, bitmap, cliprect, 0, 159); + text_update(screen, bitmap, cliprect, 160, 191); } else { - hgr_update(screen, bitmap, cliprect, 0, 191); + hgr_update(screen, bitmap, cliprect, 0, 191); } break; @@ -694,12 +694,12 @@ UINT32 laser3k_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, case DHIRES: if (m_mix) { - dhgr_update(screen, bitmap, cliprect, 0, 159); - text_update(screen, bitmap, cliprect, 160, 191); + dhgr_update(screen, bitmap, cliprect, 0, 159); + text_update(screen, bitmap, cliprect, 160, 191); } else { - dhgr_update(screen, bitmap, cliprect, 0, 191); + dhgr_update(screen, bitmap, cliprect, 0, 191); } break; } @@ -793,14 +793,14 @@ WRITE_LINE_MEMBER(laser3k_state::ay3600_data_ready_w) mod = (m_kbspecial->read() & 0x06) ? 0x01 : 0x00; mod |= (m_kbspecial->read() & 0x08) ? 0x02 : 0x00; -// printf("lastchar = %02x\n", m_lastchar & 0x3f); +// printf("lastchar = %02x\n", m_lastchar & 0x3f); m_transchar = key_remap[m_lastchar&0x3f][mod]; if (m_transchar != 0) { m_strobe = 0x80; -// printf("new char = %04x (%02x)\n", m_lastchar&0x3f, m_transchar); +// printf("new char = %04x (%02x)\n", m_lastchar&0x3f, m_transchar); } } } @@ -865,7 +865,7 @@ static INPUT_PORTS_START( laser3k ) PORT_BIT(0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(27) PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('A') PORT_CHAR('a') PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') - PORT_BIT(0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('\"') + PORT_BIT(0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('\"') PORT_BIT(0x080, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT(0x100, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT(0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) diff --git a/src/mess/drivers/m5.c b/src/mess/drivers/m5.c index c9797394764..c1e86d3d633 100644 --- a/src/mess/drivers/m5.c +++ b/src/mess/drivers/m5.c @@ -243,7 +243,7 @@ WRITE8_MEMBER( m5_state::fd5_tc_w ) static ADDRESS_MAP_START( m5_mem, AS_PROGRAM, 8, m5_state ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x1fff) AM_ROM - //AM_RANGE(0x2000, 0x6fff) // mapped by the cartslot + //AM_RANGE(0x2000, 0x6fff) // mapped by the cartslot AM_RANGE(0x7000, 0x7fff) AM_RAM AM_RANGE(0x8000, 0xffff) AM_RAM ADDRESS_MAP_END diff --git a/src/mess/drivers/msx.c b/src/mess/drivers/msx.c index b1cc5bacb21..8d75eb30f8b 100644 --- a/src/mess/drivers/msx.c +++ b/src/mess/drivers/msx.c @@ -1926,8 +1926,8 @@ static MACHINE_CONFIG_DERIVED( cpc50b, msx_ntsc ) // 1? Cartridge slot // No keyboard? // No cassette port? - // No printer port? - + // No printer port? + MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) MCFG_MSX_LAYOUT_RAM("ram", 2, 0, 3, 1) /* 16KB RAM */ @@ -2142,7 +2142,7 @@ static MACHINE_CONFIG_DERIVED( gfc1080a, msx_ntsc ) MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) MCFG_MSX_LAYOUT_RAM("ram", 2, 0, 0, 4) // 64KB RAM MCFG_MSX_LAYOUT_CARTRIDGE("cartslot2", 3, 0) - + MCFG_FRAGMENT_ADD( msx1_cartlist ) MACHINE_CONFIG_END @@ -4009,7 +4009,7 @@ static MACHINE_CONFIG_DERIVED( hc6, msx_ntsc ) // AY8910/YM2149? // FDC: None, 0 drives, // 2 Cartridge slots? - + MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) MCFG_MSX_LAYOUT_RAM("ram", 2, 0, 2, 2) // 32KB RAM @@ -4029,7 +4029,7 @@ static MACHINE_CONFIG_DERIVED( hc7, msx_ntsc ) // AY8910/YM2149? // FDC: None, 0 drives, // 2 Cartridge slots? - + MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) MCFG_MSX_LAYOUT_RAM("ram", 2, 0, 0, 4) // 64KB RAM @@ -4062,7 +4062,7 @@ MACHINE_CONFIG_END /* MSX - Yamaha CX5F (with SFG05) */ -ROM_START (cx5f) +ROM_START (cx5f) ROM_REGION (0x8000, "maincpu", 0) ROM_LOAD ("cx5fbios.rom", 0x0000, 0x8000, CRC(dc662057) SHA1(36d77d357a5fd15af2ab266ee66e5091ba4770a3)) ROM_END @@ -6036,30 +6036,30 @@ MACHINE_CONFIG_END /* MSX2 - Sanyo MPC-2500FD */ ROM_START (mpc2500f) - ROM_REGION (0x10000, "maincpu", 0) - ROM_LOAD ("mpc2500fdbios.rom", 0x0000, 0x8000, CRC(e7d08e29) SHA1(0f851ee7a1cf79819f61cc89e9948ee72a413802)) - ROM_LOAD ("mpc2500fdext.rom", 0x8000, 0x4000, CRC(3d7dc718) SHA1(e1f834b28c3ee7c9f79fe6fbf2b23c8a0617892b)) + ROM_REGION (0x10000, "maincpu", 0) + ROM_LOAD ("mpc2500fdbios.rom", 0x0000, 0x8000, CRC(e7d08e29) SHA1(0f851ee7a1cf79819f61cc89e9948ee72a413802)) + ROM_LOAD ("mpc2500fdext.rom", 0x8000, 0x4000, CRC(3d7dc718) SHA1(e1f834b28c3ee7c9f79fe6fbf2b23c8a0617892b)) ROM_LOAD ("mpc2500fddisk.rom", 0xc000, 0x4000, CRC(38454059) SHA1(58ac78bba29a06645ca8d6a94ef2ac68b743ad32)) ROM_END static MACHINE_CONFIG_DERIVED( mpc2500f, msx2 ) - // YM2149 - // FDC: wd2793?, 1? 3.5" DSDD drive? - // 2 Cartridge slots? + // YM2149 + // FDC: wd2793?, 1? 3.5" DSDD drive? + // 2 Cartridge slots? // S-3527 MSX Eninge - MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) - MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) - MCFG_MSX_LAYOUT_CARTRIDGE("cartslot2", 2, 0) + MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) + MCFG_MSX_LAYOUT_CARTRIDGE("cartslot1", 1, 0) + MCFG_MSX_LAYOUT_CARTRIDGE("cartslot2", 2, 0) MCFG_MSX_LAYOUT_ROM("ext", 2, 3, 0, 1, "maincpu", 0x8000) MCFG_MSX_LAYOUT_DISK1("disk", 3, 1, 1, 1, "maincpu", 0xC000) - MCFG_MSX_LAYOUT_RAM_MM("ram_mm", 3, 2, 0x10000) /* 64KB?? Mapper RAM */ + MCFG_MSX_LAYOUT_RAM_MM("ram_mm", 3, 2, 0x10000) /* 64KB?? Mapper RAM */ MCFG_FRAGMENT_ADD( msx_wd2793_force_ready ) MCFG_FRAGMENT_ADD( msx_1_35_dd_drive ) MCFG_FRAGMENT_ADD( msx2_floplist ) - MCFG_FRAGMENT_ADD( msx2_cartlist ) + MCFG_FRAGMENT_ADD( msx2_cartlist ) MACHINE_CONFIG_END /* MSX2 - Sanyo Wavy MPC-25FD */ @@ -7202,7 +7202,7 @@ ROM_START (victhc95a) ROM_LOAD ("hc95aext.rom", 0x8000, 0x4000, CRC(4a48779c) SHA1(b8e30d604d319d511cbfbc61e5d8c38fbb9c5a33)) ROM_LOAD ("hc95adisk.rom", 0xc000, 0x4000, CRC(11bca2ed) SHA1(a7a34671bddb48fa6c74182e2977f9129558ec32)) ROM_LOAD ("hc95afirm.rom", 0x10000, 0x4000, CRC(53791d91) SHA1(caeffdd654394726c8c0824b21af7ff51c0b1031)) - + ROM_REGION (0x20000, "kanji", 0) ROM_LOAD ("hc95akfn.rom", 0x0000, 0x20000, CRC(d23d4d2d) SHA1(db03211b7db46899df41db2b1dfbec972109a967)) ROM_END @@ -7215,7 +7215,7 @@ static MACHINE_CONFIG_DERIVED( victhc95a, msx2 ) // 1 Cartridge slot (slot 1 or 2?) // S-1985 MSX Engine // V9958 VDP - + MCFG_MSX_LAYOUT_ROM("bios", 0, 0, 0, 2, "maincpu", 0x0000) MCFG_MSX_LAYOUT_ROM("ext", 0, 1, 0, 1, "maincpu", 0x8000) MCFG_MSX_LAYOUT_ROM("firm", 0, 1, 1, 1, "maincpu", 0x10000) @@ -7387,7 +7387,7 @@ ROM_END static MACHINE_CONFIG_DERIVED( yis604, msx2 ) // YM2149 (in S-3527) - // FDC: None, 0 drives + // FDC: None, 0 drives // 2 Cartridge slots // S-3527 MSX Engine @@ -7398,7 +7398,7 @@ static MACHINE_CONFIG_DERIVED( yis604, msx2 ) MCFG_MSX_LAYOUT_ROM("yrm502", 3, 1, 1, 1, "maincpu", 0xc000) MCFG_MSX_LAYOUT_RAM_MM("ram_mm", 3, 2, 0x10000) // 64KB Mapper RAM MCFG_MSX_LAYOUT_YAMAHA_EXPANSION("expansion", 3, 3, "sfg05") - + MCFG_FRAGMENT_ADD( msx2_cartlist ) MACHINE_CONFIG_END @@ -8433,4 +8433,3 @@ COMP(19??, hbf9sp, 0, 0, hbf9sp, msx2jp, driver_device, 0, "Son /* Temporary placeholders, Turbo-R hardware is not supported yet */ COMP(19??, fsa1gt, 0, 0, fsa1gt, msx2jp, driver_device, 0, "Panasonic", "FS-A1GT (MSX Turbo-R)", GAME_NOT_WORKING) COMP(19??, fsa1st, 0, 0, fsa1st, msx2jp, driver_device, 0, "Panasonic", "FS-A1ST (MSX Turbo-R)", GAME_NOT_WORKING) - diff --git a/src/mess/drivers/myvision.c b/src/mess/drivers/myvision.c index 7c4254fbba2..0bbc56f2c78 100644 --- a/src/mess/drivers/myvision.c +++ b/src/mess/drivers/myvision.c @@ -66,7 +66,7 @@ private: static ADDRESS_MAP_START(myvision_mem, AS_PROGRAM, 8, myvision_state) ADDRESS_MAP_UNMAP_HIGH - //AM_RANGE(0x0000, 0x5fff) // mapped by the cartslot + //AM_RANGE(0x0000, 0x5fff) // mapped by the cartslot AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_RANGE(0xe000, 0xe000) AM_DEVREADWRITE("tms9918", tms9918a_device, vram_read, vram_write) AM_RANGE(0xe002, 0xe002) AM_DEVREADWRITE("tms9918", tms9918a_device, register_read, register_write) @@ -144,15 +144,15 @@ void myvision_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER( myvision_state, cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x4000 && size != 0x6000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/nc.c b/src/mess/drivers/nc.c index 85295fb2f45..a900f7fc83c 100644 --- a/src/mess/drivers/nc.c +++ b/src/mess/drivers/nc.c @@ -801,7 +801,7 @@ void nc_state::machine_start() m_card_size = m_card_ram->bytes(); else m_card_size = 0; - + /* keyboard timer */ m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this)); m_keyboard_timer->adjust(attotime::from_msec(10)); @@ -1138,14 +1138,14 @@ MACHINE_RESET_MEMBER(nc_state, nc200) MACHINE_START_MEMBER(nc_state, nc200) { m_type = NC_TYPE_200; - + astring region_tag; m_card_ram = memregion(region_tag.cpy(m_card->tag()).cat(GENERIC_ROM_REGION_TAG)); if (m_card_ram) m_card_size = m_card_ram->bytes(); else m_card_size = 0; - + /* keyboard timer */ m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this)); m_keyboard_timer->adjust(attotime::from_msec(10)); diff --git a/src/mess/drivers/nes.c b/src/mess/drivers/nes.c index 447d6cedc3e..f9823fa387d 100644 --- a/src/mess/drivers/nes.c +++ b/src/mess/drivers/nes.c @@ -752,10 +752,10 @@ void nes_state::setup_disk(nes_disksys_device *slot) space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(nes_disksys_device::write_m), (nes_disksys_device *)slot)); space.install_read_handler(0x8000, 0xffff, read8_delegate(FUNC(nes_disksys_device::read_h), (nes_disksys_device *)slot)); space.install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(nes_disksys_device::write_h), (nes_disksys_device *)slot)); - + slot->vram_alloc(0x2000); slot->prgram_alloc(0x8000); - + slot->pcb_start(machine(), m_ciram, FALSE); slot->pcb_reg_postload(machine()); m_ppu->space(AS_PROGRAM).install_readwrite_handler(0, 0x1fff, read8_delegate(FUNC(device_nes_cart_interface::chr_r),(device_nes_cart_interface *)slot), write8_delegate(FUNC(device_nes_cart_interface::chr_w),(device_nes_cart_interface *)slot)); @@ -768,7 +768,7 @@ void nes_state::setup_disk(nes_disksys_device *slot) MACHINE_START_MEMBER( nes_state, fds ) -{ +{ m_ciram = auto_alloc_array(machine(), UINT8, 0x800); setup_ioports(); setup_disk(m_disk); @@ -778,14 +778,14 @@ MACHINE_RESET_MEMBER( nes_state, fds ) { // Reset the mapper variables m_disk->pcb_reset(); - + // the rest is the same as for nes/famicom/dendy m_maincpu->reset(); - + memset(m_pad_latch, 0, sizeof(m_pad_latch)); memset(m_zapper_latch, 0, sizeof(m_zapper_latch)); m_paddle_latch = 0; - m_paddle_btn_latch = 0; + m_paddle_btn_latch = 0; } static MACHINE_CONFIG_DERIVED( fds, famicom ) @@ -810,7 +810,7 @@ MACHINE_START_MEMBER( nes_state, famitwin ) if (!m_cartslot->exists()) { setup_disk(m_disk); - + // replace the famicom disk ROM with the famicom twin one (until we modernize the floppy drive) m_maincpu->space(AS_PROGRAM).install_read_bank(0xe000, 0xffff, "ftbios"); membank("ftbios")->set_base(machine().root_device().memregion("maincpu")->base() + 0xe000); @@ -824,14 +824,14 @@ MACHINE_RESET_MEMBER( nes_state, famitwin ) // if there is no cart inserted, initialize the disk expansion instead if (!m_cartslot->exists()) m_disk->pcb_reset(); - + // the rest is the same as for nes/famicom/dendy m_maincpu->reset(); - + memset(m_pad_latch, 0, sizeof(m_pad_latch)); memset(m_zapper_latch, 0, sizeof(m_zapper_latch)); m_paddle_latch = 0; - m_paddle_btn_latch = 0; + m_paddle_btn_latch = 0; } static MACHINE_CONFIG_DERIVED( famitwin, famicom ) diff --git a/src/mess/drivers/ngp.c b/src/mess/drivers/ngp.c index 00dafbee343..d98dfb9c3e7 100644 --- a/src/mess/drivers/ngp.c +++ b/src/mess/drivers/ngp.c @@ -136,7 +136,7 @@ public: m_k1ge(*this, "k1ge"), m_io_controls(*this, "Controls"), m_io_power(*this, "Power") , - m_maincpu(*this, "maincpu") + m_maincpu(*this, "maincpu") { m_flash_chip[0].present = 0; m_flash_chip[0].state = F_READ; @@ -651,7 +651,7 @@ void ngp_state::machine_start() m_maincpu->space(AS_PROGRAM).install_read_bank(0x800000, 0x9fffff, "flash1"); membank("flash0")->set_base(cart); membank("flash1")->set_base(cart + 0x200000); - + m_flash_chip[0].data = cart; m_flash_chip[0].org_data[0] = m_flash_chip[0].data[0]; m_flash_chip[0].org_data[1] = m_flash_chip[0].data[1]; @@ -669,7 +669,7 @@ void ngp_state::machine_start() m_flash_chip[0].org_data[13] = m_flash_chip[0].data[0x1fc001]; m_flash_chip[0].org_data[14] = m_flash_chip[0].data[0x1fc002]; m_flash_chip[0].org_data[15] = m_flash_chip[0].data[0x1fc003]; - + m_flash_chip[1].data = cart + 0x200000; m_flash_chip[1].org_data[0] = m_flash_chip[1].data[0]; m_flash_chip[1].org_data[1] = m_flash_chip[1].data[1]; @@ -739,17 +739,17 @@ UINT32 ngp_state::screen_update_ngp(screen_device &screen, bitmap_ind16 &bitmap, DEVICE_IMAGE_LOAD_MEMBER( ngp_state, ngp_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x8000 && size != 0x80000 && size != 0x100000 && size != 0x200000 && size != 0x400000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + // alloc 0x400000 ROM to simplify mapping in the address map m_cart->rom_alloc(0x400000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + //printf("%2x%2x - %x - %x\n", (unsigned int) memregion("cart")->u8(0x20), (unsigned int) memregion("cart")->u8(0x21), // (unsigned int) memregion("cart")->u8(0x22), (unsigned int) memregion("cart")->u8(0x23)); m_flash_chip[0].manufacturer_id = 0x98; diff --git a/src/mess/drivers/pc2000.c b/src/mess/drivers/pc2000.c index 5b846a537b3..c6b4f23c81a 100644 --- a/src/mess/drivers/pc2000.c +++ b/src/mess/drivers/pc2000.c @@ -759,7 +759,7 @@ void gl4004_state::machine_start() UINT8 *cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG))->base(); if (!cart) cart = memregion("bios")->base(); - + m_bank0->configure_entries(0, 0x20, bios, 0x4000); m_bank1->configure_entries(0, 0x20, bios, 0x4000); m_bank2->configure_entries(0, 0x20, bios, 0x4000); @@ -814,8 +814,8 @@ DEVICE_IMAGE_LOAD_MEMBER( pc2000_state, pc2000_cart ) // we always allocate a 0x40000 region, even if most carts span only 0x20000, // because the bankswitch code accesses up to 16 x 16K banks... m_cart->rom_alloc(0x40000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/pc6001.c b/src/mess/drivers/pc6001.c index 399cb47ee4e..f86f592bd36 100644 --- a/src/mess/drivers/pc6001.c +++ b/src/mess/drivers/pc6001.c @@ -922,7 +922,7 @@ WRITE8_MEMBER(pc6001_state::nec_ppi8255_w) static ADDRESS_MAP_START(pc6001_map, AS_PROGRAM, 8, pc6001_state ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITENOP - //AM_RANGE(0x4000, 0x5fff) // mapped by the cartslot + //AM_RANGE(0x4000, 0x5fff) // mapped by the cartslot AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xffff) AM_RAM AM_SHARE("ram") ADDRESS_MAP_END @@ -1639,7 +1639,7 @@ WRITE8_MEMBER(pc6001_state::necsr_ppi8255_w) if(0) { //printf("%02x\n",data); - + if ((data & 0x0f) == 0x05 && m_cart_rom) m_bank1->set_base(m_cart_rom->base() + 0x2000); if ((data & 0x0f) == 0x04) @@ -2074,13 +2074,13 @@ void pc6001_state::machine_start() void pc6001_state::machine_reset() { m_video_ram = m_region_maincpu->base() + 0xc000; - + if (m_cart->exists()) m_maincpu->space(AS_PROGRAM).install_read_handler(0x4000, 0x5fff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); astring region_tag; m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + m_port_c_8255=0; m_cas_switch = 0; @@ -2095,13 +2095,13 @@ void pc6001_state::machine_reset() MACHINE_RESET_MEMBER(pc6001_state,pc6001m2) { m_video_ram = m_region_maincpu->base() + 0xc000 + 0x28000; - + astring region_tag; m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); // hackish way to simplify bankswitch handling if (m_cart_rom) memcpy(m_region_maincpu->base() + 0x48000, m_cart_rom->base(), 0x4000); - + m_port_c_8255=0; m_cas_switch = 0; @@ -2134,11 +2134,11 @@ MACHINE_RESET_MEMBER(pc6001_state,pc6001m2) MACHINE_RESET_MEMBER(pc6001_state,pc6001sr) { m_video_ram = m_region_maincpu->base() + 0x70000; - + astring region_tag; m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); // should this be mirrored into the EXROM regions? hard to tell without an actual cart dump... - + m_port_c_8255=0; m_cas_switch = 0; diff --git a/src/mess/drivers/pc8401a.c b/src/mess/drivers/pc8401a.c index a4f07f39e5c..b5c1ef4cd4b 100644 --- a/src/mess/drivers/pc8401a.c +++ b/src/mess/drivers/pc8401a.c @@ -521,7 +521,7 @@ void pc8401a_state::machine_start() /* bank switch */ bankswitch(0); - + /* register for state saving */ save_item(NAME(m_mmr)); save_item(NAME(m_io_addr)); diff --git a/src/mess/drivers/pc9801.c b/src/mess/drivers/pc9801.c index 7f3c206f1c1..c40661dee40 100644 --- a/src/mess/drivers/pc9801.c +++ b/src/mess/drivers/pc9801.c @@ -38,9 +38,9 @@ - Dies on ARTIC check; - Presumably one ROM is undumped? - TODO: (PC-9821AP) - - No way to exit the initial loop. Code looks broken/bad dump? - + TODO: (PC-9821AP) + - No way to exit the initial loop. Code looks broken/bad dump? + floppy issues TODO (certain fail) - Unsupported disk types: *.nfd, *.fdd, *.nhd - 46 Okunen Monogatari - The Shinkaron @@ -553,7 +553,7 @@ public: UINT8 m_joy_sel; UINT8 m_ext2_ff; UINT8 m_sys_type; - + DECLARE_WRITE_LINE_MEMBER( keyboard_irq ); DECLARE_WRITE_LINE_MEMBER( write_uart_clock ); DECLARE_READ8_MEMBER(pc9801_xx_r); @@ -702,7 +702,7 @@ public: DECLARE_MACHINE_START(pc9801bx2); DECLARE_MACHINE_START(pc9821); DECLARE_MACHINE_START(pc9821ap2); - + DECLARE_MACHINE_RESET(pc9801_common); DECLARE_MACHINE_RESET(pc9801f); DECLARE_MACHINE_RESET(pc9801rs); @@ -1938,7 +1938,7 @@ WRITE8_MEMBER(pc9801_state::pc9801rs_knjram_w) WRITE8_MEMBER(pc9801_state::pc9801rs_bank_w) { if(offset == 1) - { + { if((data & 0xf0) == 0x00 || (data & 0xf0) == 0x10) { if((data & 0xed) == 0x00) @@ -3375,7 +3375,7 @@ MACHINE_START_MEMBER(pc9801_state,pc9821) MACHINE_START_MEMBER(pc9801_state,pc9821ap2) { MACHINE_START_CALL_MEMBER(pc9821); - + // ... } @@ -3891,7 +3891,7 @@ static MACHINE_CONFIG_DERIVED( pc9821ap2, pc9821) MCFG_CPU_IO_MAP(pc9821_io) MCFG_CPU_VBLANK_INT_DRIVER("screen", pc9801_state, pc9801_vrtc_irq) MCFG_CPU_IRQ_ACKNOWLEDGE_DEVICE("pic8259_master", pic8259_device, inta_cb) - + MCFG_MACHINE_START_OVERRIDE(pc9801_state,pc9821ap2) MACHINE_CONFIG_END diff --git a/src/mess/drivers/pegasus.c b/src/mess/drivers/pegasus.c index 068ca37ea14..37ec17917b8 100644 --- a/src/mess/drivers/pegasus.c +++ b/src/mess/drivers/pegasus.c @@ -95,7 +95,7 @@ public: DECLARE_DRIVER_INIT(pegasus); TIMER_DEVICE_CALLBACK_MEMBER(pegasus_firq); void pegasus_decrypt_rom(UINT8 *ROM, bool force_decrypt); - + int 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"); } @@ -183,10 +183,10 @@ READ8_MEMBER( pegasus_state::pegasus_protection_r ) static ADDRESS_MAP_START(pegasus_mem, AS_PROGRAM, 8, pegasus_state) ADDRESS_MAP_UNMAP_HIGH - //AM_RANGE(0x0000, 0x2fff) // mapped by the cartslots 1-3 + //AM_RANGE(0x0000, 0x2fff) // mapped by the cartslots 1-3 AM_RANGE(0xb000, 0xbdff) AM_RAM AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_SHARE("p_videoram") - //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslots 4-5 + //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslots 4-5 AM_RANGE(0xe000, 0xe1ff) AM_READ(pegasus_protection_r) AM_RANGE(0xe200, 0xe3ff) AM_READWRITE(pegasus_pcg_r,pegasus_pcg_w) AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pia_u", pia6821_device, read, write) @@ -413,13 +413,13 @@ int pegasus_state::load_cart(device_image_interface &image, generic_slot_device { UINT32 size = slot->common_get_size(reg_tag); bool any_socket = false; - + if (size > 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + if (image.software_entry() != NULL && size == 0) { // we might be loading a cart compatible with all sockets! @@ -436,12 +436,12 @@ int pegasus_state::load_cart(device_image_interface &image, generic_slot_device } } - slot->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // we alloc 0x1000 also for smaller roms! + slot->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // we alloc 0x1000 also for smaller roms! slot->common_load_rom(slot->get_rom_base(), size, any_socket ? "rom" : reg_tag); - + // raw images have to be decrypted (in particular the ones from softlist) pegasus_decrypt_rom(slot->get_rom_base(), image.software_entry() != NULL); - + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/pencil2.c b/src/mess/drivers/pencil2.c index bbb45718380..bcffa59c4f8 100644 --- a/src/mess/drivers/pencil2.c +++ b/src/mess/drivers/pencil2.c @@ -107,7 +107,7 @@ static ADDRESS_MAP_START(pencil2_mem, AS_PROGRAM, 8, pencil2_state) AM_RANGE(0x0000, 0x1fff) AM_ROM AM_RANGE(0x2000, 0x5fff) AM_WRITENOP // stop error log filling up AM_RANGE(0x6000, 0x67ff) AM_MIRROR(0x1800) AM_RAM - //AM_RANGE(0x8000, 0xffff) // mapped by the cartslot + //AM_RANGE(0x8000, 0xffff) // mapped by the cartslot ADDRESS_MAP_END static ADDRESS_MAP_START(pencil2_io, AS_IO, 8, pencil2_state) diff --git a/src/mess/drivers/pet.c b/src/mess/drivers/pet.c index 0f982885a23..09f4dca6c9b 100644 --- a/src/mess/drivers/pet.c +++ b/src/mess/drivers/pet.c @@ -248,7 +248,7 @@ READ8_MEMBER( pet_state::read ) data = m_rom->base()[offset - 0x9000]; } break; - + case SELB: if (norom) { @@ -258,7 +258,7 @@ READ8_MEMBER( pet_state::read ) data = m_rom->base()[offset - 0x9000]; } break; - + case SELC: case SELD: case SELF: if (norom) { diff --git a/src/mess/drivers/pockstat.c b/src/mess/drivers/pockstat.c index 64bdc7dae4e..cb599de0751 100644 --- a/src/mess/drivers/pockstat.c +++ b/src/mess/drivers/pockstat.c @@ -961,7 +961,7 @@ DEVICE_IMAGE_LOAD_MEMBER( pockstat_state, pockstat_flash ) if (size != 0x20f40) return IMAGE_INIT_FAIL; - + image.fread(cart_id, 0xf40); for (int i = 0; i < strlen(gme_id); i++) diff --git a/src/mess/drivers/pokemini.c b/src/mess/drivers/pokemini.c index 14a3a87de59..a12452db818 100644 --- a/src/mess/drivers/pokemini.c +++ b/src/mess/drivers/pokemini.c @@ -56,7 +56,7 @@ public: m_speaker(*this, "speaker"), m_i2cmem(*this, "i2cmem"), m_cart(*this, "cartslot"), - m_inputs(*this, "INPUTS") + m_inputs(*this, "INPUTS") { } UINT8 m_pm_reg[0x100]; @@ -1506,7 +1506,7 @@ DEVICE_IMAGE_LOAD_MEMBER( pokemini_state, pokemini_cart ) image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too small"); return IMAGE_INIT_FAIL; } - + /* Verify that the image is not too big */ if (size > 0x1fffff) { @@ -1515,7 +1515,7 @@ DEVICE_IMAGE_LOAD_MEMBER( pokemini_state, pokemini_cart ) } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/pt68k4.c b/src/mess/drivers/pt68k4.c index 3f5c0a6b6f8..e163f1539df 100644 --- a/src/mess/drivers/pt68k4.c +++ b/src/mess/drivers/pt68k4.c @@ -9,21 +9,21 @@ 2014-01-03 Connect real DUARTs, FDC, and TimeKeeper. Settings now save properly, floppies can be read. 2014-01-19 ISA bus and compatible cards, PC keyboard support, speaker support 2014-09-20 Add PT68K2, add save states, we have a working SK*DOS disk! - + This has the appearance of a PC, including pc power supply, slots, etc on a conventional pc-like motherboard and case. Some pics: http://www.wormfood.net/old_computers/ - -Source code and manuals for the HUMBUG BIOS and SK*DOS are at: -http://www.users.cloud9.net/~stark/sources.html - -Usage: + +Source code and manuals for the HUMBUG BIOS and SK*DOS are at: +http://www.users.cloud9.net/~stark/sources.html + +Usage: Start up and press Enter as prompted. Type he to see a command list, or fd to boot from the first floppy drive. - + The stock NVRAM configures PT68k2 for 2 DSDD 5.25" drives, and PT68k4 for 2 DSHD 5.25" drives. - + Chips: 68230 Parallel Interface/Timer @ FE0081 68681 DUART/Timer (x2) @ FE0001 and FE0041 @@ -48,9 +48,9 @@ IRQs: 5: DUART1 6: PC FDC IRQ -TODO: 68230 device - This system and SK*DOS don't like our ISA WDXT-GEN emulation so HDD installs are not currently possible. - +TODO: 68230 device + This system and SK*DOS don't like our ISA WDXT-GEN emulation so HDD installs are not currently possible. + ****************************************************************************/ #include "emu.h" @@ -73,7 +73,7 @@ TODO: 68230 device #define ISABUS_TAG "isa" #define KBDC_TAG "pc_kbdc" #define SPEAKER_TAG "speaker" -#define WDFDC_TAG "wdfdc" +#define WDFDC_TAG "wdfdc" class pt68k4_state : public driver_device { @@ -219,11 +219,11 @@ WRITE8_MEMBER(pt68k4_state::fdc_select_w) switch (drive) { case 0: - floppy->ss_w((data & 0x40) ? 1 : 0); + floppy->ss_w((data & 0x40) ? 1 : 0); break; case 1: - floppy2->ss_w((data & 0x40) ? 1 : 0); + floppy2->ss_w((data & 0x40) ? 1 : 0); break; default: @@ -381,7 +381,7 @@ SLOT_INTERFACE_END static MACHINE_CONFIG_START( pt68k2, pt68k4_state ) /* basic machine hardware */ - MCFG_CPU_ADD(M68K_TAG, M68000, XTAL_16MHz/2) // 68k2 came in 8, 10, and 12 MHz versions + MCFG_CPU_ADD(M68K_TAG, M68000, XTAL_16MHz/2) // 68k2 came in 8, 10, and 12 MHz versions MCFG_CPU_PROGRAM_MAP(pt68k2_mem) MCFG_MC68681_ADD("duart1", XTAL_3_6864MHz) @@ -459,8 +459,8 @@ MACHINE_CONFIG_END /* ROM definition */ ROM_START( pt68k2 ) ROM_REGION16_BE( 0x10000, "roms", 0 ) - ROM_LOAD16_BYTE( "hum_u20.bin", 0x000000, 0x008000, CRC(69db483a) SHA1(9dfea73e4d7deef7c66a27cca92eb7c9ff767215) ) - ROM_LOAD16_BYTE( "hum_u27.bin", 0x000001, 0x008000, CRC(54441b06) SHA1(0e2d63b1cd01f88f37fc4859c11c252c4fea220b) ) + ROM_LOAD16_BYTE( "hum_u20.bin", 0x000000, 0x008000, CRC(69db483a) SHA1(9dfea73e4d7deef7c66a27cca92eb7c9ff767215) ) + ROM_LOAD16_BYTE( "hum_u27.bin", 0x000001, 0x008000, CRC(54441b06) SHA1(0e2d63b1cd01f88f37fc4859c11c252c4fea220b) ) ROM_REGION(0x800, TIMEKEEPER_TAG, 0) ROM_LOAD( "u21_ds1220.bin", 0x000000, 0x000800, CRC(7a6b75ce) SHA1(07663860aa6cc21aed04a568ff9c05bc75d62e4f) ) diff --git a/src/mess/drivers/pv1000.c b/src/mess/drivers/pv1000.c index bf3118263f5..5dff81ea8e1 100644 --- a/src/mess/drivers/pv1000.c +++ b/src/mess/drivers/pv1000.c @@ -185,7 +185,7 @@ public: static ADDRESS_MAP_START( pv1000, AS_PROGRAM, 8, pv1000_state ) - //AM_RANGE(0x0000, 0x7fff) // mapped by the cartslot + //AM_RANGE(0x0000, 0x7fff) // mapped by the cartslot AM_RANGE(0xb800, 0xbbff) AM_RAM AM_SHARE("p_videoram") AM_RANGE(0xbc00, 0xbfff) AM_RAM_WRITE(gfxram_w) AM_REGION("gfxram", 0) ADDRESS_MAP_END @@ -312,16 +312,16 @@ PALETTE_INIT_MEMBER(pv1000_state, pv1000) DEVICE_IMAGE_LOAD_MEMBER( pv1000_state, pv1000_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x2000 && size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } @@ -407,7 +407,7 @@ void pv1000_state::machine_start() // FIXME: this is needed for gfx decoding, but there is probably a cleaner solution! astring region_tag; memcpy(memregion("gfxrom")->base(), memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG))->base(), m_cart->get_rom_size()); - } + } save_item(NAME(m_io_regs)); save_item(NAME(m_fd_data)); diff --git a/src/mess/drivers/pv2000.c b/src/mess/drivers/pv2000.c index 8f4bf1e76fd..11719fdb074 100644 --- a/src/mess/drivers/pv2000.c +++ b/src/mess/drivers/pv2000.c @@ -179,7 +179,7 @@ static ADDRESS_MAP_START( pv2000_map, AS_PROGRAM, 8, pv2000_state ) AM_RANGE(0x7000, 0x7fff) AM_RAM //AM_RANGE(0x8000, 0xbfff) ext ram? - //AM_RANGE(0xc000, 0xffff) // mapped by the cartslot + //AM_RANGE(0xc000, 0xffff) // mapped by the cartslot ADDRESS_MAP_END @@ -361,16 +361,16 @@ void pv2000_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER( pv2000_state, pv2000_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x2000 && size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/rx78.c b/src/mess/drivers/rx78.c index 3a334a72268..c12443405d6 100644 --- a/src/mess/drivers/rx78.c +++ b/src/mess/drivers/rx78.c @@ -259,7 +259,7 @@ WRITE8_MEMBER( rx78_state::vdp_pri_mask_w ) static ADDRESS_MAP_START(rx78_mem, AS_PROGRAM, 8, rx78_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x1fff) AM_ROM - //AM_RANGE(0x2000, 0x5fff) // mapped by the cartslot + //AM_RANGE(0x2000, 0x5fff) // mapped by the cartslot AM_RANGE(0x6000, 0xafff) AM_RAM //ext RAM AM_RANGE(0xb000, 0xebff) AM_RAM AM_RANGE(0xec00, 0xffff) AM_READWRITE(rx78_vram_r, rx78_vram_w) @@ -409,7 +409,7 @@ INPUT_PORTS_END void rx78_state::machine_reset() { - address_space &prg = m_maincpu->space(AS_PROGRAM); + address_space &prg = m_maincpu->space(AS_PROGRAM); if (m_cart->exists()) prg.install_read_handler(0x2000, 0x5fff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); } @@ -417,16 +417,16 @@ void rx78_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER( rx78_state, rx78_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x2000 && size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/scv.c b/src/mess/drivers/scv.c index 9ee007a2550..f14e795a0cc 100644 --- a/src/mess/drivers/scv.c +++ b/src/mess/drivers/scv.c @@ -64,13 +64,13 @@ protected: static ADDRESS_MAP_START( scv_mem, AS_PROGRAM, 8, scv_state ) - AM_RANGE( 0x0000, 0x0fff ) AM_ROM // BIOS + AM_RANGE( 0x0000, 0x0fff ) AM_ROM // BIOS AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_SHARE("videoram") // VRAM + 4 registers AM_RANGE( 0x3600, 0x3600 ) AM_DEVWRITE("upd1771c", upd1771c_device, write) - AM_RANGE( 0x8000, 0xff7f ) AM_DEVREADWRITE("cartslot", scv_cart_slot_device, read_cart, write_cart) // cartridge - AM_RANGE( 0xff80, 0xffff ) AM_RAM // upd7801 internal RAM + AM_RANGE( 0x8000, 0xff7f ) AM_DEVREADWRITE("cartslot", scv_cart_slot_device, read_cart, write_cart) // cartridge + AM_RANGE( 0xff80, 0xffff ) AM_RAM // upd7801 internal RAM ADDRESS_MAP_END diff --git a/src/mess/drivers/socrates.c b/src/mess/drivers/socrates.c index f7e90cc6c3d..9d9bad38b88 100644 --- a/src/mess/drivers/socrates.c +++ b/src/mess/drivers/socrates.c @@ -319,7 +319,7 @@ void socrates_state::machine_reset() { astring region_tag; m_cart_reg = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + m_rom_bank = 0xF3; // actually set semi-randomly on real console but we need to initialize it somewhere... socrates_set_rom_bank(); m_ram_bank = 0; // the actual console sets it semi randomly on power up, and the bios cleans it up. @@ -898,7 +898,7 @@ void iqunlim_state::machine_start() { astring region_tag; m_cart_reg = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + UINT8 *bios = m_bios_reg->base(); UINT8 *cart = m_cart_reg ? m_cart_reg->base() : m_bios_reg->base(); UINT8 *ram = m_vram_reg->base(); diff --git a/src/mess/drivers/sorcerer.c b/src/mess/drivers/sorcerer.c index 804be385a10..05c320acf7b 100644 --- a/src/mess/drivers/sorcerer.c +++ b/src/mess/drivers/sorcerer.c @@ -163,7 +163,7 @@ static ADDRESS_MAP_START( sorcerer_mem, AS_PROGRAM, 8, sorcerer_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x07ff) AM_RAMBANK("boot") AM_RANGE(0x0800, 0xbfff) AM_RAM - //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslot + //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslot AM_RANGE(0xe000, 0xefff) AM_ROM /* rom pac and bios */ AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_REGION("maincpu", 0xf000) /* screen ram */ AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ @@ -176,7 +176,7 @@ static ADDRESS_MAP_START( sorcererd_mem, AS_PROGRAM, 8, sorcerer_state) AM_RANGE(0x0800, 0xbbff) AM_RAM AM_RANGE(0xbc00, 0xbcff) AM_ROM AM_RANGE(0xbe00, 0xbe03) AM_DEVREADWRITE("fdc", micropolis_device, read, write) - //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslot + //AM_RANGE(0xc000, 0xdfff) // mapped by the cartslot AM_RANGE(0xe000, 0xefff) AM_ROM /* rom pac and bios */ AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_REGION("maincpu", 0xf000) /* screen ram */ AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ diff --git a/src/mess/drivers/spc1000.c b/src/mess/drivers/spc1000.c index 31aa390010a..dcfb79dca44 100644 --- a/src/mess/drivers/spc1000.c +++ b/src/mess/drivers/spc1000.c @@ -70,7 +70,7 @@ public: DECLARE_READ8_MEMBER(fdc_8255_c_r); DECLARE_WRITE8_MEMBER(fdc_8255_c_w); DECLARE_READ8_MEMBER( upd765_tc_r ); - DECLARE_WRITE8_MEMBER( fdc_control_w ); + DECLARE_WRITE8_MEMBER( fdc_control_w ); MC6847_GET_CHARROM_MEMBER(get_char_rom) { return m_p_videoram[0x1000 + (ch & 0x7f) * 16 + line]; @@ -85,27 +85,27 @@ private: virtual void machine_reset(); required_device m_vdg; required_device m_maincpu; - required_device m_fdccpu; - required_device m_fdc; + required_device m_fdccpu; + required_device m_fdc; required_device m_pio; required_device m_ram; required_device m_cass; floppy_image_device *m_fd0; floppy_image_device *m_fd1; - - emu_timer *m_timer_tc; - + + emu_timer *m_timer_tc; + UINT8 m_i8255_0_pc; UINT8 m_i8255_1_pc; UINT8 m_i8255_portb; - + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); }; void spc1000_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - m_fdc->tc_w(false); + m_fdc->tc_w(false); } static ADDRESS_MAP_START(spc1000_mem, AS_PROGRAM, 8, spc1000_state ) @@ -255,7 +255,7 @@ static ADDRESS_MAP_START( spc1000_io , AS_IO, 8, spc1000_state ) AM_RANGE(0x8009, 0x8009) AM_READ_PORT("LINE9") AM_RANGE(0xA000, 0xA000) AM_READWRITE(spc1000_iplk_r, spc1000_iplk_w) AM_RANGE(0xC000, 0xC002) AM_READWRITE(spc1000_sd725_r, spc1000_sd725_w) -// AM_RANGE(0xC000, 0xC003) AM_DEVREADWRITE("d8255_master", i8255_device, read, write) +// AM_RANGE(0xC000, 0xC003) AM_DEVREADWRITE("d8255_master", i8255_device, read, write) ADDRESS_MAP_END /* Input ports */ @@ -342,7 +342,7 @@ static INPUT_PORTS_START( spc1000 ) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') PORT_CHAR(0x09) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8 (") PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') PORT_START("LINE9") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_START) PORT_NAME("IPL") PORT_CODE(KEYCODE_END) + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_START) PORT_NAME("IPL") PORT_CODE(KEYCODE_END) PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- =") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') @@ -369,20 +369,20 @@ void spc1000_state::machine_reset() membank("bank2")->set_base(ram); membank("bank3")->set_base(mem); membank("bank4")->set_base(ram + 0x8000); - + m_work_ram = auto_alloc_array_clear(machine(), UINT8, 0x10000); m_fdccpu->set_input_line_vector(0, 0); - + m_fd0 = machine().device("upd765:0")->get_device(); m_fd1 = machine().device("upd765:1")->get_device(); - m_timer_tc = timer_alloc(1, NULL); + m_timer_tc = timer_alloc(1, NULL); m_timer_tc->adjust(attotime::never); // enable rom - m_fdccpu->space(AS_PROGRAM).install_rom(0x0000, 0xfff, 0, 0x2000, memregion("rom")->base()); - - m_IPLK = 1; + m_fdccpu->space(AS_PROGRAM).install_rom(0x0000, 0xfff, 0, 0x2000, memregion("rom")->base()); + + m_IPLK = 1; } READ8_MEMBER(spc1000_state::mc6847_videoram_r) @@ -452,23 +452,23 @@ static MACHINE_CONFIG_START( spc1000, spc1000_state ) MCFG_CPU_ADD("fdccpu", Z80, XTAL_4MHz) /* 4 MHz */ MCFG_CPU_PROGRAM_MAP(sd725_mem) MCFG_CPU_IO_MAP(sd725_io) - + MCFG_DEVICE_ADD("d8255_master", I8255, 0) MCFG_I8255_IN_PORTA_CB(DEVREAD8("d8255_master", i8255_device, pb_r)) MCFG_I8255_IN_PORTB_CB(DEVREAD8("d8255_master", i8255_device, pa_r)) - MCFG_I8255_OUT_PORTB_CB(WRITE8(spc1000_state, fdc_8255_b_w)) + MCFG_I8255_OUT_PORTB_CB(WRITE8(spc1000_state, fdc_8255_b_w)) MCFG_I8255_IN_PORTC_CB(READ8(spc1000_state, fdc_8255_c_r)) - MCFG_I8255_OUT_PORTC_CB(WRITE8(spc1000_state, fdc_8255_c_w)) + MCFG_I8255_OUT_PORTC_CB(WRITE8(spc1000_state, fdc_8255_c_w)) // floppy disk controller MCFG_UPD765A_ADD("upd765", true, true) - MCFG_UPD765_INTRQ_CALLBACK(INPUTLINE("fdccpu", INPUT_LINE_IRQ0)) + MCFG_UPD765_INTRQ_CALLBACK(INPUTLINE("fdccpu", INPUT_LINE_IRQ0)) // floppy drives MCFG_FLOPPY_DRIVE_ADD("upd765:0", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats) - MCFG_FLOPPY_DRIVE_ADD("upd765:1", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("upd765:1", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats) //CFG_SOFTWARE_LIST_ADD("disk_list","spc1000_flop") - + /* video hardware */ MCFG_SCREEN_MC6847_NTSC_ADD("screen", "mc6847") @@ -501,8 +501,8 @@ ROM_START( spc1000 ) ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) ROM_LOAD( "spcall.rom", 0x0000, 0x8000, CRC(19638fc9) SHA1(489f1baa7aebf3c8c660325fb1fd790d84203284)) - ROM_REGION( 0x10000, "fdccpu", 0) - ROM_LOAD("sd725a.bin", 0x0000, 0x1000, CRC(96ac2eb8) SHA1(8e9d8f63a7fb87af417e95603e71cf537a6e83f1)) + ROM_REGION( 0x10000, "fdccpu", 0) + ROM_LOAD("sd725a.bin", 0x0000, 0x1000, CRC(96ac2eb8) SHA1(8e9d8f63a7fb87af417e95603e71cf537a6e83f1)) ROM_END #if 0 diff --git a/src/mess/drivers/specpls3.c b/src/mess/drivers/specpls3.c index 3e4502bd780..cc761d7a5c6 100644 --- a/src/mess/drivers/specpls3.c +++ b/src/mess/drivers/specpls3.c @@ -217,13 +217,13 @@ void spectrum_state::spectrum_plus3_update_memory() int ram_page = m_port_7ffd_data & 0x07; unsigned char *ram_data = messram + (ram_page<<14); membank("bank4")->set_base(ram_data); - + logerror("RAM at 0xc000: %02x\n", ram_page); - + /* Reset memory between 0x4000 - 0xbfff in case extended paging was being used */ /* Bank 5 in 0x4000 - 0x7fff */ membank("bank2")->set_base(messram + (5 << 14)); - + /* Bank 2 in 0x8000 - 0xbfff */ membank("bank3")->set_base(messram + (2 << 14)); @@ -231,13 +231,13 @@ void spectrum_state::spectrum_plus3_update_memory() { /* ROM switching */ int ROMSelection = BIT(m_port_7ffd_data, 4) | ((m_port_1ffd_data >> 1) & 0x02); - + /* rom 0 is editor, rom 1 is syntax, rom 2 is DOS, rom 3 is 48 BASIC */ unsigned char *ChosenROM = memregion("maincpu")->base() + 0x010000 + (ROMSelection << 14); - + membank("bank1")->set_base(ChosenROM); space.unmap_write(0x0000, 0x3fff); - + logerror("rom switch: %02x\n", ROMSelection); } } @@ -247,20 +247,20 @@ void spectrum_state::spectrum_plus3_update_memory() int MemorySelection = (m_port_1ffd_data >> 1) & 0x03; const int *memory_selection = &spectrum_plus3_memory_selections[(MemorySelection << 2)]; unsigned char *ram_data = messram + (memory_selection[0] << 14); - + membank("bank1")->set_base(ram_data); /* allow writes to 0x0000-0x03fff */ space.install_write_bank(0x0000, 0x3fff, "bank1"); - + ram_data = messram + (memory_selection[1] << 14); membank("bank2")->set_base(ram_data); - + ram_data = messram + (memory_selection[2] << 14); membank("bank3")->set_base(ram_data); - + ram_data = messram + (memory_selection[3] << 14); membank("bank4")->set_base(ram_data); - + logerror("extended memory paging: %02x\n", MemorySelection); } } diff --git a/src/mess/drivers/spectrum.c b/src/mess/drivers/spectrum.c index 545bb649ec7..5ecfdbb1ad6 100644 --- a/src/mess/drivers/spectrum.c +++ b/src/mess/drivers/spectrum.c @@ -654,16 +654,16 @@ INTERRUPT_GEN_MEMBER(spectrum_state::spec_interrupt) DEVICE_IMAGE_LOAD_MEMBER(spectrum_state, spectrum_cart) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/studio2.c b/src/mess/drivers/studio2.c index 822808ed027..6c731019253 100644 --- a/src/mess/drivers/studio2.c +++ b/src/mess/drivers/studio2.c @@ -201,7 +201,7 @@ Notes: class studio2_state : public driver_device { public: - + studio2_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, CDP1802_TAG), @@ -213,7 +213,7 @@ public: m_b(*this, "B"), m_screen(*this, "screen") { } - + required_device m_maincpu; required_device m_beeper; optional_device m_vdc; @@ -222,10 +222,10 @@ public: required_ioport m_a; required_ioport m_b; required_device m_screen; - + virtual void machine_start(); virtual void machine_reset(); - + DECLARE_READ8_MEMBER( cart_400 ); DECLARE_READ8_MEMBER( cart_a00 ); DECLARE_READ8_MEMBER( cart_e00 ); @@ -238,7 +238,7 @@ public: DECLARE_WRITE_LINE_MEMBER( q_w ); DECLARE_INPUT_CHANGED_MEMBER( reset_w ); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( studio2_cart_load ); - + /* keyboard state */ UINT8 m_keylatch; DECLARE_DRIVER_INIT(studio2); @@ -252,12 +252,12 @@ public: m_color0_ram(*this, "color0_ram"), m_color1_ram(*this, "color1_ram") { } - + virtual UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - + required_shared_ptr m_color0_ram; required_shared_ptr m_color1_ram; - + DECLARE_WRITE8_MEMBER( dma_w ); }; @@ -269,18 +269,18 @@ public: m_cti(*this, CDP1864_TAG), m_color_ram(*this, "color_ram") { } - + required_device m_cti; - + virtual void machine_start(); virtual void machine_reset(); - + DECLARE_READ8_MEMBER( cart_c00 ); DECLARE_WRITE8_MEMBER( dma_w ); DECLARE_READ_LINE_MEMBER( rdata_r ); DECLARE_READ_LINE_MEMBER( bdata_r ); DECLARE_READ_LINE_MEMBER( gdata_r ); - + /* video state */ required_shared_ptr m_color_ram; UINT8 m_color; @@ -511,7 +511,7 @@ void mpt02_state::machine_start() m_maincpu->space(AS_PROGRAM).install_read_handler(0x0400, 0x07ff, read8_delegate(FUNC(studio2_state::cart_400), this)); m_maincpu->space(AS_PROGRAM).install_read_handler(0x0c00, 0x0fff, read8_delegate(FUNC(mpt02_state::cart_c00), this)); } - + // register for state saving save_item(NAME(m_keylatch)); } @@ -529,10 +529,10 @@ void mpt02_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER( studio2_state, studio2_cart_load ) { UINT32 size; - + // always alloc 3K, even if range $400-$600 is not read by the system (RAM is present there) m_cart->rom_alloc(0xc00, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - + if (image.software_entry() == NULL) { if (!strcmp(image.filetype(), "st2")) @@ -540,8 +540,8 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state, studio2_cart_load ) UINT8 header[0x100]; UINT8 catalogue[10], title[32], pages[64]; UINT8 blocks; - - if (image.length() <= 0x100) + + if (image.length() <= 0x100) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid ROM file"); return IMAGE_INIT_FAIL; @@ -560,7 +560,7 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state, studio2_cart_load ) memcpy(&catalogue, &header[16], 10); memcpy(&title, &header[32], 32); memcpy(&pages, &header[64], 64); - + /* read ST2 cartridge into memory */ for (int block = 0; block < (blocks - 1); block++) { diff --git a/src/mess/drivers/supracan.c b/src/mess/drivers/supracan.c index b025f1570f6..3a1e60accef 100644 --- a/src/mess/drivers/supracan.c +++ b/src/mess/drivers/supracan.c @@ -1125,7 +1125,7 @@ WRITE16_MEMBER( supracan_state::vram_w ) } static ADDRESS_MAP_START( supracan_mem, AS_PROGRAM, 16, supracan_state ) - //AM_RANGE( 0x000000, 0x3fffff ) // mapped by the cartslot + //AM_RANGE( 0x000000, 0x3fffff ) // mapped by the cartslot AM_RANGE( 0xe80200, 0xe80201 ) AM_READ_PORT("P1") AM_RANGE( 0xe80202, 0xe80203 ) AM_READ_PORT("P2") AM_RANGE( 0xe80208, 0xe80209 ) AM_READ_PORT("P3") @@ -1754,7 +1754,7 @@ WRITE16_MEMBER( supracan_state::video_w ) DEVICE_IMAGE_LOAD_MEMBER( supracan_state, supracan_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size > 0x400000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); @@ -1762,8 +1762,8 @@ DEVICE_IMAGE_LOAD_MEMBER( supracan_state, supracan_cart ) } m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/sv8000.c b/src/mess/drivers/sv8000.c index 597156c5030..1f9925c7a91 100644 --- a/src/mess/drivers/sv8000.c +++ b/src/mess/drivers/sv8000.c @@ -94,7 +94,7 @@ private: static ADDRESS_MAP_START(sv8000_mem, AS_PROGRAM, 8, sv8000_state) ADDRESS_MAP_UNMAP_HIGH - //AM_RANGE(0x0000, 0x0fff) // mapped by the cartslot + //AM_RANGE(0x0000, 0x0fff) // mapped by the cartslot AM_RANGE( 0x8000, 0x83ff ) AM_RAM // Work RAM?? AM_RANGE( 0xc000, 0xcbff ) AM_RAM AM_SHARE("videoram") ADDRESS_MAP_END @@ -197,16 +197,16 @@ void sv8000_state::machine_reset() DEVICE_IMAGE_LOAD_MEMBER( sv8000_state, cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size != 0x1000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Incorrect or not support cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/svision.c b/src/mess/drivers/svision.c index 88e657ec2c8..f92f5b7cc0b 100644 --- a/src/mess/drivers/svision.c +++ b/src/mess/drivers/svision.c @@ -452,16 +452,16 @@ DRIVER_INIT_MEMBER(svision_state, svisions) DEVICE_IMAGE_LOAD_MEMBER( svision_state, svision_cart ) { UINT32 size = m_cart->common_get_size("rom"); - + if (size > 0x20000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/thomson.c b/src/mess/drivers/thomson.c index 1ad8eacabce..3db601fcccf 100644 --- a/src/mess/drivers/thomson.c +++ b/src/mess/drivers/thomson.c @@ -1093,7 +1093,7 @@ static MACHINE_CONFIG_DERIVED( mo5, to7 ) MCFG_DEVICE_REMOVE( "mc6846" ) - MCFG_PALETTE_MODIFY( "palette" ) + MCFG_PALETTE_MODIFY( "palette" ) MCFG_PALETTE_INIT_OWNER(thomson_state, mo5) MCFG_DEVICE_MODIFY(THOM_PIA_SYS) diff --git a/src/mess/drivers/ti74.c b/src/mess/drivers/ti74.c index d7cbfb08c8b..d06a75a2b76 100644 --- a/src/mess/drivers/ti74.c +++ b/src/mess/drivers/ti74.c @@ -5,11 +5,11 @@ Texas Instruments TI-74 BASICALC Texas Instruments TI-95 PROCALC hardware family: CC-40 -> TI-74 BASICALC -> TI-95 PROCALC - + TI-74 PCB layout: note: TI-95 PCB is nearly the same, just with a different size LCD screen, its CPU is labeled C70011, and the system ROM is labeled HN61256PC95. - + DOCK-BUS --||||||||--- C == | @@ -49,16 +49,16 @@ * - indicates that it's on the other side of the PCB - + Overall, the hardware is very similar to TI CC-40. A lot has been shuffled around to cut down on complexity (and probably for protection too). To reduce power usage even more, the OS often idles while waiting for any keypress that triggers an interrupt and wakes the processor up. - + The machine is powered by 4 AAA batteries. These will also save internal RAM, provided that the machine is turned off properly. - - + + TODO: - it runs too fast due to missing clock divider emulation in TMS70C46 - external ram cartridge @@ -131,10 +131,10 @@ DEVICE_IMAGE_LOAD_MEMBER(ti74_state, ti74_cartridge) image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid file size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } @@ -165,7 +165,7 @@ void ti74_state::update_lcd_indicator(UINT8 y, UINT8 x, int state) // TI-95 ref._________________... // output# | 40 43 41 44 42 12 11 10/13/14 0 1 2 // above | _LOW _ERROR 2nd INV ALPHA LC INS DEGRAD HEX OCT I/O - // screen- | _P{70} <{71} RUN{3} + // screen- | _P{70} <{71} RUN{3} // area . SYS{4} output_set_lamp_value(y * 10 + x, state); } @@ -175,7 +175,7 @@ static HD44780_PIXEL_UPDATE(ti74_pixel_update) // char size is 5x7 + cursor if (x > 4 || y > 7) return; - + if (line == 1 && pos == 15) { // the last char is used to control the 14 lcd indicators @@ -236,7 +236,7 @@ READ8_MEMBER(ti74_state::keyboard_r) if (m_key_select >> i & 1) ret |= m_key_matrix[i]->read(); } - + return ret; } @@ -250,14 +250,14 @@ WRITE8_MEMBER(ti74_state::bankswitch_w) { // d0-d1: system rom bankswitch membank("sysbank")->set_entry(data & 3); - + // d2: power-on latch if (~data & 4 && m_power) { m_power = 0; m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); // stop running } - + // d3: N/C } @@ -265,7 +265,7 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, ti74_state ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x1000, 0x1001) AM_DEVREADWRITE("hd44780", hd44780_device, read, write) AM_RANGE(0x2000, 0x3fff) AM_RAM AM_SHARE("sysram.ic3") - //AM_RANGE(0x4000, 0xbfff) // mapped by the cartslot + //AM_RANGE(0x4000, 0xbfff) // mapped by the cartslot AM_RANGE(0xc000, 0xdfff) AM_ROMBANK("sysbank") ADDRESS_MAP_END @@ -486,7 +486,7 @@ void ti74_state::update_battery_status(int state) void ti74_state::machine_reset() { m_power = 1; - + update_battery_status(m_battery_inp->read()); } diff --git a/src/mess/drivers/timex.c b/src/mess/drivers/timex.c index 2221048011e..ade345aeb1c 100644 --- a/src/mess/drivers/timex.c +++ b/src/mess/drivers/timex.c @@ -598,7 +598,7 @@ DEVICE_IMAGE_LOAD_MEMBER( spectrum_state, timex_cart ) int chunks_in_file = 0; dynamic_buffer header; header.resize(9); - + if (size % 0x2000 != 9) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "File corrupted"); @@ -609,22 +609,22 @@ DEVICE_IMAGE_LOAD_MEMBER( spectrum_state, timex_cart ) image.seterror(IMAGE_ERROR_UNSPECIFIED, "Loading from softlist is not supported yet"); return IMAGE_INIT_FAIL; } - + m_dock->rom_alloc(0x10000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); DOCK = m_dock->get_rom_base(); - + // check header image.fread(header, 9); - + for (int i = 0; i < 8; i++) if (header[i + 1] & 0x02) chunks_in_file++; - + if (chunks_in_file * 0x2000 + 0x09 != size) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "File corrupted"); return IMAGE_INIT_FAIL; } - + switch (header[0]) { case 0x00: logerror ("DOCK cart\n"); @@ -643,7 +643,7 @@ DEVICE_IMAGE_LOAD_MEMBER( spectrum_state, timex_cart ) } } break; - + default: image.seterror(IMAGE_ERROR_UNSPECIFIED, "Cart type not supported"); return IMAGE_INIT_FAIL; diff --git a/src/mess/drivers/tsispch.c b/src/mess/drivers/tsispch.c index 642a0fa9080..42096121f51 100644 --- a/src/mess/drivers/tsispch.c +++ b/src/mess/drivers/tsispch.c @@ -482,7 +482,7 @@ ROM_START( prose2k ) // 0 - to /CE of ROMs 12(U27) and 13(U50) // // Note U81 is optional; it can be replaced by a 74s138 instead of a prom, - // with A19, A18, A17 as inputs, for decoding the roms as: + // with A19, A18, A17 as inputs, for decoding the roms as: // 7 - to /CE of ROMs 0(U21) and 1(U44) (0xE0000-0xE3FFF) // 6 - to /CE of ROMs 2(U22) and 3(U45) (0xE4000-0xE7FFF) // 5 - to /CE of ROMs 4(U23) and 5(U46) (0xE8000-0xEBFFF) @@ -490,8 +490,8 @@ ROM_START( prose2k ) // 3 - to /CE of ROMs 8(U25) and 9(U48) (0xF0000-0xF3FFF) // 2 - to /CE of ROMs 10(U26) and 11(U49) (0xF4000-0xF7FFF) // 1 - to /CE of ROMs 12(U27) and 13(U50) (0xF8000-0xFBFFF) - // 0 - to /CE of ROMs 14(U28) and 15(U51) (0xFC000-0xFFFFF) - + // 0 - to /CE of ROMs 14(U28) and 15(U51) (0xFC000-0xFFFFF) + ROM_REGION(0x1000, "proms", 0) ROM_LOAD( "am27s19.u77", 0x0000, 0x0020, CRC(A88757FC) SHA1(9066D6DBC009D7A126D75B8461CA464DDF134412)) ROM_LOAD( "am27s19.u79", 0x0020, 0x0020, CRC(A165B090) SHA1(BFC413C79915C68906033741318C070AD5DD0F6B)) diff --git a/src/mess/drivers/tutor.c b/src/mess/drivers/tutor.c index 7596e537774..4a437c9f950 100644 --- a/src/mess/drivers/tutor.c +++ b/src/mess/drivers/tutor.c @@ -196,7 +196,7 @@ public: optional_device m_cass; optional_device m_centronics; optional_device m_cent_data_out; - required_memory_bank m_bank1; + required_memory_bank m_bank1; memory_region *m_cart_rom; DECLARE_READ8_MEMBER(key_r); @@ -223,9 +223,9 @@ void tutor_state::machine_start() { astring region_tag; m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + m_tape_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tutor_state::tape_interrupt_handler),this)); - + m_bank1->configure_entry(0, memregion("maincpu")->base() + 0x8000); m_bank1->set_entry(0); diff --git a/src/mess/drivers/tvc.c b/src/mess/drivers/tvc.c index 28ec8948a2e..c588d8b084e 100644 --- a/src/mess/drivers/tvc.c +++ b/src/mess/drivers/tvc.c @@ -47,7 +47,7 @@ public: m_palette(*this, "palette"), m_keyboard(*this, "LINE") { } - + required_device m_maincpu; required_device m_ram; required_device m_sound; @@ -65,7 +65,7 @@ public: void machine_start(); void machine_reset(); - + void set_mem_page(UINT8 data); DECLARE_WRITE8_MEMBER(bank_w); DECLARE_WRITE8_MEMBER(vram_bank_w); @@ -80,17 +80,17 @@ public: DECLARE_READ8_MEMBER(_5b_r); DECLARE_WRITE_LINE_MEMBER(int_ff_set); DECLARE_WRITE_LINE_MEMBER(centronics_ack); - + // expansions DECLARE_WRITE8_MEMBER(expansion_w); DECLARE_READ8_MEMBER(expansion_r); DECLARE_READ8_MEMBER(exp_id_r); DECLARE_WRITE8_MEMBER(expint_ack_w); - + DECLARE_QUICKLOAD_LOAD_MEMBER( tvc64); - + MC6845_UPDATE_ROW(crtc_update_row); - + UINT8 m_video_mode; UINT8 m_keyline; UINT8 m_active_slot; diff --git a/src/mess/drivers/uzebox.c b/src/mess/drivers/uzebox.c index 2ab52e6944f..a5aea162589 100644 --- a/src/mess/drivers/uzebox.c +++ b/src/mess/drivers/uzebox.c @@ -273,7 +273,7 @@ UINT32 uzebox_state::screen_update_uzebox(screen_device &screen, bitmap_rgb32 &b DEVICE_IMAGE_LOAD_MEMBER(uzebox_state, uzebox_cart) { UINT32 size = m_cart->common_get_size("rom"); - + m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); if (image.software_entry() == NULL) diff --git a/src/mess/drivers/vboy.c b/src/mess/drivers/vboy.c index 7dcfefd1f23..00db7737ac3 100644 --- a/src/mess/drivers/vboy.c +++ b/src/mess/drivers/vboy.c @@ -1112,7 +1112,7 @@ static ADDRESS_MAP_START( vboy_mem, AS_PROGRAM, 32, vboy_state ) //AM_RANGE( 0x04000000, 0x04ffffff ) // Expansion area AM_RANGE( 0x05000000, 0x0500ffff ) AM_MIRROR(0x0ff0000) AM_RAM AM_SHARE("wram")// Main RAM - 64K mask 0xffff AM_RANGE( 0x06000000, 0x06003fff ) AM_DEVREADWRITE("cartslot", vboy_cart_slot_device, read_eeprom, write_eeprom) // Cart RAM - 8K NVRAM -// AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ +// AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ ADDRESS_MAP_END static ADDRESS_MAP_START( vboy_io, AS_IO, 32, vboy_state ) @@ -1141,7 +1141,7 @@ static ADDRESS_MAP_START( vboy_io, AS_IO, 32, vboy_state ) // AM_RANGE( 0x04000000, 0x04ffffff ) // Expansion area AM_RANGE( 0x05000000, 0x0500ffff ) AM_MIRROR(0x0ff0000) AM_RAM AM_SHARE("wram") // Main RAM - 64K mask 0xffff AM_RANGE( 0x06000000, 0x06003fff ) AM_NOP // Cart RAM - 8K NVRAM ? -// AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ +// AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ ADDRESS_MAP_END /* Input ports */ diff --git a/src/mess/drivers/vc4000.c b/src/mess/drivers/vc4000.c index 085fb44ec62..727350c0456 100644 --- a/src/mess/drivers/vc4000.c +++ b/src/mess/drivers/vc4000.c @@ -378,12 +378,12 @@ void vc4000_state::machine_start() m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1800, 0x1bff, read8_delegate(FUNC(vc4000_cart_slot_device::read_ram),(vc4000_cart_slot_device*)m_cart), write8_delegate(FUNC(vc4000_cart_slot_device::write_ram),(vc4000_cart_slot_device*)m_cart)); break; // undumped Radofin Hobby Module -// case VC4000_HOBBY: -// m_maincpu->space(AS_PROGRAM).install_read_handler(0x0000, 0x07ff, read8_delegate(FUNC(vc4000_cart_slot_device::read_rom),(vc4000_cart_slot_device*)m_cart)); -// m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x0800, 0x0fff, read8_delegate(FUNC(vc4000_cart_slot_device::read_ram),(vc4000_cart_slot_device*)m_cart), write8_delegate(FUNC(vc4000_cart_slot_device::write_ram),(vc4000_cart_slot_device*)m_cart)); -// break; +// case VC4000_HOBBY: +// m_maincpu->space(AS_PROGRAM).install_read_handler(0x0000, 0x07ff, read8_delegate(FUNC(vc4000_cart_slot_device::read_rom),(vc4000_cart_slot_device*)m_cart)); +// m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x0800, 0x0fff, read8_delegate(FUNC(vc4000_cart_slot_device::read_ram),(vc4000_cart_slot_device*)m_cart), write8_delegate(FUNC(vc4000_cart_slot_device::write_ram),(vc4000_cart_slot_device*)m_cart)); +// break; } - + m_cart->save_ram(); } } @@ -398,7 +398,7 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) dynamic_buffer quick_data; int read_; int result = IMAGE_INIT_FAIL; - + quick_length = image.length(); quick_data.resize(quick_length); read_ = image.fread( quick_data, quick_length); @@ -420,7 +420,7 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) { int quick_addr = quick_data[1] * 256 + quick_data[2]; exec_addr = quick_data[3] * 256 + quick_data[4]; - + if (quick_length < 0x5) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); @@ -436,13 +436,13 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) { space.write_byte(0x08be, quick_data[3]); space.write_byte(0x08bf, quick_data[4]); - + for (i = 5; i < quick_length; i++) space.write_byte(i - 5 + quick_addr, quick_data[i]); - + /* display a message about the loaded quickload */ image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); - + // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); result = IMAGE_INIT_PASS; @@ -460,7 +460,7 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) else { exec_addr = quick_data[1] * 256 + quick_data[2]; - + if (exec_addr >= quick_length) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); @@ -482,14 +482,14 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) { space.write_byte(0x08be, quick_data[1]); space.write_byte(0x08bf, quick_data[2]); - + // load to 08C0-15FF (standard ram + extra) int read_ = 0x1600; if (quick_length < 0x1600) read_ = quick_length; for (i = 0x8c0; i < read_; i++) space.write_byte(i, quick_data[i]); - + // load to 1F50-1FAF (PVI regs) read_ = 0x1FB0; if (quick_length < 0x1FB0) @@ -497,10 +497,10 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) if (quick_length > 0x1FC0) for (i = 0x1F50; i < read_; i++) vc4000_video_w(space, i-0x1f00, quick_data[i]); - + /* display a message about the loaded quickload */ image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); - + // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); result = IMAGE_INIT_PASS; diff --git a/src/mess/drivers/vii.c b/src/mess/drivers/vii.c index 572a94ab113..de9a14b866c 100644 --- a/src/mess/drivers/vii.c +++ b/src/mess/drivers/vii.c @@ -961,13 +961,13 @@ INPUT_PORTS_END void vii_state::test_centered(UINT8 *ROM) { if (ROM[0x3cd808] == 0x99 && - ROM[0x3cd809] == 0x99 && - ROM[0x3cd80a] == 0x83 && - ROM[0x3cd80b] == 0x5e && - ROM[0x3cd80c] == 0x52 && - ROM[0x3cd80d] == 0x6b && - ROM[0x3cd80e] == 0x78 && - ROM[0x3cd80f] == 0x7f) + ROM[0x3cd809] == 0x99 && + ROM[0x3cd80a] == 0x83 && + ROM[0x3cd80b] == 0x5e && + ROM[0x3cd80c] == 0x52 && + ROM[0x3cd80d] == 0x6b && + ROM[0x3cd80e] == 0x78 && + ROM[0x3cd80f] == 0x7f) { m_centered_coordinates = 0; } @@ -982,10 +982,10 @@ DEVICE_IMAGE_LOAD_MEMBER( vii_state, vii_cart ) image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + test_centered(m_cart->get_rom_base()); return IMAGE_INIT_PASS; @@ -994,10 +994,10 @@ DEVICE_IMAGE_LOAD_MEMBER( vii_state, vii_cart ) DEVICE_IMAGE_LOAD_MEMBER( vii_state, vsmile_cart ) { UINT32 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"); - + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + return IMAGE_INIT_PASS; } @@ -1031,11 +1031,11 @@ void vii_state::machine_start() m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); memcpy(m_p_cart, m_cart_rom->base(), 0x400000 * 2); } - else if (m_spg243_mode == SPG243_VII) // Vii bios is banked + else if (m_spg243_mode == SPG243_VII) // Vii bios is banked memcpy(m_p_cart, m_bios_rom->base(), 0x400000 * 2); else memcpy(m_p_cart, memregion("maincpu")->base(), 0x400000 * 2); - + m_video_regs[0x36] = 0xffff; m_video_regs[0x37] = 0xffff; diff --git a/src/mess/drivers/x07.c b/src/mess/drivers/x07.c index 76e8fd57c4e..5ebc3ffd8ff 100644 --- a/src/mess/drivers/x07.c +++ b/src/mess/drivers/x07.c @@ -1038,12 +1038,12 @@ inline void x07_state::draw_udk() DEVICE_IMAGE_LOAD_MEMBER( x07_state, x07_card ) { UINT32 size = m_card->common_get_size("rom"); - + // check card type if (image.software_entry() != NULL) { const char *card_type = image.get_feature("card_type"); - + if (strcmp(card_type, "xp140")) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported card type"); @@ -1052,7 +1052,7 @@ DEVICE_IMAGE_LOAD_MEMBER( x07_state, x07_card ) } m_card->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG); - m_card->common_load_rom(m_card->get_rom_base(), size, "rom"); + m_card->common_load_rom(m_card->get_rom_base(), size, "rom"); m_card->ram_alloc(0x1000); diff --git a/src/mess/includes/apple2.h b/src/mess/includes/apple2.h index d294025ed9f..02dd0b9296b 100644 --- a/src/mess/includes/apple2.h +++ b/src/mess/includes/apple2.h @@ -26,7 +26,7 @@ #define IIC_ACIA1_TAG "acia1" #define IIC_ACIA2_TAG "acia2" -#define IICP_IWM_TAG "iwm" +#define IICP_IWM_TAG "iwm" #define LASER128_UDC_TAG "l128udc" @@ -83,7 +83,7 @@ enum machine_type_t APPLE_IIC, // Apple IIc APPLE_IICPLUS, // Apple IIc+ TK2000, // Microdigital TK2000 - TK3000, // Microdigital TK3000 + TK3000, // Microdigital TK3000 LASER128, // Laser 128/128EX/128EX2 SPACE84, // "Space 84" with flipped text mode LABA2P // lab equipment (?) II Plus with flipped text mode diff --git a/src/mess/includes/atom.h b/src/mess/includes/atom.h index e80a9353336..93bc57485b9 100644 --- a/src/mess/includes/atom.h +++ b/src/mess/includes/atom.h @@ -108,9 +108,9 @@ public: /* devices */ int m_previous_i8271_int_state; TIMER_DEVICE_CALLBACK_MEMBER(cassette_output_tick); - + int load_cart(device_image_interface &image, generic_slot_device *slot); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load) { return load_cart(image, m_cart); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load) { return load_cart(image, m_cart); } DECLARE_QUICKLOAD_LOAD_MEMBER(atom_atm); }; @@ -121,7 +121,7 @@ public: : atom_state(mconfig, type, tag), m_e0(*this, "rom_e0"), m_e1(*this, "rom_e1") - { + { } virtual void machine_start(); @@ -132,10 +132,10 @@ public: DECLARE_READ8_MEMBER(dos_r); DECLARE_DRIVER_INIT(atomeb); - + /* eprom state */ int m_eprom; - + generic_slot_device *m_ext[16]; required_device m_e0; required_device m_e1; diff --git a/src/mess/includes/concept.h b/src/mess/includes/concept.h index c1e280ea015..f5deecc63f8 100644 --- a/src/mess/includes/concept.h +++ b/src/mess/includes/concept.h @@ -21,7 +21,7 @@ #define ACIA_0_TAG "acia0" #define ACIA_1_TAG "acia1" #define KBD_ACIA_TAG "kbacia" -#define SPEAKER_TAG "spkr" +#define SPEAKER_TAG "spkr" #define A2BUS_TAG "a2bus" class concept_state : public driver_device diff --git a/src/mess/includes/electron.h b/src/mess/includes/electron.h index c98c85d2bcb..2de2f6da6a1 100644 --- a/src/mess/includes/electron.h +++ b/src/mess/includes/electron.h @@ -70,9 +70,9 @@ public: : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_cassette(*this, "cassette"), - m_beeper(*this, "beeper"), + m_beeper(*this, "beeper"), m_cart(*this, "cartslot"), - m_keybd(*this, "LINE") + m_keybd(*this, "LINE") { } ULA m_ula; diff --git a/src/mess/includes/intv.h b/src/mess/includes/intv.h index 949df7fb86d..f6161894f7f 100644 --- a/src/mess/includes/intv.h +++ b/src/mess/includes/intv.h @@ -44,7 +44,7 @@ public: m_io_options(*this, "OPTIONS"), m_io_test(*this, "TEST"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") + m_palette(*this, "palette") { } required_device m_maincpu; @@ -66,7 +66,7 @@ public: DECLARE_READ8_MEMBER(intv_right_control_r); DECLARE_READ8_MEMBER(intv_left_control_r); - + UINT8 m_bus_copy_mode; UINT8 m_backtab_row; UINT16 m_ram16[0x160]; diff --git a/src/mess/includes/radio86.h b/src/mess/includes/radio86.h index d2f5dd00e1e..584d69bc965 100644 --- a/src/mess/includes/radio86.h +++ b/src/mess/includes/radio86.h @@ -88,7 +88,7 @@ public: protected: required_device m_cassette; - optional_device m_cart; // for ROMDisk - only Radio86K & Orion? + optional_device m_cart; // for ROMDisk - only Radio86K & Orion? optional_device m_dma8257; required_device m_ppi8255_1; optional_device m_ppi8255_2; diff --git a/src/mess/includes/svi318.h b/src/mess/includes/svi318.h index f13d31e7360..682fc400ed1 100644 --- a/src/mess/includes/svi318.h +++ b/src/mess/includes/svi318.h @@ -52,7 +52,7 @@ public: m_bank3(*this, "bank3"), m_bank4(*this, "bank4") { } - + // FDC UINT8 m_driveselect; int m_drq; @@ -91,7 +91,7 @@ public: MC6845_UPDATE_ROW(crtc_update_row); memory_region *m_cart_rom; memory_region *m_bios_rom; - + protected: required_device m_maincpu; required_device m_cassette; @@ -111,30 +111,30 @@ protected: optional_device m_palette; private: - + void set_banks(); void postload(); - + // memory banking UINT8 m_bank_switch; UINT8 m_bank_low; UINT8 m_bank_high; - + UINT8 m_bank_low_read_only; UINT8 m_bank_high1_read_only; UINT8 m_bank_high2_read_only; - + UINT8 *m_empty_bank; UINT8 *m_bank_low_ptr; UINT8 *m_bank_high1_ptr; UINT8 *m_bank_high2_ptr; - + // keyboard UINT8 m_keyboard_row; - + // centronics int m_centronics_busy; - + // SVI-806 80 column card UINT8 m_svi806_present; UINT8 m_svi806_ram_enabled; diff --git a/src/mess/machine/aim65.c b/src/mess/machine/aim65.c index 92a30998ff7..a4b4d53d1ce 100644 --- a/src/mess/machine/aim65.c +++ b/src/mess/machine/aim65.c @@ -149,7 +149,7 @@ void aim65_state::machine_start() space.install_read_handler(0xc000, 0xcfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_z25)); if (m_z26->exists()) space.install_read_handler(0xb000, 0xbfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_z26)); - + // Init RAM space.install_ram(0x0000, ram->size() - 1, ram->pointer()); diff --git a/src/mess/machine/amigakbd.c b/src/mess/machine/amigakbd.c index ec88371482b..55f57cdcdfb 100644 --- a/src/mess/machine/amigakbd.c +++ b/src/mess/machine/amigakbd.c @@ -8,20 +8,20 @@ We currently emulate the Amiga 500 keyboard controller, which was also used in later Amiga 2000 keyboards. - TODO: - Natural keyboard mode doesn't work with shifted characters, - they get sent in the wrong order (core bug?) - - Move 6500/1 to its own CPU core so that it can be shared with - other systems - - Add support for more keyboard controllers (pending on them - getting dumped) + TODO: - Natural keyboard mode doesn't work with shifted characters, + they get sent in the wrong order (core bug?) + - Move 6500/1 to its own CPU core so that it can be shared with + other systems + - Add support for more keyboard controllers (pending on them + getting dumped) - Amiga 1000 keyboard part numbers (manufactured by Mitsumi): + Amiga 1000 keyboard part numbers (manufactured by Mitsumi): - - 327063-01 R56-2144 English - - 327063-02 British - - 327063-03 R56-2153 German - - 327063-04 R56-2152 French - - 327063-05 R56-2154 Italian + - 327063-01 R56-2144 English + - 327063-02 British + - 327063-03 R56-2153 German + - 327063-04 R56-2152 French + - 327063-05 R56-2154 Italian ***************************************************************************/ @@ -335,8 +335,8 @@ void amigakbd_device::device_reset() m_kclk = 1; m_port_c = 0xff; m_port_d = 0xff; - m_latch = 0xffff; // not initialized by hardware - m_counter = 0xffff; // not initialized by hardware + m_latch = 0xffff; // not initialized by hardware + m_counter = 0xffff; // not initialized by hardware m_control = 0x00; m_timer->adjust(attotime::zero, 0, attotime::from_hz(XTAL_3MHz / 2)); diff --git a/src/mess/machine/amstrad.c b/src/mess/machine/amstrad.c index 0d9747a829c..5954bb90682 100644 --- a/src/mess/machine/amstrad.c +++ b/src/mess/machine/amstrad.c @@ -3031,7 +3031,7 @@ MACHINE_START_MEMBER(amstrad_state,plus) m_asic.ram = m_region_user1->base(); // 16kB RAM for ASIC, memory-mapped registers. m_system_type = SYSTEM_PLUS; m_centronics->write_data7(0); - + astring region_tag; m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); } @@ -3073,7 +3073,7 @@ MACHINE_START_MEMBER(amstrad_state,gx4000) { m_asic.ram = m_region_user1->base(); // 16kB RAM for ASIC, memory-mapped registers. m_system_type = SYSTEM_GX4000; - + astring region_tag; m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); } @@ -3187,7 +3187,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state, amstrad_plus_cartridge) // check for .CPR header if (image.software_entry() == NULL) { - image.fread(header, 12); + image.fread(header, 12); if (strncmp((char *)header, "RIFF", 4) != 0) { // not a CPR file, so rewind the image at start @@ -3219,7 +3219,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state, amstrad_plus_cartridge) return IMAGE_INIT_FAIL; } else - image.fread(m_cart->get_rom_base(), size); + image.fread(m_cart->get_rom_base(), size); } else { @@ -3229,7 +3229,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state, amstrad_plus_cartridge) // Chunks labeled 'cb00' represent Cartridge block 0, and is loaded to &0000-&3fff // 'cb01' represent Cartridge block 1, and is loaded to &4000-&7fff // ... and so on. - + UINT32 offset = 0; UINT8 *crt = m_cart->get_rom_base(); dynamic_buffer temp_copy; @@ -3241,7 +3241,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state, amstrad_plus_cartridge) char chunklen[4]; // chunk length (always little-endian) int chunksize; // chunk length, calcaulated from the above int ramblock; // 16k RAM block chunk is to be loaded into - unsigned int bytes_to_read; // total bytes to read, as mame_feof doesn't react to EOF without trying to go past it. + 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) diff --git a/src/mess/machine/apple2.c b/src/mess/machine/apple2.c index 09f59120dab..927e678ec7a 100644 --- a/src/mess/machine/apple2.c +++ b/src/mess/machine/apple2.c @@ -366,7 +366,7 @@ READ8_MEMBER(apple2_state::apple2_c080_r) } } } - + if ((m_machinetype == APPLE_IICPLUS) && (slot == 6)) { offset &= 0xf; @@ -377,7 +377,7 @@ READ8_MEMBER(apple2_state::apple2_c080_r) { offset &= 0xf; UINT8 retval = m_exp_regs[offset]; - + if (offset == 3) { retval = m_exp_ram[m_exp_liveptr&m_exp_addrmask]; @@ -2287,7 +2287,7 @@ MACHINE_START_MEMBER(apple2_state,apple2c) MACHINE_START_MEMBER(apple2_state,tk3000) { - m_machinetype = TK3000; // enhanced IIe clone with Z80 keyboard scanner subcpu + m_machinetype = TK3000; // enhanced IIe clone with Z80 keyboard scanner subcpu apple2eplus_init_common((void *)NULL); } @@ -2335,7 +2335,7 @@ MACHINE_START_MEMBER(apple2_state,laser128) apple2_init_common(); // 1 MB of expansion RAM in slot 5 - m_exp_ram = auto_alloc_array(machine(), UINT8, 1024*1024); + m_exp_ram = auto_alloc_array(machine(), UINT8, 1024*1024); memset(m_exp_ram, 0xff, 1024*1024); m_exp_bankhior = 0xf0; diff --git a/src/mess/machine/apple3.c b/src/mess/machine/apple3.c index 7ca8da875f9..e90f67b36df 100644 --- a/src/mess/machine/apple3.c +++ b/src/mess/machine/apple3.c @@ -1275,4 +1275,3 @@ WRITE_LINE_MEMBER(apple3_state::a2bus_nmi_w) m_maincpu->set_input_line(INPUT_LINE_NMI, state); } } - diff --git a/src/mess/machine/bbc.c b/src/mess/machine/bbc.c index dcda1285da7..d1dfb92e980 100644 --- a/src/mess/machine/bbc.c +++ b/src/mess/machine/bbc.c @@ -1941,16 +1941,16 @@ WRITE8_MEMBER(bbc_state::bbc_disc_w) int bbc_state::bbc_load_cart(device_image_interface &image, generic_slot_device *slot) { UINT32 size = slot->common_get_size("rom"); - + if (size != 0x2000 && size != 0x4000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, "rom"); - + return IMAGE_INIT_PASS; } @@ -1969,7 +1969,7 @@ int bbc_state::bbcm_load_cart(device_image_interface &image, generic_slot_device image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + slot->rom_alloc(filesize, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); image.fread(slot->get_rom_base(), filesize); return IMAGE_INIT_PASS; @@ -1978,18 +1978,18 @@ int bbc_state::bbcm_load_cart(device_image_interface &image, generic_slot_device { UINT32 size_lo = image.get_software_region_length("lorom"); UINT32 size_hi = image.get_software_region_length("uprom"); - + if (size_lo + size_hi != 0x8000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + slot->rom_alloc(size_lo + size_hi, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); memcpy(slot->get_rom_base() + 0, image.get_software_region("uprom"), size_hi); memcpy(slot->get_rom_base() + size_hi, image.get_software_region("lorom"), size_lo); } - + return IMAGE_INIT_PASS; } @@ -2052,7 +2052,7 @@ void bbc_state::bbc_setup_banks(memory_bank *membank, int banks, UINT32 shift, U eprom[3] = tmp_reg->base() + shift; else eprom[3] = m_region_opt->base() + 0xc000 + shift; - + membank->configure_entries(0, 1, eprom[0], size); membank->configure_entries(1, 1, eprom[1], size); membank->configure_entries(2, 1, eprom[2], size); @@ -2078,12 +2078,12 @@ void bbc_state::bbcm_setup_banks(memory_bank *membank, int banks, UINT32 shift, eprom[1] = tmp_reg->base() + shift; else eprom[1] = m_region_opt->base() + 0x8000 + shift; - + membank->configure_entries(0, 1, eprom[0], size); membank->configure_entries(1, 1, eprom[0] + 0x4000, size); membank->configure_entries(2, 1, eprom[1], size); membank->configure_entries(3, 1, eprom[1] + 0x4000, size); - + if (banks > 4) { for (int i = 0; i < banks - 4; i++) @@ -2127,7 +2127,7 @@ MACHINE_START_MEMBER(bbc_state, bbcb) m_previous_wd177x_int_state=1; bbc_setup_banks(m_bank4, 16, 0, 0x4000); if (m_region_dfs) - m_bank4->configure_entries(16, 8, m_region_dfs->base(), 0x4000); // additional bank for paged ram + m_bank4->configure_entries(16, 8, m_region_dfs->base(), 0x4000); // additional bank for paged ram } MACHINE_RESET_MEMBER(bbc_state, bbcb) @@ -2155,7 +2155,7 @@ MACHINE_START_MEMBER(bbc_state, bbcbp) m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(bbc_state::bbcbp_direct_handler), this)); bbc_setup_banks(m_bank4, 16, 0, 0x3000); - m_bank4->configure_entries(16, 1, m_region_maincpu->base() + 0x8000, 0x3000); // additional bank for paged ram + m_bank4->configure_entries(16, 1, m_region_maincpu->base() + 0x8000, 0x3000); // additional bank for paged ram bbc_setup_banks(m_bank6, 16, 0x3000, 0x1000); } @@ -2180,7 +2180,7 @@ MACHINE_START_MEMBER(bbc_state, bbcm) m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(bbc_state::bbcm_direct_handler), this)); bbcm_setup_banks(m_bank4, 16, 0, 0x1000); - m_bank4->configure_entries(16, 1, m_region_maincpu->base() + 0x8000, 0x1000); // additional bank for paged ram + m_bank4->configure_entries(16, 1, m_region_maincpu->base() + 0x8000, 0x1000); // additional bank for paged ram bbcm_setup_banks(m_bank5, 16, 0x1000, 0x3000); /* Set ROM/IO bank to point to rom */ diff --git a/src/mess/machine/concept.c b/src/mess/machine/concept.c index 46575f9256f..e071d92452c 100644 --- a/src/mess/machine/concept.c +++ b/src/mess/machine/concept.c @@ -154,7 +154,7 @@ WRITE8_MEMBER(concept_state::via_out_b) WRITE_LINE_MEMBER(concept_state::via_out_cb2) { -// LOG(("via_out_cb2: Sound control written: data=0x%2.2x\n", state)); +// LOG(("via_out_cb2: Sound control written: data=0x%2.2x\n", state)); m_speaker->level_w(state); } @@ -210,7 +210,7 @@ READ16_MEMBER(concept_state::concept_io_r) if (card) { - return card->read_cnxx(space, offset & 0xff); + return card->read_cnxx(space, offset & 0xff); } } break; @@ -245,7 +245,7 @@ READ16_MEMBER(concept_state::concept_io_r) case 3: /* NVIA versatile system interface */ -// LOG(("concept_io_r: VIA read at address 0x03%4.4x\n", offset << 1)); +// LOG(("concept_io_r: VIA read at address 0x03%4.4x\n", offset << 1)); { via6522_device *via_0 = machine().device("via6522_0"); return via_0->read(space, offset & 0xf); @@ -301,7 +301,7 @@ WRITE16_MEMBER(concept_state::concept_io_w) if (card) { - return card->write_c0nx(space, offset & 0x0f, data); + return card->write_c0nx(space, offset & 0x0f, data); } } break; diff --git a/src/mess/machine/electron.c b/src/mess/machine/electron.c index bce85d595e2..ca6efe3b4d6 100644 --- a/src/mess/machine/electron.c +++ b/src/mess/machine/electron.c @@ -344,7 +344,7 @@ void electron_state::machine_reset() } void electron_state::machine_start() -{ +{ UINT8 *lo_rom, *up_rom; astring region_tag; memory_region *cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); @@ -357,7 +357,7 @@ void electron_state::machine_start() lo_rom = cart_rom->base() + 0x4000; else lo_rom = memregion("user1")->base(); - + membank("bank2")->configure_entries(0, 1, lo_rom, 0x4000); membank("bank2")->configure_entries(1, 11, memregion("user1")->base() + 0x04000, 0x4000); membank("bank2")->configure_entries(12, 1, up_rom, 0x4000); @@ -389,13 +389,13 @@ DEVICE_IMAGE_LOAD_MEMBER( electron_state, electron_cart ) { int upsize = image.get_software_region_length("uprom"); int losize = image.get_software_region_length("lorom"); - + if (upsize != 16384 && upsize != 0) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size for uprom"); return IMAGE_INIT_FAIL; } - + if (losize != 16384 && losize != 0) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size for lorom"); @@ -406,7 +406,7 @@ DEVICE_IMAGE_LOAD_MEMBER( electron_state, electron_cart ) if (upsize) memcpy(m_cart->get_rom_base(), image.get_software_region("uprom"), upsize); - + if (losize) memcpy(m_cart->get_rom_base() + upsize, image.get_software_region("lorom"), losize); diff --git a/src/mess/machine/gamecom.c b/src/mess/machine/gamecom.c index 75d69b049f6..c95e15fc0f2 100644 --- a/src/mess/machine/gamecom.c +++ b/src/mess/machine/gamecom.c @@ -640,15 +640,15 @@ int gamecom_state::common_load(device_image_interface &image, generic_slot_devic UINT32 load_offset = 0; if (size != 0x008000 && size != 0x040000 && size != 0x080000 - && size != 0x100000 && size != 0x1c0000 && size != 0x200000) + && size != 0x100000 && size != 0x1c0000 && size != 0x200000) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } - + if (size == 0x1c0000) load_offset = 0x40000; - + // in order to simplify banked access from the driver, we always allocate 0x200000, slot->rom_alloc(0x200000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // we load what we have @@ -661,7 +661,7 @@ int gamecom_state::common_load(device_image_interface &image, generic_slot_devic if (size < 0x080000) { memcpy(crt + 0x040000, crt, 0x040000); } /* ->512KB */ if (size < 0x100000) { memcpy(crt + 0x080000, crt, 0x080000); } /* ->1MB */ if (size < 0x1c0000) { memcpy(crt + 0x100000, crt, 0x100000); } /* -> >=1.8MB */ - + return IMAGE_INIT_PASS; } diff --git a/src/mess/machine/gamepock.c b/src/mess/machine/gamepock.c index e2ed49920a9..8c43df24314 100644 --- a/src/mess/machine/gamepock.c +++ b/src/mess/machine/gamepock.c @@ -139,7 +139,7 @@ void gamepock_state::machine_reset() if (m_cart->exists()) m_maincpu->space(AS_PROGRAM).install_read_handler(0x4000,0xbfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); - + } UINT32 gamepock_state::screen_update_gamepock(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) diff --git a/src/mess/machine/intv.c b/src/mess/machine/intv.c index f3c0bbc6d9d..52c250d030f 100644 --- a/src/mess/machine/intv.c +++ b/src/mess/machine/intv.c @@ -351,7 +351,7 @@ void intv_state::machine_start() save_item(NAME(m_ram16)); save_item(NAME(m_sr1_int_pending)); save_item(NAME(m_ram8)); - + // intvkbd if (m_is_keybd) { @@ -388,7 +388,7 @@ void intv_state::machine_start() case INTV_VOICE: m_cart->late_subslot_setup(); m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x0080, 0x0081, read16_delegate(FUNC(intv_cart_slot_device::read_speech),(intv_cart_slot_device*)m_cart), write16_delegate(FUNC(intv_cart_slot_device::write_speech),(intv_cart_slot_device*)m_cart)); - + // passthru for RAM-equipped carts m_maincpu->space(AS_PROGRAM).install_write_handler(0x8800, 0x8fff, write16_delegate(FUNC(intv_cart_slot_device::write_88),(intv_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_write_handler(0xd000, 0xd7ff, write16_delegate(FUNC(intv_cart_slot_device::write_d0),(intv_cart_slot_device*)m_cart)); @@ -402,10 +402,10 @@ void intv_state::machine_start() m_maincpu->space(AS_PROGRAM).install_write_handler(0x7000, 0x7fff, write16_delegate(FUNC(intv_cart_slot_device::write_rom70),(intv_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_write_handler(0xe000, 0xefff, write16_delegate(FUNC(intv_cart_slot_device::write_rome0),(intv_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_write_handler(0xf000, 0xffff, write16_delegate(FUNC(intv_cart_slot_device::write_romf0),(intv_cart_slot_device*)m_cart)); - + // passthru for Intellivoice expansion m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x0080, 0x0081, read16_delegate(FUNC(intv_cart_slot_device::read_speech),(intv_cart_slot_device*)m_cart), write16_delegate(FUNC(intv_cart_slot_device::write_speech),(intv_cart_slot_device*)m_cart)); - + // passthru for RAM-equipped carts m_maincpu->space(AS_PROGRAM).install_write_handler(0x8800, 0x8fff, write16_delegate(FUNC(intv_cart_slot_device::write_88),(intv_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_write_handler(0xd000, 0xd7ff, write16_delegate(FUNC(intv_cart_slot_device::write_d0),(intv_cart_slot_device*)m_cart)); diff --git a/src/mess/machine/lynx.c b/src/mess/machine/lynx.c index 061cf441ed3..f2864ef3ed6 100644 --- a/src/mess/machine/lynx.c +++ b/src/mess/machine/lynx.c @@ -1019,7 +1019,7 @@ READ8_MEMBER(lynx_state::suzy_read) case RCART: if (m_cart->exists()) value = m_cart->read_rom(space, (m_suzy.high * m_granularity) + m_suzy.low); - else + else value = 0; m_suzy.low = (m_suzy.low + 1) & (m_granularity - 1); break; @@ -2078,29 +2078,29 @@ DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart ) // 22 chars manufacturer UINT8 header[0x40]; image.fread(header, 0x40); - + // Check the image if (lynx_verify_cart((char*)header, LYNX_CART) == IMAGE_VERIFY_FAIL) return IMAGE_INIT_FAIL; - + /* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using it correctly in MESS? Moreover, the next two values should be page_size_bank1. We should implement this as well */ gran = header[4] | (header[5] << 8); - + logerror ("%s %dkb cartridge with %dbyte granularity from %s\n", header + 10, size / 1024, gran, header + 42); size -= 0x40; } - } + } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); // set-up granularity if (image.software_entry() == NULL) { const char *filetype = image.filetype(); - if (!core_stricmp(filetype, "lnx")) // from header + if (!core_stricmp(filetype, "lnx")) // from header m_granularity = gran; else if (!core_stricmp(filetype, "lyx")) { @@ -2122,7 +2122,7 @@ DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart ) else m_granularity = 0x400; // Homebrew roms not using all 256 banks (T-Tris) (none currently in softlist) } - + // set-up rotation from softlist if (image.software_entry() != NULL) { @@ -2140,4 +2140,3 @@ DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart ) return IMAGE_INIT_PASS; } - diff --git a/src/mess/machine/nc.c b/src/mess/machine/nc.c index 3cbbb5b7835..25246fbac18 100644 --- a/src/mess/machine/nc.c +++ b/src/mess/machine/nc.c @@ -49,7 +49,7 @@ DEVICE_IMAGE_LOAD_MEMBER( nc_state, nc_pcmcia_card ) UINT32 size = m_card->common_get_size("rom"); m_card->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_card->common_load_rom(m_card->get_rom_base(), size, "rom"); + m_card->common_load_rom(m_card->get_rom_base(), size, "rom"); set_card_present_state(1); m_membank_card_ram_mask = card_calculate_mask(size); @@ -64,14 +64,14 @@ DEVICE_IMAGE_UNLOAD_MEMBER( nc_state, nc_pcmcia_card ) // if there is no data to write, quit if (!m_card_size) return; - + logerror("attempting card save\n"); - + // write data image.fwrite(m_card_ram, m_card_size); - + logerror("write succeeded!\r\n"); - + // set card not present state set_card_present_state(0); m_card_size = 0; @@ -83,4 +83,3 @@ DRIVER_INIT_MEMBER( nc_state, nc ) set_card_present_state(0); m_card_size = 0; } - diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c index fbe2bea6bdd..14ca4c6aabe 100644 --- a/src/mess/machine/nes.c +++ b/src/mess/machine/nes.c @@ -97,7 +97,7 @@ void nes_state::setup_ioports() sprintf(str, "FT_COL%i", i); m_io_ftrainer[i] = ioport(str); } - + m_io_ctrlsel = ioport("CTRLSEL"); m_io_exp = ioport("EXP"); m_io_paddle = ioport("PADDLE"); diff --git a/src/mess/machine/primo.c b/src/mess/machine/primo.c index 1a6035dc4f5..51d41e42fdb 100644 --- a/src/mess/machine/primo.c +++ b/src/mess/machine/primo.c @@ -244,7 +244,7 @@ void primo_state::machine_start() { astring region_tag; m_cart1_rom = memregion(region_tag.cpy(m_cart1->tag()).cat(GENERIC_ROM_REGION_TAG)); - m_cart2_rom = memregion(region_tag.cpy(m_cart2->tag()).cat(GENERIC_ROM_REGION_TAG)); + m_cart2_rom = memregion(region_tag.cpy(m_cart2->tag()).cat(GENERIC_ROM_REGION_TAG)); } void primo_state::machine_reset() diff --git a/src/mess/machine/svi318.c b/src/mess/machine/svi318.c index fb284345665..3a16ff819a1 100644 --- a/src/mess/machine/svi318.c +++ b/src/mess/machine/svi318.c @@ -60,7 +60,7 @@ DEVICE_IMAGE_LOAD_MEMBER( svi318_state, svi318_cart ) } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); if (image.software_entry() == NULL && !cart_verify(m_cart->get_rom_base())) return IMAGE_INIT_FAIL; @@ -407,10 +407,10 @@ DRIVER_INIT_MEMBER(svi318_state, svi318) /* memory */ m_empty_bank = auto_alloc_array(machine(), UINT8, 0x8000); memset(m_empty_bank, 0xff, 0x8000); - + m_bank_low_ptr = m_empty_bank; m_bank_high1_ptr = m_empty_bank; - m_bank_high2_ptr = m_empty_bank; + m_bank_high2_ptr = m_empty_bank; } DRIVER_INIT_MEMBER(svi318_state, svi328_806) @@ -434,9 +434,9 @@ void svi318_state::machine_start() save_item(NAME(m_svi806_ram)); memset(m_svi806_ram, 0x00, 0x800); memset(m_svi806_ram + 0x800, 0xff, 0x800); - + m_svi806_gfx = memregion("gfx1")->base(); - + // Set SVI-806 80 column card palette m_palette->set_pen_color(TMS9928A_PALETTE_SIZE, 0, 0, 0); /* Monochrome black */ m_palette->set_pen_color(TMS9928A_PALETTE_SIZE+1, 0, 224, 0); /* Monochrome green */ @@ -459,7 +459,7 @@ void svi318_state::machine_start() save_item(NAME(m_svi806_present)); save_item(NAME(m_svi806_ram_enabled)); - + machine().save().register_postload(save_prepost_delegate(FUNC(svi318_state::postload), this)); } @@ -485,7 +485,7 @@ static void svi318_load_proc(device_image_interface &image) } void svi318_state::machine_reset() -{ +{ m_keyboard_row = 0; m_centronics_busy = 0; m_svi806_present = 0; @@ -587,7 +587,7 @@ void svi318_state::set_banks() } m_bank_high1_ptr = m_empty_bank; - m_bank_high1_read_only = 1; + m_bank_high1_read_only = 1; m_bank_high2_ptr = m_empty_bank; m_bank_high2_read_only = 1; diff --git a/src/mess/machine/thomson.c b/src/mess/machine/thomson.c index 72a81bb30f1..7b28e642a8e 100644 --- a/src/mess/machine/thomson.c +++ b/src/mess/machine/thomson.c @@ -1841,14 +1841,14 @@ void thomson_state::to9_set_video_mode( UINT8 data, int style ) thom_set_video_mode( THOM_VMODE_TO9 ); break; - // undocumented, but tested on a real TO8D - case 0x20: thom_set_video_mode( THOM_VMODE_MO5_ALT ); break; + // undocumented, but tested on a real TO8D + case 0x20: thom_set_video_mode( THOM_VMODE_MO5_ALT ); break; case 0x21: thom_set_video_mode( THOM_VMODE_BITMAP4 ); break; case 0x41: thom_set_video_mode( THOM_VMODE_BITMAP4_ALT ); break; - // also undocumented but tested + // also undocumented but tested case 0x59: thom_set_video_mode( THOM_VMODE_BITMAP4_ALT_HALF ); break; case 0x2a: @@ -1866,7 +1866,7 @@ void thomson_state::to9_set_video_mode( UINT8 data, int style ) case 0x26: thom_set_video_mode( THOM_VMODE_OVERLAY ); break; - // undocumented 160x200 variant of overlay + // undocumented 160x200 variant of overlay case 0x3e: thom_set_video_mode( THOM_VMODE_OVERLAY_HALF ); break; case 0x3f: thom_set_video_mode( THOM_VMODE_OVERLAY3 ); break; diff --git a/src/mess/machine/vtech2.c b/src/mess/machine/vtech2.c index 9be4b6aac21..e13f23c43da 100644 --- a/src/mess/machine/vtech2.c +++ b/src/mess/machine/vtech2.c @@ -71,11 +71,11 @@ DRIVER_INIT_MEMBER(vtech2_state,laser) m_laser_latch = -1; m_mem = memregion("maincpu")->base(); - + // check ROM expansion astring region_tag; m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - + for (i = 0; i < ARRAY_LENGTH(m_laser_bank); i++) m_laser_bank[i] = -1; } @@ -88,7 +88,7 @@ void vtech2_state::laser_machine_init(int bank_mask, int video_mask) m_laser_video_bank = video_mask; m_videoram = m_mem + m_laser_video_bank * 0x04000; logerror("laser_machine_init(): bank mask $%04X, video %d [$%05X]\n", m_laser_bank_mask, m_laser_video_bank, m_laser_video_bank * 0x04000); - + for (int i = 0; i < ARRAY_LENGTH(m_laser_bank); i++) laser_bank_select_w(m_maincpu->space(AS_PROGRAM), i, 0); } @@ -153,13 +153,13 @@ WRITE8_MEMBER(vtech2_state::laser_bank_select_w) else { sprintf(bank, "bank%d", offset + 1); - if (data >= 12 && m_cart_rom && (m_cart_rom->bytes() > (data % 12) * 0x4000)) // Expansion ROM banks + if (data >= 12 && m_cart_rom && (m_cart_rom->bytes() > (data % 12) * 0x4000)) // Expansion ROM banks { membank(bank)->set_base(m_cart_rom->base()+ (data % 12) * 0x4000); m_maincpu->space(AS_PROGRAM).install_read_bank(offset * 0x4000, offset * 0x4000 + 0x3fff, mra_bank_hard[offset]); m_maincpu->space(AS_PROGRAM).install_write_bank(offset * 0x4000, offset * 0x4000 + 0x3fff, mwa_bank_hard[offset]); } - else if (data < 12 && (m_laser_bank_mask & (1 << data))) // ROM/RAM banks + else if (data < 12 && (m_laser_bank_mask & (1 << data))) // ROM/RAM banks { // video RAM bank selected? if (data == m_laser_video_bank) @@ -175,7 +175,7 @@ WRITE8_MEMBER(vtech2_state::laser_bank_select_w) m_maincpu->space(AS_PROGRAM).nop_readwrite(offset * 0x4000, offset * 0x4000 + 0x3fff); } } - + } } diff --git a/src/mess/machine/wswan.c b/src/mess/machine/wswan.c index d8a219e37d1..46d213e6eba 100644 --- a/src/mess/machine/wswan.c +++ b/src/mess/machine/wswan.c @@ -201,21 +201,21 @@ void wswan_state::common_start() { m_ws_bios_bank = auto_alloc_array(machine(), UINT8, 0x10000); memcpy(m_ws_bios_bank + 0xffc0, ws_fake_bios_code, 0x40); - + m_vdp.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wswan_state::wswan_scanline_interrupt),this), &m_vdp); m_vdp.timer->adjust(attotime::from_ticks(256, 3072000), 0, attotime::from_ticks(256, 3072000)); - + wswan_register_save(); - + machine().device("nvram")->set_base(m_internal_eeprom, INTERNAL_EEPROM_SIZE); - + if (m_cart->exists()) - { + { // ROM m_maincpu->space(AS_PROGRAM).install_read_handler(0x20000, 0x2ffff, read8_delegate(FUNC(ws_cart_slot_device::read_rom20),(ws_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_read_handler(0x30000, 0x3ffff, read8_delegate(FUNC(ws_cart_slot_device::read_rom30),(ws_cart_slot_device*)m_cart)); m_maincpu->space(AS_PROGRAM).install_read_handler(0x40000, 0xeffff, read8_delegate(FUNC(ws_cart_slot_device::read_rom40),(ws_cart_slot_device*)m_cart)); - + // SRAM if (m_cart->get_type() == WS_SRAM) { @@ -249,7 +249,7 @@ void wswan_state::machine_reset() if (m_cart->exists()) m_rotate = m_cart->get_is_rotated(); else - m_rotate = 0; + m_rotate = 0; /* Intialize ports */ memcpy(m_ws_portram, ws_portram_init, 256); @@ -332,14 +332,14 @@ READ8_MEMBER( wswan_state::port_r ) case 0xc1: case 0xc2: case 0xc3: - case 0xc4: // EEPROM data - case 0xc5: // EEPROM data + case 0xc4: // EEPROM data + case 0xc5: // EEPROM data case 0xc6: case 0xc7: case 0xc8: case 0xc9: case 0xca: - case 0xcb: // RTC data + case 0xcb: // RTC data case 0xcc: case 0xcd: case 0xce: @@ -1034,18 +1034,18 @@ WRITE8_MEMBER( wswan_state::port_w ) logerror( "Unsupported internal EEPROM command: %X\n", data ); } break; - case 0xc0: // ROM bank $40000-$fffff - case 0xc1: // SRAM bank - case 0xc2: // ROM bank $20000-$2ffff - case 0xc3: // ROM bank $30000-$3ffff + case 0xc0: // ROM bank $40000-$fffff + case 0xc1: // SRAM bank + case 0xc2: // ROM bank $20000-$2ffff + case 0xc3: // ROM bank $30000-$3ffff case 0xc4: case 0xc5: - case 0xc6: // EEPROM address / command - case 0xc7: // EEPROM address / command - case 0xc8: // EEPROM command + case 0xc6: // EEPROM address / command + case 0xc7: // EEPROM address / command + case 0xc8: // EEPROM command case 0xc9: - case 0xca: // RTC command - case 0xcb: // RTC data + case 0xca: // RTC command + case 0xcb: // RTC data case 0xcc: case 0xcd: case 0xce: diff --git a/src/mess/mess.mak b/src/mess/mess.mak index ebb3638d234..e37665920aa 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -963,7 +963,7 @@ $(MESSOBJ)/adc.a: \ $(MESS_DRIVERS)/superslave.o\ $(MESSOBJ)/alesis.a: \ - $(MESS_DRIVERS)/alesis.o $(MESS_AUDIO)/alesis.o $(MESS_VIDEO)/alesis.o \ + $(MESS_DRIVERS)/alesis.o $(MESS_AUDIO)/alesis.o $(MESS_VIDEO)/alesis.o \ $(MESSOBJ)/altos.a: \ $(MESS_DRIVERS)/altos5.o \ @@ -989,7 +989,7 @@ $(MESSOBJ)/apollo.a: \ $(MESSOBJ)/apple.a: \ $(MESS_DRIVERS)/apple1.o $(MESS_MACHINE)/apple1.o $(MESS_VIDEO)/apple1.o \ $(MESS_DRIVERS)/apple2.o $(MESS_MACHINE)/apple2.o $(MESS_VIDEO)/apple2.o \ - $(MESS_DRIVERS)/apple2gs.o $(MESS_MACHINE)/apple2gs.o $(MESS_VIDEO)/apple2gs.o \ + $(MESS_DRIVERS)/apple2gs.o $(MESS_MACHINE)/apple2gs.o $(MESS_VIDEO)/apple2gs.o \ $(MESS_DRIVERS)/apple3.o $(MESS_MACHINE)/apple3.o $(MESS_VIDEO)/apple3.o \ $(MESS_DRIVERS)/lisa.o $(MESS_MACHINE)/lisa.o \ $(MESS_DRIVERS)/mac.o $(MESS_AUDIO)/mac.o $(MESS_MACHINE)/egret.o $(MESS_MACHINE)/mac.o $(MESS_MACHINE)/macadb.o $(MESS_MACHINE)/macrtc.o $(MESS_MACHINE)/mackbd.o $(MESS_MACHINE)/swim.o $(MESS_VIDEO)/mac.o \ @@ -1029,7 +1029,7 @@ $(MESSOBJ)/bandai.a: \ $(MESS_DRIVERS)/wswan.o $(MESS_AUDIO)/wswan_snd.o $(MESS_MACHINE)/wswan.o $(MESS_VIDEO)/wswan.o \ $(MESSOBJ)/be.a: \ - $(MESS_DRIVERS)/bebox.o $(MESS_MACHINE)/bebox.o \ + $(MESS_DRIVERS)/bebox.o $(MESS_MACHINE)/bebox.o \ $(MESSOBJ)/bnpo.a: \ $(MESS_DRIVERS)/b2m.o $(MESS_MACHINE)/b2m.o $(MESS_VIDEO)/b2m.o \ @@ -1359,7 +1359,7 @@ $(MESSOBJ)/mgu.a: \ $(MESS_DRIVERS)/irisha.o \ $(MESSOBJ)/microkey.a: \ - $(MESS_DRIVERS)/primo.o $(MESS_MACHINE)/primo.o $(MESS_VIDEO)/primo.o \ + $(MESS_DRIVERS)/primo.o $(MESS_MACHINE)/primo.o $(MESS_VIDEO)/primo.o \ $(MESSOBJ)/mit.a: \ $(MESS_DRIVERS)/tx0.o $(MESS_VIDEO)/crt.o $(MESS_VIDEO)/tx0.o \ @@ -1469,7 +1469,7 @@ $(MESSOBJ)/pitronic.a: \ $(MESSOBJ)/pc.a: \ $(MESS_DRIVERS)/asst128.o \ $(MESS_DRIVERS)/europc.o \ - $(MESS_DRIVERS)/genpc.o $(MESS_MACHINE)/genpc.o \ + $(MESS_DRIVERS)/genpc.o $(MESS_MACHINE)/genpc.o \ $(MESS_DRIVERS)/ibmpc.o \ $(MESS_DRIVERS)/ibmpcjr.o \ $(MESS_DRIVERS)/pc.o \ @@ -1480,7 +1480,7 @@ $(MESSOBJ)/pdp1.a: \ $(MESSOBJ)/pel.a: \ $(MESS_DRIVERS)/galeb.o $(MESS_VIDEO)/galeb.o \ - $(MESS_DRIVERS)/orao.o $(MESS_MACHINE)/orao.o $(MESS_VIDEO)/orao.o \ + $(MESS_DRIVERS)/orao.o $(MESS_MACHINE)/orao.o $(MESS_VIDEO)/orao.o \ $(MESSOBJ)/philips.a: \ $(MESS_DRIVERS)/p2000t.o $(MESS_MACHINE)/p2000t.o $(MESS_VIDEO)/p2000m.o \ @@ -1686,7 +1686,7 @@ $(MESSOBJ)/tem.a: \ $(MESS_DRIVERS)/tec1.o \ $(MESSOBJ)/tesla.a: \ - $(MESS_DRIVERS)/ondra.o $(MESS_MACHINE)/ondra.o $(MESS_VIDEO)/ondra.o \ + $(MESS_DRIVERS)/ondra.o $(MESS_MACHINE)/ondra.o $(MESS_VIDEO)/ondra.o \ $(MESS_DRIVERS)/pmd85.o $(MESS_MACHINE)/pmd85.o $(MESS_VIDEO)/pmd85.o \ $(MESS_DRIVERS)/pmi80.o \ $(MESS_DRIVERS)/sapi1.o \ @@ -1699,7 +1699,7 @@ $(MESSOBJ)/thomson.a: \ $(MESS_DRIVERS)/thomson.o $(MESS_MACHINE)/thomson.o $(MESS_MACHINE)/thomflop.o $(MESS_VIDEO)/thomson.o \ $(MESSOBJ)/ti.a: \ - $(MESS_DRIVERS)/avigo.o $(MESS_VIDEO)/avigo.o \ + $(MESS_DRIVERS)/avigo.o $(MESS_VIDEO)/avigo.o \ $(MESS_DRIVERS)/cc40.o \ $(MESS_DRIVERS)/evmbug.o \ $(MESS_DRIVERS)/exelv.o \ diff --git a/src/mess/tiny.lst b/src/mess/tiny.lst index f9c576d54cc..000c69f4ee3 100644 --- a/src/mess/tiny.lst +++ b/src/mess/tiny.lst @@ -39,4 +39,4 @@ ******************************************************************************/ coleco // NTSC ColecoVision -colecop // PAL Colecovision +colecop // PAL Colecovision diff --git a/src/mess/tools/imgtool/modules/amiga.c b/src/mess/tools/imgtool/modules/amiga.c index 0f7c02a5624..dc8a6750690 100644 --- a/src/mess/tools/imgtool/modules/amiga.c +++ b/src/mess/tools/imgtool/modules/amiga.c @@ -1776,9 +1776,9 @@ static void amiga_image_info(imgtool_image *img, char *string, size_t len) t_v = amiga_crack_time(&root.v); t_r = amiga_crack_time(&root.r); - strftime(c, sizeof(c), "%d-%b-%y %H:%M:%S", localtime(&t_c)); - strftime(v, sizeof(v), "%d-%b-%y %H:%M:%S", localtime(&t_v)); - strftime(r, sizeof(r), "%d-%b-%y %H:%M:%S", localtime(&t_r)); + strftime(c, sizeof(c), "%d-%b-%y %H:%M:%S", localtime(&t_c)); + strftime(v, sizeof(v), "%d-%b-%y %H:%M:%S", localtime(&t_v)); + strftime(r, sizeof(r), "%d-%b-%y %H:%M:%S", localtime(&t_r)); strcpy(info, "Volume name: "); strncat(info, (char *)root.diskname, root.name_len); diff --git a/src/mess/video/advision.c b/src/mess/video/advision.c index cd4d11ee377..d55fb7ed137 100644 --- a/src/mess/video/advision.c +++ b/src/mess/video/advision.c @@ -65,7 +65,7 @@ void advision_state::vh_update(int x) for (int i = 0; i < 8; i++) { - if (!BIT(data, 7 - i)) + if (!BIT(data, 7 - i)) dst[i * 256] = 8; } diff --git a/src/mess/video/apple2.c b/src/mess/video/apple2.c index f12e9828f5e..67c94abdfda 100644 --- a/src/mess/video/apple2.c +++ b/src/mess/video/apple2.c @@ -102,7 +102,7 @@ inline void apple2_state::apple2_plot_text_character(bitmap_ind16 &bitmap, int x switch (m_sysconfig->read() & 0x03) { case 0: - break; // leave alone + break; // leave alone case 1: if ((m_machinetype == APPLE_II) || (m_machinetype == LABA2P) || (m_machinetype == SPACE84)) @@ -182,7 +182,7 @@ inline void apple2_state::apple2_plot_text_character(bitmap_ind16 &bitmap, int x for (i = 0; i < xscale; i++) { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; + bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; } } } @@ -352,7 +352,7 @@ void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &clip { case 0: artifact_map_ptr = &m_hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; *(p++) = v; @@ -362,7 +362,7 @@ void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &clip case 1: w >>= 7; - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = (w & 1); w >>= 1; @@ -373,7 +373,7 @@ void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &clip case 2: w >>= 7; - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = (w & 1); w >>= 1; @@ -384,7 +384,7 @@ void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &clip case 3: w >>= 7; - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = (w & 1); w >>= 1; @@ -411,7 +411,7 @@ void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &clip switch (mon_type) { case 0: - for (b = 0; b < 7; b++) + for (b = 0; b < 7; b++) { v = m_dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; *(p++) = v; diff --git a/src/mess/video/apple3.c b/src/mess/video/apple3.c index 57bd636d98a..17ff125ccd4 100644 --- a/src/mess/video/apple3.c +++ b/src/mess/video/apple3.c @@ -412,7 +412,7 @@ void apple3_state::apple3_video_graphics_chires(bitmap_ind16 &bitmap) UINT32 apple3_state::screen_update_apple3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { -// printf("gfx mode %x\n", m_flags & (VAR_VM3|VAR_VM1|VAR_VM0)); +// printf("gfx mode %x\n", m_flags & (VAR_VM3|VAR_VM1|VAR_VM0)); switch(m_flags & (VAR_VM3|VAR_VM1|VAR_VM0)) { diff --git a/src/mess/video/maria.c b/src/mess/video/maria.c index 5f285e4b2bf..62af22ba947 100644 --- a/src/mess/video/maria.c +++ b/src/mess/video/maria.c @@ -2,22 +2,22 @@ Atari MARIA video emulation - + - some history: - 2014-10-05 Mike Saarna, Robert Tuccitto Last Line DMA value corrected - to 6. GCC and Atari docs both show a difference between - Other Line and Last Line as +6 at the lowest part of the + 2014-10-05 Mike Saarna, Robert Tuccitto Last Line DMA value corrected + to 6. GCC and Atari docs both show a difference between + Other Line and Last Line as +6 at the lowest part of the range. - Blank scanlines are drawn when DMA is off, like real + Blank scanlines are drawn when DMA is off, like real hardware. - If MARIA hits the DMA limit, the CPU doesn't run until + If MARIA hits the DMA limit, the CPU doesn't run until the next scanline. - 2014-09-03 Mike Saarna, Robert Tuccitto reorganized DMA penalties to + 2014-09-03 Mike Saarna, Robert Tuccitto reorganized DMA penalties to support new rendering timeout code. 2014-08-29 Mike Saarna Timeout rendering added. - + 2014-08-26 Fabio Priuli Converted to device 2014-05-06 Mike Saarna Added interrupts to DMA cycle eating. Updates to @@ -61,7 +61,7 @@ atari_maria_device::atari_maria_device(const machine_config &mconfig, const char void atari_maria_device::device_start() -{ +{ m_cpu = machine().device(m_cpu_tag); m_screen = machine().first_screen(); m_screen->register_screen_bitmap(m_bitmap); @@ -181,7 +181,7 @@ void atari_maria_device::draw_scanline() // All lines in a zone have the same initial DMA startup time. We'll adjust // cycles for the special last zone line later, as those penalties happen after // MARIA is done rendering, or after its hit the maximum rendering time. - maria_cycles = 16; + maria_cycles = 16; /* Process this DLL entry */ @@ -232,7 +232,7 @@ void atari_maria_device::draw_scanline() data_addr = (m_charbase | c) + (m_offset << 8); if (is_holey(data_addr)) continue; - + maria_cycles += 3; if (m_cwidth) // two data bytes per map byte { @@ -260,9 +260,9 @@ void atari_maria_device::draw_scanline() } } } - + // Last Line post-render DMA cycle penalties... - if (m_offset == 0) + if (m_offset == 0) { maria_cycles += 6; // extra shutdown time if (READ_MEM(m_dll + 3) & 0x80) @@ -443,7 +443,7 @@ WRITE8_MEMBER(atari_maria_device::write) m_color_kill = data & 0x80; switch ((data >> 5) & 3) { - case 0x00: + case 0x00: case 01: logerror("dma test mode, do not use.\n"); break; diff --git a/src/mess/video/maria.h b/src/mess/video/maria.h index e1b70baf4a8..b776ee5ae26 100644 --- a/src/mess/video/maria.h +++ b/src/mess/video/maria.h @@ -12,22 +12,22 @@ public: atari_maria_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); static void set_cpu_tag(device_t &device, const char *tag) { downcast(device).m_cpu_tag = tag; } - + void interrupt(int lines); void startdma(int lines); - + DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - + protected: // device-level overrides virtual void device_start(); virtual void device_reset(); private: - + int m_maria_palette[32]; int m_line_ram[2][160]; int m_active_buffer; @@ -54,7 +54,7 @@ private: int write_line_ram(int addr, UINT8 offset, int pal); const char *m_cpu_tag; - cpu_device *m_cpu; // CPU whose space(AS_PROGRAM) serves as DMA source + cpu_device *m_cpu; // CPU whose space(AS_PROGRAM) serves as DMA source screen_device *m_screen; }; diff --git a/src/mess/video/nes.c b/src/mess/video/nes.c index 91ec1f2d18a..64cb116df1e 100644 --- a/src/mess/video/nes.c +++ b/src/mess/video/nes.c @@ -37,8 +37,8 @@ UINT32 nes_state::screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, m_ppu->render(bitmap, 0, 0, 0, 0); // if this is a disk system game, check for the flip-disk key - if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS)) // first scenario = disksys in m_cartslot (= famicom) - || m_disk) // second scenario = disk via fixed internal disk option (fds & famitwin) + if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS)) // first scenario = disksys in m_cartslot (= famicom) + || m_disk) // second scenario = disk via fixed internal disk option (fds & famitwin) { // latch this input so it doesn't go at warp speed if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip)) diff --git a/src/mess/video/thomson.c b/src/mess/video/thomson.c index 3687bb2dc7f..6b7bb72e221 100644 --- a/src/mess/video/thomson.c +++ b/src/mess/video/thomson.c @@ -412,7 +412,7 @@ UPDATE_HI( mo5alt ) int i; pen_t c[2]; c[0] = pal[ (ramb & 15) ^ 8 ]; - c[1] = pal[ (ramb >> 4) ^ 8 ]; + c[1] = pal[ (ramb >> 4) ^ 8 ]; for ( i = 0; i < 16; i += 2, rama >>= 1 ) dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; } @@ -715,11 +715,11 @@ UPDATE_HI( overlayhalf ) c[0][0] = pal[ 0 ]; c[0][1] = c[1][1] = pal[ 1 ]; c[1][0] = pal[ 2 ]; - rama >>= 4; - ramb >>= 4; + rama >>= 4; + ramb >>= 4; for ( i = 0; i < 16; i += 4, rama >>= 1, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = dst[ 13 - i ] = dst[ 12 - i ] = - c[ ramb & 1 ] [ rama & 1 ]; + dst[ 15 - i ] = dst[ 14 - i ] = dst[ 13 - i ] = dst[ 12 - i ] = + c[ ramb & 1 ] [ rama & 1 ]; } END_UPDATE @@ -730,8 +730,8 @@ UPDATE_LOW( overlayhalf ) c[0][0] = pal[ 0 ]; c[0][1] = c[1][1] = pal[ 1 ]; c[1][0] = pal[ 2 ]; - rama >>= 4; - ramb >>= 4; + rama >>= 4; + ramb >>= 4; for ( i = 0; i < 8; i += 2, rama >>= 1, ramb >>= 1 ) dst[ 7 - i ] = dst[ 6 - i ] = c[ ramb & 1 ] [ rama & 1 ]; } @@ -782,7 +782,7 @@ static const thom_scandraw thom_scandraw_funcs[THOM_VMODE_NB][2] = FUN(to770), FUN(mo5), FUN(bitmap4), FUN(bitmap4alt), FUN(mode80), FUN(bitmap16), FUN(page1), FUN(page2), FUN(overlay), FUN(overlay3), FUN(to9), FUN(mode80_to9), - FUN(bitmap4althalf), FUN(mo5alt), FUN(overlayhalf), + FUN(bitmap4althalf), FUN(mo5alt), FUN(overlayhalf), }; @@ -1199,27 +1199,27 @@ PALETTE_INIT_MEMBER(thomson_state, thom) { LOG (( "thom: palette init called\n" )); - /* TO8 and later use an EF9369 color palette chip - The spec shows a built-in gamma correction for gamma=2.8 - i.e., output is out = in ^ (1/2.8) + /* TO8 and later use an EF9369 color palette chip + The spec shows a built-in gamma correction for gamma=2.8 + i.e., output is out = in ^ (1/2.8) - For the TO7, the gamma correction is irrelevant. - - For the TO7/70, we use the same palette and gamma has the TO8, - which gives good results (but is not verified). - */ - thom_configure_palette(1.0 / 2.8, thom_pal_init, palette); + For the TO7, the gamma correction is irrelevant. + + For the TO7/70, we use the same palette and gamma has the TO8, + which gives good results (but is not verified). + */ + thom_configure_palette(1.0 / 2.8, thom_pal_init, palette); } PALETTE_INIT_MEMBER(thomson_state, mo5) { LOG (( "thom: MO5 palette init called\n" )); - /* The MO5 has a different fixed palette than the TO7/70. - We use a smaller gamma correction which gives intutively better - results (but is not verified). - */ - thom_configure_palette(1.0, mo5_pal_init, palette); + /* The MO5 has a different fixed palette than the TO7/70. + We use a smaller gamma correction which gives intutively better + results (but is not verified). + */ + thom_configure_palette(1.0, mo5_pal_init, palette); } diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 7b146fc058b..5e039285369 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -83,7 +83,7 @@ #define SDLOPTVAL_OPENGL "opengl" #define SDLOPTVAL_SOFT "soft" -#define SDLOPTVAL_SDL2ACCEL "accel" +#define SDLOPTVAL_SDL2ACCEL "accel" #define SDLMAME_LED(x) "led" #x diff --git a/src/osd/sdl/sdlfile.c b/src/osd/sdl/sdlfile.c index a31ace78619..c2526d0021b 100644 --- a/src/osd/sdl/sdlfile.c +++ b/src/osd/sdl/sdlfile.c @@ -499,4 +499,4 @@ int osd_is_absolute_path(const char *path) return result; } -#endif \ No newline at end of file +#endif diff --git a/src/osd/sdl/sdlptty_win32.c b/src/osd/sdl/sdlptty_win32.c index 190ca354055..42b10131c61 100644 --- a/src/osd/sdl/sdlptty_win32.c +++ b/src/osd/sdl/sdlptty_win32.c @@ -11,4 +11,3 @@ //============================================================ #include "../windows/winptty.c" - diff --git a/src/osd/sdl/sdlsocket.c b/src/osd/sdl/sdlsocket.c index 7d7370128b9..cc6682abcd1 100644 --- a/src/osd/sdl/sdlsocket.c +++ b/src/osd/sdl/sdlsocket.c @@ -192,4 +192,4 @@ file_error sdl_close_socket(osd_file *file) osd_free(file); return FILERR_NONE; } -#endif \ No newline at end of file +#endif diff --git a/src/osd/sdl/sdlsync_win32.c b/src/osd/sdl/sdlsync_win32.c index 7c6464ec69e..72f729d6937 100644 --- a/src/osd/sdl/sdlsync_win32.c +++ b/src/osd/sdl/sdlsync_win32.c @@ -9,4 +9,4 @@ // //============================================================ -#include "../windows/winsync.c" \ No newline at end of file +#include "../windows/winsync.c" diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index ccbe5013190..a5b130cd87f 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -134,7 +134,7 @@ bool sdl_osd_interface::video_init() void sdl_osd_interface::video_exit() { window_exit(); - + // free all of our monitor information while (sdl_monitor_list != NULL) { diff --git a/src/osd/windows/vconv.c b/src/osd/windows/vconv.c index 3defa283a79..841895bcda4 100644 --- a/src/osd/windows/vconv.c +++ b/src/osd/windows/vconv.c @@ -99,7 +99,7 @@ static const translation_info gcc_translate[] = { 0, "c++", "" }, { 0, "-flto", "/GL" }, { 0, "-fno-optimize-sibling-calls", "" }, - { VS2005, "-fopenmp", "/openmp" }, + { VS2005, "-fopenmp", "/openmp" }, { 0 } }; diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 65a82976cc6..1841ad30100 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -97,7 +97,7 @@ bool windows_osd_interface::video_init() void windows_osd_interface::video_exit() { window_exit(); - + // free all of our monitor information while (win_monitor_list != NULL) { @@ -111,10 +111,10 @@ void windows_osd_interface::video_exit() win_monitor_info::win_monitor_info() : next(NULL), - handle(NULL), - aspect(0.0f), - reqwidth(0), - reqheight(0) + handle(NULL), + aspect(0.0f), + reqwidth(0), + reqheight(0) { } diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index 46eb17978bf..23a8f62bde9 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -38,11 +38,11 @@ public: void refresh(); float get_aspect(); void set_aspect(float a) { aspect = a; } - + win_monitor_info * next; // pointer to next monitor in list HMONITOR handle; // handle to the monitor - MONITORINFOEX info; // most recently retrieved info -private: + MONITORINFOEX info; // most recently retrieved info +private: float aspect; // computed/configured aspect ratio of the physical device int reqwidth; // requested width for this monitor int reqheight; // requested height for this monitor diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 44ec17cb70b..28794405c62 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -245,7 +245,7 @@ bool windows_osd_interface::window_init() // set up the window list last_window_ptr = &win_window_list; - + return true; } @@ -313,7 +313,7 @@ win_window_info::win_window_info(running_machine &machine) m_target(NULL), m_targetview(0), m_targetorient(0), - m_primlist(NULL), + m_primlist(NULL), m_lastclicktime(0), m_lastclickx(0), m_lastclicky(0), @@ -321,9 +321,9 @@ win_window_info::win_window_info(running_machine &machine) m_machine(machine) { memset(m_title,0,sizeof(m_title)); - m_non_fullscreen_bounds.left = 0; - m_non_fullscreen_bounds.top = 0; - m_non_fullscreen_bounds.right = 0; + m_non_fullscreen_bounds.left = 0; + m_non_fullscreen_bounds.top = 0; + m_non_fullscreen_bounds.right = 0; m_non_fullscreen_bounds.bottom = 0; } @@ -331,7 +331,7 @@ win_window_info::~win_window_info() { } - + //============================================================ // winwindow_process_events_periodic // (main thread) diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index 3af43f6bf1f..b2c6ea2e994 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -36,12 +36,12 @@ class win_window_info { public: win_window_info(running_machine &machine); - virtual ~win_window_info(); + virtual ~win_window_info(); running_machine &machine() const { return m_machine; } void update(); - + win_window_info * m_next; volatile int m_init_state; diff --git a/src/osd/windows/winos.c b/src/osd/windows/winos.c index 8d32c5ec62b..a5afa35a824 100644 --- a/src/osd/windows/winos.c +++ b/src/osd/windows/winos.c @@ -32,4 +32,4 @@ int osd_get_num_processors(void) char *osd_getenv(const char *name) { return getenv(name); -} \ No newline at end of file +} diff --git a/src/osd/windows/winos.h b/src/osd/windows/winos.h index bef3d799760..55284d8ac14 100644 --- a/src/osd/windows/winos.h +++ b/src/osd/windows/winos.h @@ -29,4 +29,4 @@ int osd_get_num_processors(void); pointer to value -----------------------------------------------------------------------------*/ -char *osd_getenv(const char *name); \ No newline at end of file +char *osd_getenv(const char *name); diff --git a/src/osd/windows/winsync.c b/src/osd/windows/winsync.c index 4ef161dd001..ce69cea1651 100644 --- a/src/osd/windows/winsync.c +++ b/src/osd/windows/winsync.c @@ -373,4 +373,4 @@ void osd_scalable_lock_free(osd_scalable_lock *lock) DeleteCriticalSection(&lock->section); #endif free(lock); -} \ No newline at end of file +} diff --git a/src/osd/windows/winsync.h b/src/osd/windows/winsync.h index c574a9ba75c..725d459366d 100644 --- a/src/osd/windows/winsync.h +++ b/src/osd/windows/winsync.h @@ -197,4 +197,4 @@ void osd_scalable_lock_release(osd_scalable_lock *lock, INT32 myslot); void osd_scalable_lock_free(osd_scalable_lock *lock); -#endif /* __WINSYNC__ */ \ No newline at end of file +#endif /* __WINSYNC__ */ diff --git a/src/version.c b/src/version.c index a2c76de86a3..89d24016165 100644 --- a/src/version.c +++ b/src/version.c @@ -9,4 +9,4 @@ ***************************************************************************/ extern const char build_version[]; -const char build_version[] = "0.154 (" __DATE__")"; +const char build_version[] = "0.155 (" __DATE__")"; -- cgit v1.2.3
NameModifiedSize