summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Miodrag Milanovic <mmicko@gmail.com>2014-10-15 07:19:47 +0000
committerGravatarGravatar Miodrag Milanovic <mmicko@gmail.com>2014-10-15 07:19:47 +0000
commitc93ed344fbd26a9c2c49bdbc99014d8dc0cbe9ef (patch)
treea5017b8341bdadc5bcd1185ae49fe4c0a85424b8
parenta4dd32afb6cbfaae0e452c90486060682ab1c31c (diff)
Cleanups and version bumpmame0155
-rw-r--r--hash/a7800.xml6
-rw-r--r--hash/amiga_a3000.xml8
-rw-r--r--hash/amiga_hardware.xml22
-rw-r--r--hash/coleco.xml12
-rw-r--r--hash/fm7_disk.xml2
-rw-r--r--hash/fmtowns_cd.xml4
-rw-r--r--hash/gamegear.xml14
-rw-r--r--hash/gameking.xml32
-rw-r--r--hash/gbcolor.xml2
-rw-r--r--hash/intvecs.xml2
-rw-r--r--hash/msx1_cart.xml22
-rw-r--r--hash/nes.xml2
-rw-r--r--hash/pencil2.xml4
-rw-r--r--hash/psx.xml22
-rw-r--r--hash/timex_dock.xml2
-rw-r--r--src/emu/bus/a2bus/a2corvus.c2
-rw-r--r--src/emu/bus/a2bus/a2lang.c2
-rw-r--r--src/emu/bus/a2bus/corvfdc01.c17
-rw-r--r--src/emu/bus/a2bus/corvfdc02.c38
-rw-r--r--src/emu/bus/a2bus/corvfdc02.h2
-rw-r--r--src/emu/bus/a2bus/laser128.c6
-rw-r--r--src/emu/bus/a2bus/mouse.c136
-rw-r--r--src/emu/bus/a2bus/timemasterho.c43
-rw-r--r--src/emu/bus/a7800/a78_carts.h8
-rw-r--r--src/emu/bus/a7800/a78_slot.c86
-rw-r--r--src/emu/bus/a7800/a78_slot.h32
-rw-r--r--src/emu/bus/a7800/cpuwiz.c20
-rw-r--r--src/emu/bus/a7800/cpuwiz.h14
-rw-r--r--src/emu/bus/a7800/hiscore.c3
-rw-r--r--src/emu/bus/a7800/hiscore.h4
-rw-r--r--src/emu/bus/a7800/rom.c51
-rw-r--r--src/emu/bus/a7800/rom.h54
-rw-r--r--src/emu/bus/a7800/xboard.c30
-rw-r--r--src/emu/bus/a7800/xboard.h10
-rw-r--r--src/emu/bus/a800/a800_carts.h6
-rw-r--r--src/emu/bus/a800/a800_slot.c53
-rw-r--r--src/emu/bus/a800/a800_slot.h18
-rw-r--r--src/emu/bus/a800/oss.c31
-rw-r--r--src/emu/bus/a800/oss.h16
-rw-r--r--src/emu/bus/a800/rom.c89
-rw-r--r--src/emu/bus/a800/rom.h50
-rw-r--r--src/emu/bus/a800/sparta.c15
-rw-r--r--src/emu/bus/a800/sparta.h6
-rw-r--r--src/emu/bus/apf/rom.h2
-rw-r--r--src/emu/bus/apf/slot.c6
-rw-r--r--src/emu/bus/apf/slot.h7
-rw-r--r--src/emu/bus/arcadia/slot.c3
-rw-r--r--src/emu/bus/arcadia/slot.h3
-rw-r--r--src/emu/bus/c64/dela_ep256.c2
-rw-r--r--src/emu/bus/c64/rex_ep256.h2
-rw-r--r--src/emu/bus/centronics/digiblst.h8
-rw-r--r--src/emu/bus/chanf/rom.c11
-rw-r--r--src/emu/bus/chanf/rom.h26
-rw-r--r--src/emu/bus/chanf/slot.c14
-rw-r--r--src/emu/bus/chanf/slot.h7
-rw-r--r--src/emu/bus/cpc/amdrum.h2
-rw-r--r--src/emu/bus/cpc/symbfac2.c50
-rw-r--r--src/emu/bus/cpc/symbfac2.h2
-rw-r--r--src/emu/bus/crvision/rom.c2
-rw-r--r--src/emu/bus/crvision/rom.h10
-rw-r--r--src/emu/bus/crvision/slot.c5
-rw-r--r--src/emu/bus/crvision/slot.h3
-rw-r--r--src/emu/bus/gameboy/gb_slot.h8
-rw-r--r--src/emu/bus/gameboy/mbc.h4
-rw-r--r--src/emu/bus/gba/gba_slot.h6
-rw-r--r--src/emu/bus/generic/carts.c4
-rw-r--r--src/emu/bus/generic/ram.c15
-rw-r--r--src/emu/bus/generic/ram.h12
-rw-r--r--src/emu/bus/generic/rom.c9
-rw-r--r--src/emu/bus/generic/rom.h8
-rw-r--r--src/emu/bus/generic/slot.c21
-rw-r--r--src/emu/bus/generic/slot.h10
-rw-r--r--src/emu/bus/intv/ecs.c55
-rw-r--r--src/emu/bus/intv/ecs.h42
-rw-r--r--src/emu/bus/intv/rom.c1
-rw-r--r--src/emu/bus/intv/rom.h8
-rw-r--r--src/emu/bus/intv/slot.c83
-rw-r--r--src/emu/bus/intv/slot.h13
-rw-r--r--src/emu/bus/intv/voice.h24
-rw-r--r--src/emu/bus/isa/sb16.c12
-rw-r--r--src/emu/bus/isa/svga_trident.c4
-rw-r--r--src/emu/bus/isa/trident.c120
-rw-r--r--src/emu/bus/megadrive/ggenie.c26
-rw-r--r--src/emu/bus/msx_cart/disk.c3
-rw-r--r--src/emu/bus/msx_slot/disk.c3
-rw-r--r--src/emu/bus/nes/disksys.c79
-rw-r--r--src/emu/bus/nes/nes_slot.c20
-rw-r--r--src/emu/bus/nes/nes_slot.h4
-rw-r--r--src/emu/bus/odyssey2/chess.h5
-rw-r--r--src/emu/bus/odyssey2/rom.c5
-rw-r--r--src/emu/bus/odyssey2/rom.h12
-rw-r--r--src/emu/bus/odyssey2/slot.c5
-rw-r--r--src/emu/bus/odyssey2/slot.h5
-rw-r--r--src/emu/bus/odyssey2/voice.c2
-rw-r--r--src/emu/bus/odyssey2/voice.h2
-rw-r--r--src/emu/bus/pet/cb2snd.c1
-rw-r--r--src/emu/bus/rs232/xvd701.c4
-rw-r--r--src/emu/bus/saturn/sat_slot.c6
-rw-r--r--src/emu/bus/scv/rom.h16
-rw-r--r--src/emu/bus/scv/slot.c5
-rw-r--r--src/emu/bus/scv/slot.h7
-rw-r--r--src/emu/bus/sega8/ccatch.c4
-rw-r--r--src/emu/bus/sega8/mgear.h4
-rw-r--r--src/emu/bus/sega8/rom.c2
-rw-r--r--src/emu/bus/sega8/sega8_slot.c1
-rw-r--r--src/emu/bus/sega8/sega8_slot.h2
-rw-r--r--src/emu/bus/sms_ctrl/graphic.c21
-rw-r--r--src/emu/bus/snes/snes_slot.h6
-rw-r--r--src/emu/bus/vboy/rom.h4
-rw-r--r--src/emu/bus/vboy/slot.c6
-rw-r--r--src/emu/bus/vboy/slot.h7
-rw-r--r--src/emu/bus/vc4000/rom.c106
-rw-r--r--src/emu/bus/vc4000/rom.h4
-rw-r--r--src/emu/bus/vc4000/slot.c8
-rw-r--r--src/emu/bus/vc4000/slot.h7
-rw-r--r--src/emu/bus/vcs/compumat.c4
-rw-r--r--src/emu/bus/vcs/compumat.h4
-rw-r--r--src/emu/bus/vcs/dpc.c11
-rw-r--r--src/emu/bus/vcs/dpc.h8
-rwxr-xr-xsrc/emu/bus/vcs/rom.c131
-rwxr-xr-xsrc/emu/bus/vcs/rom.h76
-rw-r--r--src/emu/bus/vcs/scharger.c38
-rw-r--r--src/emu/bus/vcs/scharger.h6
-rwxr-xr-xsrc/emu/bus/vcs/vcs_slot.c86
-rwxr-xr-xsrc/emu/bus/vcs/vcs_slot.h6
-rw-r--r--src/emu/bus/vectrex/rom.h6
-rw-r--r--src/emu/bus/vectrex/slot.c24
-rw-r--r--src/emu/bus/vectrex/slot.h3
-rw-r--r--src/emu/bus/vic20/fe3.c48
-rw-r--r--src/emu/bus/vic20/fe3.h2
-rw-r--r--src/emu/bus/wswan/rom.c108
-rw-r--r--src/emu/bus/wswan/rom.h8
-rw-r--r--src/emu/bus/wswan/slot.c28
-rw-r--r--src/emu/bus/wswan/slot.h7
-rw-r--r--src/emu/cpu/dsp56k/dsp56k.c9
-rw-r--r--src/emu/cpu/hd61700/hd61700.c2
-rw-r--r--src/emu/cpu/hd61700/hd61700.h4
-rw-r--r--src/emu/cpu/i86/i186.c8
-rw-r--r--src/emu/cpu/mcs96/mcs96.c8
-rw-r--r--src/emu/cpu/mips/mips3drc.c2
-rw-r--r--src/emu/cpu/rsp/rsp.c52
-rw-r--r--src/emu/cpu/rsp/rspdrc.c1
-rw-r--r--src/emu/cpu/sh4/sh4.c4
-rw-r--r--src/emu/cpu/tlcs90/tlcs90.c90
-rw-r--r--src/emu/cpu/tms32031/tms32031.h2
-rw-r--r--src/emu/cpu/tms32051/tms32051.c4
-rw-r--r--src/emu/cpu/tms32051/tms32051.h2
-rw-r--r--src/emu/cpu/tms34010/tms34010.c4
-rw-r--r--src/emu/cpu/tms34010/tms34010.h34
-rw-r--r--src/emu/cpu/tms7000/tms7000.c4
-rw-r--r--src/emu/cpu/tms7000/tms7000.h2
-rw-r--r--src/emu/debug/debugcpu.c2
-rw-r--r--src/emu/devcpu.c1
-rw-r--r--src/emu/diimage.c6
-rw-r--r--src/emu/imagedev/floppy.c2
-rw-r--r--src/emu/machine.c2
-rw-r--r--src/emu/machine/mb8421.c6
-rw-r--r--src/emu/machine/pit8253.c2
-rw-r--r--src/emu/machine/rp5h01.c2
-rw-r--r--src/emu/machine/smpc.c2
-rw-r--r--src/emu/machine/wozfdc.c6
-rw-r--r--src/emu/sound/flt_rc.h10
-rw-r--r--src/emu/sound/k053260.c4
-rw-r--r--src/emu/sound/k053260.h2
-rw-r--r--src/emu/sound/samples.c2
-rw-r--r--src/emu/sound/samples.h6
-rw-r--r--src/emu/sound/speaker.h4
-rw-r--r--src/emu/sound/ymf278b.c2
-rw-r--r--src/emu/sound/zsg2.c2
-rw-r--r--src/emu/ui/swlist.c2
-rw-r--r--src/emu/ui/ui.c4
-rw-r--r--src/emu/video/315_5124.c2
-rw-r--r--src/emu/video/epic12.c2
-rw-r--r--src/emu/video/upd7220.c2
-rw-r--r--src/emu/video/vooddefs.h18
-rw-r--r--src/emu/video/voodoo.c4
-rw-r--r--src/emu/webengine.c222
-rw-r--r--src/lib/formats/ap2_dsk.c4
-rw-r--r--src/lib/formats/dmk_dsk.c1
-rw-r--r--src/lib/formats/dmk_dsk.h1
-rw-r--r--src/lib/formats/mfi_dsk.c4
-rw-r--r--src/lib/web/mongoose.c7301
-rw-r--r--src/lib/web/mongoose.h104
-rw-r--r--src/mame/audio/cclimber.h4
-rw-r--r--src/mame/audio/leland.c6
-rw-r--r--src/mame/audio/mario.c1
-rw-r--r--src/mame/drivers/20pacgal.c2
-rw-r--r--src/mame/drivers/4enraya.c14
-rw-r--r--src/mame/drivers/8080bw.c6
-rw-r--r--src/mame/drivers/aces1.c18
-rw-r--r--src/mame/drivers/alg.c24
-rw-r--r--src/mame/drivers/aristmk4.c2
-rw-r--r--src/mame/drivers/arkanoid.c10
-rw-r--r--src/mame/drivers/atarisy4.c16
-rw-r--r--src/mame/drivers/bartop52.c2
-rw-r--r--src/mame/drivers/battlera.c2
-rw-r--r--src/mame/drivers/bfm_sc1.c2
-rw-r--r--src/mame/drivers/bfm_sc2.c6
-rw-r--r--src/mame/drivers/bmcpokr.c76
-rw-r--r--src/mame/drivers/btoads.c2
-rw-r--r--src/mame/drivers/bublbobl.c2
-rw-r--r--src/mame/drivers/calchase.c19
-rw-r--r--src/mame/drivers/capr1.c18
-rw-r--r--src/mame/drivers/caprcyc.c6
-rw-r--r--src/mame/drivers/centiped.c16
-rw-r--r--src/mame/drivers/chqflag.c2
-rw-r--r--src/mame/drivers/coinmvga.c2
-rw-r--r--src/mame/drivers/coolpool.c2
-rw-r--r--src/mame/drivers/cops.c62
-rw-r--r--src/mame/drivers/cps1.c42
-rw-r--r--src/mame/drivers/cv1k.c8
-rw-r--r--src/mame/drivers/dkong.c4
-rw-r--r--src/mame/drivers/dlair.c2
-rw-r--r--src/mame/drivers/dlair2.c2
-rw-r--r--src/mame/drivers/dragrace.c2
-rw-r--r--src/mame/drivers/fcrash.c12
-rw-r--r--src/mame/drivers/foodf.c8
-rw-r--r--src/mame/drivers/fuukifg2.c2
-rw-r--r--src/mame/drivers/gaiden.c2
-rw-r--r--src/mame/drivers/galaxian.c8
-rw-r--r--src/mame/drivers/galpani3.c6
-rw-r--r--src/mame/drivers/galpanic.c2
-rw-r--r--src/mame/drivers/hikaru.c64
-rw-r--r--src/mame/drivers/igs011.c6
-rw-r--r--src/mame/drivers/igs017.c34
-rw-r--r--src/mame/drivers/iqblock.c6
-rw-r--r--src/mame/drivers/itech32.c28
-rw-r--r--src/mame/drivers/jchan.c2
-rw-r--r--src/mame/drivers/jclub2.c2
-rw-r--r--src/mame/drivers/jeutel.c2
-rw-r--r--src/mame/drivers/karnov.c8
-rw-r--r--src/mame/drivers/legionna.c14
-rw-r--r--src/mame/drivers/ltd.c2
-rw-r--r--src/mame/drivers/macs.c4
-rw-r--r--src/mame/drivers/mario.c22
-rw-r--r--src/mame/drivers/maxaflex.c4
-rw-r--r--src/mame/drivers/mazerbla.c2
-rw-r--r--src/mame/drivers/megatech.c18
-rw-r--r--src/mame/drivers/metro.c12
-rw-r--r--src/mame/drivers/mgavegas.c276
-rw-r--r--src/mame/drivers/midtunit.c2
-rw-r--r--src/mame/drivers/midwunit.c2
-rw-r--r--src/mame/drivers/midxunit.c2
-rw-r--r--src/mame/drivers/midyunit.c4
-rw-r--r--src/mame/drivers/model1.c4
-rw-r--r--src/mame/drivers/model3.c28
-rw-r--r--src/mame/drivers/mpu5hw.c38
-rw-r--r--src/mame/drivers/namcops2.c16
-rw-r--r--src/mame/drivers/namcos21.c2
-rw-r--r--src/mame/drivers/naomi.c30
-rw-r--r--src/mame/drivers/nmk16.c139
-rw-r--r--src/mame/drivers/pacman.c10
-rw-r--r--src/mame/drivers/peplus.c12
-rw-r--r--src/mame/drivers/potgoldu.c6
-rw-r--r--src/mame/drivers/punchout.c20
-rw-r--r--src/mame/drivers/r2dx_v33.c68
-rw-r--r--src/mame/drivers/raiden2.c20
-rw-r--r--src/mame/drivers/rainbow.c4
-rw-r--r--src/mame/drivers/rastersp.c2
-rw-r--r--src/mame/drivers/redclash.c2
-rw-r--r--src/mame/drivers/segac2.c2
-rw-r--r--src/mame/drivers/segas18.c2
-rw-r--r--src/mame/drivers/segas32.c40
-rw-r--r--src/mame/drivers/segaybd.c4
-rw-r--r--src/mame/drivers/simple_st0016.c4
-rw-r--r--src/mame/drivers/skimaxx.c10
-rw-r--r--src/mame/drivers/snesb.c66
-rw-r--r--src/mame/drivers/snk6502.c2
-rw-r--r--src/mame/drivers/snowbros.c2
-rw-r--r--src/mame/drivers/speedbal.c30
-rw-r--r--src/mame/drivers/speglsht.c2
-rw-r--r--src/mame/drivers/splash.c64
-rw-r--r--src/mame/drivers/srmp5.c8
-rw-r--r--src/mame/drivers/st_mp100.c2
-rw-r--r--src/mame/drivers/stv.c10
-rw-r--r--src/mame/drivers/system16.c4
-rw-r--r--src/mame/drivers/taito_z.c18
-rw-r--r--src/mame/drivers/tatsumi.c2
-rw-r--r--src/mame/drivers/tickee.c16
-rw-r--r--src/mame/drivers/travrusa.c1
-rw-r--r--src/mame/drivers/twinkle.c4
-rw-r--r--src/mame/drivers/vamphalf.c6
-rw-r--r--src/mame/drivers/vectrex.c2
-rw-r--r--src/mame/drivers/warpsped.c4
-rw-r--r--src/mame/drivers/xtheball.c2
-rw-r--r--src/mame/includes/8080bw.h2
-rw-r--r--src/mame/includes/artmagic.h8
-rw-r--r--src/mame/includes/bfm_sc45.h2
-rw-r--r--src/mame/includes/cinemat.h4
-rw-r--r--src/mame/includes/coolpool.h4
-rw-r--r--src/mame/includes/cosmic.h4
-rw-r--r--src/mame/includes/exterm.h4
-rw-r--r--src/mame/includes/fuukifg2.h2
-rw-r--r--src/mame/includes/fuukifg3.h2
-rw-r--r--src/mame/includes/harddriv.h12
-rw-r--r--src/mame/includes/jpmimpct.h4
-rw-r--r--src/mame/includes/konamigx.h2
-rw-r--r--src/mame/includes/legionna.h4
-rw-r--r--src/mame/includes/meadows.h4
-rw-r--r--src/mame/includes/micro3d.h4
-rw-r--r--src/mame/includes/midtunit.h2
-rw-r--r--src/mame/includes/midyunit.h4
-rw-r--r--src/mame/includes/model1.h4
-rw-r--r--src/mame/includes/model3.h4
-rw-r--r--src/mame/includes/namcos2.h2
-rw-r--r--src/mame/includes/polyplay.h6
-rw-r--r--src/mame/includes/raiden2.h50
-rw-r--r--src/mame/includes/simple_st0016.h2
-rw-r--r--src/mame/includes/snk.h8
-rw-r--r--src/mame/includes/splash.h2
-rw-r--r--src/mame/includes/sslam.h4
-rw-r--r--src/mame/includes/stv.h2
-rw-r--r--src/mame/includes/suna8.h2
-rw-r--r--src/mame/includes/suprnova.h4
-rw-r--r--src/mame/includes/taito_f3.h6
-rw-r--r--src/mame/includes/tatsumi.h4
-rw-r--r--src/mame/includes/thepit.h4
-rw-r--r--src/mame/includes/tnzs.h4
-rw-r--r--src/mame/includes/vectrex.h2
-rw-r--r--src/mame/layout/mgavegas.lay64
-rw-r--r--src/mame/layout/s11a.lay2
-rw-r--r--src/mame/machine/315_5296.c28
-rw-r--r--src/mame/machine/amiga.c2
-rw-r--r--src/mame/machine/asic65.c2
-rw-r--r--src/mame/machine/atari.c2
-rw-r--r--src/mame/machine/awboard.h4
-rw-r--r--src/mame/machine/inder_vid.c2
-rw-r--r--src/mame/machine/inder_vid.h4
-rw-r--r--src/mame/machine/kaneko_calc3.h6
-rw-r--r--src/mame/machine/kaneko_toybox.h4
-rw-r--r--src/mame/machine/konppc.c2
-rw-r--r--src/mame/machine/model1.c96
-rw-r--r--src/mame/machine/nmk004.c2
-rw-r--r--src/mame/machine/raiden2cop.c143
-rw-r--r--src/mame/machine/raiden2cop.h7
-rw-r--r--src/mame/machine/seicop.c12
-rw-r--r--src/mame/machine/seicop.h1
-rw-r--r--src/mame/machine/st0016.c53
-rw-r--r--src/mame/machine/st0016.h2
-rw-r--r--src/mame/machine/vectrex.c4
-rw-r--r--src/mame/mame.lst72
-rw-r--r--src/mame/mame.mak2
-rw-r--r--src/mame/video/antic.c131
-rw-r--r--src/mame/video/antic.h24
-rw-r--r--src/mame/video/battlera.c1
-rw-r--r--src/mame/video/decmxc06.h2
-rw-r--r--src/mame/video/dooyong.c5
-rw-r--r--src/mame/video/fuukifg.c6
-rw-r--r--src/mame/video/fuukifg.h7
-rw-r--r--src/mame/video/fuukifg3.c4
-rw-r--r--src/mame/video/gtia.c14
-rw-r--r--src/mame/video/gtia.h24
-rw-r--r--src/mame/video/k054156_k054157_k056832.c2
-rw-r--r--src/mame/video/legionna.c15
-rw-r--r--src/mame/video/mario.c7
-rw-r--r--src/mame/video/model3.c676
-rw-r--r--src/mame/video/seibuspi.c4
-rw-r--r--src/mame/video/sknsspr.h2
-rw-r--r--src/mame/video/skyfox.c2
-rw-r--r--src/mame/video/snk.c2
-rw-r--r--src/mame/video/taito_f3.c2
-rw-r--r--src/mame/video/tc0480scp.c2
-rw-r--r--src/mess/audio/vc4000snd.h8
-rw-r--r--src/mess/audio/wswan_snd.h12
-rw-r--r--src/mess/drivers/a2600.c6
-rw-r--r--src/mess/drivers/a7800.c26
-rw-r--r--src/mess/drivers/aim65.c2
-rw-r--r--src/mess/drivers/apf.c4
-rw-r--r--src/mess/drivers/apple2.c38
-rw-r--r--src/mess/drivers/apple2gs.c2
-rw-r--r--src/mess/drivers/apple3.c2
-rw-r--r--src/mess/drivers/atari400.c114
-rw-r--r--src/mess/drivers/atarist.c4
-rw-r--r--src/mess/drivers/atom.c8
-rw-r--r--src/mess/drivers/bbcbc.c2
-rw-r--r--src/mess/drivers/beta.c22
-rw-r--r--src/mess/drivers/casloopy.c8
-rw-r--r--src/mess/drivers/cc40.c14
-rw-r--r--src/mess/drivers/cgenie.c8
-rw-r--r--src/mess/drivers/channelf.c2
-rw-r--r--src/mess/drivers/concept.c4
-rw-r--r--src/mess/drivers/crvision.c4
-rw-r--r--src/mess/drivers/electron.c2
-rw-r--r--src/mess/drivers/ep64.c2
-rw-r--r--src/mess/drivers/exelv.c6
-rw-r--r--src/mess/drivers/fc100.c2
-rw-r--r--src/mess/drivers/fm7.c196
-rw-r--r--src/mess/drivers/gameking.c8
-rw-r--r--src/mess/drivers/gamepock.c2
-rw-r--r--src/mess/drivers/gba.c2
-rw-r--r--src/mess/drivers/geniusiq.c4
-rw-r--r--src/mess/drivers/gmaster.c2
-rw-r--r--src/mess/drivers/ibmpcjr.c2
-rw-r--r--src/mess/drivers/intv.c22
-rw-r--r--src/mess/drivers/itt3030.c46
-rw-r--r--src/mess/drivers/kyocera.c12
-rw-r--r--src/mess/drivers/laser3k.c162
-rw-r--r--src/mess/drivers/m5.c2
-rw-r--r--src/mess/drivers/msx.c43
-rw-r--r--src/mess/drivers/myvision.c8
-rw-r--r--src/mess/drivers/nc.c6
-rw-r--r--src/mess/drivers/nes.c20
-rw-r--r--src/mess/drivers/ngp.c14
-rw-r--r--src/mess/drivers/pc2000.c6
-rw-r--r--src/mess/drivers/pc6001.c16
-rw-r--r--src/mess/drivers/pc8401a.c2
-rw-r--r--src/mess/drivers/pc9801.c16
-rw-r--r--src/mess/drivers/pegasus.c16
-rw-r--r--src/mess/drivers/pencil2.c2
-rw-r--r--src/mess/drivers/pet.c4
-rw-r--r--src/mess/drivers/pockstat.c2
-rw-r--r--src/mess/drivers/pokemini.c6
-rw-r--r--src/mess/drivers/pt68k4.c34
-rw-r--r--src/mess/drivers/pv1000.c12
-rw-r--r--src/mess/drivers/pv2000.c10
-rw-r--r--src/mess/drivers/rx78.c12
-rw-r--r--src/mess/drivers/scv.c6
-rw-r--r--src/mess/drivers/socrates.c4
-rw-r--r--src/mess/drivers/sorcerer.c4
-rw-r--r--src/mess/drivers/spc1000.c48
-rw-r--r--src/mess/drivers/specpls3.c22
-rw-r--r--src/mess/drivers/spectrum.c8
-rw-r--r--src/mess/drivers/studio2.c36
-rw-r--r--src/mess/drivers/supracan.c8
-rw-r--r--src/mess/drivers/sv8000.c10
-rw-r--r--src/mess/drivers/svision.c8
-rw-r--r--src/mess/drivers/thomson.c2
-rw-r--r--src/mess/drivers/ti74.c32
-rw-r--r--src/mess/drivers/timex.c14
-rw-r--r--src/mess/drivers/tsispch.c6
-rw-r--r--src/mess/drivers/tutor.c6
-rw-r--r--src/mess/drivers/tvc.c12
-rw-r--r--src/mess/drivers/uzebox.c2
-rw-r--r--src/mess/drivers/vboy.c4
-rw-r--r--src/mess/drivers/vc4000.c30
-rw-r--r--src/mess/drivers/vii.c30
-rw-r--r--src/mess/drivers/x07.c6
-rw-r--r--src/mess/includes/apple2.h4
-rw-r--r--src/mess/includes/atom.h10
-rw-r--r--src/mess/includes/concept.h2
-rw-r--r--src/mess/includes/electron.h4
-rw-r--r--src/mess/includes/intv.h4
-rw-r--r--src/mess/includes/radio86.h2
-rw-r--r--src/mess/includes/svi318.h18
-rw-r--r--src/mess/machine/aim65.c2
-rw-r--r--src/mess/machine/amigakbd.c28
-rw-r--r--src/mess/machine/amstrad.c12
-rw-r--r--src/mess/machine/apple2.c8
-rw-r--r--src/mess/machine/apple3.c1
-rw-r--r--src/mess/machine/bbc.c26
-rw-r--r--src/mess/machine/concept.c8
-rw-r--r--src/mess/machine/electron.c10
-rw-r--r--src/mess/machine/gamecom.c8
-rw-r--r--src/mess/machine/gamepock.c2
-rw-r--r--src/mess/machine/intv.c8
-rw-r--r--src/mess/machine/lynx.c17
-rw-r--r--src/mess/machine/nc.c11
-rw-r--r--src/mess/machine/nes.c2
-rw-r--r--src/mess/machine/primo.c2
-rw-r--r--src/mess/machine/svi318.c16
-rw-r--r--src/mess/machine/thomson.c8
-rw-r--r--src/mess/machine/vtech2.c12
-rw-r--r--src/mess/machine/wswan.c38
-rw-r--r--src/mess/mess.mak16
-rw-r--r--src/mess/tiny.lst2
-rw-r--r--src/mess/tools/imgtool/modules/amiga.c6
-rw-r--r--src/mess/video/advision.c2
-rw-r--r--src/mess/video/apple2.c14
-rw-r--r--src/mess/video/apple3.c2
-rw-r--r--src/mess/video/maria.c28
-rw-r--r--src/mess/video/maria.h10
-rw-r--r--src/mess/video/nes.c4
-rw-r--r--src/mess/video/thomson.c44
-rw-r--r--src/osd/sdl/osdsdl.h2
-rw-r--r--src/osd/sdl/sdlfile.c2
-rw-r--r--src/osd/sdl/sdlptty_win32.c1
-rw-r--r--src/osd/sdl/sdlsocket.c2
-rw-r--r--src/osd/sdl/sdlsync_win32.c2
-rw-r--r--src/osd/sdl/video.c2
-rw-r--r--src/osd/windows/vconv.c2
-rw-r--r--src/osd/windows/video.c10
-rw-r--r--src/osd/windows/video.h6
-rw-r--r--src/osd/windows/window.c12
-rw-r--r--src/osd/windows/window.h4
-rw-r--r--src/osd/windows/winos.c2
-rw-r--r--src/osd/windows/winos.h2
-rw-r--r--src/osd/windows/winsync.c2
-rw-r--r--src/osd/windows/winsync.h2
-rw-r--r--src/version.c2
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.
</software>
<!--
-The code has some race conditions for NMIs (related to input readings)
-and often fails to boot on real systems too. To successfully start the
+The code has some race conditions for NMIs (related to input readings)
+and often fails to boot on real systems too. To successfully start the
game, you can keep pressed Button 1 during Atari logo (thanks to Mike
Saarna for debugging the problem)
-->
@@ -2369,7 +2369,7 @@ almost nothing like the prototype.
<!-- This version features a lot *LESS* sounds than the newer version:
e.g. no sound in bobsled ans ski jump games!
- Dump is confirmed from multiple carts, and it was probably used in
+ Dump is confirmed from multiple carts, and it was probably used in
some erlier production run, until they found out the mistake and
replaced it with the complete version -->
<software name="wingameso" cloneof="wingames">
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 @@
</dataarea>
</part>
</software>
-
+
<!-- A3000 Installation disks -->
-
+
<software name="a3kin203">
<description>A3000 Install Disk 2.03</description>
<year>1991</year>
@@ -44,11 +44,11 @@
<rom name="335603-04_install.adf" size="901120" crc="9a3cc466" sha1="b12a225890a3957bb01dcbfba44c046c19e19c8f" offset="0"/>
</dataarea>
</part>
- </software>
+ </software>
<!-- Amiga UNIX System V Release 4 -->
<!-- TODO: Part numbers -->
-
+
<software name="amix11">
<description>UNIX System V Release 4 Amiga Version 1.1</description>
<year>1990</year>
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 @@
<dataarea name="flop" size="901120">
<rom name="370132_a570_utilities.adf" size="901120" crc="30097474" sha1="958b97674e3e99fb9b0e3117009f27d4e7a9220b" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a590">
@@ -25,7 +25,7 @@
<dataarea name="flop" size="901120">
<rom name="317734-01_a590_scsi.adf" size="901120" crc="a560a938" sha1="9c6136c6580779a948cd1c0b50cb229512af415c" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a590_wd" cloneof="a590">
@@ -40,7 +40,7 @@
<dataarea name="flop" size="901120">
<rom name="317734-03_a590_wd.adf" size="901120" crc="a88fda41" sha1="7424f8645e1903e3e4ec8bb824186868319be1f3" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a590_seagate" cloneof="a590">
@@ -52,7 +52,7 @@
<dataarea name="flop" size="901120">
<rom name="317734-04_a590_seagate.adf" size="901120" status="nodump" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a590_ram">
@@ -64,7 +64,7 @@
<dataarea name="flop" size="901120">
<rom name="317830-01_a590_ram_test.adf" size="901120" crc="6583d1d0" sha1="7779b825b8555956d341ff7e909ab71d89e2321c" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2024">
@@ -76,7 +76,7 @@
<dataarea name="flop" size="901120">
<rom name="317809-01_a2024_jumpstart.adf" size="901120" crc="dad46588" sha1="30c2c1f1d98bd008b2c67f3b23480181935d4b01" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2091">
@@ -90,7 +90,7 @@
<dataarea name="flop" size="901120">
<rom name="317806-04_a2091_setup.adf" size="901120" crc="122c8f93" sha1="603e106c1a44a209171610af8d48bc35ad31c9bc" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2058">
@@ -102,7 +102,7 @@
<dataarea name="flop" size="901120">
<rom name="317719-01_a2058_ram_test.adf" size="901120" crc="5dba7fc3" sha1="76fbce4bef7df0f6042c85376d9bdfd4d4911e74" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2232">
@@ -114,7 +114,7 @@
<dataarea name="flop" size="901120">
<rom name="317769-01_a2232_install.adf" size="901120" crc="3caa21b7" sha1="24f47f6f88712f046303b8812a598043440a5e6d" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2300">
@@ -126,7 +126,7 @@
<dataarea name="flop" size="901120">
<rom name="317718-02_a2300_genlock_demo.adf" size="901120" crc="464ff0f6" sha1="26b94e8d52d35e2746b74610bb9b65eb2f899297" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
<software name="a2320">
@@ -138,7 +138,7 @@
<dataarea name="flop" size="901120">
<rom name="317210-01_a2320_test_demo.adf" size="901120" crc="cff98aae" sha1="f46f7de0d908ed68abfd784d84b964cbce7dc503" offset="0"/>
</dataarea>
- </part>
+ </part>
</software>
</softwarelist>
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 @@
<software name="choplift">
<!-- Choplifter (1984)(Coleco)[a].bin -->
- <!-- Other available dump has corrupted gfx -->
+ <!-- Other available dump has corrupted gfx -->
<description>Choplifter!</description>
<year>1984</year>
<publisher>Coleco / CBS</publisher>
@@ -699,7 +699,7 @@
<part name="cart" interface="coleco_cart">
<dataarea name="rom" size="16384">
<rom name="apshai.1" size="8192" crc="aa3ec181" sha1="7f79628c298ad6e410af82eeb33871869ad23de8" offset="0x0000" />
- <!-- 2nd 8K chunk containes two copies of the same 4K data -->
+ <!-- 2nd 8K chunk containes two copies of the same 4K data -->
<rom name="apshai.2" size="8192" crc="0e440f8f" sha1="09ffaeb79cdd8173882b77a8398a4e00ba826de1" offset="0x2000" />
</dataarea>
</part>
@@ -2262,7 +2262,7 @@
<dataarea name="rom" size="24576">
<rom name="subroc.1" size="8192" crc="ff56b769" sha1="612a0abd13c4c7790890cbcb265a7fd786c7ec5c" offset="0x0000" />
<rom name="subroc.2" size="8192" crc="e9e60d4c" sha1="bfc94db65985b7a906099465a47d900f7a9a9106" offset="0x2000" />
- <!-- 3rd 8K chunk containes two copies of the same 4K data -->
+ <!-- 3rd 8K chunk containes two copies of the same 4K data -->
<rom name="subroc.3" size="8192" crc="abe18f08" sha1="6ebdc68397c7b20dceba12ff754f88c955d5f98a" offset="0x4000" />
</dataarea>
</part>
@@ -2369,9 +2369,9 @@
</software>
<software name="zaxxont" cloneof="zaxxon">
- <!-- The Taiwan Cooper cart contains a 32K ROM, the last 8K of which was found to
- contain 0x4000-0x4fff from Super Action Baseball followed by 0x1000-0x1fff
- from Meteoric Shower! -->
+ <!-- The Taiwan Cooper cart contains a 32K ROM, the last 8K of which was found to
+ contain 0x4000-0x4fff from Super Action Baseball followed by 0x1000-0x1fff
+ from Meteoric Shower! -->
<description>Zaxxon (Taiwan Cooper)</description>
<year>198?</year>
<publisher>Taiwan Cooper</publisher>
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:
</dataarea>
</part>
</software>
-
+
<software name="mdos7_09">
<description>M-DOS7 Volume 9</description>
<year>19??</year>
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 @@
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
<softwarelist name="fmtowns" description="FM Towns CD-ROMs">
<!-- skeleton test list -->
-
- <!-- works well on fmtmarty, keyboard seems to interfere with movements on fmtowns -->
+
+ <!-- works well on fmtmarty, keyboard seems to interfere with movements on fmtowns -->
<software name="raiden">
<description>Raiden Densetsu / Raiden Trad</description>
<year>1991</year>
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
</software>
<!-- some disassembling performed by Paul Baker suggests that this version is a prototype
-e.g. the mapper control register at $fffc gets set to $80, you cannot switch characters
-on the pause screen, some messages are not displayed ("Sorry boys, no tickets, no show!"
-to explain why it is not possible to progress beyond a certain point in the game without
+e.g. the mapper control register at $fffc gets set to $80, you cannot switch characters
+on the pause screen, some messages are not displayed ("Sorry boys, no tickets, no show!"
+to explain why it is not possible to progress beyond a certain point in the game without
a certain item) -->
<software name="beavisp" cloneof="beavis">
<description>Beavis and Butt-head (Prototype?)</description>
@@ -7285,7 +7285,7 @@ a certain item) -->
</software>
<software name="soniclab">
- <!-- A final pre-release version of this same dump was found on a proto board with 4x128K sockets and no labels -->
+ <!-- A final pre-release version of this same dump was found on a proto board with 4x128K sockets and no labels -->
<description>Sonic Labyrinth (World)</description>
<year>1995</year>
<publisher>Sega</publisher>
@@ -7594,7 +7594,7 @@ a certain item) -->
</software>
<software name="sonic2d" cloneof="sonic2">
- <!-- This predates the final release and contains some different tiles & sprites compared to the final game -->
+ <!-- This predates the final release and contains some different tiles & sprites compared to the final game -->
<description>Sonic The Hedgehog 2 (Rolling Demo)</description>
<year>1992</year>
<publisher>Sega</publisher>
@@ -7609,7 +7609,7 @@ a certain item) -->
<feature name="batt" value="" />
<feature name="sw" value="ON = 1M / OFF = 256" />
<dataarea name="rom" size="262144">
- <!-- The ROM should be split in two halves -->
+ <!-- The ROM should be split in two halves -->
<rom name="sonic_2_auto_demo_prototype_(1991-12-05)_tmr_sega_cb06_ffff.bin" size="262144" crc="15ad37a5" sha1="b780c6f059b48d1bb48ee2ad521552dab1487c88" offset="000000" />
</dataarea>
</part>
@@ -8634,7 +8634,7 @@ a certain item) -->
</software>
<software name="tailsadv">
- <!-- A final pre-release version of this same dump was found on a proto board with 4x128K sockets and no labels -->
+ <!-- A final pre-release version of this same dump was found on a proto board with 4x128K sockets and no labels -->
<description>Tails Adventures (World)</description>
<year>1995</year>
<publisher>Sega</publisher>
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 @@
<!-- dumps are not yet verified as good, the 3-in-1 internal ROM is not yet dumped -->
<softwarelist name="gameking" description="TimeTop GameKing cartridges">
-
+
<software name="2004">
<description>2004</description>
<year>200?</year>
@@ -25,7 +25,7 @@
<rom name="adventure legend carlo.bin" size="0x20000" crc="7d61d215" sha1="741684b5379d4be732a98beace5d09f37ff19bbf" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="aries">
<description>Aries</description>
@@ -36,7 +36,7 @@
<rom name="aries.bin" size="0x20000" crc="b854f1f2" sha1="1ad7a325aba2cf3593165b53e7ae3973388335f7" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="dinoadv">
<description>Dino Adventure Legend</description>
@@ -47,7 +47,7 @@
<rom name="dino adventure legend.bin" size="0x20000" crc="2df0c1e6" sha1="df4b5dc80a758d9e3c9b00384e3099ad8331faad" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="duckman">
<description>Duck Man</description>
@@ -58,7 +58,7 @@
<rom name="duck man.bin" size="0x20000" crc="9d12950a" sha1="376606097f66105d1a9e97e9793362f6f1e3b1a7" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="happybal">
<description>Happy Ball</description>
@@ -69,7 +69,7 @@
<rom name="happy ball.bin" size="0x20000" crc="79d4e738" sha1="fc14712260ed6e3d6313055046546d37b7c838d2" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="happykil">
<description>Happy Killer</description>
@@ -80,7 +80,7 @@
<rom name="happy killer.bin" size="0x20000" crc="9fd7ec65" sha1="705309829ee87689793c15be1f781d52471908d6" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="lanner">
<description>Lanneret</description>
@@ -91,7 +91,7 @@
<rom name="lanneret.bin" size="0x20000" crc="249df6a5" sha1="bcf92ab85cc97ffe94d6a363a87b0b5de62c3c66" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="penguin">
<description>Penguin</description>
@@ -102,8 +102,8 @@
<rom name="penguin.bin" size="0x20000" crc="8c7b81c9" sha1="2f253b6ab6f6b9fc114ffca120d13df2e1e5f860" offset="0x00000" />
</dataarea>
</part>
- </software>
-
+ </software>
+
<software name="popper">
<description>Popper</description>
<year>200?</year>
@@ -113,7 +113,7 @@
<rom name="popper.bin" size="0x20000" crc="a704617b" sha1="314931548578303e5e80a2bcb03c92472cb014d9" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="sthero">
<description>Street Hero</description>
@@ -124,8 +124,8 @@
<rom name="street hero.bin" size="0x20000" crc="9e0fe489" sha1="2c442126999e4b112a48e42a82dfa9ad9d6efa22" offset="0x00000" />
</dataarea>
</part>
- </software>
-
+ </software>
+
<software name="smotor">
<description>Supermotor</description>
<year>200?</year>
@@ -135,7 +135,7 @@
<rom name="supermotor.bin" size="0x20000" crc="6290b94b" sha1="0c3011da35170241637907bb23d79355db38f343" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
<software name="trojanl">
<description>Trojan Legend</description>
@@ -146,8 +146,8 @@
<rom name="trojan legend.bin" size="0x20000" crc="7ce3975e" sha1="e925e4f28efc85ce69fb504b85a98a60883aa30d" offset="0x00000" />
</dataarea>
</part>
- </software>
+ </software>
+
-
</softwarelist>
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 @@
<dataarea name="D000" size="0x4000">
<rom name="world series major league baseball.d0" size="0x4000" crc="839fa5c7" sha1="1ef12665079d1ce50bd2419b668344a08c9a872f" offset="0x0000"/>
</dataarea>
- <!-- two ROM pages -->
+ <!-- two ROM pages -->
<dataarea name="F000" size="0x4000">
<rom name="world series major league baseball (page 0).f0" size="0x2000" crc="a0f2fe49" sha1="fab397b49c5a7db53a501caea42fce169da5a31a" offset="0x0000"/>
<rom name="world series major league baseball (page 1).f0" size="0x2000" crc="94d6b056" sha1="df2a8c950dd1c398db901a624c04322d2b4f2782" offset="0x2000"/>
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...
<feature name="mapper" value="NOMAPPER" />
<dataarea name="rom" size="131072">
<!--
- 20140725:
- There are 3 versions of this rom floating around:
- 930eae7057af1652abae794072b296a59decd61b - a "dirty" dump; it seems to be a direct memory copy made on an MSX and contains RAM contents at 3000-3FFF and 7000-7FFF
- a45692849acf29ddb653707a62747985439f6d4f - RAM areas are set to FFs
- 36d47cf70618fdb460f97a8ceb75013ec4529063 - A dump made using an eeprom reader. This dump differs one bit with the dump above (offset 8a49, bit 3)
- By looking the code it is not yet possible to say which one is 100% correct, so marking it as baddump for the moment.
+ 20140725:
+ There are 3 versions of this rom floating around:
+ 930eae7057af1652abae794072b296a59decd61b - a "dirty" dump; it seems to be a direct memory copy made on an MSX and contains RAM contents at 3000-3FFF and 7000-7FFF
+ a45692849acf29ddb653707a62747985439f6d4f - RAM areas are set to FFs
+ 36d47cf70618fdb460f97a8ceb75013ec4529063 - A dump made using an eeprom reader. This dump differs one bit with the dump above (offset 8a49, bit 3)
+ By looking the code it is not yet possible to say which one is 100% correct, so marking it as baddump for the moment.
-->
<rom name="msx audio (japan) (fs-ca1) (program).rom" size="131072" crc="78584d2e" sha1="a45692849acf29ddb653707a62747985439f6d4f" status="baddump" offset="0" />
</dataarea>
@@ -17109,8 +17109,8 @@ legacy FM implementations cannot find it.
</part>
<!-- The package came with a copy of MSX-DOS -->
<!--
- <part name="flop1" interface="floppy_3_5">
- </part>
+ <part name="flop1" interface="floppy_3_5">
+ </part>
-->
</software>
@@ -17126,9 +17126,9 @@ legacy FM implementations cannot find it.
</dataarea>
</part>
<!--
- The floppy drive was most likely bundled with a copy of MSX-DOS, but we are not 100% sure yet
- <part name="flop1" interface="floppy_3_5">
- </part>
+ The floppy drive was most likely bundled with a copy of MSX-DOS, but we are not 100% sure yet
+ <part name="flop1" interface="floppy_3_5">
+ </part>
-->
</software>
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 @@
<feature name="pcb_model" value="NR8OV2-1" />
<feature name="u1" value="U1 PRG" />
<feature name="u2" value="U2 CHR" />
- <feature name="u3" value="CME-01" /> <!-- CIC clone? -->
+ <feature name="u3" value="CME-01" /> <!-- CIC clone? -->
<feature name="mirroring" value="vertical" />
<dataarea name="prg" size="262144">
<rom name="sup.adv.quest.u1" size="262144" crc="6a7bf037" sha1="22b430d7d4167f16751facd3515f7c8e1133a3d9" offset="00000" />
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 @@
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
<softwarelist name="pencil2" description="Hanimex Pencil II cartridges">
-<!--
+<!--
Undumped known carts
@@ -16,7 +16,7 @@ Zaxxon
-->
-<!--
+<!--
BASIC CART PEN-700 11-50332-31 Rev.0
SD-BASIC VERSION 2.0 FOR PENCIL II
diff --git a/hash/psx.xml b/hash/psx.xml
index f87627969ab..c58f7e2b157 100644
--- a/hash/psx.xml
+++ b/hash/psx.xml
@@ -704,9 +704,9 @@ A few comments on these:
</part>
</software>
- <!-- Redump.org sets -->
-
- <software name="raidendx" supported="yes"> <!-- Hamster re-release) -->
+ <!-- Redump.org sets -->
+
+ <software name="raidendx" supported="yes"> <!-- Hamster re-release) -->
<description>Raiden DX (Japan, V1.1)</description>
<year>199?</year>
<publisher>Seibu / Hamster</publisher>
@@ -717,8 +717,8 @@ A few comments on these:
</diskarea>
</part>
</software>
-
- <software name="raidendxo" cloneof="raidendx" supported="yes"> <!-- original release) -->
+
+ <software name="raidendxo" cloneof="raidendx" supported="yes"> <!-- original release) -->
<description>Raiden DX (Japan, V1.0)</description>
<year>199?</year>
<publisher>Seibu</publisher>
@@ -729,7 +729,7 @@ A few comments on these:
</diskarea>
</part>
</software>
-
+
<software name="raidenpr" supported="yes">
<description>Raiden Project (USA)</description>
<year>199?</year>
@@ -740,9 +740,9 @@ A few comments on these:
<disk name="raiden project, the (usa)" sha1="cb1e4fae25d42e70fcb3eec5e1c1afcbdc5c2af3"/>
</diskarea>
</part>
- </software>
-
- <!-- this image doesn't boot, some kind of copy protection? could be bad -->
+ </software>
+
+ <!-- this image doesn't boot, some kind of copy protection? could be bad -->
<software name="raidenprj" cloneof="raidenpr" supported="no">
<description>Raiden Project (Japan)</description>
<year>1995</year>
@@ -753,8 +753,8 @@ A few comments on these:
<disk name="raiden project (japan)" sha1="12ec8ee3117df1f95752dc65155a611f43725251"/>
</diskarea>
</part>
- </software>
-
+ </software>
+
<!-- Images below are 'low-grade' ie not dumped to any specific standard, or verified to be of any specific quality, they could have bad gaps or audio tracks etc. -->
<!-- They should be replaced with better quality images once said images are available (and verified to be the same versions) -->
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 @@
</part>
</software>
- <!-- TODO: add support for RAM in this cart (0xa000-0xffff) -->
+ <!-- TODO: add support for RAM in this cart (0xa000-0xffff) -->
<software name="rwp32" supported="no">
<description>rWP32</description>
<year>19??</year>
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<a2bus_corvfdc01_device>;
-#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<a2bus_corvfdc02_device>;
-#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<a2bus_mouse_device>;
-#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<a2bus_timemasterho_device>;
-#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<pokey_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<pokey_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<pokey_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<pokey_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<pokey_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<pokey_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<pokey_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<ym2151_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<generic_slot_device>(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<generic_slot_device &>(device).m_device_image_load = callback; }
static void static_set_device_unload(device_t &device, device_image_func_delegate callback) { downcast<generic_slot_device &>(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<ay8914_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<sp0256_device> m_speech;
required_device<intv_cart_slot_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;x<cursor_size;x++)
{
UINT32 bitb = (vga.memory[(src+3) % vga.svga_intf.vram_size]
- | ((vga.memory[(src+2) % vga.svga_intf.vram_size]) << 8)
- | ((vga.memory[(src+1) % vga.svga_intf.vram_size]) << 16)
- | ((vga.memory[(src+0) % vga.svga_intf.vram_size]) << 24));
+ | ((vga.memory[(src+2) % vga.svga_intf.vram_size]) << 8)
+ | ((vga.memory[(src+1) % vga.svga_intf.vram_size]) << 16)
+ | ((vga.memory[(src+0) % vga.svga_intf.vram_size]) << 24));
UINT32 bita = (vga.memory[(src+7) % vga.svga_intf.vram_size]
| ((vga.memory[(src+6) % vga.svga_intf.vram_size]) << 8)
| ((vga.memory[(src+5) % vga.svga_intf.vram_size]) << 16)
@@ -1131,60 +1131,60 @@ UINT8 trident_vga_device::old_mmio_r(address_space& space, UINT32 offset)
/*
Graphics Engine for 9440/9660/9680
-#define GER_STATUS 0x2120
-#define GE_BUSY 0x80
-#define GER_OPERMODE 0x2122 Byte for 9440, Word for 96xx
-#define DST_ENABLE 0x200 // Destination Transparency
-#define GER_COMMAND 0x2124
-#define GE_NOP 0x00 // No Operation
-#define GE_BLT 0x01 // BitBLT ROP3 only
-#define GE_BLT_ROP4 0x02 // BitBLT ROP4 (96xx only)
-#define GE_SCANLINE 0x03 // Scan Line
-#define GE_BRESLINE 0x04 // Bresenham Line
-#define GE_SHVECTOR 0x05 // Short Vector
-#define GE_FASTLINE 0x06 // Fast Line (96xx only)
-#define GE_TRAPEZ 0x07 // Trapezoidal fill (96xx only)
-#define GE_ELLIPSE 0x08 // Ellipse (96xx only) (RES)
-#define GE_ELLIP_FILL 0x09 // Ellipse Fill (96xx only) (RES)
-#define GER_FMIX 0x2127
-#define GER_DRAWFLAG 0x2128 // long
-#define FASTMODE 1<<28
-#define STENCIL 0x8000
-#define SOLIDFILL 0x4000
-#define TRANS_ENABLE 0x1000
-#define TRANS_REVERSE 0x2000
-#define YMAJ 0x0400
-#define XNEG 0x0200
-#define YNEG 0x0100
-#define SRCMONO 0x0040
-#define PATMONO 0x0020
-#define SCR2SCR 0x0004
-#define PAT2SCR 0x0002
-#define GER_FCOLOUR 0x212C // Word for 9440, long for 96xx
-#define GER_BCOLOUR 0x2130 // Word for 9440, long for 96xx
-#define GER_PATLOC 0x2134 // Word
-#define GER_DEST_XY 0x2138
-#define GER_DEST_X 0x2138 // Word
-#define GER_DEST_Y 0x213A // Word
-#define GER_SRC_XY 0x213C
-#define GER_SRC_X 0x213C // Word
-#define GER_SRC_Y 0x213E // Word
-#define GER_DIM_XY 0x2140
-#define GER_DIM_X 0x2140 // Word
-#define GER_DIM_Y 0x2142 // Word
-#define GER_STYLE 0x2144 // Long
-#define GER_CKEY 0x2168 // Long
-#define GER_FPATCOL 0x2178
-#define GER_BPATCOL 0x217C
-#define GER_PATTERN 0x2180 // from 0x2180 to 0x21FF
+#define GER_STATUS 0x2120
+#define GE_BUSY 0x80
+#define GER_OPERMODE 0x2122 Byte for 9440, Word for 96xx
+#define DST_ENABLE 0x200 // Destination Transparency
+#define GER_COMMAND 0x2124
+#define GE_NOP 0x00 // No Operation
+#define GE_BLT 0x01 // BitBLT ROP3 only
+#define GE_BLT_ROP4 0x02 // BitBLT ROP4 (96xx only)
+#define GE_SCANLINE 0x03 // Scan Line
+#define GE_BRESLINE 0x04 // Bresenham Line
+#define GE_SHVECTOR 0x05 // Short Vector
+#define GE_FASTLINE 0x06 // Fast Line (96xx only)
+#define GE_TRAPEZ 0x07 // Trapezoidal fill (96xx only)
+#define GE_ELLIPSE 0x08 // Ellipse (96xx only) (RES)
+#define GE_ELLIP_FILL 0x09 // Ellipse Fill (96xx only) (RES)
+#define GER_FMIX 0x2127
+#define GER_DRAWFLAG 0x2128 // long
+#define FASTMODE 1<<28
+#define STENCIL 0x8000
+#define SOLIDFILL 0x4000
+#define TRANS_ENABLE 0x1000
+#define TRANS_REVERSE 0x2000
+#define YMAJ 0x0400
+#define XNEG 0x0200
+#define YNEG 0x0100
+#define SRCMONO 0x0040
+#define PATMONO 0x0020
+#define SCR2SCR 0x0004
+#define PAT2SCR 0x0002
+#define GER_FCOLOUR 0x212C // Word for 9440, long for 96xx
+#define GER_BCOLOUR 0x2130 // Word for 9440, long for 96xx
+#define GER_PATLOC 0x2134 // Word
+#define GER_DEST_XY 0x2138
+#define GER_DEST_X 0x2138 // Word
+#define GER_DEST_Y 0x213A // Word
+#define GER_SRC_XY 0x213C
+#define GER_SRC_X 0x213C // Word
+#define GER_SRC_Y 0x213E // Word
+#define GER_DIM_XY 0x2140
+#define GER_DIM_X 0x2140 // Word
+#define GER_DIM_Y 0x2142 // Word
+#define GER_STYLE 0x2144 // Long
+#define GER_CKEY 0x2168 // Long
+#define GER_FPATCOL 0x2178
+#define GER_BPATCOL 0x217C
+#define GER_PATTERN 0x2180 // from 0x2180 to 0x21FF
Additional - Graphics Engine for 96xx
-#define GER_SRCCLIP_XY 0x2148
-#define GER_SRCCLIP_X 0x2148 // Word
-#define GER_SRCCLIP_Y 0x214A // Word
-#define GER_DSTCLIP_XY 0x214C
-#define GER_DSTCLIP_X 0x214C // Word
-#define GER_DSTCLIP_Y 0x214E // Word
+#define GER_SRCCLIP_XY 0x2148
+#define GER_SRCCLIP_X 0x2148 // Word
+#define GER_SRCCLIP_Y 0x214A // Word
+#define GER_DSTCLIP_XY 0x214C
+#define GER_DSTCLIP_X 0x214C // Word
+#define GER_DSTCLIP_Y 0x214E // Word
*/
READ8_MEMBER(trident_vga_device::accel_r)
diff --git a/src/emu/bus/megadrive/ggenie.c b/src/emu/bus/megadrive/ggenie.c
index 1f1dc8ceab1..62ebfbb55aa 100644
--- a/src/emu/bus/megadrive/ggenie.c
+++ b/src/emu/bus/megadrive/ggenie.c
@@ -5,17 +5,17 @@
based on Charles MacDonald's docs: http://cgfm2.emuviews.com/txt/genie.txt
-
+
There is an interesting difference between Rev.0 and Rev.A
- After the codes has been entered, the former just performs
- a last write to the MODE register (m_gg_regs[0]) which both
- sets the enable bits for the 6 available cheats (in the low
- 8 bits) and locks the GG so that later reads goes to the
+ After the codes has been entered, the former just performs
+ a last write to the MODE register (m_gg_regs[0]) which both
+ sets the enable bits for the 6 available cheats (in the low
+ 8 bits) and locks the GG so that later reads goes to the
piggyback cart. The latter revision, instead, performs the
- same operations in two subsequent 8bit writes, accessing
+ same operations in two subsequent 8bit writes, accessing
separately the low and high bits of the register.
-
+
***********************************************************************************************************/
#include "emu.h"
@@ -86,7 +86,7 @@ READ16_MEMBER(md_rom_ggenie_device::read)
return m_gg_data[5];
else
return m_exp->m_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<cpu_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<cpu_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<sms_graphic_device>;
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<dpc_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<cassette_image_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<dsp56k_device>;
* 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<class _Object> static devcb_base &set_kb_read_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_kb_read_cb.set_callback(object); }
template<class _Object> static devcb_base &set_port_write_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_port_write_cb.set_callback(object); }
template<class _Object> static devcb_base &set_port_read_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(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<tms32051_device>;
**************************************************************************/
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<void (screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params)> 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<void (screen_device &screen, bitmap_rgb32 &bitmap, int scanline, const tms34010_display_params *params)> 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<void (screen_device &screen, bitmap_rgb32 &bitmap, int s
typedef device_delegate<void (address_space &space, offs_t address, UINT16 *shiftreg)> 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<void (address_space &space, offs_t address, UINT16 *shiftreg)> 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<floppy_image_device *>(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<void ()> 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<INT16> 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<speaker_sound_device &>(device).m_num_levels = num_levels; downcast<speaker_sound_device &>(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", &sector_data[0x103], 6))
{
m_prodos_order = true;
- } // check for alternate version ProDOS boot block
+ } // check for alternate version ProDOS boot block
if (!memcmp("PRODOS", &sector_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, &sector_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, &sector_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<dmk_format>;
-
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 ? "<A" : ev == NS_CONNECT ? "C>" : "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 ? "<A" : ev == NS_CONNECT ? "C>" : "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, &current_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, &current_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,
- "<tr><td><a href=\"%s%s\">%s%s</a></td>"
- "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\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,
+ "<tr><td><a href=\"%s%s\">%s%s</a></td>"
+ "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\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 dir