| Previous | 199869 Revisions | Next |
| r37176 Tuesday 14th April, 2015 at 17:58:17 UTC by Olivier Galibert |
|---|
| Replace dynamic_array with std::vector [O. Galibert] |
| [src/emu] | clifront.c devfind.h digfx.c diimage.c disound.h drawgfx.c drawgfx.h drivenum.c drivenum.h emualloc.c emualloc.h emupal.c emupal.h fileio.c ioport.c ioport.h memarray.h memory.c memory.h render.c render.h rendfont.c rendfont.h rendlay.h romload.c save.h softlist.c softlist.h sound.c sound.h sprite.h tilemap.c tilemap.h |
| [src/emu/bus/a7800] | a78_slot.c a78_slot.h |
| [src/emu/bus/a800] | a800_slot.c a800_slot.h |
| [src/emu/bus/amiga/zorro] | a2052.c a2052.h a590.c |
| [src/emu/bus/apf] | slot.h |
| [src/emu/bus/astrocde] | ram.c |
| [src/emu/bus/chanf] | rom.c slot.h |
| [src/emu/bus/cpc] | symbfac2.c |
| [src/emu/bus/gameboy] | gb_slot.c gb_slot.h mbc.c rom.c |
| [src/emu/bus/gba] | gba_slot.c gba_slot.h rom.c |
| [src/emu/bus/generic] | ram.c rom.c slot.h |
| [src/emu/bus/intv] | ecs.c ecs.h rom.h slot.c slot.h |
| [src/emu/bus/isa] | 3c505.c 3c505.h cga.c gus.c hdc.c mda.c omti8621.c s3virge.c sc499.c sc499.h trident.c |
| [src/emu/bus/megadrive] | md_slot.c md_slot.h |
| [src/emu/bus/msx_cart] | cartridge.c cartridge.h konami.c |
| [src/emu/bus/msx_slot] | cartridge.c panasonic08.c ram.h ram_mm.c ram_mm.h |
| [src/emu/bus/neogeo] | bootleg_prot.c cmc_prot.c kof2002_prot.c kof98_prot.c kog_prot.c neogeo_helper.c neogeo_helper.h neogeo_intf.h neogeo_slot.h pcm2_prot.c pvc_prot.c |
| [src/emu/bus/nes] | aladdin.c bandai.c bootleg.c konami.c mmc1.c mmc3.c mmc3_clones.c mmc5.c namcot.c nes_ines.inc nes_pcb.inc nes_slot.c nes_slot.h nes_unif.inc pirate.c sunsoft.c sunsoft_dcs.c |
| [src/emu/bus/nubus] | nubus.c nubus_48gc.c nubus_cb264.c nubus_m2hires.c nubus_m2video.c nubus_radiustpd.c nubus_spec8.c nubus_specpdq.c nubus_vikbw.c nubus_wsportrait.c pds30_30hr.c pds30_cb264.c pds30_mc30.c pds30_procolor816.c pds30_sigmalview.c |
| [src/emu/bus/odyssey2] | slot.h |
| [src/emu/bus/pce] | pce_rom.c pce_slot.c pce_slot.h |
| [src/emu/bus/saturn] | bram.c bram.h dram.c sat_slot.h |
| [src/emu/bus/scsi] | s1410.c |
| [src/emu/bus/scv] | slot.c slot.h |
| [src/emu/bus/sega8] | rom.c sega8_slot.c sega8_slot.h |
| [src/emu/bus/snes] | event.c event.h sa1.c snes_slot.c snes_slot.h upd.c upd.h |
| [src/emu/bus/ti99_peb] | tn_usbsm.h |
| [src/emu/bus/vboy] | slot.h |
| [src/emu/bus/vc4000] | rom.c slot.h |
| [src/emu/bus/vcs] | rom.c vcs_slot.c vcs_slot.h |
| [src/emu/bus/vectrex] | slot.c |
| [src/emu/bus/vidbrain] | exp.c |
| [src/emu/bus/vtech/memexp] | memory.c memory.h |
| [src/emu/bus/wswan] | rom.c slot.c slot.h |
| [src/emu/cpu] | drcfe.h drcuml.c drcuml.h vtlb.c |
| [src/emu/cpu/esrip] | esrip.h |
| [src/emu/cpu/mips] | r3000.c r3000.h |
| [src/emu/cpu/tms0980] | tms0980.c tms0980.h |
| [src/emu/debug] | debugcmd.c debugcpu.c debugcpu.h debugvw.h dvbpoints.c dvbpoints.h dvdisasm.c dvdisasm.h dvmemory.c dvstate.c dvtext.c dvwpoints.c dvwpoints.h |
| [src/emu/imagedev] | floppy.c floppy.h |
| [src/emu/machine] | 7200fifo.h at28c16.c at45dbxx.c at45dbxx.h atapihle.c dp8390.c eeprom.c i2cmem.c i82875p.h idehd.c intelfsh.c laserdsc.c laserdsc.h mc146818.c nscsi_s1410.c pci.c pci.h pla.h ram.c ram.h s2636.c serflash.c smc92x4.c stvcd.c timekpr.c vrc4373.h |
| [src/emu/sound] | ay8910.c discrete.c discrete.h samples.c samples.h spu.c wavwrite.c |
| [src/emu/ui] | selgame.h |
| [src/emu/video] | bufsprite.h pc_vga.c resnet.c resnet.h |
| [src/lib/formats] | ap2_dsk.c apridisk.c cassimg.c cassimg.h ccvf_dsk.c coco_dsk.c cqm_dsk.c csw_cas.c d64_dsk.c dfi_dsk.c dmk_dsk.c flopimg.c flopimg.h g64_dsk.c hxcmfm_dsk.c imd_dsk.c ipf_dsk.c ipf_dsk.h kc_cas.c mfi_dsk.c oric_dsk.c pasti_dsk.c pasti_dsk.h td0_dsk.c ti99_dsk.c upd765_dsk.c upd765_dsk.h victor9k_dsk.c wd177x_dsk.c wd177x_dsk.h z80ne_dsk.c |
| [src/lib/util] | avhuff.c avhuff.h chd.c chd.h chdcodec.c corefile.c coretmpl.h huffman.c palette.c palette.h |
| [src/mame/drivers] | 4enlinea.c 8080bw.c alg.c arkanoid.c astrafr.c backfire.c bfcobra.c bfm_sc45_helper.c blktiger.c cave.c coinmstr.c cps2.c crimfght.c darkmist.c dassault.c ddayjlc.c deco156.c deco32.c deco_mlc.c dynax.c exerion.c fcombat.c flyball.c forte2.c funworld.c gaiden.c galaxian.c galaxold.c gauntlet.c goldstar.c halleys.c hng64.c igs011.c igs017.c igs_m027.c igspoker.c jclub2.c kas89.c legionna.c megasys1.c meyc8088.c mitchell.c multfish.c multigam.c namcos86.c ninjakd2.c nmk16.c nova2001.c panicr.c pengadvb.c pirates.c popeye.c popobear.c r2dx_v33.c segag80r.c segas16b.c seta.c sigmab98.c simpl156.c snowbros.c speedbal.c tcl.c tmnt.c toki.c travrusa.c tumbleb.c vendetta.c wecleman.c wink.c |
| [src/mame/includes] | blockhl.h crimfght.h flstory.h hng64.h ladyfrog.h m92.h mitchell.h namcona1.h neogeo.h nycaptor.h segag80r.h speedspn.h spy.h stv.h vendetta.h |
| [src/mame/machine] | atarigen.c bfm_comn.c deco102.c deco156.c decocrpt.c fd1089.c fd1089.h fd1094.c fd1094.h jalcrpt.c kaneko_calc3.c neocrypt.c pgmprot_igs027a_type1.c pgmprot_igs027a_type3.c scramble.c segaic16.c segaic16.h segas32.c |
| [src/mame/video] | aeroboto.c atarimo.h atarirle.h atarisy1.c bfm_adr2.c c116.c c116.h carjmbre.c dkong.c gauntlet.c hng64_3d.c k051316.c k051316.h k053250.c k053250.h k054156_k054157_k056832.c k054156_k054157_k056832.h m62.c mario.c model1.c namcona1.c neogeo.c neogeo_spr.c neogeo_spr.h phoenix.c popeye.c popper.c skyfox.c speedspn.c tagteam.c tc0150rod.c tc0150rod.h tc0480scp.c tc0480scp.h tceptor.c wpc_dmd.c wpc_dmd.h |
| [src/mess/drivers] | abc80.c amiga.c beta.c binbug.c casloopy.c cd2650.c d6800.c homelab.c hp16500.c instruct.c lynx.c megadriv.c pcd.c pegasus.c pipbug.c psx.c ravens.c rex6000.c supracan.c ti99_4p.c timex.c uzebox.c vc4000.c vii.c x68k.c |
| [src/mess/includes] | imds2.h x68k.h |
| [src/mess/machine] | amstrad.c cbm_snqk.c cybiko.c kc.c lviv.c megacd.c megacd.h microtan.c msx_matsushita.c primo.c spec_snqk.c svi318.c ti85.c x68k_hdc.c |
| [src/mess/machine/ti99] | gromport.c |
| [src/mess/tools/imgtool] | iflopimg.c imghd.c main.c |
| [src/mess/tools/imgtool/modules] | os9.c psion.c |
| [src/mess/video] | advision.c wswan_video.c x68k.c |
| [src/osd/modules/lib] | osdobj_common.c osdobj_common.h |
| [src/osd/windows] | winmain.c |
| [src/tools] | chdman.c ldresample.c ldverify.c |
| r245687 | r245688 | |
|---|---|---|
| 539 | 539 | int type = A78_TYPE0, mapper; |
| 540 | 540 | |
| 541 | 541 | // Load and check the header |
| 542 | core_fread(m_file, head, 128); | |
| 542 | core_fread(m_file, &head[0], 128); | |
| 543 | 543 | |
| 544 | 544 | // let's try to auto-fix some common errors in the header |
| 545 | 545 | mapper = validate_header((head[53] << 8) | head[54], FALSE); |
| r245687 | r245688 | |
|---|---|---|
| 57 | 57 | void ram_alloc(UINT32 size); |
| 58 | 58 | void nvram_alloc(UINT32 size); |
| 59 | 59 | UINT8* get_rom_base() { return m_rom; } |
| 60 | UINT8* get_ram_base() { return m_ram; } | |
| 61 | UINT8* get_nvram_base() { return m_nvram; } | |
| 60 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 61 | UINT8* get_nvram_base() { return &m_nvram[0]; } | |
| 62 | 62 | UINT32 get_rom_size() { return m_rom_size; } |
| 63 | UINT32 get_ram_size() { return m_ram.bytes(); } | |
| 64 | UINT32 get_nvram_size() { return m_nvram.bytes(); } | |
| 63 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 64 | UINT32 get_nvram_size() { return m_nvram.size(); } | |
| 65 | 65 | |
| 66 | 66 | protected: |
| 67 | 67 | // internal state |
| r245687 | r245688 | |
|---|---|---|
| 420 | 420 | // check whether there is an header, to identify the cart type |
| 421 | 421 | if ((len % 0x1000) == 0x10) |
| 422 | 422 | { |
| 423 | core_fread(m_file, head, 0x10); | |
| 424 | type = identify_cart_type(head); | |
| 423 | core_fread(m_file, &head[0], 0x10); | |
| 424 | type = identify_cart_type(&head[0]); | |
| 425 | 425 | } |
| 426 | 426 | else // otherwise try to guess based on size |
| 427 | 427 | { |
| r245687 | r245688 | |
| 457 | 457 | // check whether there is an header, to identify the cart type |
| 458 | 458 | if ((len % 0x1000) == 0x10) |
| 459 | 459 | { |
| 460 | core_fread(m_file, head, 0x10); | |
| 461 | type = identify_cart_type(head); | |
| 460 | core_fread(m_file, &head[0], 0x10); | |
| 461 | type = identify_cart_type(&head[0]); | |
| 462 | 462 | |
| 463 | 463 | astring info; |
| 464 | 464 | if (hashfile_extrainfo(*this, info) && info == "A13MIRRORING") |
| r245687 | r245688 | |
| 490 | 490 | // check whether there is an header, to identify the cart type |
| 491 | 491 | if ((len % 0x1000) == 0x10) |
| 492 | 492 | { |
| 493 | core_fread(m_file, head, 0x10); | |
| 494 | type = identify_cart_type(head); | |
| 493 | core_fread(m_file, &head[0], 0x10); | |
| 494 | type = identify_cart_type(&head[0]); | |
| 495 | 495 | } |
| 496 | 496 | if (type != A800_XEGS) |
| 497 | 497 | { |
| r245687 | r245688 | |
|---|---|---|
| 60 | 60 | void ram_alloc(UINT32 size); |
| 61 | 61 | void nvram_alloc(UINT32 size); |
| 62 | 62 | UINT8* get_rom_base() { return m_rom; } |
| 63 | UINT8* get_ram_base() { return m_ram; } | |
| 64 | UINT8* get_nvram_base() { return m_nvram; } | |
| 63 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 64 | UINT8* get_nvram_base() { return &m_nvram[0]; } | |
| 65 | 65 | UINT32 get_rom_size() { return m_rom_size; } |
| 66 | UINT32 get_ram_size() { return m_ram.bytes(); } | |
| 67 | UINT32 get_nvram_size() { return m_nvram.bytes(); } | |
| 66 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 67 | UINT32 get_nvram_size() { return m_nvram.size(); } | |
| 68 | 68 | |
| 69 | 69 | protected: |
| 70 | 70 | // internal state |
| r245687 | r245688 | |
|---|---|---|
| 84 | 84 | m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f); |
| 85 | 85 | |
| 86 | 86 | // install access to the rom space |
| 87 | m_slot->m_space->install_ram(address, address + m_ram. | |
| 87 | m_slot->m_space->install_ram(address, address + m_ram.size()*2 - 1, &m_ram[0]); | |
| 88 | 88 | |
| 89 | 89 | // we're done |
| 90 | 90 | m_slot->cfgout_w(0); |
| r245687 | r245688 | |
|---|---|---|
| 43 | 43 | |
| 44 | 44 | private: |
| 45 | 45 | required_ioport m_config; |
| 46 | d | |
| 46 | std::vector<UINT16> m_ram; | |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | 49 | // device type definition |
| r245687 | r245688 | |
|---|---|---|
| 279 | 279 | break; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | m_dmac->set_ram(m_ram); | |
| 282 | m_dmac->set_ram(&m_ram[0]); | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | void a590_device::device_reset() |
| r245687 | r245688 | |
|---|---|---|
| 35 | 35 | void rom_alloc(UINT32 size, const char *tag); |
| 36 | 36 | void ram_alloc(UINT32 size); |
| 37 | 37 | UINT8* get_rom_base() { return m_rom; } |
| 38 | UINT8* get_ram_base() { return m_ram; } | |
| 38 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 39 | 39 | UINT32 get_rom_size() { return m_rom_size; } |
| 40 | UINT32 get_ram_size() { return m_ram. | |
| 40 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 41 | 41 | |
| 42 | 42 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 43 | 43 |
| r245687 | r245688 | |
|---|---|---|
| 153 | 153 | // Blue RAM expansions have RAM starting at 0x6000, up to the RAM size |
| 154 | 154 | READ8_MEMBER(astrocade_blueram_4k_device::read) |
| 155 | 155 | { |
| 156 | if (offset >= 0x1000 && offset < 0x1000 + m_ram. | |
| 156 | if (offset >= 0x1000 && offset < 0x1000 + m_ram.size()) | |
| 157 | 157 | return m_ram[offset - 0x1000]; |
| 158 | 158 | else |
| 159 | 159 | return 0; |
| r245687 | r245688 | |
| 161 | 161 | |
| 162 | 162 | WRITE8_MEMBER(astrocade_blueram_4k_device::write) |
| 163 | 163 | { |
| 164 | if (offset >= 0x1000 && offset < 0x1000 + m_ram. | |
| 164 | if (offset >= 0x1000 && offset < 0x1000 + m_ram.size() && !m_write_prot->read()) | |
| 165 | 165 | m_ram[offset - 0x1000] = data; |
| 166 | 166 | } |
| 167 | 167 |
| r245687 | r245688 | |
|---|---|---|
| 200 | 200 | // These are shared among Schach & Multigame cart types (not directly used by base chanf_rom_device) |
| 201 | 201 | UINT8 chanf_rom_device::common_read_3853(UINT32 offset) |
| 202 | 202 | { |
| 203 | if (offset < m_ram. | |
| 203 | if (offset < m_ram.size()) | |
| 204 | 204 | return m_ram[offset]; |
| 205 | 205 | else |
| 206 | 206 | return 0xff; |
| r245687 | r245688 | |
| 208 | 208 | |
| 209 | 209 | void chanf_rom_device::common_write_3853(UINT32 offset, UINT8 data) |
| 210 | 210 | { |
| 211 | if (offset < m_ram. | |
| 211 | if (offset < m_ram.size()) | |
| 212 | 212 | m_ram[offset] = data; |
| 213 | 213 | } |
| 214 | 214 |
| r245687 | r245688 | |
|---|---|---|
| 38 | 38 | void rom_alloc(UINT32 size, const char *tag); |
| 39 | 39 | void ram_alloc(UINT32 size); |
| 40 | 40 | UINT8* get_rom_base() { return m_rom; } |
| 41 | UINT8* get_ram_base() { return m_ram; } | |
| 41 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 42 | 42 | UINT32 get_rom_size() { return m_rom_size; } |
| 43 | UINT32 get_ram_size() { return m_ram. | |
| 43 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 44 | 44 | |
| 45 | 45 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 46 | 46 |
| r245687 | r245688 | |
|---|---|---|
| 102 | 102 | // 32 banks of 16kB (512kB) |
| 103 | 103 | m_rom_space.resize(32*16384); |
| 104 | 104 | |
| 105 | m_nvram->set_base(m_rom_space,m_rom_space. | |
| 105 | m_nvram->set_base(&m_rom_space[0],m_rom_space.size()); | |
| 106 | 106 | save_item(NAME(m_rom_space)); |
| 107 | 107 | |
| 108 | 108 | } |
| r245687 | r245688 | |
| 275 | 275 | m_4xxx_ptr_w = (UINT8*)machine().root_device().membank("bank11")->base(); |
| 276 | 276 | m_6xxx_ptr_r = (UINT8*)machine().root_device().membank("bank4")->base(); |
| 277 | 277 | m_6xxx_ptr_w = (UINT8*)machine().root_device().membank("bank12")->base(); |
| 278 | machine().root_device().membank("bank3")->set_base((UINT8*)m_rom_space+(bank*16384)); | |
| 279 | machine().root_device().membank("bank4")->set_base((UINT8*)m_rom_space+(bank*16384+8192)); | |
| 280 | machine().root_device().membank("bank11")->set_base((UINT8*)m_rom_space+(bank*16384)); | |
| 281 | machine().root_device().membank("bank12")->set_base((UINT8*)m_rom_space+(bank*16384+8192)); | |
| 278 | machine().root_device().membank("bank3")->set_base(&m_rom_space[bank*16384]); | |
| 279 | machine().root_device().membank("bank4")->set_base(&m_rom_space[bank*16384+8192]); | |
| 280 | machine().root_device().membank("bank11")->set_base(&m_rom_space[bank*16384]); | |
| 281 | machine().root_device().membank("bank12")->set_base(&m_rom_space[bank*16384+8192]); | |
| 282 | 282 | |
| 283 | 283 | return 0xff; |
| 284 | 284 | } |
| r245687 | r245688 | |
|---|---|---|
| 609 | 609 | dynamic_buffer rom(len); |
| 610 | 610 | int type; |
| 611 | 611 | |
| 612 | core_fread(m_file, rom, len); | |
| 612 | core_fread(m_file, &rom[0], len); | |
| 613 | 613 | |
| 614 | 614 | if ((len % 0x4000) == 512) |
| 615 | 615 | offset = 512; |
| 616 | 616 | |
| 617 | if (get_mmm01_candidate(rom | |
| 617 | if (get_mmm01_candidate(&rom[offset], len - offset)) | |
| 618 | 618 | offset += (len - 0x8000); |
| 619 | 619 | |
| 620 | type = get_cart_type(rom | |
| 620 | type = get_cart_type(&rom[offset], len - offset); | |
| 621 | 621 | slot_string = gb_get_slot(type); |
| 622 | 622 | |
| 623 | 623 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 62 | 62 | void rom_alloc(UINT32 size, const char *tag); |
| 63 | 63 | void ram_alloc(UINT32 size); |
| 64 | 64 | UINT8* get_rom_base() { return m_rom; } |
| 65 | UINT8* get_ram_base() { return m_ram; } | |
| 65 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 66 | 66 | UINT32 get_rom_size() { return m_rom_size; } |
| 67 | UINT32 get_ram_size() { return m_ram. | |
| 67 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 68 | 68 | |
| 69 | 69 | void rom_map_setup(UINT32 size); |
| 70 | 70 | void ram_map_setup(UINT8 banks); |
| r245687 | r245688 | |
|---|---|---|
| 291 | 291 | |
| 292 | 292 | READ8_MEMBER(gb_rom_mbc_device::read_ram) |
| 293 | 293 | { |
| 294 | if (m_ram) | |
| 294 | if (!m_ram.empty()) | |
| 295 | 295 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + offset]; |
| 296 | 296 | else |
| 297 | 297 | return 0xff; |
| r245687 | r245688 | |
| 299 | 299 | |
| 300 | 300 | WRITE8_MEMBER(gb_rom_mbc_device::write_ram) |
| 301 | 301 | { |
| 302 | if (m_ram) | |
| 302 | if (!m_ram.empty()) | |
| 303 | 303 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + offset] = data; |
| 304 | 304 | } |
| 305 | 305 | |
| r245687 | r245688 | |
| 342 | 342 | |
| 343 | 343 | READ8_MEMBER(gb_rom_mbc1_device::read_ram) |
| 344 | 344 | { |
| 345 | if (m_ram && m_ram_enable) | |
| 345 | if (!m_ram.empty() && m_ram_enable) | |
| 346 | 346 | { |
| 347 | 347 | int bank = (m_mode == MODE_4M_256k) ? m_ram_bank : 0; |
| 348 | 348 | return m_ram[ram_bank_map[bank] * 0x2000 + offset]; |
| r245687 | r245688 | |
| 353 | 353 | |
| 354 | 354 | WRITE8_MEMBER(gb_rom_mbc1_device::write_ram) |
| 355 | 355 | { |
| 356 | if (m_ram && m_ram_enable) | |
| 356 | if (!m_ram.empty() && m_ram_enable) | |
| 357 | 357 | { |
| 358 | 358 | int bank = (m_mode == MODE_4M_256k) ? m_ram_bank : 0; |
| 359 | 359 | m_ram[ram_bank_map[bank] * 0x2000 + offset] = data; |
| r245687 | r245688 | |
| 392 | 392 | // 1 bank only?? |
| 393 | 393 | READ8_MEMBER(gb_rom_mbc2_device::read_ram) |
| 394 | 394 | { |
| 395 | if (m_ram && m_ram_enable) | |
| 395 | if (!m_ram.empty() && m_ram_enable) | |
| 396 | 396 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 397 | 397 | else |
| 398 | 398 | return 0xff; |
| r245687 | r245688 | |
| 400 | 400 | |
| 401 | 401 | WRITE8_MEMBER(gb_rom_mbc2_device::write_ram) |
| 402 | 402 | { |
| 403 | if (m_ram && m_ram_enable) | |
| 403 | if (!m_ram.empty() && m_ram_enable) | |
| 404 | 404 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 405 | 405 | } |
| 406 | 406 | |
| r245687 | r245688 | |
| 451 | 451 | { |
| 452 | 452 | if (m_ram_bank < 4 && m_ram_enable) |
| 453 | 453 | { // RAM |
| 454 | if (m_ram) | |
| 454 | if (!m_ram.empty()) | |
| 455 | 455 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 456 | 456 | } |
| 457 | 457 | if (m_ram_bank >= 0x8 && m_ram_bank <= 0xc) |
| r245687 | r245688 | |
| 466 | 466 | { |
| 467 | 467 | if (m_ram_bank < 4 && m_ram_enable) |
| 468 | 468 | { // RAM |
| 469 | if (m_ram) | |
| 469 | if (!m_ram.empty()) | |
| 470 | 470 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 471 | 471 | } |
| 472 | 472 | if (m_ram_bank >= 0x8 && m_ram_bank <= 0xc) |
| r245687 | r245688 | |
| 515 | 515 | |
| 516 | 516 | READ8_MEMBER(gb_rom_mbc5_device::read_ram) |
| 517 | 517 | { |
| 518 | if (m_ram && m_ram_enable) | |
| 518 | if (!m_ram.empty() && m_ram_enable) | |
| 519 | 519 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 520 | 520 | else |
| 521 | 521 | return 0xff; |
| r245687 | r245688 | |
| 523 | 523 | |
| 524 | 524 | WRITE8_MEMBER(gb_rom_mbc5_device::write_ram) |
| 525 | 525 | { |
| 526 | if (m_ram && m_ram_enable) | |
| 526 | if (!m_ram.empty() && m_ram_enable) | |
| 527 | 527 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 528 | 528 | } |
| 529 | 529 | |
| r245687 | r245688 | |
| 563 | 563 | |
| 564 | 564 | READ8_MEMBER(gb_rom_mbc6_device::read_ram) |
| 565 | 565 | { |
| 566 | if (m_ram) | |
| 566 | if (!m_ram.empty()) | |
| 567 | 567 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 568 | 568 | else |
| 569 | 569 | return 0xff; |
| r245687 | r245688 | |
| 571 | 571 | |
| 572 | 572 | WRITE8_MEMBER(gb_rom_mbc6_device::write_ram) |
| 573 | 573 | { |
| 574 | if (m_ram) | |
| 574 | if (!m_ram.empty()) | |
| 575 | 575 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 576 | 576 | } |
| 577 | 577 | |
| r245687 | r245688 | |
| 620 | 620 | |
| 621 | 621 | READ8_MEMBER(gb_rom_mbc7_device::read_ram) |
| 622 | 622 | { |
| 623 | if (m_ram) | |
| 623 | if (!m_ram.empty()) | |
| 624 | 624 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 625 | 625 | else |
| 626 | 626 | return 0xff; |
| r245687 | r245688 | |
| 628 | 628 | |
| 629 | 629 | WRITE8_MEMBER(gb_rom_mbc7_device::write_ram) |
| 630 | 630 | { |
| 631 | if (m_ram) | |
| 631 | if (!m_ram.empty()) | |
| 632 | 632 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 633 | 633 | } |
| 634 | 634 | |
| r245687 | r245688 | |
| 910 | 910 | |
| 911 | 911 | READ8_MEMBER(gb_rom_sintax_device::read_ram) |
| 912 | 912 | { |
| 913 | if (m_ram && m_ram_enable) | |
| 913 | if (!m_ram.empty() && m_ram_enable) | |
| 914 | 914 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 915 | 915 | else |
| 916 | 916 | return 0xff; |
| r245687 | r245688 | |
| 918 | 918 | |
| 919 | 919 | WRITE8_MEMBER(gb_rom_sintax_device::write_ram) |
| 920 | 920 | { |
| 921 | if (m_ram && m_ram_enable) | |
| 921 | if (!m_ram.empty() && m_ram_enable) | |
| 922 | 922 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 923 | 923 | } |
| 924 | 924 | |
| r245687 | r245688 | |
| 977 | 977 | |
| 978 | 978 | READ8_MEMBER(gb_rom_digimon_device::read_ram) |
| 979 | 979 | { |
| 980 | if (m_ram && m_ram_enable) | |
| 980 | if (!m_ram.empty() && m_ram_enable) | |
| 981 | 981 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)]; |
| 982 | 982 | else |
| 983 | 983 | return 0xff; |
| r245687 | r245688 | |
| 985 | 985 | |
| 986 | 986 | WRITE8_MEMBER(gb_rom_digimon_device::write_ram) |
| 987 | 987 | { |
| 988 | if (m_ram && m_ram_enable) | |
| 988 | if (!m_ram.empty() && m_ram_enable) | |
| 989 | 989 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; |
| 990 | 990 | } |
| 991 | 991 | |
| r245687 | r245688 | |
| 1019 | 1019 | |
| 1020 | 1020 | READ8_MEMBER(gb_rom_rockman8_device::read_ram) |
| 1021 | 1021 | { |
| 1022 | if (m_ram) | |
| 1022 | if (!m_ram.empty()) | |
| 1023 | 1023 | return m_ram[offset]; |
| 1024 | 1024 | else |
| 1025 | 1025 | return 0xff; |
| r245687 | r245688 | |
| 1027 | 1027 | |
| 1028 | 1028 | WRITE8_MEMBER(gb_rom_rockman8_device::write_ram) |
| 1029 | 1029 | { |
| 1030 | if (m_ram) | |
| 1030 | if (!m_ram.empty()) | |
| 1031 | 1031 | m_ram[offset] = data; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| r245687 | r245688 | |
| 1127 | 1127 | |
| 1128 | 1128 | READ8_MEMBER(gb_rom_sm3sp_device::read_ram) |
| 1129 | 1129 | { |
| 1130 | if (m_ram) | |
| 1130 | if (!m_ram.empty()) | |
| 1131 | 1131 | return m_ram[offset]; |
| 1132 | 1132 | else |
| 1133 | 1133 | return 0xff; |
| r245687 | r245688 | |
| 1135 | 1135 | |
| 1136 | 1136 | WRITE8_MEMBER(gb_rom_sm3sp_device::write_ram) |
| 1137 | 1137 | { |
| 1138 | if (m_ram) | |
| 1138 | if (!m_ram.empty()) | |
| 1139 | 1139 | m_ram[offset] = data; |
| 1140 | 1140 | } |
| r245687 | r245688 | |
|---|---|---|
| 153 | 153 | |
| 154 | 154 | READ8_MEMBER(gb_rom_device::read_ram) |
| 155 | 155 | { |
| 156 | if (m_ram) | |
| 156 | if (!m_ram.empty()) | |
| 157 | 157 | return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + offset]; |
| 158 | 158 | else |
| 159 | 159 | return 0xff; |
| r245687 | r245688 | |
| 161 | 161 | |
| 162 | 162 | WRITE8_MEMBER(gb_rom_device::write_ram) |
| 163 | 163 | { |
| 164 | if (m_ram) | |
| 164 | if (!m_ram.empty()) | |
| 165 | 165 | m_ram[ram_bank_map[m_ram_bank] * 0x2000 + offset] = data; |
| 166 | 166 | } |
| 167 | 167 |
| r245687 | r245688 | |
|---|---|---|
| 408 | 408 | dynamic_buffer rom(len); |
| 409 | 409 | int type; |
| 410 | 410 | |
| 411 | core_fread(m_file, rom, len); | |
| 411 | core_fread(m_file, &rom[0], len); | |
| 412 | 412 | |
| 413 | type = get_cart_type(rom, len); | |
| 413 | type = get_cart_type(&rom[0], len); | |
| 414 | 414 | slot_string = gba_get_slot(type); |
| 415 | 415 | |
| 416 | 416 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 37 | 37 | void rom_alloc(UINT32 size, const char *tag); |
| 38 | 38 | void nvram_alloc(UINT32 size); |
| 39 | 39 | UINT32* get_rom_base() { return m_rom; } |
| 40 | UINT32* get_nvram_base() { return m_nvram; } | |
| 40 | UINT32* get_nvram_base() { return &m_nvram[0]; } | |
| 41 | 41 | UINT32 get_rom_size() { return m_rom_size; } |
| 42 | UINT32 get_nvram_size() { return m_nvram. | |
| 42 | UINT32 get_nvram_size() { return m_nvram.size()*sizeof(UINT32); } | |
| 43 | 43 | void set_rom_size(UINT32 val) { m_rom_size = val; } |
| 44 | 44 | |
| 45 | 45 | void save_nvram() { device().save_item(NAME(m_nvram)); } |
| r245687 | r245688 | |
| 47 | 47 | // internal state |
| 48 | 48 | UINT32 *m_rom; // this points to the cart rom region |
| 49 | 49 | UINT32 m_rom_size; // this is the actual game size, not the rom region size! |
| 50 | d | |
| 50 | std::vector<UINT32> m_nvram; | |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 |
| r245687 | r245688 | |
|---|---|---|
| 116 | 116 | |
| 117 | 117 | READ32_MEMBER(gba_rom_sram_device::read_ram) |
| 118 | 118 | { |
| 119 | if (m_nvram && offset < m_nvram. | |
| 119 | if (!m_nvram.empty() && offset < m_nvram.size()) | |
| 120 | 120 | return m_nvram[offset]; |
| 121 | 121 | else // this cannot actually happen... |
| 122 | 122 | return 0xffffffff; |
| r245687 | r245688 | |
| 124 | 124 | |
| 125 | 125 | WRITE32_MEMBER(gba_rom_sram_device::write_ram) |
| 126 | 126 | { |
| 127 | if (m_nvram && offset < m_nvram. | |
| 127 | if (!m_nvram.empty() && offset < m_nvram.size()) | |
| 128 | 128 | COMBINE_DATA(&m_nvram[offset]); |
| 129 | 129 | } |
| 130 | 130 |
| r245687 | r245688 | |
|---|---|---|
| 99 | 99 | |
| 100 | 100 | READ8_MEMBER(generic_ram_plain_device::read_ram) |
| 101 | 101 | { |
| 102 | if (offset < m_ram. | |
| 102 | if (offset < m_ram.size()) | |
| 103 | 103 | return m_ram[offset]; |
| 104 | 104 | else |
| 105 | 105 | return 0xff; |
| r245687 | r245688 | |
| 107 | 107 | |
| 108 | 108 | WRITE8_MEMBER(generic_ram_plain_device::write_ram) |
| 109 | 109 | { |
| 110 | if (offset < m_ram. | |
| 110 | if (offset < m_ram.size()) | |
| 111 | 111 | m_ram[offset] = data; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | READ8_MEMBER(generic_ram_linear_device::read_ram) |
| 116 | 116 | { |
| 117 | return m_ram[offset % m_ram. | |
| 117 | return m_ram[offset % m_ram.size()]; | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | WRITE8_MEMBER(generic_ram_linear_device::write_ram) |
| 121 | 121 | { |
| 122 | m_ram[offset % m_ram. | |
| 122 | m_ram[offset % m_ram.size()] = data; | |
| 123 | 123 | } |
| r245687 | r245688 | |
|---|---|---|
| 109 | 109 | |
| 110 | 110 | READ8_MEMBER(generic_romram_plain_device::read_ram) |
| 111 | 111 | { |
| 112 | if (offset < m_ram. | |
| 112 | if (offset < m_ram.size()) | |
| 113 | 113 | return m_ram[offset]; |
| 114 | 114 | else |
| 115 | 115 | return 0xff; |
| r245687 | r245688 | |
| 117 | 117 | |
| 118 | 118 | WRITE8_MEMBER(generic_romram_plain_device::write_ram) |
| 119 | 119 | { |
| 120 | if (offset < m_ram. | |
| 120 | if (offset < m_ram.size()) | |
| 121 | 121 | m_ram[offset] = data; |
| 122 | 122 | } |
| r245687 | r245688 | |
|---|---|---|
| 31 | 31 | UINT8* get_rom_base() { return m_rom; } |
| 32 | 32 | UINT32 get_rom_size() { return m_rom_size; } |
| 33 | 33 | |
| 34 | UINT8* get_ram_base() { return m_ram; } | |
| 35 | UINT32 get_ram_size() { return m_ram.count(); } | |
| 34 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 35 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 36 | 36 | |
| 37 | 37 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 38 | 38 |
| r245687 | r245688 | |
|---|---|---|
| 57 | 57 | astring region_tag; |
| 58 | 58 | m_rom = memregion(region_tag.cpy(tag()).cat(":ecs").c_str())->base(); |
| 59 | 59 | } |
| 60 | if ( | |
| 60 | if (m_ram.empty()) | |
| 61 | 61 | { |
| 62 | 62 | m_ram.resize(0x800); |
| 63 | 63 | } |
| r245687 | r245688 | |
|---|---|---|
| 31 | 31 | virtual DECLARE_READ16_MEMBER(read_rome0); |
| 32 | 32 | virtual DECLARE_READ16_MEMBER(read_romf0); |
| 33 | 33 | // RAM |
| 34 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } | |
| 35 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } | |
| 34 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.size() - 1)]; } | |
| 35 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.size() - 1)] = data & 0xff; } | |
| 36 | 36 | // AY8914 |
| 37 | 37 | virtual DECLARE_READ16_MEMBER(read_ay); |
| 38 | 38 | virtual DECLARE_WRITE16_MEMBER(write_ay); |
| r245687 | r245688 | |
|---|---|---|
| 45 | 45 | intv_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 46 | 46 | |
| 47 | 47 | // reading and writing |
| 48 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } | |
| 49 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } | |
| 48 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.size() - 1)]; } | |
| 49 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.size() - 1)] = data & 0xff; } | |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | 52 | // ======================> intv_gfact_device |
| r245687 | r245688 | |
| 58 | 58 | intv_gfact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 59 | 59 | |
| 60 | 60 | // reading and writing |
| 61 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.count() - 1)]; } | |
| 62 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.count() - 1)] = data & 0xff; } | |
| 61 | virtual DECLARE_READ16_MEMBER(read_ram) { return (int)m_ram[offset & (m_ram.size() - 1)]; } | |
| 62 | virtual DECLARE_WRITE16_MEMBER(write_ram) { m_ram[offset & (m_ram.size() - 1)] = data & 0xff; } | |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | 65 | // ======================> intv_wsmlb_device |
| r245687 | r245688 | |
|---|---|---|
| 468 | 468 | dynamic_buffer rom(len); |
| 469 | 469 | int type = INTV_STD; |
| 470 | 470 | |
| 471 | core_fread(m_file, rom, len); | |
| 471 | core_fread(m_file, &rom[0], len); | |
| 472 | 472 | |
| 473 | 473 | if (rom[0] == 0xa8 && (rom[1] == (rom[2] ^ 0xff))) |
| 474 | 474 | { |
| r245687 | r245688 | |
|---|---|---|
| 67 | 67 | void rom_alloc(UINT32 size, const char *tag); |
| 68 | 68 | void ram_alloc(UINT32 size); |
| 69 | 69 | UINT8* get_rom_base() { return m_rom; } |
| 70 | UINT8* get_ram_base() { return m_ram; } | |
| 70 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 71 | 71 | UINT32 get_rom_size() { return m_rom_size; } |
| 72 | UINT32 get_ram_size() { return m_ram. | |
| 72 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 73 | 73 | |
| 74 | 74 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 75 | 75 | virtual void late_subslot_setup() {} |
| r245687 | r245688 | |
|---|---|---|
| 435 | 435 | |
| 436 | 436 | void threecom3c505_device::data_buffer::copy(data_buffer *db) const |
| 437 | 437 | { |
| 438 | db->m_data.resize(m_data. | |
| 438 | db->m_data.resize(m_data.size()); | |
| 439 | 439 | db->m_length = m_length; |
| 440 | memcpy(db->m_data, m_data, m_data. | |
| 440 | memcpy(&db->m_data[0], &m_data[0], m_data.size()); | |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | int threecom3c505_device::data_buffer::append(UINT8 data) |
| 444 | 444 | { |
| 445 | if (m_length >= m_data. | |
| 445 | if (m_length >= m_data.size()) | |
| 446 | 446 | { |
| 447 | 447 | return 0; |
| 448 | 448 | } |
| r245687 | r245688 | |
| 532 | 532 | } |
| 533 | 533 | else |
| 534 | 534 | { |
| 535 | memcpy(m_db[m_put_index]->m_data, data, length); | |
| 535 | memcpy(&m_db[m_put_index]->m_data[0], data, length); | |
| 536 | 536 | m_db[m_put_index]->m_length = length; |
| 537 | 537 | m_put_index = next_index; |
| 538 | 538 | m_count++; |
| r245687 | r245688 | |
|---|---|---|
| 168 | 168 | UINT8 get(int i) { return m_data[i]; }; |
| 169 | 169 | UINT16 get_word(int i) { return (m_data[i*2+1] << 8) + m_data[i*2]; }; |
| 170 | 170 | int is_empty() {return m_length == 0; }; |
| 171 | int is_full() {return m_length >= m_data. | |
| 171 | int is_full() {return m_length >= m_data.size(); }; | |
| 172 | 172 | UINT16 get_length() { return m_length; }; |
| 173 | UINT16 get_size() { return m_data.count(); }; | |
| 174 | UINT8 *get_data() { return m_data; }; | |
| 173 | UINT16 get_size() { return m_data.size(); }; | |
| 174 | UINT8 *get_data() { return &m_data[0]; }; | |
| 175 | 175 | void copy(data_buffer *db) const; |
| 176 | 176 | void log(const char *title) const; |
| 177 | 177 |
| r245687 | r245688 | |
|---|---|---|
| 339 | 339 | set_isa_device(); |
| 340 | 340 | m_vram.resize(m_vram_size); |
| 341 | 341 | m_isa->install_device(0x3d0, 0x3df, 0, 0, read8_delegate( FUNC(isa8_cga_device::io_read), this ), write8_delegate( FUNC(isa8_cga_device::io_write), this ) ); |
| 342 | m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, 0, m_vram_size & 0x4000, "bank_cga", m_vram); | |
| 342 | m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, 0, m_vram_size & 0x4000, "bank_cga", &m_vram[0]); | |
| 343 | 343 | |
| 344 | 344 | /* Initialise the cga palette */ |
| 345 | 345 | int i; |
| r245687 | r245688 | |
| 1552 | 1552 | isa8_cga_device::device_start(); |
| 1553 | 1553 | |
| 1554 | 1554 | m_isa->install_device(0x3d0, 0x3df, 0, 0, read8_delegate( FUNC(isa8_cga_pc1512_device::io_read), this ), write8_delegate( FUNC(isa8_cga_pc1512_device::io_write), this ) ); |
| 1555 | m_isa->install_bank(0xb8000, 0xbbfff, 0, 0, "bank1", m_vram); | |
| 1555 | m_isa->install_bank(0xb8000, 0xbbfff, 0, 0, "bank1", &m_vram[0]); | |
| 1556 | 1556 | |
| 1557 | 1557 | address_space &space = machine().firstcpu->space( AS_PROGRAM ); |
| 1558 | 1558 | |
| r245687 | r245688 | |
| 1787 | 1787 | read8_delegate( FUNC(isa8_ec1841_0002_device::char_ram_read), this), |
| 1788 | 1788 | write8_delegate(FUNC(isa8_ec1841_0002_device::char_ram_write), this) ); |
| 1789 | 1789 | } else { |
| 1790 | m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, 0, m_vram_size & 0x4000, "bank_cga", m_vram); | |
| 1790 | m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, 0, m_vram_size & 0x4000, "bank_cga", &m_vram[0]); | |
| 1791 | 1791 | } |
| 1792 | 1792 | break; |
| 1793 | 1793 | default: |
| r245687 | r245688 | |
|---|---|---|
| 389 | 389 | m_nmi_handler.resolve_safe(); |
| 390 | 390 | |
| 391 | 391 | // TODO: make DRAM size configurable. Can be 256k, 512k, 768k, or 1024k |
| 392 | m_wave_ram.resize_and_clear(1024*1024); | |
| 392 | m_wave_ram.resize(1024*1024); | |
| 393 | memset(&m_wave_ram[0], 0, 1024*1024); | |
| 393 | 394 | |
| 394 | 395 | m_stream = stream_alloc(0,2,44100); |
| 395 | 396 |
| r245687 | r245688 | |
|---|---|---|
| 582 | 582 | csb = 0x00; |
| 583 | 583 | error = 0; |
| 584 | 584 | |
| 585 | buffer_ptr = buffer; | |
| 585 | buffer_ptr = &buffer[0]; | |
| 586 | 586 | cmd = buffer[0]; |
| 587 | 587 | |
| 588 | 588 | get_drive(); |
| r245687 | r245688 | |
| 716 | 716 | if (LOG_HDC_DATA) |
| 717 | 717 | logerror("hdc_data_w $%02x: ", data); |
| 718 | 718 | |
| 719 | buffer_ptr = buffer; | |
| 719 | buffer_ptr = &buffer[0]; | |
| 720 | 720 | data_cnt = 6; /* expect 6 bytes including this one */ |
| 721 | 721 | status &= ~STA_READY; |
| 722 | 722 | status &= ~STA_INPUT; |
| r245687 | r245688 | |
| 792 | 792 | sector[0] = sector[1] = 0; |
| 793 | 793 | csb = 0; |
| 794 | 794 | status = STA_COMMAND | STA_READY; |
| 795 | memset(buffer, 0, buffer.count()); | |
| 796 | buffer_ptr = buffer; | |
| 795 | memset(&buffer[0], 0, buffer.size()); | |
| 796 | buffer_ptr = &buffer[0]; | |
| 797 | 797 | data_cnt = 0; |
| 798 | 798 | } |
| 799 | 799 |
| r245687 | r245688 | |
|---|---|---|
| 176 | 176 | set_isa_device(); |
| 177 | 177 | m_videoram.resize(0x1000); |
| 178 | 178 | m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_mda_device::io_read), this ), write8_delegate( FUNC(isa8_mda_device::io_write), this ) ); |
| 179 | m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", m_videoram); | |
| 179 | m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", &m_videoram[0]); | |
| 180 | 180 | |
| 181 | 181 | /* Initialise the mda palette */ |
| 182 | 182 | for(int i = 0; i < 4; i++) |
| r245687 | r245688 | |
| 596 | 596 | m_videoram.resize(0x10000); |
| 597 | 597 | set_isa_device(); |
| 598 | 598 | m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_hercules_device::io_read), this ), write8_delegate( FUNC(isa8_hercules_device::io_write), this ) ); |
| 599 | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", m_videoram); | |
| 599 | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", &m_videoram[0]); | |
| 600 | 600 | |
| 601 | 601 | /* Initialise the mda palette */ |
| 602 | 602 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| r245687 | r245688 | |
|---|---|---|
| 339 | 339 | // default the sector data buffer with model and status information |
| 340 | 340 | // (i.e. set sector data buffer for cmd=0x0e READ SECTOR BUFFER) |
| 341 | 341 | |
| 342 | memset(sector_buffer, 0, OMTI_DISK_SECTOR_SIZE); | |
| 343 | memcpy(sector_buffer, "8621VB.4060487xx", 0x10); | |
| 342 | memset(§or_buffer[0], 0, OMTI_DISK_SECTOR_SIZE); | |
| 343 | memcpy(§or_buffer[0], "8621VB.4060487xx", 0x10); | |
| 344 | 344 | sector_buffer[0x10] = 0; // ROM Checksum error |
| 345 | 345 | sector_buffer[0x11] = 0; // Processor Register error |
| 346 | 346 | sector_buffer[0x12] = 0; // Buffer RAM error |
| r245687 | r245688 | |
| 543 | 543 | |
| 544 | 544 | void omti8621_device::read_sectors_from_disk(INT32 diskaddr, UINT8 count, UINT8 lun) |
| 545 | 545 | { |
| 546 | UINT8 *data_buffer = sector_buffer; | |
| 546 | UINT8 *data_buffer = §or_buffer[0]; | |
| 547 | 547 | device_image_interface *image = our_disks[lun]->m_image; |
| 548 | 548 | |
| 549 | 549 | while (count-- > 0) { |
| r245687 | r245688 | |
| 563 | 563 | |
| 564 | 564 | void omti8621_device::write_sectors_to_disk(INT32 diskaddr, UINT8 count, UINT8 lun) |
| 565 | 565 | { |
| 566 | UINT8 *data_buffer = sector_buffer; | |
| 566 | UINT8 *data_buffer = §or_buffer[0]; | |
| 567 | 567 | device_image_interface *image = our_disks[lun]->m_image; |
| 568 | 568 | |
| 569 | 569 | while (count-- > 0) { |
| r245687 | r245688 | |
| 594 | 594 | |
| 595 | 595 | while (count-- > 0) { |
| 596 | 596 | image->fseek( src_addr * OMTI_DISK_SECTOR_SIZE, SEEK_SET); |
| 597 | image->fread( sector_buffer, OMTI_DISK_SECTOR_SIZE); | |
| 597 | image->fread( §or_buffer[0], OMTI_DISK_SECTOR_SIZE); | |
| 598 | 598 | |
| 599 | 599 | image->fseek( dst_addr * OMTI_DISK_SECTOR_SIZE, SEEK_SET); |
| 600 | image->fwrite( sector_buffer, OMTI_DISK_SECTOR_SIZE); | |
| 600 | image->fwrite( §or_buffer[0], OMTI_DISK_SECTOR_SIZE); | |
| 601 | 601 | |
| 602 | 602 | if (dst_addr == diskaddr_ecc_error) { |
| 603 | 603 | // reset previous ECC error |
| r245687 | r245688 | |
| 641 | 641 | |
| 642 | 642 | if (check_disk_address(cdb) ) { |
| 643 | 643 | if ((cdb[5] & 0x40) == 0) { |
| 644 | memset(sector_buffer, 0x6C, OMTI_DISK_SECTOR_SIZE * our_disks[lun]->m_sectors); | |
| 644 | memset(§or_buffer[0], 0x6C, OMTI_DISK_SECTOR_SIZE * our_disks[lun]->m_sectors); | |
| 645 | 645 | } |
| 646 | 646 | write_sectors_to_disk(disk_addr, our_disks[lun]->m_sectors, lun); |
| 647 | 647 | } |
| r245687 | r245688 | |
| 840 | 840 | if (check_disk_address(cdb)) { |
| 841 | 841 | // read data from controller |
| 842 | 842 | read_sectors_from_disk(get_disk_address(cdb), cdb[4], lun); |
| 843 | set_data_transfer(sector_buffer, OMTI_DISK_SECTOR_SIZE*cdb[4]); | |
| 843 | set_data_transfer(§or_buffer[0], OMTI_DISK_SECTOR_SIZE*cdb[4]); | |
| 844 | 844 | } |
| 845 | 845 | break; |
| 846 | 846 | |
| r245687 | r245688 | |
| 856 | 856 | break; |
| 857 | 857 | |
| 858 | 858 | case OMTI_CMD_READ_SECTOR_BUFFER: // 0x0E |
| 859 | set_data_transfer(sector_buffer, OMTI_DISK_SECTOR_SIZE*cdb[4]); | |
| 859 | set_data_transfer(§or_buffer[0], OMTI_DISK_SECTOR_SIZE*cdb[4]); | |
| 860 | 860 | break; |
| 861 | 861 | |
| 862 | 862 | case OMTI_CMD_WRITE_SECTOR_BUFFER: // 0x0F |
| r245687 | r245688 | |
| 909 | 909 | if (check_disk_address(cdb)) { |
| 910 | 910 | // read data from controller |
| 911 | 911 | read_sectors_from_disk(get_disk_address(cdb), cdb[4], lun); |
| 912 | set_data_transfer(sector_buffer, OMTI_DISK_SECTOR_SIZE+6); | |
| 912 | set_data_transfer(§or_buffer[0], OMTI_DISK_SECTOR_SIZE+6); | |
| 913 | 913 | } |
| 914 | 914 | break; |
| 915 | 915 | |
| r245687 | r245688 | |
| 1050 | 1050 | // TODO: check diskaddr |
| 1051 | 1051 | // Fall through |
| 1052 | 1052 | case OMTI_CMD_WRITE_SECTOR_BUFFER: // 0x0F |
| 1053 | set_data_transfer(sector_buffer, | |
| 1053 | set_data_transfer(§or_buffer[0], | |
| 1054 | 1054 | OMTI_DISK_SECTOR_SIZE * command_buffer[4]); |
| 1055 | 1055 | status_port &= ~OMTI_STATUS_IO; |
| 1056 | 1056 | break; |
| r245687 | r245688 | |
| 1062 | 1062 | |
| 1063 | 1063 | case OMTI_CMD_WRITE_LONG: // 0xE6 |
| 1064 | 1064 | // TODO: check diskaddr |
| 1065 | set_data_transfer(sector_buffer, | |
| 1065 | set_data_transfer(§or_buffer[0], | |
| 1066 | 1066 | (OMTI_DISK_SECTOR_SIZE +6) * command_buffer[4]); |
| 1067 | 1067 | status_port &= ~OMTI_STATUS_IO; |
| 1068 | 1068 | break; |
| r245687 | r245688 | |
|---|---|---|
| 60 | 60 | vga.svga_intf.seq_regcount = 0x1c; |
| 61 | 61 | vga.svga_intf.crtc_regcount = 0x19; |
| 62 | 62 | vga.svga_intf.vram_size = 0x400000; |
| 63 | vga.memory.resize_and_clear(vga.svga_intf.vram_size); | |
| 63 | vga.memory.resize(vga.svga_intf.vram_size); | |
| 64 | memset(&vga.memory[0], 0, vga.svga_intf.vram_size); | |
| 64 | 65 | save_item(vga.memory,"Video RAM"); |
| 65 | 66 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 66 | 67 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| r245687 | r245688 | |
|---|---|---|
| 1187 | 1187 | } |
| 1188 | 1188 | else |
| 1189 | 1189 | { |
| 1190 | memcpy(m_ctape_block_buffer, tape, SC499_CTAPE_BLOCK_SIZE); | |
| 1190 | memcpy(&m_ctape_block_buffer[0], tape, SC499_CTAPE_BLOCK_SIZE); | |
| 1191 | 1191 | |
| 1192 | 1192 | // if (verbose > 1 || m_tape_pos % 100 == 0) |
| 1193 | 1193 | { |
| r245687 | r245688 | |
| 1238 | 1238 | check_tape(); |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | m_image->write_block(m_tape_pos, m_ctape_block_buffer); | |
| 1241 | m_image->write_block(m_tape_pos, &m_ctape_block_buffer[0]); | |
| 1242 | 1242 | m_ctape_block_count = m_tape_pos; |
| 1243 | 1243 | m_ctape_block_index = 0; |
| 1244 | 1244 | m_tape_pos++; |
| r245687 | r245688 | |
| 1255 | 1255 | { |
| 1256 | 1256 | static const UINT8 fm_pattern[] = {0xDE, 0xAF, 0xFA, 0xED}; |
| 1257 | 1257 | |
| 1258 | int is_filemark = memcmp(m_ctape_block_buffer, fm_pattern, 4) == 0 && | |
| 1259 | memcmp(m_ctape_block_buffer, m_ctape_block_buffer+4, SC499_CTAPE_BLOCK_SIZE-4) == 0; | |
| 1258 | int is_filemark = memcmp(&m_ctape_block_buffer[0], fm_pattern, 4) == 0 && | |
| 1259 | memcmp(&m_ctape_block_buffer[0], &m_ctape_block_buffer[4], SC499_CTAPE_BLOCK_SIZE-4) == 0; | |
| 1260 | 1260 | |
| 1261 | 1261 | LOG3(("block_is_filemark for block %d = %d", m_tape_pos-1, is_filemark)); |
| 1262 | 1262 | return is_filemark; |
| r245687 | r245688 | |
| 1271 | 1271 | static const UINT8 fm_pattern[] = {0xDE, 0xAF, 0xFA, 0xED}; |
| 1272 | 1272 | for (int i = 0; i < SC499_CTAPE_BLOCK_SIZE; i += 4) |
| 1273 | 1273 | { |
| 1274 | memcpy(m_ctape_block_buffer | |
| 1274 | memcpy(&m_ctape_block_buffer[i], fm_pattern, 4); | |
| 1275 | 1275 | } |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| r245687 | r245688 | |
| 1294 | 1294 | UINT8 *sc499_ctape_image_device::read_block(int block_num) |
| 1295 | 1295 | { |
| 1296 | 1296 | // access beyond end of tape cart |
| 1297 | if (m_ctape_data. | |
| 1297 | if (m_ctape_data.size() <= (block_num + 1) * SC499_CTAPE_BLOCK_SIZE) | |
| 1298 | 1298 | return NULL; |
| 1299 | 1299 | else |
| 1300 | return m_ctape_data | |
| 1300 | return &m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE]; | |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | void sc499_ctape_image_device::write_block(int block_num, UINT8 *ptr) |
| 1304 | 1304 | { |
| 1305 | if (!(m_ctape_data.bytes() <= (block_num + 1) * SC499_CTAPE_BLOCK_SIZE)) | |
| 1306 | memcpy(m_ctape_data + (block_num * SC499_CTAPE_BLOCK_SIZE), ptr, SC499_CTAPE_BLOCK_SIZE); | |
| 1305 | if (!(m_ctape_data.size() <= (block_num + 1) * SC499_CTAPE_BLOCK_SIZE)) | |
| 1306 | memcpy(&m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE], ptr, SC499_CTAPE_BLOCK_SIZE); | |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | bool sc499_ctape_image_device::call_load() |
| r245687 | r245688 | |
| 1317 | 1317 | size = io_generic_size(&io); |
| 1318 | 1318 | m_ctape_data.resize(size); |
| 1319 | 1319 | |
| 1320 | io_generic_read(&io, m_ctape_data, 0, size); | |
| 1320 | io_generic_read(&io, &m_ctape_data[0], 0, size); | |
| 1321 | 1321 | |
| 1322 | 1322 | return IMAGE_INIT_PASS; |
| 1323 | 1323 | } |
| r245687 | r245688 | |
|---|---|---|
| 46 | 46 | |
| 47 | 47 | UINT8 *read_block(int block_num); |
| 48 | 48 | void write_block(int block_num, UINT8 *ptr); |
| 49 | UINT64 tapelen() { return m_ctape_data. | |
| 49 | UINT64 tapelen() { return m_ctape_data.size(); } | |
| 50 | 50 | |
| 51 | 51 | protected: |
| 52 | 52 | // device-level overrides |
| r245687 | r245688 | |
|---|---|---|
| 169 | 169 | vga.read_dipswitch = read8_delegate(); //read_dipswitch; |
| 170 | 170 | vga.svga_intf.vram_size = 0x200000; |
| 171 | 171 | |
| 172 | vga.memory.resize_and_clear(vga.svga_intf.vram_size); | |
| 172 | vga.memory.resize(vga.svga_intf.vram_size); | |
| 173 | memset(&vga.memory[0], 0, vga.svga_intf.vram_size); | |
| 173 | 174 | save_item(NAME(vga.memory)); |
| 174 | 175 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 175 | 176 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| r245687 | r245688 | |
|---|---|---|
| 471 | 471 | dynamic_buffer tmpROM(tmplen); |
| 472 | 472 | |
| 473 | 473 | // STEP 1: store a (possibly headered) copy of the file and determine its type (SMD? MD? BIN?) |
| 474 | fread(tmpROM, tmplen); | |
| 474 | fread(&tmpROM[0], tmplen); | |
| 475 | 475 | is_smd = genesis_is_SMD(&tmpROM[0x200], tmplen - 0x200); |
| 476 | 476 | is_md = (tmpROM[0x80] == 'E') && (tmpROM[0x81] == 'A') && (tmpROM[0x82] == 'M' || tmpROM[0x82] == 'G'); |
| 477 | 477 | |
| r245687 | r245688 | |
| 909 | 909 | dynamic_buffer rom(len); |
| 910 | 910 | int type; |
| 911 | 911 | |
| 912 | core_fread(m_file, rom, len); | |
| 912 | core_fread(m_file, &rom[0], len); | |
| 913 | 913 | |
| 914 | 914 | if (genesis_is_SMD(&rom[0x200], len - 0x200)) |
| 915 | 915 | offset = 0x200; |
| 916 | 916 | |
| 917 | type = get_cart_type(rom | |
| 917 | type = get_cart_type(&rom[offset], len - offset); | |
| 918 | 918 | slot_string = md_get_slot(type); |
| 919 | 919 | |
| 920 | 920 | clear(); |
| r245687 | r245688 | |
|---|---|---|
| 103 | 103 | virtual void rom_alloc(size_t size, const char *tag); |
| 104 | 104 | virtual void nvram_alloc(size_t size); |
| 105 | 105 | virtual UINT16* get_rom_base() { return m_rom; }; |
| 106 | virtual UINT16* get_nvram_base() { return m_nvram; }; | |
| 106 | virtual UINT16* get_nvram_base() { return &m_nvram[0]; }; | |
| 107 | 107 | virtual UINT32 get_rom_size() { return m_rom_size; }; |
| 108 | virtual UINT32 get_nvram_size() { return m_nvram. | |
| 108 | virtual UINT32 get_nvram_size() { return m_nvram.size()*sizeof(UINT16); }; | |
| 109 | 109 | virtual void set_bank_to_rom(const char *banktag, UINT32 offset) {}; |
| 110 | 110 | |
| 111 | 111 | void save_nvram() { device().save_item(NAME(m_nvram)); } |
| r245687 | r245688 | |
| 124 | 124 | // internal state |
| 125 | 125 | UINT16 *m_rom; |
| 126 | 126 | UINT32 m_rom_size; |
| 127 | d | |
| 127 | std::vector<UINT16> m_nvram; | |
| 128 | 128 | |
| 129 | 129 | UINT8 rom_bank_map[128]; // 64K chunks of rom |
| 130 | 130 | }; |
| r245687 | r245688 | |
|---|---|---|
| 70 | 70 | |
| 71 | 71 | void msx_cart_interface::rom_alloc(UINT32 size) |
| 72 | 72 | { |
| 73 | m_rom.resize_and_clear(size, 0xff); | |
| 73 | m_rom.resize(size); | |
| 74 | memset(&m_rom[0], 0xff, size); | |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | void msx_cart_interface::rom_vlm5030_alloc(UINT32 size) |
| 77 | 78 | { |
| 78 | m_rom_vlm5030.resize_and_clear(size, 0xff); | |
| 79 | m_rom_vlm5030.resize(size); | |
| 80 | memset(&m_rom_vlm5030[0], 0xff, size); | |
| 79 | 81 | } |
| 80 | 82 | |
| 81 | 83 | void msx_cart_interface::ram_alloc(UINT32 size) |
| 82 | 84 | { |
| 83 | m_ram.resize_and_clear(size); | |
| 85 | m_ram.resize(size); | |
| 86 | memset(&m_ram[0], 0x00, size); | |
| 84 | 87 | } |
| 85 | 88 | |
| 86 | 89 | void msx_cart_interface::sram_alloc(UINT32 size) |
| 87 | 90 | { |
| 88 | m_sram.resize_and_clear(size); | |
| 91 | m_sram.resize(size); | |
| 92 | memset(&m_sram[0], 0x00, size); | |
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 |
| r245687 | r245688 | |
|---|---|---|
| 29 | 29 | void rom_vlm5030_alloc(UINT32 size); |
| 30 | 30 | void sram_alloc(UINT32 size); |
| 31 | 31 | |
| 32 | UINT8* get_rom_base() { return m_rom; } | |
| 33 | UINT8* get_rom_vlm5030_base() { return m_rom_vlm5030; } | |
| 34 | UINT8* get_ram_base() { return m_ram; } | |
| 35 | UINT8* get_sram_base() { return m_sram; } | |
| 36 | UINT32 get_rom_size() { return m_rom.count(); } | |
| 37 | UINT32 get_rom_vlm5030_size() { return m_rom_vlm5030.count(); } | |
| 38 | UINT32 get_ram_size() { return m_ram.count(); } | |
| 39 | UINT32 get_sram_size() { return m_sram.count(); } | |
| 32 | UINT8* get_rom_base() { return &m_rom[0]; } | |
| 33 | UINT8* get_rom_vlm5030_base() { return &m_rom_vlm5030[0]; } | |
| 34 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 35 | UINT8* get_sram_base() { return &m_sram[0]; } | |
| 36 | UINT32 get_rom_size() { return m_rom.size(); } | |
| 37 | UINT32 get_rom_vlm5030_size() { return m_rom_vlm5030.size(); } | |
| 38 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 39 | UINT32 get_sram_size() { return m_sram.size(); } | |
| 40 | 40 | |
| 41 | 41 | protected: |
| 42 | 42 | dynamic_buffer m_rom; |
| r245687 | r245688 | |
|---|---|---|
| 907 | 907 | { |
| 908 | 908 | fatalerror("keyboard_master: Invalid ROM size\n"); |
| 909 | 909 | } |
| 910 | m_vlm5030->set_rom(m_rom_vlm5030); | |
| 910 | m_vlm5030->set_rom(&m_rom_vlm5030[0]); | |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 |
| r245687 | r245688 | |
|---|---|---|
| 326 | 326 | if (type == NOMAPPER) |
| 327 | 327 | { |
| 328 | 328 | // Not identified through hashfile, try automatic detection |
| 329 | type = get_cart_type(rom, length); | |
| 329 | type = get_cart_type(&rom[0], length); | |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | if (type > NOMAPPER) |
| r245687 | r245688 | |
|---|---|---|
| 69 | 69 | |
| 70 | 70 | m_sram.resize(0x4000); |
| 71 | 71 | |
| 72 | m_nvram->set_base( | |
| 72 | m_nvram->set_base(&m_sram[0], 0x4000); | |
| 73 | 73 | |
| 74 | 74 | m_rom = m_rom_region->base() + m_region_offset; |
| 75 | 75 | |
| r245687 | r245688 | |
| 87 | 87 | if (m_selected_bank[bank] >= 0x80 && m_selected_bank[bank] < 0x84) // Are these banks were sram is present? Mirroring? |
| 88 | 88 | { |
| 89 | 89 | logerror("panasonic08: mapping bank %d to sram\n", bank); |
| 90 | m_bank_base[bank] = m_sram | |
| 90 | m_bank_base[bank] = &m_sram[((m_selected_bank[bank] & 0x7f) * 0x2000) & 0x3fff]; | |
| 91 | 91 | } |
| 92 | 92 | else |
| 93 | 93 | { |
| r245687 | r245688 | |
|---|---|---|
| 24 | 24 | virtual DECLARE_WRITE8_MEMBER(write); |
| 25 | 25 | |
| 26 | 26 | private: |
| 27 | d | |
| 27 | std::vector<UINT8> m_ram; | |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | 30 |
| r245687 | r245688 | |
|---|---|---|
| 32 | 32 | for ( int i = 0; i < 4; i++ ) |
| 33 | 33 | { |
| 34 | 34 | m_bank_selected[i] = 3 -i; |
| 35 | m_bank_base[i] = m_ram | |
| 35 | m_bank_base[i] = &m_ram[0x4000 * m_bank_selected[i]]; | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | save_item(NAME(m_ram)); |
| r245687 | r245688 | |
| 50 | 50 | { |
| 51 | 51 | for ( int i = 0; i < 3; i++ ) |
| 52 | 52 | { |
| 53 | m_bank_base[i] = m_ram | |
| 53 | m_bank_base[i] = &m_ram[0x4000 * ( m_bank_selected[i] & m_bank_mask )]; | |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| r245687 | r245688 | |
| 74 | 74 | offset &= 3; |
| 75 | 75 | |
| 76 | 76 | m_bank_selected[offset] = data; |
| 77 | m_bank_base[offset] = m_ram | |
| 77 | m_bank_base[offset] = &m_ram[0x4000 * ( m_bank_selected[offset] & m_bank_mask )]; | |
| 78 | 78 | } |
| r245687 | r245688 | |
|---|---|---|
| 30 | 30 | void restore_banks(); |
| 31 | 31 | |
| 32 | 32 | private: |
| 33 | d | |
| 33 | std::vector<UINT8> m_ram; | |
| 34 | 34 | UINT32 m_total_size; |
| 35 | 35 | UINT8 m_bank_mask; |
| 36 | 36 | UINT8 m_bank_selected[4]; |
| r245687 | r245688 | |
|---|---|---|
| 54 | 54 | UINT8 *rom = sprrom; |
| 55 | 55 | dynamic_buffer buf( cx_size ); |
| 56 | 56 | |
| 57 | memcpy( buf, rom, cx_size ); | |
| 57 | memcpy( &buf[0], rom, cx_size ); | |
| 58 | 58 | |
| 59 | 59 | for( i = 0; i < cx_size / 0x40; i++ ){ |
| 60 | 60 | memcpy( &rom[ i * 0x40 ], &buf[ (i ^ 1) * 0x40 ], 0x40 ); |
| r245687 | r245688 | |
| 71 | 71 | if (value == 1) |
| 72 | 72 | { |
| 73 | 73 | dynamic_buffer buf( sx_size ); |
| 74 | memcpy( buf, rom, sx_size ); | |
| 74 | memcpy( &buf[0], rom, sx_size ); | |
| 75 | 75 | |
| 76 | 76 | for( i = 0; i < sx_size; i += 0x10 ) |
| 77 | 77 | { |
| r245687 | r245688 | |
| 93 | 93 | void ngbootleg_prot_device::kof97oro_px_decode(UINT8* cpurom, UINT32 cpurom_size) |
| 94 | 94 | { |
| 95 | 95 | int i; |
| 96 | d | |
| 96 | std::vector<UINT16> tmp( 0x500000 ); | |
| 97 | 97 | UINT16 *src = (UINT16*)cpurom; |
| 98 | 98 | |
| 99 | 99 | for (i = 0; i < 0x500000/2; i++) { |
| 100 | 100 | tmp[i] = src[i ^ 0x7ffef]; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | memcpy (src, tmp, 0x500000); | |
| 103 | memcpy (src, &tmp[0], 0x500000); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| r245687 | r245688 | |
| 175 | 175 | dynamic_buffer dst(0x900000); |
| 176 | 176 | UINT8 *src = cpurom; |
| 177 | 177 | |
| 178 | memcpy(dst + 0x000000, src + 0x700000, 0x100000); // Correct (Verified in Uni-bios) | |
| 179 | memcpy(dst + 0x100000, src + 0x000000, 0x800000); | |
| 178 | memcpy(&dst[0x000000], src + 0x700000, 0x100000); // Correct (Verified in Uni-bios) | |
| 179 | memcpy(&dst[0x100000], src + 0x000000, 0x800000); | |
| 180 | 180 | |
| 181 | 181 | for (i = 0; i < 0x900000; i++) { |
| 182 | 182 | j = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0); |
| r245687 | r245688 | |
| 200 | 200 | void ngbootleg_prot_device::kf10thep_px_decrypt(UINT8* cpurom, UINT32 cpurom_size) |
| 201 | 201 | { |
| 202 | 202 | UINT16 *rom = (UINT16*)cpurom; |
| 203 | d | |
| 203 | std::vector<UINT16> buf(0x100000/2); | |
| 204 | 204 | |
| 205 | 205 | memcpy(&buf[0x000000/2], &rom[0x060000/2], 0x20000); |
| 206 | 206 | memcpy(&buf[0x020000/2], &rom[0x100000/2], 0x20000); |
| r245687 | r245688 | |
| 212 | 212 | memcpy(&buf[0x0e0000/2], &rom[0x1a0000/2], 0x20000); |
| 213 | 213 | memcpy(&buf[0x0002e0/2], &rom[0x0402e0/2], 0x6a); // copy banked code to a new memory region |
| 214 | 214 | memcpy(&buf[0x0f92bc/2], &rom[0x0492bc/2], 0xb9e); // copy banked code to a new memory region |
| 215 | memcpy(rom, buf, 0x100000); | |
| 215 | memcpy(rom, &buf[0], 0x100000); | |
| 216 | 216 | |
| 217 | 217 | for (int i = 0xf92bc/2; i < 0xf9e58/2; i++) |
| 218 | 218 | { |
| r245687 | r245688 | |
| 239 | 239 | for (j = 0; j < 0x80; j+=2) |
| 240 | 240 | { |
| 241 | 241 | ofst = BITSWAP8(j, 0, 3, 4, 5, 6, 1, 2, 7); |
| 242 | memcpy(dst | |
| 242 | memcpy(&dst[j], src + i + ofst, 2); | |
| 243 | 243 | } |
| 244 | memcpy(src + i, dst, 0x80); | |
| 244 | memcpy(src + i, &dst[0], 0x80); | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | memcpy(src, src + 0x600000, 0x100000); // Seems to be the same as kof10th |
| r245687 | r245688 | |
| 295 | 295 | |
| 296 | 296 | for ( i = 0; i < size; i+=0x10000 ) |
| 297 | 297 | { |
| 298 | memcpy( dst, src+i, 0x10000 ); | |
| 298 | memcpy( &dst[0], src+i, 0x10000 ); | |
| 299 | 299 | |
| 300 | 300 | for ( j = 0; j < 0x200; j++ ) |
| 301 | 301 | { |
| 302 | 302 | int n = (j & 0x38) >> 3; |
| 303 | 303 | int ofst = BITSWAP16(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2], 5, 4, 3, t[n][3], t[n][4], t[n][5]); |
| 304 | memcpy( src+i+ofst*128, dst | |
| 304 | memcpy( src+i+ofst*128, &dst[j*128], 128 ); | |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | } |
| r245687 | r245688 | |
| 339 | 339 | UINT8 *src = cpurom; |
| 340 | 340 | dynamic_buffer dst(0x600000); |
| 341 | 341 | |
| 342 | memcpy (dst + 0x000000, src + 0x1C0000, 0x040000); | |
| 343 | memcpy (dst + 0x040000, src + 0x140000, 0x080000); | |
| 344 | memcpy (dst + 0x0C0000, src + 0x100000, 0x040000); | |
| 345 | memcpy (dst + 0x100000, src + 0x200000, 0x400000); | |
| 346 | memcpy (src + 0x000000, dst + 0x000000, 0x600000); | |
| 342 | memcpy (&dst[0x000000], &src[0x1C0000], 0x040000); | |
| 343 | memcpy (&dst[0x040000], &src[0x140000], 0x080000); | |
| 344 | memcpy (&dst[0x0C0000], &src[0x100000], 0x040000); | |
| 345 | memcpy (&dst[0x100000], &src[0x200000], 0x400000); | |
| 346 | memcpy (&src[0x000000], &dst[0x000000], 0x600000); | |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | |
| r245687 | r245688 | |
| 366 | 366 | +(((j&4)>>2)<<bit2shift) |
| 367 | 367 | +(((j&8)>>3)<<bit3shift); |
| 368 | 368 | |
| 369 | memcpy(rom | |
| 369 | memcpy(&rom[j*tilesize], realrom+offset*tilesize, tilesize); | |
| 370 | 370 | } |
| 371 | memcpy(realrom,rom,tilesize*16); | |
| 371 | memcpy(realrom,&rom[0],tilesize*16); | |
| 372 | 372 | realrom+=16*tilesize; |
| 373 | 373 | } |
| 374 | 374 | } |
| r245687 | r245688 | |
| 412 | 412 | UINT8 *romdata = fixedrom; |
| 413 | 413 | dynamic_buffer tmp(8*128*128); |
| 414 | 414 | |
| 415 | memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); | |
| 416 | memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); | |
| 417 | memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); | |
| 418 | memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); | |
| 419 | memcpy(romdata, tmp, 8*128*128); | |
| 415 | memcpy(&tmp[8*0*128], romdata+8*0*128, 8*32*128); | |
| 416 | memcpy(&tmp[8*32*128], romdata+8*64*128, 8*32*128); | |
| 417 | memcpy(&tmp[8*64*128], romdata+8*32*128, 8*32*128); | |
| 418 | memcpy(&tmp[8*96*128], romdata+8*96*128, 8*32*128); | |
| 419 | memcpy(romdata, &tmp[0], 8*128*128); | |
| 420 | 420 | |
| 421 | 421 | romdata = audiorom+0x10000; |
| 422 | memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); | |
| 423 | memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); | |
| 424 | memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); | |
| 425 | memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); | |
| 426 | memcpy(romdata, tmp, 8*128*128); | |
| 422 | memcpy(&tmp[8*0*128], romdata+8*0*128, 8*32*128); | |
| 423 | memcpy(&tmp[8*32*128], romdata+8*64*128, 8*32*128); | |
| 424 | memcpy(&tmp[8*64*128], romdata+8*32*128, 8*32*128); | |
| 425 | memcpy(&tmp[8*96*128], romdata+8*96*128, 8*32*128); | |
| 426 | memcpy(romdata, &tmp[0], 8*128*128); | |
| 427 | 427 | |
| 428 | 428 | memcpy(romdata-0x10000,romdata,0x10000); |
| 429 | 429 | |
| r245687 | r245688 | |
| 498 | 498 | int i; |
| 499 | 499 | int ofst; |
| 500 | 500 | |
| 501 | memcpy( buf, rom, rom_size ); | |
| 501 | memcpy( &buf[0], rom, rom_size ); | |
| 502 | 502 | |
| 503 | 503 | for( i = 0; i < rom_size; i++ ){ |
| 504 | 504 | ofst = BITSWAP24( (i & 0x1ffff), 23, 22, 21, 20, 19, 18, 17, 3, |
| r245687 | r245688 | |
| 510 | 510 | rom[ i ] = buf[ ofst ]; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | memcpy( buf, rom, rom_size ); | |
| 513 | memcpy( &buf[0], rom, rom_size ); | |
| 514 | 514 | |
| 515 | 515 | memcpy( &rom[ 0x08000 ], &buf[ 0x10000 ], 0x8000 ); |
| 516 | 516 | memcpy( &rom[ 0x10000 ], &buf[ 0x08000 ], 0x8000 ); |
| r245687 | r245688 | |
| 522 | 522 | { |
| 523 | 523 | UINT8 *romdata = audiorom+0x10000; |
| 524 | 524 | dynamic_buffer tmp(8*128*128); |
| 525 | memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); | |
| 526 | memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); | |
| 527 | memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); | |
| 528 | memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); | |
| 529 | memcpy(romdata, tmp, 8*128*128); | |
| 525 | memcpy(&tmp[8*0*128], romdata+8*0*128, 8*32*128); | |
| 526 | memcpy(&tmp[8*32*128], romdata+8*64*128, 8*32*128); | |
| 527 | memcpy(&tmp[8*64*128], romdata+8*32*128, 8*32*128); | |
| 528 | memcpy(&tmp[8*96*128], romdata+8*96*128, 8*32*128); | |
| 529 | memcpy(romdata, &tmp[0], 8*128*128); | |
| 530 | 530 | |
| 531 | 531 | memcpy(romdata-0x10000,romdata,0x10000); |
| 532 | 532 | ct2k3sp_sx_decrypt(fixedrom, fixedrom_size); |
| r245687 | r245688 | |
| 541 | 541 | { |
| 542 | 542 | UINT8 *romdata = audiorom+0x10000; |
| 543 | 543 | dynamic_buffer tmp(8*128*128); |
| 544 | memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); | |
| 545 | memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); | |
| 546 | memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); | |
| 547 | memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); | |
| 548 | memcpy(romdata, tmp, 8*128*128); | |
| 544 | memcpy(&tmp[8*0*128], romdata+8*0*128, 8*32*128); | |
| 545 | memcpy(&tmp[8*32*128], romdata+8*64*128, 8*32*128); | |
| 546 | memcpy(&tmp[8*64*128], romdata+8*32*128, 8*32*128); | |
| 547 | memcpy(&tmp[8*96*128], romdata+8*96*128, 8*32*128); | |
| 548 | memcpy(romdata, &tmp[0], 8*128*128); | |
| 549 | 549 | |
| 550 | 550 | memcpy(romdata-0x10000,romdata,0x10000); |
| 551 | 551 | cthd2003_c(sprrom,sprrom_size, 0); |
| r245687 | r245688 | |
| 600 | 600 | dynamic_buffer dst(0x400000); |
| 601 | 601 | int i; |
| 602 | 602 | static const int sec[] = {0x300000,0x200000,0x100000,0x000000}; |
| 603 | memcpy(dst,src,0x400000); | |
| 603 | memcpy(&dst[0],src,0x400000); | |
| 604 | 604 | |
| 605 | 605 | for(i = 0; i < 4; ++i) |
| 606 | 606 | { |
| 607 | memcpy(src+i*0x100000,dst | |
| 607 | memcpy(src+i*0x100000,&dst[sec[i]],0x100000); | |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| r245687 | r245688 | |
| 632 | 632 | dynamic_buffer dst(0x600000); |
| 633 | 633 | |
| 634 | 634 | for (i = 0; i < 8; i++) |
| 635 | memcpy (dst | |
| 635 | memcpy (&dst[i * 0x20000], src + sec[i] * 0x20000, 0x20000); | |
| 636 | 636 | |
| 637 | memcpy (dst + 0x0BBB00, src + 0x045B00, 0x001710); | |
| 638 | memcpy (dst + 0x02FFF0, src + 0x1A92BE, 0x000010); | |
| 639 | memcpy (dst + 0x100000, src + 0x200000, 0x400000); | |
| 640 | memcpy (src, dst, 0x600000); | |
| 637 | memcpy (&dst[0x0BBB00], src + 0x045B00, 0x001710); | |
| 638 | memcpy (&dst[0x02FFF0], src + 0x1A92BE, 0x000010); | |
| 639 | memcpy (&dst[0x100000], src + 0x200000, 0x400000); | |
| 640 | memcpy (src, &dst[0], 0x600000); | |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | for (i = 0xBBB00/2; i < 0xBE000/2; i++) { |
| r245687 | r245688 | |
| 737 | 737 | UINT8 *src = sprrom; |
| 738 | 738 | dynamic_buffer dst( size ); |
| 739 | 739 | int ofst; |
| 740 | memcpy( dst, src, size ); | |
| 740 | memcpy( &dst[0], src, size ); | |
| 741 | 741 | for( i = 0; i < size / 0x80; i++ ){ |
| 742 | 742 | int idx = idx_tbl[ (i & 0xf00) >> 8 ]; |
| 743 | 743 | int bit0 = bitswap4_tbl[ idx ][ 0 ]; |
| r245687 | r245688 | |
| 764 | 764 | dynamic_buffer dst( size ); |
| 765 | 765 | int i; |
| 766 | 766 | int ofst; |
| 767 | memcpy( dst, src, size ); | |
| 767 | memcpy( &dst[0], src, size ); | |
| 768 | 768 | for( i = 0; i < size / 2; i++ ){ |
| 769 | 769 | ofst = BITSWAP24( (i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02, |
| 770 | 770 | 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, |
| r245687 | r245688 | |
| 773 | 773 | ofst += (i & 0xff00000); |
| 774 | 774 | memcpy( &src[ i * 0x02 ], &dst[ ofst * 0x02 ], 0x02 ); |
| 775 | 775 | } |
| 776 | memcpy( dst, src, size ); | |
| 776 | memcpy( &dst[0], src, size ); | |
| 777 | 777 | for( i = 0; i < 6; i++ ){ |
| 778 | 778 | memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); |
| 779 | 779 | } |
| r245687 | r245688 | |
| 799 | 799 | int size = cpurom_size; |
| 800 | 800 | UINT8 *src = cpurom; |
| 801 | 801 | dynamic_buffer dst( size ); |
| 802 | memcpy( dst, src, size ); | |
| 802 | memcpy( &dst[0], src, size ); | |
| 803 | 803 | for( i = 0; i < 6; i++ ){ |
| 804 | 804 | memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); |
| 805 | 805 | } |
| r245687 | r245688 | |
| 819 | 819 | dynamic_buffer dst( size ); |
| 820 | 820 | int i; |
| 821 | 821 | int ofst; |
| 822 | memcpy( dst, src, size ); | |
| 822 | memcpy( &dst[0], src, size ); | |
| 823 | 823 | for( i = 0; i < size / 2; i++ ){ |
| 824 | 824 | ofst = BITSWAP16( (i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d, |
| 825 | 825 | 0x04, 0x03, 0x01, 0x07, 0x06, 0x02, 0x05, 0x0e ); |
| r245687 | r245688 | |
| 898 | 898 | int rom_size = 0x800000; |
| 899 | 899 | UINT8 *rom = cpurom; |
| 900 | 900 | dynamic_buffer buf( rom_size ); |
| 901 | memcpy( buf, rom, rom_size ); | |
| 901 | memcpy( &buf[0], rom, rom_size ); | |
| 902 | 902 | |
| 903 | 903 | for( i = 0; i < rom_size / 0x100000; i++ ){ |
| 904 | 904 | memcpy( &rom[ i * 0x100000 ], &buf[ sec[ i ] * 0x100000 ], 0x100000 ); |
| r245687 | r245688 | |
| 922 | 922 | |
| 923 | 923 | void ngbootleg_prot_device::kf2k3pl_px_decrypt(UINT8* cpurom, UINT32 cpurom_size) |
| 924 | 924 | { |
| 925 | d | |
| 925 | std::vector<UINT16> tmp(0x100000/2); | |
| 926 | 926 | UINT16*rom16 = (UINT16*)cpurom; |
| 927 | 927 | int j; |
| 928 | 928 | int i; |
| 929 | 929 | |
| 930 | 930 | for (i = 0;i < 0x700000/2;i+=0x100000/2) |
| 931 | 931 | { |
| 932 | memcpy(tmp,&rom16[i],0x100000); | |
| 932 | memcpy(&tmp[0],&rom16[i],0x100000); | |
| 933 | 933 | for (j = 0;j < 0x100000/2;j++) |
| 934 | 934 | rom16[i+j] = tmp[BITSWAP24(j,23,22,21,20,19,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)]; |
| 935 | 935 | } |
| r245687 | r245688 | |
| 989 | 989 | int ofst; |
| 990 | 990 | int i; |
| 991 | 991 | |
| 992 | memcpy( buf, rom, px_size ); | |
| 992 | memcpy( &buf[0], rom, px_size ); | |
| 993 | 993 | |
| 994 | 994 | for( i = 0; i < px_size / 2; i++ ){ |
| 995 | 995 | ofst = BITSWAP8( (i & 0x000ff), 7, 6, 5, 4, 3, 0, 1, 2 ); |
| r245687 | r245688 | |
| 999 | 999 | memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 0x02 ); |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | memcpy( buf, rom, px_size ); | |
| 1002 | memcpy( &buf[0], rom, px_size ); | |
| 1003 | 1003 | |
| 1004 | 1004 | memcpy( &rom[ 0x000000 ], &buf[ 0x700000 ], 0x100000 ); |
| 1005 | 1005 | memcpy( &rom[ 0x100000 ], &buf[ 0x000000 ], 0x700000 ); |
| r245687 | r245688 | |
| 1028 | 1028 | UINT8 *rom = audiorom+0x10000; |
| 1029 | 1029 | dynamic_buffer buf( 0x20000 ); |
| 1030 | 1030 | int i, j=0; |
| 1031 | memcpy( buf, rom, 0x20000 ); | |
| 1031 | memcpy( &buf[0], rom, 0x20000 ); | |
| 1032 | 1032 | for( i=0x00000; i<0x20000; i++ ) |
| 1033 | 1033 | { |
| 1034 | 1034 | if ( i&0x10000 ) |
| r245687 | r245688 | |
|---|---|---|
| 504 | 504 | // Data xor |
| 505 | 505 | for (rpos = 0;rpos < rom_size/4;rpos++) |
| 506 | 506 | { |
| 507 | decrypt(buf+4*rpos+0, buf+4*rpos+3, rom[4*rpos+0], rom[4*rpos+3], type0_t03, type0_t12, type1_t03, rpos, (rpos>>8) & 1); | |
| 508 | decrypt(buf+4*rpos+1, buf+4*rpos+2, rom[4*rpos+1], rom[4*rpos+2], type0_t12, type0_t03, type1_t12, rpos, ((rpos>>16) ^ address_16_23_xor2[(rpos>>8) & 0xff]) & 1); | |
| 507 | decrypt(&buf[4*rpos+0], &buf[4*rpos+3], rom[4*rpos+0], rom[4*rpos+3], type0_t03, type0_t12, type1_t03, rpos, (rpos>>8) & 1); | |
| 508 | decrypt(&buf[4*rpos+1], &buf[4*rpos+2], rom[4*rpos+1], rom[4*rpos+2], type0_t12, type0_t03, type1_t12, rpos, ((rpos>>16) ^ address_16_23_xor2[(rpos>>8) & 0xff]) & 1); | |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | // Address xor |
| r245687 | r245688 | |
| 747 | 747 | buffer[i] = rom[m1_address_scramble(i,key)]; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | memcpy(rom,buffer,rom_size); | |
| 750 | memcpy(rom,&buffer[0],rom_size); | |
| 751 | 751 | |
| 752 | 752 | memcpy(rom2,rom,0x10000); |
| 753 | 753 | memcpy(rom2+0x10000,rom,0x80000); |
| r245687 | r245688 | |
|---|---|---|
| 29 | 29 | static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; |
| 30 | 30 | UINT8 *src = cpurom+0x100000; |
| 31 | 31 | dynamic_buffer dst(0x400000); |
| 32 | memcpy( dst, src, 0x400000 ); | |
| 32 | memcpy( &dst[0], src, 0x400000 ); | |
| 33 | 33 | for( i=0; i<8; ++i ) |
| 34 | 34 | { |
| 35 | memcpy( src+i*0x80000, dst | |
| 35 | memcpy( src+i*0x80000, &dst[sec[i]], 0x80000 ); | |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| r245687 | r245688 | |
| 43 | 43 | static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; |
| 44 | 44 | UINT8 *src = cpurom+0x100000; |
| 45 | 45 | dynamic_buffer dst(0x400000); |
| 46 | memcpy( dst, src, 0x400000); | |
| 46 | memcpy( &dst[0], src, 0x400000); | |
| 47 | 47 | for( i=0; i<8; ++i ) |
| 48 | 48 | { |
| 49 | memcpy( src+i*0x80000, dst | |
| 49 | memcpy( src+i*0x80000, &dst[sec[i]], 0x80000 ); | |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| r245687 | r245688 | |
| 58 | 58 | UINT8 *src = cpurom; |
| 59 | 59 | dynamic_buffer dst(0x800000); |
| 60 | 60 | |
| 61 | memcpy( dst, src, 0x800000 ); | |
| 61 | memcpy( &dst[0], src, 0x800000 ); | |
| 62 | 62 | for( i=0; i<16; ++i ) |
| 63 | 63 | { |
| 64 | memcpy( src+i*0x80000, dst | |
| 64 | memcpy( src+i*0x80000, &dst[sec[i]], 0x80000 ); | |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| r245687 | r245688 | |
| 73 | 73 | UINT8 *src = cpurom; |
| 74 | 74 | dynamic_buffer dst(0x800000); |
| 75 | 75 | |
| 76 | memcpy( dst, src, 0x800000 ); | |
| 76 | memcpy( &dst[0], src, 0x800000 ); | |
| 77 | 77 | for( i=0; i<16; ++i ) |
| 78 | 78 | { |
| 79 | memcpy( src+i*0x80000, dst | |
| 79 | memcpy( src+i*0x80000, &dst[sec[i]], 0x80000 ); | |
| 80 | 80 | } |
| 81 | 81 | } |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | static const UINT32 sec[]={0x000000,0x100000,0x000004,0x100004,0x10000a,0x00000a,0x10000e,0x00000e}; |
| 34 | 34 | static const UINT32 pos[]={0x000,0x004,0x00a,0x00e}; |
| 35 | 35 | |
| 36 | memcpy( dst, src, 0x200000); | |
| 36 | memcpy( &dst[0], src, 0x200000); | |
| 37 | 37 | for( i=0x800; i<0x100000; i+=0x200 ) |
| 38 | 38 | { |
| 39 | 39 | for( j=0; j<0x100; j+=0x10 ) |
| r245687 | r245688 | |
|---|---|---|
| 49 | 49 | static const int sec[] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD }; |
| 50 | 50 | |
| 51 | 51 | for (i = 0; i < 8; i++){ |
| 52 | memcpy (dst | |
| 52 | memcpy (&dst[i * 0x20000], src + sec[i] * 0x20000, 0x20000); | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | memcpy (dst + 0x0007A6, src + 0x0407A6, 0x000006); | |
| 56 | memcpy (dst + 0x0007C6, src + 0x0407C6, 0x000006); | |
| 57 | memcpy (dst + 0x0007E6, src + 0x0407E6, 0x000006); | |
| 58 | memcpy (dst + 0x090000, src + 0x040000, 0x004000); | |
| 59 | memcpy (dst + 0x100000, src + 0x200000, 0x400000); | |
| 60 | memcpy (src, dst, 0x600000); | |
| 55 | memcpy (&dst[0x0007A6], src + 0x0407A6, 0x000006); | |
| 56 | memcpy (&dst[0x0007C6], src + 0x0407C6, 0x000006); | |
| 57 | memcpy (&dst[0x0007E6], src + 0x0407E6, 0x000006); | |
| 58 | memcpy (&dst[0x090000], src + 0x040000, 0x004000); | |
| 59 | memcpy (&dst[0x100000], src + 0x200000, 0x400000); | |
| 60 | memcpy (src, &dst[0], 0x600000); | |
| 61 | 61 | |
| 62 | 62 | for (i = 0x90000/2; i < 0x94000/2; i++){ |
| 63 | 63 | if (((rom[i]&0xFFBF) == 0x4EB9 || rom[i] == 0x43F9) && !rom[i + 1]) |
| r245687 | r245688 | |
|---|---|---|
| 23 | 23 | return mask; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | UINT32 neogeohelper_optimize_sprite_data(d | |
| 26 | UINT32 neogeohelper_optimize_sprite_data(std::vector<UINT8> &spritegfx, UINT8* region_sprites, UINT32 region_sprites_size) | |
| 27 | 27 | { |
| 28 | 28 | /* convert the sprite graphics data into a format that |
| 29 | 29 | allows faster blitting */ |
| r245687 | r245688 | |
| 36 | 36 | UINT32 spritegfx_address_mask = mask; |
| 37 | 37 | |
| 38 | 38 | src = region_sprites; |
| 39 | dest = spritegfx; | |
| 39 | dest = &spritegfx[0]; | |
| 40 | 40 | |
| 41 | 41 | for (unsigned i = 0; i < region_sprites_size; i += 0x80, src += 0x80) |
| 42 | 42 | { |
| r245687 | r245688 | |
|---|---|---|
| 1 | 1 | |
| 2 | extern UINT32 neogeohelper_optimize_sprite_data(d | |
| 2 | extern UINT32 neogeohelper_optimize_sprite_data(std::vector<UINT8> &spritegfx, UINT8* region_sprites, UINT32 region_sprites_size); |
| r245687 | r245688 | |
|---|---|---|
| 23 | 23 | virtual void decrypt_all(DECRYPT_ALL_PARAMS) { }; |
| 24 | 24 | virtual int get_fixed_bank_type(void) { return 0; } |
| 25 | 25 | |
| 26 | void rom_alloc(UINT32 size) { if (m_rom == NULL) m_rom.resize(size/sizeof(UINT16)); } | |
| 27 | UINT16* get_rom_base() { return m_rom; } | |
| 28 | UINT32 get_rom_size() { return m_rom.bytes(); } | |
| 26 | void rom_alloc(UINT32 size) { m_rom.resize(size/sizeof(UINT16)); } | |
| 27 | UINT16* get_rom_base() { return &m_rom[0]; } | |
| 28 | UINT32 get_rom_size() { return m_rom.size()*sizeof(UINT16); } | |
| 29 | 29 | |
| 30 | void fixed_alloc(UINT32 size) { if (m_fixed == NULL) m_fixed.resize(size/sizeof(UINT8)); } | |
| 31 | UINT8* get_fixed_base() { return m_fixed; } | |
| 32 | UINT32 get_fixed_size() { return m_fixed.bytes(); } | |
| 30 | void fixed_alloc(UINT32 size) { m_fixed.resize(size); } | |
| 31 | UINT8* get_fixed_base() { return &m_fixed[0]; } | |
| 32 | UINT32 get_fixed_size() { return m_fixed.size(); } | |
| 33 | 33 | |
| 34 | void audio_alloc(UINT32 size) { if (m_audio == NULL) m_audio.resize(size/sizeof(UINT8)); } | |
| 35 | UINT8* get_audio_base() { return m_audio; } | |
| 36 | UINT32 get_audio_size() { return m_audio.bytes(); } | |
| 34 | void audio_alloc(UINT32 size) { m_audio.resize(size); } | |
| 35 | UINT8* get_audio_base() { return &m_audio[0]; } | |
| 36 | UINT32 get_audio_size() { return m_audio.size(); } | |
| 37 | 37 | |
| 38 | void audiocrypt_alloc(UINT32 size) { if (m_audiocrypt == NULL) m_audiocrypt.resize(size/sizeof(UINT8)); } | |
| 39 | UINT8* get_audiocrypt_base() { return m_audiocrypt; } | |
| 40 | UINT32 get_audiocrypt_size() { return m_audiocrypt.bytes(); } | |
| 38 | void audiocrypt_alloc(UINT32 size) { m_audiocrypt.resize(size); } | |
| 39 | UINT8* get_audiocrypt_base() { return &m_audiocrypt[0]; } | |
| 40 | UINT32 get_audiocrypt_size() { return m_audiocrypt.size(); } | |
| 41 | 41 | |
| 42 | void sprites_alloc(UINT32 size) { if (m_sprites == NULL) m_sprites.resize(size/sizeof(UINT8)); } | |
| 43 | UINT8* get_sprites_base() { return m_sprites; } | |
| 44 | UINT32 get_sprites_size() { return m_sprites.bytes(); } | |
| 45 | UINT8* get_sprites_optimized() { return m_sprites_optimized; } | |
| 42 | void sprites_alloc(UINT32 size) { m_sprites.resize(size); } | |
| 43 | UINT8* get_sprites_base() { return &m_sprites[0]; } | |
| 44 | UINT32 get_sprites_size() { return m_sprites.size(); } | |
| 45 | UINT8* get_sprites_optimized() { return &m_sprites_optimized[0]; } | |
| 46 | 46 | UINT32 get_sprites_addrmask() { return m_sprite_gfx_address_mask; } |
| 47 | d | |
| 47 | std::vector<UINT8>& get_sprites_optimized_arr() { return m_sprites_optimized; } | |
| 48 | 48 | |
| 49 | void ym_alloc(UINT32 size) { if (m_ym == NULL) m_ym.resize(size/sizeof(UINT8)); } | |
| 50 | UINT8* get_ym_base() { return m_ym; } | |
| 51 | UINT32 get_ym_size() { return m_ym.bytes(); } | |
| 49 | void ym_alloc(UINT32 size) { m_ym.resize(size); } | |
| 50 | UINT8* get_ym_base() { return &m_ym[0]; } | |
| 51 | UINT32 get_ym_size() { return m_ym.size(); } | |
| 52 | 52 | |
| 53 | void ymdelta_alloc(UINT32 size) { if (m_ymdelta == NULL) m_ymdelta.resize(size/sizeof(UINT8)); } | |
| 54 | UINT8* get_ymdelta_base() { return m_ymdelta; } | |
| 55 | UINT32 get_ymdelta_size() { return m_ymdelta.bytes(); } | |
| 53 | void ymdelta_alloc(UINT32 size) { m_ymdelta.resize(size); } | |
| 54 | UINT8* get_ymdelta_base() { return &m_ymdelta[0]; } | |
| 55 | UINT32 get_ymdelta_size() { return m_ymdelta.size(); } | |
| 56 | 56 | |
| 57 | dynamic_array<UINT16> m_rom; | |
| 58 | dynamic_array<UINT8> m_fixed; | |
| 59 | dynamic_array<UINT8> m_sprites; | |
| 60 | dynamic_array<UINT8> m_sprites_optimized; | |
| 61 | dynamic_array<UINT8> m_audio; | |
| 62 | dynamic_array<UINT8> m_ym; | |
| 63 | dynamic_array<UINT8> m_ymdelta; | |
| 57 | std::vector<UINT16> m_rom; | |
| 58 | std::vector<UINT8> m_fixed; | |
| 59 | std::vector<UINT8> m_sprites; | |
| 60 | std::vector<UINT8> m_sprites_optimized; | |
| 61 | std::vector<UINT8> m_audio; | |
| 62 | std::vector<UINT8> m_ym; | |
| 63 | std::vector<UINT8> m_ymdelta; | |
| 64 | 64 | |
| 65 | 65 | UINT32 m_sprite_gfx_address_mask; |
| 66 | 66 | |
| r245687 | r245688 | |
| 68 | 68 | |
| 69 | 69 | protected: |
| 70 | 70 | // internal state |
| 71 | d | |
| 71 | std::vector<UINT8> m_audiocrypt; | |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | }; |
| r245687 | r245688 | |
|---|---|---|
| 45 | 45 | virtual DECLARE_READ16_MEMBER(read_rom); |
| 46 | 46 | |
| 47 | 47 | UINT16* get_rom_base() { if (m_cart) { return m_cart->get_rom_base(); } else { return 0; } } |
| 48 | UINT32 get_rom_size() { if (m_cart) { return m_cart-> | |
| 48 | UINT32 get_rom_size() { if (m_cart) { return m_cart->get_rom_size()*sizeof(UINT16); } else { return 0; } } | |
| 49 | 49 | UINT8* get_fixed_base() { if (m_cart) { return m_cart->get_fixed_base(); } else { return 0; } } |
| 50 | UINT32 get_fixed_size() { if (m_cart) { return m_cart-> | |
| 50 | UINT32 get_fixed_size() { if (m_cart) { return m_cart->get_fixed_size(); } else { return 0; } } | |
| 51 | 51 | UINT8* get_sprites_base() { if (m_cart) { return m_cart->get_sprites_base(); } else { return 0; } } |
| 52 | 52 | UINT32 get_sprites_size() { if (m_cart) { return m_cart->get_sprites_size(); } else { return 0; } } |
| 53 | 53 | UINT8* get_sprites_optimized() { if (m_cart) { return m_cart->get_sprites_optimized(); } else { return 0; } } |
| r245687 | r245688 | |
|---|---|---|
| 38 | 38 | |
| 39 | 39 | if( rom != NULL ) |
| 40 | 40 | { /* swap address lines on the whole ROMs */ |
| 41 | d | |
| 41 | std::vector<UINT16> buffer(value / 2); | |
| 42 | 42 | |
| 43 | 43 | for( i = 0; i < size / 2; i += ( value / 2 ) ) |
| 44 | 44 | { |
| 45 | memcpy( buffer, &rom[ i ], value ); | |
| 45 | memcpy( &buffer[0], &rom[ i ], value ); | |
| 46 | 46 | for( j = 0; j < (value / 2); j++ ) |
| 47 | 47 | { |
| 48 | 48 | rom[ i + j ] = buffer[ j ^ (value/4) ]; |
| r245687 | r245688 | |
| 75 | 75 | dynamic_buffer buf(0x1000000); |
| 76 | 76 | int i, j, d; |
| 77 | 77 | UINT8* src = ymrom; |
| 78 | memcpy(buf,src,0x1000000); | |
| 78 | memcpy(&buf[0],src,0x1000000); | |
| 79 | 79 | for (i=0;i<0x1000000;i++) |
| 80 | 80 | { |
| 81 | 81 | j=BITSWAP24(i,23,22,21,20,19,18,17,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16); |
| r245687 | r245688 | |
|---|---|---|
| 124 | 124 | rom[BYTE_XOR_LE(i+1)] = rom16&0xff; |
| 125 | 125 | rom[BYTE_XOR_LE(i+2)] = rom16>>8; |
| 126 | 126 | } |
| 127 | memcpy( buf, rom, rom_size ); | |
| 127 | memcpy( &buf[0], rom, rom_size ); | |
| 128 | 128 | for( i = 0; i < 0x0100000 / 0x10000; i++ ) |
| 129 | 129 | { |
| 130 | 130 | ofst = (i & 0xf0) + BITSWAP8( (i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2 ); |
| r245687 | r245688 | |
| 135 | 135 | ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00700) + (BITSWAP8( ((i & 0x0ff000) >> 12), 5, 4, 7, 6, 1, 0, 3, 2 ) << 12); |
| 136 | 136 | memcpy( &rom[ i ], &buf[ ofst ], 0x100 ); |
| 137 | 137 | } |
| 138 | memcpy( buf, rom, rom_size ); | |
| 138 | memcpy( &buf[0], rom, rom_size ); | |
| 139 | 139 | memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); |
| 140 | 140 | memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 ); |
| 141 | 141 | } |
| r245687 | r245688 | |
| 167 | 167 | rom[BYTE_XOR_LE(i+1)] = rom16&0xff; |
| 168 | 168 | rom[BYTE_XOR_LE(i+2)] = rom16>>8; |
| 169 | 169 | } |
| 170 | memcpy( buf, rom, rom_size ); | |
| 170 | memcpy( &buf[0], rom, rom_size ); | |
| 171 | 171 | for( i = 0; i < 0x0100000 / 0x10000; i++ ) |
| 172 | 172 | { |
| 173 | 173 | ofst = (i & 0xf0) + BITSWAP8( (i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1 ); |
| r245687 | r245688 | |
| 178 | 178 | ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00a00) + (BITSWAP8( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12); |
| 179 | 179 | memcpy( &rom[ i ], &buf[ ofst ], 0x100 ); |
| 180 | 180 | } |
| 181 | memcpy( buf, rom, rom_size ); | |
| 181 | memcpy( &buf[0], rom, rom_size ); | |
| 182 | 182 | memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); |
| 183 | 183 | memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 ); |
| 184 | 184 | } |
| r245687 | r245688 | |
|---|---|---|
| 150 | 150 | dynamic_buffer rom(len); |
| 151 | 151 | UINT8 mapper; |
| 152 | 152 | |
| 153 | core_fread(m_file, rom, len); | |
| 153 | core_fread(m_file, &rom[0], len); | |
| 154 | 154 | |
| 155 | 155 | mapper = (rom[6] & 0xf0) >> 4; |
| 156 | 156 | mapper |= rom[7] & 0xf0; |
| r245687 | r245688 | |
|---|---|---|
| 355 | 355 | { |
| 356 | 356 | LOG_MMC(("lz93d50 write_m, offset: %04x, data: %02x\n", offset, data)); |
| 357 | 357 | |
| 358 | if ( | |
| 358 | if (m_battery.empty() && m_prgram.empty()) | |
| 359 | 359 | fcg_write(space, offset & 0x0f, data, mem_mask); |
| 360 | else if (m_battery) | |
| 360 | else if (!m_battery.empty()) | |
| 361 | 361 | m_battery[offset] = data; |
| 362 | 362 | else |
| 363 | 363 | m_prgram[offset] = data; |
| r245687 | r245688 | |
| 447 | 447 | READ8_MEMBER(nes_fjump2_device::read_m) |
| 448 | 448 | { |
| 449 | 449 | LOG_MMC(("fjump2 read_m, offset: %04x\n", offset)); |
| 450 | return m_battery[offset & (m_battery. | |
| 450 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | WRITE8_MEMBER(nes_fjump2_device::write_m) |
| 454 | 454 | { |
| 455 | 455 | LOG_MMC(("fjump2 write_m, offset: %04x, data: %02x\n", offset, data)); |
| 456 | m_battery[offset & (m_battery. | |
| 456 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | WRITE8_MEMBER(nes_fjump2_device::write_h) |
| r245687 | r245688 | |
|---|---|---|
| 1537 | 1537 | |
| 1538 | 1538 | if (offset < 0x0800) |
| 1539 | 1539 | return m_prg[0x8000 + offset]; |
| 1540 | else if (m_prgram && offset >= 0x1000 && offset < 0x1800) // WRAM only in these 2K | |
| 1540 | else if (!m_prgram.empty() && offset >= 0x1000 && offset < 0x1800) // WRAM only in these 2K | |
| 1541 | 1541 | return m_prgram[offset & 0x7ff]; |
| 1542 | 1542 | |
| 1543 | 1543 | return ((offset + 0x6000) & 0xff00) >> 8; |
| r245687 | r245688 | |
| 1547 | 1547 | { |
| 1548 | 1548 | LOG_MMC(("mmalee write_m, offset: %04x, data: %02x\n", offset, data)); |
| 1549 | 1549 | |
| 1550 | if (m_prgram && offset >= 0x1000 && offset < 0x1800) // WRAM only in these 2K | |
| 1550 | if (!m_prgram.empty() && offset >= 0x1000 && offset < 0x1800) // WRAM only in these 2K | |
| 1551 | 1551 | m_prgram[offset & 0x7ff] = data; |
| 1552 | 1552 | } |
| 1553 | 1553 |
| r245687 | r245688 | |
|---|---|---|
| 288 | 288 | { |
| 289 | 289 | LOG_MMC(("VRC-2 read_m, offset: %04x\n", offset)); |
| 290 | 290 | |
| 291 | if (m_battery) | |
| 292 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 293 | else if (m_prgram) | |
| 294 | return m_prgram[offset & (m_prgram.count() - 1)]; | |
| 291 | if (!m_battery.empty()) | |
| 292 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 293 | else if (!m_prgram.empty()) | |
| 294 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 295 | 295 | else // sort of protection? it returns open bus in $7000-$7fff and (open bus & 0xfe) | m_latch in $6000-$6fff |
| 296 | 296 | return (offset < 0x1000) ? ((m_open_bus & 0xfe) | (m_latch & 1)) : m_open_bus; |
| 297 | 297 | } |
| r245687 | r245688 | |
| 300 | 300 | { |
| 301 | 301 | LOG_MMC(("VRC-2 write_m, offset: %04x, data: %02x\n", offset, data)); |
| 302 | 302 | |
| 303 | if (m_battery) | |
| 304 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 305 | else if (m_prgram) | |
| 306 | m_prgram[offset & (m_prgram.count() - 1)] = data; | |
| 303 | if (!m_battery.empty()) | |
| 304 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 305 | else if (!m_prgram.empty()) | |
| 306 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 307 | 307 | else if (offset < 0x1000) |
| 308 | 308 | m_latch = data; |
| 309 | 309 | } |
| r245687 | r245688 | |
|---|---|---|
| 273 | 273 | |
| 274 | 274 | if (!BIT(m_reg[3], 4)) // WRAM enabled |
| 275 | 275 | { |
| 276 | if (m_battery) | |
| 277 | m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)] = data; | |
| 278 | if (m_prgram) | |
| 279 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)] = data; | |
| 276 | if (!m_battery.empty()) | |
| 277 | m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)] = data; | |
| 278 | if (!m_prgram.empty()) | |
| 279 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)] = data; | |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| r245687 | r245688 | |
| 287 | 287 | |
| 288 | 288 | if (!BIT(m_reg[3], 4)) // WRAM enabled |
| 289 | 289 | { |
| 290 | if (m_battery) | |
| 291 | return m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)]; | |
| 292 | if (m_prgram) | |
| 293 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)]; | |
| 290 | if (!m_battery.empty()) | |
| 291 | return m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)]; | |
| 292 | if (!m_prgram.empty()) | |
| 293 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)]; | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | return m_open_bus; // open bus |
| r245687 | r245688 | |
| 305 | 305 | if (!BIT(m_reg[3], 4)) // WRAM enabled |
| 306 | 306 | { |
| 307 | 307 | if (type) |
| 308 | m_battery[offset & (m_battery. | |
| 308 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 309 | 309 | else |
| 310 | m_prgram[offset & (m_prgram. | |
| 310 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| r245687 | r245688 | |
| 319 | 319 | if (!BIT(m_reg[3], 4)) // WRAM enabled |
| 320 | 320 | { |
| 321 | 321 | if (type) |
| 322 | return m_battery[offset & (m_battery. | |
| 322 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 323 | 323 | else |
| 324 | return m_prgram[offset & (m_prgram. | |
| 324 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | return m_open_bus; // open bus |
| r245687 | r245688 | |
| 333 | 333 | UINT8 bank = (m_reg[1] >> 2) & 3; |
| 334 | 334 | LOG_MMC(("sxrom_a write_m, offset: %04x, data: %02x\n", offset, data)); |
| 335 | 335 | |
| 336 | if (m_battery) | |
| 337 | m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)] = data; | |
| 338 | if (m_prgram) | |
| 339 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)] = data; | |
| 336 | if (!m_battery.empty()) | |
| 337 | m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)] = data; | |
| 338 | if (!m_prgram.empty()) | |
| 339 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)] = data; | |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | READ8_MEMBER(nes_sxrom_a_device::read_m) |
| r245687 | r245688 | |
| 344 | 344 | UINT8 bank = (m_reg[1] >> 2) & 3; |
| 345 | 345 | LOG_MMC(("sxrom_a read_m, offset: %04x\n", offset)); |
| 346 | 346 | |
| 347 | if (m_battery) | |
| 348 | return m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)]; | |
| 349 | if (m_prgram) | |
| 350 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)]; | |
| 347 | if (!m_battery.empty()) | |
| 348 | return m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)]; | |
| 349 | if (!m_prgram.empty()) | |
| 350 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)]; | |
| 351 | 351 | |
| 352 | 352 | return m_open_bus; // open bus |
| 353 | 353 | } |
| r245687 | r245688 | |
| 358 | 358 | LOG_MMC(("sorom_a write_m, offset: %04x, data: %02x\n", offset, data)); |
| 359 | 359 | |
| 360 | 360 | if (type) |
| 361 | m_battery[offset & (m_battery. | |
| 361 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 362 | 362 | else |
| 363 | m_prgram[offset & (m_prgram. | |
| 363 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | READ8_MEMBER(nes_sorom_a_device::read_m) |
| r245687 | r245688 | |
| 369 | 369 | LOG_MMC(("sorom_a read_m, offset: %04x\n", offset)); |
| 370 | 370 | |
| 371 | 371 | if (type) |
| 372 | return m_battery[offset & (m_battery. | |
| 372 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 373 | 373 | else |
| 374 | return m_prgram[offset & (m_prgram. | |
| 374 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 375 | 375 | } |
| r245687 | r245688 | |
|---|---|---|
| 320 | 320 | |
| 321 | 321 | if (BIT(m_wram_protect, 7) && !BIT(m_wram_protect, 6)) |
| 322 | 322 | { |
| 323 | if (m_battery) | |
| 324 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 325 | if (m_prgram) | |
| 326 | m_prgram[offset & (m_prgram.count() - 1)] = data; | |
| 323 | if (!m_battery.empty()) | |
| 324 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 325 | if (!m_prgram.empty()) | |
| 326 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
| r245687 | r245688 | |
| 333 | 333 | |
| 334 | 334 | if (BIT(m_wram_protect, 7)) |
| 335 | 335 | { |
| 336 | if (m_battery) | |
| 337 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 338 | if (m_prgram) | |
| 339 | return m_prgram[offset & (m_prgram.count() - 1)]; | |
| 336 | if (!m_battery.empty()) | |
| 337 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 338 | if (!m_prgram.empty()) | |
| 339 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | return m_open_bus; // open bus |
| r245687 | r245688 | |
|---|---|---|
| 2077 | 2077 | |
| 2078 | 2078 | /* This bit is the "register lock". Once register are locked, writes go to WRAM |
| 2079 | 2079 | and there is no way to unlock them (except by resetting the machine) */ |
| 2080 | if ((m_reg[3] & 0x40) && m_prgram) | |
| 2080 | if ((m_reg[3] & 0x40) && !m_prgram.empty()) | |
| 2081 | 2081 | m_prgram[offset] = data; |
| 2082 | 2082 | else |
| 2083 | 2083 | { |
| r245687 | r245688 | |
|---|---|---|
| 622 | 622 | READ8_MEMBER(nes_exrom_device::read_m) |
| 623 | 623 | { |
| 624 | 624 | LOG_MMC(("exrom read_m, offset: %04x\n", offset)); |
| 625 | if (m_battery && m_prgram) // 2 chips present: first is BWRAM, second is WRAM | |
| 625 | if (!m_battery.empty() && !m_prgram.empty()) // 2 chips present: first is BWRAM, second is WRAM | |
| 626 | 626 | { |
| 627 | 627 | if (m_wram_base & 0x04) |
| 628 | return m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram. | |
| 628 | return m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram.size() - 1)]; | |
| 629 | 629 | else |
| 630 | return m_battery[(offset + (m_wram_base & 0x03) * 0x2000) & (m_battery. | |
| 630 | return m_battery[(offset + (m_wram_base & 0x03) * 0x2000) & (m_battery.size() - 1)]; | |
| 631 | 631 | } |
| 632 | else if (m_prgram) // 1 chip, WRAM | |
| 633 | return m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram.count() - 1)]; | |
| 634 | else if (m_battery) // 1 chip, BWRAM | |
| 635 | return m_battery[(offset + (m_wram_base & 0x03) * 0x2000) & (m_battery.count() - 1)]; | |
| 632 | else if (!m_prgram.empty()) // 1 chip, WRAM | |
| 633 | return m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram.size() - 1)]; | |
| 634 | else if (!m_battery.empty()) // 1 chip, BWRAM | |
| 635 | return m_battery[(offset + (m_wram_base & 0x03) * 0x2000) & (m_battery.size() - 1)]; | |
| 636 | 636 | else |
| 637 | 637 | return m_open_bus; |
| 638 | 638 | } |
| r245687 | r245688 | |
| 643 | 643 | if (m_wram_protect_1 != 0x02 || m_wram_protect_2 != 0x01) |
| 644 | 644 | return; |
| 645 | 645 | |
| 646 | if (m_battery && m_wram_base < 4) | |
| 647 | m_battery[(offset + m_wram_base * 0x2000) & (m_battery.count() - 1)] = data; | |
| 648 | else if (m_prgram) | |
| 649 | m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram.count() - 1)] = data; | |
| 646 | if (!m_battery.empty() && m_wram_base < 4) | |
| 647 | m_battery[(offset + m_wram_base * 0x2000) & (m_battery.size() - 1)] = data; | |
| 648 | else if (!m_prgram.empty()) | |
| 649 | m_prgram[(offset + (m_wram_base & 0x03) * 0x2000) & (m_prgram.size() - 1)] = data; | |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | // some games (e.g. Bandit Kings of Ancient China) write to PRG-RAM through 0x8000-0xdfff |
| r245687 | r245688 | |
| 657 | 657 | |
| 658 | 658 | if (bank < 3 && offset >= bank * 0x2000 && offset < (bank + 1) * 0x2000 && m_prg_ram_mapped[bank]) |
| 659 | 659 | { |
| 660 | if (m_battery && m_ram_hi_banks[bank] < 4) | |
| 661 | return m_battery[((m_ram_hi_banks[bank] * 0x2000) + (offset & 0x1fff)) & (m_battery.count() - 1)]; | |
| 662 | else if (m_prgram) | |
| 663 | return m_prgram[(((m_ram_hi_banks[bank] & 3) * 0x2000) + (offset & 0x1fff)) & (m_prgram.count() - 1)]; | |
| 660 | if (!m_battery.empty() && m_ram_hi_banks[bank] < 4) | |
| 661 | return m_battery[((m_ram_hi_banks[bank] * 0x2000) + (offset & 0x1fff)) & (m_battery.size() - 1)]; | |
| 662 | else if (!m_prgram.empty()) | |
| 663 | return m_prgram[(((m_ram_hi_banks[bank] & 3) * 0x2000) + (offset & 0x1fff)) & (m_prgram.size() - 1)]; | |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | return hi_access_rom(offset); |
| r245687 | r245688 | |
| 673 | 673 | if (m_wram_protect_1 != 0x02 || m_wram_protect_2 != 0x01 || bank == 3 || !m_prg_ram_mapped[bank]) |
| 674 | 674 | return; |
| 675 | 675 | |
| 676 | if (m_battery && m_ram_hi_banks[bank] < 4) | |
| 677 | m_battery[((m_ram_hi_banks[bank] * 0x2000) + (offset & 0x1fff)) & (m_battery.count() - 1)] = data; | |
| 678 | else if (m_prgram) | |
| 679 | m_prgram[(((m_ram_hi_banks[bank] & 3) * 0x2000) + (offset & 0x1fff)) & (m_prgram.count() - 1)] = data; | |
| 676 | if (!m_battery.empty() && m_ram_hi_banks[bank] < 4) | |
| 677 | m_battery[((m_ram_hi_banks[bank] * 0x2000) + (offset & 0x1fff)) & (m_battery.size() - 1)] = data; | |
| 678 | else if (!m_prgram.empty()) | |
| 679 | m_prgram[(((m_ram_hi_banks[bank] & 3) * 0x2000) + (offset & 0x1fff)) & (m_prgram.size() - 1)] = data; | |
| 680 | 680 | } |
| r245687 | r245688 | |
|---|---|---|
| 512 | 512 | { |
| 513 | 513 | // the only game supporting this is Family Circuit '91, and it has 2KB of battery |
| 514 | 514 | // but it's mirrored up to 8KB (see Sprint Race -> Back Up menu breakage if not) |
| 515 | if (m_battery && !m_wram_protect) | |
| 516 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 515 | if (!m_battery.empty() && !m_wram_protect) | |
| 516 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 517 | 517 | |
| 518 | 518 | return m_open_bus; // open bus |
| 519 | 519 | } |
| r245687 | r245688 | |
| 522 | 522 | { |
| 523 | 523 | // the only game supporting this is Family Circuit '91, and it has 2KB of battery |
| 524 | 524 | // but it's mirrored up to 8KB (see Sprint Race -> Back Up menu breakage if not) |
| 525 | if (m_battery && !m_wram_protect) | |
| 526 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 525 | if (!m_battery.empty() && !m_wram_protect) | |
| 526 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | WRITE8_MEMBER(nes_namcot175_device::write_h) |
| r245687 | r245688 | |
| 595 | 595 | |
| 596 | 596 | READ8_MEMBER(nes_namcot163_device::read_m) |
| 597 | 597 | { |
| 598 | if (m_battery && offset < m_battery.count()) | |
| 599 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 598 | if (!m_battery.empty() && offset < m_battery.size()) | |
| 599 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 600 | 600 | |
| 601 | 601 | return m_open_bus; // open bus |
| 602 | 602 | } |
| r245687 | r245688 | |
| 605 | 605 | { |
| 606 | 606 | // the pcb can separately protect each 2KB chunk of the external wram from writes |
| 607 | 607 | int bank = (offset & 0x1800) >> 11; |
| 608 | if (m_battery && !BIT(m_wram_protect, bank)) | |
| 609 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 608 | if (!m_battery.empty() && !BIT(m_wram_protect, bank)) | |
| 609 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | WRITE8_MEMBER(nes_namcot163_device::write_l) |
| r245687 | r245688 | |
|---|---|---|
| 797 | 797 | { |
| 798 | 798 | UINT32 tot_size = battery_size + mapper_sram_size; |
| 799 | 799 | dynamic_buffer temp_nvram(tot_size); |
| 800 | battery_load(temp_nvram, tot_size, 0x00); | |
| 800 | battery_load(&temp_nvram[0], tot_size, 0x00); | |
| 801 | 801 | if (battery_size) |
| 802 | 802 | { |
| 803 | 803 | //printf("here %d\n", battery_size); |
| 804 | 804 | m_cart->battery_alloc(battery_size); |
| 805 | memcpy(m_cart->get_battery_base(), temp_nvram, battery_size); | |
| 805 | memcpy(m_cart->get_battery_base(), &temp_nvram[0], battery_size); | |
| 806 | 806 | } |
| 807 | 807 | if (mapper_sram_size) |
| 808 | memcpy(m_cart->get_mapper_sram_base(), temp_nvram | |
| 808 | memcpy(m_cart->get_mapper_sram_base(), &temp_nvram[battery_size], m_cart->get_mapper_sram_size()); | |
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 |
| r245687 | r245688 | |
|---|---|---|
| 588 | 588 | // and we use the info from xml here to prepare a default NVRAM |
| 589 | 589 | dynamic_buffer default_nvram(tot_size); |
| 590 | 590 | if (battery_size) |
| 591 | memcpy(default_nvram, get_software_region("bwram"), battery_size); | |
| 591 | memcpy(&default_nvram[0], get_software_region("bwram"), battery_size); | |
| 592 | 592 | if (mapper_sram_size) |
| 593 | memset(default_nvram | |
| 593 | memset(&default_nvram[battery_size], 0, mapper_sram_size); | |
| 594 | 594 | |
| 595 | 595 | // load battery (using default if no battery exists) |
| 596 | battery_load(temp_nvram, tot_size, default_nvram); | |
| 596 | battery_load(&temp_nvram[0], tot_size, &default_nvram[0]); | |
| 597 | 597 | |
| 598 | 598 | // copy battery into PCB arrays |
| 599 | 599 | if (battery_size) |
| 600 | 600 | { |
| 601 | 601 | m_cart->battery_alloc(battery_size); |
| 602 | memcpy(m_cart->get_battery_base(), temp_nvram, battery_size); | |
| 602 | memcpy(m_cart->get_battery_base(), &temp_nvram[0], battery_size); | |
| 603 | 603 | } |
| 604 | 604 | if (mapper_sram_size) |
| 605 | memcpy(m_cart->get_mapper_sram_base(), temp_nvram | |
| 605 | memcpy(m_cart->get_mapper_sram_base(), &temp_nvram[battery_size], mapper_sram_size); | |
| 606 | 606 | } |
| 607 | 607 | } |
| r245687 | r245688 | |
|---|---|---|
| 368 | 368 | |
| 369 | 369 | inline void device_nes_cart_interface::chr_sanity_check( int source ) |
| 370 | 370 | { |
| 371 | if (source == CHRRAM && m_vram | |
| 371 | if (source == CHRRAM && m_vram.empty()) | |
| 372 | 372 | fatalerror("CHRRAM bankswitch with no VRAM\n"); |
| 373 | 373 | |
| 374 | 374 | if (source == CHRROM && m_vrom == NULL) |
| r245687 | r245688 | |
| 484 | 484 | switch (source) |
| 485 | 485 | { |
| 486 | 486 | case CART_NTRAM: |
| 487 | base_ptr = m_ext_ntram; | |
| 487 | base_ptr = &m_ext_ntram[0]; | |
| 488 | 488 | break; |
| 489 | 489 | case VROM: |
| 490 | 490 | bank &= ((m_vrom_chunks << 3) - 1); |
| r245687 | r245688 | |
| 546 | 546 | break; |
| 547 | 547 | |
| 548 | 548 | case PPU_MIRROR_4SCREEN: |
| 549 | if ( | |
| 549 | if (m_ext_ntram.empty()) fatalerror("4-screen mirroring without on-cart NTRAM!\n"); | |
| 550 | 550 | set_nt_page(0, CART_NTRAM, 0, 1); |
| 551 | 551 | set_nt_page(1, CART_NTRAM, 1, 1); |
| 552 | 552 | set_nt_page(2, CART_NTRAM, 2, 1); |
| r245687 | r245688 | |
| 643 | 643 | |
| 644 | 644 | READ8_MEMBER(device_nes_cart_interface::read_m) |
| 645 | 645 | { |
| 646 | if (m_battery) | |
| 647 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 648 | if (m_prgram) | |
| 649 | return m_prgram[offset & (m_prgram.count() - 1)]; | |
| 646 | if (!m_battery.empty()) | |
| 647 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 648 | if (!m_prgram.empty()) | |
| 649 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 650 | 650 | |
| 651 | 651 | return m_open_bus; |
| 652 | 652 | } |
| r245687 | r245688 | |
| 657 | 657 | |
| 658 | 658 | WRITE8_MEMBER(device_nes_cart_interface::write_m) |
| 659 | 659 | { |
| 660 | if (m_battery) | |
| 661 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 662 | if (m_prgram) | |
| 663 | m_prgram[offset & (m_prgram.count() - 1)] = data; | |
| 660 | if (!m_battery.empty()) | |
| 661 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 662 | if (!m_prgram.empty()) | |
| 663 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | WRITE8_MEMBER(device_nes_cart_interface::write_h) |
| r245687 | r245688 | |
| 709 | 709 | set_nt_mirroring(m_mirroring); |
| 710 | 710 | |
| 711 | 711 | // save the on-cart RAM pointers |
| 712 | if (m_prgram. | |
| 712 | if (!m_prgram.empty()) | |
| 713 | 713 | device().save_item(NAME(m_prgram)); |
| 714 | if (m_vram. | |
| 714 | if (!m_vram.empty()) | |
| 715 | 715 | device().save_item(NAME(m_vram)); |
| 716 | if (m_battery. | |
| 716 | if (!m_battery.empty()) | |
| 717 | 717 | device().save_item(NAME(m_battery)); |
| 718 | 718 | } |
| 719 | 719 | |
| r245687 | r245688 | |
| 888 | 888 | UINT32 tot_size = m_cart->get_battery_size() + m_cart->get_mapper_sram_size(); |
| 889 | 889 | dynamic_buffer temp_nvram(tot_size); |
| 890 | 890 | if (m_cart->get_battery_size()) |
| 891 | memcpy(temp_nvram, m_cart->get_battery_base(), m_cart->get_battery_size()); | |
| 891 | memcpy(&temp_nvram[0], m_cart->get_battery_base(), m_cart->get_battery_size()); | |
| 892 | 892 | if (m_cart->get_mapper_sram_size()) |
| 893 | memcpy(temp_nvram | |
| 893 | memcpy(&temp_nvram[m_cart->get_battery_size()], m_cart->get_mapper_sram_base(), m_cart->get_mapper_sram_size()); | |
| 894 | 894 | |
| 895 | battery_save(temp_nvram, tot_size); | |
| 895 | battery_save(&temp_nvram[0], tot_size); | |
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | } |
| r245687 | r245688 | |
| 920 | 920 | UINT32 len = core_fsize(m_file); |
| 921 | 921 | dynamic_buffer rom(len); |
| 922 | 922 | |
| 923 | core_fread(m_file, rom, len); | |
| 923 | core_fread(m_file, &rom[0], len); | |
| 924 | 924 | |
| 925 | 925 | if ((rom[0] == 'N') && (rom[1] == 'E') && (rom[2] == 'S')) |
| 926 | slot_string = get_default_card_ines(rom, len); | |
| 926 | slot_string = get_default_card_ines(&rom[0], len); | |
| 927 | 927 | |
| 928 | 928 | if ((rom[0] == 'U') && (rom[1] == 'N') && (rom[2] == 'I') && (rom[3] == 'F')) |
| 929 | slot_string = get_default_card_unif(rom, len); | |
| 929 | slot_string = get_default_card_unif(&rom[0], len); | |
| 930 | 930 | |
| 931 | 931 | clear(); |
| 932 | 932 |
| r245687 | r245688 | |
|---|---|---|
| 198 | 198 | void set_open_bus(UINT8 val) { m_open_bus = val; } |
| 199 | 199 | |
| 200 | 200 | UINT8* get_prg_base() { return m_prg; } |
| 201 | UINT8* get_prgram_base() { return m_prgram; } | |
| 201 | UINT8* get_prgram_base() { return &m_prgram[0]; } | |
| 202 | 202 | UINT8* get_vrom_base() { return m_vrom; } |
| 203 | UINT8* get_vram_base() { return m_vram; } | |
| 204 | UINT8* get_battery_base() { return m_battery; } | |
| 203 | UINT8* get_vram_base() { return &m_vram[0]; } | |
| 204 | UINT8* get_battery_base() { return &m_battery[0]; } | |
| 205 | 205 | UINT8* get_mapper_sram_base() { return m_mapper_sram; } |
| 206 | 206 | |
| 207 | 207 | UINT32 get_prg_size() { return m_prg_size; } |
| 208 | UINT32 get_prgram_size() { return m_prgram. | |
| 208 | UINT32 get_prgram_size() { return m_prgram.size(); } | |
| 209 | 209 | UINT32 get_vrom_size() { return m_vrom_size; } |
| 210 | UINT32 get_vram_size() { return m_vram.bytes(); } | |
| 211 | UINT32 get_battery_size() { return m_battery.bytes(); } | |
| 210 | UINT32 get_vram_size() { return m_vram.size(); } | |
| 211 | UINT32 get_battery_size() { return m_battery.size(); } | |
| 212 | 212 | UINT32 get_mapper_sram_size() { return m_mapper_sram_size; } |
| 213 | 213 | |
| 214 | 214 | virtual void ppu_latch(offs_t offset) {} |
| r245687 | r245688 | |
| 320 | 320 | void set_nt_page(int page, int source, int bank, int writable); |
| 321 | 321 | void set_nt_mirroring(int mirroring); |
| 322 | 322 | |
| 323 | d | |
| 323 | std::vector<UINT16> m_prg_bank_map; | |
| 324 | 324 | }; |
| 325 | 325 | |
| 326 | 326 | void nes_partialhash(hash_collection &dest, const unsigned char *data, unsigned long length, const char *functions); |
| r245687 | r245688 | |
|---|---|---|
| 467 | 467 | if (prg_size == 0x4000) |
| 468 | 468 | { |
| 469 | 469 | m_cart->prg_alloc(0x8000, tag()); |
| 470 | memcpy(m_cart->get_prg_base(), temp_prg, 0x4000); | |
| 470 | memcpy(m_cart->get_prg_base(), &temp_prg[0], 0x4000); | |
| 471 | 471 | memcpy(m_cart->get_prg_base() + 0x4000, m_cart->get_prg_base(), 0x4000); |
| 472 | 472 | } |
| 473 | 473 | else |
| 474 | 474 | { |
| 475 | 475 | m_cart->prg_alloc(prg_size, tag()); |
| 476 | memcpy(m_cart->get_prg_base(), temp_prg, prg_size); | |
| 476 | memcpy(m_cart->get_prg_base(), &temp_prg[0], prg_size); | |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | if (small_prg) // This is not supported yet, so warn users about this |
| r245687 | r245688 | |
| 482 | 482 | if (vrom_size) |
| 483 | 483 | { |
| 484 | 484 | m_cart->vrom_alloc(vrom_size, tag()); |
| 485 | memcpy(m_cart->get_vrom_base(), temp_chr, vrom_size); | |
| 485 | memcpy(m_cart->get_vrom_base(), &temp_chr[0], vrom_size); | |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | #if SPLIT_PRG |
| r245687 | r245688 | |
| 530 | 530 | { |
| 531 | 531 | UINT32 tot_size = battery_size + mapper_sram_size; |
| 532 | 532 | dynamic_buffer temp_nvram(tot_size); |
| 533 | battery_load(temp_nvram, tot_size, 0x00); | |
| 533 | battery_load(&temp_nvram[0], tot_size, 0x00); | |
| 534 | 534 | if (battery_size) |
| 535 | 535 | { |
| 536 | 536 | m_cart->battery_alloc(battery_size); |
| 537 | memcpy(m_cart->get_battery_base(), temp_nvram, battery_size); | |
| 537 | memcpy(m_cart->get_battery_base(), &temp_nvram[0], battery_size); | |
| 538 | 538 | } |
| 539 | 539 | if (mapper_sram_size) |
| 540 | memcpy(m_cart->get_mapper_sram_base(), temp_nvram | |
| 540 | memcpy(m_cart->get_mapper_sram_base(), &temp_nvram[battery_size], mapper_sram_size); | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | logerror("UNIF support is only very preliminary.\n"); |
| r245687 | r245688 | |
|---|---|---|
| 551 | 551 | WRITE8_MEMBER(nes_fukutake_device::write_m) |
| 552 | 552 | { |
| 553 | 553 | LOG_MMC(("fukutake write_m, offset: %04x, data: %02x\n", offset, data)); |
| 554 | m_prgram[((m_latch * 0x2000) + offset) & (m_prgram. | |
| 554 | m_prgram[((m_latch * 0x2000) + offset) & (m_prgram.size() - 1)] = data; | |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | READ8_MEMBER(nes_fukutake_device::read_m) |
| 558 | 558 | { |
| 559 | 559 | LOG_MMC(("fukutake read_m, offset: %04x\n", offset)); |
| 560 | return m_prgram[((m_latch * 0x2000) + offset) & (m_prgram. | |
| 560 | return m_prgram[((m_latch * 0x2000) + offset) & (m_prgram.size() - 1)]; | |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /*------------------------------------------------- |
| r245687 | r245688 | |
| 871 | 871 | WRITE8_MEMBER(nes_edu2k_device::write_m) |
| 872 | 872 | { |
| 873 | 873 | LOG_MMC(("edu2k write_m, offset: %04x, data: %02x\n", offset, data)); |
| 874 | m_prgram[((m_latch * 0x2000) + offset) & (m_prgram. | |
| 874 | m_prgram[((m_latch * 0x2000) + offset) & (m_prgram.size() - 1)] = data; | |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | READ8_MEMBER(nes_edu2k_device::read_m) |
| 878 | 878 | { |
| 879 | 879 | LOG_MMC(("edu2k read_m, offset: %04x\n", offset)); |
| 880 | return m_prgram[((m_latch * 0x2000) + offset) & (m_prgram. | |
| 880 | return m_prgram[((m_latch * 0x2000) + offset) & (m_prgram.size() - 1)]; | |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /*------------------------------------------------- |
| r245687 | r245688 | |
|---|---|---|
| 428 | 428 | { |
| 429 | 429 | LOG_MMC(("Sunsoft 4 write_m, offset: %04x, data: %02x\n", offset, data)); |
| 430 | 430 | |
| 431 | if (m_battery && m_wram_enable) | |
| 432 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 433 | if (m_prgram && m_wram_enable) | |
| 434 | m_prgram[offset & (m_prgram.count() - 1)] = data; | |
| 431 | if (!m_battery.empty() && m_wram_enable) | |
| 432 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 433 | if (!m_prgram.empty() && m_wram_enable) | |
| 434 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | READ8_MEMBER(nes_sunsoft_4_device::read_m) |
| 438 | 438 | { |
| 439 | 439 | LOG_MMC(("Sunsoft 4 read_m, offset: %04x\n", offset)); |
| 440 | 440 | |
| 441 | if (m_battery && m_wram_enable) | |
| 442 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 443 | if (m_prgram && m_wram_enable) | |
| 444 | return m_prgram[offset & (m_prgram.count() - 1)]; | |
| 441 | if (!m_battery.empty() && m_wram_enable) | |
| 442 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 443 | if (!m_prgram.empty() && m_wram_enable) | |
| 444 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 445 | 445 | |
| 446 | 446 | return m_open_bus; // open bus |
| 447 | 447 | } |
| r245687 | r245688 | |
| 542 | 542 | return; |
| 543 | 543 | else if (m_wram_bank & 0x80) // is PRG RAM |
| 544 | 544 | { |
| 545 | if (m_battery) | |
| 546 | m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)] = data; | |
| 547 | if (m_prgram) | |
| 548 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)] = data; | |
| 545 | if (!m_battery.empty()) | |
| 546 | m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)] = data; | |
| 547 | if (!m_prgram.empty()) | |
| 548 | m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)] = data; | |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | 551 | |
| r245687 | r245688 | |
| 558 | 558 | return m_prg[((bank * 0x2000) + offset) & (m_prg_size - 1)]; |
| 559 | 559 | else if (m_wram_bank & 0x80) // is PRG RAM |
| 560 | 560 | { |
| 561 | if (m_battery) | |
| 562 | return m_battery[((bank * 0x2000) + offset) & (m_battery.count() - 1)]; | |
| 563 | if (m_prgram) | |
| 564 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.count() - 1)]; | |
| 561 | if (!m_battery.empty()) | |
| 562 | return m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)]; | |
| 563 | if (!m_prgram.empty()) | |
| 564 | return m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)]; | |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | return m_open_bus; // open bus |
| r245687 | r245688 | |
|---|---|---|
| 254 | 254 | { |
| 255 | 255 | LOG_MMC(("Sunsoft DCS write_m, offset: %04x, data: %02x\n", offset, data)); |
| 256 | 256 | |
| 257 | if (m_battery && m_wram_enable) | |
| 258 | m_battery[offset & (m_battery.count() - 1)] = data; | |
| 259 | if (m_prgram && m_wram_enable) | |
| 260 | m_prgram[offset & (m_prgram.count() - 1)] = data; | |
| 257 | if (!m_battery.empty() && m_wram_enable) | |
| 258 | m_battery[offset & (m_battery.size() - 1)] = data; | |
| 259 | if (!m_prgram.empty() && m_wram_enable) | |
| 260 | m_prgram[offset & (m_prgram.size() - 1)] = data; | |
| 261 | 261 | if (!m_wram_enable && !m_timer_on) |
| 262 | 262 | { |
| 263 | 263 | m_timer_on = 1; |
| r245687 | r245688 | |
| 270 | 270 | { |
| 271 | 271 | LOG_MMC(("Sunsoft DCS read_m, offset: %04x\n", offset)); |
| 272 | 272 | |
| 273 | if (m_battery && m_wram_enable) | |
| 274 | return m_battery[offset & (m_battery.count() - 1)]; | |
| 275 | if (m_prgram && m_wram_enable) | |
| 276 | return m_prgram[offset & (m_prgram.count() - 1)]; | |
| 273 | if (!m_battery.empty() && m_wram_enable) | |
| 274 | return m_battery[offset & (m_battery.size() - 1)]; | |
| 275 | if (!m_prgram.empty() && m_wram_enable) | |
| 276 | return m_prgram[offset & (m_prgram.size() - 1)]; | |
| 277 | 277 | |
| 278 | 278 | return m_open_bus; // open bus |
| 279 | 279 | } |
| r245687 | r245688 | |
|---|---|---|
| 371 | 371 | break; |
| 372 | 372 | |
| 373 | 373 | case 0xe1: // lane 0 only |
| 374 | m_declaration_rom.resize_and_clear(romlen*4); | |
| 374 | m_declaration_rom.resize(romlen*4); | |
| 375 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 375 | 376 | for (int i = 0; i < romlen; i++) |
| 376 | 377 | { |
| 377 | 378 | m_declaration_rom[BYTE4_XOR_BE(i*4)] = rom[i]; |
| r245687 | r245688 | |
| 380 | 381 | break; |
| 381 | 382 | |
| 382 | 383 | case 0xd2: // lane 1 only |
| 383 | m_declaration_rom.resize_and_clear(romlen*4); | |
| 384 | m_declaration_rom.resize(romlen*4); | |
| 385 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 384 | 386 | for (int i = 0; i < romlen; i++) |
| 385 | 387 | { |
| 386 | 388 | m_declaration_rom[BYTE4_XOR_BE((i*4)+1)] = rom[i]; |
| r245687 | r245688 | |
| 389 | 391 | break; |
| 390 | 392 | |
| 391 | 393 | case 0xb4: // lane 2 only |
| 392 | m_declaration_rom.resize_and_clear(romlen*4); | |
| 394 | m_declaration_rom.resize(romlen*4); | |
| 395 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 393 | 396 | for (int i = 0; i < romlen; i++) |
| 394 | 397 | { |
| 395 | 398 | m_declaration_rom[BYTE4_XOR_BE((i*4)+2)] = rom[i]; |
| r245687 | r245688 | |
| 398 | 401 | break; |
| 399 | 402 | |
| 400 | 403 | case 0x78: // lane 3 only |
| 401 | m_declaration_rom.resize_and_clear(romlen*4); | |
| 404 | m_declaration_rom.resize(romlen*4); | |
| 405 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 402 | 406 | for (int i = 0; i < romlen; i++) |
| 403 | 407 | { |
| 404 | 408 | m_declaration_rom[BYTE4_XOR_BE((i*4)+3)] = rom[i]; |
| r245687 | r245688 | |
| 407 | 411 | break; |
| 408 | 412 | |
| 409 | 413 | case 0xc3: // lanes 0, 1 |
| 410 | m_declaration_rom.resize_and_clear(romlen*2); | |
| 414 | m_declaration_rom.resize(romlen*2); | |
| 415 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 411 | 416 | for (int i = 0; i < romlen/2; i++) |
| 412 | 417 | { |
| 413 | 418 | m_declaration_rom[BYTE4_XOR_BE((i*4)+0)] = rom[(i*2)]; |
| r245687 | r245688 | |
| 417 | 422 | break; |
| 418 | 423 | |
| 419 | 424 | case 0xa5: // lanes 0, 2 |
| 420 | m_declaration_rom.resize_and_clear(romlen*2); | |
| 425 | m_declaration_rom.resize(romlen*2); | |
| 426 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 421 | 427 | for (int i = 0; i < romlen/2; i++) |
| 422 | 428 | { |
| 423 | 429 | m_declaration_rom[BYTE4_XOR_BE((i*4)+0)] = rom[(i*2)]; |
| r245687 | r245688 | |
| 427 | 433 | break; |
| 428 | 434 | |
| 429 | 435 | case 0x3c: // lanes 2,3 |
| 430 | m_declaration_rom.resize_and_clear(romlen*2); | |
| 436 | m_declaration_rom.resize(romlen*2); | |
| 437 | memset(&m_declaration_rom[0], 0, romlen*4); | |
| 431 | 438 | for (int i = 0; i < romlen/2; i++) |
| 432 | 439 | { |
| 433 | 440 | m_declaration_rom[BYTE4_XOR_BE((i*4)+2)] = rom[(i*2)]; |
| r245687 | r245688 | |
| 458 | 465 | // printf("Installing ROM at %x, length %x\n", addr, romlen); |
| 459 | 466 | if (mirror_all_mb) // mirror the declaration ROM across all 16 megs of the slot space |
| 460 | 467 | { |
| 461 | m_nubus->install_bank(addr, addr+romlen-1, 0, 0x00f00000, bankname, m_declaration_rom); | |
| 468 | m_nubus->install_bank(addr, addr+romlen-1, 0, 0x00f00000, bankname, &m_declaration_rom[0]); | |
| 462 | 469 | } |
| 463 | 470 | else |
| 464 | 471 | { |
| 465 | m_nubus->install_bank(addr, addr+romlen-1, 0, 0, bankname, m_declaration_rom); | |
| 472 | m_nubus->install_bank(addr, addr+romlen-1, 0, 0, bankname, &m_declaration_rom[0]); | |
| 466 | 473 | } |
| 467 | 474 | } |
| r245687 | r245688 | |
|---|---|---|
| 112 | 112 | // printf("[JMFB %p] slotspace = %x\n", this, slotspace); |
| 113 | 113 | |
| 114 | 114 | m_vram.resize(VRAM_SIZE); |
| 115 | install_bank(slotspace, slotspace+VRAM_SIZE-1, 0, 0, "bank_48gc", m_vram); | |
| 115 | install_bank(slotspace, slotspace+VRAM_SIZE-1, 0, 0, "bank_48gc", &m_vram[0]); | |
| 116 | 116 | |
| 117 | 117 | m_nubus->install_device(slotspace+0x200000, slotspace+0x2003ff, read32_delegate(FUNC(jmfb_device::mac_48gc_r), this), write32_delegate(FUNC(jmfb_device::mac_48gc_w), this)); |
| 118 | 118 | |
| r245687 | r245688 | |
| 135 | 135 | m_xres = 640; |
| 136 | 136 | m_yres = 480; |
| 137 | 137 | m_mode = 0; |
| 138 | memset(m_vram, 0, VRAM_SIZE); | |
| 138 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 139 | 139 | memset(m_palette, 0, sizeof(m_palette)); |
| 140 | 140 | } |
| 141 | 141 | |
| r245687 | r245688 | |
| 159 | 159 | { |
| 160 | 160 | UINT32 *scanline, *base; |
| 161 | 161 | int x, y; |
| 162 | UINT8 *vram8 = | |
| 162 | UINT8 *vram8 = &m_vram[0]; | |
| 163 | 163 | UINT8 pixels; |
| 164 | 164 | |
| 165 | 165 | // first time? kick off the VBL timer |
| r245687 | r245688 | |
|---|---|---|
| 96 | 96 | // printf("[cb264 %p] slotspace = %x\n", this, slotspace); |
| 97 | 97 | |
| 98 | 98 | m_vram.resize(VRAM_SIZE); |
| 99 | install_bank(slotspace, slotspace+VRAM_SIZE-1, 0, 0, "bank_cb264", m_vram); | |
| 99 | install_bank(slotspace, slotspace+VRAM_SIZE-1, 0, 0, "bank_cb264", &m_vram[0]); | |
| 100 | 100 | |
| 101 | 101 | m_nubus->install_device(slotspace+0xff6000, slotspace+0xff60ff, read32_delegate(FUNC(nubus_cb264_device::cb264_r), this), write32_delegate(FUNC(nubus_cb264_device::cb264_w), this)); |
| 102 | 102 | m_nubus->install_device(slotspace+0xff7000, slotspace+0xff70ff, read32_delegate(FUNC(nubus_cb264_device::cb264_ramdac_r), this), write32_delegate(FUNC(nubus_cb264_device::cb264_ramdac_w), this)); |
| r245687 | r245688 | |
| 113 | 113 | m_clutoffs = 0; |
| 114 | 114 | m_cb264_vbl_disable = 1; |
| 115 | 115 | m_cb264_mode = 0; |
| 116 | memset(m_vram, 0, VRAM_SIZE); | |
| 116 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 117 | 117 | memset(m_palette, 0, sizeof(m_palette)); |
| 118 | 118 | } |
| 119 | 119 |
| r245687 | r245688 | |
|---|---|---|
| 118 | 118 | m_clutoffs = 0; |
| 119 | 119 | m_vbl_disable = 1; |
| 120 | 120 | m_mode = 0; |
| 121 | memset(m_vram, 0, VRAM_SIZE); | |
| 121 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 122 | 122 | memset(m_palette, 0, sizeof(m_palette)); |
| 123 | 123 | |
| 124 | 124 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 148 | 148 | int x, y; |
| 149 | 149 | UINT8 pixels, *vram; |
| 150 | 150 | |
| 151 | vram = m_vram | |
| 151 | vram = &m_vram[0x20]; | |
| 152 | 152 | |
| 153 | 153 | switch (m_mode) |
| 154 | 154 | { |
| r245687 | r245688 | |
|---|---|---|
| 119 | 119 | m_clutoffs = 0; |
| 120 | 120 | m_vbl_disable = 1; |
| 121 | 121 | m_mode = 0; |
| 122 | memset(m_vram, 0, VRAM_SIZE); | |
| 122 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 123 | 123 | memset(m_palette, 0, sizeof(m_palette)); |
| 124 | 124 | |
| 125 | 125 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 149 | 149 | int x, y; |
| 150 | 150 | UINT8 pixels, *vram; |
| 151 | 151 | |
| 152 | vram = m_vram | |
| 152 | vram = &m_vram[0x20]; | |
| 153 | 153 | |
| 154 | 154 | switch (m_mode) |
| 155 | 155 | { |
| r245687 | r245688 | |
|---|---|---|
| 119 | 119 | m_clutoffs = 0; |
| 120 | 120 | m_vbl_disable = 1; |
| 121 | 121 | m_mode = 0; |
| 122 | memset(m_vram, 0, VRAM_SIZE); | |
| 122 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 123 | 123 | memset(m_palette, 0, sizeof(m_palette)); |
| 124 | 124 | |
| 125 | 125 | m_palette[1] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 149 | 149 | int x, y; |
| 150 | 150 | UINT8 pixels, *vram; |
| 151 | 151 | |
| 152 | vram = m_vram | |
| 152 | vram = &m_vram[0x200]; | |
| 153 | 153 | |
| 154 | 154 | for (y = 0; y < 880; y++) |
| 155 | 155 | { |
| r245687 | r245688 | |
|---|---|---|
| 121 | 121 | m_mode = 0; |
| 122 | 122 | m_vbl_pending = false; |
| 123 | 123 | m_parameter = 0; |
| 124 | memset(m_vram, 0, VRAM_SIZE); | |
| 124 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 125 | 125 | memset(m_palette, 0, sizeof(m_palette)); |
| 126 | 126 | |
| 127 | 127 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 152 | 152 | int x, y; |
| 153 | 153 | UINT8 pixels, *vram; |
| 154 | 154 | |
| 155 | vram = m_vram | |
| 155 | vram = &m_vram[0x400]; | |
| 156 | 156 | |
| 157 | 157 | switch (m_mode) |
| 158 | 158 | { |
| r245687 | r245688 | |
|---|---|---|
| 135 | 135 | m_clutoffs = 0; |
| 136 | 136 | m_vbl_disable = 1; |
| 137 | 137 | m_mode = 0; |
| 138 | memset(m_vram, 0, VRAM_SIZE); | |
| 138 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 139 | 139 | memset(m_palette_val, 0, sizeof(m_palette_val)); |
| 140 | 140 | |
| 141 | 141 | m_palette_val[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 166 | 166 | UINT8 pixels, *vram; |
| 167 | 167 | |
| 168 | 168 | // first time? kick off the VBL timer |
| 169 | vram = m_vram | |
| 169 | vram = &m_vram[0x9000]; | |
| 170 | 170 | |
| 171 | 171 | switch (m_mode) |
| 172 | 172 | { |
| r245687 | r245688 | |
| 424 | 424 | if (data == 2) |
| 425 | 425 | { |
| 426 | 426 | int x, y; |
| 427 | UINT8 *vram = m_vram | |
| 427 | UINT8 *vram = &m_vram[m_vram_addr + m_patofsx]; // m_vram_addr is missing the low 2 bits, we add them back here | |
| 428 | 428 | |
| 429 | 429 | // printf("Fill rectangle with %02x %02x %02x %02x, width %d height %d\n", m_fillbytes[0], m_fillbytes[1], m_fillbytes[2], m_fillbytes[3], m_width, m_height); |
| 430 | 430 | |
| r245687 | r245688 | |
| 439 | 439 | else if ((data == 0x101) || (data == 0x100)) |
| 440 | 440 | { |
| 441 | 441 | int x, y; |
| 442 | UINT8 *vram = m_vram + m_vram_addr; | |
| 443 | UINT8 *vramsrc = m_vram + m_vram_src; | |
| 442 | UINT8 *vram = &m_vram[m_vram_addr]; | |
| 443 | UINT8 *vramsrc = &m_vram[m_vram_src]; | |
| 444 | 444 | |
| 445 | 445 | // printf("Copy rectangle, width %d height %d src %x dst %x\n", m_width, m_height, m_vram_addr, m_vram_src); |
| 446 | 446 |
| r245687 | r245688 | |
|---|---|---|
| 92 | 92 | // printf("[vikbw %p] slotspace = %x\n", this, slotspace); |
| 93 | 93 | |
| 94 | 94 | m_vram.resize(VRAM_SIZE); |
| 95 | install_bank(slotspace+0x40000, slotspace+0x40000+VRAM_SIZE-1, 0, 0, "bank_vikbw", m_vram); | |
| 96 | install_bank(slotspace+0x940000, slotspace+0x940000+VRAM_SIZE-1, 0, 0, "bank_vikbw2", m_vram); | |
| 95 | install_bank(slotspace+0x40000, slotspace+0x40000+VRAM_SIZE-1, 0, 0, "bank_vikbw", &m_vram[0]); | |
| 96 | install_bank(slotspace+0x940000, slotspace+0x940000+VRAM_SIZE-1, 0, 0, "bank_vikbw2", &m_vram[0]); | |
| 97 | 97 | |
| 98 | 98 | m_nubus->install_device(slotspace, slotspace+3, read32_delegate(FUNC(nubus_vikbw_device::viking_enable_r), this), write32_delegate(FUNC(nubus_vikbw_device::viking_disable_w), this)); |
| 99 | 99 | m_nubus->install_device(slotspace+0x80000, slotspace+0x80000+3, read32_delegate(FUNC(nubus_vikbw_device::viking_ack_r), this), write32_delegate(FUNC(nubus_vikbw_device::viking_ack_w), this)); |
| r245687 | r245688 | |
| 106 | 106 | void nubus_vikbw_device::device_reset() |
| 107 | 107 | { |
| 108 | 108 | m_vbl_disable = 1; |
| 109 | memset(m_vram, 0, VRAM_SIZE); | |
| 109 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 110 | 110 | |
| 111 | 111 | m_palette[0] = rgb_t(255, 255, 255); |
| 112 | 112 | m_palette[1] = rgb_t(0, 0, 0); |
| r245687 | r245688 | |
|---|---|---|
| 121 | 121 | m_clutoffs = 0; |
| 122 | 122 | m_vbl_disable = 1; |
| 123 | 123 | m_mode = 0; |
| 124 | memset(m_vram, 0, VRAM_SIZE); | |
| 124 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 125 | 125 | memset(m_palette, 0, sizeof(m_palette)); |
| 126 | 126 | } |
| 127 | 127 | |
| r245687 | r245688 | |
| 149 | 149 | UINT8 pixels, *vram; |
| 150 | 150 | |
| 151 | 151 | // first time? kick off the VBL timer |
| 152 | vram = m_vram | |
| 152 | vram = &m_vram[0x80]; | |
| 153 | 153 | |
| 154 | 154 | switch (m_mode) |
| 155 | 155 | { |
| r245687 | r245688 | |
|---|---|---|
| 120 | 120 | m_clutoffs = 0; |
| 121 | 121 | m_vbl_disable = 1; |
| 122 | 122 | m_mode = 0; |
| 123 | memset(m_vram, 0, VRAM_SIZE); | |
| 123 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 124 | 124 | memset(m_palette, 0, sizeof(m_palette)); |
| 125 | 125 | |
| 126 | 126 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 150 | 150 | int x, y; |
| 151 | 151 | UINT8 pixels, *vram; |
| 152 | 152 | |
| 153 | vram = m_vram | |
| 153 | vram = &m_vram[1024]; | |
| 154 | 154 | |
| 155 | 155 | switch (m_mode) |
| 156 | 156 | { |
| r245687 | r245688 | |
|---|---|---|
| 113 | 113 | m_clutoffs = 0; |
| 114 | 114 | m_vbl_disable = 1; |
| 115 | 115 | m_mode = 4; |
| 116 | memset(m_vram, 0, VRAM_SIZE); | |
| 116 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 117 | 117 | memset(m_palette, 0, sizeof(m_palette)); |
| 118 | 118 | |
| 119 | 119 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 143 | 143 | int x, y; |
| 144 | 144 | UINT8 pixels, *vram; |
| 145 | 145 | |
| 146 | vram = m_vram | |
| 146 | vram = &m_vram[8*1024]; | |
| 147 | 147 | |
| 148 | 148 | switch (m_mode) |
| 149 | 149 | { |
| r245687 | r245688 | |
|---|---|---|
| 116 | 116 | m_clutoffs = 0; |
| 117 | 117 | m_vbl_disable = 1; |
| 118 | 118 | m_mode = 0; |
| 119 | memset(m_vram, 0, VRAM_SIZE); | |
| 119 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 120 | 120 | memset(m_palette, 0, sizeof(m_palette)); |
| 121 | 121 | |
| 122 | 122 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 146 | 146 | int x, y; |
| 147 | 147 | UINT8 pixels, *vram; |
| 148 | 148 | |
| 149 | vram = m_vram | |
| 149 | vram = &m_vram[4*1024]; | |
| 150 | 150 | |
| 151 | 151 | switch (m_mode) |
| 152 | 152 | { |
| r245687 | r245688 | |
|---|---|---|
| 120 | 120 | m_clutoffs = 0; |
| 121 | 121 | m_vbl_disable = 1; |
| 122 | 122 | m_mode = 3; |
| 123 | memset(m_vram, 0, VRAM_SIZE); | |
| 123 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 124 | 124 | memset(m_palette, 0, sizeof(m_palette)); |
| 125 | 125 | |
| 126 | 126 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 150 | 150 | int x, y; |
| 151 | 151 | UINT8 pixels, *vram; |
| 152 | 152 | |
| 153 | vram = m_vram | |
| 153 | vram = &m_vram[4]; | |
| 154 | 154 | |
| 155 | 155 | switch (m_mode) |
| 156 | 156 | { |
| r245687 | r245688 | |
|---|---|---|
| 112 | 112 | { |
| 113 | 113 | m_vbl_disable = 1; |
| 114 | 114 | m_protstate = 0; |
| 115 | memset(m_vram, 0, VRAM_SIZE); | |
| 115 | memset(&m_vram[0], 0, VRAM_SIZE); | |
| 116 | 116 | memset(m_palette, 0, sizeof(m_palette)); |
| 117 | 117 | |
| 118 | 118 | m_palette[0] = rgb_t(255, 255, 255); |
| r245687 | r245688 | |
| 142 | 142 | int x, y; |
| 143 | 143 | UINT8 pixels, *vram; |
| 144 | 144 | |
| 145 | vram = m_vram | |
| 145 | vram = &m_vram[0x20]; | |
| 146 | 146 | |
| 147 | 147 | for (y = 0; y < 600; y++) |
| 148 | 148 | { |
| r245687 | r245688 | |
|---|---|---|
| 39 | 39 | void rom_alloc(UINT32 size, const char *tag); |
| 40 | 40 | void ram_alloc(UINT32 size); |
| 41 | 41 | UINT8* get_rom_base() { return m_rom; } |
| 42 | UINT8* get_ram_base() { return m_ram; } | |
| 42 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 43 | 43 | UINT32 get_rom_size() { return m_rom_size; } |
| 44 | UINT32 get_ram_size() { return m_ram. | |
| 44 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 45 | 45 | |
| 46 | 46 | protected: |
| 47 | 47 | // internal state |
| r245687 | r245688 | |
|---|---|---|
| 80 | 80 | READ8_MEMBER(pce_cdsys3_device::read_cart) |
| 81 | 81 | { |
| 82 | 82 | int bank = offset / 0x20000; |
| 83 | if (m_ram && offset >= 0xd0000) | |
| 83 | if (!m_ram.empty() && offset >= 0xd0000) | |
| 84 | 84 | return m_ram[offset - 0xd0000]; |
| 85 | 85 | |
| 86 | 86 | return m_rom[rom_bank_map[bank] * 0x20000 + (offset & 0x1ffff)]; |
| r245687 | r245688 | |
| 88 | 88 | |
| 89 | 89 | WRITE8_MEMBER(pce_cdsys3_device::write_cart) |
| 90 | 90 | { |
| 91 | if (m_ram && offset >= 0xd0000) | |
| 91 | if (!m_ram.empty() && offset >= 0xd0000) | |
| 92 | 92 | m_ram[offset - 0xd0000] = data; |
| 93 | 93 | } |
| 94 | 94 | |
| r245687 | r245688 | |
| 96 | 96 | READ8_MEMBER(pce_populous_device::read_cart) |
| 97 | 97 | { |
| 98 | 98 | int bank = offset / 0x20000; |
| 99 | if (m_ram && offset >= 0x80000 && offset < 0x88000) | |
| 99 | if (!m_ram.empty() && offset >= 0x80000 && offset < 0x88000) | |
| 100 | 100 | return m_ram[offset & 0x7fff]; |
| 101 | 101 | |
| 102 | 102 | return m_rom[rom_bank_map[bank] * 0x20000 + (offset & 0x1ffff)]; |
| r245687 | r245688 | |
| 104 | 104 | |
| 105 | 105 | WRITE8_MEMBER(pce_populous_device::write_cart) |
| 106 | 106 | { |
| 107 | if (m_ram && offset >= 0x80000 && offset < 0x88000) | |
| 107 | if (!m_ram.empty() && offset >= 0x80000 && offset < 0x88000) | |
| 108 | 108 | m_ram[offset & 0x7fff] = data; |
| 109 | 109 | } |
| 110 | 110 |
| r245687 | r245688 | |
|---|---|---|
| 348 | 348 | dynamic_buffer rom(len); |
| 349 | 349 | int type; |
| 350 | 350 | |
| 351 | core_fread(m_file, rom, len); | |
| 351 | core_fread(m_file, &rom[0], len); | |
| 352 | 352 | |
| 353 | type = get_cart_type(rom, len); | |
| 353 | type = get_cart_type(&rom[0], len); | |
| 354 | 354 | slot_string = pce_get_slot(type); |
| 355 | 355 | |
| 356 | 356 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | void rom_alloc(UINT32 size, const char *tag); |
| 34 | 34 | void ram_alloc(UINT32 size); |
| 35 | 35 | UINT8* get_rom_base() { return m_rom; } |
| 36 | UINT8* get_ram_base() { return m_ram; } | |
| 36 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 37 | 37 | UINT32 get_rom_size() { return m_rom_size; } |
| 38 | UINT32 get_ram_size() { return m_ram. | |
| 38 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 39 | 39 | |
| 40 | 40 | // internal state |
| 41 | 41 | UINT8 *m_rom; |
| r245687 | r245688 | |
|---|---|---|
| 67 | 67 | { |
| 68 | 68 | static const UINT8 init[16] = |
| 69 | 69 | { 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't' }; |
| 70 | memset(m_ext_bram, 0, m_ext_bram. | |
| 70 | memset(&m_ext_bram[0], 0, m_ext_bram.size()); | |
| 71 | 71 | |
| 72 | 72 | for (int i = 0; i < 32; i++) |
| 73 | 73 | { |
| r245687 | r245688 | |
| 85 | 85 | |
| 86 | 86 | READ32_MEMBER(saturn_bram_device::read_ext_bram) |
| 87 | 87 | { |
| 88 | if (offset < m_ext_bram. | |
| 88 | if (offset < m_ext_bram.size()/2) | |
| 89 | 89 | return (m_ext_bram[offset * 2] << 16) | m_ext_bram[offset * 2 + 1]; |
| 90 | 90 | else |
| 91 | 91 | { |
| r245687 | r245688 | |
| 96 | 96 | |
| 97 | 97 | WRITE32_MEMBER(saturn_bram_device::write_ext_bram) |
| 98 | 98 | { |
| 99 | if (offset < m_ext_bram. | |
| 99 | if (offset < m_ext_bram.size()/2) | |
| 100 | 100 | { |
| 101 | 101 | if (ACCESSING_BITS_16_23) |
| 102 | 102 | m_ext_bram[offset * 2 + 0] = (data & 0x00ff0000) >> 16; |
| r245687 | r245688 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | // device_nvram_interface overrides |
| 22 | 22 | virtual void nvram_default(); |
| 23 | virtual void nvram_read(emu_file &file) { if (m_ext_bram != NULL) { file.read(m_ext_bram, m_ext_bram.bytes()); } } | |
| 24 | virtual void nvram_write(emu_file &file) { if (m_ext_bram != NULL) { file.write(m_ext_bram, m_ext_bram.bytes()); } } | |
| 23 | virtual void nvram_read(emu_file &file) { if (!m_ext_bram.empty()) file.read(&m_ext_bram[0], m_ext_bram.size()); } | |
| 24 | virtual void nvram_write(emu_file &file) { if (!m_ext_bram.empty()) file.write(&m_ext_bram[0], m_ext_bram.size()); } | |
| 25 | 25 | |
| 26 | 26 | // reading and writing |
| 27 | 27 | virtual DECLARE_READ32_MEMBER(read_ext_bram); |
| r245687 | r245688 | |
|---|---|---|
| 58 | 58 | READ32_MEMBER(saturn_dram_device::read_ext_dram0) |
| 59 | 59 | { |
| 60 | 60 | if (offset < (0x400000/2)/4) |
| 61 | return m_ext_dram0[offset % m_ext_dram0. | |
| 61 | return m_ext_dram0[offset % m_ext_dram0.size()]; | |
| 62 | 62 | else |
| 63 | 63 | { |
| 64 | 64 | popmessage("DRAM0 read beyond its boundary! offs: %X\n", offset); |
| r245687 | r245688 | |
| 69 | 69 | READ32_MEMBER(saturn_dram_device::read_ext_dram1) |
| 70 | 70 | { |
| 71 | 71 | if (offset < (0x400000/2)/4) |
| 72 | return m_ext_dram1[offset % m_ext_dram1. | |
| 72 | return m_ext_dram1[offset % m_ext_dram1.size()]; | |
| 73 | 73 | else |
| 74 | 74 | { |
| 75 | 75 | popmessage("DRAM1 read beyond its boundary! offs: %X\n", offset); |
| r245687 | r245688 | |
| 80 | 80 | WRITE32_MEMBER(saturn_dram_device::write_ext_dram0) |
| 81 | 81 | { |
| 82 | 82 | if (offset < (0x400000/2)/4) |
| 83 | COMBINE_DATA(&m_ext_dram0[offset % m_ext_dram0. | |
| 83 | COMBINE_DATA(&m_ext_dram0[offset % m_ext_dram0.size()]); | |
| 84 | 84 | else |
| 85 | 85 | popmessage("DRAM0 write beyond its boundary! offs: %X data: %X\n", offset, data); |
| 86 | 86 | } |
| r245687 | r245688 | |
| 88 | 88 | WRITE32_MEMBER(saturn_dram_device::write_ext_dram1) |
| 89 | 89 | { |
| 90 | 90 | if (offset < (0x400000/2)/4) |
| 91 | COMBINE_DATA(&m_ext_dram1[offset % m_ext_dram1. | |
| 91 | COMBINE_DATA(&m_ext_dram1[offset % m_ext_dram1.size()]); | |
| 92 | 92 | else |
| 93 | 93 | popmessage("DRAM1 write beyond its boundary! offs: %X data: %X\n", offset, data); |
| 94 | 94 | } |
| r245687 | r245688 | |
|---|---|---|
| 34 | 34 | void dram0_alloc(UINT32 size); |
| 35 | 35 | void dram1_alloc(UINT32 size); |
| 36 | 36 | UINT32* get_rom_base() { return m_rom; } |
| 37 | UINT32* get_ext_dram0_base() { return m_ext_dram0; } | |
| 38 | UINT32* get_ext_dram1_base() { return m_ext_dram1; } | |
| 39 | UINT8* get_ext_bram_base() { return m_ext_bram; } | |
| 37 | UINT32* get_ext_dram0_base() { return &m_ext_dram0[0]; } | |
| 38 | UINT32* get_ext_dram1_base() { return &m_ext_dram1[0]; } | |
| 39 | UINT8* get_ext_bram_base() { return &m_ext_bram[0]; } | |
| 40 | 40 | UINT32 get_rom_size() { return m_rom_size; } |
| 41 | UINT32 get_ext_dram0_size() { return m_ext_dram0.bytes(); } | |
| 42 | UINT32 get_ext_dram1_size() { return m_ext_dram1.bytes(); } | |
| 43 | UINT32 get_ext_bram_size() { return m_ext_bram.bytes(); } | |
| 41 | UINT32 get_ext_dram0_size() { return m_ext_dram0.size()*sizeof(UINT32); } | |
| 42 | UINT32 get_ext_dram1_size() { return m_ext_dram1.size()*sizeof(UINT32); } | |
| 43 | UINT32 get_ext_bram_size() { return m_ext_bram.size(); } | |
| 44 | 44 | |
| 45 | 45 | protected: |
| 46 | 46 | int m_cart_type; |
| r245687 | r245688 | |
| 48 | 48 | // internal state |
| 49 | 49 | UINT32 *m_rom; |
| 50 | 50 | UINT32 m_rom_size; |
| 51 | dynamic_array<UINT32> m_ext_dram0; | |
| 52 | dynamic_array<UINT32> m_ext_dram1; | |
| 51 | std::vector<UINT32> m_ext_dram0; | |
| 52 | std::vector<UINT32> m_ext_dram1; | |
| 53 | 53 | dynamic_buffer m_ext_bram; |
| 54 | 54 | }; |
| 55 | 55 |
| r245687 | r245688 | |
|---|---|---|
| 260 | 260 | if ((m_disk) && (m_blocks)) |
| 261 | 261 | { |
| 262 | 262 | dynamic_buffer data(m_sector_bytes); |
| 263 | memset(data, 0xc6, m_sector_bytes); | |
| 263 | memset(&data[0], 0xc6, m_sector_bytes); | |
| 264 | 264 | |
| 265 | 265 | while (m_blocks > 0) |
| 266 | 266 | { |
| 267 | if (!hard_disk_write(m_disk, m_lba, data)) | |
| 267 | if (!hard_disk_write(m_disk, m_lba, &data[0])) | |
| 268 | 268 | { |
| 269 | 269 | logerror("S1410: HD write error!\n"); |
| 270 | 270 | } |
| r245687 | r245688 | |
|---|---|---|
| 270 | 270 | dynamic_buffer rom(len); |
| 271 | 271 | int type; |
| 272 | 272 | |
| 273 | core_fread(m_file, rom, len); | |
| 273 | core_fread(m_file, &rom[0], len); | |
| 274 | 274 | |
| 275 | type = get_cart_type(rom, len); | |
| 275 | type = get_cart_type(&rom[0], len); | |
| 276 | 276 | slot_string = scv_get_slot(type); |
| 277 | 277 | |
| 278 | 278 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 38 | 38 | void rom_alloc(UINT32 size, const char *tag); |
| 39 | 39 | void ram_alloc(UINT32 size); |
| 40 | 40 | UINT8* get_rom_base() { return m_rom; } |
| 41 | UINT8* get_ram_base() { return m_ram; } | |
| 41 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 42 | 42 | UINT32 get_rom_size() { return m_rom_size; } |
| 43 | UINT32 get_ram_size() { return m_ram. | |
| 43 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 44 | 44 | |
| 45 | 45 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 46 | 46 |
| r245687 | r245688 | |
|---|---|---|
| 332 | 332 | { |
| 333 | 333 | int bank = offset / 0x4000; |
| 334 | 334 | |
| 335 | if (bank == 2 && m_ram && m_ram_enabled) | |
| 336 | return m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.count()]; | |
| 335 | if (bank == 2 && !m_ram.empty() && m_ram_enabled) | |
| 336 | return m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.size()]; | |
| 337 | 337 | |
| 338 | 338 | if (offset < 0x400) // first 1k is hardcoded |
| 339 | 339 | return m_rom[offset]; |
| r245687 | r245688 | |
| 345 | 345 | { |
| 346 | 346 | int bank = offset / 0x4000; |
| 347 | 347 | |
| 348 | if (bank == 2 && m_ram && m_ram_enabled) | |
| 349 | m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.count()] = data; | |
| 348 | if (bank == 2 && !m_ram.empty() && m_ram_enabled) | |
| 349 | m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.size()] = data; | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | WRITE8_MEMBER(sega8_rom_device::write_mapper) |
| r245687 | r245688 | |
| 717 | 717 | { |
| 718 | 718 | int bank = offset / 0x2000; |
| 719 | 719 | |
| 720 | if (bank == 5 && m_ram && m_ram_enabled) | |
| 721 | return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()]; | |
| 720 | if (bank == 5 && !m_ram.empty() && m_ram_enabled) | |
| 721 | return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.size()]; | |
| 722 | 722 | |
| 723 | 723 | return m_rom[m_rom_bank_base[bank/2] * 0x4000 + (offset & 0x3fff)]; |
| 724 | 724 | } |
| r245687 | r245688 | |
| 749 | 749 | break; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | if (bank == 5 && m_ram && m_ram_enabled) | |
| 753 | m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()] = data; | |
| 752 | if (bank == 5 && !m_ram.empty() && m_ram_enabled) | |
| 753 | m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.size()] = data; | |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /*------------------------------------------------- |
| r245687 | r245688 | |
| 799 | 799 | { |
| 800 | 800 | int bank = offset / 0x2000; |
| 801 | 801 | |
| 802 | if (bank >= 4 && m_ram && m_ram_enabled) | |
| 803 | return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()]; | |
| 802 | if (bank >= 4 && !m_ram.empty() && m_ram_enabled) | |
| 803 | return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.size()]; | |
| 804 | 804 | |
| 805 | 805 | return m_rom[m_rom_bank_base[bank] * 0x2000 + (offset & 0x1fff)]; |
| 806 | 806 | } |
| r245687 | r245688 | |
| 809 | 809 | { |
| 810 | 810 | int bank = offset / 0x2000; |
| 811 | 811 | |
| 812 | if (bank >= 4 && m_ram && m_ram_enabled) | |
| 813 | m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()] = data; | |
| 812 | if (bank >= 4 && !m_ram.empty() && m_ram_enabled) | |
| 813 | m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.size()] = data; | |
| 814 | 814 | |
| 815 | 815 | if (offset < 4) |
| 816 | 816 | { |
| r245687 | r245688 | |
| 930 | 930 | { |
| 931 | 931 | int bank = offset / 0x4000; |
| 932 | 932 | |
| 933 | if (bank == 2 && m_ram && m_ram_enabled) | |
| 933 | if (bank == 2 && !m_ram.empty() && m_ram_enabled) | |
| 934 | 934 | m_ram[m_ram_base * 0x4000 + (offset & 0x3fff)] = data; |
| 935 | 935 | |
| 936 | 936 | if (offset == 0xa000) |
| r245687 | r245688 | |
|---|---|---|
| 612 | 612 | dynamic_buffer rom(len); |
| 613 | 613 | int type; |
| 614 | 614 | |
| 615 | core_fread(m_file, rom, len); | |
| 615 | core_fread(m_file, &rom[0], len); | |
| 616 | 616 | |
| 617 | 617 | if ((len % 0x4000) == 512) |
| 618 | 618 | offset = 512; |
| 619 | 619 | |
| 620 | type = get_cart_type(rom | |
| 620 | type = get_cart_type(&rom[offset], len - offset); | |
| 621 | 621 | slot_string = sega8_get_slot(type); |
| 622 | 622 | |
| 623 | 623 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 65 | 65 | |
| 66 | 66 | //protected: |
| 67 | 67 | UINT8* get_rom_base() { return m_rom; } |
| 68 | UINT8* get_ram_base() { return m_ram; } | |
| 68 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 69 | 69 | UINT32 get_rom_size() { return m_rom_size; } |
| 70 | UINT32 get_ram_size() { return m_ram. | |
| 70 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 71 | 71 | |
| 72 | 72 | void rom_map_setup(UINT32 size); |
| 73 | 73 | void ram_map_setup(UINT8 banks); |
| r245687 | r245688 | |
|---|---|---|
| 171 | 171 | { |
| 172 | 172 | m_upd7725->space(AS_PROGRAM).install_read_bank(0x0000, 0x07ff, "dsp_prg"); |
| 173 | 173 | m_upd7725->space(AS_DATA).install_read_bank(0x0000, 0x03ff, "dsp_data"); |
| 174 | membank("dsp_prg")->set_base(m_dsp_prg); | |
| 175 | membank("dsp_data")->set_base(m_dsp_data); | |
| 174 | membank("dsp_prg")->set_base(&m_dsp_prg[0]); | |
| 175 | membank("dsp_data")->set_base(&m_dsp_data[0]); | |
| 176 | 176 | // copy data in the correct format |
| 177 | 177 | for (int x = 0; x < 0x800; x++) |
| 178 | 178 | m_dsp_prg[x] = (m_bios[x * 4] << 24) | (m_bios[x * 4 + 1] << 16) | (m_bios[x * 4 + 2] << 8) | 0x00; |
| r245687 | r245688 | |
| 184 | 184 | // DSP dump contains prg at offset 0 and data at offset 0x2000 |
| 185 | 185 | READ32_MEMBER( sns_pfest94_device::necdsp_prg_r ) |
| 186 | 186 | { |
| 187 | return get_prg(m_bios, offset); | |
| 187 | return get_prg(&m_bios[0], offset); | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | READ16_MEMBER( sns_pfest94_device::necdsp_data_r ) |
| 191 | 191 | { |
| 192 | return get_data(m_bios, offset + 0x2000/2); | |
| 192 | return get_data(&m_bios[0], offset + 0x2000/2); | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 |
| r245687 | r245688 | |
|---|---|---|
| 41 | 41 | UINT8 m_status; |
| 42 | 42 | UINT32 m_count; |
| 43 | 43 | |
| 44 | dynamic_array<UINT32> m_dsp_prg; | |
| 45 | dynamic_array<UINT16> m_dsp_data; | |
| 44 | std::vector<UINT32> m_dsp_prg; | |
| 45 | std::vector<UINT16> m_dsp_data; | |
| 46 | 46 | |
| 47 | 47 | static const device_timer_id TIMER_EVENT = 0; |
| 48 | 48 | emu_timer *pfest94_timer; |
| r245687 | r245688 | |
|---|---|---|
| 823 | 823 | int shift = 0; |
| 824 | 824 | UINT8 mask = 0xff; |
| 825 | 825 | |
| 826 | if ( | |
| 826 | if (m_nvram.empty()) | |
| 827 | 827 | return 0xff; // this should probably never happen, or are there SA-1 games with no BWRAM? |
| 828 | 828 | |
| 829 | 829 | if (offset < 0x100000) |
| 830 | return m_nvram[offset & (m_nvram. | |
| 830 | return m_nvram[offset & (m_nvram.size() - 1)]; | |
| 831 | 831 | |
| 832 | 832 | // Bitmap BWRAM |
| 833 | 833 | offset -= 0x100000; |
| r245687 | r245688 | |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | // only return the correct bits |
| 851 | return (m_nvram[offset & (m_nvram. | |
| 851 | return (m_nvram[offset & (m_nvram.size() - 1)] >> shift) & mask; | |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | void sns_sa1_device::write_bwram(UINT32 offset, UINT8 data) |
| 855 | 855 | { |
| 856 | 856 | UINT8 mask = 0xff; |
| 857 | 857 | |
| 858 | if ( | |
| 858 | if (m_nvram.empty()) | |
| 859 | 859 | return; // this should probably never happen, or are there SA-1 games with no BWRAM? |
| 860 | 860 | |
| 861 | 861 | if (offset < 0x100000) |
| 862 | 862 | { |
| 863 | m_nvram[offset & (m_nvram. | |
| 863 | m_nvram[offset & (m_nvram.size() - 1)] = data; | |
| 864 | 864 | return; |
| 865 | 865 | } |
| 866 | 866 | |
| r245687 | r245688 | |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | // only change the correct bits, keeping the rest untouched |
| 886 | m_nvram[offset & (m_nvram. | |
| 886 | m_nvram[offset & (m_nvram.size() - 1)] = (m_nvram[offset & (m_nvram.size() - 1)] & ~mask) | data; | |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 |
| r245687 | r245688 | |
|---|---|---|
| 613 | 613 | { |
| 614 | 614 | UINT32 tmplen = length(); |
| 615 | 615 | dynamic_buffer tmpROM(tmplen); |
| 616 | fread(tmpROM, tmplen); | |
| 617 | offset = snes_skip_header(tmpROM, tmplen); | |
| 616 | fread(&tmpROM[0], tmplen); | |
| 617 | offset = snes_skip_header(&tmpROM[0], tmplen); | |
| 618 | 618 | fseek(offset, SEEK_SET); |
| 619 | 619 | } |
| 620 | 620 | |
| r245687 | r245688 | |
| 666 | 666 | { |
| 667 | 667 | UINT32 tot_size = m_cart->get_nvram_size() + m_cart->get_rtc_ram_size(); |
| 668 | 668 | dynamic_buffer temp_nvram(tot_size); |
| 669 | battery_load(temp_nvram, tot_size, 0xff); | |
| 669 | battery_load(&temp_nvram[0], tot_size, 0xff); | |
| 670 | 670 | if (m_cart->get_nvram_size()) |
| 671 | memcpy(m_cart->get_nvram_base(), temp_nvram, m_cart->get_nvram_size()); | |
| 671 | memcpy(m_cart->get_nvram_base(), &temp_nvram[0], m_cart->get_nvram_size()); | |
| 672 | 672 | if (m_cart->get_rtc_ram_size()) |
| 673 | memcpy(m_cart->get_rtc_ram_base(), temp_nvram | |
| 673 | memcpy(m_cart->get_rtc_ram_base(), &temp_nvram[m_cart->get_nvram_size()], m_cart->get_rtc_ram_size()); | |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | //printf("Type %d\n", m_type); |
| r245687 | r245688 | |
| 697 | 697 | UINT32 tot_size = m_cart->get_nvram_size() + m_cart->get_rtc_ram_size(); |
| 698 | 698 | dynamic_buffer temp_nvram(tot_size); |
| 699 | 699 | if (m_cart->get_nvram_size()) |
| 700 | memcpy(temp_nvram, m_cart->get_nvram_base(), m_cart->get_nvram_size()); | |
| 700 | memcpy(&temp_nvram[0], m_cart->get_nvram_base(), m_cart->get_nvram_size()); | |
| 701 | 701 | if (m_cart->get_rtc_ram_size()) |
| 702 | memcpy(temp_nvram | |
| 702 | memcpy(&temp_nvram[m_cart->get_nvram_size()], m_cart->get_rtc_ram_base(), m_cart->get_rtc_ram_size()); | |
| 703 | 703 | |
| 704 | battery_save(temp_nvram, tot_size); | |
| 704 | battery_save(&temp_nvram[0], tot_size); | |
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | } |
| r245687 | r245688 | |
| 1011 | 1011 | dynamic_buffer rom(len); |
| 1012 | 1012 | int type = 0, addon = 0; |
| 1013 | 1013 | |
| 1014 | core_fread(m_file, rom, len); | |
| 1014 | core_fread(m_file, &rom[0], len); | |
| 1015 | 1015 | |
| 1016 | offset = snes_skip_header(rom, len); | |
| 1016 | offset = snes_skip_header(&rom[0], len); | |
| 1017 | 1017 | |
| 1018 | get_cart_type_addon(rom | |
| 1018 | get_cart_type_addon(&rom[offset], len - offset, type, addon); | |
| 1019 | 1019 | // here we're from fullpath, so check if it's a DSP game which needs legacy device (i.e. it has no appended DSP dump) |
| 1020 | 1020 | switch (addon) |
| 1021 | 1021 | { |
| r245687 | r245688 | |
|---|---|---|
| 103 | 103 | // reading and writing |
| 104 | 104 | virtual DECLARE_READ8_MEMBER(read_l) { return 0xff; } // ROM access in range [00-7f] |
| 105 | 105 | virtual DECLARE_READ8_MEMBER(read_h) { return 0xff; } // ROM access in range [80-ff] |
| 106 | virtual DECLARE_READ8_MEMBER(read_ram) { if (m_nvram | |
| 106 | virtual DECLARE_READ8_MEMBER(read_ram) { if (!m_nvram.empty()) return m_nvram[offset & (m_nvram.size()-1)]; else return 0xff; } // NVRAM access | |
| 107 | 107 | virtual DECLARE_WRITE8_MEMBER(write_l) {} // used by carts with subslots |
| 108 | 108 | virtual DECLARE_WRITE8_MEMBER(write_h) {} // used by carts with subslots |
| 109 | virtual DECLARE_WRITE8_MEMBER(write_ram) { if (m_nvram | |
| 109 | virtual DECLARE_WRITE8_MEMBER(write_ram) { if (!m_nvram.empty()) m_nvram[offset & (m_nvram.size()-1)] = data; } // NVRAM access | |
| 110 | 110 | virtual DECLARE_READ8_MEMBER(chip_read) { return 0xff; } |
| 111 | 111 | virtual DECLARE_WRITE8_MEMBER(chip_write) {} |
| 112 | 112 | virtual void speedup_addon_bios_access() {}; |
| r245687 | r245688 | |
| 116 | 116 | void rtc_ram_alloc(UINT32 size); |
| 117 | 117 | void addon_bios_alloc(UINT32 size); |
| 118 | 118 | UINT8* get_rom_base() { return m_rom; }; |
| 119 | UINT8* get_nvram_base() { return m_nvram; }; | |
| 120 | UINT8* get_addon_bios_base() { return m_bios; }; | |
| 121 | UINT8* get_rtc_ram_base() { return m_rtc_ram; }; | |
| 119 | UINT8* get_nvram_base() { return &m_nvram[0]; }; | |
| 120 | UINT8* get_addon_bios_base() { return &m_bios[0]; }; | |
| 121 | UINT8* get_rtc_ram_base() { return &m_rtc_ram[0]; }; | |
| 122 | 122 | UINT32 get_rom_size() { return m_rom_size; }; |
| 123 | UINT32 get_nvram_size() { return m_nvram.count(); }; | |
| 124 | UINT32 get_addon_bios_size() { return m_bios.count(); }; | |
| 125 | UINT32 get_rtc_ram_size() { return m_rtc_ram.count(); }; | |
| 123 | UINT32 get_nvram_size() { return m_nvram.size(); }; | |
| 124 | UINT32 get_addon_bios_size() { return m_bios.size(); }; | |
| 125 | UINT32 get_rtc_ram_size() { return m_rtc_ram.size(); }; | |
| 126 | 126 | |
| 127 | 127 | void rom_map_setup(UINT32 size); |
| 128 | 128 | void save_nvram() { device().save_item(NAME(m_nvram)); } |
| r245687 | r245688 | |
|---|---|---|
| 105 | 105 | // DSP dump contains prg at offset 0 and data at offset 0x2000 |
| 106 | 106 | READ32_MEMBER( sns_rom20_necdsp_device::necdsp_prg_r ) |
| 107 | 107 | { |
| 108 | return get_prg(m_bios, offset); | |
| 108 | return get_prg(&m_bios[0], offset); | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | READ16_MEMBER( sns_rom20_necdsp_device::necdsp_data_r ) |
| 112 | 112 | { |
| 113 | return get_data(m_bios, offset + 0x2000/2); | |
| 113 | return get_data(&m_bios[0], offset + 0x2000/2); | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
| r245687 | r245688 | |
| 171 | 171 | // DSP dump contains prg at offset 0 and data at offset 0x2000 |
| 172 | 172 | READ32_MEMBER( sns_rom21_necdsp_device::necdsp_prg_r ) |
| 173 | 173 | { |
| 174 | return get_prg(m_bios, offset); | |
| 174 | return get_prg(&m_bios[0], offset); | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | READ16_MEMBER( sns_rom21_necdsp_device::necdsp_data_r ) |
| 178 | 178 | { |
| 179 | return get_data(m_bios, offset + 0x2000/2); | |
| 179 | return get_data(&m_bios[0], offset + 0x2000/2); | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| r245687 | r245688 | |
| 290 | 290 | // DSP dump contains prg at offset 0 and data at offset 0x10000 |
| 291 | 291 | READ32_MEMBER( sns_rom_setadsp_device::setadsp_prg_r ) |
| 292 | 292 | { |
| 293 | return get_prg(m_bios, offset); | |
| 293 | return get_prg(&m_bios[0], offset); | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | READ16_MEMBER( sns_rom_setadsp_device::setadsp_data_r ) |
| 297 | 297 | { |
| 298 | return get_data(m_bios, offset + 0x10000/2); | |
| 298 | return get_data(&m_bios[0], offset + 0x10000/2); | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | |
| r245687 | r245688 | |
| 359 | 359 | { |
| 360 | 360 | m_upd7725->space(AS_PROGRAM).install_read_bank(0x0000, 0x07ff, "dsp_prg"); |
| 361 | 361 | m_upd7725->space(AS_DATA).install_read_bank(0x0000, 0x03ff, "dsp_data"); |
| 362 | membank("dsp_prg")->set_base(m_dsp_prg); | |
| 363 | membank("dsp_data")->set_base(m_dsp_data); | |
| 362 | membank("dsp_prg")->set_base(&m_dsp_prg[0]); | |
| 363 | membank("dsp_data")->set_base(&m_dsp_data[0]); | |
| 364 | 364 | // copy data in the correct format |
| 365 | 365 | for (int x = 0; x < 0x800; x++) |
| 366 | 366 | m_dsp_prg[x] = (m_bios[x * 4] << 24) | (m_bios[x * 4 + 1] << 16) | (m_bios[x * 4 + 2] << 8) | 0x00; |
| r245687 | r245688 | |
| 372 | 372 | { |
| 373 | 373 | m_upd7725->space(AS_PROGRAM).install_read_bank(0x0000, 0x07ff, "dsp_prg"); |
| 374 | 374 | m_upd7725->space(AS_DATA).install_read_bank(0x0000, 0x03ff, "dsp_data"); |
| 375 | membank("dsp_prg")->set_base(m_dsp_prg); | |
| 376 | membank("dsp_data")->set_base(m_dsp_data); | |
| 375 | membank("dsp_prg")->set_base(&m_dsp_prg[0]); | |
| 376 | membank("dsp_data")->set_base(&m_dsp_data[0]); | |
| 377 | 377 | // copy data in the correct format |
| 378 | 378 | for (int x = 0; x < 0x800; x++) |
| 379 | 379 | m_dsp_prg[x] = (m_bios[x * 4] << 24) | (m_bios[x * 4 + 1] << 16) | (m_bios[x * 4 + 2] << 8) | 0x00; |
| r245687 | r245688 | |
| 385 | 385 | { |
| 386 | 386 | m_upd96050->space(AS_PROGRAM).install_read_bank(0x0000, 0x3fff, "dsp_prg"); |
| 387 | 387 | m_upd96050->space(AS_DATA).install_read_bank(0x0000, 0x07ff, "dsp_data"); |
| 388 | membank("dsp_prg")->set_base(m_dsp_prg); | |
| 389 | membank("dsp_data")->set_base(m_dsp_data); | |
| 388 | membank("dsp_prg")->set_base(&m_dsp_prg[0]); | |
| 389 | membank("dsp_data")->set_base(&m_dsp_data[0]); | |
| 390 | 390 | // copy data in the correct format |
| 391 | 391 | for (int x = 0; x < 0x3fff; x++) |
| 392 | 392 | m_dsp_prg[x] = (m_bios[x * 4] << 24) | (m_bios[x * 4 + 1] << 16) | (m_bios[x * 4 + 2] << 8) | 0x00; |
| r245687 | r245688 | |
|---|---|---|
| 29 | 29 | virtual DECLARE_READ32_MEMBER(necdsp_prg_r); |
| 30 | 30 | virtual DECLARE_READ16_MEMBER(necdsp_data_r); |
| 31 | 31 | |
| 32 | dynamic_array<UINT32> m_dsp_prg; | |
| 33 | dynamic_array<UINT16> m_dsp_data; | |
| 32 | std::vector<UINT32> m_dsp_prg; | |
| 33 | std::vector<UINT16> m_dsp_data; | |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | // ======================> sns_rom21_necdsp_device |
| r245687 | r245688 | |
| 56 | 56 | virtual DECLARE_READ32_MEMBER(necdsp_prg_r); |
| 57 | 57 | virtual DECLARE_READ16_MEMBER(necdsp_data_r); |
| 58 | 58 | |
| 59 | dynamic_array<UINT32> m_dsp_prg; | |
| 60 | dynamic_array<UINT16> m_dsp_data; | |
| 59 | std::vector<UINT32> m_dsp_prg; | |
| 60 | std::vector<UINT16> m_dsp_data; | |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | // ======================> sns_rom_setadsp_device |
| r245687 | r245688 | |
| 81 | 81 | virtual DECLARE_READ32_MEMBER(setadsp_prg_r); |
| 82 | 82 | virtual DECLARE_READ16_MEMBER(setadsp_data_r); |
| 83 | 83 | |
| 84 | dynamic_array<UINT32> m_dsp_prg; | |
| 85 | dynamic_array<UINT16> m_dsp_data; | |
| 84 | std::vector<UINT32> m_dsp_prg; | |
| 85 | std::vector<UINT16> m_dsp_data; | |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | // ======================> sns_rom_seta10dsp_device |
| r245687 | r245688 | |
|---|---|---|
| 51 | 51 | |
| 52 | 52 | UINT16 m_input_latch; |
| 53 | 53 | UINT16 m_output_latch; |
| 54 | d | |
| 54 | std::vector<UINT16> m_ram; | |
| 55 | 55 | |
| 56 | 56 | required_device<smartmedia_image_device> m_smartmedia; |
| 57 | 57 | required_device<strataflash_device> m_flash; |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | void rom_alloc(UINT32 size, const char *tag); |
| 34 | 34 | void eeprom_alloc(UINT32 size); |
| 35 | 35 | UINT32* get_rom_base() { return m_rom; } |
| 36 | UINT32* get_eeprom_base() { return m_eeprom; } | |
| 36 | UINT32* get_eeprom_base() { return &m_eeprom[0]; } | |
| 37 | 37 | UINT32 get_rom_size() { return m_rom_size; } |
| 38 | UINT32 get_eeprom_size() { return m_eeprom. | |
| 38 | UINT32 get_eeprom_size() { return m_eeprom.size(); } | |
| 39 | 39 | |
| 40 | 40 | void save_eeprom() { device().save_item(NAME(m_eeprom)); } |
| 41 | 41 | |
| r245687 | r245688 | |
| 44 | 44 | UINT32 *m_rom; |
| 45 | 45 | UINT32 m_rom_size; |
| 46 | 46 | UINT32 m_rom_mask; |
| 47 | d | |
| 47 | std::vector<UINT32> m_eeprom; | |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | 50 |
| r245687 | r245688 | |
|---|---|---|
| 241 | 241 | |
| 242 | 242 | READ8_MEMBER(vc4000_ram1k_device::read_ram) |
| 243 | 243 | { |
| 244 | return m_ram[offset & (m_ram. | |
| 244 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | WRITE8_MEMBER(vc4000_ram1k_device::write_ram) |
| 248 | 248 | { |
| 249 | m_ram[offset & (m_ram. | |
| 249 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| r245687 | r245688 | |
| 260 | 260 | |
| 261 | 261 | READ8_MEMBER(vc4000_chess2_device::read_ram) |
| 262 | 262 | { |
| 263 | return m_ram[offset & (m_ram. | |
| 263 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | WRITE8_MEMBER(vc4000_chess2_device::write_ram) |
| 267 | 267 | { |
| 268 | m_ram[offset & (m_ram. | |
| 268 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 269 | 269 | } |
| r245687 | r245688 | |
|---|---|---|
| 36 | 36 | void rom_alloc(UINT32 size, const char *tag); |
| 37 | 37 | void ram_alloc(UINT32 size); |
| 38 | 38 | UINT8* get_rom_base() { return m_rom; } |
| 39 | UINT8* get_ram_base() { return m_ram; } | |
| 39 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 40 | 40 | UINT32 get_rom_size() { return m_rom_size; } |
| 41 | UINT32 get_ram_size() { return m_ram. | |
| 41 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 42 | 42 | |
| 43 | 43 | void save_ram() { device().save_item(NAME(m_ram)); } |
| 44 | 44 |
| r245687 | r245688 | |
|---|---|---|
| 327 | 327 | READ8_MEMBER(a26_rom_2k_device::read_rom) |
| 328 | 328 | { |
| 329 | 329 | // Super Chip RAM reads are mapped in 0x1080-0x10ff |
| 330 | if (m_ram && offset >= 0x80 && offset < 0x100) | |
| 330 | if (!m_ram.empty() && offset >= 0x80 && offset < 0x100) | |
| 331 | 331 | { |
| 332 | return m_ram[offset & (m_ram. | |
| 332 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | return m_rom[offset & (m_rom_size - 1)]; |
| r245687 | r245688 | |
| 346 | 346 | READ8_MEMBER(a26_rom_f4_device::read_rom) |
| 347 | 347 | { |
| 348 | 348 | // Super Chip RAM reads are mapped in 0x1080-0x10ff |
| 349 | if (m_ram && offset >= 0x80 && offset < 0x100) | |
| 349 | if (!m_ram.empty() && offset >= 0x80 && offset < 0x100) | |
| 350 | 350 | { |
| 351 | return m_ram[offset & (m_ram. | |
| 351 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | // update banks |
| r245687 | r245688 | |
| 375 | 375 | WRITE8_MEMBER(a26_rom_f4_device::write_bank) |
| 376 | 376 | { |
| 377 | 377 | // Super Chip RAM writes are mapped in 0x1000-0x107f |
| 378 | if (m_ram && offset < 0x80) | |
| 378 | if (!m_ram.empty() && offset < 0x80) | |
| 379 | 379 | { |
| 380 | m_ram[offset & (m_ram. | |
| 380 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 381 | 381 | return; |
| 382 | 382 | } |
| 383 | 383 | |
| r245687 | r245688 | |
| 412 | 412 | READ8_MEMBER(a26_rom_f6_device::read_rom) |
| 413 | 413 | { |
| 414 | 414 | // Super Chip RAM reads are mapped in 0x1080-0x10ff |
| 415 | if (m_ram && offset >= 0x80 && offset < 0x100) | |
| 415 | if (!m_ram.empty() && offset >= 0x80 && offset < 0x100) | |
| 416 | 416 | { |
| 417 | return m_ram[offset & (m_ram. | |
| 417 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | // update banks |
| r245687 | r245688 | |
| 437 | 437 | WRITE8_MEMBER(a26_rom_f6_device::write_bank) |
| 438 | 438 | { |
| 439 | 439 | // Super Chip RAM writes are mapped in 0x1000-0x107f |
| 440 | if (m_ram && offset < 0x80) | |
| 440 | if (!m_ram.empty() && offset < 0x80) | |
| 441 | 441 | { |
| 442 | m_ram[offset & (m_ram. | |
| 442 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 443 | 443 | return; |
| 444 | 444 | } |
| 445 | 445 | |
| r245687 | r245688 | |
| 480 | 480 | READ8_MEMBER(a26_rom_f8_device::read_rom) |
| 481 | 481 | { |
| 482 | 482 | // Super Chip RAM reads are mapped in 0x1080-0x10ff |
| 483 | if (m_ram && offset >= 0x80 && offset < 0x100) | |
| 483 | if (!m_ram.empty() && offset >= 0x80 && offset < 0x100) | |
| 484 | 484 | { |
| 485 | return m_ram[offset & (m_ram. | |
| 485 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | // update banks |
| r245687 | r245688 | |
| 503 | 503 | WRITE8_MEMBER(a26_rom_f8_device::write_bank) |
| 504 | 504 | { |
| 505 | 505 | // Super Chip RAM writes are mapped in 0x1000-0x107f |
| 506 | if (m_ram && offset < 0x80) | |
| 506 | if (!m_ram.empty() && offset < 0x80) | |
| 507 | 507 | { |
| 508 | m_ram[offset & (m_ram. | |
| 508 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 509 | 509 | return; |
| 510 | 510 | } |
| 511 | 511 | |
| r245687 | r245688 | |
| 536 | 536 | READ8_MEMBER(a26_rom_fa_device::read_rom) |
| 537 | 537 | { |
| 538 | 538 | // CBS RAM+ reads are mapped in 0x1100-0x11ff |
| 539 | if (m_ram && offset >= 0x100 && offset < 0x200) | |
| 539 | if (!m_ram.empty() && offset >= 0x100 && offset < 0x200) | |
| 540 | 540 | { |
| 541 | return m_ram[offset & (m_ram. | |
| 541 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | // update banks |
| r245687 | r245688 | |
| 560 | 560 | WRITE8_MEMBER(a26_rom_fa_device::write_bank) |
| 561 | 561 | { |
| 562 | 562 | // CBS RAM+ writes are mapped in 0x1000-0x10ff |
| 563 | if (m_ram && offset < 0x100) | |
| 563 | if (!m_ram.empty() && offset < 0x100) | |
| 564 | 564 | { |
| 565 | m_ram[offset & (m_ram. | |
| 565 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | switch (offset) |
| r245687 | r245688 | |
| 603 | 603 | UINT8 data; |
| 604 | 604 | |
| 605 | 605 | // Super Chip RAM reads are mapped in 0x1080-0x10ff |
| 606 | if (m_ram && offset >= 0x80 && offset < 0x100) | |
| 606 | if (!m_ram.empty() && offset >= 0x80 && offset < 0x100) | |
| 607 | 607 | { |
| 608 | return m_ram[offset & (m_ram. | |
| 608 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | data = m_rom[offset + (m_base_bank * 0x1000)]; |
| r245687 | r245688 | |
| 625 | 625 | WRITE8_MEMBER(a26_rom_fe_device::write_ram) |
| 626 | 626 | { |
| 627 | 627 | // Super Chip RAM writes are mapped in 0x1000-0x107f |
| 628 | if (m_ram && offset < 0x80) | |
| 628 | if (!m_ram.empty() && offset < 0x80) | |
| 629 | 629 | { |
| 630 | m_ram[offset & (m_ram. | |
| 630 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | |
| r245687 | r245688 | |
| 678 | 678 | |
| 679 | 679 | READ8_MEMBER(a26_rom_3e_device::read_rom) |
| 680 | 680 | { |
| 681 | if (m_ram && m_ram_enable && offset < 0x400) | |
| 681 | if (!m_ram.empty() && m_ram_enable && offset < 0x400) | |
| 682 | 682 | return m_ram[offset + (m_ram_bank * 0x400)]; |
| 683 | 683 | |
| 684 | 684 | if (offset >= 0x800) |
| r245687 | r245688 | |
| 703 | 703 | |
| 704 | 704 | WRITE8_MEMBER(a26_rom_3e_device::write_ram) |
| 705 | 705 | { |
| 706 | if (m_ram && m_ram_enable && offset >= 0x400 && offset < 0x800) | |
| 706 | if (!m_ram.empty() && m_ram_enable && offset >= 0x400 && offset < 0x800) | |
| 707 | 707 | m_ram[(offset & 0x3ff) + (m_ram_bank * 0x400)] = data; |
| 708 | 708 | } |
| 709 | 709 | |
| r245687 | r245688 | |
| 792 | 792 | m_ram_bank = offset - 0xfe8; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | if (m_ram) | |
| 795 | if (!m_ram.empty()) | |
| 796 | 796 | { |
| 797 | 797 | // 1K of RAM |
| 798 | 798 | if (m_base_bank == 0x07 && offset >= 0x400 && offset < 0x800) |
| r245687 | r245688 | |
| 818 | 818 | if (offset >= 0xfe8 && offset <= 0xfeb) |
| 819 | 819 | m_ram_bank = offset - 0xfe8; |
| 820 | 820 | |
| 821 | if (m_ram) | |
| 821 | if (!m_ram.empty()) | |
| 822 | 822 | { |
| 823 | 823 | // 1K of RAM |
| 824 | 824 | if (m_base_bank == 0x07 && offset < 0x400) |
| r245687 | r245688 | |
| 874 | 874 | |
| 875 | 875 | READ8_MEMBER(a26_rom_cv_device::read_rom) |
| 876 | 876 | { |
| 877 | if (m_ram && offset < 0x400) | |
| 877 | if (!m_ram.empty() && offset < 0x400) | |
| 878 | 878 | { |
| 879 | return m_ram[offset & (m_ram. | |
| 879 | return m_ram[offset & (m_ram.size() - 1)]; | |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | // games shall not read from 0x1400-0x17ff (RAM write) |
| r245687 | r245688 | |
| 886 | 886 | |
| 887 | 887 | WRITE8_MEMBER(a26_rom_cv_device::write_bank) |
| 888 | 888 | { |
| 889 | if (m_ram && offset >= 0x400 && offset < 0x800) | |
| 889 | if (!m_ram.empty() && offset >= 0x400 && offset < 0x800) | |
| 890 | 890 | { |
| 891 | m_ram[offset & (m_ram. | |
| 891 | m_ram[offset & (m_ram.size() - 1)] = data; | |
| 892 | 892 | } |
| 893 | 893 | } |
| 894 | 894 |
| r245687 | r245688 | |
|---|---|---|
| 788 | 788 | dynamic_buffer rom(len); |
| 789 | 789 | int type; |
| 790 | 790 | |
| 791 | core_fread(m_file, rom, len); | |
| 791 | core_fread(m_file, &rom[0], len); | |
| 792 | 792 | |
| 793 | type = identify_cart_type(rom, len); | |
| 793 | type = identify_cart_type(&rom[0], len); | |
| 794 | 794 | slot_string = vcs_get_slot(type); |
| 795 | 795 | |
| 796 | 796 | clear(); |
| r245687 | r245688 | |
|---|---|---|
| 62 | 62 | void rom_alloc(UINT32 size, const char *tag); |
| 63 | 63 | void ram_alloc(UINT32 size); |
| 64 | 64 | UINT8* get_rom_base() { return m_rom; } |
| 65 | UINT8* get_ram_base() { return m_ram; } | |
| 65 | UINT8* get_ram_base() { return &m_ram[0]; } | |
| 66 | 66 | UINT32 get_rom_size() { return m_rom_size; } |
| 67 | UINT32 get_ram_size() { return m_ram. | |
| 67 | UINT32 get_ram_size() { return m_ram.size(); } | |
| 68 | 68 | |
| 69 | 69 | protected: |
| 70 | 70 | // internal state |
| r245687 | r245688 | |
|---|---|---|
| 228 | 228 | dynamic_buffer rom(size); |
| 229 | 229 | int type = VECTREX_STD; |
| 230 | 230 | |
| 231 | core_fread(m_file, rom, size); | |
| 231 | core_fread(m_file, &rom[0], size); | |
| 232 | 232 | |
| 233 | if (!memcmp(rom | |
| 233 | if (!memcmp(&rom[0x06], "SRAM", 4)) | |
| 234 | 234 | type = VECTREX_SRAM; |
| 235 | 235 | if (size > 0x8000) |
| 236 | 236 | type = VECTREX_64K; |
| r245687 | r245688 | |
|---|---|---|
| 52 | 52 | |
| 53 | 53 | UINT8* device_videobrain_expansion_card_interface::videobrain_rom_pointer(running_machine &machine, size_t size) |
| 54 | 54 | { |
| 55 | if (m_rom. | |
| 55 | if (m_rom.empty()) | |
| 56 | 56 | { |
| 57 | 57 | m_rom.resize(size); |
| 58 | 58 | |
| 59 | 59 | m_rom_mask = size - 1; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | return m_rom; | |
| 62 | return &m_rom[0]; | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
| r245687 | r245688 | |
| 69 | 69 | |
| 70 | 70 | UINT8* device_videobrain_expansion_card_interface::videobrain_ram_pointer(running_machine &machine, size_t size) |
| 71 | 71 | { |
| 72 | if (m_ram. | |
| 72 | if (m_ram.empty()) | |
| 73 | 73 | { |
| 74 | 74 | m_ram.resize(size); |
| 75 | 75 | |
| 76 | 76 | m_ram_mask = size - 1; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | return m_ram; | |
| 79 | return &m_ram[0]; | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 |
| r245687 | r245688 | |
|---|---|---|
| 49 | 49 | |
| 50 | 50 | void laser110_16k_device::device_reset() |
| 51 | 51 | { |
| 52 | m_slot->m_program->install_ram(0x8000, 0xbfff, m_ram); | |
| 52 | m_slot->m_program->install_ram(0x8000, 0xbfff, &m_ram[0]); | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| r245687 | r245688 | |
| 82 | 82 | |
| 83 | 83 | void laser210_16k_device::device_reset() |
| 84 | 84 | { |
| 85 | m_slot->m_program->install_ram(0x9000, 0xcfff, m_ram); | |
| 85 | m_slot->m_program->install_ram(0x9000, 0xcfff, &m_ram[0]); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| r245687 | r245688 | |
| 115 | 115 | |
| 116 | 116 | void laser310_16k_device::device_reset() |
| 117 | 117 | { |
| 118 | m_slot->m_program->install_ram(0xb800, 0xf7ff, m_ram); | |
| 118 | m_slot->m_program->install_ram(0xb800, 0xf7ff, &m_ram[0]); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
| r245687 | r245688 | |
| 149 | 149 | void laser_64k_device::device_reset() |
| 150 | 150 | { |
| 151 | 151 | // fixed first bank |
| 152 | m_slot->m_program->install_ram(0x8000, 0xbfff, m_ram); | |
| 152 | m_slot->m_program->install_ram(0x8000, 0xbfff, &m_ram[0]); | |
| 153 | 153 | |
| 154 | 154 | // other banks |
| 155 | 155 | m_slot->m_program->install_readwrite_bank(0xc000, 0xffff, tag()); |
| 156 | 156 | |
| 157 | membank(tag())->configure_entries(0, 4, m_ram, 0x4000); | |
| 157 | membank(tag())->configure_entries(0, 4, &m_ram[0], 0x4000); | |
| 158 | 158 | membank(tag())->set_entry(1); |
| 159 | 159 | |
| 160 | 160 | // bank switch |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | virtual void device_reset(); |
| 34 | 34 | |
| 35 | 35 | private: |
| 36 | d | |
| 36 | std::vector<UINT8> m_ram; | |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 | // ======================> laser210_16k_device |
| r245687 | r245688 | |
| 49 | 49 | virtual void device_reset(); |
| 50 | 50 | |
| 51 | 51 | private: |
| 52 | d | |
| 52 | std::vector<UINT8> m_ram; | |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | 55 | // ======================> laser310_16k_device |
| r245687 | r245688 | |
| 65 | 65 | virtual void device_reset(); |
| 66 | 66 | |
| 67 | 67 | private: |
| 68 | d | |
| 68 | std::vector<UINT8> m_ram; | |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | 71 | // ======================> laser_64k_device |
| r245687 | r245688 | |
| 83 | 83 | virtual void device_reset(); |
| 84 | 84 | |
| 85 | 85 | private: |
| 86 | d | |
| 86 | std::vector<UINT8> m_ram; | |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | // device type definition |
| r245687 | r245688 | |
|---|---|---|
| 125 | 125 | m_eeprom_command = 0; |
| 126 | 126 | m_eeprom_start = 0; |
| 127 | 127 | m_eeprom_write_enabled = 0; |
| 128 | switch (m_nvram. | |
| 128 | switch (m_nvram.size()) | |
| 129 | 129 | { |
| 130 | 130 | case 0x80: |
| 131 | 131 | m_eeprom_mode = EEPROM_1K; |
| r245687 | r245688 | |
| 343 | 343 | switch (offset) |
| 344 | 344 | { |
| 345 | 345 | case 0x01: // SRAM bank to select |
| 346 | m_nvram_base = (data * 0x10000) & (m_nvram. | |
| 346 | m_nvram_base = (data * 0x10000) & (m_nvram.size() - 1); | |
| 347 | 347 | default: |
| 348 | 348 | ws_rom_device::write_io(space, offset, data); |
| 349 | 349 | break; |
| r245687 | r245688 | |
|---|---|---|
| 316 | 316 | int type; |
| 317 | 317 | UINT32 nvram; |
| 318 | 318 | |
| 319 | core_fread(m_file, rom, size); | |
| 319 | core_fread(m_file, &rom[0], size); | |
| 320 | 320 | |
| 321 | 321 | // nvram size is not really used here, but we set it up nevertheless |
| 322 | type = get_cart_type(rom, size, nvram); | |
| 322 | type = get_cart_type(&rom[0], size, nvram); | |
| 323 | 323 | slot_string = ws_get_slot(type); |
| 324 | 324 | |
| 325 | 325 | //printf("type: %s\n", slot_string); |
| r245687 | r245688 | |
|---|---|---|
| 36 | 36 | void rom_alloc(UINT32 size, const char *tag); |
| 37 | 37 | void nvram_alloc(UINT32 size); |
| 38 | 38 | UINT8* get_rom_base() { return m_rom; } |
| 39 | UINT8* get_nvram_base() { return m_nvram; } | |
| 39 | UINT8* get_nvram_base() { return &m_nvram[0]; } | |
| 40 | 40 | UINT32 get_rom_size() { return m_rom_size; } |
| 41 | UINT32 get_nvram_size() { return m_nvram. | |
| 41 | UINT32 get_nvram_size() { return m_nvram.size(); } | |
| 42 | 42 | |
| 43 | 43 | void save_nvram() { device().save_item(NAME(m_nvram)); } |
| 44 | 44 | void set_has_rtc(bool val) { m_has_rtc = val; } |
| r245687 | r245688 | |
|---|---|---|
| 584 | 584 | |
| 585 | 585 | // build a list of devices |
| 586 | 586 | device_iterator iter(drivlist.config().root_device()); |
| 587 | d | |
| 587 | std::vector<device_t *> device_list; | |
| 588 | 588 | for (device_t *device = iter.first(); device != NULL; device = iter.next()) |
| 589 | device_list. | |
| 589 | device_list.push_back(device); | |
| 590 | 590 | |
| 591 | 591 | // sort them by tag |
| 592 | qsort(&device_list[0], device_list. | |
| 592 | qsort(&device_list[0], device_list.size(), sizeof(device_list[0]), compare_devices); | |
| 593 | 593 | |
| 594 | 594 | // dump the results |
| 595 | for (int index = 0; index < device_list. | |
| 595 | for (unsigned int index = 0; index < device_list.size(); index++) | |
| 596 | 596 | { |
| 597 | 597 | device_t *device = device_list[index]; |
| 598 | 598 | |
| r245687 | r245688 | |
| 1708 | 1708 | const CSzFileItem *f = _7z->db.db.Files + i; |
| 1709 | 1709 | _7z->curr_file_idx = i; |
| 1710 | 1710 | int namelen = SzArEx_GetFileNameUtf16(&_7z->db, i, NULL); |
| 1711 | d | |
| 1711 | std::vector<UINT16> temp(namelen); | |
| 1712 | 1712 | dynamic_buffer temp2(namelen+1); |
| 1713 | UINT8* temp3 = | |
| 1713 | UINT8* temp3 = &temp2[0]; | |
| 1714 | 1714 | memset(temp3, 0x00, namelen); |
| 1715 | SzArEx_GetFileNameUtf16(&_7z->db, i, temp); | |
| 1715 | SzArEx_GetFileNameUtf16(&_7z->db, i, &temp[0]); | |
| 1716 | 1716 | // crude, need real UTF16->UTF8 conversion ideally |
| 1717 | 1717 | for (int j=0;j<namelen;j++) |
| 1718 | 1718 | { |
| r245687 | r245688 | |
| 1723 | 1723 | { |
| 1724 | 1724 | // decompress data into RAM and identify it |
| 1725 | 1725 | dynamic_buffer data(f->Size); |
| 1726 | _7zerr = _7z_file_decompress(_7z, data, f->Size); | |
| 1726 | _7zerr = _7z_file_decompress(_7z, &data[0], f->Size); | |
| 1727 | 1727 | if (_7zerr == _7ZERR_NONE) |
| 1728 | identify_data((const char*)&temp2[0], data, f->Size); | |
| 1728 | identify_data((const char*)&temp2[0], &data[0], f->Size); | |
| 1729 | 1729 | } |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| r245687 | r245688 | |
| 1749 | 1749 | { |
| 1750 | 1750 | // decompress data into RAM and identify it |
| 1751 | 1751 | dynamic_buffer data(entry->uncompressed_length); |
| 1752 | ziperr = zip_file_decompress(zip, data, entry->uncompressed_length); | |
| 1752 | ziperr = zip_file_decompress(zip, &data[0], entry->uncompressed_length); | |
| 1753 | 1753 | if (ziperr == ZIPERR_NONE) |
| 1754 | identify_data(entry->filename, data, entry->uncompressed_length); | |
| 1754 | identify_data(entry->filename, &data[0], entry->uncompressed_length); | |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | // close up |
| r245687 | r245688 | |
| 1844 | 1844 | // now determine the new data length and allocate temporary memory for it |
| 1845 | 1845 | length = jedbin_output(&jed, NULL, 0); |
| 1846 | 1846 | tempjed.resize(length); |
| 1847 | jedbin_output(&jed, tempjed, length); | |
| 1848 | data = tempjed; | |
| 1847 | jedbin_output(&jed, &tempjed[0], length); | |
| 1848 | data = &tempjed[0]; | |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | // compute the hash of the data |
| r245687 | r245688 | |
|---|---|---|
| 157 | 157 | // opcode descriptor arrays |
| 158 | 158 | simple_list<opcode_desc> m_desc_live_list; // list of live descriptions |
| 159 | 159 | fixed_allocator<opcode_desc> m_desc_allocator; // fixed allocator for descriptions |
| 160 | d | |
| 160 | std::vector<opcode_desc *> m_desc_array; // array of descriptions in PC order | |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | 163 |
| r245687 | r245688 | |
|---|---|---|
| 340 | 340 | disassemble(); |
| 341 | 341 | |
| 342 | 342 | // generate the code via the back-end |
| 343 | m_drcuml.generate(*this, m_inst, m_nextinst); | |
| 343 | m_drcuml.generate(*this, &m_inst[0], m_nextinst); | |
| 344 | 344 | |
| 345 | 345 | // block is no longer in use |
| 346 | 346 | m_inuse = false; |
| r245687 | r245688 | |
|---|---|---|
| 128 | 128 | drcuml_block * m_next; // pointer to next block |
| 129 | 129 | UINT32 m_nextinst; // next instruction to fill in the cache |
| 130 | 130 | UINT32 m_maxinst; // maximum number of instructions |
| 131 | d | |
| 131 | std::vector<uml::instruction> m_inst; // pointer to the instruction list | |
| 132 | 132 | bool m_inuse; // this block is in use |
| 133 | 133 | }; |
| 134 | 134 |
| r245687 | r245688 | |
|---|---|---|
| 200 | 200 | |
| 201 | 201 | UINT8 m_optable[65536]; |
| 202 | 202 | |
| 203 | d | |
| 203 | std::vector<UINT16> m_ipt_ram; | |
| 204 | 204 | UINT8 *m_lbrm; |
| 205 | 205 | |
| 206 | 206 | address_space *m_program; |
| r245687 | r245688 | |
|---|---|---|
| 257 | 257 | m_icache.resize(m_icache_size/4); |
| 258 | 258 | m_dcache.resize(m_dcache_size/4); |
| 259 | 259 | |
| 260 | m_cache = m_dcache; | |
| 260 | m_cache = &m_dcache[0]; | |
| 261 | 261 | m_cache_size = m_dcache_size; |
| 262 | 262 | |
| 263 | 263 | // set up memory handlers |
| r245687 | r245688 | |
| 712 | 712 | if (diff & SR_SwC) |
| 713 | 713 | { |
| 714 | 714 | if (val & SR_SwC) |
| 715 | m_cache = m_icache, m_cache_size = m_icache_size; | |
| 715 | m_cache = &m_icache[0], m_cache_size = m_icache_size; | |
| 716 | 716 | else |
| 717 | m_cache = m_dcache, m_cache_size = m_dcache_size; | |
| 717 | m_cache = &m_dcache[0], m_cache_size = m_dcache_size; | |
| 718 | 718 | } |
| 719 | 719 | m_cpr[0][idx] = val; |
| 720 | 720 |
| r245687 | r245688 | |
|---|---|---|
| 249 | 249 | |
| 250 | 250 | // cache memory |
| 251 | 251 | UINT32 * m_cache; |
| 252 | dynamic_array<UINT32> m_icache; | |
| 253 | dynamic_array<UINT32> m_dcache; | |
| 252 | std::vector<UINT32> m_icache; | |
| 253 | std::vector<UINT32> m_dcache; | |
| 254 | 254 | size_t m_cache_size; |
| 255 | 255 | size_t m_icache_size; |
| 256 | 256 | size_t m_dcache_size; |
| r245687 | r245688 | |
|---|---|---|
| 593 | 593 | tms1xxx_cpu_device::device_reset(); |
| 594 | 594 | |
| 595 | 595 | // pre-decode instructionset |
| 596 | m_fixed_decode.resize_and_clear(0x100); | |
| 597 | m_micro_decode.resize_and_clear(0x100); | |
| 596 | m_fixed_decode.resize(0x100); | |
| 597 | memset(&m_fixed_decode[0], 0, 0x100*sizeof(UINT32)); | |
| 598 | m_micro_decode.resize(0x100); | |
| 599 | memset(&m_micro_decode[0], 0, 0x100*sizeof(UINT32)); | |
| 598 | 600 | |
| 599 | 601 | for (int op = 0; op < 0x100; op++) |
| 600 | 602 | { |
| r245687 | r245688 | |
| 653 | 655 | tms1xxx_cpu_device::device_reset(); |
| 654 | 656 | |
| 655 | 657 | // pre-decode instructionset |
| 656 | m_fixed_decode.resize_and_clear(0x100); | |
| 657 | m_micro_decode.resize_and_clear(0x100); | |
| 658 | m_fixed_decode.resize(0x100); | |
| 659 | memset(&m_fixed_decode[0], 0, 0x100*sizeof(UINT32)); | |
| 660 | m_micro_decode.resize(0x100); | |
| 661 | memset(&m_micro_decode[0], 0, 0x100*sizeof(UINT32)); | |
| 658 | 662 | |
| 659 | 663 | for (int op = 0; op < 0x100; op++) |
| 660 | 664 | { |
| r245687 | r245688 | |
| 717 | 721 | tms1xxx_cpu_device::device_reset(); |
| 718 | 722 | |
| 719 | 723 | // pre-decode instructionset |
| 720 | m_fixed_decode.resize_and_clear(0x200); | |
| 721 | m_micro_decode.resize_and_clear(0x200); | |
| 724 | m_fixed_decode.resize(0x200); | |
| 725 | memset(&m_fixed_decode[0], 0, 0x200*sizeof(UINT32)); | |
| 726 | m_micro_decode.resize(0x200); | |
| 727 | memset(&m_micro_decode[0], 0, 0x200*sizeof(UINT32)); | |
| 722 | 728 | |
| 723 | 729 | for (int op = 0; op < 0x200; op++) |
| 724 | 730 | { |
| r245687 | r245688 | |
| 741 | 747 | |
| 742 | 748 | // like on TMS0970, one of the terms directly select a microinstruction index (via R4-R8), |
| 743 | 749 | // but it can't be pre-determined when it's active |
| 744 | m_micro_direct.resize_and_clear(0x40); | |
| 750 | m_micro_direct.resize(0x40); | |
| 751 | memset(&m_micro_decode[0], 0, 0x40*sizeof(UINT32)); | |
| 745 | 752 | |
| 746 | 753 | for (int op = 0; op < 0x40; op++) |
| 747 | 754 | m_micro_direct[op] = decode_micro(op); |
| r245687 | r245688 | |
|---|---|---|
| 198 | 198 | UINT32 m_x_mask; |
| 199 | 199 | |
| 200 | 200 | // lookup tables |
| 201 | dynamic_array<UINT32> m_fixed_decode; | |
| 202 | dynamic_array<UINT32> m_micro_decode; | |
| 203 | dynamic_array<UINT32> m_micro_direct; | |
| 201 | std::vector<UINT32> m_fixed_decode; | |
| 202 | std::vector<UINT32> m_micro_decode; | |
| 203 | std::vector<UINT32> m_micro_direct; | |
| 204 | 204 | }; |
| 205 | 205 | |
| 206 | 206 |
| r245687 | r245688 | |
|---|---|---|
| 35 | 35 | int dynindex; /* index of next dynamic entry */ |
| 36 | 36 | int pageshift; /* bits to shift to get page index */ |
| 37 | 37 | int addrwidth; /* logical address bus width */ |
| 38 | dynamic_array<offs_t> live; /* array of live entries by table index */ | |
| 39 | dynamic_array<int> fixedpages; /* number of pages each fixed entry covers */ | |
| 40 | dynamic_array<vtlb_entry> table; /* table of entries by address */ | |
| 38 | std::vector<offs_t> live; /* array of live entries by table index */ | |
| 39 | std::vector<int> fixedpages; /* number of pages each fixed entry covers */ | |
| 40 | std::vector<vtlb_entry> table; /* table of entries by address */ | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | |
| r245687 | r245688 | |
| 73 | 73 | assert(vtlb->addrwidth > vtlb->pageshift); |
| 74 | 74 | |
| 75 | 75 | /* allocate the entry array */ |
| 76 | vtlb->live.resize_and_clear(fixed_entries + dynamic_entries); | |
| 76 | vtlb->live.resize(fixed_entries + dynamic_entries); | |
| 77 | memset(&vtlb->live[0], 0, vtlb->live.size()*sizeof(vtlb->live[0])); | |
| 77 | 78 | cpu->save_item(NAME(vtlb->live)); |
| 78 | 79 | |
| 79 | 80 | /* allocate the lookup table */ |
| 80 | vtlb->table.resize_and_clear((size_t) 1 << (vtlb->addrwidth - vtlb->pageshift)); | |
| 81 | vtlb->table.resize((size_t) 1 << (vtlb->addrwidth - vtlb->pageshift)); | |
| 82 | memset(&vtlb->table[0], 0, vtlb->table.size()*sizeof(vtlb->table[0])); | |
| 81 | 83 | cpu->save_item(NAME(vtlb->table)); |
| 82 | 84 | |
| 83 | 85 | /* allocate the fixed page count array */ |
| 84 | 86 | if (fixed_entries > 0) |
| 85 | 87 | { |
| 86 | vtlb->fixedpages.resize_and_clear(fixed_entries); | |
| 88 | vtlb->fixedpages.resize(fixed_entries); | |
| 89 | memset(&vtlb->fixedpages[0], 0, fixed_entries*sizeof(vtlb->fixedpages[0])); | |
| 87 | 90 | cpu->save_item(NAME(vtlb->fixedpages)); |
| 88 | 91 | } |
| 89 | 92 | return vtlb; |
| r245687 | r245688 | |
| 96 | 99 | |
| 97 | 100 | void vtlb_free(vtlb_state *vtlb) |
| 98 | 101 | { |
| 99 | /* free the fixed pages if allocated */ | |
| 100 | if (vtlb->fixedpages != NULL) | |
| 101 | auto_free(vtlb->cpudevice->machine(), vtlb->fixedpages); | |
| 102 | ||
| 103 | /* free the table and array if they exist */ | |
| 104 | if (vtlb->live != NULL) | |
| 105 | auto_free(vtlb->cpudevice->machine(), vtlb->live); | |
| 106 | if (vtlb->table != NULL) | |
| 107 | auto_free(vtlb->cpudevice->machine(), vtlb->table); | |
| 108 | ||
| 109 | /* and then the VTLB object itself */ | |
| 110 | 102 | auto_free(vtlb->cpudevice->machine(), vtlb); |
| 111 | 103 | } |
| 112 | 104 | |
| r245687 | r245688 | |
| 314 | 306 | |
| 315 | 307 | const vtlb_entry *vtlb_table(vtlb_state *vtlb) |
| 316 | 308 | { |
| 317 | return vtlb->table; | |
| 309 | return &vtlb->table[0]; | |
| 318 | 310 | } |
| r245687 | r245688 | |
|---|---|---|
| 55 | 55 | { |
| 56 | 56 | char cpu[2]; |
| 57 | 57 | UINT8 width; |
| 58 | d | |
| 58 | std::vector<cheat_map> cheatmap; | |
| 59 | 59 | UINT8 undo; |
| 60 | 60 | UINT8 signed_cheat; |
| 61 | 61 | UINT8 swapped_cheat; |
| r245687 | r245688 | |
| 2050 | 2050 | if (!debug_command_parameter_cpu_space(machine, cheat.cpu, AS_PROGRAM, space)) |
| 2051 | 2051 | return; |
| 2052 | 2052 | |
| 2053 | active_cheat = cheat.cheatmap.count(); | |
| 2054 | cheat.cheatmap.resize_keep(cheat.cheatmap.count() + real_length); | |
| 2053 | active_cheat = cheat.cheatmap.size(); | |
| 2054 | cheat.cheatmap.resize(cheat.cheatmap.size() + real_length); | |
| 2055 | 2055 | } |
| 2056 | 2056 | |
| 2057 | 2057 | /* initialize cheatmap in the selected space */ |
| r245687 | r245688 | |
| 2148 | 2148 | cheat.undo++; |
| 2149 | 2149 | |
| 2150 | 2150 | /* execute the search */ |
| 2151 | for (cheatindex = 0; cheatindex < | |
| 2151 | for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1) | |
| 2152 | 2152 | if (cheat.cheatmap[cheatindex].state == 1) |
| 2153 | 2153 | { |
| 2154 | 2154 | UINT64 cheat_value = cheat_read_extended(&cheat, *space, cheat.cheatmap[cheatindex].offset); |
| r245687 | r245688 | |
| 2293 | 2293 | } |
| 2294 | 2294 | |
| 2295 | 2295 | /* write the cheat list */ |
| 2296 | for (cheatindex = 0; cheatindex < | |
| 2296 | for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1) | |
| 2297 | 2297 | { |
| 2298 | 2298 | if (cheat.cheatmap[cheatindex].state == 1) |
| 2299 | 2299 | { |
| r245687 | r245688 | |
| 2329 | 2329 | |
| 2330 | 2330 | if (cheat.undo > 0) |
| 2331 | 2331 | { |
| 2332 | for (cheatindex = 0; cheatindex < | |
| 2332 | for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1) | |
| 2333 | 2333 | { |
| 2334 | 2334 | if (cheat.cheatmap[cheatindex].undo == cheat.undo) |
| 2335 | 2335 | { |
| r245687 | r245688 | |
|---|---|---|
| 1979 | 1979 | watchpoint_check(space, WATCHPOINT_READ, address, 0, mem_mask); |
| 1980 | 1980 | |
| 1981 | 1981 | // check hotspots |
| 1982 | if (m_hotspots. | |
| 1982 | if (!m_hotspots.empty()) | |
| 1983 | 1983 | hotspot_check(space, address); |
| 1984 | 1984 | } |
| 1985 | 1985 | |
| r245687 | r245688 | |
| 2542 | 2542 | void device_debug::hotspot_track(int numspots, int threshhold) |
| 2543 | 2543 | { |
| 2544 | 2544 | // if we already have tracking enabled, kill it |
| 2545 | m_hotspots. | |
| 2545 | m_hotspots.clear(); | |
| 2546 | 2546 | |
| 2547 | 2547 | // only start tracking if we have a non-zero count |
| 2548 | 2548 | if (numspots > 0) |
| 2549 | 2549 | { |
| 2550 | 2550 | // allocate memory for hotspots |
| 2551 | m_hotspots.resize_and_clear(numspots, 0xff); | |
| 2551 | m_hotspots.resize(numspots); | |
| 2552 | memset(&m_hotspots[0], 0xff, numspots*sizeof(m_hotspots[0])); | |
| 2552 | 2553 | |
| 2553 | 2554 | // fill in the info |
| 2554 | 2555 | m_hotspot_threshhold = threshhold; |
| r245687 | r245688 | |
| 2951 | 2952 | { |
| 2952 | 2953 | // if hotspots are enabled, turn on all reads |
| 2953 | 2954 | bool enableread = false; |
| 2954 | if (m_hotspots. | |
| 2955 | if (!m_hotspots.empty()) | |
| 2955 | 2956 | enableread = true; |
| 2956 | 2957 | |
| 2957 | 2958 | // see if there are any enabled breakpoints |
| r245687 | r245688 | |
| 3079 | 3080 | offs_t curpc = pc(); |
| 3080 | 3081 | |
| 3081 | 3082 | // see if we have a match in our list |
| 3082 | int hotindex; | |
| 3083 | for (hotindex = 0; hotindex < m_hotspots.count(); hotindex++) | |
| 3083 | unsigned int hotindex; | |
| 3084 | for (hotindex = 0; hotindex < m_hotspots.size(); hotindex++) | |
| 3084 | 3085 | if (m_hotspots[hotindex].m_access == address && m_hotspots[hotindex].m_pc == curpc && m_hotspots[hotindex].m_space == &space) |
| 3085 | 3086 | break; |
| 3086 | 3087 | |
| 3087 | 3088 | // if we didn't find any, make a new entry |
| 3088 | if (hotindex == m_hotspots. | |
| 3089 | if (hotindex == m_hotspots.size()) | |
| 3089 | 3090 | { |
| 3090 | 3091 | // if the bottom of the list is over the threshhold, print it |
| 3091 | hotspot_entry &spot = m_hotspots[m_hotspots. | |
| 3092 | hotspot_entry &spot = m_hotspots[m_hotspots.size() - 1]; | |
| 3092 | 3093 | if (spot.m_count > m_hotspot_threshhold) |
| 3093 | 3094 | debug_console_printf(space.machine(), "Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space.name(), spot.m_access, spot.m_pc, spot.m_count); |
| 3094 | 3095 | |
| 3095 | 3096 | // move everything else down and insert this one at the top |
| 3096 | memmove(&m_hotspots[1], &m_hotspots[0], sizeof(m_hotspots[0]) * (m_hotspots. | |
| 3097 | memmove(&m_hotspots[1], &m_hotspots[0], sizeof(m_hotspots[0]) * (m_hotspots.size() - 1)); | |
| 3097 | 3098 | m_hotspots[0].m_access = address; |
| 3098 | 3099 | m_hotspots[0].m_pc = curpc; |
| 3099 | 3100 | m_hotspots[0].m_space = &space; |
| r245687 | r245688 | |
|---|---|---|
| 236 | 236 | void registerpoint_enable_all(bool enable = true ); |
| 237 | 237 | |
| 238 | 238 | // hotspots |
| 239 | ||
| 239 | bool hotspot_tracking_enabled() const { return !m_hotspots.empty(); } | |
| 240 | 240 | void hotspot_track(int numspots, int threshhold); |
| 241 | 241 | |
| 242 | 242 | // comments |
| r245687 | r245688 | |
| 370 | 370 | address_space * m_space; // space where the access occurred |
| 371 | 371 | UINT32 m_count; // number of hits |
| 372 | 372 | }; |
| 373 | d | |
| 373 | std::vector<hotspot_entry> m_hotspots; // hotspot list | |
| 374 | 374 | int m_hotspot_threshhold; // threshhold for the number of hits to print |
| 375 | 375 | |
| 376 | 376 | // pc tracking |
| r245687 | r245688 | |
|---|---|---|
| 150 | 150 | running_machine &machine() const { return m_machine; } |
| 151 | 151 | debug_view *next() const { return m_next; } |
| 152 | 152 | debug_view_type type() const { return m_type; } |
| 153 | const debug_view_char *viewdata() const { return m_viewdata; } | |
| 153 | const debug_view_char *viewdata() const { return &m_viewdata[0]; } | |
| 154 | 154 | debug_view_xy total_size() { flush_updates(); return m_total; } |
| 155 | 155 | debug_view_xy visible_size() { flush_updates(); return m_visible; } |
| 156 | 156 | debug_view_xy visible_position() { flush_updates(); return m_topleft; } |
| r245687 | r245688 | |
| 216 | 216 | UINT8 m_update_level; // update level; updates when this hits 0 |
| 217 | 217 | bool m_update_pending; // true if there is a pending update |
| 218 | 218 | bool m_osd_update_pending; // true if there is a pending update |
| 219 | d | |
| 219 | std::vector<debug_view_char> m_viewdata; // current array of view data | |
| 220 | 220 | |
| 221 | 221 | private: |
| 222 | 222 | running_machine & m_machine; // machine associated with this view |
| r245687 | r245688 | |
|---|---|---|
| 171 | 171 | // Gather a sorted list of all the breakpoints for all the CPUs |
| 172 | 172 | gather_breakpoints(); |
| 173 | 173 | |
| 174 | int const bpIndex = pos.y - 1; | |
| 175 | if ((bpIndex >= m_buffer.count()) || (bpIndex < 0)) | |
| 174 | int bpIndex = pos.y - 1; | |
| 175 | if ((bpIndex >= m_buffer.size()) || (bpIndex < 0)) | |
| 176 | 176 | return; |
| 177 | 177 | |
| 178 | 178 | // Enable / disable |
| r245687 | r245688 | |
| 209 | 209 | // Collect |
| 210 | 210 | device_debug &debugInterface = *source->device()->debug(); |
| 211 | 211 | for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next()) |
| 212 | m_buffer. | |
| 212 | m_buffer.push_back(bp); | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // And now for the sort |
| 216 | if (m_buffer.count() > 0) | |
| 217 | qsort(&m_buffer[0], m_buffer.count(), sizeof(device_debug::breakpoint *), m_sortType); | |
| 216 | if (!m_buffer.empty()) | |
| 217 | qsort(&m_buffer[0], m_buffer.size(), sizeof(device_debug::breakpoint *), m_sortType); | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| r245687 | r245688 | |
| 230 | 230 | |
| 231 | 231 | // Set the view region so the scroll bars update |
| 232 | 232 | m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1]; |
| 233 | m_total.y = m_buffer. | |
| 233 | m_total.y = m_buffer.size() + 1; | |
| 234 | 234 | if (m_total.y < 10) |
| 235 | 235 | m_total.y = 10; |
| 236 | 236 | |
| 237 | 237 | // Draw |
| 238 | debug_view_char *dest = m_viewdata; | |
| 238 | debug_view_char *dest = &m_viewdata[0]; | |
| 239 | 239 | astring linebuf; |
| 240 | 240 | |
| 241 | 241 | // Header |
| r245687 | r245688 | |
| 278 | 278 | { |
| 279 | 279 | // Breakpoints |
| 280 | 280 | int bpi = row + m_topleft.y - 1; |
| 281 | if ((bpi < m_buffer. | |
| 281 | if ((bpi < m_buffer.size()) && (bpi >= 0)) | |
| 282 | 282 | { |
| 283 | 283 | device_debug::breakpoint *const bp = m_buffer[bpi]; |
| 284 | 284 |
| r245687 | r245688 | |
|---|---|---|
| 52 | 52 | |
| 53 | 53 | // internal state |
| 54 | 54 | int (*m_sortType)(void const *, void const *); |
| 55 | d | |
| 55 | std::vector<device_debug::breakpoint *> m_buffer; | |
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | 58 |
| r245687 | r245688 | |
|---|---|---|
| 167 | 167 | offs_t pc = source.m_space.address_to_byte(source.m_device.safe_pc()) & source.m_space.logbytemask(); |
| 168 | 168 | |
| 169 | 169 | // figure out which row the pc is on |
| 170 | for (int curline = 0; curline < m_byteaddress. | |
| 170 | for (unsigned int curline = 0; curline < m_byteaddress.size(); curline++) | |
| 171 | 171 | if (m_byteaddress[curline] == pc) |
| 172 | 172 | m_cursor.y = curline; |
| 173 | 173 | break; |
| r245687 | r245688 | |
| 464 | 464 | |
| 465 | 465 | // see if the new result is an address we already have |
| 466 | 466 | UINT32 row; |
| 467 | for (row = 0; row < m_byteaddress. | |
| 467 | for (row = 0; row < m_byteaddress.size(); row++) | |
| 468 | 468 | if (m_byteaddress[row] == resultbyte) |
| 469 | 469 | break; |
| 470 | 470 | |
| 471 | 471 | // if we didn't find it, or if it's really close to the bottom, recompute |
| 472 | if (row == m_byteaddress. | |
| 472 | if (row == m_byteaddress.size() || row >= m_total.y - m_visible.y) | |
| 473 | 473 | m_recompute = true; |
| 474 | 474 | |
| 475 | 475 | // otherwise, if it's not visible, adjust the view so it is |
| r245687 | r245688 | |
| 491 | 491 | if (m_recompute) |
| 492 | 492 | { |
| 493 | 493 | // recompute the view |
| 494 | if (m_byteaddress. | |
| 494 | if (!m_byteaddress.empty() && m_last_change_count != source.m_device.debug()->comment_change_count()) | |
| 495 | 495 | { |
| 496 | 496 | // smoosh us against the left column, but not the top row |
| 497 | 497 | m_topleft.x = 0; |
| r245687 | r245688 | |
| 520 | 520 | for (UINT32 row = 0; row < m_visible.y; row++) |
| 521 | 521 | { |
| 522 | 522 | UINT32 effrow = m_topleft.y + row; |
| 523 | if (effrow >= m_byteaddress. | |
| 523 | if (effrow >= m_byteaddress.size()) | |
| 524 | 524 | break; |
| 525 | 525 | if (pcbyte == m_byteaddress[effrow]) |
| 526 | 526 | { |
| r245687 | r245688 | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | // loop over visible rows |
| 544 | debug_view_char *dest = m_viewdata; | |
| 545 | int row_width = m_dasm.count() / m_byteaddress.count(); | |
| 544 | debug_view_char *dest = &m_viewdata[0]; | |
| 545 | int row_width = m_dasm.size() / m_byteaddress.size(); | |
| 546 | 546 | for (UINT32 row = 0; row < m_visible.y; row++) |
| 547 | 547 | { |
| 548 | 548 | UINT32 effrow = m_topleft.y + row; |
| r245687 | r245688 | |
| 550 | 550 | |
| 551 | 551 | // if this visible row is valid, add it to the buffer |
| 552 | 552 | UINT8 attrib = DCA_NORMAL; |
| 553 | if (effrow < m_byteaddress. | |
| 553 | if (effrow < m_byteaddress.size()) | |
| 554 | 554 | { |
| 555 | 555 | // if we're on the line with the PC, recompute and hilight it |
| 556 | 556 | if (pcbyte == m_byteaddress[effrow]) |
| r245687 | r245688 | |
|---|---|---|
| 104 | 104 | int m_divider1, m_divider2; // left and right divider columns |
| 105 | 105 | int m_divider3; // comment divider column |
| 106 | 106 | debug_view_expression m_expression; // expression-related information |
| 107 | dynamic_array<offs_t> m_byteaddress; // addresses of the instructions | |
| 108 | dynamic_array<char> m_dasm; // disassembled instructions | |
| 107 | std::vector<offs_t> m_byteaddress; // addresses of the instructions | |
| 108 | std::vector<char> m_dasm; // disassembled instructions | |
| 109 | 109 | |
| 110 | 110 | // constants |
| 111 | 111 | static const int DEFAULT_DASM_LINES = 1000; |
| r245687 | r245688 | |
|---|---|---|
| 217 | 217 | // loop over visible rows |
| 218 | 218 | for (UINT32 row = 0; row < m_visible.y; row++) |
| 219 | 219 | { |
| 220 | debug_view_char *destmin = m_viewdata | |
| 220 | debug_view_char *destmin = &m_viewdata[row * m_visible.x]; | |
| 221 | 221 | debug_view_char *destmax = destmin + m_visible.x; |
| 222 | 222 | debug_view_char *destrow = destmin - m_topleft.x; |
| 223 | 223 | UINT32 effrow = m_topleft.y + row; |
| r245687 | r245688 | |
|---|---|---|
| 212 | 212 | |
| 213 | 213 | // loop over visible rows |
| 214 | 214 | screen_device *screen = machine().first_screen(); |
| 215 | debug_view_char *dest = m_viewdata; | |
| 215 | debug_view_char *dest = &m_viewdata[0]; | |
| 216 | 216 | for (UINT32 row = 0; row < m_visible.y; row++) |
| 217 | 217 | { |
| 218 | 218 | UINT32 col = 0; |
| r245687 | r245688 | |
|---|---|---|
| 72 | 72 | m_topleft.y = curseq - text_buffer_line_index_to_seqnum(&m_textbuf, 0); |
| 73 | 73 | |
| 74 | 74 | // loop over visible rows |
| 75 | debug_view_char *dest = m_viewdata; | |
| 75 | debug_view_char *dest = &m_viewdata[0]; | |
| 76 | 76 | for (UINT32 row = 0; row < m_visible.y; row++) |
| 77 | 77 | { |
| 78 | 78 | const char *line = text_buffer_get_seqnum_line(&m_textbuf, curseq++); |
| r245687 | r245688 | |
|---|---|---|
| 198 | 198 | gather_watchpoints(); |
| 199 | 199 | |
| 200 | 200 | int const wpIndex = pos.y - 1; |
| 201 | if ((wpIndex >= m_buffer. | |
| 201 | if ((wpIndex >= m_buffer.size()) || (wpIndex < 0)) | |
| 202 | 202 | return; |
| 203 | 203 | |
| 204 | 204 | // Enable / disable |
| r245687 | r245688 | |
| 235 | 235 | for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++) |
| 236 | 236 | { |
| 237 | 237 | for (device_debug::watchpoint *wp = debugInterface.watchpoint_first(spacenum); wp != NULL; wp = wp->next()) |
| 238 | m_buffer. | |
| 238 | m_buffer.push_back(wp); | |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // And now for the sort |
| 243 | if (m_buffer.count() > 0) | |
| 244 | qsort(&m_buffer[0], m_buffer.count(), sizeof(device_debug::watchpoint *), m_sortType); | |
| 243 | if (!m_buffer.empty()) | |
| 244 | qsort(&m_buffer[0], m_buffer.size(), sizeof(device_debug::watchpoint *), m_sortType); | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| r245687 | r245688 | |
| 257 | 257 | |
| 258 | 258 | // Set the view region so the scroll bars update |
| 259 | 259 | m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1]; |
| 260 | m_total.y = m_buffer. | |
| 260 | m_total.y = m_buffer.size() + 1; | |
| 261 | 261 | if (m_total.y < 10) |
| 262 | 262 | m_total.y = 10; |
| 263 | 263 | |
| 264 | 264 | // Draw |
| 265 | debug_view_char *dest = m_viewdata; | |
| 265 | debug_view_char *dest = &m_viewdata[0]; | |
| 266 | 266 | astring linebuf; |
| 267 | 267 | |
| 268 | 268 | // Header |
| r245687 | r245688 | |
| 313 | 313 | { |
| 314 | 314 | // watchpoints |
| 315 | 315 | int const wpi = row + m_topleft.y - 1; |
| 316 | if ((wpi < m_buffer. | |
| 316 | if ((wpi < m_buffer.size()) && wpi >= 0) | |
| 317 | 317 | { |
| 318 | 318 | static char const *const types[] = { "unkn ", "read ", "write", "r/w " }; |
| 319 | 319 | device_debug::watchpoint *const wp = m_buffer[wpi]; |
| r245687 | r245688 | |
|---|---|---|
| 48 | 48 | |
| 49 | 49 | // internal state |
| 50 | 50 | int (*m_sortType)(void const *, void const *); |
| 51 | d | |
| 51 | std::vector<device_debug::watchpoint *> m_buffer; | |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 |
| r245687 | r245688 | |
|---|---|---|
| 384 | 384 | // dynamic allocation of a shared pointer |
| 385 | 385 | void allocate(UINT32 entries) |
| 386 | 386 | { |
| 387 | assert(m_allocated. | |
| 387 | assert(m_allocated.empty()); | |
| 388 | 388 | m_allocated.resize(entries); |
| 389 | this->m_target = m_allocated; | |
| 389 | this->m_target = &m_allocated[0]; | |
| 390 | 390 | m_bytes = entries * sizeof(_PointerType); |
| 391 | 391 | this->m_base.save_item(this->m_allocated, this->m_tag); |
| 392 | 392 | } |
| r245687 | r245688 | |
| 403 | 403 | // internal state |
| 404 | 404 | size_t m_bytes; |
| 405 | 405 | UINT8 m_width; |
| 406 | d | |
| 406 | std::vector<_PointerType> m_allocated; | |
| 407 | 407 | }; |
| 408 | 408 | |
| 409 | 409 | // optional shared pointer finder |
| r245687 | r245688 | |
|---|---|---|
| 121 | 121 | |
| 122 | 122 | // local variables to hold mutable copies of gfx layout data |
| 123 | 123 | gfx_layout glcopy; |
| 124 | dynamic_array<UINT32> extxoffs(0); | |
| 125 | dynamic_array<UINT32> extyoffs(0); | |
| 124 | std::vector<UINT32> extxoffs(0); | |
| 125 | std::vector<UINT32> extyoffs(0); | |
| 126 | 126 | |
| 127 | 127 | // loop over all elements |
| 128 | 128 | for (int curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++) |
| r245687 | r245688 | |
| 206 | 206 | memcpy(&extyoffs[0], (glcopy.extyoffs != NULL) ? glcopy.extyoffs : glcopy.yoffset, glcopy.height * sizeof(UINT32)); |
| 207 | 207 | |
| 208 | 208 | // always use the extended offsets here |
| 209 | glcopy.extxoffs = extxoffs; | |
| 210 | glcopy.extyoffs = extyoffs; | |
| 209 | glcopy.extxoffs = &extxoffs[0]; | |
| 210 | glcopy.extyoffs = &extyoffs[0]; | |
| 211 | 211 | |
| 212 | 212 | // expand X and Y by the scale factors |
| 213 | 213 | if (xscale > 1) |
| r245687 | r245688 | |
|---|---|---|
| 431 | 431 | hashes.reset(); |
| 432 | 432 | size = (UINT32) length(); |
| 433 | 433 | |
| 434 | buf.resize_and_clear(size); | |
| 434 | buf.resize(size); | |
| 435 | memset(&buf[0], 0, size); | |
| 435 | 436 | |
| 436 | 437 | /* read the file */ |
| 437 | 438 | fseek(0, SEEK_SET); |
| 438 | fread(buf, size); | |
| 439 | fread(&buf[0], size); | |
| 439 | 440 | |
| 440 | 441 | if (partialhash) |
| 441 | partialhash(hashes, buf, size, types); | |
| 442 | partialhash(hashes, &buf[0], size, types); | |
| 442 | 443 | else |
| 443 | hashes.compute(buf, size, types); | |
| 444 | hashes.compute(&buf[0], size, types); | |
| 444 | 445 | |
| 445 | 446 | /* cleanup */ |
| 446 | 447 | fseek(0, SEEK_SET); |
| r245687 | r245688 | |
|---|---|---|
| 146 | 146 | |
| 147 | 147 | // internal state |
| 148 | 148 | UINT8 m_outputs; // number of outputs |
| 149 | d | |
| 149 | std::vector<UINT8> m_outputmap; // map of inputs to outputs | |
| 150 | 150 | sound_stream * m_mixer_stream; // mixing stream |
| 151 | 151 | }; |
| 152 | 152 |
| r245687 | r245688 | |
|---|---|---|
| 190 | 190 | if (m_layout_is_raw) |
| 191 | 191 | { |
| 192 | 192 | // RAW layouts don't need these arrays |
| 193 | m_layout_planeoffset.reset(); | |
| 194 | m_layout_xoffset.reset(); | |
| 195 | m_layout_yoffset.reset(); | |
| 196 | m_gfxdata_allocated.reset(); | |
| 193 | m_layout_planeoffset.clear(); | |
| 194 | m_layout_xoffset.clear(); | |
| 195 | m_layout_yoffset.clear(); | |
| 196 | m_gfxdata_allocated.clear(); | |
| 197 | 197 | |
| 198 | 198 | // modulos are determined for us by the layout |
| 199 | 199 | m_line_modulo = gl.yoffs(0) / 8; |
| r245687 | r245688 | |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // mark everything dirty |
| 232 | m_dirty.resize_and_clear(m_total_elements, 1); | |
| 232 | m_dirty.resize(m_total_elements); | |
| 233 | memset(&m_dirty[0], 1, m_total_elements); | |
| 233 | 234 | |
| 234 | 235 | // allocate a pen usage array for entries with 32 pens or less |
| 235 | 236 | if (m_color_depth <= 32) |
| 236 | 237 | m_pen_usage.resize(m_total_elements); |
| 237 | 238 | else |
| 238 | m_pen_usage. | |
| 239 | m_pen_usage.clear(); | |
| 239 | 240 | } |
| 240 | 241 | |
| 241 | 242 | |
| r245687 | r245688 | |
| 264 | 265 | void gfx_element::set_source(const UINT8 *source) |
| 265 | 266 | { |
| 266 | 267 | m_srcdata = source; |
| 267 | memset(m_dirty, 1, elements()); | |
| 268 | memset(&m_dirty[0], 1, elements()); | |
| 268 | 269 | if (m_layout_is_raw) m_gfxdata = const_cast<UINT8 *>(source); |
| 269 | 270 | } |
| 270 | 271 | |
| r245687 | r245688 | |
| 280 | 281 | m_total_elements = total; |
| 281 | 282 | |
| 282 | 283 | // mark everything dirty |
| 283 | m_dirty.resize_and_clear(m_total_elements, 1); | |
| 284 | m_dirty.resize(m_total_elements); | |
| 285 | memset(&m_dirty[0], 1, m_total_elements); | |
| 284 | 286 | |
| 285 | 287 | // allocate a pen usage array for entries with 32 pens or less |
| 286 | 288 | if (m_color_depth <= 32) |
| r245687 | r245688 | |
| 353 | 355 | } |
| 354 | 356 | |
| 355 | 357 | // (re)compute pen usage |
| 356 | if (code < m_pen_usage. | |
| 358 | if (code < m_pen_usage.size()) | |
| 357 | 359 | { |
| 358 | 360 | // iterate over data, creating a bitmask of live pens |
| 359 | 361 | const UINT8 *dp = m_gfxdata + code * m_char_modulo; |
| r245687 | r245688 | |
|---|---|---|
| 164 | 164 | UINT16 granularity() const { return m_color_granularity; } |
| 165 | 165 | UINT32 colors() const { return m_total_colors; } |
| 166 | 166 | UINT32 rowbytes() const { return m_line_modulo; } |
| 167 | bool has_pen_usage() const { return | |
| 167 | bool has_pen_usage() const { return !m_pen_usage.empty(); } | |
| 168 | 168 | |
| 169 | 169 | // used by tilemaps |
| 170 | 170 | UINT32 dirtyseq() const { return m_dirtyseq; } |
| r245687 | r245688 | |
| 188 | 188 | const UINT8 *get_data(UINT32 code) |
| 189 | 189 | { |
| 190 | 190 | assert(code < elements()); |
| 191 | if (code < m_dirty. | |
| 191 | if (code < m_dirty.size() && m_dirty[code]) decode(code); | |
| 192 | 192 | return m_gfxdata + code * m_char_modulo + m_starty * m_line_modulo + m_startx; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | UINT32 pen_usage(UINT32 code) |
| 196 | 196 | { |
| 197 | assert(code < m_pen_usage. | |
| 197 | assert(code < m_pen_usage.size()); | |
| 198 | 198 | if (m_dirty[code]) decode(code); |
| 199 | 199 | return m_pen_usage[code]; |
| 200 | 200 | } |
| r245687 | r245688 | |
| 293 | 293 | UINT8 * m_gfxdata; // pointer to decoded pixel data, 8bpp |
| 294 | 294 | dynamic_buffer m_gfxdata_allocated; // allocated decoded pixel data, 8bpp |
| 295 | 295 | dynamic_buffer m_dirty; // dirty array for detecting chars that need decoding |
| 296 | d | |
| 296 | std::vector<UINT32> m_pen_usage; // bitmask of pens that are used (pens 0-31 only) | |
| 297 | 297 | |
| 298 | 298 | bool m_layout_is_raw; // raw layout? |
| 299 | 299 | UINT8 m_layout_planes; // bit planes in the layout |
| 300 | 300 | UINT32 m_layout_xormask; // xor mask applied to each bit offset |
| 301 | 301 | UINT32 m_layout_charincrement; // per-character increment in source data |
| 302 | dynamic_array<UINT32> m_layout_planeoffset;// plane offsets | |
| 303 | dynamic_array<UINT32> m_layout_xoffset; // X offsets | |
| 304 | dynamic_array<UINT32> m_layout_yoffset; // Y offsets | |
| 302 | std::vector<UINT32> m_layout_planeoffset;// plane offsets | |
| 303 | std::vector<UINT32> m_layout_xoffset; // X offsets | |
| 304 | std::vector<UINT32> m_layout_yoffset; // Y offsets | |
| 305 | 305 | }; |
| 306 | 306 | |
| 307 | 307 |
| r245687 | r245688 | |
|---|---|---|
| 132 | 132 | m_filtered_count(0), |
| 133 | 133 | m_options(options), |
| 134 | 134 | m_included(s_driver_count, 0), |
| 135 | m_config(s_driver_count, | |
| 135 | m_config(s_driver_count, NULL) | |
| 136 | 136 | { |
| 137 | 137 | include_all(); |
| 138 | 138 | } |
| r245687 | r245688 | |
| 143 | 143 | m_filtered_count(0), |
| 144 | 144 | m_options(options), |
| 145 | 145 | m_included(s_driver_count, 0), |
| 146 | m_config(s_driver_count, | |
| 146 | m_config(s_driver_count, NULL) | |
| 147 | 147 | { |
| 148 | 148 | filter(string); |
| 149 | 149 | } |
| r245687 | r245688 | |
| 154 | 154 | m_filtered_count(0), |
| 155 | 155 | m_options(options), |
| 156 | 156 | m_included(s_driver_count, 0), |
| 157 | m_config(s_driver_count, | |
| 157 | m_config(s_driver_count, NULL) | |
| 158 | 158 | { |
| 159 | 159 | filter(driver); |
| 160 | 160 | } |
| r245687 | r245688 | |
| 242 | 242 | |
| 243 | 243 | void driver_enumerator::include_all() |
| 244 | 244 | { |
| 245 | memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); | |
| 245 | memset(&m_included[0], 1, sizeof(m_included[0]) * s_driver_count); | |
| 246 | 246 | m_filtered_count = s_driver_count; |
| 247 | 247 | |
| 248 | 248 | // always exclude the empty driver |
| r245687 | r245688 | |
| 316 | 316 | srand(osd_ticks()); |
| 317 | 317 | |
| 318 | 318 | // allocate a temporary list |
| 319 | d | |
| 319 | std::vector<int> templist(m_filtered_count); | |
| 320 | 320 | int arrayindex = 0; |
| 321 | 321 | for (int index = 0; index < s_driver_count; index++) |
| 322 | 322 | if (m_included[index]) |
| r245687 | r245688 | |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | // allocate memory to track the penalty value |
| 343 | d | |
| 343 | std::vector<int> penalty(count); | |
| 344 | 344 | |
| 345 | 345 | // initialize everyone's states |
| 346 | 346 | for (int matchnum = 0; matchnum < count; matchnum++) |
| r245687 | r245688 | |
|---|---|---|
| 106 | 106 | int filter(const char *string = NULL); |
| 107 | 107 | int filter(const game_driver &driver); |
| 108 | 108 | void include_all(); |
| 109 | void exclude_all() { memset(m_included, 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; } | |
| 109 | void exclude_all() { memset(&m_included[0], 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; } | |
| 110 | 110 | void reset() { m_current = -1; } |
| 111 | 111 | bool next(); |
| 112 | 112 | bool next_excluded(); |
| r245687 | r245688 | |
| 146 | 146 | int m_current; |
| 147 | 147 | int m_filtered_count; |
| 148 | 148 | emu_options & m_options; |
| 149 | dynamic_array<UINT8> m_included; | |
| 150 | mutable dynamic_array<machine_config *> m_config; | |
| 149 | std::vector<UINT8> m_included; | |
| 150 | mutable std::vector<machine_config *> m_config; | |
| 151 | 151 | mutable simple_list<config_entry> m_config_cache; |
| 152 | 152 | }; |
| 153 | 153 |
| r245687 | r245688 | |
|---|---|---|
| 40 | 40 | resource_pool::resource_pool(int hash_size) |
| 41 | 41 | : m_hash_size(hash_size), |
| 42 | 42 | m_listlock(osd_lock_alloc()), |
| 43 | m_hash(hash_size | |
| 43 | m_hash(hash_size), | |
| 44 | 44 | m_ordered_head(NULL), |
| 45 | 45 | m_ordered_tail(NULL) |
| 46 | 46 | { |
| 47 | memset(&m_hash[0], 0, hash_size*sizeof(m_hash[0])); | |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 |
| r245687 | r245688 | |
|---|---|---|
| 142 | 142 | private: |
| 143 | 143 | int m_hash_size; |
| 144 | 144 | osd_lock * m_listlock; |
| 145 | d | |
| 145 | std::vector<resource_pool_item *> m_hash; | |
| 146 | 146 | resource_pool_item * m_ordered_head; |
| 147 | 147 | resource_pool_item * m_ordered_tail; |
| 148 | 148 | static UINT64 s_id; |
| r245687 | r245688 | |
|---|---|---|
| 117 | 117 | m_indirect_colors[index] = rgb; |
| 118 | 118 | |
| 119 | 119 | // update the palette for any colortable entries that reference it |
| 120 | for (UINT32 pen = 0; pen < m_indirect_pens. | |
| 120 | for (UINT32 pen = 0; pen < m_indirect_pens.size(); pen++) | |
| 121 | 121 | if (m_indirect_pens[pen] == index) |
| 122 | 122 | m_palette->entry_set_color(pen, rgb); |
| 123 | 123 | } |
| r245687 | r245688 | |
| 150 | 150 | UINT32 entry = gfx.colorbase() + (color % gfx.colors()) * gfx.granularity(); |
| 151 | 151 | |
| 152 | 152 | // make sure we are in range |
| 153 | assert(entry < m_indirect_pens. | |
| 153 | assert(entry < m_indirect_pens.size()); | |
| 154 | 154 | assert(gfx.depth() <= 32); |
| 155 | 155 | |
| 156 | 156 | // either gfx->color_depth entries or as many as we can get up until the end |
| 157 | int count = MIN(gfx.depth(), m_indirect_pens. | |
| 157 | int count = MIN(gfx.depth(), m_indirect_pens.size() - entry); | |
| 158 | 158 | |
| 159 | 159 | // set a bit anywhere the transcolor matches |
| 160 | 160 | UINT32 mask = 0; |
| r245687 | r245688 | |
|---|---|---|
| 361 | 361 | void set_pen_color(pen_t pen, rgb_t rgb) { m_palette->entry_set_color(pen, rgb); } |
| 362 | 362 | void set_pen_color(pen_t pen, UINT8 r, UINT8 g, UINT8 b) { m_palette->entry_set_color(pen, rgb_t(r, g, b)); } |
| 363 | 363 | void set_pen_colors(pen_t color_base, const rgb_t *colors, int color_count) { while (color_count--) set_pen_color(color_base++, *colors++); } |
| 364 | void set_pen_colors(pen_t color_base, const std::vector<rgb_t> &colors) { for(unsigned int i=0; i != colors.size(); i++) set_pen_color(color_base+i, colors[i]); } | |
| 364 | 365 | void set_pen_contrast(pen_t pen, double bright) { m_palette->entry_set_contrast(pen, bright); } |
| 365 | 366 | |
| 366 | 367 | // indirection (aka colortables) |
| r245687 | r245688 | |
| 447 | 448 | pen_t m_black_pen; // precomputed black pen value |
| 448 | 449 | |
| 449 | 450 | // indirection state |
| 450 | dynamic_array<rgb_t> m_indirect_colors; // actual colors set for indirection | |
| 451 | dynamic_array<UINT16> m_indirect_pens; // indirection values | |
| 451 | std::vector<rgb_t> m_indirect_colors; // actual colors set for indirection | |
| 452 | std::vector<UINT16> m_indirect_pens; // indirection values | |
| 452 | 453 | |
| 453 | 454 | struct shadow_table_data |
| 454 | 455 | { |
| r245687 | r245688 | |
| 460 | 461 | }; |
| 461 | 462 | shadow_table_data m_shadow_tables[MAX_SHADOW_PRESETS]; // array of shadow table data |
| 462 | 463 | |
| 463 | dynamic_array<pen_t> m_save_pen; // pens for save/restore | |
| 464 | dynamic_array<float> m_save_contrast; // brightness for save/restore | |
| 464 | std::vector<pen_t> m_save_pen; // pens for save/restore | |
| 465 | std::vector<float> m_save_contrast; // brightness for save/restore | |
| 465 | 466 | |
| 466 | dynamic_array<pen_t> m_pen_array; | |
| 467 | dynamic_array<pen_t> m_shadow_array; | |
| 468 | dynamic_array<pen_t> m_hilight_array; | |
| 467 | std::vector<pen_t> m_pen_array; | |
| 468 | std::vector<pen_t> m_shadow_array; | |
| 469 | std::vector<pen_t> m_hilight_array; | |
| 469 | 470 | palette_init_delegate m_init; |
| 470 | 471 | }; |
| 471 | 472 |
| r245687 | r245688 | |
|---|---|---|
| 239 | 239 | return m_hashes; |
| 240 | 240 | |
| 241 | 241 | // if we have ZIP data, just hash that directly |
| 242 | if (m__7zdata. | |
| 242 | if (!m__7zdata.empty()) | |
| 243 | 243 | { |
| 244 | m_hashes.compute(m__7zdata, m__7zdata. | |
| 244 | m_hashes.compute(&m__7zdata[0], m__7zdata.size(), needed.c_str()); | |
| 245 | 245 | return m_hashes; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | if (m_zipdata. | |
| 248 | if (!m_zipdata.empty()) | |
| 249 | 249 | { |
| 250 | m_hashes.compute(m_zipdata, m_zipdata. | |
| 250 | m_hashes.compute(&m_zipdata[0], m_zipdata.size(), needed.c_str()); | |
| 251 | 251 | return m_hashes; |
| 252 | 252 | } |
| 253 | 253 | |
| r245687 | r245688 | |
| 409 | 409 | core_fclose(m_file); |
| 410 | 410 | m_file = NULL; |
| 411 | 411 | |
| 412 | m__7zdata.reset(); | |
| 413 | m_zipdata.reset(); | |
| 412 | m__7zdata.clear(); | |
| 413 | m_zipdata.clear(); | |
| 414 | 414 | |
| 415 | 415 | if (m_remove_on_close) |
| 416 | 416 | osd_rmfile(m_fullpath.c_str()); |
| r245687 | r245688 | |
| 751 | 751 | file_error emu_file::load_zipped_file() |
| 752 | 752 | { |
| 753 | 753 | assert(m_file == NULL); |
| 754 | assert(m_zipdata. | |
| 754 | assert(m_zipdata.empty()); | |
| 755 | 755 | assert(m_zipfile != NULL); |
| 756 | 756 | |
| 757 | 757 | // allocate some memory |
| 758 | 758 | m_zipdata.resize(m_ziplength); |
| 759 | 759 | |
| 760 | 760 | // read the data into our buffer and return |
| 761 | zip_error ziperr = zip_file_decompress(m_zipfile, m_zipdata, m_zipdata. | |
| 761 | zip_error ziperr = zip_file_decompress(m_zipfile, &m_zipdata[0], m_zipdata.size()); | |
| 762 | 762 | if (ziperr != ZIPERR_NONE) |
| 763 | 763 | { |
| 764 | m_zipdata. | |
| 764 | m_zipdata.clear(); | |
| 765 | 765 | return FILERR_FAILURE; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | // convert to RAM file |
| 769 | file_error filerr = core_fopen_ram(m_zipdata, m_zipdata. | |
| 769 | file_error filerr = core_fopen_ram(&m_zipdata[0], m_zipdata.size(), m_openflags, &m_file); | |
| 770 | 770 | if (filerr != FILERR_NONE) |
| 771 | 771 | { |
| 772 | m_zipdata. | |
| 772 | m_zipdata.clear(); | |
| 773 | 773 | return FILERR_FAILURE; |
| 774 | 774 | } |
| 775 | 775 | |
| r245687 | r245688 | |
| 880 | 880 | file_error emu_file::load__7zped_file() |
| 881 | 881 | { |
| 882 | 882 | assert(m_file == NULL); |
| 883 | assert(m__7zdata. | |
| 883 | assert(m__7zdata.empty()); | |
| 884 | 884 | assert(m__7zfile != NULL); |
| 885 | 885 | |
| 886 | 886 | // allocate some memory |
| 887 | 887 | m__7zdata.resize(m__7zlength); |
| 888 | 888 | |
| 889 | 889 | // read the data into our buffer and return |
| 890 | _7z_error _7zerr = _7z_file_decompress(m__7zfile, m__7zdata, m__7zdata. | |
| 890 | _7z_error _7zerr = _7z_file_decompress(m__7zfile, &m__7zdata[0], m__7zdata.size()); | |
| 891 | 891 | if (_7zerr != _7ZERR_NONE) |
| 892 | 892 | { |
| 893 | m__7zdata. | |
| 893 | m__7zdata.clear(); | |
| 894 | 894 | return FILERR_FAILURE; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | // convert to RAM file |
| 898 | file_error filerr = core_fopen_ram(m__7zdata, m__7zdata. | |
| 898 | file_error filerr = core_fopen_ram(&m__7zdata[0], m__7zdata.size(), m_openflags, &m_file); | |
| 899 | 899 | if (filerr != FILERR_NONE) |
| 900 | 900 | { |
| 901 | m__7zdata. | |
| 901 | m__7zdata.clear(); | |
| 902 | 902 | return FILERR_FAILURE; |
| 903 | 903 | } |
| 904 | 904 |
| r245687 | r245688 | |
|---|---|---|
| 596 | 596 | dskchg = 1; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | int floppy_image_device::find_index(UINT32 position, const UINT32 | |
| 599 | int floppy_image_device::find_index(UINT32 position, const std::vector<UINT32> &buf) | |
| 600 | 600 | { |
| 601 | int spos = (buf | |
| 601 | int spos = (buf.size() >> 1)-1; | |
| 602 | 602 | int step; |
| 603 | for(step=1; step<buf | |
| 603 | for(step=1; step<buf.size()+1; step<<=1); | |
| 604 | 604 | step >>= 1; |
| 605 | 605 | |
| 606 | 606 | for(;;) { |
| 607 | if(spos >= buf | |
| 607 | if(spos >= buf.size() || (spos > 0 && (buf[spos] & floppy_image::TIME_MASK) > position)) { | |
| 608 | 608 | spos -= step; |
| 609 | 609 | step >>= 1; |
| 610 | } else if(spos < 0 || (spos < buf | |
| 610 | } else if(spos < 0 || (spos < buf.size()-1 && (buf[spos+1] & floppy_image::TIME_MASK) <= position)) { | |
| 611 | 611 | spos += step; |
| 612 | 612 | step >>= 1; |
| 613 | 613 | } else |
| r245687 | r245688 | |
| 637 | 637 | if(!image || mon) |
| 638 | 638 | return attotime::never; |
| 639 | 639 | |
| 640 | int cells = image->get_track_size(cyl, ss, subcyl); | |
| 640 | std::vector<UINT32> &buf = image->get_buffer(cyl, ss, subcyl); | |
| 641 | UINT32 cells = buf.size(); | |
| 641 | 642 | if(cells <= 1) |
| 642 | 643 | return attotime::never; |
| 643 | 644 | |
| 644 | 645 | attotime base; |
| 645 | 646 | UINT32 position = find_position(base, from_when); |
| 646 | 647 | |
| 647 | const UINT32 *buf = image->get_buffer(cyl, ss, subcyl); | |
| 648 | int index = find_index(position, buf, cells); | |
| 648 | int index = find_index(position, buf); | |
| 649 | 649 | |
| 650 | 650 | if(index == -1) |
| 651 | 651 | return attotime::never; |
| r245687 | r245688 | |
| 671 | 671 | int start_pos = find_position(base, start); |
| 672 | 672 | int end_pos = find_position(base, end); |
| 673 | 673 | |
| 674 | d | |
| 674 | std::vector<int> trans_pos(transition_count); | |
| 675 | 675 | for(int i=0; i != transition_count; i++) |
| 676 | 676 | trans_pos[i] = find_position(base, transitions[i]); |
| 677 | 677 | |
| 678 | int cells = image->get_track_size(cyl, ss, subcyl); | |
| 679 | UINT32 *buf = image->get_buffer(cyl, ss, subcyl); | |
| 678 | std::vector<UINT32> &buf = image->get_buffer(cyl, ss, subcyl); | |
| 680 | 679 | |
| 681 | 680 | int index; |
| 682 | if(cells) | |
| 683 | index = find_index(start_pos, buf, cells); | |
| 681 | if(!buf.empty()) | |
| 682 | index = find_index(start_pos, buf); | |
| 684 | 683 | else { |
| 685 | 684 | index = 0; |
| 686 | image->set_track_size(cyl, ss, 1, subcyl); | |
| 687 | buf = image->get_buffer(cyl, ss, subcyl); | |
| 688 | buf[cells++] = floppy_image::MG_N; | |
| 685 | buf.push_back(floppy_image::MG_N); | |
| 689 | 686 | } |
| 690 | 687 | |
| 691 | 688 | if(index && (buf[index] & floppy_image::TIME_MASK) == start_pos) |
| r245687 | r245688 | |
| 697 | 694 | |
| 698 | 695 | UINT32 pos = start_pos; |
| 699 | 696 | int ti = 0; |
| 697 | int cells = buf.size(); | |
| 700 | 698 | while(pos != end_pos) { |
| 701 | if(image->get_track_size(cyl, ss, subcyl) < cells+10) { | |
| 702 | image->set_track_size(cyl, ss, cells+200, subcyl); | |
| 703 | buf = image->get_buffer(cyl, ss, subcyl); | |
| 704 | } | |
| 699 | if(buf.size() < cells+10) | |
| 700 | buf.resize(cells+200); | |
| 705 | 701 | UINT32 next_pos; |
| 706 | 702 | if(ti != transition_count) |
| 707 | 703 | next_pos = trans_pos[ti++]; |
| 708 | 704 | else |
| 709 | 705 | next_pos = end_pos; |
| 710 | 706 | if(next_pos > pos) |
| 711 | write_zone(buf, cells, index, pos, next_pos, cur_mg); | |
| 707 | write_zone(&buf[0], cells, index, pos, next_pos, cur_mg); | |
| 712 | 708 | else { |
| 713 | write_zone(buf, cells, index, pos, 200000000, cur_mg); | |
| 709 | write_zone(&buf[0], cells, index, pos, 200000000, cur_mg); | |
| 714 | 710 | index = 0; |
| 715 | write_zone(buf, cells, index, 0, next_pos, cur_mg); | |
| 711 | write_zone(&buf[0], cells, index, 0, next_pos, cur_mg); | |
| 716 | 712 | } |
| 717 | 713 | pos = next_pos; |
| 718 | 714 | cur_mg = cur_mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; |
| 719 | 715 | } |
| 720 | 716 | |
| 721 | | |
| 717 | buf.resize(cells); | |
| 722 | 718 | } |
| 723 | 719 | |
| 724 | 720 | void floppy_image_device::write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg) |
| r245687 | r245688 | |
|---|---|---|
| 93 | 93 | void setup_ready_cb(ready_cb cb); |
| 94 | 94 | void setup_wpt_cb(wpt_cb cb); |
| 95 | 95 | |
| 96 | UINT32* get_buffer() { return image->get_buffer(cyl, ss); } | |
| 97 | UINT32 get_len() { return image->get_track_size(cyl, ss); } | |
| 96 | std::vector<UINT32> &get_buffer() { return image->get_buffer(cyl, ss, subcyl); } | |
| 98 | 97 | int get_cyl() { return cyl; } |
| 99 | 98 | |
| 100 | 99 | void mon_w(int state); |
| r245687 | r245688 | |
| 181 | 180 | wpt_cb cur_wpt_cb; |
| 182 | 181 | |
| 183 | 182 | UINT32 find_position(attotime &base, const attotime &when); |
| 184 | int find_index(UINT32 position, const UINT32 | |
| 183 | int find_index(UINT32 position, const std::vector<UINT32> &buf); | |
| 185 | 184 | void write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg); |
| 186 | 185 | void commit_image(); |
| 187 | 186 | }; |
| r245687 | r245688 | |
|---|---|---|
| 1097 | 1097 | newcode.field[1] = field; |
| 1098 | 1098 | } |
| 1099 | 1099 | newcode.ch = code; |
| 1100 | m_keycode_map. | |
| 1100 | m_keycode_map.push_back(newcode); | |
| 1101 | 1101 | |
| 1102 | 1102 | if (LOG_NATURAL_KEYBOARD) |
| 1103 | 1103 | { |
| r245687 | r245688 | |
| 1190 | 1190 | |
| 1191 | 1191 | // add to the buffer, resizing if necessary |
| 1192 | 1192 | m_buffer[m_bufend++] = ch; |
| 1193 | if ((m_bufend + 1) % m_buffer.count() == m_bufbegin) | |
| 1194 | m_buffer.resize_keep(m_buffer.count() + KEY_BUFFER_SIZE); | |
| 1195 | m_bufend %= m_buffer.count(); | |
| 1193 | if ((m_bufend + 1) % m_buffer.size() == m_bufbegin) | |
| 1194 | m_buffer.resize(m_buffer.size() + KEY_BUFFER_SIZE); | |
| 1195 | m_bufend %= m_buffer.size(); | |
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | |
| r245687 | r245688 | |
| 1208 | 1208 | { |
| 1209 | 1209 | while (!empty() && m_queue_chars(&m_buffer[m_bufbegin], 1)) |
| 1210 | 1210 | { |
| 1211 | m_bufbegin = (m_bufbegin + 1) % m_buffer. | |
| 1211 | m_bufbegin = (m_bufbegin + 1) % m_buffer.size(); | |
| 1212 | 1212 | if (m_current_rate != attotime::zero) |
| 1213 | 1213 | break; |
| 1214 | 1214 | } |
| r245687 | r245688 | |
| 1218 | 1218 | else |
| 1219 | 1219 | { |
| 1220 | 1220 | if (m_status_keydown) |
| 1221 | m_bufbegin = (m_bufbegin + 1) % m_buffer. | |
| 1221 | m_bufbegin = (m_bufbegin + 1) % m_buffer.size(); | |
| 1222 | 1222 | m_status_keydown = !m_status_keydown; |
| 1223 | 1223 | } |
| 1224 | 1224 | |
| r245687 | r245688 | |
| 1274 | 1274 | |
| 1275 | 1275 | const natural_keyboard::keycode_map_entry *natural_keyboard::find_code(unicode_char ch) const |
| 1276 | 1276 | { |
| 1277 | for (int index = 0; index < m_keycode_map. | |
| 1277 | for (unsigned int index = 0; index < m_keycode_map.size(); index++) | |
| 1278 | 1278 | { |
| 1279 | 1279 | if (m_keycode_map[index].ch == ch) |
| 1280 | 1280 | return &m_keycode_map[index]; |
| r245687 | r245688 | |
| 1341 | 1341 | const size_t left_column_width = 24; |
| 1342 | 1342 | |
| 1343 | 1343 | // loop through all codes |
| 1344 | for (int index = 0; index < m_keycode_map. | |
| 1344 | for (unsigned int index = 0; index < m_keycode_map.size(); index++) | |
| 1345 | 1345 | { |
| 1346 | 1346 | // describe the character code |
| 1347 | 1347 | const natural_keyboard::keycode_map_entry &code = m_keycode_map[index]; |
| r245687 | r245688 | |
| 3031 | 3031 | if (count > 0) |
| 3032 | 3032 | { |
| 3033 | 3033 | // allocate tables |
| 3034 | dynamic_array<input_code> oldtable(count); | |
| 3035 | dynamic_array<input_code> newtable(count); | |
| 3034 | std::vector<input_code> oldtable(count); | |
| 3035 | std::vector<input_code> newtable(count); | |
| 3036 | 3036 | |
| 3037 | 3037 | // build up the remap table |
| 3038 | 3038 | count = 0; |
| r245687 | r245688 | |
|---|---|---|
| 816 | 816 | // getters and queries |
| 817 | 817 | running_machine &machine() const { return m_machine; } |
| 818 | 818 | bool empty() const { return (m_bufbegin == m_bufend); } |
| 819 | bool full() const { return ((m_bufend + 1) % m_buffer.count()) == m_bufbegin; } | |
| 820 | bool can_post() const { return (!m_queue_chars.isnull() || m_keycode_map.count() != 0); } | |
| 819 | bool full() const { return ((m_bufend + 1) % m_buffer.size()) == m_bufbegin; } | |
| 820 | bool can_post() const { return (!m_queue_chars.isnull() || !m_keycode_map.empty()); } | |
| 821 | 821 | bool is_posting() const { return (!empty() || (!m_charqueue_empty.isnull() && !m_charqueue_empty())); } |
| 822 | 822 | |
| 823 | 823 | // configuration |
| r245687 | r245688 | |
| 857 | 857 | running_machine & m_machine; // reference to our machine |
| 858 | 858 | UINT32 m_bufbegin; // index of starting character |
| 859 | 859 | UINT32 m_bufend; // index of ending character |
| 860 | d | |
| 860 | std::vector<unicode_char> m_buffer; // actual buffer | |
| 861 | 861 | bool m_status_keydown; // current keydown status |
| 862 | 862 | bool m_last_cr; // was the last char a CR? |
| 863 | 863 | emu_timer * m_timer; // timer for posting characters |
| r245687 | r245688 | |
| 865 | 865 | ioport_queue_chars_delegate m_queue_chars; // queue characters callback |
| 866 | 866 | ioport_accept_char_delegate m_accept_char; // accept character callback |
| 867 | 867 | ioport_charqueue_empty_delegate m_charqueue_empty; // character queue empty callback |
| 868 | d | |
| 868 | std::vector<keycode_map_entry> m_keycode_map; // keycode map | |
| 869 | 869 | }; |
| 870 | 870 | |
| 871 | 871 |
| r245687 | r245688 | |
|---|---|---|
| 113 | 113 | void fifo_write(UINT16 data); |
| 114 | 114 | UINT16 fifo_read(); |
| 115 | 115 | |
| 116 | d | |
| 116 | std::vector<UINT16> m_buffer; | |
| 117 | 117 | int m_ram_size; |
| 118 | 118 | |
| 119 | 119 | int m_read_ptr; |
| r245687 | r245688 | |
|---|---|---|
| 147 | 147 | { |
| 148 | 148 | dynamic_buffer buffer( AT28C16_TOTAL_BYTES ); |
| 149 | 149 | |
| 150 | file.read( buffer, AT28C16_TOTAL_BYTES ); | |
| 150 | file.read( &buffer[0], AT28C16_TOTAL_BYTES ); | |
| 151 | 151 | |
| 152 | 152 | for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ ) |
| 153 | 153 | { |
| r245687 | r245688 | |
| 169 | 169 | buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs ); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | file.write( buffer, AT28C16_TOTAL_BYTES ); | |
| 172 | file.write( &buffer[0], AT28C16_TOTAL_BYTES ); | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 |
| r245687 | r245688 | |
|---|---|---|
| 140 | 140 | |
| 141 | 141 | void at45db041_device::nvram_default() |
| 142 | 142 | { |
| 143 | m_data | |
| 143 | memset(&m_data[0], 0xff, m_data.size()); | |
| 144 | 144 | |
| 145 | 145 | if (region() != NULL) |
| 146 | 146 | { |
| r245687 | r245688 | |
| 148 | 148 | if (bytes > m_size) |
| 149 | 149 | bytes = m_size; |
| 150 | 150 | |
| 151 | memcpy(m_data, region()->base(), bytes); | |
| 151 | memcpy(&m_data[0], region()->base(), bytes); | |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| r245687 | r245688 | |
| 159 | 159 | |
| 160 | 160 | void at45db041_device::nvram_read(emu_file &file) |
| 161 | 161 | { |
| 162 | file.read(m_data, m_size); | |
| 162 | file.read(&m_data[0], m_size); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | //------------------------------------------------- |
| r245687 | r245688 | |
| 169 | 169 | |
| 170 | 170 | void at45db041_device::nvram_write(emu_file &file) |
| 171 | 171 | { |
| 172 | file.write(m_data, m_size); | |
| 172 | file.write(&m_data[0], m_size); | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | UINT8 at45db041_device::read_byte() |
| r245687 | r245688 | |
| 255 | 255 | UINT8 comp; |
| 256 | 256 | page = flash_get_page_addr(); |
| 257 | 257 | _logerror( 1, ("at45dbxx opcode %02X - main memory page to buffer 1 compare [%04X]\n", opcode, page)); |
| 258 | comp = memcmp( m_data | |
| 258 | comp = memcmp( &m_data[page * page_size()], &m_buffer1[0], page_size()) == 0 ? 0 : 1; | |
| 259 | 259 | if (comp) m_status |= 0x40; else m_status &= ~0x40; |
| 260 | 260 | _logerror( 1, ("at45dbxx page compare %s\n", comp ? "failure" : "success")); |
| 261 | 261 | m_mode = FLASH_MODE_SI; |
| r245687 | r245688 | |
| 273 | 273 | page = flash_get_page_addr(); |
| 274 | 274 | byte = flash_get_byte_addr(); |
| 275 | 275 | _logerror( 1, ("at45dbxx opcode %02X - main memory page read [%04X/%04X]\n", opcode, page, byte)); |
| 276 | flash_set_io(m_data | |
| 276 | flash_set_io(&m_data[page * page_size()], page_size(), byte); | |
| 277 | 277 | m_mode = FLASH_MODE_SO; |
| 278 | 278 | m_cmd.size = 8; |
| 279 | 279 | } |
| r245687 | r245688 | |
| 289 | 289 | page = flash_get_page_addr(); |
| 290 | 290 | byte = flash_get_byte_addr(); |
| 291 | 291 | _logerror( 1, ("at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte)); |
| 292 | flash_set_io(m_buffer1, page_size(), byte); | |
| 293 | m_buffer1.clear(0xFF); | |
| 292 | flash_set_io(&m_buffer1[0], page_size(), byte); | |
| 293 | memset(&m_buffer1[0], 0xff, m_buffer1.size()); | |
| 294 | 294 | m_mode = FLASH_MODE_SI; |
| 295 | 295 | m_cmd.size = 8; |
| 296 | 296 | } |
| r245687 | r245688 | |
| 342 | 342 | page = flash_get_page_addr(); |
| 343 | 343 | byte = flash_get_byte_addr(); |
| 344 | 344 | _logerror( 1, ("at45dbxx - program data stored in buffer 1 into selected page in main memory [%04X/%04X]\n", page, byte)); |
| 345 | memcpy( m_data | |
| 345 | memcpy( &m_data[page * page_size()], &m_buffer1[0], page_size()); | |
| 346 | 346 | } |
| 347 | 347 | // reset |
| 348 | 348 | at45db041_device::device_reset(); |
| r245687 | r245688 | |
|---|---|---|
| 47 | 47 | DECLARE_WRITE_LINE_MEMBER(si_w); |
| 48 | 48 | DECLARE_READ_LINE_MEMBER(so_r); |
| 49 | 49 | |
| 50 | UINT8 *get_ptr() { return m_data; } | |
| 50 | UINT8 *get_ptr() { return &m_data[0]; } | |
| 51 | 51 | |
| 52 | 52 | template<class _Object> static devcb_base &set_so_cb(device_t &device, _Object object) { return downcast<at45db041_device &>(device).write_so.set_callback(object); } |
| 53 | 53 | devcb_write_line write_so; |
| r245687 | r245688 | |
|---|---|---|
| 32 | 32 | |
| 33 | 33 | m_error = 0; // HACK: This might not be the right place, but firebeat needs this cleared at some point |
| 34 | 34 | |
| 35 | SetCommand(m_buffer, m_buffer_size); | |
| 35 | SetCommand(&m_buffer[0], m_buffer_size); | |
| 36 | 36 | ExecCommand(); |
| 37 | 37 | GetLength(&m_data_size); |
| 38 | 38 | |
| r245687 | r245688 | |
| 79 | 79 | switch (m_command) |
| 80 | 80 | { |
| 81 | 81 | case IDE_COMMAND_PACKET: |
| 82 | WriteData( m_buffer, m_buffer_size ); | |
| 82 | WriteData( &m_buffer[0], m_buffer_size ); | |
| 83 | 83 | m_data_size -= m_buffer_size; |
| 84 | 84 | |
| 85 | 85 | wait_buffer(); |
| r245687 | r245688 | |
| 107 | 107 | |
| 108 | 108 | if (m_buffer_size > 0) |
| 109 | 109 | { |
| 110 | ReadData( m_buffer, m_buffer_size ); | |
| 110 | ReadData( &m_buffer[0], m_buffer_size ); | |
| 111 | 111 | m_data_size -= m_buffer_size; |
| 112 | 112 | |
| 113 | 113 | m_status |= IDE_STATUS_DRQ; |
| r245687 | r245688 | |
|---|---|---|
| 78 | 78 | buf.resize(m_regs.tbcr); |
| 79 | 79 | for(i = 0; i < m_regs.tbcr; i++) buf[i] = m_mem_read_cb(high16 + (m_regs.tpsr << 8) + i); |
| 80 | 80 | |
| 81 | if(send(buf, m_regs.tbcr)) { | |
| 81 | if(send(&buf[0], m_regs.tbcr)) { | |
| 82 | 82 | m_regs.tsr = 1; |
| 83 | 83 | m_regs.isr |= 2; |
| 84 | 84 | } else { |
| r245687 | r245688 | |
|---|---|---|
| 326 | 326 | UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8; |
| 327 | 327 | |
| 328 | 328 | dynamic_buffer buffer(eeprom_bytes); |
| 329 | file.read(buffer, eeprom_bytes); | |
| 329 | file.read(&buffer[0], eeprom_bytes); | |
| 330 | 330 | for (offs_t offs = 0; offs < eeprom_bytes; offs++) |
| 331 | 331 | m_addrspace[0]->write_byte(offs, buffer[offs]); |
| 332 | 332 | } |
| r245687 | r245688 | |
| 345 | 345 | dynamic_buffer buffer(eeprom_bytes); |
| 346 | 346 | for (offs_t offs = 0; offs < eeprom_bytes; offs++) |
| 347 | 347 | buffer[offs] = m_addrspace[0]->read_byte(offs); |
| 348 | file.write(buffer, eeprom_bytes); | |
| 348 | file.write(&buffer[0], eeprom_bytes); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 |
| r245687 | r245688 | |
|---|---|---|
| 208 | 208 | int i2cmem_bytes = m_data_size; |
| 209 | 209 | dynamic_buffer buffer ( i2cmem_bytes ); |
| 210 | 210 | |
| 211 | file.read( buffer, i2cmem_bytes ); | |
| 211 | file.read( &buffer[0], i2cmem_bytes ); | |
| 212 | 212 | |
| 213 | 213 | for( offs_t offs = 0; offs < i2cmem_bytes; offs++ ) |
| 214 | 214 | { |
| r245687 | r245688 | |
| 231 | 231 | buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs ); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | file.write( buffer, i2cmem_bytes ); | |
| 234 | file.write( &buffer[0], i2cmem_bytes ); | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 |
| r245687 | r245688 | |
|---|---|---|
| 86 | 86 | const char *cpu_tag; |
| 87 | 87 | int ram_size; |
| 88 | 88 | cpu_device *cpu; |
| 89 | d | |
| 89 | std::vector<UINT32> ram; | |
| 90 | 90 | |
| 91 | 91 | UINT8 agpm, fpllcont, pam[8], smram, esmramc; |
| 92 | 92 | UINT8 apsize, amtt, lptt; |
| r245687 | r245688 | |
|---|---|---|
| 408 | 408 | set_dasp(CLEAR_LINE); |
| 409 | 409 | |
| 410 | 410 | /* now do the read */ |
| 411 | count = read_sector(lba, m_buffer); | |
| 411 | count = read_sector(lba, &m_buffer[0]); | |
| 412 | 412 | |
| 413 | 413 | /* if we succeeded, advance to the next sector and set the nice bits */ |
| 414 | 414 | if (count == 1) |
| r245687 | r245688 | |
| 477 | 477 | { |
| 478 | 478 | if (m_command == IDE_COMMAND_SECURITY_UNLOCK) |
| 479 | 479 | { |
| 480 | if (m_user_password_enable && memcmp(m_buffer, m_user_password, 2 + 32) == 0) | |
| 480 | if (m_user_password_enable && memcmp(&m_buffer[0], m_user_password, 2 + 32) == 0) | |
| 481 | 481 | { |
| 482 | 482 | LOGPRINT(("IDE Unlocked user password\n")); |
| 483 | 483 | m_user_password_enable = 0; |
| 484 | 484 | } |
| 485 | if (m_master_password_enable && memcmp(m_buffer, m_master_password, 2 + 32) == 0) | |
| 485 | if (m_master_password_enable && memcmp(&m_buffer[0], m_master_password, 2 + 32) == 0) | |
| 486 | 486 | { |
| 487 | 487 | LOGPRINT(("IDE Unlocked master password\n")); |
| 488 | 488 | m_master_password_enable = 0; |
| r245687 | r245688 | |
| 538 | 538 | set_dasp(CLEAR_LINE); |
| 539 | 539 | |
| 540 | 540 | /* now do the write */ |
| 541 | count = write_sector(lba, m_buffer); | |
| 541 | count = write_sector(lba, &m_buffer[0]); | |
| 542 | 542 | |
| 543 | 543 | /* if we succeeded, advance to the next sector and set the nice bits */ |
| 544 | 544 | if (count == 1) |
| r245687 | r245688 | |
| 790 | 790 | |
| 791 | 791 | // build the features page |
| 792 | 792 | UINT32 metalength; |
| 793 | if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_buffer, 512, metalength) == CHDERR_NONE) | |
| 793 | if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, &m_buffer[0], 512, metalength) == CHDERR_NONE) | |
| 794 | 794 | { |
| 795 | 795 | for( int w = 0; w < 256; w++ ) |
| 796 | 796 | { |
| r245687 | r245688 | |
|---|---|---|
| 548 | 548 | void intelfsh_device::nvram_read(emu_file &file) |
| 549 | 549 | { |
| 550 | 550 | dynamic_buffer buffer(m_size); |
| 551 | file.read(buffer, m_size); | |
| 551 | file.read(&buffer[0], m_size); | |
| 552 | 552 | for (int byte = 0; byte < m_size; byte++) |
| 553 | 553 | m_addrspace[0]->write_byte(byte, buffer[byte]); |
| 554 | 554 | } |
| r245687 | r245688 | |
| 564 | 564 | dynamic_buffer buffer(m_size); |
| 565 | 565 | for (int byte = 0; byte < m_size; byte++) |
| 566 | 566 | buffer[byte] = m_addrspace[0]->read_byte(byte); |
| 567 | file.write(buffer, m_size); | |
| 567 | file.write(&buffer[0], m_size); | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 |
| r245687 | r245688 | |
|---|---|---|
| 436 | 436 | // otherwise, stream from our buffer |
| 437 | 437 | else |
| 438 | 438 | { |
| 439 | INT16 *buffer0 = m_audiobuffer[0]; | |
| 440 | INT16 *buffer1 = m_audiobuffer[1]; | |
| 439 | INT16 *buffer0 = &m_audiobuffer[0][0]; | |
| 440 | INT16 *buffer1 = &m_audiobuffer[1][0]; | |
| 441 | 441 | int sampout = m_audiobufout; |
| 442 | 442 | |
| 443 | 443 | // copy samples, clearing behind us as we go |
| r245687 | r245688 | |
| 777 | 777 | |
| 778 | 778 | // allocate memory for the precomputed per-frame metadata |
| 779 | 779 | err = m_disc->read_metadata(AV_LD_METADATA_TAG, 0, m_vbidata); |
| 780 | if (err != CHDERR_NONE || m_vbidata. | |
| 780 | if (err != CHDERR_NONE || m_vbidata.size() != totalhunks * VBI_PACKED_BYTES) | |
| 781 | 781 | throw emu_fatalerror("Precomputed VBI metadata missing or incorrect size"); |
| 782 | 782 | } |
| 783 | 783 | m_maxtrack = MAX(m_maxtrack, VIRTUAL_LEAD_IN_TRACKS + VIRTUAL_LEAD_OUT_TRACKS + m_chdtracks); |
| r245687 | r245688 | |
| 993 | 993 | |
| 994 | 994 | // cheat and look up the metadata we are about to retrieve |
| 995 | 995 | vbi_metadata vbidata = { 0 }; |
| 996 | if (m_vbidata. | |
| 996 | if (!m_vbidata.empty()) | |
| 997 | 997 | vbi_metadata_unpack(&vbidata, NULL, &m_vbidata[readhunk * VBI_PACKED_BYTES]); |
| 998 | 998 | |
| 999 | 999 | // if we're in the lead-in area, force the VBI data to be standard lead-in |
| r245687 | r245688 | |
| 1044 | 1044 | m_audiocursamples = 0; |
| 1045 | 1045 | |
| 1046 | 1046 | // set the VBI data for the new field from our precomputed data |
| 1047 | if (m_vbidata. | |
| 1047 | if (!m_vbidata.empty()) | |
| 1048 | 1048 | { |
| 1049 | 1049 | UINT32 vbiframe; |
| 1050 | 1050 | vbi_metadata_unpack(&m_metadata[m_fieldnum], &vbiframe, &m_vbidata[readhunk * VBI_PACKED_BYTES]); |
| r245687 | r245688 | |
|---|---|---|
| 328 | 328 | |
| 329 | 329 | // audio data |
| 330 | 330 | sound_stream * m_stream; |
| 331 | d | |
| 331 | std::vector<INT16> m_audiobuffer[2]; // buffer for audio samples | |
| 332 | 332 | UINT32 m_audiobufsize; // size of buffer |
| 333 | 333 | UINT32 m_audiobufin; // input index |
| 334 | 334 | UINT32 m_audiobufout; // output index |
| r245687 | r245688 | |
|---|---|---|
| 190 | 190 | if (bytes > data_size()) |
| 191 | 191 | bytes = data_size(); |
| 192 | 192 | |
| 193 | memcpy(m_data, m_region->base(), bytes); | |
| 193 | memcpy(&m_data[0], m_region->base(), bytes); | |
| 194 | 194 | } |
| 195 | 195 | else |
| 196 | 196 | { |
| r245687 | r245688 | |
| 210 | 210 | |
| 211 | 211 | void mc146818_device::nvram_read(emu_file &file) |
| 212 | 212 | { |
| 213 | file.read(m_data, data_size()); | |
| 213 | file.read(&m_data[0], data_size()); | |
| 214 | 214 | |
| 215 | 215 | set_base_datetime(); |
| 216 | 216 | update_timer(); |
| r245687 | r245688 | |
| 225 | 225 | |
| 226 | 226 | void mc146818_device::nvram_write(emu_file &file) |
| 227 | 227 | { |
| 228 | file.write(m_data, data_size()); | |
| 228 | file.write(&m_data[0], data_size()); | |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 |
| r245687 | r245688 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | int track_length = blocks*bytes_per_sector; |
| 61 | 61 | dynamic_buffer data(track_length); |
| 62 | memset(data, 0xc6, track_length); | |
| 62 | memset(&data[0], 0xc6, track_length); | |
| 63 | 63 | |
| 64 | if(!hard_disk_write(harddisk, lba, data)) { | |
| 64 | if(!hard_disk_write(harddisk, lba, &data[0])) { | |
| 65 | 65 | logerror("%s: HD WRITE ERROR !\n", tag()); |
| 66 | 66 | scsi_status_complete(SS_FORMAT_ERROR); |
| 67 | 67 | } else { |
| r245687 | r245688 | |
|---|---|---|
| 401 | 401 | void pci_bridge_device::set_remap_cb(mapper_cb _remap_cb) |
| 402 | 402 | { |
| 403 | 403 | remap_cb = _remap_cb; |
| 404 | for(int i=0; i != all_devices. | |
| 404 | for(unsigned int i=0; i != all_devices.size(); i++) | |
| 405 | 405 | if(all_devices[i] != this) |
| 406 | 406 | all_devices[i]->set_remap_cb(_remap_cb); |
| 407 | 407 | } |
| r245687 | r245688 | |
| 430 | 430 | if((i & 7) && sub_devices[i & ~7]) |
| 431 | 431 | sub_devices[i & ~7]->set_multifunction_device(true); |
| 432 | 432 | |
| 433 | all_devices. | |
| 433 | all_devices.push_back(sub_devices[i]); | |
| 434 | 434 | if(sub_devices[i] != this) { |
| 435 | 435 | sub_devices[i]->remap_config_cb = cf_cb; |
| 436 | 436 | sub_devices[i]->set_remap_cb(remap_cb); |
| 437 | 437 | pci_bridge_device *bridge = dynamic_cast<pci_bridge_device *>(sub_devices[i]); |
| 438 | 438 | if(bridge) |
| 439 | all_bridges. | |
| 439 | all_bridges.push_back(bridge); | |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | } |
| r245687 | r245688 | |
| 456 | 456 | { |
| 457 | 457 | pci_device::reset_all_mappings(); |
| 458 | 458 | |
| 459 | for(int i=0; i != all_devices. | |
| 459 | for(unsigned int i=0; i != all_devices.size(); i++) | |
| 460 | 460 | if(all_devices[i] != this) |
| 461 | 461 | all_devices[i]->reset_all_mappings(); |
| 462 | 462 | |
| r245687 | r245688 | |
| 475 | 475 | void pci_bridge_device::map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space, |
| 476 | 476 | UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space) |
| 477 | 477 | { |
| 478 | for(int i = all_devices. | |
| 478 | for(int i = int(all_devices.size())-1; i>=0; i--) | |
| 479 | 479 | if(all_devices[i] != this) |
| 480 | 480 | all_devices[i]->map_device(memory_window_start, memory_window_end, memory_offset, memory_space, |
| 481 | 481 | io_window_start, io_window_end, io_offset, io_space); |
| r245687 | r245688 | |
| 507 | 507 | UINT32 pci_bridge_device::propagate_config_read(UINT8 bus, UINT8 device, UINT16 reg, UINT32 mem_mask) |
| 508 | 508 | { |
| 509 | 509 | UINT32 data = 0xffffffff; |
| 510 | for(int i=0; i != all_bridges. | |
| 510 | for(unsigned int i=0; i != all_bridges.size(); i++) | |
| 511 | 511 | data &= all_bridges[i]->config_read(bus, device, reg, mem_mask); |
| 512 | 512 | return data; |
| 513 | 513 | } |
| r245687 | r245688 | |
| 533 | 533 | |
| 534 | 534 | void pci_bridge_device::propagate_config_write(UINT8 bus, UINT8 device, UINT16 reg, UINT32 data, UINT32 mem_mask) |
| 535 | 535 | { |
| 536 | for(int i=0; i != all_bridges. | |
| 536 | for(unsigned int i=0; i != all_bridges.size(); i++) | |
| 537 | 537 | all_bridges[i]->config_write(bus, device, reg, data, mem_mask); |
| 538 | 538 | } |
| 539 | 539 |
| r245687 | r245688 | |
|---|---|---|
| 190 | 190 | |
| 191 | 191 | protected: |
| 192 | 192 | pci_device *sub_devices[32*8]; |
| 193 | dynamic_array<pci_device *> all_devices; | |
| 194 | dynamic_array<pci_bridge_device *> all_bridges; | |
| 193 | std::vector<pci_device *> all_devices; | |
| 194 | std::vector<pci_bridge_device *> all_bridges; | |
| 195 | 195 | |
| 196 | 196 | UINT32 prefetch_baseu, prefetch_limitu; |
| 197 | 197 | UINT16 bridge_control, memory_base, memory_limit, prefetch_base, prefetch_limit, iobaseu, iolimitu; |
| r245687 | r245688 | |
|---|---|---|
| 121 | 121 | UINT64 m_xor; |
| 122 | 122 | |
| 123 | 123 | int m_cache_size; |
| 124 | d | |
| 124 | std::vector<UINT32> m_cache; | |
| 125 | 125 | UINT64 m_cache2[CACHE2_SIZE]; |
| 126 | 126 | UINT8 m_cache2_ptr; |
| 127 | 127 |
| r245687 | r245688 | |
|---|---|---|
| 61 | 61 | m_size = default_size(); |
| 62 | 62 | |
| 63 | 63 | /* allocate space for the ram */ |
| 64 | m_pointer.resize_and_clear(m_size, m_default_value); | |
| 64 | m_pointer.resize(m_size); | |
| 65 | memset(&m_pointer[0], m_default_value, m_size); | |
| 65 | 66 | |
| 66 | 67 | /* register for state saving */ |
| 67 | 68 | save_item(NAME(m_size)); |
| r245687 | r245688 | |
|---|---|---|
| 57 | 57 | // accessors |
| 58 | 58 | UINT32 size(void) const { return m_size; } |
| 59 | 59 | UINT32 mask(void) const { return m_size - 1; } |
| 60 | UINT8 *pointer(void) { return m_pointer; } | |
| 60 | UINT8 *pointer(void) { return &m_pointer[0]; } | |
| 61 | 61 | static UINT32 parse_string(const char *s); |
| 62 | 62 | UINT32 default_size(void) const; |
| 63 | 63 | const char *extra_options(void) const { return m_extra_options; } |
| r245687 | r245688 | |
|---|---|---|
| 112 | 112 | int width = m_screen->width(); |
| 113 | 113 | int height = m_screen->height(); |
| 114 | 114 | |
| 115 | m_work_ram.resize_and_clear(m_work_ram_size); | |
| 115 | m_work_ram.resize(m_work_ram_size); | |
| 116 | memset(&m_work_ram[0], 0, m_work_ram_size); | |
| 116 | 117 | m_bitmap.resize(width, height); |
| 117 | 118 | m_collision_bitmap.resize(width, height); |
| 118 | 119 |
| r245687 | r245688 | |
|---|---|---|
| 37 | 37 | m_length = machine().root_device().memregion( tag() )->bytes(); |
| 38 | 38 | m_region = machine().root_device().memregion( tag() )->base(); |
| 39 | 39 | |
| 40 | m_flashwritemap.resize_and_clear(m_length / FLASH_PAGE_SIZE); | |
| 41 | ||
| 40 | m_flashwritemap.resize(m_length / FLASH_PAGE_SIZE); | |
| 41 | memset(&m_flashwritemap[0], 0, m_length / FLASH_PAGE_SIZE); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | void serflash_device::device_reset() |
| r245687 | r245688 | |
|---|---|---|
| 773 | 773 | |
| 774 | 774 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 775 | 775 | { |
| 776 | m_drive->floppy_drive_read_sector_data(id.H, sector_data_id, buf, sector_len); | |
| 776 | m_drive->floppy_drive_read_sector_data(id.H, sector_data_id, &buf[0], sector_len); | |
| 777 | 777 | } |
| 778 | 778 | else |
| 779 | 779 | { |
| 780 | 780 | // TODO: Should we get the sector length from the harddisk? |
| 781 | m_harddisk->read_sector(id.C, id.H, id.R, buf); | |
| 781 | m_harddisk->read_sector(id.C, id.H, id.R, &buf[0]); | |
| 782 | 782 | } |
| 783 | 783 | sync_status_in(); |
| 784 | 784 | |
| r245687 | r245688 | |
| 867 | 867 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 868 | 868 | { |
| 869 | 869 | if (VERBOSE>4) LOG("smc92x4 info: write sector CHS=(%d,%d,%d)\n", id.C, id.H, id.R); |
| 870 | m_drive->floppy_drive_write_sector_data(id.H, sector_data_id, buf, sector_len, false); | |
| 870 | m_drive->floppy_drive_write_sector_data(id.H, sector_data_id, &buf[0], sector_len, false); | |
| 871 | 871 | } |
| 872 | 872 | else |
| 873 | 873 | { |
| 874 | m_harddisk->write_sector(id.C, id.H, id.R, buf); | |
| 874 | m_harddisk->write_sector(id.C, id.H, id.R, &buf[0]); | |
| 875 | 875 | } |
| 876 | 876 | sync_status_in(); |
| 877 | 877 | |
| r245687 | r245688 | |
| 1476 | 1476 | memset(&buffer[index], gap_byte, gap4); |
| 1477 | 1477 | index += gap4; |
| 1478 | 1478 | |
| 1479 | m_drive->floppy_drive_write_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, buffer, &data_count); | |
| 1479 | m_drive->floppy_drive_write_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, &buffer[0], &data_count); | |
| 1480 | 1480 | sync_status_in(); |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| r245687 | r245688 | |
| 1573 | 1573 | for (i=0; i < gap4; i++) buffer[index++] = gap_byte; |
| 1574 | 1574 | |
| 1575 | 1575 | // Now write the whole track |
| 1576 | m_harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count); | |
| 1576 | m_harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, &buffer[0], data_count); | |
| 1577 | 1577 | |
| 1578 | 1578 | sync_status_in(); |
| 1579 | 1579 | } |
| r245687 | r245688 | |
| 1622 | 1622 | |
| 1623 | 1623 | buffer.resize(data_count); |
| 1624 | 1624 | |
| 1625 | m_drive->floppy_drive_read_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, (char *) | |
| 1625 | m_drive->floppy_drive_read_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, (char *)&buffer[0], &data_count); | |
| 1626 | 1626 | sync_status_in(); |
| 1627 | 1627 | |
| 1628 | 1628 | // Transfer the buffer to the external memory. We assume the memory |
| r245687 | r245688 | |
| 1654 | 1654 | buffer.resize(data_count); |
| 1655 | 1655 | |
| 1656 | 1656 | /* buffer and data_count are allocated and set by the function. */ |
| 1657 | m_harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer); | |
| 1657 | m_harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, &buffer[0]); | |
| 1658 | 1658 | sync_status_in(); |
| 1659 | 1659 | |
| 1660 | 1660 | if (!(m_register_r[DRIVE_STATUS] & DS_READY)) |
| r245687 | r245688 | |
|---|---|---|
| 1429 | 1429 | cd_stat |= CD_STAT_PERI; |
| 1430 | 1430 | cur_track = 0xff; |
| 1431 | 1431 | |
| 1432 | curdir. | |
| 1432 | curdir.clear(); | |
| 1433 | 1433 | |
| 1434 | 1434 | xfertype = XFERTYPE_INVALID; |
| 1435 | 1435 | xfertype32 = XFERTYPE32_INVALID; |
| r245687 | r245688 | |
| 2140 | 2140 | dynamic_buffer sect(MAX_DIR_SIZE); |
| 2141 | 2141 | direntryT *curentry; |
| 2142 | 2142 | |
| 2143 | memset(sect, 0, MAX_DIR_SIZE); | |
| 2143 | memset(§[0], 0, MAX_DIR_SIZE); | |
| 2144 | 2144 | if(sectlenin != 2048) |
| 2145 | 2145 | popmessage("Sector Length %d, contact MAMEdev (1)",sectlenin); |
| 2146 | 2146 | |
| r245687 | r245688 | |
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | curdir.resize(numentries); |
| 2168 | curentry = curdir; | |
| 2168 | curentry = &curdir[0]; | |
| 2169 | 2169 | numfiles = numentries; |
| 2170 | 2170 | |
| 2171 | 2171 | nextent = 0; |
| r245687 | r245688 | |
| 2233 | 2233 | |
| 2234 | 2234 | void saturn_state::stvcd_exit( void ) |
| 2235 | 2235 | { |
| 2236 | curdir. | |
| 2236 | curdir.clear(); | |
| 2237 | 2237 | |
| 2238 | 2238 | if (cdrom) |
| 2239 | 2239 | { |
| r245687 | r245688 | |
|---|---|---|
| 257 | 257 | |
| 258 | 258 | void timekeeper_device::counters_to_ram() |
| 259 | 259 | { |
| 260 | counter_to_ram( m_data, m_offset_control, m_control ); | |
| 261 | counter_to_ram( m_data, m_offset_seconds, m_seconds ); | |
| 262 | counter_to_ram( m_data, m_offset_minutes, m_minutes ); | |
| 263 | counter_to_ram( m_data, m_offset_hours, m_hours ); | |
| 264 | counter_to_ram( m_data, m_offset_day, m_day ); | |
| 265 | counter_to_ram( m_data, m_offset_date, m_date ); | |
| 266 | counter_to_ram( m_data, m_offset_month, m_month ); | |
| 267 | counter_to_ram( m_data, m_offset_year, m_year ); | |
| 268 | counter_to_ram( m_data, m_offset_century, m_century ); | |
| 260 | counter_to_ram( &m_data[0], m_offset_control, m_control ); | |
| 261 | counter_to_ram( &m_data[0], m_offset_seconds, m_seconds ); | |
| 262 | counter_to_ram( &m_data[0], m_offset_minutes, m_minutes ); | |
| 263 | counter_to_ram( &m_data[0], m_offset_hours, m_hours ); | |
| 264 | counter_to_ram( &m_data[0], m_offset_day, m_day ); | |
| 265 | counter_to_ram( &m_data[0], m_offset_date, m_date ); | |
| 266 | counter_to_ram( &m_data[0], m_offset_month, m_month ); | |
| 267 | counter_to_ram( &m_data[0], m_offset_year, m_year ); | |
| 268 | counter_to_ram( &m_data[0], m_offset_century, m_century ); | |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | void timekeeper_device::counters_from_ram() |
| 272 | 272 | { |
| 273 | m_control = counter_from_ram( m_data, m_offset_control ); | |
| 274 | m_seconds = counter_from_ram( m_data, m_offset_seconds ); | |
| 275 | m_minutes = counter_from_ram( m_data, m_offset_minutes ); | |
| 276 | m_hours = counter_from_ram( m_data, m_offset_hours ); | |
| 277 | m_day = counter_from_ram( m_data, m_offset_day ); | |
| 278 | m_date = counter_from_ram( m_data, m_offset_date ); | |
| 279 | m_month = counter_from_ram( m_data, m_offset_month ); | |
| 280 | m_year = counter_from_ram( m_data, m_offset_year ); | |
| 281 | m_century = counter_from_ram( m_data, m_offset_century ); | |
| 273 | m_control = counter_from_ram( &m_data[0], m_offset_control ); | |
| 274 | m_seconds = counter_from_ram( &m_data[0], m_offset_seconds ); | |
| 275 | m_minutes = counter_from_ram( &m_data[0], m_offset_minutes ); | |
| 276 | m_hours = counter_from_ram( &m_data[0], m_offset_hours ); | |
| 277 | m_day = counter_from_ram( &m_data[0], m_offset_day ); | |
| 278 | m_date = counter_from_ram( &m_data[0], m_offset_date ); | |
| 279 | m_month = counter_from_ram( &m_data[0], m_offset_month ); | |
| 280 | m_year = counter_from_ram( &m_data[0], m_offset_year ); | |
| 281 | m_century = counter_from_ram( &m_data[0], m_offset_century ); | |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | void timekeeper_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| r245687 | r245688 | |
| 398 | 398 | { |
| 399 | 399 | if( m_default_data != NULL ) |
| 400 | 400 | { |
| 401 | memcpy( m_data, m_default_data, m_size ); | |
| 401 | memcpy( &m_data[0], m_default_data, m_size ); | |
| 402 | 402 | } |
| 403 | 403 | else |
| 404 | 404 | { |
| 405 | m_data | |
| 405 | memset( &m_data[0], 0xff, m_data.size()); | |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | if ( m_offset_flags >= 0 ) |
| r245687 | r245688 | |
| 418 | 418 | |
| 419 | 419 | void timekeeper_device::nvram_read(emu_file &file) |
| 420 | 420 | { |
| 421 | file.read( m_data, m_size ); | |
| 421 | file.read( &m_data[0], m_size ); | |
| 422 | 422 | |
| 423 | 423 | counters_to_ram(); |
| 424 | 424 | } |
| r245687 | r245688 | |
| 431 | 431 | |
| 432 | 432 | void timekeeper_device::nvram_write(emu_file &file) |
| 433 | 433 | { |
| 434 | file.write( m_data, m_size ); | |
| 434 | file.write( &m_data[0], m_size ); | |
| 435 | 435 | } |
| r245687 | r245688 | |
|---|---|---|
| 109 | 109 | |
| 110 | 110 | UINT32 m_ram_size; |
| 111 | 111 | UINT32 m_ram_base; |
| 112 | d | |
| 112 | std::vector<UINT32> m_ram; | |
| 113 | 113 | |
| 114 | 114 | UINT32 m_simm_size; |
| 115 | 115 | UINT32 m_simm_base; |
| 116 | d | |
| 116 | std::vector<UINT32> m_simm; | |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | UINT32 m_cpu_regs[0x7c]; |
| r245687 | r245688 | |
|---|---|---|
| 45 | 45 | // construction/destruction |
| 46 | 46 | memory_array(); |
| 47 | 47 | memory_array(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe) { set(base, bytes, membits, endianness, bpe); } |
| 48 | template <typename _Type> memory_array(d | |
| 48 | template <typename _Type> memory_array(std::vector<_Type> &array, endianness_t endianness, int bpe) { set(array, endianness, bpe); } | |
| 49 | 49 | memory_array(const address_space &space, void *base, UINT32 bytes, int bpe) { set(space, base, bytes, bpe); } |
| 50 | 50 | memory_array(const memory_share &share, int bpe) { set(share, bpe); } |
| 51 | 51 | memory_array(const memory_array &array) { set(array); } |
| 52 | 52 | |
| 53 | 53 | // configuration |
| 54 | 54 | void set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe); |
| 55 | template <typename _Type> void set(d | |
| 55 | template <typename _Type> void set(std::vector<_Type> &array, endianness_t endianness, int bpe) { set(&array[0], array.size(), 8*sizeof(_Type), endianness, bpe); } | |
| 56 | 56 | void set(const address_space &space, void *base, UINT32 bytes, int bpe); |
| 57 | 57 | void set(const memory_share &share, int bpe); |
| 58 | 58 | void set(const memory_array &array); |
| r245687 | r245688 | |
|---|---|---|
| 586 | 586 | UINT16 *subtable_ptr(UINT16 entry) { return &m_table[level2_index(entry, 0)]; } |
| 587 | 587 | |
| 588 | 588 | // internal state |
| 589 | d | |
| 589 | std::vector<UINT16> m_table; // pointer to base of table | |
| 590 | 590 | UINT16 * m_live_lookup; // current lookup |
| 591 | 591 | address_space & m_space; // pointer back to the space |
| 592 | 592 | bool m_large; // large memory model? |
| r245687 | r245688 | |
| 604 | 604 | UINT32 m_checksum; // checksum over all the bytes |
| 605 | 605 | UINT32 m_usecount; // number of times this has been used |
| 606 | 606 | }; |
| 607 | d | |
| 607 | std::vector<subtable_data> m_subtable; // info about each subtable | |
| 608 | 608 | UINT16 m_subtable_alloc; // number of subtables allocated |
| 609 | 609 | |
| 610 | 610 | // static global read-only watchpoint table |
| r245687 | r245688 | |
| 698 | 698 | m_space.device().debug()->memory_read_hook(m_space, offset * sizeof(_UintType), mask); |
| 699 | 699 | |
| 700 | 700 | UINT16 *oldtable = m_live_lookup; |
| 701 | m_live_lookup = m_table; | |
| 701 | m_live_lookup = &m_table[0]; | |
| 702 | 702 | _UintType result; |
| 703 | 703 | if (sizeof(_UintType) == 1) result = m_space.read_byte(offset); |
| 704 | 704 | if (sizeof(_UintType) == 2) result = m_space.read_word(offset << 1, mask); |
| r245687 | r245688 | |
| 768 | 768 | m_space.device().debug()->memory_write_hook(m_space, offset * sizeof(_UintType), data, mask); |
| 769 | 769 | |
| 770 | 770 | UINT16 *oldtable = m_live_lookup; |
| 771 | m_live_lookup = m_table; | |
| 771 | m_live_lookup = &m_table[0]; | |
| 772 | 772 | if (sizeof(_UintType) == 1) m_space.write_byte(offset, data); |
| 773 | 773 | if (sizeof(_UintType) == 2) m_space.write_word(offset << 1, data, mask); |
| 774 | 774 | if (sizeof(_UintType) == 4) m_space.write_dword(offset << 2, data, mask); |
| r245687 | r245688 | |
| 2702 | 2702 | |
| 2703 | 2703 | address_table::address_table(address_space &space, bool large) |
| 2704 | 2704 | : m_table(1 << LEVEL1_BITS), |
| 2705 | m_live_lookup(m_table), | |
| 2706 | 2705 | m_space(space), |
| 2707 | 2706 | m_large(large), |
| 2708 | 2707 | m_subtable(SUBTABLE_COUNT), |
| 2709 | 2708 | m_subtable_alloc(0) |
| 2710 | 2709 | { |
| 2710 | m_live_lookup = &m_table[0]; | |
| 2711 | ||
| 2711 | 2712 | // make our static table all watchpoints |
| 2712 | 2713 | if (s_watchpoint_table[0] != STATIC_WATCHPOINT) |
| 2713 | 2714 | for (unsigned int i=0; i != ARRAY_LENGTH(s_watchpoint_table); i++) |
| r245687 | r245688 | |
| 3297 | 3298 | m_subtable_alloc += SUBTABLE_ALLOC; |
| 3298 | 3299 | UINT32 newsize = (1 << LEVEL1_BITS) + (m_subtable_alloc << level2_bits()); |
| 3299 | 3300 | |
| 3300 | bool was_live = (m_live_lookup == m_table); | |
| 3301 | m_table.resize_keep_and_clear_new(newsize); | |
| 3301 | bool was_live = (m_live_lookup == &m_table[0]); | |
| 3302 | int oldsize = m_table.size(); | |
| 3303 | m_table.resize(newsize); | |
| 3304 | memset(&m_table[oldsize], 0, (newsize-oldsize)*sizeof(m_table[0])); | |
| 3302 | 3305 | if (was_live) |
| 3303 | m_live_lookup = m_table; | |
| 3306 | m_live_lookup = &m_table[0]; | |
| 3304 | 3307 | } |
| 3305 | 3308 | // bump the usecount and return |
| 3306 | 3309 | m_subtable[subindex].m_usecount++; |
| r245687 | r245688 | |
| 3849 | 3852 | offs_t length = byteend + 1 - bytestart; |
| 3850 | 3853 | if (length < 4096) |
| 3851 | 3854 | { |
| 3852 | m_allocated.resize_and_clear(length); | |
| 3853 | m_data = m_allocated; | |
| 3855 | m_allocated.resize(length); | |
| 3856 | memset(&m_allocated[0], 0, length); | |
| 3857 | m_data = &m_allocated[0]; | |
| 3854 | 3858 | } |
| 3855 | 3859 | else |
| 3856 | 3860 | { |
| 3857 | m_allocated.resize_and_clear(length + 0xfff); | |
| 3861 | m_allocated.resize(length + 0xfff); | |
| 3862 | memset(&m_allocated[0], 0, length + 0xfff); | |
| 3858 | 3863 | m_data = reinterpret_cast<UINT8 *>((reinterpret_cast<FPTR>(&m_allocated[0]) + 0xfff) & ~0xfff); |
| 3859 | 3864 | } |
| 3860 | 3865 | } |
| r245687 | r245688 | |
| 4019 | 4024 | // validate |
| 4020 | 4025 | if (m_anonymous) |
| 4021 | 4026 | throw emu_fatalerror("memory_bank::set_entry called for anonymous bank"); |
| 4022 | if (entrynum < 0 || entrynum >= m_entry. | |
| 4027 | if (entrynum < 0 || entrynum >= int(m_entry.size())) | |
| 4023 | 4028 | throw emu_fatalerror("memory_bank::set_entry called with out-of-range entry %d", entrynum); |
| 4024 | 4029 | if (m_entry[entrynum].m_raw == NULL) |
| 4025 | 4030 | throw emu_fatalerror("memory_bank::set_entry called for bank '%s' with invalid bank entry %d", m_tag.c_str(), entrynum); |
| r245687 | r245688 | |
| 4042 | 4047 | void memory_bank::expand_entries(int entrynum) |
| 4043 | 4048 | { |
| 4044 | 4049 | // allocate a new array and copy from the old one; zero out the new entries |
| 4045 | m_entry.resize_keep_and_clear_new(entrynum + 1); | |
| 4050 | int old_size = m_entry.size(); | |
| 4051 | m_entry.resize(entrynum + 1); | |
| 4052 | memset(&m_entry[old_size], 0, (entrynum+1-old_size)*sizeof(m_entry[0])); | |
| 4046 | 4053 | } |
| 4047 | 4054 | |
| 4048 | 4055 | |
| r245687 | r245688 | |
| 4057 | 4064 | throw emu_fatalerror("memory_bank::configure_entry called with out-of-range entry %d", entrynum); |
| 4058 | 4065 | |
| 4059 | 4066 | // if we haven't allocated this many entries yet, expand our array |
| 4060 | if (entrynum >= m_entry. | |
| 4067 | if (entrynum >= int(m_entry.size())) | |
| 4061 | 4068 | expand_entries(entrynum); |
| 4062 | 4069 | |
| 4063 | 4070 | // set the entry |
| r245687 | r245688 | |
| 4093 | 4100 | throw emu_fatalerror("memory_bank::configure_decrypted_entry called with out-of-range entry %d", entrynum); |
| 4094 | 4101 | |
| 4095 | 4102 | // if we haven't allocated this many entries yet, expand our array |
| 4096 | if (entrynum >= m_entry. | |
| 4103 | if (entrynum >= int(m_entry.size())) | |
| 4097 | 4104 | expand_entries(entrynum); |
| 4098 | 4105 | |
| 4099 | 4106 | // set the entry |
| r245687 | r245688 | |
|---|---|---|
| 626 | 626 | offs_t m_bytestart; // byte-adjusted start offset |
| 627 | 627 | offs_t m_byteend; // byte-adjusted end offset |
| 628 | 628 | int m_curentry; // current entry |
| 629 | d | |
| 629 | std::vector<bank_entry> m_entry; // array of entries (dynamically allocated) | |
| 630 | 630 | astring m_name; // friendly name for this bank |
| 631 | 631 | astring m_tag; // tag for this bank |
| 632 | 632 | simple_list<bank_reference> m_reflist; // linked list of address spaces referencing this bank |
| r245687 | r245688 | |
| 693 | 693 | running_machine &machine() const { return m_machine; } |
| 694 | 694 | memory_region *next() const { return m_next; } |
| 695 | 695 | UINT8 *base() { return (this != NULL) ? &m_buffer[0] : NULL; } |
| 696 | UINT8 *end() { return (this != NULL) ? base() + m_buffer.count() : NULL; } | |
| 697 | UINT32 bytes() const { return (this != NULL) ? m_buffer.count() : 0; } | |
| 696 | UINT8 *end() { return (this != NULL) ? base() + m_buffer.size() : NULL; } | |
| 697 | UINT32 bytes() const { return (this != NULL) ? m_buffer.size() : 0; } | |
| 698 | 698 | const char *name() const { return m_name.c_str(); } |
| 699 | 699 | |
| 700 | 700 | // flag expansion |
| r245687 | r245688 | |
|---|---|---|
| 729 | 729 | recompute_lookups(); |
| 730 | 730 | } |
| 731 | 731 | assert (palette == &m_palclient->palette()); |
| 732 | return m_bcglookup; | |
| 732 | return &m_bcglookup[0]; | |
| 733 | 733 | |
| 734 | 734 | case TEXFORMAT_RGB32: |
| 735 | 735 | case TEXFORMAT_ARGB32: |
| r245687 | r245688 | |
|---|---|---|
| 575 | 575 | bitmap_argb32 * m_overlaybitmap; // overlay bitmap |
| 576 | 576 | render_texture * m_overlaytexture; // overlay texture |
| 577 | 577 | auto_pointer<palette_client> m_palclient; // client to the screen palette |
| 578 | d | |
| 578 | std::vector<rgb_t> m_bcglookup; // copy of screen palette with bcg adjustment | |
| 579 | 579 | rgb_t m_bcglookup256[0x400]; // lookup table for brightness/contrast/gamma |
| 580 | 580 | }; |
| 581 | 581 |
| r245687 | r245688 | |
|---|---|---|
| 53 | 53 | static glyph dummy_glyph; |
| 54 | 54 | |
| 55 | 55 | // grab the table; if none, return the dummy character |
| 56 | if (m_glyphs[chnum / 256].count() == 0 && m_format == FF_OSD) | |
| 57 | m_glyphs[chnum / 256].resize(256); | |
| 58 | if (m_glyphs[chnum / 256].count() == 0) | |
| 56 | if (!m_glyphs[chnum / 256] && m_format == FF_OSD) | |
| 57 | m_glyphs[chnum / 256] = new glyph[256]; | |
| 58 | if (!m_glyphs[chnum / 256]) | |
| 59 | 59 | return dummy_glyph; |
| 60 | 60 | |
| 61 | 61 | // if the character isn't generated yet, do it now |
| r245687 | r245688 | |
| 86 | 86 | m_rawsize(0), |
| 87 | 87 | m_osdfont(NULL) |
| 88 | 88 | { |
| 89 | memset(m_glyphs, 0, sizeof(m_glyphs)); | |
| 90 | ||
| 89 | 91 | // if this is an OSD font, we're done |
| 90 | 92 | if (filename != NULL) |
| 91 | 93 | { |
| r245687 | r245688 | |
| 127 | 129 | { |
| 128 | 130 | // free all the subtables |
| 129 | 131 | for (int tablenum = 0; tablenum < 256; tablenum++) |
| 130 | f | |
| 132 | if (m_glyphs[tablenum]) | |
| 131 | 133 | { |
| 132 | glyph &gl = m_glyphs[tablenum][charnum]; | |
| 133 | m_manager.texture_free(gl.texture); | |
| 134 | for (unsigned int charnum = 0; charnum < 256; charnum++) | |
| 135 | { | |
| 136 | glyph &gl = m_glyphs[tablenum][charnum]; | |
| 137 | m_manager.texture_free(gl.texture); | |
| 138 | } | |
| 139 | delete[] m_glyphs[tablenum]; | |
| 134 | 140 | } |
| 135 | 141 | |
| 136 | 142 | // release the OSD font |
| r245687 | r245688 | |
| 378 | 384 | m_rawdata.resize(m_rawsize + 1); |
| 379 | 385 | |
| 380 | 386 | // read the first chunk |
| 381 | UINT32 bytes = file.read(m_rawdata, MIN(CACHED_BDF_HASH_SIZE, m_rawsize)); | |
| 387 | UINT32 bytes = file.read(&m_rawdata[0], MIN(CACHED_BDF_HASH_SIZE, m_rawsize)); | |
| 382 | 388 | if (bytes != MIN(CACHED_BDF_HASH_SIZE, m_rawsize)) |
| 383 | 389 | return false; |
| 384 | 390 | |
| r245687 | r245688 | |
| 411 | 417 | // read in the rest of the font |
| 412 | 418 | if (bytes < m_rawsize) |
| 413 | 419 | { |
| 414 | UINT32 read = file.read(m_rawdata | |
| 420 | UINT32 read = file.read(&m_rawdata[bytes], m_rawsize - bytes); | |
| 415 | 421 | if (read != m_rawsize - bytes) |
| 416 | 422 | { |
| 417 | m_rawdata. | |
| 423 | m_rawdata.clear(); | |
| 418 | 424 | return false; |
| 419 | 425 | } |
| 420 | 426 | } |
| r245687 | r245688 | |
| 445 | 451 | |
| 446 | 452 | // first find the FONTBOUNDINGBOX tag |
| 447 | 453 | const char *ptr; |
| 448 | for (ptr = m_rawdata; ptr != NULL; ptr = next_line(ptr)) | |
| 454 | for (ptr = &m_rawdata[0]; ptr != NULL; ptr = next_line(ptr)) | |
| 449 | 455 | { |
| 450 | 456 | // we only care about a tiny few fields |
| 451 | 457 | if (strncmp(ptr, "FONTBOUNDINGBOX ", 16) == 0) |
| r245687 | r245688 | |
| 514 | 520 | if (charnum >= 0 && charnum < 65536 && rawdata != NULL && bmwidth >= 0 && bmheight >= 0) |
| 515 | 521 | { |
| 516 | 522 | // if we don't have a subtable yet, make one |
| 517 | if (m_glyphs[charnum / 256].count() == 0) | |
| 518 | m_glyphs[charnum / 256].resize(256); | |
| 523 | if (!m_glyphs[charnum / 256]) | |
| 524 | m_glyphs[charnum / 256] = new glyph[256]; | |
| 519 | 525 | |
| 520 | 526 | // fill in the entry |
| 521 | 527 | glyph &gl = m_glyphs[charnum / 256][charnum % 256]; |
| r245687 | r245688 | |
| 534 | 540 | } |
| 535 | 541 | |
| 536 | 542 | // make sure all the numbers are the same width |
| 537 | if (m_glyphs[0] | |
| 543 | if (m_glyphs[0]) | |
| 538 | 544 | { |
| 539 | 545 | int maxwidth = 0; |
| 540 | 546 | for (int ch = '0'; ch <= '9'; ch++) |
| r245687 | r245688 | |
| 577 | 583 | |
| 578 | 584 | // now read the rest of the data |
| 579 | 585 | m_rawdata.resize(filesize - CACHED_HEADER_SIZE); |
| 580 | bytes_read = file.read(m_rawdata, filesize - CACHED_HEADER_SIZE); | |
| 586 | bytes_read = file.read(&m_rawdata[0], filesize - CACHED_HEADER_SIZE); | |
| 581 | 587 | if (bytes_read != filesize - CACHED_HEADER_SIZE) |
| 582 | 588 | { |
| 583 | m_rawdata. | |
| 589 | m_rawdata.clear(); | |
| 584 | 590 | return false; |
| 585 | 591 | } |
| 586 | 592 | |
| r245687 | r245688 | |
| 592 | 598 | int chnum = (info[0] << 8) | info[1]; |
| 593 | 599 | |
| 594 | 600 | // if we don't have a subtable yet, make one |
| 595 | if (m_glyphs[chnum / 256].count() == 0) | |
| 596 | m_glyphs[chnum / 256].resize(256); | |
| 601 | if (!m_glyphs[chnum / 256]) | |
| 602 | m_glyphs[chnum / 256] = new glyph[256]; | |
| 597 | 603 | |
| 598 | 604 | // fill in the entry |
| 599 | 605 | glyph &gl = m_glyphs[chnum / 256][chnum % 256]; |
| r245687 | r245688 | |
| 602 | 608 | gl.yoffs = (INT16)((info[6] << 8) | info[7]); |
| 603 | 609 | gl.bmwidth = (info[8] << 8) | info[9]; |
| 604 | 610 | gl.bmheight = (info[10] << 8) | info[11]; |
| 605 | gl.rawdata = | |
| 611 | gl.rawdata = &m_rawdata[offset]; | |
| 606 | 612 | |
| 607 | 613 | // advance the offset past the character |
| 608 | 614 | offset += (gl.bmwidth * gl.bmheight + 7) / 8; |
| 609 | 615 | if (offset > filesize - CACHED_HEADER_SIZE) |
| 610 | 616 | { |
| 611 | m_rawdata. | |
| 617 | m_rawdata.clear(); | |
| 612 | 618 | return false; |
| 613 | 619 | } |
| 614 | 620 | } |
| r245687 | r245688 | |
| 637 | 643 | int numchars = 0; |
| 638 | 644 | for (int chnum = 0; chnum < 65536; chnum++) |
| 639 | 645 | { |
| 640 | if (m_glyphs[chnum / 256] | |
| 646 | if (m_glyphs[chnum / 256]) | |
| 641 | 647 | { |
| 642 | 648 | glyph &gl = m_glyphs[chnum / 256][chnum % 256]; |
| 643 | 649 | if (gl.width > 0) |
| r245687 | r245688 | |
| 654 | 660 | dynamic_buffer tempbuffer(65536); |
| 655 | 661 | |
| 656 | 662 | // write the header |
| 657 | UINT8 *dest = tempbuffer; | |
| 663 | UINT8 *dest = &tempbuffer[0]; | |
| 658 | 664 | *dest++ = 'f'; |
| 659 | 665 | *dest++ = 'o'; |
| 660 | 666 | *dest++ = 'n'; |
| r245687 | r245688 | |
| 671 | 677 | *dest++ = numchars >> 16; |
| 672 | 678 | *dest++ = numchars >> 8; |
| 673 | 679 | *dest++ = numchars & 0xff; |
| 674 | assert(dest - tempbuffer == CACHED_HEADER_SIZE); | |
| 675 | UINT32 bytes_written = file.write(tempbuffer, dest - tempbuffer); | |
| 676 | if (bytes_written != dest - tempbuffer) | |
| 680 | assert(dest == &tempbuffer[CACHED_HEADER_SIZE]); | |
| 681 | UINT32 bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE); | |
| 682 | if (bytes_written != dest - &tempbuffer[0]) | |
| 677 | 683 | throw emu_fatalerror("Error writing cached file"); |
| 678 | 684 | |
| 679 | 685 | // write the empty table to the beginning of the file |
| 680 | bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE); | |
| 686 | bytes_written = file.write(&chartable[0], numchars * CACHED_CHAR_SIZE); | |
| 681 | 687 | if (bytes_written != numchars * CACHED_CHAR_SIZE) |
| 682 | 688 | throw emu_fatalerror("Error writing cached file"); |
| 683 | 689 | |
| r245687 | r245688 | |
| 692 | 698 | if (gl.bitmap.valid()) |
| 693 | 699 | { |
| 694 | 700 | // write the data to the tempbuffer |
| 695 | dest = tempbuffer; | |
| 701 | dest = &tempbuffer[0]; | |
| 696 | 702 | UINT8 accum = 0; |
| 697 | 703 | UINT8 accbit = 7; |
| 698 | 704 | |
| r245687 | r245688 | |
| 719 | 725 | *dest++ = accum; |
| 720 | 726 | |
| 721 | 727 | // write the data |
| 722 | bytes_written = file.write(tempbuffer, dest - tempbuffer); | |
| 723 | if (bytes_written != dest - tempbuffer) | |
| 728 | bytes_written = file.write(&tempbuffer[0], dest - &tempbuffer[0]); | |
| 729 | if (bytes_written != dest - &tempbuffer[0]) | |
| 724 | 730 | throw emu_fatalerror("Error writing cached file"); |
| 725 | 731 | |
| 726 | 732 | // free the bitmap and texture |
| r245687 | r245688 | |
| 748 | 754 | |
| 749 | 755 | // seek back to the beginning and rewrite the table |
| 750 | 756 | file.seek(CACHED_HEADER_SIZE, SEEK_SET); |
| 751 | bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE); | |
| 757 | bytes_written = file.write(&chartable[0], numchars * CACHED_CHAR_SIZE); | |
| 752 | 758 | if (bytes_written != numchars * CACHED_CHAR_SIZE) |
| 753 | 759 | throw emu_fatalerror("Error writing cached file"); |
| 754 | 760 | return true; |
| r245687 | r245688 | |
|---|---|---|
| 90 | 90 | int m_height; // height of the font, from ascent to descent |
| 91 | 91 | int m_yoffs; // y offset from baseline to descent |
| 92 | 92 | float m_scale; // 1 / height precomputed |
| 93 | dynamic_array<glyph> m_glyphs[256]; // array of glyph subtables | |
| 94 | dynamic_array<char> m_rawdata; // pointer to the raw data for the font | |
| 93 | glyph *m_glyphs[256]; // array of glyph subtables | |
| 94 | std::vector<char> m_rawdata; // pointer to the raw data for the font | |
| 95 | 95 | UINT64 m_rawsize; // size of the raw font data |
| 96 | osd_font *m_osdfont; | |
| 96 | osd_font *m_osdfont; // handle to the OSD font | |
| 97 | 97 | |
| 98 | 98 | // constants |
| 99 | 99 | static const int CACHED_CHAR_SIZE = 12; |
| r245687 | r245688 | |
|---|---|---|
| 176 | 176 | simple_list<component> m_complist; // list of components |
| 177 | 177 | int m_defstate; // default state of this element |
| 178 | 178 | int m_maxstate; // maximum state value for all components |
| 179 | d | |
| 179 | std::vector<texture> m_elemtex; // array of element textures used for managing the scaled bitmaps | |
| 180 | 180 | }; |
| 181 | 181 | |
| 182 | 182 |
| r245687 | r245688 | |
|---|---|---|
| 800 | 800 | { |
| 801 | 801 | int evengroupcount = (tempbufsize / groupsize) * groupsize; |
| 802 | 802 | int bytesleft = (numbytes > evengroupcount) ? evengroupcount : numbytes; |
| 803 | UINT8 *bufptr = tempbuf; | |
| 803 | UINT8 *bufptr = &tempbuf[0]; | |
| 804 | 804 | |
| 805 | 805 | /* read as much as we can */ |
| 806 | 806 | LOG((" Reading %X bytes into buffer\n", bytesleft)); |
| r245687 | r245688 | |
|---|---|---|
| 48 | 48 | #define ALLOW_SAVE_TYPE(TYPE) \ |
| 49 | 49 | template<> struct save_manager::type_checker<TYPE> { static const bool is_atom = true; static const bool is_pointer = false; } |
| 50 | 50 | |
| 51 | // use this as above, but also to declare that d | |
| 51 | // use this as above, but also to declare that std::vector<TYPE> is safe as well | |
| 52 | 52 | #define ALLOW_SAVE_TYPE_AND_ARRAY(TYPE) \ |
| 53 | 53 | ALLOW_SAVE_TYPE(TYPE); \ |
| 54 | template<> inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, d | |
| 54 | template<> inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, std::vector<TYPE> &value, const char *name) { save_memory(device, module, tag, index, name, &value[0], sizeof(TYPE), value.size()); } | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // register items with explicit tags |
| r245687 | r245688 | |
| 209 | 209 | |
| 210 | 210 | // template specializations to enumerate the fundamental atomic types you are allowed to save |
| 211 | 211 | ALLOW_SAVE_TYPE_AND_ARRAY(char); |
| 212 | ALLOW_SAVE_TYPE | |
| 212 | ALLOW_SAVE_TYPE (bool); // std::vector<bool> may be packed internally | |
| 213 | 213 | ALLOW_SAVE_TYPE_AND_ARRAY(INT8); |
| 214 | 214 | ALLOW_SAVE_TYPE_AND_ARRAY(UINT8); |
| 215 | 215 | ALLOW_SAVE_TYPE_AND_ARRAY(INT16); |
| r245687 | r245688 | |
|---|---|---|
| 328 | 328 | return; |
| 329 | 329 | |
| 330 | 330 | // initialize everyone's states |
| 331 | d | |
| 331 | std::vector<int> penalty(matches); | |
| 332 | 332 | for (int matchnum = 0; matchnum < matches; matchnum++) |
| 333 | 333 | { |
| 334 | 334 | penalty[matchnum] = 9999; |
| r245687 | r245688 | |
| 781 | 781 | |
| 782 | 782 | // make sure we don't add duplicate regions |
| 783 | 783 | if (name != NULL && (flags & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_REGION) |
| 784 | for (int romentry = 0; romentry < m_current_part->m_romdata. | |
| 784 | for (unsigned int romentry = 0; romentry < m_current_part->m_romdata.size(); romentry++) | |
| 785 | 785 | if (m_current_part->m_romdata[romentry]._name != NULL && strcmp(m_current_part->m_romdata[romentry]._name, name) == 0) |
| 786 | 786 | parse_error("Duplicated dataarea %s in software %s", name, infoname()); |
| 787 | 787 | |
| 788 | 788 | // create the new entry and append it |
| 789 | rom_entry | |
| 789 | rom_entry entry; | |
| 790 | 790 | entry._name = m_list.add_string(name); |
| 791 | 791 | entry._hashdata = m_list.add_string(hashdata); |
| 792 | 792 | entry._offset = offset; |
| 793 | 793 | entry._length = length; |
| 794 | 794 | entry._flags = flags; |
| 795 | ||
| 796 | m_current_part->m_romdata.push_back(entry); | |
| 795 | 797 | } |
| 796 | 798 | |
| 797 | 799 |
| r245687 | r245688 | |
|---|---|---|
| 111 | 111 | const char *name() const { return m_name; } |
| 112 | 112 | const char *interface() const { return m_interface; } |
| 113 | 113 | feature_list_item *featurelist() const { return m_featurelist.first(); } |
| 114 | rom_entry *romdata(int index = 0) { return (index < m_romdata. | |
| 114 | rom_entry *romdata(unsigned int index = 0) { return (index < m_romdata.size()) ? &m_romdata[index] : NULL; } | |
| 115 | 115 | |
| 116 | 116 | // helpers |
| 117 | 117 | bool is_compatible(const software_list_device &swlist) const; |
| r245687 | r245688 | |
| 125 | 125 | const char * m_name; |
| 126 | 126 | const char * m_interface; |
| 127 | 127 | simple_list<feature_list_item> m_featurelist; |
| 128 | d | |
| 128 | std::vector<rom_entry> m_romdata; | |
| 129 | 129 | }; |
| 130 | 130 | |
| 131 | 131 |
| r245687 | r245688 | |
|---|---|---|
| 81 | 81 | m_device.machine().save().register_postload(save_prepost_delegate(FUNC(sound_stream::postload), this)); |
| 82 | 82 | |
| 83 | 83 | // save the gain of each input and output |
| 84 | for (int inputnum = 0; inputnum < m_input. | |
| 84 | for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) | |
| 85 | 85 | { |
| 86 | 86 | m_device.machine().save().save_item(&m_device, "stream", state_tag.c_str(), inputnum, NAME(m_input[inputnum].m_gain)); |
| 87 | 87 | m_device.machine().save().save_item(&m_device, "stream", state_tag.c_str(), inputnum, NAME(m_input[inputnum].m_user_gain)); |
| 88 | 88 | } |
| 89 | for (int outputnum = 0; outputnum < m_output. | |
| 89 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) | |
| 90 | 90 | { |
| 91 | 91 | m_output[outputnum].m_stream = this; |
| 92 | 92 | m_device.machine().save().save_item(&m_device, "stream", state_tag.c_str(), outputnum, NAME(m_output[outputnum].m_gain)); |
| r245687 | r245688 | |
| 129 | 129 | |
| 130 | 130 | float sound_stream::user_gain(int inputnum) const |
| 131 | 131 | { |
| 132 | assert(inputnum >= 0 && inputnum < m_input. | |
| 132 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 133 | 133 | return float(m_input[inputnum].m_user_gain) / 256.0f; |
| 134 | 134 | } |
| 135 | 135 | |
| r245687 | r245688 | |
| 141 | 141 | |
| 142 | 142 | float sound_stream::input_gain(int inputnum) const |
| 143 | 143 | { |
| 144 | assert(inputnum >= 0 && inputnum < m_input. | |
| 144 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 145 | 145 | return float(m_input[inputnum].m_gain) / 256.0f; |
| 146 | 146 | } |
| 147 | 147 | |
| r245687 | r245688 | |
| 153 | 153 | |
| 154 | 154 | float sound_stream::output_gain(int outputnum) const |
| 155 | 155 | { |
| 156 | assert(outputnum >= 0 && outputnum < m_output. | |
| 156 | assert(outputnum >= 0 && outputnum < m_output.size()); | |
| 157 | 157 | return float(m_output[outputnum].m_gain) / 256.0f; |
| 158 | 158 | } |
| 159 | 159 | |
| r245687 | r245688 | |
| 166 | 166 | const char *sound_stream::input_name(int inputnum, astring &str) const |
| 167 | 167 | { |
| 168 | 168 | // start with our device name and tag |
| 169 | assert(inputnum >= 0 && inputnum < m_input. | |
| 169 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 170 | 170 | str.printf("%s '%s': ", m_device.name(), m_device.tag()); |
| 171 | 171 | |
| 172 | 172 | // if we have a source, indicate where the sound comes from by device name and tag |
| r245687 | r245688 | |
| 202 | 202 | |
| 203 | 203 | device_t *sound_stream::input_source_device(int inputnum) const |
| 204 | 204 | { |
| 205 | assert(inputnum >= 0 && inputnum < m_input. | |
| 205 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 206 | 206 | return (m_input[inputnum].m_source != NULL) ? &m_input[inputnum].m_source->m_stream->device() : NULL; |
| 207 | 207 | } |
| 208 | 208 | |
| r245687 | r245688 | |
| 214 | 214 | |
| 215 | 215 | int sound_stream::input_source_outputnum(int inputnum) const |
| 216 | 216 | { |
| 217 | assert(inputnum >= 0 && inputnum < m_input. | |
| 217 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 218 | 218 | return (m_input[inputnum].m_source != NULL) ? (m_input[inputnum].m_source - &m_input[inputnum].m_source->m_stream->m_output[0]) : -1; |
| 219 | 219 | } |
| 220 | 220 | |
| r245687 | r245688 | |
| 228 | 228 | VPRINTF(("stream_set_input(%p, '%s', %d, %p, %d, %f)\n", this, m_device.tag(), index, input_stream, output_index, gain)); |
| 229 | 229 | |
| 230 | 230 | // make sure it's a valid input |
| 231 | if (index >= m_input.count()) | |
| 232 | fatalerror("Fatal error: stream_set_input attempted to configure non-existant input %d (%d max)\n", index, m_input.count()); | |
| 231 | if (index >= m_input.size()) | |
| 232 | fatalerror("Fatal error: stream_set_input attempted to configure non-existant input %d (%d max)\n", index, int(m_input.size())); | |
| 233 | 233 | |
| 234 | 234 | // make sure it's a valid output |
| 235 | if (input_stream != NULL && output_index >= input_stream->m_output.count()) | |
| 236 | fatalerror("Fatal error: stream_set_input attempted to use a non-existant output %d (%d max)\n", output_index, m_output.count()); | |
| 235 | if (input_stream != NULL && output_index >= input_stream->m_output.size()) | |
| 236 | fatalerror("Fatal error: stream_set_input attempted to use a non-existant output %d (%d max)\n", output_index, int(m_output.size())); | |
| 237 | 237 | |
| 238 | 238 | // if this input is already wired, update the dependent info |
| 239 | 239 | stream_input &input = m_input[index]; |
| r245687 | r245688 | |
| 339 | 339 | void sound_stream::set_user_gain(int inputnum, float gain) |
| 340 | 340 | { |
| 341 | 341 | update(); |
| 342 | assert(inputnum >= 0 && inputnum < m_input. | |
| 342 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 343 | 343 | m_input[inputnum].m_user_gain = int(0x100 * gain); |
| 344 | 344 | } |
| 345 | 345 | |
| r245687 | r245688 | |
| 352 | 352 | void sound_stream::set_input_gain(int inputnum, float gain) |
| 353 | 353 | { |
| 354 | 354 | update(); |
| 355 | assert(inputnum >= 0 && inputnum < m_input. | |
| 355 | assert(inputnum >= 0 && inputnum < m_input.size()); | |
| 356 | 356 | m_input[inputnum].m_gain = int(0x100 * gain); |
| 357 | 357 | } |
| 358 | 358 | |
| r245687 | r245688 | |
| 365 | 365 | void sound_stream::set_output_gain(int outputnum, float gain) |
| 366 | 366 | { |
| 367 | 367 | update(); |
| 368 | assert(outputnum >= 0 && outputnum < m_output. | |
| 368 | assert(outputnum >= 0 && outputnum < m_output.size()); | |
| 369 | 369 | m_output[outputnum].m_gain = int(0x100 * gain); |
| 370 | 370 | } |
| 371 | 371 | |
| r245687 | r245688 | |
| 401 | 401 | { |
| 402 | 402 | // if we have samples to move, do so for each output |
| 403 | 403 | if (output_bufindex > 0) |
| 404 | for (int outputnum = 0; outputnum < m_output. | |
| 404 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) | |
| 405 | 405 | { |
| 406 | 406 | stream_output &output = m_output[outputnum]; |
| 407 | 407 | memmove(&output.m_buffer[0], &output.m_buffer[samples_to_lose], sizeof(output.m_buffer[0]) * (output_bufindex - samples_to_lose)); |
| r245687 | r245688 | |
| 439 | 439 | m_output_base_sampindex = m_output_sampindex - m_max_samples_per_update; |
| 440 | 440 | |
| 441 | 441 | // clear out the buffer |
| 442 | for (int outputnum = 0; outputnum < m_output. | |
| 442 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) | |
| 443 | 443 | memset(&m_output[outputnum].m_buffer[0], 0, m_max_samples_per_update * sizeof(m_output[outputnum].m_buffer[0])); |
| 444 | 444 | } |
| 445 | 445 | |
| r245687 | r245688 | |
| 456 | 456 | { |
| 457 | 457 | m_sample_rate = 0; |
| 458 | 458 | // When synchronous, pick the sample rate for the inputs, if any |
| 459 | for (int inputnum = 0; inputnum < m_input. | |
| 459 | for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) | |
| 460 | 460 | { |
| 461 | 461 | stream_input &input = m_input[inputnum]; |
| 462 | 462 | if (input.m_source != NULL) |
| r245687 | r245688 | |
| 482 | 482 | allocate_output_buffers(); |
| 483 | 483 | |
| 484 | 484 | // iterate over each input |
| 485 | for (int inputnum = 0; inputnum < m_input. | |
| 485 | for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) | |
| 486 | 486 | { |
| 487 | 487 | // if we have a source, see if its sample rate changed |
| 488 | 488 | stream_input &input = m_input[inputnum]; |
| r245687 | r245688 | |
| 536 | 536 | m_resample_bufalloc = bufsize; |
| 537 | 537 | |
| 538 | 538 | // iterate over outputs and realloc their buffers |
| 539 | for (int inputnum = 0; inputnum < m_input.count(); inputnum++) | |
| 540 | m_input[inputnum].m_resample.resize_keep_and_clear_new(m_resample_bufalloc); | |
| 539 | for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) { | |
| 540 | unsigned int old_size = m_input[inputnum].m_resample.size(); | |
| 541 | m_input[inputnum].m_resample.resize(m_resample_bufalloc); | |
| 542 | memset(&m_input[inputnum].m_resample[old_size], 0, (m_resample_bufalloc - old_size)*sizeof(m_input[inputnum].m_resample[0])); | |
| 543 | } | |
| 541 | 544 | } |
| 542 | 545 | } |
| 543 | 546 | |
| r245687 | r245688 | |
| 557 | 560 | m_output_bufalloc = bufsize; |
| 558 | 561 | |
| 559 | 562 | // iterate over outputs and realloc their buffers |
| 560 | for (int outputnum = 0; outputnum < m_output.count(); outputnum++) | |
| 561 | m_output[outputnum].m_buffer.resize_keep_and_clear_new(m_output_bufalloc); | |
| 563 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) { | |
| 564 | unsigned int old_size = m_output[outputnum].m_buffer.size(); | |
| 565 | m_output[outputnum].m_buffer.resize(m_output_bufalloc); | |
| 566 | memset(&m_output[outputnum].m_buffer[old_size], 0, (m_output_bufalloc - old_size)*sizeof(m_output[outputnum].m_buffer[0])); | |
| 567 | } | |
| 562 | 568 | } |
| 563 | 569 | } |
| 564 | 570 | |
| r245687 | r245688 | |
| 573 | 579 | recompute_sample_rate_data(); |
| 574 | 580 | |
| 575 | 581 | // make sure our output buffers are fully cleared |
| 576 | for (int outputnum = 0; outputnum < m_output.count(); outputnum++) | |
| 577 | memset(m_output[outputnum].m_buffer, 0, m_output_bufalloc * sizeof(m_output[outputnum].m_buffer[0])); | |
| 582 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) | |
| 583 | memset(&m_output[outputnum].m_buffer[0], 0, m_output_bufalloc * sizeof(m_output[outputnum].m_buffer[0])); | |
| 578 | 584 | |
| 579 | 585 | // recompute the sample indexes to make sense |
| 580 | 586 | m_output_sampindex = m_device.machine().sound().last_update().attoseconds / m_attoseconds_per_sample; |
| r245687 | r245688 | |
| 599 | 605 | VPRINTF(("generate_samples(%p, %d)\n", this, samples)); |
| 600 | 606 | |
| 601 | 607 | // ensure all inputs are up to date and generate resampled data |
| 602 | for (int inputnum = 0; inputnum < m_input. | |
| 608 | for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) | |
| 603 | 609 | { |
| 604 | 610 | // update the stream to the current time |
| 605 | 611 | stream_input &input = m_input[inputnum]; |
| r245687 | r245688 | |
| 611 | 617 | } |
| 612 | 618 | |
| 613 | 619 | // loop over all outputs and compute the output pointer |
| 614 | for (int outputnum = 0; outputnum < m_output. | |
| 620 | for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) | |
| 615 | 621 | { |
| 616 | 622 | stream_output &output = m_output[outputnum]; |
| 617 | 623 | m_output_array[outputnum] = &output.m_buffer[m_output_sampindex - m_output_base_sampindex]; |
| r245687 | r245688 | |
| 619 | 625 | |
| 620 | 626 | // run the callback |
| 621 | 627 | VPRINTF((" callback(%p, %d)\n", this, samples)); |
| 622 | m_callback(*this, m_input_array, m_output_array, samples); | |
| 628 | m_callback(*this, &m_input_array[0], &m_output_array[0], samples); | |
| 623 | 629 | VPRINTF((" callback done\n")); |
| 624 | 630 | } |
| 625 | 631 | |
| r245687 | r245688 | |
| 632 | 638 | stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, UINT32 numsamples) |
| 633 | 639 | { |
| 634 | 640 | // if we don't have an output to pull data from, generate silence |
| 635 | stream_sample_t *dest = input.m_resample; | |
| 641 | stream_sample_t *dest = &input.m_resample[0]; | |
| 636 | 642 | if (input.m_source == NULL) |
| 637 | 643 | { |
| 638 | 644 | memset(dest, 0, numsamples * sizeof(*dest)); |
| 639 | return input.m_resample; | |
| 645 | return &input.m_resample[0]; | |
| 640 | 646 | } |
| 641 | 647 | |
| 642 | 648 | // grab data from the output |
| r245687 | r245688 | |
| 740 | 746 | } |
| 741 | 747 | } |
| 742 | 748 | |
| 743 | return input.m_resample; | |
| 749 | return &input.m_resample[0]; | |
| 744 | 750 | } |
| 745 | 751 | |
| 746 | 752 | |
| r245687 | r245688 | |
| 1022 | 1028 | int samples_this_update = 0; |
| 1023 | 1029 | speaker_device_iterator iter(machine().root_device()); |
| 1024 | 1030 | for (speaker_device *speaker = iter.first(); speaker != NULL; speaker = iter.next()) |
| 1025 | speaker->mix(m_leftmix, m_rightmix, samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); | |
| 1031 | speaker->mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); | |
| 1026 | 1032 | |
| 1027 | 1033 | // now downmix the final result |
| 1028 | 1034 | UINT32 finalmix_step = machine().video().speed_factor(); |
| 1029 | 1035 | UINT32 finalmix_offset = 0; |
| 1030 | INT16 *finalmix = m_finalmix; | |
| 1036 | INT16 *finalmix = &m_finalmix[0]; | |
| 1031 | 1037 | int sample; |
| 1032 | 1038 | for (sample = m_finalmix_leftover; sample < samples_this_update * 1000; sample += finalmix_step) |
| 1033 | 1039 | { |
| r245687 | r245688 | |
|---|---|---|
| 67 | 67 | |
| 68 | 68 | // internal state |
| 69 | 69 | sound_stream * m_stream; // owning stream |
| 70 | d | |
| 70 | std::vector<stream_sample_t> m_buffer; // output buffer | |
| 71 | 71 | int m_dependents; // number of dependents |
| 72 | 72 | INT16 m_gain; // gain to apply to the output |
| 73 | 73 | }; |
| r245687 | r245688 | |
| 82 | 82 | |
| 83 | 83 | // internal state |
| 84 | 84 | stream_output * m_source; // pointer to the sound_output for this source |
| 85 | d | |
| 85 | std::vector<stream_sample_t> m_resample; // buffer for resampling to the stream's sample rate | |
| 86 | 86 | attoseconds_t m_latency_attoseconds; // latency between this stream and the input stream |
| 87 | 87 | INT16 m_gain; // gain to apply to this input |
| 88 | 88 | INT16 m_user_gain; // user-controlled gain to apply to this input |
| r245687 | r245688 | |
| 104 | 104 | int sample_rate() const { return (m_new_sample_rate != 0) ? m_new_sample_rate : m_sample_rate; } |
| 105 | 105 | attotime sample_time() const; |
| 106 | 106 | attotime sample_period() const { return attotime(0, m_attoseconds_per_sample); } |
| 107 | int input_count() const { return m_input.count(); } | |
| 108 | int output_count() const { return m_output.count(); } | |
| 107 | int input_count() const { return m_input.size(); } | |
| 108 | int output_count() const { return m_output.size(); } | |
| 109 | 109 | const char *input_name(int inputnum, astring &str) const; |
| 110 | 110 | device_t *input_source_device(int inputnum) const; |
| 111 | 111 | int input_source_outputnum(int inputnum) const; |
| r245687 | r245688 | |
| 153 | 153 | emu_timer * m_sync_timer; // update timer for synchronous streams |
| 154 | 154 | |
| 155 | 155 | // input information |
| 156 | dynamic_array<stream_input> m_input; // list of streams we directly depend upon | |
| 157 | dynamic_array<stream_sample_t *> m_input_array; // array of inputs for passing to the callback | |
| 156 | std::vector<stream_input> m_input; // list of streams we directly depend upon | |
| 157 | std::vector<stream_sample_t *> m_input_array; // array of inputs for passing to the callback | |
| 158 | 158 | |
| 159 | 159 | // resample buffer information |
| 160 | 160 | UINT32 m_resample_bufalloc; // allocated size of each resample buffer |
| 161 | 161 | |
| 162 | 162 | // output information |
| 163 | dynamic_array<stream_output> m_output; // list of streams which directly depend upon us | |
| 164 | dynamic_array<stream_sample_t *> m_output_array; // array of outputs for passing to the callback | |
| 163 | std::vector<stream_output> m_output; // list of streams which directly depend upon us | |
| 164 | std::vector<stream_sample_t *> m_output_array; // array of outputs for passing to the callback | |
| 165 | 165 | |
| 166 | 166 | // output buffer information |
| 167 | 167 | UINT32 m_output_bufalloc; // allocated size of each output buffer |
| r245687 | r245688 | |
| 232 | 232 | emu_timer * m_update_timer; // timer to drive periodic updates |
| 233 | 233 | |
| 234 | 234 | UINT32 m_finalmix_leftover; |
| 235 | dynamic_array<INT16> m_finalmix; | |
| 236 | dynamic_array<INT32> m_leftmix; | |
| 237 | dynamic_array<INT32> m_rightmix; | |
| 235 | std::vector<INT16> m_finalmix; | |
| 236 | std::vector<INT32> m_leftmix; | |
| 237 | std::vector<INT32> m_rightmix; | |
| 238 | 238 | |
| 239 | 239 | UINT8 m_muted; |
| 240 | 240 | int m_attenuation; |
| r245687 | r245688 | |
|---|---|---|
| 433 | 433 | { |
| 434 | 434 | double min = 10.0, max = 0.0; |
| 435 | 435 | |
| 436 | d | |
| 436 | std::vector<double> temp(8*32*32*32, 0); | |
| 437 | 437 | |
| 438 | 438 | for (int e=0; e < 8; e++) |
| 439 | 439 | { |
| r245687 | r245688 | |
|---|---|---|
| 117 | 117 | node_step_list_t step_list; |
| 118 | 118 | |
| 119 | 119 | /* list of source nodes */ |
| 120 | | |
| 120 | vector_t<input_buffer> source_list; /* discrete_source_node */ | |
| 121 | 121 | |
| 122 | 122 | int task_group; |
| 123 | 123 | |
| r245687 | r245688 | |
| 137 | 137 | void check(discrete_task *dest_task); |
| 138 | 138 | void prepare_for_queue(int samples); |
| 139 | 139 | |
| 140 | | |
| 140 | vector_t<output_buffer> m_buffers; | |
| 141 | 141 | discrete_device & m_device; |
| 142 | 142 | |
| 143 | 143 | private: |
| r245687 | r245688 | |
| 525 | 525 | } |
| 526 | 526 | else if (intf[node_count].type == DSO_DELETE) |
| 527 | 527 | { |
| 528 | | |
| 528 | vector_t<int> deletethem; | |
| 529 | 529 | |
| 530 | 530 | for (int i=0; i<block_list.count(); i++) |
| 531 | 531 | { |
| r245687 | r245688 | |
|---|---|---|
| 3751 | 3751 | * add and delete may be slow - the focus is on access! |
| 3752 | 3752 | */ |
| 3753 | 3753 | |
| 3754 | // TODO: replace with dynamic_array from utils | |
| 3755 | template<class _ElementType> struct dynamic_array_t | |
| 3754 | // TODO: replace with vector from utils | |
| 3755 | template<class _ElementType> struct vector_t | |
| 3756 | 3756 | { |
| 3757 | 3757 | public: |
| 3758 | | |
| 3758 | vector_t(int initial) { | |
| 3759 | 3759 | m_count = 0; |
| 3760 | 3760 | m_allocated = initial; |
| 3761 | 3761 | m_arr = global_alloc_array_clear(_ElementType, m_allocated); |
| 3762 | 3762 | } |
| 3763 | | |
| 3763 | vector_t() { | |
| 3764 | 3764 | m_count = 0; |
| 3765 | 3765 | m_allocated = 16; |
| 3766 | 3766 | m_arr = global_alloc_array_clear(_ElementType, m_allocated); |
| 3767 | 3767 | } |
| 3768 | ~ | |
| 3768 | ~vector_t() { | |
| 3769 | 3769 | global_free_array(m_arr); |
| 3770 | 3770 | } |
| 3771 | 3771 | _ElementType& operator [] (unsigned int index) const // get array item |
| r245687 | r245688 | |
| 3773 | 3773 | return m_arr[index]; |
| 3774 | 3774 | } |
| 3775 | 3775 | |
| 3776 | | |
| 3776 | vector_t(const vector_t &a) // copy constructor | |
| 3777 | 3777 | { |
| 3778 | 3778 | m_allocated = a.count(); |
| 3779 | 3779 | if (m_allocated < 16) |
| r245687 | r245688 | |
| 3783 | 3783 | for (int i=0; i < m_count; i++) |
| 3784 | 3784 | m_arr[i] = a[i]; |
| 3785 | 3785 | } |
| 3786 | | |
| 3786 | vector_t& operator = (const vector_t &a) // assignment operator | |
| 3787 | 3787 | { |
| 3788 | 3788 | if (this == &a) return *this; |
| 3789 | 3789 | m_allocated = a.count(); |
| r245687 | r245688 | |
| 4185 | 4185 | class discrete_base_node; |
| 4186 | 4186 | class discrete_dss_input_stream_node; |
| 4187 | 4187 | class discrete_device; |
| 4188 | typedef dynamic_array_t<discrete_base_node *> node_list_t; | |
| 4189 | typedef dynamic_array_t<discrete_dss_input_stream_node *> istream_node_list_t; | |
| 4190 | typedef dynamic_array_t<discrete_task *> task_list_t; | |
| 4188 | typedef vector_t<discrete_base_node *> node_list_t; | |
| 4189 | typedef vector_t<discrete_dss_input_stream_node *> istream_node_list_t; | |
| 4190 | typedef vector_t<discrete_task *> task_list_t; | |
| 4191 | 4191 | |
| 4192 | 4192 | |
| 4193 | 4193 | /************************************* |
| r245687 | r245688 | |
| 4216 | 4216 | const char * name; /* Node Name */ |
| 4217 | 4217 | const char * mod_name; /* Module / class name */ |
| 4218 | 4218 | }; |
| 4219 | typedef | |
| 4219 | typedef vector_t<const discrete_block *> sound_block_list_t; | |
| 4220 | 4220 | |
| 4221 | 4221 | /************************************* |
| 4222 | 4222 | * |
| r245687 | r245688 | |
| 4233 | 4233 | osd_ticks_t run_time; |
| 4234 | 4234 | discrete_base_node * self; |
| 4235 | 4235 | }; |
| 4236 | typedef | |
| 4236 | typedef vector_t<discrete_step_interface *> node_step_list_t; | |
| 4237 | 4237 | |
| 4238 | 4238 | class discrete_input_interface |
| 4239 | 4239 | { |
| r245687 | r245688 | |
| 4271 | 4271 | //************************************************************************** |
| 4272 | 4272 | |
| 4273 | 4273 | class discrete_sound_output_interface; |
| 4274 | typedef | |
| 4274 | typedef vector_t<discrete_sound_output_interface *> node_output_list_t; | |
| 4275 | 4275 | |
| 4276 | 4276 | |
| 4277 | 4277 | // ======================> discrete_device |
| r245687 | r245688 | |
|---|---|---|
| 73 | 73 | void samples_device::start(UINT8 channel, UINT32 samplenum, bool loop) |
| 74 | 74 | { |
| 75 | 75 | // if samples are disabled, just return quietly |
| 76 | if (m_sample. | |
| 76 | if (m_sample.empty()) | |
| 77 | 77 | return; |
| 78 | 78 | |
| 79 | assert(samplenum < m_sample. | |
| 79 | assert(samplenum < m_sample.size()); | |
| 80 | 80 | assert(channel < m_channels); |
| 81 | 81 | |
| 82 | 82 | // force an update before we start |
| r245687 | r245688 | |
| 85 | 85 | |
| 86 | 86 | // update the parameters |
| 87 | 87 | sample_t &sample = m_sample[samplenum]; |
| 88 | chan.source = sample.data; | |
| 89 | chan.source_length = sample.data.count(); | |
| 88 | chan.source = &sample.data[0]; | |
| 89 | chan.source_length = sample.data.size(); | |
| 90 | 90 | chan.source_num = (chan.source_length > 0) ? samplenum : -1; |
| 91 | 91 | chan.pos = 0; |
| 92 | 92 | chan.frac = 0; |
| r245687 | r245688 | |
| 292 | 292 | { |
| 293 | 293 | // attach any samples that were loaded and playing |
| 294 | 294 | channel_t &chan = m_channel[channel]; |
| 295 | if (chan.source_num >= 0 && chan.source_num < m_sample. | |
| 295 | if (chan.source_num >= 0 && chan.source_num < m_sample.size()) | |
| 296 | 296 | { |
| 297 | 297 | sample_t &sample = m_sample[chan.source_num]; |
| 298 | chan.source = sample.data; | |
| 299 | chan.source_length = sample.data.count(); | |
| 300 | if (sample.data == NULL) | |
| 298 | chan.source = &sample.data[0]; | |
| 299 | chan.source_length = sample.data.size(); | |
| 300 | if (sample.data.empty()) | |
| 301 | 301 | chan.source_num = -1; |
| 302 | 302 | } |
| 303 | 303 | |
| r245687 | r245688 | |
| 540 | 540 | if (bits == 8) |
| 541 | 541 | { |
| 542 | 542 | sample.data.resize(length); |
| 543 | file.read(sample.data, length); | |
| 543 | file.read(&sample.data[0], length); | |
| 544 | 544 | |
| 545 | 545 | // convert 8-bit data to signed samples |
| 546 | 546 | UINT8 *tempptr = reinterpret_cast<UINT8 *>(&sample.data[0]); |
| r245687 | r245688 | |
| 551 | 551 | { |
| 552 | 552 | // 16-bit data is fine as-is |
| 553 | 553 | sample.data.resize(length / 2); |
| 554 | file.read(sample.data, length); | |
| 554 | file.read(&sample.data[0], length); | |
| 555 | 555 | |
| 556 | 556 | // swap high/low on big-endian systems |
| 557 | 557 | if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) |
| r245687 | r245688 | |
| 583 | 583 | |
| 584 | 584 | // resize the array and read |
| 585 | 585 | sample.data.resize(decoder.total_samples()); |
| 586 | if (!decoder.decode_interleaved(sample.data, sample.data. | |
| 586 | if (!decoder.decode_interleaved(&sample.data[0], sample.data.size())) | |
| 587 | 587 | return false; |
| 588 | 588 | |
| 589 | 589 | // finish up and clean up |
| r245687 | r245688 | |
|---|---|---|
| 71 | 71 | sample_t &operator=(const sample_t &rhs) { assert(false); return *this; } |
| 72 | 72 | |
| 73 | 73 | UINT32 frequency; // frequency of the sample |
| 74 | d | |
| 74 | std::vector<INT16> data; // 16-bit signed data | |
| 75 | 75 | }; |
| 76 | 76 | static bool read_sample(emu_file &file, sample_t &sample); |
| 77 | 77 | |
| r245687 | r245688 | |
| 114 | 114 | void load_samples(); |
| 115 | 115 | |
| 116 | 116 | // internal state |
| 117 | dynamic_array<channel_t> m_channel; | |
| 118 | dynamic_array<sample_t> m_sample; | |
| 117 | std::vector<channel_t> m_channel; | |
| 118 | std::vector<sample_t> m_sample; | |
| 119 | 119 | |
| 120 | 120 | // internal constants |
| 121 | 121 | static const UINT8 FRAC_BITS = 24; |
| r245687 | r245688 | |
|---|---|---|
| 494 | 494 | marker_tail(NULL) |
| 495 | 495 | { |
| 496 | 496 | buffer_size=sector_size*num_sectors; |
| 497 | buffer.resize_and_clear(buffer_size); | |
| 497 | buffer.resize(buffer_size); | |
| 498 | memset(&buffer[0], 0, buffer_size); | |
| 498 | 499 | } |
| 499 | 500 | |
| 500 | 501 | ~stream_buffer() |
| r245687 | r245688 | |
| 518 | 519 | } |
| 519 | 520 | marker_tail=xam; |
| 520 | 521 | |
| 521 | unsigned char *ret=buffer | |
| 522 | unsigned char *ret=&buffer[head]; | |
| 522 | 523 | head=(head+sector_size)%buffer_size; |
| 523 | 524 | in+=sector_size; |
| 524 | 525 | return ret; |
| r245687 | r245688 | |
|---|---|---|
| 122 | 122 | |
| 123 | 123 | void wav_add_data_32(wav_file *wav, INT32 *data, int samples, int shift) |
| 124 | 124 | { |
| 125 | d | |
| 125 | std::vector<INT16> temp; | |
| 126 | 126 | int i; |
| 127 | 127 | |
| 128 | if (!wav) return; | |
| 128 | if (!wav || !samples) return; | |
| 129 | 129 | |
| 130 | 130 | /* resize dynamic array */ |
| 131 | 131 | temp.resize(samples); |
| 132 | if (!temp) | |
| 133 | return; | |
| 134 | 132 | |
| 135 | 133 | /* clamp */ |
| 136 | 134 | for (i = 0; i < samples; i++) |
| r245687 | r245688 | |
| 140 | 138 | } |
| 141 | 139 | |
| 142 | 140 | /* write and flush */ |
| 143 | fwrite(temp, 2, samples, wav->file); | |
| 141 | fwrite(&temp[0], 2, samples, wav->file); | |
| 144 | 142 | fflush(wav->file); |
| 145 | 143 | } |
| 146 | 144 | |
| 147 | 145 | |
| 148 | 146 | void wav_add_data_16lr(wav_file *wav, INT16 *left, INT16 *right, int samples) |
| 149 | 147 | { |
| 150 | d | |
| 148 | std::vector<INT16> temp; | |
| 151 | 149 | int i; |
| 152 | 150 | |
| 153 | if (!wav) return; | |
| 151 | if (!wav || !samples) return; | |
| 154 | 152 | |
| 155 | 153 | /* resize dynamic array */ |
| 156 | 154 | temp.resize(samples * 2); |
| 157 | if (!temp) | |
| 158 | return; | |
| 159 | 155 | |
| 160 | 156 | /* interleave */ |
| 161 | 157 | for (i = 0; i < samples * 2; i++) |
| 162 | 158 | temp[i] = (i & 1) ? right[i / 2] : left[i / 2]; |
| 163 | 159 | |
| 164 | 160 | /* write and flush */ |
| 165 | fwrite(temp, 4, samples, wav->file); | |
| 161 | fwrite(&temp[0], 4, samples, wav->file); | |
| 166 | 162 | fflush(wav->file); |
| 167 | 163 | } |
| 168 | 164 | |
| 169 | 165 | |
| 170 | 166 | void wav_add_data_32lr(wav_file *wav, INT32 *left, INT32 *right, int samples, int shift) |
| 171 | 167 | { |
| 172 | d | |
| 168 | std::vector<INT16> temp; | |
| 173 | 169 | int i; |
| 174 | 170 | |
| 175 | if (!wav) return; | |
| 171 | if (!wav || !samples) return; | |
| 176 | 172 | |
| 177 | 173 | /* resize dynamic array */ |
| 178 | 174 | temp.resize(samples); |
| 179 | if (!temp) | |
| 180 | return; | |
| 181 | 175 | |
| 182 | 176 | /* interleave */ |
| 183 | 177 | for (i = 0; i < samples * 2; i++) |
| r245687 | r245688 | |
| 188 | 182 | } |
| 189 | 183 | |
| 190 | 184 | /* write and flush */ |
| 191 | fwrite(temp, 4, samples, wav->file); | |
| 185 | fwrite(&temp[0], 4, samples, wav->file); | |
| 192 | 186 | fflush(wav->file); |
| 193 | 187 | } |
| r245687 | r245688 | |
|---|---|---|
| 194 | 194 | // memory pointers and buffers |
| 195 | 195 | _SpriteRAMType * m_spriteram; // pointer to spriteram pointer |
| 196 | 196 | INT32 m_spriteram_bytes; // size of sprite RAM in bytes |
| 197 | d | |
| 197 | std::vector<_SpriteRAMType> m_buffer; // buffered spriteram for those that use it | |
| 198 | 198 | |
| 199 | 199 | // bitmaps |
| 200 | 200 | _BitmapType m_bitmap; // live bitmap |
| r245687 | r245688 | |
|---|---|---|
| 378 | 378 | // reset scroll information |
| 379 | 379 | m_scrollrows = 1; |
| 380 | 380 | m_scrollcols = 1; |
| 381 | m_rowscroll.resize_and_clear(m_height); | |
| 382 | m_colscroll.resize_and_clear(m_width); | |
| 381 | m_rowscroll.resize(m_height); | |
| 382 | memset(&m_rowscroll[0], 0, m_height*sizeof(m_rowscroll[0])); | |
| 383 | m_colscroll.resize(m_width); | |
| 384 | memset(&m_colscroll[0], 0, m_width*sizeof(m_colscroll[0])); | |
| 383 | 385 | m_dx = 0; |
| 384 | 386 | m_dx_flipped = 0; |
| 385 | 387 | m_dy = 0; |
| r245687 | r245688 | |
| 442 | 444 | void tilemap_t::mark_tile_dirty(tilemap_memory_index memindex) |
| 443 | 445 | { |
| 444 | 446 | // only mark if within range |
| 445 | if (memindex < m_memory_to_logical. | |
| 447 | if (memindex < m_memory_to_logical.size()) | |
| 446 | 448 | { |
| 447 | 449 | // there may be no logical index for a given memory index |
| 448 | 450 | logical_index logindex = m_memory_to_logical[memindex]; |
| r245687 | r245688 | |
| 660 | 662 | void tilemap_t::mappings_update() |
| 661 | 663 | { |
| 662 | 664 | // initialize all the mappings to invalid values |
| 663 | memset(&m_memory_to_logical[0], 0xff, m_memory_to_logical. | |
| 665 | memset(&m_memory_to_logical[0], 0xff, m_memory_to_logical.size() * sizeof(m_memory_to_logical[0])); | |
| 664 | 666 | |
| 665 | 667 | // now iterate over all logical indexes and populate the memory index |
| 666 | for (logical_index logindex = 0; logindex < m_logical_to_memory. | |
| 668 | for (logical_index logindex = 0; logindex < m_logical_to_memory.size(); logindex++) | |
| 667 | 669 | { |
| 668 | 670 | UINT32 logical_col = logindex % m_cols; |
| 669 | 671 | UINT32 logical_row = logindex / m_cols; |
| r245687 | r245688 | |
| 697 | 699 | // flush the dirty status to all tiles |
| 698 | 700 | if (m_all_tiles_dirty || gfx_elements_changed()) |
| 699 | 701 | { |
| 700 | memset(&m_tileflags[0], TILE_FLAG_DIRTY, m_tileflags. | |
| 702 | memset(&m_tileflags[0], TILE_FLAG_DIRTY, m_tileflags.size()); | |
| 701 | 703 | m_all_tiles_dirty = false; |
| 702 | 704 | m_gfx_used = 0; |
| 703 | 705 | } |
| r245687 | r245688 | |
|---|---|---|
| 512 | 512 | int scrolly(int which = 0) const { return (which < m_scrollcols) ? m_colscroll[which] : 0; } |
| 513 | 513 | bitmap_ind16 &pixmap() { pixmap_update(); return m_pixmap; } |
| 514 | 514 | bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; } |
| 515 | UINT8 *tile_flags() { pixmap_update(); return m_tileflags; } | |
| 515 | UINT8 *tile_flags() { pixmap_update(); return &m_tileflags[0]; } | |
| 516 | 516 | tilemap_memory_index memory_index(UINT32 col, UINT32 row) { return m_mapper(col, row, m_cols, m_rows); } |
| 517 | 517 | |
| 518 | 518 | // setters |
| r245687 | r245688 | |
| 639 | 639 | UINT32 m_height; // height of the full tilemap in pixels |
| 640 | 640 | |
| 641 | 641 | // logical <-> memory mappings |
| 642 | tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index | |
| 643 | dynamic_array<logical_index> m_memory_to_logical; // map from memory index to logical index | |
| 644 | dynamic_array<tilemap_memory_index> m_logical_to_memory; // map from logical index to memory index | |
| 642 | tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index | |
| 643 | std::vector<logical_index> m_memory_to_logical; // map from memory index to logical index | |
| 644 | std::vector<tilemap_memory_index> m_logical_to_memory; // map from logical index to memory index | |
| 645 | 645 | |
| 646 | 646 | // callback to interpret video RAM for the tilemap |
| 647 | 647 | tilemap_get_info_delegate m_tile_get_info; // callback to get information about a tile |
| r245687 | r245688 | |
| 659 | 659 | // scroll information |
| 660 | 660 | UINT32 m_scrollrows; // number of independently scrolled rows |
| 661 | 661 | UINT32 m_scrollcols; // number of independently scrolled columns |
| 662 | dynamic_array<INT32> m_rowscroll; // array of rowscroll values | |
| 663 | dynamic_array<INT32> m_colscroll; // array of colscroll values | |
| 662 | std::vector<INT32> m_rowscroll; // array of rowscroll values | |
| 663 | std::vector<INT32> m_colscroll; // array of colscroll values | |
| 664 | 664 | INT32 m_dx; // global horizontal scroll offset |
| 665 | 665 | INT32 m_dx_flipped; // global horizontal scroll offset when flipped |
| 666 | 666 | INT32 m_dy; // global vertical scroll offset |
| r245687 | r245688 | |
| 671 | 671 | |
| 672 | 672 | // transparency mapping |
| 673 | 673 | bitmap_ind8 m_flagsmap; // per-pixel flags |
| 674 | d | |
| 674 | std::vector<UINT8> m_tileflags; // per-tile flags | |
| 675 | 675 | UINT8 m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS]; // mapping of pens to flags |
| 676 | 676 | }; |
| 677 | 677 |
| r245687 | r245688 | |
|---|---|---|
| 35 | 35 | UINT8 m_rerandomize; |
| 36 | 36 | char m_search[40]; |
| 37 | 37 | int m_matchlist[VISIBLE_GAMES_IN_LIST]; |
| 38 | d | |
| 38 | std::vector<const game_driver *> m_driverlist; | |
| 39 | 39 | auto_pointer<driver_enumerator> m_drivlist; |
| 40 | 40 | |
| 41 | 41 | // internal methods |
| r245687 | r245688 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | // getters |
| 61 | 61 | _Type *live() const { return m_spriteram; } |
| 62 | _Type *buffer() { return m_buffered; } | |
| 62 | _Type *buffer() { return &m_buffered[0]; } | |
| 63 | 63 | UINT32 bytes() const { return m_spriteram.bytes(); } |
| 64 | 64 | |
| 65 | 65 | // operations |
| r245687 | r245688 | |
| 67 | 67 | { |
| 68 | 68 | assert(m_spriteram != NULL); |
| 69 | 69 | if (m_spriteram != NULL) |
| 70 | memcpy(m_buffered, m_spriteram + srcoffset, MIN(srclength, m_spriteram.bytes() / sizeof(_Type) - srcoffset) * sizeof(_Type)); | |
| 71 | return m_buffered; | |
| 70 | memcpy(&m_buffered[0], m_spriteram + srcoffset, MIN(srclength, m_spriteram.bytes() / sizeof(_Type) - srcoffset) * sizeof(_Type)); | |
| 71 | return &m_buffered[0]; | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // read/write handlers |
| r245687 | r245688 | |
| 92 | 92 | private: |
| 93 | 93 | // internal state |
| 94 | 94 | required_shared_ptr<_Type> m_spriteram; |
| 95 | d | |
| 95 | std::vector<_Type> m_buffered; | |
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | 98 |
| r245687 | r245688 | |
|---|---|---|
| 256 | 256 | vga.svga_intf.crtc_regcount = 0x19; |
| 257 | 257 | vga.svga_intf.vram_size = 0x100000; |
| 258 | 258 | |
| 259 | vga.memory.resize_and_clear(vga.svga_intf.vram_size); | |
| 259 | vga.memory.resize(vga.svga_intf.vram_size); | |
| 260 | memset(&vga.memory[0], 0, vga.svga_intf.vram_size); | |
| 260 | 261 | save_item(NAME(vga.memory)); |
| 261 | 262 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 262 | 263 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| r245687 | r245688 | |
| 288 | 289 | vga.svga_intf.crtc_regcount = 0x2d; |
| 289 | 290 | vga.svga_intf.vram_size = 0x200000; |
| 290 | 291 | |
| 291 | vga.memory.resize_and_clear(vga.svga_intf.vram_size); | |
| 292 | vga.memory.resize(vga.svga_intf.vram_size); | |
| 293 | memset(&vga.memory[0], 0, vga.svga_intf.vram_size); | |
| 292 | 294 | save_item(NAME(vga.memory)); |
| 293 | 295 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 294 | 296 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| r245687 | r245688 | |
|---|---|---|
| 256 | 256 | |
| 257 | 257 | /* parse input parameters */ |
| 258 | 258 | |
| 259 | dynamic_array<double> o((1<<MAX_RES_PER_NET) * MAX_NETS); | |
| 260 | dynamic_array<double> os((1<<MAX_RES_PER_NET) * MAX_NETS); | |
| 259 | std::vector<double> o((1<<MAX_RES_PER_NET) * MAX_NETS); | |
| 260 | std::vector<double> os((1<<MAX_RES_PER_NET) * MAX_NETS); | |
| 261 | 261 | |
| 262 | 262 | networks_no = 0; |
| 263 | 263 | for (n = 0; n < MAX_NETS; n++) |
| r245687 | r245688 | |
| 693 | 693 | return (int) (v * 255 / vcc + 0.4); |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | void compute_res_net_all(d | |
| 696 | void compute_res_net_all(std::vector<rgb_t> &rgb, const UINT8 *prom, const res_net_decode_info &rdi, const res_net_info &di) | |
| 697 | 697 | { |
| 698 | 698 | UINT8 r,g,b; |
| 699 | 699 | int i,j,k; |
| r245687 | r245688 | |
|---|---|---|
| 157 | 157 | |
| 158 | 158 | /* compute all values */ |
| 159 | 159 | |
| 160 | void compute_res_net_all(d | |
| 160 | void compute_res_net_all(std::vector<rgb_t> &rgb, const UINT8 *prom, const res_net_decode_info &rdi, const res_net_info &di); | |
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | /* legacy interface */ |
| r245687 | r245688 | |
|---|---|---|
| 607 | 607 | |
| 608 | 608 | int fpos = 0; |
| 609 | 609 | for(int track=0; track < 35; track++) { |
| 610 | UINT32 track_data | |
| 610 | std::vector<UINT32> track_data; | |
| 611 | 611 | UINT8 sector_data[256*16]; |
| 612 | int offset = 0; | |
| 613 | 612 | static const unsigned char pascal_block1[4] = { 0x08, 0xa5, 0x0f, 0x29 }; |
| 614 | 613 | static const unsigned char pascal2_block1[4] = { 0xff, 0xa2, 0x00, 0x8e }; |
| 615 | 614 | static const unsigned char dos33_block1[4] = { 0xa2, 0x02, 0x8e, 0x52 }; |
| r245687 | r245688 | |
| 668 | 667 | |
| 669 | 668 | fpos += 256*16; |
| 670 | 669 | for(int i=0; i<51; i++) |
| 671 | raw_w(track_data, | |
| 670 | raw_w(track_data, 10, 0x3fc); | |
| 672 | 671 | for(int i=0; i<16; i++) { |
| 673 | 672 | int sector; |
| 674 | 673 | |
| r245687 | r245688 | |
| 683 | 682 | |
| 684 | 683 | const UINT8 *sdata = sector_data + 256 * sector; |
| 685 | 684 | for(int j=0; j<20; j++) |
| 686 | raw_w(track_data, offset, 10, 0x3fc); | |
| 687 | raw_w(track_data, offset, 8, 0xff); | |
| 688 | raw_w(track_data, offset, 24, 0xd5aa96); | |
| 689 | raw_w(track_data, offset, 16, gcr4_encode(0xfe)); | |
| 690 | raw_w(track_data, offset, 16, gcr4_encode(track)); | |
| 691 | raw_w(track_data, offset, 16, gcr4_encode(i)); | |
| 692 | raw_w(track_data, offset, 16, gcr4_encode(0xfe ^ track ^ i)); | |
| 693 | raw_w(track_data, offset, 24, 0xdeaaeb); | |
| 685 | raw_w(track_data, 10, 0x3fc); | |
| 686 | raw_w(track_data, 8, 0xff); | |
| 687 | raw_w(track_data, 24, 0xd5aa96); | |
| 688 | raw_w(track_data, 16, gcr4_encode(0xfe)); | |
| 689 | raw_w(track_data, 16, gcr4_encode(track)); | |
| 690 | raw_w(track_data, 16, gcr4_encode(i)); | |
| 691 | raw_w(track_data, 16, gcr4_encode(0xfe ^ track ^ i)); | |
| 692 | raw_w(track_data, 24, 0xdeaaeb); | |
| 694 | 693 | |
| 695 | 694 | for(int j=0; j<4; j++) |
| 696 | raw_w(track_data, | |
| 695 | raw_w(track_data, 10, 0x3fc); | |
| 697 | 696 | |
| 698 | raw_w(track_data, offset, 9, 0x01fe); | |
| 699 | raw_w(track_data, offset, 24, 0xd5aaad); | |
| 697 | raw_w(track_data, 9, 0x01fe); | |
| 698 | raw_w(track_data, 24, 0xd5aaad); | |
| 700 | 699 | |
| 701 | 700 | UINT8 pval = 0x00; |
| 702 | 701 | for(int i=0; i<342; i++) { |
| r245687 | r245688 | |
| 714 | 713 | ((sdata[i+0xac] & 0x01) << 5) | |
| 715 | 714 | ((sdata[i+0xac] & 0x02) << 3); |
| 716 | 715 | } |
| 717 | raw_w(track_data, | |
| 716 | raw_w(track_data, 8, translate6[nval ^ pval]); | |
| 718 | 717 | pval = nval; |
| 719 | 718 | } |
| 720 | raw_w(track_data, offset, 8, translate6[pval]); | |
| 721 | raw_w(track_data, offset, 24, 0xdeaaeb); | |
| 719 | raw_w(track_data, 8, translate6[pval]); | |
| 720 | raw_w(track_data, 24, 0xdeaaeb); | |
| 722 | 721 | } |
| 723 | raw_w(track_data, offset, 4, 0xff); | |
| 724 | assert(offset == 51090); | |
| 722 | raw_w(track_data, 4, 0xff); | |
| 723 | assert(track_data.size() == 51090); | |
| 725 | 724 | |
| 726 | generate_track_from_levels(track, 0, track_data, | |
| 725 | generate_track_from_levels(track, 0, track_data, 0, image); | |
| 727 | 726 | } |
| 728 | 727 | return true; |
| 729 | 728 | } |
| r245687 | r245688 | |
|---|---|---|
| 182 | 182 | UINT16 length; |
| 183 | 183 | UINT8 value; |
| 184 | 184 | |
| 185 | floppy_image_read(floppy, buffer, pos, data_size); | |
| 185 | floppy_image_read(floppy, &buffer[0], pos, data_size); | |
| 186 | 186 | |
| 187 | length = pick_integer_le(buffer, 0, 2); | |
| 188 | value = pick_integer_le(buffer, 2, 1); | |
| 187 | length = pick_integer_le(&buffer[0], 0, 2); | |
| 188 | value = pick_integer_le(&buffer[0], 2, 1); | |
| 189 | 189 | |
| 190 | 190 | /* not sure if this is possible */ |
| 191 | 191 | if (length != 512) { |
| r245687 | r245688 | |
|---|---|---|
| 276 | 276 | { |
| 277 | 277 | if ((cassette->flags & CASSETTE_FLAG_DIRTY) && (cassette->flags & CASSETTE_FLAG_SAVEONEXIT)) |
| 278 | 278 | cassette_save(cassette); |
| 279 | for (int i = 0; i < cassette->blocks. | |
| 279 | for (unsigned int i = 0; i < cassette->blocks.size(); i++) | |
| 280 | 280 | global_free(cassette->blocks[i]); |
| 281 | 281 | global_free(cassette); |
| 282 | 282 | } |
| r245687 | r245688 | |
| 377 | 377 | size_t sample_index = sample % SAMPLES_PER_BLOCK; |
| 378 | 378 | |
| 379 | 379 | /* is this block beyond the edge of our waveform? */ |
| 380 | if (sample_blocknum >= cassette->blocks.count()) | |
| 381 | cassette->blocks.resize_keep_and_clear_new(sample_blocknum + 1); | |
| 380 | if (sample_blocknum >= cassette->blocks.size()) { | |
| 381 | size_t osize = cassette->blocks.size(); | |
| 382 | cassette->blocks.resize(sample_blocknum + 1); | |
| 383 | memset(&cassette->blocks[osize], 0, (cassette->blocks.size()-osize)*sizeof(cassette->blocks[0])); | |
| 384 | } | |
| 382 | 385 | |
| 383 | 386 | if (cassette->blocks[sample_blocknum] == NULL) |
| 384 | 387 | cassette->blocks[sample_blocknum] = global_alloc(sample_block); |
| r245687 | r245688 | |
| 386 | 389 | sample_block &block = *cassette->blocks[sample_blocknum]; |
| 387 | 390 | |
| 388 | 391 | /* is this sample access off the current block? */ |
| 389 | if (sample_index >= block.count()) | |
| 390 | block.resize_keep_and_clear_new(SAMPLES_PER_BLOCK); | |
| 392 | if (sample_index >= block.size()) { | |
| 393 | size_t osize = block.size(); | |
| 394 | block.resize(SAMPLES_PER_BLOCK); | |
| 395 | memset(&block[osize], 0, (SAMPLES_PER_BLOCK-osize)*sizeof(block[0])); | |
| 396 | } | |
| 391 | 397 | |
| 392 | 398 | *ptr = &block[sample_index]; |
| 393 | 399 | return CASSETTE_ERROR_SUCCESS; |
| r245687 | r245688 | |
| 857 | 863 | int sample_count; |
| 858 | 864 | dynamic_buffer bytes; |
| 859 | 865 | dynamic_buffer chunk; |
| 860 | d | |
| 866 | std::vector<INT16> samples; | |
| 861 | 867 | int pos = 0; |
| 862 | 868 | UINT64 offset = 0; |
| 863 | 869 | UINT64 size; |
| r245687 | r245688 | |
| 892 | 898 | } |
| 893 | 899 | |
| 894 | 900 | bytes.resize(size); |
| 895 | cassette_image_read(cassette, bytes, 0, size); | |
| 896 | sample_count = args.chunk_sample_calc(bytes, (int)size); | |
| 901 | cassette_image_read(cassette, &bytes[0], 0, size); | |
| 902 | sample_count = args.chunk_sample_calc(&bytes[0], (int)size); | |
| 897 | 903 | |
| 898 | 904 | if (args.header_samples < 0) |
| 899 | 905 | args.header_samples = sample_count; |
| r245687 | r245688 | |
| 911 | 917 | /* if there has to be a header */ |
| 912 | 918 | if (args.header_samples > 0) |
| 913 | 919 | { |
| 914 | length = args.fill_wave(samples | |
| 920 | length = args.fill_wave(&samples[pos], sample_count - pos, CODE_HEADER); | |
| 915 | 921 | if (length < 0) |
| 916 | 922 | { |
| 917 | 923 | err = CASSETTE_ERROR_INVALIDIMAGE; |
| r245687 | r245688 | |
| 923 | 929 | /* convert the file data to samples */ |
| 924 | 930 | while((pos < sample_count) && (offset < size)) |
| 925 | 931 | { |
| 926 | cassette_image_read(cassette, chunk, offset, args.chunk_size); | |
| 932 | cassette_image_read(cassette, &chunk[0], offset, args.chunk_size); | |
| 927 | 933 | offset += args.chunk_size; |
| 928 | 934 | |
| 929 | length = args.fill_wave(samples | |
| 935 | length = args.fill_wave(&samples[pos], sample_count - pos, &chunk[0]); | |
| 930 | 936 | if (length < 0) |
| 931 | 937 | { |
| 932 | 938 | err = CASSETTE_ERROR_INVALIDIMAGE; |
| r245687 | r245688 | |
| 940 | 946 | /* if there has to be a trailer */ |
| 941 | 947 | if (args.trailer_samples > 0) |
| 942 | 948 | { |
| 943 | length = args.fill_wave(samples | |
| 949 | length = args.fill_wave(&samples[pos], sample_count - pos, CODE_TRAILER); | |
| 944 | 950 | if (length < 0) |
| 945 | 951 | { |
| 946 | 952 | err = CASSETTE_ERROR_INVALIDIMAGE; |
| r245687 | r245688 | |
| 951 | 957 | |
| 952 | 958 | /* specify the wave */ |
| 953 | 959 | err = cassette_put_samples(cassette, 0, 0.0, ((double) pos) / args.sample_frequency, |
| 954 | pos, 2, samples, CASSETTE_WAVEFORM_16BIT); | |
| 960 | pos, 2, &samples[0], CASSETTE_WAVEFORM_16BIT); | |
| 955 | 961 | if (err) |
| 956 | 962 | goto done; |
| 957 | 963 |
| r245687 | r245688 | |
|---|---|---|
| 69 | 69 | } |
| 70 | 70 | casserr_t; |
| 71 | 71 | |
| 72 | typedef d | |
| 72 | typedef std::vector<INT32> sample_block; | |
| 73 | 73 | |
| 74 | 74 | struct CassetteOptions |
| 75 | 75 | { |
| r245687 | r245688 | |
| 95 | 95 | int flags; |
| 96 | 96 | UINT32 sample_frequency; |
| 97 | 97 | |
| 98 | d | |
| 98 | std::vector<sample_block *> blocks; | |
| 99 | 99 | size_t sample_count; |
| 100 | 100 | }; |
| 101 | 101 |
| r245687 | r245688 | |
|---|---|---|
| 91 | 91 | |
| 92 | 92 | UINT64 size = io_generic_size(io); |
| 93 | 93 | dynamic_buffer img(size); |
| 94 | io_generic_read(io, img, 0, size); | |
| 94 | io_generic_read(io, &img[0], 0, size); | |
| 95 | 95 | |
| 96 | 96 | astring ccvf = astring((const char *)&img[0], size); |
| 97 | 97 | dynamic_buffer bytes(78720); |
| r245687 | r245688 | |
| 119 | 119 | int total_size = 200000000/f.cell_size; |
| 120 | 120 | |
| 121 | 121 | for(int track=0; track < f.track_count; track++) { |
| 122 | d | |
| 122 | std::vector<UINT32> buffer; | |
| 123 | 123 | int offset = 0; |
| 124 | 124 | |
| 125 | 125 | for (int i=0; i<1920 && pos<size; i++, pos++) { |
| 126 | 126 | for (int bit=0; bit<8; bit++) { |
| 127 | bit_w(buffer, | |
| 127 | bit_w(buffer, BIT(bytes[pos], bit), f.cell_size); | |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (offset < total_size) { |
| 132 | 132 | // pad the remainder of the track with sync |
| 133 | int count = | |
| 133 | int count = total_size-buffer.size(); | |
| 134 | 134 | for (int i=0; i<count;i++) { |
| 135 | bit_w(buffer, | |
| 135 | bit_w(buffer, (track > 0) ? 1 : 0, f.cell_size); | |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | generate_track_from_levels(track, 0, buffer, | |
| 139 | generate_track_from_levels(track, 0, buffer, 0, image); | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | image->set_variant(f.variant); |
| r245687 | r245688 | |
|---|---|---|
| 720 | 720 | UINT8 *track_data; |
| 721 | 721 | void *track_data_v; |
| 722 | 722 | UINT32 max_track_size; |
| 723 | d | |
| 723 | std::vector<int> sector_map; | |
| 724 | 724 | |
| 725 | 725 | sectors = option_resolution_lookup_int(params, PARAM_SECTORS); |
| 726 | 726 | sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); |
| r245687 | r245688 | |
| 747 | 747 | track_data = (UINT8 *) track_data_v; |
| 748 | 748 | |
| 749 | 749 | /* set up sector map */ |
| 750 | sector_map | |
| 750 | memset(§or_map[0], 0xff, sectors*sizeof(int)); | |
| 751 | 751 | |
| 752 | 752 | physical_sector = 0; |
| 753 | 753 | for (logical_sector = 0; logical_sector < sectors; logical_sector++) |
| r245687 | r245688 | |
|---|---|---|
| 317 | 317 | |
| 318 | 318 | int cqm_size = io_generic_size(io); |
| 319 | 319 | dynamic_buffer cqmbuf(cqm_size); |
| 320 | io_generic_read(io, cqmbuf, 0, cqm_size); | |
| 320 | io_generic_read(io, &cqmbuf[0], 0, cqm_size); | |
| 321 | 321 | |
| 322 | 322 | // decode the RLE data |
| 323 | 323 | for (int s = 0, pos = CQM_HEADER_SIZE + comment_size; pos < cqm_size; ) |
| r245687 | r245688 | |
|---|---|---|
| 104 | 104 | d_stream.avail_in = caslen - ( in_ptr - casdata ); |
| 105 | 105 | d_stream.total_in=0; |
| 106 | 106 | |
| 107 | d_stream.next_out = gz_ptr; | |
| 107 | d_stream.next_out = &gz_ptr[0]; | |
| 108 | 108 | d_stream.avail_out = 1; |
| 109 | 109 | d_stream.total_out=0; |
| 110 | 110 | |
| r245687 | r245688 | |
| 124 | 124 | total_size=1; |
| 125 | 125 | do |
| 126 | 126 | { |
| 127 | d_stream.next_out = gz_ptr; | |
| 127 | d_stream.next_out = &gz_ptr[0]; | |
| 128 | 128 | d_stream.avail_out=1; |
| 129 | 129 | err=inflate( &d_stream, Z_SYNC_FLUSH ); |
| 130 | 130 | if (err==Z_OK) |
| r245687 | r245688 | |
| 133 | 133 | if (bsize==0) |
| 134 | 134 | { |
| 135 | 135 | d_stream.avail_out=4; |
| 136 | d_stream.next_out = gz_ptr; | |
| 136 | d_stream.next_out = &gz_ptr[0]; | |
| 137 | 137 | err=inflate( &d_stream, Z_SYNC_FLUSH ); |
| 138 | bsize=get_leuint32(gz_ptr); | |
| 138 | bsize=get_leuint32(&gz_ptr[0]); | |
| 139 | 139 | } |
| 140 | 140 | total_size=total_size+bsize; |
| 141 | 141 | } |
| r245687 | r245688 | |
| 212 | 212 | d_stream.avail_in = mycaslen - ( in_ptr - bytes ); |
| 213 | 213 | d_stream.total_in=0; |
| 214 | 214 | |
| 215 | d_stream.next_out = gz_ptr; | |
| 215 | d_stream.next_out = &gz_ptr[0]; | |
| 216 | 216 | d_stream.avail_out = 1; |
| 217 | 217 | d_stream.total_out=0; |
| 218 | 218 | |
| r245687 | r245688 | |
| 232 | 232 | |
| 233 | 233 | do |
| 234 | 234 | { |
| 235 | d_stream.next_out = gz_ptr; | |
| 235 | d_stream.next_out = &gz_ptr[0]; | |
| 236 | 236 | d_stream.avail_out=1; |
| 237 | 237 | err=inflate( &d_stream, Z_SYNC_FLUSH ); |
| 238 | 238 | if (err==Z_OK) |
| r245687 | r245688 | |
| 241 | 241 | if (bsize==0) |
| 242 | 242 | { |
| 243 | 243 | d_stream.avail_out=4; |
| 244 | d_stream.next_out = gz_ptr; | |
| 244 | d_stream.next_out = &gz_ptr[0]; | |
| 245 | 245 | err=inflate( &d_stream, Z_SYNC_FLUSH ); |
| 246 | bsize=get_leuint32(gz_ptr); | |
| 246 | bsize=get_leuint32(&gz_ptr[0]); | |
| 247 | 247 | } |
| 248 | 248 | for (i=0;i<bsize;i++) |
| 249 | 249 | { |
| r245687 | r245688 | |
|---|---|---|
| 199 | 199 | dynamic_buffer img; |
| 200 | 200 | |
| 201 | 201 | if(size == (UINT32)f.sector_count*f.sector_base_size) { |
| 202 | img.resize_and_clear(size + f.sector_count, ERROR_00); | |
| 202 | img.resize(size + f.sector_count); | |
| 203 | memset(&img[0], ERROR_00, size + f.sector_count); | |
| 203 | 204 | } |
| 204 | 205 | else { |
| 205 | 206 | img.resize(size); |
| 206 | 207 | } |
| 207 | 208 | |
| 208 | io_generic_read(io, img, 0, size); | |
| 209 | io_generic_read(io, &img[0], 0, size); | |
| 209 | 210 | |
| 210 | 211 | int track_offset = 0, error_offset = f.sector_count*f.sector_base_size; |
| 211 | 212 | |
| r245687 | r245688 | |
| 230 | 231 | |
| 231 | 232 | desc_s sectors[40]; |
| 232 | 233 | |
| 233 | build_sector_description(f, img, track_offset, error_offset, sectors, sector_count); | |
| 234 | build_sector_description(f, &img[0], track_offset, error_offset, sectors, sector_count); | |
| 234 | 235 | generate_track(desc, physical_track, head, sectors, sector_count, total_size, image); |
| 235 | 236 | |
| 236 | 237 | track_offset += track_size; |
| r245687 | r245688 | |
|---|---|---|
| 90 | 90 | data.resize(tsize); |
| 91 | 91 | |
| 92 | 92 | pos += 10; // skip the header, we already read it |
| 93 | io_generic_read(io, data, pos, tsize); | |
| 93 | io_generic_read(io, &data[0], pos, tsize); | |
| 94 | 94 | pos += tsize; // for next time we read, increment to the beginning of next header |
| 95 | 95 | |
| 96 | 96 | int index_time = 0; // what point the last index happened |
| r245687 | r245688 | |
| 149 | 149 | if(!index_time) |
| 150 | 150 | index_time = total_time; |
| 151 | 151 | |
| 152 | image->set_track_size(track, head, tsize); | |
| 152 | std::vector<UINT32> &buf = image->get_buffer(track, head); | |
| 153 | buf.resize(tsize); | |
| 153 | 154 | |
| 154 | 155 | int cur_time = 0; |
| 155 | 156 | int prev_time = 0; |
| r245687 | r245688 | |
| 162 | 163 | index_count = 0; |
| 163 | 164 | //index_polarity = 0; |
| 164 | 165 | UINT32 mg = floppy_image::MG_A; |
| 165 | UINT32 *buf = image->get_buffer(track, head); | |
| 166 | 166 | int tpos = 0; |
| 167 | 167 | buf[tpos++] = mg; |
| 168 | 168 | for(int i=0; i<tsize; i++) { |
| r245687 | r245688 | |
| 218 | 218 | fprintf(stderr,"\n"); |
| 219 | 219 | #endif |
| 220 | 220 | index_count = 0; |
| 221 | | |
| 221 | buf.resize(tpos); | |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | return true; |
| r245687 | r245688 | |
|---|---|---|
| 121 | 121 | { |
| 122 | 122 | for (int head = 0; head < heads; head++) |
| 123 | 123 | { |
| 124 | dynamic_array<UINT8> track_data(track_size); | |
| 125 | dynamic_array<UINT32> raw_track_data(raw_track_size); | |
| 124 | std::vector<UINT8> track_data(track_size); | |
| 125 | std::vector<UINT32> raw_track_data; | |
| 126 | 126 | int iam_location = -1; |
| 127 | 127 | int idam_location[64]; |
| 128 | 128 | int dam_location[64]; |
| 129 | int tpos = 0; | |
| 130 | 129 | |
| 131 | 130 | // Read track |
| 132 | io_generic_read(io, track_data, header_size + ( heads * track + head ) * track_size, track_size); | |
| 131 | io_generic_read(io, &track_data[0], header_size + ( heads * track + head ) * track_size, track_size); | |
| 133 | 132 | |
| 134 | 133 | for (int i = 0; i < 64; i++) |
| 135 | 134 | { |
| r245687 | r245688 | |
| 179 | 178 | if (offset == iam_location) |
| 180 | 179 | { |
| 181 | 180 | // Write IAM |
| 182 | raw_w(raw_track_data, tpos, 16, 0x5224); | |
| 183 | raw_w(raw_track_data, tpos, 16, 0x5224); | |
| 184 | raw_w(raw_track_data, tpos, 16, 0x5224); | |
| 181 | raw_w(raw_track_data, 16, 0x5224); | |
| 182 | raw_w(raw_track_data, 16, 0x5224); | |
| 183 | raw_w(raw_track_data, 16, 0x5224); | |
| 185 | 184 | offset += 3; |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | if (offset == idam_location[idam_index]) |
| 189 | 188 | { |
| 190 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 191 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 192 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 189 | raw_w(raw_track_data, 16, 0x4489); | |
| 190 | raw_w(raw_track_data, 16, 0x4489); | |
| 191 | raw_w(raw_track_data, 16, 0x4489); | |
| 193 | 192 | idam_index += 1; |
| 194 | 193 | offset += 3; |
| 195 | 194 | } |
| 196 | 195 | |
| 197 | 196 | if (offset == dam_location[dam_index]) |
| 198 | 197 | { |
| 199 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 200 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 201 | raw_w(raw_track_data, tpos, 16, 0x4489); | |
| 198 | raw_w(raw_track_data, 16, 0x4489); | |
| 199 | raw_w(raw_track_data, 16, 0x4489); | |
| 200 | raw_w(raw_track_data, 16, 0x4489); | |
| 202 | 201 | dam_index += 1; |
| 203 | 202 | offset += 3; |
| 204 | 203 | } |
| 205 | 204 | |
| 206 | mfm_w(raw_track_data, | |
| 205 | mfm_w(raw_track_data, 8, track_data[offset]); | |
| 207 | 206 | } |
| 208 | 207 | |
| 209 | generate_track_from_levels(track, head, raw_track_data, | |
| 208 | generate_track_from_levels(track, head, raw_track_data, 0, image); | |
| 210 | 209 | } |
| 211 | 210 | } |
| 212 | 211 |
| r245687 | r245688 | |
|---|---|---|
| 489 | 489 | alloc_buf.resize(sector_length); |
| 490 | 490 | |
| 491 | 491 | /* read the sector (we need to do this even when writing */ |
| 492 | err = read_sector(floppy, head, track, sector, alloc_buf, sector_length); | |
| 492 | err = read_sector(floppy, head, track, sector, &alloc_buf[0], sector_length); | |
| 493 | 493 | if (err) |
| 494 | 494 | goto done; |
| 495 | 495 | |
| r245687 | r245688 | |
| 497 | 497 | |
| 498 | 498 | if (writing) |
| 499 | 499 | { |
| 500 | memcpy(alloc_buf | |
| 500 | memcpy(&alloc_buf[offset], buffer_ptr, this_buffer_len); | |
| 501 | 501 | |
| 502 | err = write_sector(floppy, head, track, sector, alloc_buf, sector_length, ddam); | |
| 502 | err = write_sector(floppy, head, track, sector, &alloc_buf[0], sector_length, ddam); | |
| 503 | 503 | if (err) |
| 504 | 504 | goto done; |
| 505 | 505 | } |
| 506 | 506 | else |
| 507 | 507 | { |
| 508 | memcpy(buffer_ptr, alloc_buf | |
| 508 | memcpy(buffer_ptr, &alloc_buf[offset], this_buffer_len); | |
| 509 | 509 | } |
| 510 | 510 | offset += this_buffer_len; |
| 511 | 511 | offset %= sector_length; |
| r245687 | r245688 | |
| 968 | 968 | |
| 969 | 969 | while(maxt >= 0) { |
| 970 | 970 | for(int i=0; i<=maxh; i++) |
| 971 | if(track_array[maxt][i]. | |
| 971 | if(!track_array[maxt][i].cell_data.empty()) | |
| 972 | 972 | goto track_done; |
| 973 | 973 | maxt--; |
| 974 | 974 | } |
| r245687 | r245688 | |
| 976 | 976 | if(maxt >= 0) |
| 977 | 977 | while(maxh >= 0) { |
| 978 | 978 | for(int i=0; i<=maxt; i++) |
| 979 | if(track_array[i][maxh]. | |
| 979 | if(!track_array[i][maxh].cell_data.empty()) | |
| 980 | 980 | goto head_done; |
| 981 | 981 | maxh--; |
| 982 | 982 | } |
| r245687 | r245688 | |
| 990 | 990 | int mask = 0; |
| 991 | 991 | for(int i=0; i<=(tracks-1)*4; i++) |
| 992 | 992 | for(int j=0; j<heads; j++) |
| 993 | if(track_array[i][j]. | |
| 993 | if(!track_array[i][j].cell_data.empty()) | |
| 994 | 994 | mask |= 1 << (i & 3); |
| 995 | 995 | if(mask & 0xa) |
| 996 | 996 | return 2; |
| r245687 | r245688 | |
| 999 | 999 | return 0; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | void floppy_image::ensure_alloc(int track, int head) | |
| 1003 | { | |
| 1004 | track_info &tr = track_array[track][head]; | |
| 1005 | if(tr.track_size > tr.cell_data.count()) | |
| 1006 | tr.cell_data.resize_keep_and_clear_new(tr.track_size); | |
| 1007 | } | |
| 1008 | ||
| 1009 | 1002 | const char *floppy_image::get_variant_name(UINT32 form_factor, UINT32 variant) |
| 1010 | 1003 | { |
| 1011 | 1004 | switch(variant) { |
| r245687 | r245688 | |
| 1145 | 1138 | } |
| 1146 | 1139 | } |
| 1147 | 1140 | |
| 1148 | bool floppy_image_format_t::bit_r(const UINT32 | |
| 1141 | bool floppy_image_format_t::bit_r(const std::vector<UINT32> &buffer, int offset) | |
| 1149 | 1142 | { |
| 1150 | 1143 | return (buffer[offset] & floppy_image::MG_MASK) == MG_1; |
| 1151 | 1144 | } |
| 1152 | 1145 | |
| 1153 | UINT32 floppy_image_format_t::bitn_r(const UINT32 | |
| 1146 | UINT32 floppy_image_format_t::bitn_r(const std::vector<UINT32> &buffer, int offset, int count) | |
| 1154 | 1147 | { |
| 1155 | 1148 | UINT32 r = 0; |
| 1156 | 1149 | for(int i=0; i<count; i++) |
| r245687 | r245688 | |
| 1158 | 1151 | return r; |
| 1159 | 1152 | } |
| 1160 | 1153 | |
| 1161 | void floppy_image_format_t::bit_w(UINT32 | |
| 1154 | void floppy_image_format_t::bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size, int offset) | |
| 1162 | 1155 | { |
| 1163 | 1156 | buffer[offset] = (val ? MG_1 : MG_0) | size; |
| 1164 | 1157 | } |
| 1165 | 1158 | |
| 1166 | void floppy_image_format_t:: | |
| 1159 | void floppy_image_format_t::bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size) | |
| 1167 | 1160 | { |
| 1161 | buffer.push_back((val ? MG_1 : MG_0) | size); | |
| 1162 | } | |
| 1163 | ||
| 1164 | void floppy_image_format_t::raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) | |
| 1165 | { | |
| 1168 | 1166 | for(int i=n-1; i>=0; i--) |
| 1169 | bit_w(buffer, | |
| 1167 | bit_w(buffer, (val >> i) & 1, size); | |
| 1170 | 1168 | } |
| 1171 | 1169 | |
| 1172 | void floppy_image_format_t:: | |
| 1170 | void floppy_image_format_t::raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) | |
| 1173 | 1171 | { |
| 1172 | for(int i=n-1; i>=0; i--) | |
| 1173 | bit_w(buffer, (val >> i) & 1, size, offset); | |
| 1174 | } | |
| 1175 | ||
| 1176 | void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) | |
| 1177 | { | |
| 1178 | int prec = buffer.empty() ? 0 : bit_r(buffer, buffer.size()-1); | |
| 1179 | for(int i=n-1; i>=0; i--) { | |
| 1180 | int bit = (val >> i) & 1; | |
| 1181 | bit_w(buffer, !(prec || bit), size); | |
| 1182 | bit_w(buffer, bit, size); | |
| 1183 | prec = bit; | |
| 1184 | } | |
| 1185 | } | |
| 1186 | ||
| 1187 | void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) | |
| 1188 | { | |
| 1174 | 1189 | int prec = offset ? bit_r(buffer, offset-1) : 0; |
| 1175 | 1190 | for(int i=n-1; i>=0; i--) { |
| 1176 | 1191 | int bit = (val >> i) & 1; |
| r245687 | r245688 | |
| 1180 | 1195 | } |
| 1181 | 1196 | } |
| 1182 | 1197 | |
| 1183 | void floppy_image_format_t::fm_w(UINT32 | |
| 1198 | void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) | |
| 1184 | 1199 | { |
| 1185 | 1200 | for(int i=n-1; i>=0; i--) { |
| 1186 | 1201 | int bit = (val >> i) & 1; |
| 1187 | bit_w(buffer, offset++, true); | |
| 1188 | bit_w(buffer, offset++, bit, size); | |
| 1202 | bit_w(buffer, true, size); | |
| 1203 | bit_w(buffer, bit, size); | |
| 1189 | 1204 | } |
| 1190 | 1205 | } |
| 1191 | 1206 | |
| 1192 | void floppy_image_format_t:: | |
| 1207 | void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) | |
| 1193 | 1208 | { |
| 1194 | int prec = offset ? bit_r(buffer, offset-1) : 0; | |
| 1209 | for(int i=n-1; i>=0; i--) { | |
| 1210 | int bit = (val >> i) & 1; | |
| 1211 | bit_w(buffer, true, size, offset++); | |
| 1212 | bit_w(buffer, bit, size, offset++); | |
| 1213 | } | |
| 1214 | } | |
| 1215 | ||
| 1216 | void floppy_image_format_t::mfm_half_w(std::vector<UINT32> &buffer, int start_bit, UINT32 val, UINT32 size) | |
| 1217 | { | |
| 1218 | int prec = buffer.empty() ? 0 : bit_r(buffer, buffer.size()-1); | |
| 1195 | 1219 | for(int i=start_bit; i>=0; i-=2) { |
| 1196 | 1220 | int bit = (val >> i) & 1; |
| 1197 | bit_w(buffer, offset++, !(prec || bit), size); | |
| 1198 | bit_w(buffer, offset++, bit, size); | |
| 1221 | bit_w(buffer, !(prec || bit), size); | |
| 1222 | bit_w(buffer, bit, size); | |
| 1199 | 1223 | prec = bit; |
| 1200 | 1224 | } |
| 1201 | 1225 | } |
| 1202 | 1226 | |
| 1203 | void floppy_image_format_t::gcr5_w(UINT32 | |
| 1227 | void floppy_image_format_t::gcr5_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) | |
| 1204 | 1228 | { |
| 1205 | 1229 | UINT32 e0 = gcr5fw_tb[val >> 4]; |
| 1206 | 1230 | UINT32 e1 = gcr5fw_tb[val & 0x0f]; |
| 1207 | raw_w(buffer, offset, 5, e0, size); | |
| 1208 | raw_w(buffer, offset, 5, e1, size); | |
| 1231 | raw_w(buffer, 5, e0, size); | |
| 1232 | raw_w(buffer, 5, e1, size); | |
| 1209 | 1233 | } |
| 1210 | 1234 | |
| 1211 | void floppy_image_format_t::_ | |
| 1235 | void floppy_image_format_t::gcr5_w(std::vector<UINT32> &buffer, int start_bit, int n, UINT32 val, UINT32 size) | |
| 1212 | 1236 | { |
| 1213 | bit_w(buffer, offset++, 0); | |
| 1237 | UINT32 e0 = gcr5fw_tb[val >> 4]; | |
| 1238 | UINT32 e1 = gcr5fw_tb[val & 0x0f]; | |
| 1239 | raw_w(buffer, 5, e0, size, start_bit); | |
| 1240 | raw_w(buffer, 5, e1, size, start_bit+5); | |
| 1241 | } | |
| 1242 | ||
| 1243 | void floppy_image_format_t::_8n1_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) | |
| 1244 | { | |
| 1245 | bit_w(buffer, 0, size); | |
| 1214 | 1246 | for(int i=n-1; i>=0; i--) { |
| 1215 | 1247 | int bit = (val >> i) & 1; |
| 1216 | bit_w(buffer, | |
| 1248 | bit_w(buffer, bit, size); | |
| 1217 | 1249 | } |
| 1218 | bit_w(buffer, | |
| 1250 | bit_w(buffer, 1, size); | |
| 1219 | 1251 | } |
| 1220 | 1252 | |
| 1221 | void floppy_image_format_t::fixup_crc_amiga(UINT32 | |
| 1253 | void floppy_image_format_t::fixup_crc_amiga(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1222 | 1254 | { |
| 1223 | 1255 | UINT16 res = 0; |
| 1224 | 1256 | int size = crc->end - crc->start; |
| 1225 | 1257 | for(int i=1; i<size; i+=2) |
| 1226 | 1258 | if(bit_r(buffer, crc->start + i)) |
| 1227 | 1259 | res = res ^ (0x8000 >> ((i >> 1) & 15)); |
| 1228 | int offset = crc->write; | |
| 1229 | mfm_w(buffer, offset, 16, 0); | |
| 1230 | mfm_w(buffer, offset, 16, res); | |
| 1260 | mfm_w(buffer, 16, 0, 1000, crc->write); | |
| 1261 | mfm_w(buffer, 16, res, 1000, crc->write+16); | |
| 1231 | 1262 | } |
| 1232 | 1263 | |
| 1233 | void floppy_image_format_t::fixup_crc_cbm(UINT32 | |
| 1264 | void floppy_image_format_t::fixup_crc_cbm(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1234 | 1265 | { |
| 1235 | 1266 | UINT8 v = 0; |
| 1236 | 1267 | for(int o = crc->start; o < crc->end; o+=10) { |
| 1237 | 1268 | v = v ^ (gcr5bw_tb[bitn_r(buffer, o, 5)] << 4); |
| 1238 | 1269 | v = v ^ gcr5bw_tb[bitn_r(buffer, o+5, 5)]; |
| 1239 | 1270 | } |
| 1240 | int offset = crc->write; | |
| 1241 | gcr5_w(buffer, offset, 10, v); | |
| 1271 | gcr5_w(buffer, 10, v, 1000, crc->write); | |
| 1242 | 1272 | } |
| 1243 | 1273 | |
| 1244 | UINT16 floppy_image_format_t::calc_crc_ccitt(const UINT32 | |
| 1274 | UINT16 floppy_image_format_t::calc_crc_ccitt(const std::vector<UINT32> &buffer, int start, int end) | |
| 1245 | 1275 | { |
| 1246 | 1276 | UINT32 res = 0xffff; |
| 1247 | 1277 | int size = end - start; |
| r245687 | r245688 | |
| 1255 | 1285 | return res; |
| 1256 | 1286 | } |
| 1257 | 1287 | |
| 1258 | void floppy_image_format_t::fixup_crc_ccitt(UINT32 | |
| 1288 | void floppy_image_format_t::fixup_crc_ccitt(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1259 | 1289 | { |
| 1260 | int offset = crc->write; | |
| 1261 | mfm_w(buffer, offset, 16, calc_crc_ccitt(buffer, crc->start, crc->end)); | |
| 1290 | mfm_w(buffer, 16, calc_crc_ccitt(buffer, crc->start, crc->end), 1000, crc->write); | |
| 1262 | 1291 | } |
| 1263 | 1292 | |
| 1264 | void floppy_image_format_t::fixup_crc_ccitt_fm(UINT32 | |
| 1293 | void floppy_image_format_t::fixup_crc_ccitt_fm(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1265 | 1294 | { |
| 1266 | int offset = crc->write; | |
| 1267 | fm_w(buffer, offset, 16, calc_crc_ccitt(buffer, crc->start, crc->end)); | |
| 1295 | fm_w(buffer, 16, calc_crc_ccitt(buffer, crc->start, crc->end), 1000, crc->write); | |
| 1268 | 1296 | } |
| 1269 | 1297 | |
| 1270 | void floppy_image_format_t::fixup_crc_machead(UINT32 | |
| 1298 | void floppy_image_format_t::fixup_crc_machead(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1271 | 1299 | { |
| 1272 | 1300 | UINT8 v = 0; |
| 1273 | 1301 | for(int o = crc->start; o < crc->end; o+=8) |
| 1274 | 1302 | v = v ^ gcr6bw_tb[bitn_r(buffer, o, 8)]; |
| 1275 | int offset = crc->write; | |
| 1276 | raw_w(buffer, offset, 8, gcr6fw_tb[v]); | |
| 1303 | raw_w(buffer, 8, gcr6fw_tb[v], 1000, crc->write); | |
| 1277 | 1304 | } |
| 1278 | 1305 | |
| 1279 | void floppy_image_format_t::fixup_crc_fcs(UINT32 | |
| 1306 | void floppy_image_format_t::fixup_crc_fcs(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1280 | 1307 | { |
| 1281 | 1308 | // TODO |
| 1282 | 1309 | } |
| 1283 | 1310 | |
| 1284 | void floppy_image_format_t::fixup_crc_victor_header(UINT32 | |
| 1311 | void floppy_image_format_t::fixup_crc_victor_header(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1285 | 1312 | { |
| 1286 | 1313 | UINT8 v = 0; |
| 1287 | for(int o = crc->start; o < crc->end; o+=10) | |
| 1314 | for(int o = crc->start; o < crc->end; o+=10) | |
| 1288 | 1315 | v += ((gcr5bw_tb[bitn_r(buffer, o, 5)] << 4) | gcr5bw_tb[bitn_r(buffer, o+5, 5)]); |
| 1289 | } | |
| 1290 | int offset = crc->write; | |
| 1291 | gcr5_w(buffer, offset, 10, v); | |
| 1316 | gcr5_w(buffer, 10, v, 1000, crc->write); | |
| 1292 | 1317 | } |
| 1293 | 1318 | |
| 1294 | void floppy_image_format_t::fixup_crc_victor_data(UINT32 | |
| 1319 | void floppy_image_format_t::fixup_crc_victor_data(std::vector<UINT32> &buffer, const gen_crc_info *crc) | |
| 1295 | 1320 | { |
| 1296 | 1321 | UINT16 v = 0; |
| 1297 | for(int o = crc->start; o < crc->end; o+=10) | |
| 1322 | for(int o = crc->start; o < crc->end; o+=10) | |
| 1298 | 1323 | v += ((gcr5bw_tb[bitn_r(buffer, o, 5)] << 4) | gcr5bw_tb[bitn_r(buffer, o+5, 5)]); |
| 1299 | } | |
| 1300 | int offset = crc->write; | |
| 1301 | gcr5_w(buffer, offset, 10, v & 0xff); | |
| 1302 | gcr5_w(buffer, offset, 10, v >> 8); | |
| 1324 | gcr5_w(buffer, 10, v & 0xff, 1000, crc->write); | |
| 1325 | gcr5_w(buffer, 10, v >> 8, 1000, crc->write+10); | |
| 1303 | 1326 | } |
| 1304 | 1327 | |
| 1305 | void floppy_image_format_t::fixup_crcs(UINT32 | |
| 1328 | void floppy_image_format_t::fixup_crcs(std::vector<UINT32> &buffer, gen_crc_info *crcs) | |
| 1306 | 1329 | { |
| 1307 | 1330 | for(int i=0; i != MAX_CRC_COUNT; i++) |
| 1308 | 1331 | if(crcs[i].write != -1) { |
| r245687 | r245688 | |
| 1381 | 1404 | |
| 1382 | 1405 | void floppy_image_format_t::generate_track(const desc_e *desc, int track, int head, const desc_s *sect, int sect_count, int track_size, floppy_image *image) |
| 1383 | 1406 | { |
| 1384 | d | |
| 1407 | std::vector<UINT32> buffer; | |
| 1385 | 1408 | |
| 1386 | 1409 | gen_crc_info crcs[MAX_CRC_COUNT]; |
| 1387 | 1410 | collect_crcs(desc, crcs); |
| 1388 | 1411 | |
| 1389 | int offset = 0; | |
| 1390 | 1412 | int index = 0; |
| 1391 | 1413 | int sector_loop_start = 0; |
| 1392 | 1414 | int sector_idx = 0; |
| r245687 | r245688 | |
| 1396 | 1418 | int sector_skew = 0; |
| 1397 | 1419 | |
| 1398 | 1420 | while(desc[index].type != END) { |
| 1399 | // printf("%d.%d.%d (%d) - %d %d\n", desc[index].type, desc[index].p1, desc[index].p2, index, offset, offset/8); | |
| 1400 | 1421 | switch(desc[index].type) { |
| 1401 | 1422 | case FM: |
| 1402 | 1423 | for(int i=0; i<desc[index].p2; i++) |
| 1403 | fm_w(buffer, | |
| 1424 | fm_w(buffer, 8, desc[index].p1); | |
| 1404 | 1425 | break; |
| 1405 | 1426 | |
| 1406 | 1427 | case MFM: |
| 1407 | 1428 | for(int i=0; i<desc[index].p2; i++) |
| 1408 | mfm_w(buffer, | |
| 1429 | mfm_w(buffer, 8, desc[index].p1); | |
| 1409 | 1430 | break; |
| 1410 | 1431 | |
| 1411 | 1432 | case MFMBITS: |
| 1412 | mfm_w(buffer, | |
| 1433 | mfm_w(buffer, desc[index].p2, desc[index].p1); | |
| 1413 | 1434 | break; |
| 1414 | 1435 | |
| 1415 | 1436 | case GCR5: |
| 1416 | 1437 | for(int i=0; i<desc[index].p2; i++) |
| 1417 | gcr5_w(buffer, | |
| 1438 | gcr5_w(buffer, 10, desc[index].p1); | |
| 1418 | 1439 | break; |
| 1419 | 1440 | |
| 1420 | 1441 | case _8N1: |
| 1421 | 1442 | for(int i=0; i<desc[index].p2; i++) |
| 1422 | _8n1_w(buffer, | |
| 1443 | _8n1_w(buffer, 8, desc[index].p1); | |
| 1423 | 1444 | break; |
| 1424 | 1445 | |
| 1425 | 1446 | case RAW: |
| 1426 | 1447 | for(int i=0; i<desc[index].p2; i++) |
| 1427 | raw_w(buffer, | |
| 1448 | raw_w(buffer, 16, desc[index].p1); | |
| 1428 | 1449 | break; |
| 1429 | 1450 | |
| 1430 | 1451 | case RAWBYTE: |
| 1431 | 1452 | for(int i=0; i<desc[index].p2; i++) |
| 1432 | raw_w(buffer, | |
| 1453 | raw_w(buffer, 8, desc[index].p1); | |
| 1433 | 1454 | break; |
| 1434 | 1455 | |
| 1435 | 1456 | case RAWBITS: |
| 1436 | raw_w(buffer, | |
| 1457 | raw_w(buffer, desc[index].p2, desc[index].p1); | |
| 1437 | 1458 | break; |
| 1438 | 1459 | |
| 1439 | 1460 | case SYNC_GCR5: |
| 1440 | 1461 | for(int i=0; i<desc[index].p1; i++) |
| 1441 | raw_w(buffer, | |
| 1462 | raw_w(buffer, 10, 0xffff); | |
| 1442 | 1463 | break; |
| 1443 | 1464 | |
| 1444 | 1465 | case TRACK_ID: |
| 1445 | mfm_w(buffer, | |
| 1466 | mfm_w(buffer, 8, track); | |
| 1446 | 1467 | break; |
| 1447 | 1468 | |
| 1448 | 1469 | case TRACK_ID_FM: |
| 1449 | fm_w(buffer, | |
| 1470 | fm_w(buffer, 8, track); | |
| 1450 | 1471 | break; |
| 1451 | 1472 | |
| 1452 | 1473 | case TRACK_ID_DOS2_GCR5: |
| 1453 | gcr5_w(buffer, | |
| 1474 | gcr5_w(buffer, 10, 1 + (track >> 1) + (head * 35)); | |
| 1454 | 1475 | break; |
| 1455 | 1476 | |
| 1456 | 1477 | case TRACK_ID_DOS25_GCR5: |
| 1457 | gcr5_w(buffer, | |
| 1478 | gcr5_w(buffer, 10, 1 + track + (head * 77)); | |
| 1458 | 1479 | break; |
| 1459 | 1480 | |
| 1460 | 1481 | case TRACK_ID_GCR6: |
| 1461 | raw_w(buffer, | |
| 1482 | raw_w(buffer, 8, gcr6fw_tb[track & 0x3f]); | |
| 1462 | 1483 | break; |
| 1463 | 1484 | |
| 1464 | 1485 | case TRACK_ID_8N1: |
| 1465 | _8n1_w(buffer, | |
| 1486 | _8n1_w(buffer, 8, track); | |
| 1466 | 1487 | break; |
| 1467 | 1488 | |
| 1468 | 1489 | case TRACK_ID_VICTOR_GCR5: |
| 1469 | gcr5_w(buffer, | |
| 1490 | gcr5_w(buffer, 10, track + (head * 0x80)); | |
| 1470 | 1491 | break; |
| 1471 | 1492 | |
| 1472 | 1493 | case HEAD_ID: |
| 1473 | mfm_w(buffer, | |
| 1494 | mfm_w(buffer, 8, head); | |
| 1474 | 1495 | break; |
| 1475 | 1496 | |
| 1476 | 1497 | case HEAD_ID_FM: |
| 1477 | fm_w(buffer, | |
| 1498 | fm_w(buffer, 8, head); | |
| 1478 | 1499 | break; |
| 1479 | 1500 | |
| 1480 | 1501 | case HEAD_ID_SWAP: |
| 1481 | mfm_w(buffer, | |
| 1502 | mfm_w(buffer, 8, !head); | |
| 1482 | 1503 | break; |
| 1483 | 1504 | |
| 1484 | 1505 | case TRACK_HEAD_ID_GCR6: |
| 1485 | raw_w(buffer, | |
| 1506 | raw_w(buffer, 8, gcr6fw_tb[(track & 0x40 ? 1 : 0) | (head ? 0x20 : 0)]); | |
| 1486 | 1507 | break; |
| 1487 | 1508 | |
| 1488 | 1509 | case SECTOR_ID: |
| 1489 | mfm_w(buffer, | |
| 1510 | mfm_w(buffer, 8, sect[sector_idx].sector_id); | |
| 1490 | 1511 | break; |
| 1491 | 1512 | |
| 1492 | 1513 | case SECTOR_ID_FM: |
| 1493 | fm_w(buffer, | |
| 1514 | fm_w(buffer, 8, sect[sector_idx].sector_id); | |
| 1494 | 1515 | break; |
| 1495 | 1516 | |
| 1496 | 1517 | case SECTOR_ID_GCR5: |
| 1497 | gcr5_w(buffer, | |
| 1518 | gcr5_w(buffer, 10, sect[sector_idx].sector_id); | |
| 1498 | 1519 | break; |
| 1499 | 1520 | |
| 1500 | 1521 | case SECTOR_ID_GCR6: |
| 1501 | raw_w(buffer, | |
| 1522 | raw_w(buffer, 8, gcr6fw_tb[sect[sector_idx].sector_id]); | |
| 1502 | 1523 | break; |
| 1503 | 1524 | |
| 1504 | 1525 | case SECTOR_ID_8N1: |
| 1505 | _8n1_w(buffer, | |
| 1526 | _8n1_w(buffer, 8, sect[sector_idx].sector_id); | |
| 1506 | 1527 | break; |
| 1507 | 1528 | |
| 1508 | 1529 | case SIZE_ID: { |
| 1509 | 1530 | int size = sect[sector_idx].size; |
| 1510 | 1531 | int id; |
| 1511 | 1532 | for(id = 0; size > 128; size >>=1, id++); |
| 1512 | mfm_w(buffer, | |
| 1533 | mfm_w(buffer, 8, id); | |
| 1513 | 1534 | break; |
| 1514 | 1535 | } |
| 1515 | 1536 | |
| r245687 | r245688 | |
| 1517 | 1538 | int size = sect[sector_idx].size; |
| 1518 | 1539 | int id; |
| 1519 | 1540 | for(id = 0; size > 128; size >>=1, id++); |
| 1520 | fm_w(buffer, | |
| 1541 | fm_w(buffer, 8, id); | |
| 1521 | 1542 | break; |
| 1522 | 1543 | } |
| 1523 | 1544 | |
| 1524 | 1545 | case SECTOR_INFO_GCR6: |
| 1525 | raw_w(buffer, | |
| 1546 | raw_w(buffer, 8, gcr6fw_tb[sect[sector_idx].sector_info]); | |
| 1526 | 1547 | break; |
| 1527 | 1548 | |
| 1528 | 1549 | case OFFSET_ID_O: |
| 1529 | mfm_half_w(buffer, | |
| 1550 | mfm_half_w(buffer, 7, track*2+head); | |
| 1530 | 1551 | break; |
| 1531 | 1552 | |
| 1532 | 1553 | case OFFSET_ID_E: |
| 1533 | mfm_half_w(buffer, | |
| 1554 | mfm_half_w(buffer, 6, track*2+head); | |
| 1534 | 1555 | break; |
| 1535 | 1556 | |
| 1536 | 1557 | case SECTOR_ID_O: |
| 1537 | mfm_half_w(buffer, | |
| 1558 | mfm_half_w(buffer, 7, sector_idx); | |
| 1538 | 1559 | break; |
| 1539 | 1560 | |
| 1540 | 1561 | case SECTOR_ID_E: |
| 1541 | mfm_half_w(buffer, | |
| 1562 | mfm_half_w(buffer, 6, sector_idx); | |
| 1542 | 1563 | break; |
| 1543 | 1564 | |
| 1544 | 1565 | case REMAIN_O: |
| 1545 | mfm_half_w(buffer, | |
| 1566 | mfm_half_w(buffer, 7, desc[index].p1 - sector_idx); | |
| 1546 | 1567 | break; |
| 1547 | 1568 | |
| 1548 | 1569 | case REMAIN_E: |
| 1549 | mfm_half_w(buffer, | |
| 1570 | mfm_half_w(buffer, 6, desc[index].p1 - sector_idx); | |
| 1550 | 1571 | break; |
| 1551 | 1572 | |
| 1552 | 1573 | case SECTOR_LOOP_START: |
| r245687 | r245688 | |
| 1580 | 1601 | case CRC_FCS_START: |
| 1581 | 1602 | case CRC_VICTOR_HDR_START: |
| 1582 | 1603 | case CRC_VICTOR_DATA_START: |
| 1583 | crcs[desc[index].p1].start = | |
| 1604 | crcs[desc[index].p1].start = buffer.size(); | |
| 1584 | 1605 | break; |
| 1585 | 1606 | |
| 1586 | 1607 | case CRC_END: |
| 1587 | crcs[desc[index].p1].end = | |
| 1608 | crcs[desc[index].p1].end = buffer.size(); | |
| 1588 | 1609 | break; |
| 1589 | 1610 | |
| 1590 | 1611 | case CRC: |
| 1591 | crcs[desc[index].p1].write = offset; | |
| 1592 | offset += crc_cells_size(crcs[desc[index].p1].type); | |
| 1612 | crcs[desc[index].p1].write = buffer.size(); | |
| 1613 | buffer.resize(buffer.size() + crc_cells_size(crcs[desc[index].p1].type)); | |
| 1593 | 1614 | break; |
| 1594 | 1615 | |
| 1595 | 1616 | case SECTOR_DATA: { |
| 1596 | 1617 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1597 | 1618 | for(int i=0; i != csect->size; i++) |
| 1598 | mfm_w(buffer, | |
| 1619 | mfm_w(buffer, 8, csect->data[i]); | |
| 1599 | 1620 | break; |
| 1600 | 1621 | } |
| 1601 | 1622 | |
| 1602 | 1623 | case SECTOR_DATA_FM: { |
| 1603 | 1624 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1604 | 1625 | for(int i=0; i != csect->size; i++) |
| 1605 | fm_w(buffer, | |
| 1626 | fm_w(buffer, 8, csect->data[i]); | |
| 1606 | 1627 | break; |
| 1607 | 1628 | } |
| 1608 | 1629 | |
| 1609 | 1630 | case SECTOR_DATA_O: { |
| 1610 | 1631 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1611 | 1632 | for(int i=0; i != csect->size; i++) |
| 1612 | mfm_half_w(buffer, | |
| 1633 | mfm_half_w(buffer, 7, csect->data[i]); | |
| 1613 | 1634 | break; |
| 1614 | 1635 | } |
| 1615 | 1636 | |
| 1616 | 1637 | case SECTOR_DATA_E: { |
| 1617 | 1638 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1618 | 1639 | for(int i=0; i != csect->size; i++) |
| 1619 | mfm_half_w(buffer, | |
| 1640 | mfm_half_w(buffer, 6, csect->data[i]); | |
| 1620 | 1641 | break; |
| 1621 | 1642 | } |
| 1622 | 1643 | |
| 1623 | 1644 | case SECTOR_DATA_GCR5: { |
| 1624 | 1645 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1625 | 1646 | for(int i=0; i != csect->size; i++) |
| 1626 | gcr5_w(buffer, | |
| 1647 | gcr5_w(buffer, 10, csect->data[i]); | |
| 1627 | 1648 | break; |
| 1628 | 1649 | } |
| 1629 | 1650 | |
| r245687 | r245688 | |
| 1649 | 1670 | vc = vc ^ cb; |
| 1650 | 1671 | |
| 1651 | 1672 | int nb = dt > 2 ? 32 : dt > 1 ? 24 : 16; |
| 1652 | raw_w(buffer, | |
| 1673 | raw_w(buffer, nb, gcr6_encode(va, vb, vc) >> (32-nb)); | |
| 1653 | 1674 | } |
| 1654 | raw_w(buffer, | |
| 1675 | raw_w(buffer, 32, gcr6_encode(ca, cb, cc)); | |
| 1655 | 1676 | break; |
| 1656 | 1677 | } |
| 1657 | 1678 | |
| 1658 | 1679 | case SECTOR_DATA_8N1: { |
| 1659 | 1680 | const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); |
| 1660 | 1681 | for(int i=0; i != csect->size; i++) |
| 1661 | _8n1_w(buffer, | |
| 1682 | _8n1_w(buffer, 8, csect->data[i]); | |
| 1662 | 1683 | break; |
| 1663 | 1684 | } |
| 1664 | 1685 | |
| r245687 | r245688 | |
| 1669 | 1690 | index++; |
| 1670 | 1691 | } |
| 1671 | 1692 | |
| 1672 | if(offset != track_size) | |
| 1673 | throw emu_fatalerror("Wrong track size in generate_track, expected %d, got %d\n", track_size, offset); | |
| 1693 | if(int(buffer.size()) != track_size) | |
| 1694 | throw emu_fatalerror("Wrong track size in generate_track, expected %d, got %d\n", track_size, int(buffer.size())); | |
| 1674 | 1695 | |
| 1675 | 1696 | fixup_crcs(buffer, crcs); |
| 1676 | 1697 | |
| 1677 | generate_track_from_levels(track, head, buffer, | |
| 1698 | generate_track_from_levels(track, head, buffer, 0, image); | |
| 1678 | 1699 | } |
| 1679 | 1700 | |
| 1680 | void floppy_image_format_t::normalize_times(UINT32 | |
| 1701 | void floppy_image_format_t::normalize_times(std::vector<UINT32> &buffer) | |
| 1681 | 1702 | { |
| 1682 | 1703 | unsigned int total_sum = 0; |
| 1683 | for(int i=0; i != bi | |
| 1704 | for(unsigned int i=0; i != buffer.size(); i++) | |
| 1684 | 1705 | total_sum += buffer[i] & floppy_image::TIME_MASK; |
| 1685 | 1706 | |
| 1686 | 1707 | unsigned int current_sum = 0; |
| 1687 | for(int i=0; i != bi | |
| 1708 | for(unsigned int i=0; i != buffer.size(); i++) { | |
| 1688 | 1709 | UINT32 time = buffer[i] & floppy_image::TIME_MASK; |
| 1689 | 1710 | buffer[i] = (buffer[i] & floppy_image::MG_MASK) | (200000000ULL * current_sum / total_sum); |
| 1690 | 1711 | current_sum += time; |
| r245687 | r245688 | |
| 1694 | 1715 | void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack) |
| 1695 | 1716 | { |
| 1696 | 1717 | // Maximal number of cells which happens when the buffer is all 1 |
| 1697 | image->set_track_size(track, head, track_size+1, subtrack); | |
| 1698 | UINT32 *dest = image->get_buffer(track, head, subtrack); | |
| 1699 | UINT32 *base = dest; | |
| 1718 | std::vector<UINT32> &dest = image->get_buffer(track, head, subtrack); | |
| 1719 | dest.clear(); | |
| 1700 | 1720 | |
| 1701 | 1721 | UINT32 cbit = floppy_image::MG_A; |
| 1702 | 1722 | UINT32 count = 0; |
| 1703 | 1723 | for(int i=0; i != track_size; i++) |
| 1704 | 1724 | if(trackbuf[i >> 3] & (0x80 >> (i & 7))) { |
| 1705 | | |
| 1725 | dest.push_back(cbit | (count+1)); | |
| 1706 | 1726 | cbit = cbit == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; |
| 1707 | 1727 | count = 1; |
| 1708 | 1728 | } else |
| 1709 | 1729 | count += 2; |
| 1710 | 1730 | |
| 1711 | 1731 | if(count) |
| 1712 | | |
| 1732 | dest.push_back(cbit | count); | |
| 1713 | 1733 | |
| 1714 | int size = dest - base; | |
| 1715 | normalize_times(base, size); | |
| 1716 | image->set_track_size(track, head, size, subtrack); | |
| 1734 | normalize_times(dest); | |
| 1717 | 1735 | image->set_write_splice_position(track, head, 0, subtrack); |
| 1718 | 1736 | } |
| 1719 | 1737 | |
| 1720 | void floppy_image_format_t::generate_track_from_levels(int track, int head, UINT32 | |
| 1738 | void floppy_image_format_t::generate_track_from_levels(int track, int head, std::vector<UINT32> &trackbuf, int splice_pos, floppy_image *image) | |
| 1721 | 1739 | { |
| 1722 | 1740 | // Retrieve the angular splice pos before messing with the data |
| 1723 | splice_pos = splice_pos % track | |
| 1741 | splice_pos = splice_pos % trackbuf.size(); | |
| 1724 | 1742 | UINT32 splice_angular_pos = trackbuf[splice_pos] & floppy_image::TIME_MASK; |
| 1725 | 1743 | |
| 1726 | 1744 | // Check if we need to invert a cell to get an even number of |
| r245687 | r245688 | |
| 1729 | 1747 | // Also check if all MG values are valid |
| 1730 | 1748 | |
| 1731 | 1749 | int transition_count = 0; |
| 1732 | for(int i=0; i<track | |
| 1750 | for(unsigned int i=0; i<trackbuf.size(); i++) { | |
| 1733 | 1751 | switch(trackbuf[i] & floppy_image::MG_MASK) { |
| 1734 | 1752 | case MG_1: |
| 1735 | 1753 | transition_count++; |
| r245687 | r245688 | |
| 1754 | 1772 | int pos = splice_pos; |
| 1755 | 1773 | while((trackbuf[pos] & floppy_image::MG_MASK) != MG_0 && (trackbuf[pos] & floppy_image::MG_MASK) != MG_1) { |
| 1756 | 1774 | pos++; |
| 1757 | if(pos == track | |
| 1775 | if(pos == int(trackbuf.size())) | |
| 1758 | 1776 | pos = 0; |
| 1759 | 1777 | if(pos == splice_pos) |
| 1760 | 1778 | goto meh; |
| r245687 | r245688 | |
| 1770 | 1788 | } |
| 1771 | 1789 | |
| 1772 | 1790 | // Maximal number of cells which happens when the buffer is all MG_1/MG_N alternated, which would be 3/2 |
| 1773 | image->set_track_size(track, head, track_size*2); | |
| 1774 | UINT32 *dest = image->get_buffer(track, head); | |
| 1775 | UINT32 *base = dest; | |
| 1791 | std::vector<UINT32> &dest = image->get_buffer(track, head); | |
| 1792 | dest.clear(); | |
| 1776 | 1793 | |
| 1777 | 1794 | UINT32 cbit = floppy_image::MG_A; |
| 1778 | 1795 | UINT32 count = 0; |
| 1779 | for(int i=0; i<track | |
| 1796 | for(unsigned int i=0; i<trackbuf.size(); i++) { | |
| 1780 | 1797 | UINT32 bit = trackbuf[i] & floppy_image::MG_MASK; |
| 1781 | 1798 | UINT32 time = trackbuf[i] & floppy_image::TIME_MASK; |
| 1782 | 1799 | if(bit == MG_0) { |
| r245687 | r245688 | |
| 1785 | 1802 | } |
| 1786 | 1803 | if(bit == MG_1) { |
| 1787 | 1804 | count += time >> 1; |
| 1788 | | |
| 1805 | dest.push_back(cbit | count); | |
| 1789 | 1806 | cbit = cbit == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; |
| 1790 | 1807 | count = time - (time >> 1); |
| 1791 | 1808 | continue; |
| 1792 | 1809 | } |
| 1793 | *dest++ = cbit | count; | |
| 1794 | *dest++ = trackbuf[i]; | |
| 1810 | dest.push_back(cbit | count); | |
| 1811 | dest.push_back(trackbuf[i]); | |
| 1795 | 1812 | count = 0; |
| 1796 | 1813 | } |
| 1797 | 1814 | |
| 1798 | 1815 | if(count) |
| 1799 | | |
| 1816 | dest.push_back(cbit | count); | |
| 1800 | 1817 | |
| 1801 | int size = dest - base; | |
| 1802 | normalize_times(base, size); | |
| 1803 | image->set_track_size(track, head, size); | |
| 1818 | normalize_times(dest); | |
| 1804 | 1819 | image->set_write_splice_position(track, head, splice_angular_pos); |
| 1805 | 1820 | } |
| 1806 | 1821 | |
| r245687 | r245688 | |
| 2212 | 2227 | |
| 2213 | 2228 | void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack) |
| 2214 | 2229 | { |
| 2215 | int tsize = image->get_track_size(track, head, subtrack); | |
| 2216 | if(!tsize || tsize == 1) { | |
| 2230 | std::vector<UINT32> &tbuf = image->get_buffer(track, head, subtrack); | |
| 2231 | if(tbuf.size() <= 1) { | |
| 2217 | 2232 | // Unformatted track |
| 2218 | 2233 | track_size = 200000000/cell_size; |
| 2219 | 2234 | memset(trackbuf, 0, (track_size+7)/8); |
| r245687 | r245688 | |
| 2221 | 2236 | } |
| 2222 | 2237 | |
| 2223 | 2238 | // Start at the write splice |
| 2224 | const UINT32 *tbuf = image->get_buffer(track, head, subtrack); | |
| 2225 | 2239 | UINT32 splice = image->get_write_splice_position(track, head, subtrack); |
| 2226 | 2240 | int cur_pos = splice; |
| 2227 | 2241 | int cur_entry = 0; |
| 2228 | while(cur_entry < tsize-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos) | |
| 2242 | while(cur_entry < int(tbuf.size())-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos) | |
| 2229 | 2243 | cur_entry++; |
| 2230 | 2244 | |
| 2231 | 2245 | int cur_bit = 0; |
| r245687 | r245688 | |
| 2297 | 2311 | cur_pos -= 200000000; |
| 2298 | 2312 | cur_entry = 0; |
| 2299 | 2313 | } |
| 2300 | while(cur_entry < tsize-1 && (tbuf[cur_entry] & floppy_image::TIME_MASK) < cur_pos) | |
| 2314 | while(cur_entry < int(tbuf.size())-1 && (tbuf[cur_entry] & floppy_image::TIME_MASK) < cur_pos) | |
| 2301 | 2315 | cur_entry++; |
| 2302 | 2316 | |
| 2303 | 2317 | // Wrap around |
| 2304 | if(cur_entry == tsize-1 && | |
| 2318 | if(cur_entry == int(tbuf.size())-1 && | |
| 2305 | 2319 | (tbuf[cur_entry] & floppy_image::TIME_MASK) < cur_pos) { |
| 2306 | 2320 | // Wrap to index 0 or 1 depending on whether there is a transition exactly at the index hole |
| 2307 | cur_entry = (tbuf[tsize-1] & floppy_image::MG_MASK) != (tbuf[0] & floppy_image::MG_MASK) ? | |
| 2321 | cur_entry = (tbuf[int(tbuf.size())-1] & floppy_image::MG_MASK) != (tbuf[0] & floppy_image::MG_MASK) ? | |
| 2308 | 2322 | 0 : 1; |
| 2309 | 2323 | } |
| 2310 | 2324 | } |
| r245687 | r245688 | |
| 2642 | 2656 | |
| 2643 | 2657 | void floppy_image_format_t::build_pc_track_fm(int track, int head, floppy_image *image, int cell_count, int sector_count, const desc_pc_sector *sects, int gap_3, int gap_4a, int gap_1, int gap_2) |
| 2644 | 2658 | { |
| 2645 | dynamic_array<UINT32> track_data(cell_count+10000); | |
| 2646 | int tpos = 0; | |
| 2659 | std::vector<UINT32> track_data; | |
| 2647 | 2660 | |
| 2648 | 2661 | // gap 4a , IAM and gap 1 |
| 2649 | 2662 | if(gap_4a != -1) { |
| 2650 | for(int i=0; i<gap_4a; i++) fm_w(track_data, tpos, 8, 0xff); | |
| 2651 | for(int i=0; i< 6; i++) fm_w(track_data, tpos, 8, 0x00); | |
| 2652 | raw_w(track_data, tpos, 16, 0xf77a); | |
| 2663 | for(int i=0; i<gap_4a; i++) fm_w(track_data, 8, 0xff); | |
| 2664 | for(int i=0; i< 6; i++) fm_w(track_data, 8, 0x00); | |
| 2665 | raw_w(track_data, 16, 0xf77a); | |
| 2653 | 2666 | } |
| 2654 | for(int i=0; i<gap_1; i++) fm_w(track_data, | |
| 2667 | for(int i=0; i<gap_1; i++) fm_w(track_data, 8, 0xff); | |
| 2655 | 2668 | |
| 2656 | 2669 | int total_size = 0; |
| 2657 | 2670 | for(int i=0; i<sector_count; i++) |
| 2658 | 2671 | total_size += sects[i].actual_size; |
| 2659 | 2672 | |
| 2660 | int etpos = tpos; | |
| 2661 | etpos += (sector_count*(6+5+2+gap_2+6+1+2) + total_size)*16; | |
| 2673 | unsigned int etpos = track_data.size() + (sector_count*(6+5+2+gap_2+6+1+2) + total_size)*16; | |
| 2662 | 2674 | |
| 2663 | 2675 | if(etpos > cell_count) |
| 2664 | 2676 | throw emu_fatalerror("Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, etpos); |
| r245687 | r245688 | |
| 2668 | 2680 | |
| 2669 | 2681 | // Build the track |
| 2670 | 2682 | for(int i=0; i<sector_count; i++) { |
| 2671 | int cpos; | |
| 2672 | 2683 | UINT16 crc; |
| 2673 | 2684 | // sync and IDAM and gap 2 |
| 2674 | for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0x00); | |
| 2675 | cpos = tpos; | |
| 2676 | raw_w(track_data, tpos, 16, 0xf57e); | |
| 2677 | fm_w (track_data, tpos, 8, sects[i].track); | |
| 2678 | fm_w (track_data, tpos, 8, sects[i].head); | |
| 2679 | fm_w (track_data, tpos, 8, sects[i].sector); | |
| 2680 | fm_w (track_data, tpos, 8, sects[i].size); | |
| 2681 | crc = calc_crc_ccitt(track_data, cpos, tpos); | |
| 2682 | fm_w (track_data, tpos, 16, crc); | |
| 2683 | for(int j=0; j<gap_2; j++) fm_w(track_data, tpos, 8, 0xff); | |
| 2685 | for(int j=0; j< 6; j++) fm_w(track_data, 8, 0x00); | |
| 2684 | 2686 | |
| 2687 | unsigned int cpos = track_data.size(); | |
| 2688 | raw_w(track_data, 16, 0xf57e); | |
| 2689 | fm_w (track_data, 8, sects[i].track); | |
| 2690 | fm_w (track_data, 8, sects[i].head); | |
| 2691 | fm_w (track_data, 8, sects[i].sector); | |
| 2692 | fm_w (track_data, 8, sects[i].size); | |
| 2693 | crc = calc_crc_ccitt(track_data, cpos, track_data.size()); | |
| 2694 | fm_w (track_data, 16, crc); | |
| 2695 | for(int j=0; j<gap_2; j++) fm_w(track_data, 8, 0xff); | |
| 2696 | ||
| 2685 | 2697 | if(!sects[i].data) |
| 2686 | for(int j=0; j<6+1+sects[i].actual_size+2+(i != sector_count-1 ? gap_3 : 0); j++) fm_w(track_data, | |
| 2698 | for(int j=0; j<6+1+sects[i].actual_size+2+(i != sector_count-1 ? gap_3 : 0); j++) fm_w(track_data, 8, 0xff); | |
| 2687 | 2699 | |
| 2688 | 2700 | else { |
| 2689 | 2701 | // sync, DAM, data and gap 3 |
| 2690 | for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0x00); | |
| 2691 | cpos = tpos; | |
| 2692 | raw_w(track_data, tpos, 16, sects[i].deleted ? 0xf56a : 0xf56f); | |
| 2693 | for(int j=0; j<sects[i].actual_size; j++) fm_w(track_data, tpos, 8, sects[i].data[j]); | |
| 2694 | crc = calc_crc_ccitt(track_data, cpos, tpos); | |
| 2702 | for(int j=0; j< 6; j++) fm_w(track_data, 8, 0x00); | |
| 2703 | cpos = track_data.size(); | |
| 2704 | raw_w(track_data, 16, sects[i].deleted ? 0xf56a : 0xf56f); | |
| 2705 | for(int j=0; j<sects[i].actual_size; j++) fm_w(track_data, 8, sects[i].data[j]); | |
| 2706 | crc = calc_crc_ccitt(track_data, cpos, track_data.size()); | |
| 2695 | 2707 | if(sects[i].bad_crc) |
| 2696 | 2708 | crc = 0xffff^crc; |
| 2697 | fm_w(track_data, | |
| 2709 | fm_w(track_data, 16, crc); | |
| 2698 | 2710 | if(i != sector_count-1) |
| 2699 | for(int j=0; j<gap_3; j++) fm_w(track_data, | |
| 2711 | for(int j=0; j<gap_3; j++) fm_w(track_data, 8, 0xff); | |
| 2700 | 2712 | } |
| 2701 | 2713 | } |
| 2702 | 2714 | |
| 2703 | 2715 | // Gap 4b |
| 2704 | 2716 | |
| 2705 | while(tpos < cell_count-15) fm_w(track_data, tpos, 8, 0xff); | |
| 2706 | raw_w(track_data, tpos, cell_count-tpos, 0xffff >> (16+tpos-cell_count)); | |
| 2717 | while(int(track_data.size()) < cell_count-15) fm_w(track_data, 8, 0xff); | |
| 2718 | raw_w(track_data, cell_count-int(track_data.size()), 0xffff >> (16+int(track_data.size())-cell_count)); | |
| 2707 | 2719 | |
| 2708 | generate_track_from_levels(track, head, track_data, | |
| 2720 | generate_track_from_levels(track, head, track_data, 0, image); | |
| 2709 | 2721 | } |
| 2710 | 2722 | |
| 2711 | 2723 | void floppy_image_format_t::build_pc_track_mfm(int track, int head, floppy_image *image, int cell_count, int sector_count, const desc_pc_sector *sects, int gap_3, int gap_4a, int gap_1, int gap_2) |
| 2712 | 2724 | { |
| 2713 | dynamic_array<UINT32> track_data(cell_count+10000); | |
| 2714 | int tpos = 0; | |
| 2725 | std::vector<UINT32> track_data; | |
| 2715 | 2726 | |
| 2716 | 2727 | // gap 4a , IAM and gap 1 |
| 2717 | 2728 | if(gap_4a != -1) { |
| 2718 | for(int i=0; i<gap_4a; i++) mfm_w(track_data, tpos, 8, 0x4e); | |
| 2719 | for(int i=0; i<12; i++) mfm_w(track_data, tpos, 8, 0x00); | |
| 2720 | for(int i=0; i< 3; i++) raw_w(track_data, tpos, 16, 0x5224); | |
| 2721 | mfm_w(track_data, tpos, 8, 0xfc); | |
| 2729 | for(int i=0; i<gap_4a; i++) mfm_w(track_data, 8, 0x4e); | |
| 2730 | for(int i=0; i<12; i++) mfm_w(track_data, 8, 0x00); | |
| 2731 | for(int i=0; i< 3; i++) raw_w(track_data, 16, 0x5224); | |
| 2732 | mfm_w(track_data, 8, 0xfc); | |
| 2722 | 2733 | } |
| 2723 | for(int i=0; i<gap_1; i++) mfm_w(track_data, | |
| 2734 | for(int i=0; i<gap_1; i++) mfm_w(track_data, 8, 0x4e); | |
| 2724 | 2735 | |
| 2725 | 2736 | int total_size = 0; |
| 2726 | 2737 | for(int i=0; i<sector_count; i++) |
| 2727 | 2738 | total_size += sects[i].actual_size; |
| 2728 | 2739 | |
| 2729 | int etpos = tpos; | |
| 2730 | etpos += (sector_count*(12+3+5+2+gap_2+12+3+1+2) + total_size)*16; | |
| 2740 | int etpos = int(track_data.size()) + (sector_count*(12+3+5+2+gap_2+12+3+1+2) + total_size)*16; | |
| 2731 | 2741 | |
| 2732 | 2742 | if(etpos > cell_count) |
| 2733 | 2743 | throw emu_fatalerror("Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, etpos); |
| r245687 | r245688 | |
| 2737 | 2747 | |
| 2738 | 2748 | // Build the track |
| 2739 | 2749 | for(int i=0; i<sector_count; i++) { |
| 2740 | int cpos; | |
| 2741 | 2750 | UINT16 crc; |
| 2742 | 2751 | // sync and IDAM and gap 2 |
| 2743 | for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00); | |
| 2744 | cpos = tpos; | |
| 2745 | for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489); | |
| 2746 | mfm_w(track_data, tpos, 8, 0xfe); | |
| 2747 | mfm_w(track_data, tpos, 8, sects[i].track); | |
| 2748 | mfm_w(track_data, tpos, 8, sects[i].head); | |
| 2749 | mfm_w(track_data, tpos, 8, sects[i].sector); | |
| 2750 | mfm_w(track_data, tpos, 8, sects[i].size); | |
| 2751 | crc = calc_crc_ccitt(track_data, cpos, tpos); | |
| 2752 | mfm_w(track_data, tpos, 16, crc); | |
| 2753 | for(int j=0; j<gap_2; j++) mfm_w(track_data, tpos, 8, 0x4e); | |
| 2752 | for(int j=0; j<12; j++) mfm_w(track_data, 8, 0x00); | |
| 2753 | unsigned int cpos = track_data.size(); | |
| 2754 | for(int j=0; j< 3; j++) raw_w(track_data, 16, 0x4489); | |
| 2755 | mfm_w(track_data, 8, 0xfe); | |
| 2756 | mfm_w(track_data, 8, sects[i].track); | |
| 2757 | mfm_w(track_data, 8, sects[i].head); | |
| 2758 | mfm_w(track_data, 8, sects[i].sector); | |
| 2759 | mfm_w(track_data, 8, sects[i].size); | |
| 2760 | crc = calc_crc_ccitt(track_data, cpos, track_data.size()); | |
| 2761 | mfm_w(track_data, 16, crc); | |
| 2762 | for(int j=0; j<gap_2; j++) mfm_w(track_data, 8, 0x4e); | |
| 2754 | 2763 | |
| 2755 | 2764 | if(!sects[i].data) |
| 2756 | for(int j=0; j<12+4+sects[i].actual_size+2+(i != sector_count-1 ? gap_3 : 0); j++) mfm_w(track_data, | |
| 2765 | for(int j=0; j<12+4+sects[i].actual_size+2+(i != sector_count-1 ? gap_3 : 0); j++) mfm_w(track_data, 8, 0x4e); | |
| 2757 | 2766 | |
| 2758 | 2767 | else { |
| 2759 | 2768 | // sync, DAM, data and gap 3 |
| 2760 | for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00); | |
| 2761 | cpos = tpos; | |
| 2762 | for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489); | |
| 2763 | mfm_w(track_data, tpos, 8, sects[i].deleted ? 0xf8 : 0xfb); | |
| 2764 | for(int j=0; j<sects[i].actual_size; j++) mfm_w(track_data, tpos, 8, sects[i].data[j]); | |
| 2765 | crc = calc_crc_ccitt(track_data, cpos, tpos); | |
| 2769 | for(int j=0; j<12; j++) mfm_w(track_data, 8, 0x00); | |
| 2770 | cpos = track_data.size(); | |
| 2771 | for(int j=0; j< 3; j++) raw_w(track_data, 16, 0x4489); | |
| 2772 | mfm_w(track_data, 8, sects[i].deleted ? 0xf8 : 0xfb); | |
| 2773 | for(int j=0; j<sects[i].actual_size; j++) mfm_w(track_data, 8, sects[i].data[j]); | |
| 2774 | crc = calc_crc_ccitt(track_data, cpos, track_data.size()); | |
| 2766 | 2775 | if(sects[i].bad_crc) |
| 2767 | 2776 | crc = 0xffff^crc; |
| 2768 | mfm_w(track_data, | |
| 2777 | mfm_w(track_data, 16, crc); | |
| 2769 | 2778 | if(i != sector_count-1) |
| 2770 | for(int j=0; j<gap_3; j++) mfm_w(track_data, | |
| 2779 | for(int j=0; j<gap_3; j++) mfm_w(track_data, 8, 0x4e); | |
| 2771 | 2780 | } |
| 2772 | 2781 | } |
| 2773 | 2782 | |
| 2774 | 2783 | // Gap 4b |
| 2775 | 2784 | |
| 2776 | while(tpos < cell_count-15) mfm_w(track_data, tpos, 8, 0x4e); | |
| 2777 | raw_w(track_data, tpos, cell_count-tpos, 0x9254 >> (16+tpos-cell_count)); | |
| 2785 | while(int(track_data.size()) < cell_count-15) mfm_w(track_data, 8, 0x4e); | |
| 2786 | raw_w(track_data, cell_count-int(track_data.size()), 0x9254 >> (16+int(track_data.size())-cell_count)); | |
| 2778 | 2787 | |
| 2779 | generate_track_from_levels(track, head, track_data, | |
| 2788 | generate_track_from_levels(track, head, track_data, 0, image); | |
| 2780 | 2789 | } |
| r245687 | r245688 | |
|---|---|---|
| 402 | 402 | know. trackbuf may be modified at that position or after. |
| 403 | 403 | @param image |
| 404 | 404 | */ |
| 405 | void generate_track_from_levels(int track, int head, UINT32 | |
| 405 | void generate_track_from_levels(int track, int head, std::vector<UINT32> &trackbuf, int splice_pos, floppy_image *image); | |
| 406 | 406 | |
| 407 | 407 | //! Normalize the times in a cell buffer to sum up to 200000000 |
| 408 | void normalize_times(UINT32 | |
| 408 | void normalize_times(std::vector<UINT32> &buffer); | |
| 409 | 409 | |
| 410 | 410 | // Some conversion tables for gcr |
| 411 | 411 | static const UINT8 gcr5fw_tb[0x10], gcr5bw_tb[0x20]; |
| r245687 | r245688 | |
| 538 | 538 | void get_track_data_fm_pc(int track, int head, floppy_image *image, int cell_size, int sector_size, int sector_count, UINT8 *sectdata); |
| 539 | 539 | |
| 540 | 540 | //! Look up a bit in a level-type stream. |
| 541 | bool bit_r(const UINT32 | |
| 541 | bool bit_r(const std::vector<UINT32> &buffer, int offset); | |
| 542 | 542 | //! Look up multiple bits |
| 543 | UINT32 bitn_r(const UINT32 | |
| 543 | UINT32 bitn_r(const std::vector<UINT32> &buffer, int offset, int count); | |
| 544 | 544 | //! Write a bit with a given size. |
| 545 | void bit_w(UINT32 *buffer, int offset, bool val, UINT32 size = 1000); | |
| 545 | void bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size = 1000); | |
| 546 | void bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size, int offset); | |
| 546 | 547 | //! Calculate a CCITT-type CRC. |
| 547 | UINT16 calc_crc_ccitt(const UINT32 *buffer, int start, int end); | |
| 548 | //! Write a series of (raw) bits and increment the offset. | |
| 549 | void raw_w(UINT32 *buffer, int &offset, int n, UINT32 val, UINT32 size = 1000); | |
| 548 | UINT16 calc_crc_ccitt(const std::vector<UINT32> &buffer, int start, int end); | |
| 549 | //! Write a series of (raw) bits | |
| 550 | void raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size = 1000); | |
| 551 | void raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset); | |
| 550 | 552 | //! FM-encode and write a series of bits |
| 551 | void fm_w(UINT32 *buffer, int &offset, int n, UINT32 val, UINT32 size = 1000); | |
| 553 | void fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size = 1000); | |
| 554 | void fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset); | |
| 552 | 555 | //! MFM-encode and write a series of bits |
| 553 | void mfm_w(UINT32 *buffer, int &offset, int n, UINT32 val, UINT32 size = 1000); | |
| 556 | void mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size = 1000); | |
| 557 | void mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset); | |
| 554 | 558 | //! MFM-encode every two bits and write |
| 555 | void mfm_half_w(UINT32 | |
| 559 | void mfm_half_w(std::vector<UINT32> &buffer, int start_bit, UINT32 val, UINT32 size = 1000); | |
| 556 | 560 | //! GCR5-encode and write a series of bits |
| 557 | void gcr5_w(UINT32 *buffer, int &offset, int n, UINT32 val, UINT32 size = 1000); | |
| 561 | void gcr5_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size = 1000); | |
| 562 | void gcr5_w(std::vector<UINT32> &buffer, int offset, int n, UINT32 val, UINT32 size = 1000); | |
| 558 | 563 | //! 8N1-encode and write a series of bits |
| 559 | void _8n1_w(UINT32 | |
| 564 | void _8n1_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size = 1000); | |
| 560 | 565 | //! GCR4 encode (Apple II sector header) |
| 561 | 566 | UINT16 gcr4_encode(UINT8 va); |
| 562 | 567 | //! GCR4 decode |
| r245687 | r245688 | |
| 585 | 590 | bool type_data_mfm(int type, int p1, const gen_crc_info *crcs) const; |
| 586 | 591 | |
| 587 | 592 | int crc_cells_size(int type) const; |
| 588 | void fixup_crc_amiga(UINT32 *buffer, const gen_crc_info *crc); | |
| 589 | void fixup_crc_cbm(UINT32 *buffer, const gen_crc_info *crc); | |
| 590 | void fixup_crc_ccitt(UINT32 *buffer, const gen_crc_info *crc); | |
| 591 | void fixup_crc_ccitt_fm(UINT32 *buffer, const gen_crc_info *crc); | |
| 592 | void fixup_crc_machead(UINT32 *buffer, const gen_crc_info *crc); | |
| 593 | void fixup_crc_fcs(UINT32 *buffer, const gen_crc_info *crc); | |
| 594 | void fixup_crc_victor_header(UINT32 *buffer, const gen_crc_info *crc); | |
| 595 | void fixup_crc_victor_data(UINT32 *buffer, const gen_crc_info *crc); | |
| 596 | void fixup_crcs(UINT32 *buffer, gen_crc_info *crcs); | |
| 593 | void fixup_crc_amiga(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 594 | void fixup_crc_cbm(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 595 | void fixup_crc_ccitt(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 596 | void fixup_crc_ccitt_fm(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 597 | void fixup_crc_machead(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 598 | void fixup_crc_fcs(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 599 | void fixup_crc_victor_header(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 600 | void fixup_crc_victor_data(std::vector<UINT32> &buffer, const gen_crc_info *crc); | |
| 601 | void fixup_crcs(std::vector<UINT32> &buffer, gen_crc_info *crcs); | |
| 597 | 602 | void collect_crcs(const desc_e *desc, gen_crc_info *crcs); |
| 598 | 603 | |
| 599 | 604 | int sbit_r(const UINT8 *bitstream, int pos); |
| r245687 | r245688 | |
| 717 | 722 | /*! |
| 718 | 723 | @param track |
| 719 | 724 | @param subtrack |
| 720 | @param head | |
| 721 | @param size size of this track | |
| 722 | */ | |
| 723 | void set_track_size(int track, int head, UINT32 size, int subtrack = 0) { track_array[track*4+subtrack][head].track_size = size; ensure_alloc(track*4+subtrack, head); } | |
| 724 | ||
| 725 | /*! | |
| 726 | @param track | |
| 727 | @param subtrack | |
| 728 | 725 | @param head head number |
| 729 | 726 | @return a pointer to the data buffer for this track and head |
| 730 | 727 | */ |
| 731 | UINT32 | |
| 728 | std::vector<UINT32> &get_buffer(int track, int head, int subtrack = 0) { return track_array[track*4+subtrack][head].cell_data; } | |
| 732 | 729 | |
| 733 | //! @return the track size | |
| 734 | //! @param track | |
| 735 | //! @param subtrack | |
| 736 | //! @param head | |
| 737 | UINT32 get_track_size(int track, int head, int subtrack = 0) { return track_array[track*4+subtrack][head].track_size; } | |
| 738 | ||
| 739 | 730 | //! Sets the write splice position. |
| 740 | 731 | //! The "track splice" information indicates where to start writing |
| 741 | 732 | //! if you try to rewrite a physical disk with the data. Some |
| r245687 | r245688 | |
| 772 | 763 | UINT32 form_factor, variant; |
| 773 | 764 | |
| 774 | 765 | struct track_info { |
| 775 | dynamic_array<UINT32> cell_data; | |
| 776 | UINT32 track_size; | |
| 766 | std::vector<UINT32> cell_data; | |
| 777 | 767 | UINT32 write_splice; |
| 778 | 768 | |
| 779 | track_info() { | |
| 769 | track_info() { write_splice = 0; } | |
| 780 | 770 | }; |
| 781 | 771 | |
| 782 | 772 | // track number multiplied by 4 then head |
| 783 | 773 | // last array size may be bigger than actual track size |
| 784 | dynamic_array<dynamic_array<track_info> > track_array; | |
| 785 | ||
| 786 | void ensure_alloc(int track, int head); | |
| 774 | std::vector<std::vector<track_info> > track_array; | |
| 787 | 775 | }; |
| 788 | 776 | |
| 789 | 777 | #endif /* FLOPIMG_H */ |
| r245687 | r245688 | |
|---|---|---|
| 42 | 42 | { |
| 43 | 43 | UINT64 size = io_generic_size(io); |
| 44 | 44 | dynamic_buffer img(size); |
| 45 | io_generic_read(io, img, 0, size); | |
| 45 | io_generic_read(io, &img[0], 0, size); | |
| 46 | 46 | |
| 47 | 47 | if (img[VERSION]) { |
| 48 | 48 | throw emu_fatalerror("g64_format: Unsupported version %u", img[VERSION]); |
| r245687 | r245688 | |
| 53 | 53 | |
| 54 | 54 | for (int track = 0; track < track_count; track++) |
| 55 | 55 | { |
| 56 | UINT32 track_offset = pick_integer_le(img, TRACK_OFFSET + (track * 4), 4); | |
| 56 | UINT32 track_offset = pick_integer_le(&img[0], TRACK_OFFSET + (track * 4), 4); | |
| 57 | 57 | |
| 58 | 58 | if (!track_offset) |
| 59 | 59 | continue; |
| r245687 | r245688 | |
| 61 | 61 | if (track_offset > size) |
| 62 | 62 | throw emu_fatalerror("g64_format: Track %u offset %06x out of bounds", track, track_offset); |
| 63 | 63 | |
| 64 | UINT32 speed_zone = pick_integer_le(img, SPEED_ZONE + (track * 4), 4); | |
| 64 | UINT32 speed_zone = pick_integer_le(&img[0], SPEED_ZONE + (track * 4), 4); | |
| 65 | 65 | |
| 66 | 66 | if (speed_zone > 3) |
| 67 | 67 | throw emu_fatalerror("g64_format: Unsupported variable speed zones on track %d", track); |
| 68 | 68 | |
| 69 | UINT16 track_bytes = pick_integer_le(img, track_offset, 2); | |
| 69 | UINT16 track_bytes = pick_integer_le(&img[0], track_offset, 2); | |
| 70 | 70 | int track_size = track_bytes * 8; |
| 71 | 71 | |
| 72 | 72 | LOG_FORMATS("track %u size %u cell %ld\n", track, track_size, 200000000L/track_size); |
| r245687 | r245688 | |
| 109 | 109 | io_generic_write_filler(io, 0x00, tpos, 4); |
| 110 | 110 | io_generic_write_filler(io, 0x00, spos, 4); |
| 111 | 111 | |
| 112 | if (image->get_ | |
| 112 | if (image->get_buffer(track, head).size() <= 1) | |
| 113 | 113 | continue; |
| 114 | 114 | |
| 115 | 115 | int track_size; |
| 116 | 116 | int speed_zone; |
| 117 | 117 | |
| 118 | 118 | // figure out the cell size and speed zone from the track data |
| 119 | if ((speed_zone = generate_bitstream(track, head, 3, trackbuf, track_size, image)) == -1) | |
| 120 | if ((speed_zone = generate_bitstream(track, head, 2, trackbuf, track_size, image)) == -1) | |
| 121 | if ((speed_zone = generate_bitstream(track, head, 1, trackbuf, track_size, image)) == -1) | |
| 122 | if ((speed_zone = generate_bitstream(track, head, 0, trackbuf, track_size, image)) == -1) | |
| 119 | if ((speed_zone = generate_bitstream(track, head, 3, &trackbuf[0], track_size, image)) == -1) | |
| 120 | if ((speed_zone = generate_bitstream(track, head, 2, &trackbuf[0], track_size, image)) == -1) | |
| 121 | if ((speed_zone = generate_bitstream(track, head, 1, &trackbuf[0], track_size, image)) == -1) | |
| 122 | if ((speed_zone = generate_bitstream(track, head, 0, &trackbuf[0], track_size, image)) == -1) | |
| 123 | 123 | throw emu_fatalerror("g64_format: Cannot determine speed zone for track %u", track); |
| 124 | 124 | |
| 125 | 125 | LOG_FORMATS("track %u size %u cell %u\n", track, track_size, c1541_cell_size[speed_zone]); |
| r245687 | r245688 | |
| 136 | 136 | io_generic_write(io, speed_offset, spos, 4); |
| 137 | 137 | io_generic_write_filler(io, 0xff, dpos, TRACK_LENGTH); |
| 138 | 138 | io_generic_write(io, track_length, dpos, 2); |
| 139 | io_generic_write(io, trackbuf, dpos + 2, track_size); | |
| 139 | io_generic_write(io, &trackbuf[0], dpos + 2, track_size); | |
| 140 | 140 | |
| 141 | 141 | tracks_written++; |
| 142 | 142 | } |
| r245687 | r245688 | |
|---|---|---|
| 85 | 85 | trackbuf.resize(trackdesc.mfmtracksize); |
| 86 | 86 | |
| 87 | 87 | // actual data read |
| 88 | io_generic_read(io, trackbuf, trackdesc.mfmtrackoffset, trackdesc.mfmtracksize); | |
| 88 | io_generic_read(io, &trackbuf[0], trackdesc.mfmtrackoffset, trackdesc.mfmtracksize); | |
| 89 | 89 | |
| 90 | generate_track_from_bitstream(track, side, trackbuf, trackdesc.mfmtracksize*8, image); | |
| 90 | generate_track_from_bitstream(track, side, &trackbuf[0], trackdesc.mfmtracksize*8, image); | |
| 91 | 91 | |
| 92 | 92 | counter++; |
| 93 | 93 | } |
| r245687 | r245688 | |
|---|---|---|
| 336 | 336 | { |
| 337 | 337 | UINT64 size = io_generic_size(io); |
| 338 | 338 | dynamic_buffer img(size); |
| 339 | io_generic_read(io, img, 0, size); | |
| 339 | io_generic_read(io, &img[0], 0, size); | |
| 340 | 340 | |
| 341 | 341 | UINT64 pos; |
| 342 | 342 | for(pos=0; pos < size && img[pos] != 0x1a; pos++); |
| r245687 | r245688 | |
| 363 | 363 | int rpm = form_factor == floppy_image::FF_8 || (form_factor == floppy_image::FF_525 && rate >= 300000) ? 360 : 300; |
| 364 | 364 | int cell_count = (fm ? 1 : 2)*rate*60/rpm; |
| 365 | 365 | |
| 366 | const UINT8 *snum = img | |
| 366 | const UINT8 *snum = &img[pos]; | |
| 367 | 367 | pos += sector_count; |
| 368 | const UINT8 *tnum = head & 0x80 ? img | |
| 368 | const UINT8 *tnum = head & 0x80 ? &img[pos] : NULL; | |
| 369 | 369 | if(tnum) |
| 370 | 370 | pos += sector_count; |
| 371 | const UINT8 *hnum = head & 0x40 ? img | |
| 371 | const UINT8 *hnum = head & 0x40 ? &img[pos] : NULL; | |
| 372 | 372 | if(hnum) |
| 373 | 373 | pos += sector_count; |
| 374 | 374 | |
| r245687 | r245688 | |
| 398 | 398 | memset(sects[i].data, img[pos++], actual_size); |
| 399 | 399 | |
| 400 | 400 | } else { |
| 401 | sects[i].data = img | |
| 401 | sects[i].data = &img[pos]; | |
| 402 | 402 | pos += actual_size; |
| 403 | 403 | } |
| 404 | 404 | } |
| r245687 | r245688 | |
| 410 | 410 | build_pc_track_mfm(track, head, image, cell_count, sector_count, sects, gap_3); |
| 411 | 411 | |
| 412 | 412 | for(int i=0; i<sector_count; i++) |
| 413 | if(sects[i].data && (sects[i].data < img || sects[i].data >= img | |
| 413 | if(sects[i].data && (sects[i].data < &img[0] || sects[i].data >= &img[size])) | |
| 414 | 414 | global_free_array(sects[i].data); |
| 415 | 415 | } |
| 416 | 416 |
| r245687 | r245688 | |
|---|---|---|
| 43 | 43 | { |
| 44 | 44 | UINT64 size = io_generic_size(io); |
| 45 | 45 | dynamic_buffer data(size); |
| 46 | io_generic_read(io, data, 0, size); | |
| 47 | bool res = parse(data, size, image); | |
| 46 | io_generic_read(io, &data[0], 0, size); | |
| 47 | bool res = parse(data, image); | |
| 48 | 48 | return res; |
| 49 | 49 | } |
| 50 | 50 | |
| r245687 | r245688 | |
| 77 | 77 | return ~crc; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | bool ipf_format::parse( | |
| 80 | bool ipf_format::parse(dynamic_buffer &data, floppy_image *image) | |
| 81 | 81 | { |
| 82 | 82 | image->set_variant(floppy_image::DSDD); // Not handling anything else yet |
| 83 | 83 | tcount = 84*2+1; // Usual max |
| 84 | 84 | tinfos = global_alloc_array_clear(track_info, tcount); |
| 85 | bool res = scan_all_tags(data | |
| 85 | bool res = scan_all_tags(data); | |
| 86 | 86 | if(res) |
| 87 | 87 | res = generate_tracks(image); |
| 88 | 88 | global_free_array(tinfos); |
| r245687 | r245688 | |
| 179 | 179 | return true; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | bool ipf_format::scan_one_tag( | |
| 182 | bool ipf_format::scan_one_tag(dynamic_buffer &data, UINT32 &pos, UINT8 *&tag, UINT32 &tsize) | |
| 183 | 183 | { |
| 184 | if(size-pos < 12) | |
| 184 | if(data.size()-pos < 12) | |
| 185 | 185 | return false; |
| 186 | tag = data | |
| 186 | tag = &data[pos]; | |
| 187 | 187 | tsize = r32(tag+4); |
| 188 | if(size-pos < tsize) | |
| 188 | if(data.size()-pos < tsize) | |
| 189 | 189 | return false; |
| 190 | 190 | UINT32 crc = r32(tag+8); |
| 191 | 191 | tag[8] = tag[9] = tag[10] = tag[11] = 0; |
| r245687 | r245688 | |
| 195 | 195 | return true; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | bool ipf_format::scan_all_tags( | |
| 198 | bool ipf_format::scan_all_tags(dynamic_buffer &data) | |
| 199 | 199 | { |
| 200 | 200 | UINT32 pos = 0; |
| 201 | UINT32 size = data.size(); | |
| 201 | 202 | while(pos != size) { |
| 202 | 203 | UINT8 *tag; |
| 203 | 204 | UINT32 tsize; |
| 204 | 205 | |
| 205 | if(!scan_one_tag(data, | |
| 206 | if(!scan_one_tag(data, pos, tag, tsize)) | |
| 206 | 207 | return false; |
| 207 | 208 | |
| 208 | 209 | switch(r32(tag)) { |
| r245687 | r245688 | |
| 253 | 254 | return true; |
| 254 | 255 | } |
| 255 | 256 | |
| 256 | void ipf_format::rotate(UINT32 | |
| 257 | void ipf_format::rotate(std::vector<UINT32> &track, UINT32 offset, UINT32 size) | |
| 257 | 258 | { |
| 258 | 259 | UINT32 done = 0; |
| 259 | 260 | for(UINT32 bpos=0; done < size; bpos++) { |
| r245687 | r245688 | |
| 274 | 275 | } |
| 275 | 276 | } |
| 276 | 277 | |
| 277 | void ipf_format::mark_track_splice(UINT32 | |
| 278 | void ipf_format::mark_track_splice(std::vector<UINT32> &track, UINT32 offset, UINT32 size) | |
| 278 | 279 | { |
| 279 | 280 | for(int i=0; i<3; i++) { |
| 280 | 281 | UINT32 pos = (offset + i) % size; |
| r245687 | r245688 | |
| 287 | 288 | } |
| 288 | 289 | } |
| 289 | 290 | |
| 290 | void ipf_format::timing_set(UINT32 | |
| 291 | void ipf_format::timing_set(std::vector<UINT32> &track, UINT32 start, UINT32 end, UINT32 time) | |
| 291 | 292 | { |
| 292 | 293 | for(UINT32 i=start; i != end; i++) |
| 293 | 294 | track[i] = (track[i] & floppy_image::MG_MASK) | time; |
| 294 | 295 | } |
| 295 | 296 | |
| 296 | bool ipf_format::generate_timings(track_info *t, UINT32 | |
| 297 | bool ipf_format::generate_timings(track_info *t, std::vector<UINT32> &track, const std::vector<UINT32> &data_pos, const std::vector<UINT32> &gap_pos) | |
| 297 | 298 | { |
| 298 | 299 | timing_set(track, 0, t->size_cells, 2000); |
| 299 | 300 | |
| r245687 | r245688 | |
| 387 | 388 | if(t->index_cells >= t->size_cells) |
| 388 | 389 | return false; |
| 389 | 390 | |
| 390 | dynamic_array<UINT32> track(t->size_cells); | |
| 391 | dynamic_array<UINT32> data_pos(t->block_count+1); | |
| 392 | dynamic_array<UINT32> gap_pos(t->block_count); | |
| 393 | dynamic_array<UINT32> splice_pos(t->block_count); | |
| 391 | std::vector<UINT32> track(t->size_cells); | |
| 392 | std::vector<UINT32> data_pos(t->block_count+1); | |
| 393 | std::vector<UINT32> gap_pos(t->block_count); | |
| 394 | std::vector<UINT32> splice_pos(t->block_count); | |
| 394 | 395 | |
| 395 | 396 | bool context = false; |
| 396 | 397 | UINT32 pos = 0; |
| r245687 | r245688 | |
| 414 | 415 | if(t->index_cells) |
| 415 | 416 | rotate(track, t->size_cells - t->index_cells, t->size_cells); |
| 416 | 417 | |
| 417 | generate_track_from_levels(t->cylinder, t->head, track, | |
| 418 | generate_track_from_levels(t->cylinder, t->head, track, splice_pos[t->block_count-1] + t->index_cells, image); | |
| 418 | 419 | |
| 419 | 420 | return true; |
| 420 | 421 | } |
| 421 | 422 | |
| 422 | void ipf_format::track_write_raw(UINT32 | |
| 423 | void ipf_format::track_write_raw(std::vector<UINT32>::iterator &tpos, const UINT8 *data, UINT32 cells, bool &context) | |
| 423 | 424 | { |
| 424 | 425 | for(UINT32 i=0; i != cells; i++) |
| 425 | *t | |
| 426 | *tpos++ = data[i>>3] & (0x80 >> (i & 7)) ? MG_1 : MG_0; | |
| 426 | 427 | if(cells) |
| 427 | context = t | |
| 428 | context = tpos[-1] == MG_1; | |
| 428 | 429 | } |
| 429 | 430 | |
| 430 | void ipf_format::track_write_mfm(UINT32 | |
| 431 | void ipf_format::track_write_mfm(std::vector<UINT32>::iterator &tpos, const UINT8 *data, UINT32 start_offset, UINT32 patlen, UINT32 cells, bool &context) | |
| 431 | 432 | { |
| 432 | 433 | patlen *= 2; |
| 433 | 434 | for(UINT32 i=0; i != cells; i++) { |
| 434 | 435 | UINT32 pos = (i + start_offset) % patlen; |
| 435 | 436 | bool bit = data[pos>>4] & (0x80 >> ((pos >> 1) & 7)); |
| 436 | 437 | if(pos & 1) { |
| 437 | *t | |
| 438 | *tpos++ = bit ? MG_1 : MG_0; | |
| 438 | 439 | context = bit; |
| 439 | 440 | } else |
| 440 | *t | |
| 441 | *tpos++ = context || bit ? MG_0 : MG_1; | |
| 441 | 442 | } |
| 442 | 443 | } |
| 443 | 444 | |
| 444 | void ipf_format::track_write_weak(UINT32 | |
| 445 | void ipf_format::track_write_weak(std::vector<UINT32>::iterator &tpos, UINT32 cells) | |
| 445 | 446 | { |
| 446 | 447 | for(UINT32 i=0; i != cells; i++) |
| 447 | *t | |
| 448 | *tpos++ = floppy_image::MG_N; | |
| 448 | 449 | } |
| 449 | 450 | |
| 450 | bool ipf_format::generate_block_data(const UINT8 *data, const UINT8 *dlimit, UINT32 | |
| 451 | bool ipf_format::generate_block_data(const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, std::vector<UINT32>::iterator tlimit, bool &context) | |
| 451 | 452 | { |
| 452 | 453 | for(;;) { |
| 453 | 454 | if(data >= dlimit) |
| r245687 | r245688 | |
| 456 | 457 | if((val >> 5) > dlimit-data) |
| 457 | 458 | return false; |
| 458 | 459 | UINT32 param = rb(data, val >> 5); |
| 459 | UINT32 tleft = tlimit - t | |
| 460 | UINT32 tleft = tlimit - tpos; | |
| 460 | 461 | switch(val & 0x1f) { |
| 461 | 462 | case 0: // End of description |
| 462 | 463 | return !tleft; |
| r245687 | r245688 | |
| 464 | 465 | case 1: // Raw bytes |
| 465 | 466 | if(8*param > tleft) |
| 466 | 467 | return false; |
| 467 | track_write_raw(t | |
| 468 | track_write_raw(tpos, data, 8*param, context); | |
| 468 | 469 | data += param; |
| 469 | 470 | break; |
| 470 | 471 | |
| r245687 | r245688 | |
| 472 | 473 | case 3: // MFM-decoded gap bytes |
| 473 | 474 | if(16*param > tleft) |
| 474 | 475 | return false; |
| 475 | track_write_mfm(t | |
| 476 | track_write_mfm(tpos, data, 0, 8*param, 16*param, context); | |
| 476 | 477 | data += param; |
| 477 | 478 | break; |
| 478 | 479 | |
| 479 | 480 | case 5: // Weak bytes |
| 480 | 481 | if(16*param > tleft) |
| 481 | 482 | return false; |
| 482 | track_write_weak(t | |
| 483 | track_write_weak(tpos, 16*param); | |
| 483 | 484 | context = 0; |
| 484 | 485 | break; |
| 485 | 486 | |
| r245687 | r245688 | |
| 489 | 490 | } |
| 490 | 491 | } |
| 491 | 492 | |
| 492 | bool ipf_format::generate_block_gap_0(UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, UINT32 | |
| 493 | bool ipf_format::generate_block_gap_0(UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, std::vector<UINT32>::iterator &tpos, bool &context) | |
| 493 | 494 | { |
| 494 | 495 | spos = ipos >= 16 && ipos+16 <= gap_cells ? ipos : gap_cells >> 1; |
| 495 | track_write_mfm(t | |
| 496 | track_write_mfm(tpos, &pattern, 0, 8, spos, context); | |
| 496 | 497 | UINT32 delta = 0; |
| 497 | 498 | if(gap_cells & 1) { |
| 498 | *t | |
| 499 | *tpos++ = MG_0; | |
| 499 | 500 | delta++; |
| 500 | 501 | } |
| 501 | track_write_mfm(t | |
| 502 | track_write_mfm(tpos, &pattern, spos+delta-gap_cells, 8, gap_cells-spos-delta, context); | |
| 502 | 503 | return true; |
| 503 | 504 | } |
| 504 | 505 | |
| r245687 | r245688 | |
| 527 | 528 | } |
| 528 | 529 | } |
| 529 | 530 | |
| 530 | bool ipf_format::generate_gap_from_description(const UINT8 *&data, const UINT8 *dlimit, UINT32 | |
| 531 | bool ipf_format::generate_gap_from_description(const UINT8 *&data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, UINT32 size, bool pre, bool &context) | |
| 531 | 532 | { |
| 532 | 533 | const UINT8 *data1 = data; |
| 533 | 534 | UINT32 res_size; |
| r245687 | r245688 | |
| 577 | 578 | if(pos + block_size > size) |
| 578 | 579 | return false; |
| 579 | 580 | // printf("pat=%02x size=%d pre\n", pattern[0], block_size); |
| 580 | track_write_mfm(t | |
| 581 | track_write_mfm(tpos, pattern, 0, pattern_size, block_size, context); | |
| 581 | 582 | pos += block_size; |
| 582 | 583 | } else { |
| 583 | 584 | if(pos == 0 && block_size && res_size != size) |
| r245687 | r245688 | |
| 587 | 588 | if(pos + block_size > size) |
| 588 | 589 | return false; |
| 589 | 590 | // printf("pat=%02x block_size=%d size=%d res_size=%d post\n", pattern[0], block_size, size, res_size); |
| 590 | track_write_mfm(t | |
| 591 | track_write_mfm(tpos, pattern, -block_size, pattern_size, block_size, context); | |
| 591 | 592 | pos += block_size; |
| 592 | 593 | } |
| 593 | 594 | block_size = 0; |
| r245687 | r245688 | |
| 597 | 598 | } |
| 598 | 599 | |
| 599 | 600 | |
| 600 | bool ipf_format::generate_block_gap_1(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 | |
| 601 | bool ipf_format::generate_block_gap_1(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context) | |
| 601 | 602 | { |
| 602 | 603 | if(ipos >= 16 && ipos < gap_cells-16) |
| 603 | 604 | spos = ipos; |
| 604 | 605 | else |
| 605 | 606 | spos = 0; |
| 606 | return generate_gap_from_description(data, dlimit, t | |
| 607 | return generate_gap_from_description(data, dlimit, tpos, gap_cells, true, context); | |
| 607 | 608 | } |
| 608 | 609 | |
| 609 | bool ipf_format::generate_block_gap_2(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 | |
| 610 | bool ipf_format::generate_block_gap_2(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context) | |
| 610 | 611 | { |
| 611 | 612 | if(ipos >= 16 && ipos < gap_cells-16) |
| 612 | 613 | spos = ipos; |
| 613 | 614 | else |
| 614 | 615 | spos = gap_cells; |
| 615 | return generate_gap_from_description(data, dlimit, t | |
| 616 | return generate_gap_from_description(data, dlimit, tpos, gap_cells, false, context); | |
| 616 | 617 | } |
| 617 | 618 | |
| 618 | bool ipf_format::generate_block_gap_3(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 | |
| 619 | bool ipf_format::generate_block_gap_3(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context) | |
| 619 | 620 | { |
| 620 | 621 | if(ipos >= 16 && ipos < gap_cells-16) |
| 621 | 622 | spos = ipos; |
| r245687 | r245688 | |
| 631 | 632 | |
| 632 | 633 | spos = presize + (gap_cells - presize - postsize)/2; |
| 633 | 634 | } |
| 634 | if(!generate_gap_from_description(data, dlimit, t | |
| 635 | if(!generate_gap_from_description(data, dlimit, tpos, spos, true, context)) | |
| 635 | 636 | return false; |
| 636 | 637 | UINT32 delta = 0; |
| 637 | 638 | if(gap_cells & 1) { |
| 638 | t | |
| 639 | tpos[spos] = MG_0; | |
| 639 | 640 | delta++; |
| 640 | 641 | } |
| 641 | 642 | |
| 642 | return generate_gap_from_description(data, dlimit, t | |
| 643 | return generate_gap_from_description(data, dlimit, tpos+spos+delta, gap_cells - spos - delta, false, context); | |
| 643 | 644 | } |
| 644 | 645 | |
| 645 | bool ipf_format::generate_block_gap(UINT32 gap_type, UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 | |
| 646 | bool ipf_format::generate_block_gap(UINT32 gap_type, UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, bool &context) | |
| 646 | 647 | { |
| 647 | 648 | switch(gap_type) { |
| 648 | 649 | case 0: |
| 649 | return generate_block_gap_0(gap_cells, pattern, spos, ipos, t | |
| 650 | return generate_block_gap_0(gap_cells, pattern, spos, ipos, tpos, context); | |
| 650 | 651 | case 1: |
| 651 | return generate_block_gap_1(gap_cells, spos, ipos, data, dlimit, t | |
| 652 | return generate_block_gap_1(gap_cells, spos, ipos, data, dlimit, tpos, context); | |
| 652 | 653 | case 2: |
| 653 | return generate_block_gap_2(gap_cells, spos, ipos, data, dlimit, t | |
| 654 | return generate_block_gap_2(gap_cells, spos, ipos, data, dlimit, tpos, context); | |
| 654 | 655 | case 3: |
| 655 | return generate_block_gap_3(gap_cells, spos, ipos, data, dlimit, t | |
| 656 | return generate_block_gap_3(gap_cells, spos, ipos, data, dlimit, tpos, context); | |
| 656 | 657 | default: |
| 657 | 658 | return false; |
| 658 | 659 | } |
| 659 | 660 | } |
| 660 | 661 | |
| 661 | bool ipf_format::generate_block(track_info *t, UINT32 idx, UINT32 ipos, UINT32 | |
| 662 | bool ipf_format::generate_block(track_info *t, UINT32 idx, UINT32 ipos, std::vector<UINT32> &track, UINT32 &pos, UINT32 &dpos, UINT32 &gpos, UINT32 &spos, bool &context) | |
| 662 | 663 | { |
| 663 | 664 | const UINT8 *data = t->data; |
| 664 | 665 | const UINT8 *data_end = t->data + t->data_size; |
| r245687 | r245688 | |
| 681 | 682 | pos = gpos + gap_cells; |
| 682 | 683 | if(pos > t->size_cells) |
| 683 | 684 | return false; |
| 684 | if(!generate_block_data(data + r32(thead+28), data_end, track+dpos, track+gpos, context)) | |
| 685 | if(!generate_block_data(data + r32(thead+28), data_end, track.begin()+dpos, track.begin()+gpos, context)) | |
| 685 | 686 | return false; |
| 686 | if(!generate_block_gap(r32(thead+20), gap_cells, r32(thead+24), spos, ipos > gpos ? ipos-gpos : 0, data + r32(thead+8), data_end, track+gpos, context)) | |
| 687 | if(!generate_block_gap(r32(thead+20), gap_cells, r32(thead+24), spos, ipos > gpos ? ipos-gpos : 0, data + r32(thead+8), data_end, track.begin()+gpos, context)) | |
| 687 | 688 | return false; |
| 688 | 689 | spos += gpos; |
| 689 | 690 |
| r245687 | r245688 | |
|---|---|---|
| 48 | 48 | bool parse_imge(const UINT8 *imge); |
| 49 | 49 | bool parse_data(const UINT8 *data, UINT32 &pos, UINT32 max_extra_size); |
| 50 | 50 | |
| 51 | bool scan_one_tag(UINT8 *data, UINT32 size, UINT32 &pos, UINT8 *&tag, UINT32 &tsize); | |
| 52 | bool scan_all_tags(UINT8 *data, UINT32 size); | |
| 51 | bool scan_one_tag(dynamic_buffer &data, UINT32 &pos, UINT8 *&tag, UINT32 &tsize); | |
| 52 | bool scan_all_tags(dynamic_buffer &data); | |
| 53 | 53 | static UINT32 r32(const UINT8 *p); |
| 54 | 54 | static UINT32 rb(const UINT8 *&p, int count); |
| 55 | 55 | |
| 56 | 56 | track_info *get_index(UINT32 idx); |
| 57 | 57 | |
| 58 | void track_write_raw(UINT32 *&track, const UINT8 *data, UINT32 cells, bool &context); | |
| 59 | void track_write_mfm(UINT32 *&track, const UINT8 *data, UINT32 start_offset, UINT32 patlen, UINT32 cells, bool &context); | |
| 60 | void track_write_weak(UINT32 *&track, UINT32 cells); | |
| 61 | bool generate_block_data(const UINT8 *data, const UINT8 *dlimit, UINT32 *track, UINT32 *tlimit, bool &context); | |
| 58 | void track_write_raw(std::vector<UINT32>::iterator &tpos, const UINT8 *data, UINT32 cells, bool &context); | |
| 59 | void track_write_mfm(std::vector<UINT32>::iterator &tpos, const UINT8 *data, UINT32 start_offset, UINT32 patlen, UINT32 cells, bool &context); | |
| 60 | void track_write_weak(std::vector<UINT32>::iterator &tpos, UINT32 cells); | |
| 61 | bool generate_block_data(const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, std::vector<UINT32>::iterator tlimit, bool &context); | |
| 62 | 62 | |
| 63 | 63 | bool gap_description_to_reserved_size(const UINT8 *&data, const UINT8 *dlimit, UINT32 &res_size); |
| 64 | bool generate_gap_from_description(const UINT8 *&data, const UINT8 *dlimit, UINT32 *track, UINT32 size, bool pre, bool &context); | |
| 65 | bool generate_block_gap_0(UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, UINT32 *track, bool &context); | |
| 66 | bool generate_block_gap_1(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 *track, bool &context); | |
| 67 | bool generate_block_gap_2(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 *track, bool &context); | |
| 68 | bool generate_block_gap_3(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 *track, bool &context); | |
| 69 | bool generate_block_gap(UINT32 gap_type, UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, UINT32 *track, bool &context); | |
| 64 | bool generate_gap_from_description(const UINT8 *&data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, UINT32 size, bool pre, bool &context); | |
| 65 | bool generate_block_gap_0(UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, std::vector<UINT32>::iterator &tpos, bool &context); | |
| 66 | bool generate_block_gap_1(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context); | |
| 67 | bool generate_block_gap_2(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context); | |
| 68 | bool generate_block_gap_3(UINT32 gap_cells, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator &tpos, bool &context); | |
| 69 | bool generate_block_gap(UINT32 gap_type, UINT32 gap_cells, UINT8 pattern, UINT32 &spos, UINT32 ipos, const UINT8 *data, const UINT8 *dlimit, std::vector<UINT32>::iterator tpos, bool &context); | |
| 70 | 70 | |
| 71 | bool generate_block(track_info *t, UINT32 idx, UINT32 ipos, UINT32 | |
| 71 | bool generate_block(track_info *t, UINT32 idx, UINT32 ipos, std::vector<UINT32> &track, UINT32 &pos, UINT32 &dpos, UINT32 &gpos, UINT32 &spos, bool &context); | |
| 72 | 72 | UINT32 block_compute_real_size(track_info *t); |
| 73 | 73 | |
| 74 | void timing_set(UINT32 *track, UINT32 start, UINT32 end, UINT32 time); | |
| 75 | bool generate_timings(track_info *t, UINT32 *track, const UINT32 *data_pos, const UINT32 *gap_pos); | |
| 74 | void timing_set(std::vector<UINT32> &track, UINT32 start, UINT32 end, UINT32 time); | |
| 75 | bool generate_timings(track_info *t, std::vector<UINT32> &track, const std::vector<UINT32> &data_pos, const std::vector<UINT32> &gap_pos); | |
| 76 | 76 | |
| 77 | void rotate(UINT32 *track, UINT32 offset, UINT32 size); | |
| 78 | void mark_track_splice(UINT32 *track, UINT32 offset, UINT32 size); | |
| 77 | void rotate(std::vector<UINT32> &track, UINT32 offset, UINT32 size); | |
| 78 | void mark_track_splice(std::vector<UINT32> &track, UINT32 offset, UINT32 size); | |
| 79 | 79 | bool generate_track(track_info *t, floppy_image *image); |
| 80 | 80 | bool generate_tracks(floppy_image *image); |
| 81 | 81 | |
| 82 | bool parse( | |
| 82 | bool parse(dynamic_buffer &data, floppy_image *image); | |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | 85 | extern const floppy_format_type FLOPPY_IPF_FORMAT; |
| r245687 | r245688 | |
|---|---|---|
| 215 | 215 | dynamic_buffer sss(kc_image_size + 11); |
| 216 | 216 | |
| 217 | 217 | // tries to generate the missing head |
| 218 | memset(sss + 0, 0xd3, 3); | |
| 219 | memset(sss + 3, 0x20, 8); | |
| 220 | memcpy(sss + 11, casdata, kc_image_size); | |
| 218 | memset(&sss[0], 0xd3, 3); | |
| 219 | memset(&sss[3], 0x20, 8); | |
| 220 | memcpy(&sss[11], casdata, kc_image_size); | |
| 221 | 221 | |
| 222 | 222 | // set an arbitrary filename |
| 223 | 223 | sss[3] = 'A'; |
| 224 | 224 | |
| 225 | int retval = kc_handle_cass(buffer, sss, KC_IMAGE_KCC); | |
| 225 | int retval = kc_handle_cass(buffer, &sss[0], KC_IMAGE_KCC); | |
| 226 | 226 | |
| 227 | 227 | return retval; |
| 228 | 228 | } |
| r245687 | r245688 | |
|---|---|---|
| 128 | 128 | |
| 129 | 129 | if(ent->uncompressed_size == 0) { |
| 130 | 130 | // Unformatted track |
| 131 | image-> | |
| 131 | image->get_buffer(cyl >> 2, head, cyl & 3).clear(); | |
| 132 | 132 | ent++; |
| 133 | 133 | continue; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | compressed.resize(ent->compressed_size); |
| 137 | 137 | |
| 138 | io_generic_read(io, compressed, ent->offset, ent->compressed_size); | |
| 138 | io_generic_read(io, &compressed[0], ent->offset, ent->compressed_size); | |
| 139 | 139 | |
| 140 | 140 | unsigned int cell_count = ent->uncompressed_size/4; |
| 141 | image->set_track_size(cyl >> 2, head, cell_count, cyl & 3); | |
| 142 | UINT32 *trackbuf = image->get_buffer(cyl >> 2, head, cyl & 3); | |
| 141 | std::vector<UINT32> &trackbuf = image->get_buffer(cyl >> 2, head, cyl & 3);; | |
| 142 | trackbuf.resize(cell_count); | |
| 143 | 143 | |
| 144 | 144 | uLongf size = ent->uncompressed_size; |
| 145 | if(uncompress((Bytef *)trackbuf, &size, compressed, ent->compressed_size) != Z_OK) | |
| 145 | if(uncompress((Bytef *)&trackbuf[0], &size, &compressed[0], ent->compressed_size) != Z_OK) | |
| 146 | 146 | return false; |
| 147 | 147 | |
| 148 | 148 | UINT32 cur_time = 0; |
| r245687 | r245688 | |
| 168 | 168 | int max_track_size = 0; |
| 169 | 169 | for(int track=0; track <= (tracks-1) << 2; track += 4 >> resolution) |
| 170 | 170 | for(int head=0; head<heads; head++) { |
| 171 | int tsize = image->get_ | |
| 171 | int tsize = image->get_buffer(track >> 2, head, track & 3).size(); | |
| 172 | 172 | if(tsize > max_track_size) |
| 173 | 173 | max_track_size = tsize; |
| 174 | 174 | } |
| r245687 | r245688 | |
| 192 | 192 | |
| 193 | 193 | for(int track=0; track <= (tracks-1) << 2; track += 4 >> resolution) |
| 194 | 194 | for(int head=0; head<heads; head++) { |
| 195 | int tsize = image->get_track_size(track >> 2, head, track & 3); | |
| 195 | std::vector<UINT32> &buffer = image->get_buffer(track >> 2, head, track & 3); | |
| 196 | int tsize = buffer.size(); | |
| 196 | 197 | if(!tsize) { |
| 197 | 198 | epos++; |
| 198 | 199 | continue; |
| 199 | 200 | } |
| 200 | 201 | |
| 201 | memcpy(precomp, | |
| 202 | memcpy(precomp, &buffer[0], tsize*4); | |
| 202 | 203 | for(int j=0; j<tsize-1; j++) |
| 203 | 204 | precomp[j] = (precomp[j] & floppy_image::MG_MASK) | |
| 204 | 205 | ((precomp[j+1] & floppy_image::TIME_MASK) - |
| r245687 | r245688 | |
|---|---|---|
| 58 | 58 | { |
| 59 | 59 | UINT8 h[256]; |
| 60 | 60 | UINT8 t[6250+3]; |
| 61 | UINT32 stream[100000]; | |
| 62 | 61 | |
| 63 | 62 | t[6250] = t[6251] = t[6252] = 0; |
| 64 | 63 | io_generic_read(io, h, 0, 256); |
| r245687 | r245688 | |
| 69 | 68 | for(int side=0; side<sides; side++) |
| 70 | 69 | for(int track=0; track<tracks; track++) { |
| 71 | 70 | io_generic_read(io, t, 256+6400*(tracks*side + track), 6250); |
| 72 | | |
| 71 | std::vector<UINT32> stream; | |
| 73 | 72 | int sector_size = 128; |
| 74 | 73 | for(int i=0; i<6250; i++) { |
| 75 | 74 | if(t[i] == 0xc2 && t[i+1] == 0xc2 && t[i+2] == 0xc2) { |
| 76 | raw_w(stream, pos, 16, 0x5224); | |
| 77 | raw_w(stream, pos, 16, 0x5224); | |
| 78 | raw_w(stream, pos, 16, 0x5224); | |
| 75 | raw_w(stream, 16, 0x5224); | |
| 76 | raw_w(stream, 16, 0x5224); | |
| 77 | raw_w(stream, 16, 0x5224); | |
| 79 | 78 | i += 2; |
| 80 | 79 | continue; |
| 81 | 80 | } |
| 82 | 81 | if(t[i] == 0xa1 && t[i+1] == 0xa1 && t[i+2] == 0xa1) { |
| 83 | raw_w(stream, pos, 16, 0x4489); | |
| 84 | raw_w(stream, pos, 16, 0x4489); | |
| 85 | raw_w(stream, pos, 16, 0x4489); | |
| 82 | raw_w(stream, 16, 0x4489); | |
| 83 | raw_w(stream, 16, 0x4489); | |
| 84 | raw_w(stream, 16, 0x4489); | |
| 86 | 85 | int copy; |
| 87 | 86 | if(t[i+3] == 0xfe) { |
| 88 | 87 | copy = 7; |
| 89 | 88 | sector_size = 128 << (t[i+7] & 3); |
| 90 | logerror("%02x %x - %02x %02x %02x %02x\n", | |
| 91 | track, side, t[i+4], t[i+5], t[i+6], t[i+7]); | |
| 92 | 89 | } else if(t[i+3] == 0xfb) |
| 93 | 90 | copy = sector_size+3; |
| 94 | 91 | else |
| 95 | 92 | copy = 0; |
| 96 | 93 | for(int j=0; j<copy; j++) |
| 97 | mfm_w(stream, | |
| 94 | mfm_w(stream, 8, t[i+3+j]); | |
| 98 | 95 | i += 2+copy; |
| 99 | 96 | continue; |
| 100 | 97 | } |
| 101 | mfm_w(stream, | |
| 98 | mfm_w(stream, 8, t[i]); | |
| 102 | 99 | } |
| 103 | generate_track_from_levels(track, side, stream, | |
| 100 | generate_track_from_levels(track, side, stream, 0, image); | |
| 104 | 101 | } |
| 105 | 102 | |
| 106 | 103 | return true; |
| r245687 | r245688 | |
|---|---|---|
| 86 | 86 | |
| 87 | 87 | raw_track.resize(entry_len-16); |
| 88 | 88 | |
| 89 | io_generic_read(io, raw_track, pos+16, entry_len-16); | |
| 89 | io_generic_read(io, &raw_track[0], pos+16, entry_len-16); | |
| 90 | 90 | |
| 91 | UINT8 *fuzz = fuzz_len ? raw_track+16*sect : 0; | |
| 92 | UINT8 *bdata = fuzz ? fuzz+fuzz_len : raw_track+16*sect; | |
| 91 | UINT8 *fuzz = fuzz_len ? &raw_track[16*sect] : 0; | |
| 92 | UINT8 *bdata = fuzz ? fuzz+fuzz_len : &raw_track[16*sect]; | |
| 93 | 93 | UINT8 *tdata = bdata; |
| 94 | 94 | |
| 95 | 95 | int syncpos = -1; |
| r245687 | r245688 | |
| 109 | 109 | printf("Track %2d.%d: el=%d fl=%d sect=%d flags=%04x tlen=%d/%d tnum=%d flags2=%02x sync=%x\n", |
| 110 | 110 | track, head, |
| 111 | 111 | entry_len, fuzz_len, sect, flags, track_len, tsize, track_num, flags2, syncpos); |
| 112 | hexdump(raw_track | |
| 112 | hexdump(&raw_track[16*sect], entry_len-16-16*sect); | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if(0 && tdata) { |
| r245687 | r245688 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | for(int s=0; s<sect; s++) { |
| 127 | UINT8 *sh = raw_track | |
| 127 | UINT8 *sh = &raw_track[16*s]; | |
| 128 | 128 | int s_off = sh[0] | (sh[1] << 8) | (sh[2] << 16) | (sh[3] << 24); |
| 129 | 129 | int s_pos = sh[4] | (sh[5] << 8); |
| 130 | 130 | int s_time = sh[6] | (sh[7] << 8); |
| r245687 | r245688 | |
| 168 | 168 | wd_generate_track_from_sectors_and_track(track, head, image, obs); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | void pasti_format::wd_generate_unsynced_gap(UINT32 | |
| 171 | void pasti_format::wd_generate_unsynced_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, UINT32 cell_size) | |
| 172 | 172 | { |
| 173 | 173 | for(int i=tstart; i != tend;) { |
| 174 | 174 | unsigned char v = obs.track_data[i]; |
| r245687 | r245688 | |
| 176 | 176 | for(j=i+1; j != tend && obs.track_data[j] == v; j++); |
| 177 | 177 | int size = j-i; |
| 178 | 178 | if(size < 4) { |
| 179 | mfm_w(track, | |
| 179 | mfm_w(track, 8, v, cell_size); | |
| 180 | 180 | i++; |
| 181 | 181 | continue; |
| 182 | 182 | } |
| r245687 | r245688 | |
| 189 | 189 | if((v == 0 || v == 0x4e) && j != tend) |
| 190 | 190 | size++; |
| 191 | 191 | for(j=0; j != size; j++) |
| 192 | mfm_w(track, | |
| 192 | mfm_w(track, 8, v, cell_size); | |
| 193 | 193 | i += size; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | void pasti_format::wd_generate_synced_gap(UINT32 | |
| 197 | void pasti_format::wd_generate_synced_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, UINT32 cell_size) | |
| 198 | 198 | { |
| 199 | 199 | for(int i = tstart; i != tend; i++) { |
| 200 | 200 | unsigned char v = obs.track_data[i]; |
| 201 | 201 | if((v == 0x14 || v == 0xa1 || v == 0xc2) && i+2 < tend && obs.track_data[i+1] == 0xa1 && obs.track_data[i+2] == 0xa1) { |
| 202 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 203 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 204 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 202 | raw_w(track, 16, 0x4489, cell_size); | |
| 203 | raw_w(track, 16, 0x4489, cell_size); | |
| 204 | raw_w(track, 16, 0x4489, cell_size); | |
| 205 | 205 | i += 2; |
| 206 | } else if(pos && i != tend-1 && (((v == 0x14 || v == 0xc2) && (track[pos-1] & 0x1f) == 10) || (v == 0xa1 && (track[pos-1] & 0x1f) != 10))) | |
| 207 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 206 | } else if(!track.empty() && i != tend-1 && (((v == 0x14 || v == 0xc2) && (track.back() & 0x1f) == 10) || (v == 0xa1 && (track.back() & 0x1f) != 10))) | |
| 207 | raw_w(track, 16, 0x4489, cell_size); | |
| 208 | 208 | else if(i != tend-1 && (v == 0x14 || v == 0xc2)) |
| 209 | raw_w(track, | |
| 209 | raw_w(track, 16, 0x5224, cell_size); | |
| 210 | 210 | else |
| 211 | mfm_w(track, | |
| 211 | mfm_w(track, 8, v, cell_size); | |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | void pasti_format::wd_generate_gap(UINT32 | |
| 215 | void pasti_format::wd_generate_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, bool synced, UINT32 cell_size_start, UINT32 cell_size_end) | |
| 216 | 216 | { |
| 217 | int spos = | |
| 217 | unsigned int spos = track.size(); | |
| 218 | 218 | if(!synced) { |
| 219 | 219 | int sync = -1; |
| 220 | 220 | for(int i = tstart; sync == -1 && i != tend; i++) |
| r245687 | r245688 | |
| 222 | 222 | sync = i; |
| 223 | 223 | if(sync == -1) |
| 224 | 224 | sync = tend; |
| 225 | wd_generate_unsynced_gap(track, | |
| 225 | wd_generate_unsynced_gap(track, obs, tstart, sync, cell_size_start); | |
| 226 | 226 | tstart = sync; |
| 227 | 227 | } |
| 228 | 228 | if(tstart != tend) |
| 229 | wd_generate_synced_gap(track, | |
| 229 | wd_generate_synced_gap(track, obs, tstart, tend, cell_size_start); | |
| 230 | 230 | |
| 231 | 231 | if(cell_size_end != cell_size_start) { |
| 232 | 232 | INT32 total_size = 0; |
| 233 | for(int i=spos; i != | |
| 233 | for(unsigned int i=spos; i != track.size(); i++) | |
| 234 | 234 | total_size += track[i] & floppy_image::TIME_MASK; |
| 235 | 235 | INT64 cur_size = 0; |
| 236 | for(int i=spos; i != | |
| 236 | for(unsigned int i=spos; i != track.size(); i++) { | |
| 237 | 237 | cur_size += track[i] & floppy_image::TIME_MASK; |
| 238 | 238 | track[i] = (track[i] & floppy_image::MG_MASK) | |
| 239 | 239 | (cur_size*int(cell_size_end-cell_size_start)/total_size + cell_size_start); |
| r245687 | r245688 | |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | void pasti_format::wd_generate_sector_header(UINT32 | |
| 244 | void pasti_format::wd_generate_sector_header(std::vector<UINT32> &track, const wd_obs &obs, int sector, int tstart, UINT32 cell_size) | |
| 245 | 245 | { |
| 246 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 247 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 248 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 249 | mfm_w(track, pos, 8, obs.track_data[tstart+3], cell_size); | |
| 246 | raw_w(track, 16, 0x4489, cell_size); | |
| 247 | raw_w(track, 16, 0x4489, cell_size); | |
| 248 | raw_w(track, 16, 0x4489, cell_size); | |
| 249 | mfm_w(track, 8, obs.track_data[tstart+3], cell_size); | |
| 250 | 250 | for(int i=0; i != 6; i++) |
| 251 | mfm_w(track, | |
| 251 | mfm_w(track, 8, obs.sectors[sector].id[i], cell_size); | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | void pasti_format::wd_generate_sector_data(UINT32 | |
| 254 | void pasti_format::wd_generate_sector_data(std::vector<UINT32> &track, const wd_obs &obs, int sector, int tstart, UINT32 cell_size) | |
| 255 | 255 | { |
| 256 | 256 | const wd_sect &s = obs.sectors[sector]; |
| 257 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 258 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 259 | raw_w(track, pos, 16, 0x4489, cell_size); | |
| 260 | mfm_w(track, pos, 8, obs.track_data[tstart+3], cell_size); | |
| 257 | raw_w(track, 16, 0x4489, cell_size); | |
| 258 | raw_w(track, 16, 0x4489, cell_size); | |
| 259 | raw_w(track, 16, 0x4489, cell_size); | |
| 260 | mfm_w(track, 8, obs.track_data[tstart+3], cell_size); | |
| 261 | 261 | for(int i=0; i<128 << (s.id[3] & 3); i++) |
| 262 | mfm_w(track, pos, 8, s.data[i], cell_size); | |
| 263 | UINT16 crc = calc_crc_ccitt(track, pos - (2048 << (s.id[3] & 3)) - 16*4, pos); | |
| 264 | mfm_w(track, pos, 8, crc >> 8, cell_size); | |
| 265 | mfm_w(track, pos, 8, crc, cell_size); | |
| 262 | mfm_w(track, 8, s.data[i], cell_size); | |
| 263 | UINT16 crc = calc_crc_ccitt(track, track.size() - (2048 << (s.id[3] & 3)) - 16*4, track.size()); | |
| 264 | mfm_w(track, 8, crc >> 8, cell_size); | |
| 265 | mfm_w(track, 8, crc, cell_size); | |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | void pasti_format::wd_generate_track_from_sectors_and_track(int track, int head, floppy_image *image, wd_obs &obs) |
| 269 | 269 | { |
| 270 | 270 | if(0) |
| 271 | 271 | printf("Track %d head %d sectors %d\n", track, head, obs.sector_count); |
| 272 | dynamic_array<UINT32> trackbuf(200000); | |
| 273 | int pos = 0; | |
| 272 | std::vector<UINT32> trackbuf; | |
| 274 | 273 | |
| 275 | 274 | wd_sect_info sect_infos[256]; |
| 276 | 275 | |
| r245687 | r245688 | |
| 306 | 305 | } |
| 307 | 306 | |
| 308 | 307 | UINT32 cell_size = UINT32(obs.sectors[0].time_ratio * 1000+0.5); |
| 309 | wd_generate_gap(trackbuf, | |
| 308 | wd_generate_gap(trackbuf, obs, 0, sect_infos[0].hstart, false, cell_size, cell_size); | |
| 310 | 309 | |
| 311 | 310 | for(int i=0; i != obs.sector_count; i++) { |
| 312 | 311 | wd_sect_info *s = sect_infos + i; |
| r245687 | r245688 | |
| 319 | 318 | |
| 320 | 319 | UINT32 ncell_size = UINT32(obs.sectors[i+1 != obs.sector_count ? i+1 : 0].time_ratio * 1000+0.5); |
| 321 | 320 | |
| 322 | wd_generate_sector_header(trackbuf, | |
| 321 | wd_generate_sector_header(trackbuf, obs, i, s->hstart, cell_size); | |
| 323 | 322 | |
| 324 | 323 | if(s->dstart == -1) { |
| 325 | 324 | if(i == obs.sector_count-1) |
| 326 | wd_generate_gap(trackbuf, | |
| 325 | wd_generate_gap(trackbuf, obs, s->hend, obs.track_size, s->hsynced, cell_size, ncell_size); | |
| 327 | 326 | else |
| 328 | wd_generate_gap(trackbuf, | |
| 327 | wd_generate_gap(trackbuf, obs, s->hend, s[1].hstart, s->hsynced, cell_size, ncell_size); | |
| 329 | 328 | } else { |
| 330 | wd_generate_gap(trackbuf, pos, obs, s->hend, s->dstart, s->hsynced, cell_size, cell_size); | |
| 331 | wd_generate_sector_data(trackbuf, pos, obs, i, s->dstart, cell_size); | |
| 329 | wd_generate_gap(trackbuf, obs, s->hend, s->dstart, s->hsynced, cell_size, cell_size); | |
| 330 | wd_generate_sector_data(trackbuf, obs, i, s->dstart, cell_size); | |
| 332 | 331 | if(i == obs.sector_count-1) |
| 333 | wd_generate_gap(trackbuf, | |
| 332 | wd_generate_gap(trackbuf, obs, s->dend, obs.track_size, s->dsynced, cell_size, ncell_size); | |
| 334 | 333 | else |
| 335 | wd_generate_gap(trackbuf, | |
| 334 | wd_generate_gap(trackbuf, obs, s->dend, s[1].hstart, s->dsynced, cell_size, ncell_size); | |
| 336 | 335 | } |
| 337 | 336 | cell_size = ncell_size; |
| 338 | 337 | } |
| 339 | 338 | |
| 340 | 339 | } else |
| 341 | wd_generate_gap(trackbuf, | |
| 340 | wd_generate_gap(trackbuf, obs, 0, obs.track_size, false, 1000, 1000); | |
| 342 | 341 | |
| 343 | generate_track_from_levels(track, head, trackbuf, | |
| 342 | generate_track_from_levels(track, head, trackbuf, 0, image); | |
| 344 | 343 | } |
| 345 | 344 | |
| 346 | 345 | void pasti_format::wd_generate_track_from_sectors_only(int track, int head, floppy_image *image, wd_obs &obs) |
| r245687 | r245688 | |
| 360 | 359 | } |
| 361 | 360 | } |
| 362 | 361 | |
| 363 | UINT32 *tdata = global_alloc_array(UINT32, 200000); | |
| 364 | int pos = 0; | |
| 362 | std::vector<UINT32> tdata; | |
| 365 | 363 | for(int i=0; i != obs.sector_count; i++) { |
| 366 | 364 | const wd_sect &s = obs.sectors[i]; |
| 367 | 365 | if(i+1 != obs.sector_count && obs.sectors[i+1].position < s.position+10+44+4+(128 << (s.id[3] & 3))) { |
| 368 | 366 | logerror("pasti: Unsupported sector data sharing, track %d head %d\n", track, head); |
| 369 | 367 | return; |
| 370 | 368 | } |
| 371 | if(pos >> 4 < s.position - 12) { | |
| 372 | int count = s.position - 12 - (pos >> 4); | |
| 369 | if(tdata.size() >> 4 < s.position - 12) { | |
| 370 | int count = s.position - 12 - (tdata.size() >> 4); | |
| 373 | 371 | if(count & 1) { |
| 374 | mfm_w(tdata, | |
| 372 | mfm_w(tdata, 8, 0x4e); | |
| 375 | 373 | count--; |
| 376 | 374 | } |
| 377 | 375 | for(int j=0; j<count; j+=2) |
| 378 | mfm_w(tdata, | |
| 376 | mfm_w(tdata, 8, 0x4e); | |
| 379 | 377 | } |
| 380 | if(pos < s.position*16) { | |
| 381 | int count = s.position - (pos >> 4); | |
| 378 | if(tdata.size() < s.position*16) { | |
| 379 | int count = s.position - (tdata.size() >> 4); | |
| 382 | 380 | if(count & 1) { |
| 383 | mfm_w(tdata, | |
| 381 | mfm_w(tdata, 8, 0x00); | |
| 384 | 382 | count--; |
| 385 | 383 | } |
| 386 | 384 | for(int j=0; j<count; j+=2) |
| 387 | mfm_w(tdata, | |
| 385 | mfm_w(tdata, 8, 0x00); | |
| 388 | 386 | } |
| 389 | raw_w(tdata, pos, 16, 0x4489); | |
| 390 | raw_w(tdata, pos, 16, 0x4489); | |
| 391 | raw_w(tdata, pos, 16, 0x4489); | |
| 392 | mfm_w(tdata, pos, 8, 0xfe); | |
| 387 | raw_w(tdata, 16, 0x4489); | |
| 388 | raw_w(tdata, 16, 0x4489); | |
| 389 | raw_w(tdata, 16, 0x4489); | |
| 390 | mfm_w(tdata, 8, 0xfe); | |
| 393 | 391 | for(int j=0; j<6; j++) |
| 394 | mfm_w(tdata, | |
| 392 | mfm_w(tdata, 8, s.id[j]); | |
| 395 | 393 | |
| 396 | 394 | if(!s.data) |
| 397 | 395 | continue; |
| 398 | 396 | |
| 399 | 397 | for(int j=0; j<22; j++) |
| 400 | mfm_w(tdata, | |
| 398 | mfm_w(tdata, 8, 0x4e); | |
| 401 | 399 | for(int j=0; j<12; j++) |
| 402 | mfm_w(tdata, | |
| 400 | mfm_w(tdata, 8, 0x00); | |
| 403 | 401 | |
| 404 | raw_w(tdata, pos, 16, 0x4489); | |
| 405 | raw_w(tdata, pos, 16, 0x4489); | |
| 406 | raw_w(tdata, pos, 16, 0x4489); | |
| 407 | mfm_w(tdata, pos, 8, 0xfb); | |
| 402 | raw_w(tdata, 16, 0x4489); | |
| 403 | raw_w(tdata, 16, 0x4489); | |
| 404 | raw_w(tdata, 16, 0x4489); | |
| 405 | mfm_w(tdata, 8, 0xfb); | |
| 408 | 406 | for(int j=0; j<128 << (s.id[3] & 3); j++) |
| 409 | mfm_w(tdata, pos, 8, s.data[j]); | |
| 410 | UINT16 crc = calc_crc_ccitt(tdata, pos - (2048 << (s.id[3] & 3)) - 16*4, pos); | |
| 411 | mfm_w(tdata, pos, 8, crc >> 8); | |
| 412 | mfm_w(tdata, pos, 8, crc); | |
| 407 | mfm_w(tdata, 8, s.data[j]); | |
| 408 | UINT16 crc = calc_crc_ccitt(tdata, tdata.size() - (2048 << (s.id[3] & 3)) - 16*4, tdata.size()); | |
| 409 | mfm_w(tdata, 8, crc >> 8); | |
| 410 | mfm_w(tdata, 8, crc); | |
| 413 | 411 | } |
| 414 | 412 | |
| 415 | int count = (100015 - | |
| 413 | int count = (100015 - tdata.size()) >> 16; | |
| 416 | 414 | for(int i=0; i<count; i++) |
| 417 | mfm_w(tdata, | |
| 415 | mfm_w(tdata, 8, 0x4e); | |
| 418 | 416 | |
| 419 | generate_track_from_levels(track, head, tdata, | |
| 417 | generate_track_from_levels(track, head, tdata, 0, image); | |
| 420 | 418 | } |
| 421 | 419 | |
| 422 | 420 | UINT16 pasti_format::byte_to_mfm(UINT8 data, bool context) |
| r245687 | r245688 | |
|---|---|---|
| 48 | 48 | UINT16 byte_to_mfm(UINT8 data, bool context); |
| 49 | 49 | UINT16 calc_crc(const UINT8 *data, int size, UINT16 crc); |
| 50 | 50 | |
| 51 | void wd_generate_unsynced_gap(UINT32 *track, int &pos, const wd_obs &obs, int tstart, int tend, UINT32 cell_size); | |
| 52 | void wd_generate_synced_gap(UINT32 *track, int &pos, const wd_obs &obs, int tstart, int tend, UINT32 cell_size); | |
| 53 | void wd_generate_gap(UINT32 *track, int &pos, const wd_obs &obs, int tstart, int tend, bool synced, UINT32 cell_size_start, UINT32 cell_size_end); | |
| 54 | void wd_generate_sector_header(UINT32 *track, int &pos, const wd_obs &obs, int sector, int tstart, UINT32 cell_size); | |
| 55 | void wd_generate_sector_data(UINT32 *track, int &pos, const wd_obs &obs, int sector, int tstart, UINT32 cell_size); | |
| 51 | void wd_generate_unsynced_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, UINT32 cell_size); | |
| 52 | void wd_generate_synced_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, UINT32 cell_size); | |
| 53 | void wd_generate_gap(std::vector<UINT32> &track, const wd_obs &obs, int tstart, int tend, bool synced, UINT32 cell_size_start, UINT32 cell_size_end); | |
| 54 | void wd_generate_sector_header(std::vector<UINT32> &track, const wd_obs &obs, int sector, int tstart, UINT32 cell_size); | |
| 55 | void wd_generate_sector_data(std::vector<UINT32> &track, const wd_obs &obs, int sector, int tstart, UINT32 cell_size); | |
| 56 | 56 | void wd_generate_track_from_sectors_and_track(int track, int head, floppy_image *image, wd_obs &obs); |
| 57 | 57 | void wd_generate_track_from_sectors_only(int track, int head, floppy_image *image, wd_obs &obs); |
| 58 | 58 | }; |
| r245687 | r245688 | |
|---|---|---|
| 833 | 833 | disk_decode.floppy_file = io; |
| 834 | 834 | disk_decode.init_Decode(); |
| 835 | 835 | disk_decode.floppy_file_offset = 12; |
| 836 | disk_decode.Decode(imagebuf, max_size); | |
| 836 | disk_decode.Decode(&imagebuf[0], max_size); | |
| 837 | 837 | } |
| 838 | 838 | else |
| 839 | io_generic_read(io, imagebuf, 12, io_generic_size(io)); | |
| 839 | io_generic_read(io, &imagebuf[0], 12, io_generic_size(io)); | |
| 840 | 840 | |
| 841 | 841 | if(header[7] & 0x80) |
| 842 | 842 | offset = 10 + imagebuf[2] + (imagebuf[3] << 8); |
| r245687 | r245688 | |
|---|---|---|
| 284 | 284 | void ti99_floppy_format::generate_track_fm(int track, int head, int cell_size, UINT8* trackdata, floppy_image *image) |
| 285 | 285 | { |
| 286 | 286 | int track_size_cells = 200000000/cell_size; |
| 287 | UINT32 | |
| 287 | std::vector<UINT32> buffer; | |
| 288 | 288 | |
| 289 | 289 | // The TDF has a long track lead-out that makes the track length sum up |
| 290 | 290 | // to 3253; this is too long for the number of cells in the real track. |
| r245687 | r245688 | |
| 299 | 299 | |
| 300 | 300 | int track_size = track_size_cells / 16; |
| 301 | 301 | |
| 302 | int offset = 0; | |
| 303 | 302 | short crc1, crc2, found_crc; |
| 304 | 303 | int start = 16; |
| 305 | 304 | |
| 306 | 305 | if (check_for_address_marks(trackdata, floppy_image::FM)==false) |
| 307 | 306 | { |
| 308 | 307 | if (head==0 && track==0) logerror("ti99_dsk: Cannot find FM address marks on track %d, head %d; likely broken or unformatted.\n", track, head); |
| 309 | global_free_array(buffer); | |
| 310 | 308 | return; |
| 311 | 309 | } |
| 312 | 310 | |
| r245687 | r245688 | |
| 323 | 321 | if (((i-start-6)%334==0) && (i < start + 9*334)) |
| 324 | 322 | { |
| 325 | 323 | // IDAM |
| 326 | raw_w(buffer, | |
| 324 | raw_w(buffer, 16, 0xf57e); | |
| 327 | 325 | } |
| 328 | 326 | else |
| 329 | 327 | { |
| 330 | 328 | if (((i-start-30)%334==0) && (i < start + 9*334)) |
| 331 | 329 | { |
| 332 | 330 | // DAM |
| 333 | raw_w(buffer, | |
| 331 | raw_w(buffer, 16, 0xf56f); | |
| 334 | 332 | } |
| 335 | 333 | else |
| 336 | 334 | { |
| r245687 | r245688 | |
| 374 | 372 | } |
| 375 | 373 | } |
| 376 | 374 | } |
| 377 | fm_w(buffer, | |
| 375 | fm_w(buffer, 8, trackdata[i]); | |
| 378 | 376 | } |
| 379 | 377 | } |
| 380 | 378 | } |
| 381 | 379 | |
| 382 | generate_track_from_levels(track, head, buffer, track_size_cells, 0, image); | |
| 383 | ||
| 384 | global_free_array(buffer); | |
| 380 | generate_track_from_levels(track, head, buffer, 0, image); | |
| 385 | 381 | } |
| 386 | 382 | |
| 387 | 383 | void ti99_floppy_format::generate_track_mfm(int track, int head, int cell_size, UINT8* trackdata, floppy_image *image) |
| 388 | 384 | { |
| 389 | 385 | int track_size_cells = 200000000/cell_size; |
| 390 | UINT32 | |
| 386 | std::vector<UINT32> buffer; | |
| 391 | 387 | |
| 392 | 388 | // See above |
| 393 | 389 | // We limit the track size to cell_number / 16, which means 6250 for MFM |
| r245687 | r245688 | |
| 395 | 391 | // (not 712 as specified in the TDF format) |
| 396 | 392 | int track_size = track_size_cells / 16; |
| 397 | 393 | |
| 398 | int offset = 0; | |
| 399 | 394 | short crc1, crc2, found_crc; |
| 400 | 395 | int start = 40; |
| 401 | 396 | |
| 402 | 397 | if (check_for_address_marks(trackdata, floppy_image::MFM)==false) |
| 403 | 398 | { |
| 404 | 399 | if (track==0 && head==0) logerror("ti99_dsk: Cannot find MFM address marks on track %d, head %d; likely broken or unformatted.\n", track, head); |
| 405 | global_free_array(buffer); | |
| 406 | 400 | return; |
| 407 | 401 | } |
| 408 | 402 | |
| r245687 | r245688 | |
| 420 | 414 | { |
| 421 | 415 | // IDAM |
| 422 | 416 | for (int j=0; j < 3; j++) |
| 423 | raw_w(buffer, offset, 16, 0x4489); // 3 times A1 | |
| 424 | mfm_w(buffer, offset, 8, 0xfe); | |
| 417 | raw_w(buffer, 16, 0x4489); // 3 times A1 | |
| 418 | mfm_w(buffer, 8, 0xfe); | |
| 425 | 419 | i += 3; |
| 426 | 420 | } |
| 427 | 421 | else |
| r245687 | r245688 | |
| 430 | 424 | { |
| 431 | 425 | // DAM |
| 432 | 426 | for (int j=0; j < 3; j++) |
| 433 | raw_w(buffer, offset, 16, 0x4489); // 3 times A1 | |
| 434 | mfm_w(buffer, offset, 8, 0xfb); | |
| 427 | raw_w(buffer, 16, 0x4489); // 3 times A1 | |
| 428 | mfm_w(buffer, 8, 0xfb); | |
| 435 | 429 | i += 3; |
| 436 | 430 | } |
| 437 | 431 | else |
| r245687 | r245688 | |
| 476 | 470 | } |
| 477 | 471 | } |
| 478 | 472 | } |
| 479 | mfm_w(buffer, | |
| 473 | mfm_w(buffer, 8, trackdata[i]); | |
| 480 | 474 | } |
| 481 | 475 | } |
| 482 | 476 | } |
| 483 | 477 | |
| 484 | generate_track_from_levels(track, head, buffer, track_size_cells, 0, image); | |
| 485 | ||
| 486 | global_free_array(buffer); | |
| 478 | generate_track_from_levels(track, head, buffer, 0, image); | |
| 487 | 479 | } |
| 488 | 480 | |
| 489 | 481 | // States for decoding the bitstream |
| r245687 | r245688 | |
| 2551 | 2543 | imgtrack = track / 2; |
| 2552 | 2544 | } |
| 2553 | 2545 | |
| 2554 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size); | |
| 2546 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, &track_data[0], tag->track_size); | |
| 2555 | 2547 | if (err) |
| 2556 | 2548 | return err; |
| 2557 | 2549 | |
| 2558 | err = ti99_tdf_seek_sector_in_track(floppy, head, imgtrack, sector, track_data, §or_data); | |
| 2550 | err = ti99_tdf_seek_sector_in_track(floppy, head, imgtrack, sector, &track_data[0], §or_data); | |
| 2559 | 2551 | if (err) |
| 2560 | 2552 | return err; |
| 2561 | 2553 | /* verify CRC? */ |
| r245687 | r245688 | |
| 2635 | 2627 | imgtrack = track / 2; |
| 2636 | 2628 | } |
| 2637 | 2629 | |
| 2638 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size); | |
| 2630 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, &track_data[0], tag->track_size); | |
| 2639 | 2631 | if (err) |
| 2640 | 2632 | { |
| 2641 | 2633 | return err; |
| r245687 | r245688 | |
| 2644 | 2636 | /* Search for the sector_index-th sector. */ |
| 2645 | 2637 | if (tag->first_idam==0) /* should we check for every track? */ |
| 2646 | 2638 | { |
| 2647 | if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2639 | if (determine_offset(tag->format, &track_data[0], &tag->first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2648 | 2640 | { |
| 2649 | 2641 | return FLOPPY_ERROR_SEEKERROR; |
| 2650 | 2642 | } |
| r245687 | r245688 | |
| 2654 | 2646 | i=0; |
| 2655 | 2647 | while (i < tag->track_size && sector_index>=0) |
| 2656 | 2648 | { |
| 2657 | byte = read_byte(tag->format, tag->first_idam, track_data, i); | |
| 2649 | byte = read_byte(tag->format, tag->first_idam, &track_data[0], i); | |
| 2658 | 2650 | if (byte == TI99_IDAM) |
| 2659 | 2651 | { |
| 2660 | 2652 | sector_index--; |
| r245687 | r245688 | |
| 2672 | 2664 | /* Find the DAM. */ |
| 2673 | 2665 | while (i < tag->track_size) |
| 2674 | 2666 | { |
| 2675 | byte = read_byte(tag->format, tag->first_idam, track_data, i); | |
| 2667 | byte = read_byte(tag->format, tag->first_idam, &track_data[0], i); | |
| 2676 | 2668 | if (byte == TI99_DAM) |
| 2677 | 2669 | break; |
| 2678 | 2670 | else |
| r245687 | r245688 | |
| 2693 | 2685 | if (err) |
| 2694 | 2686 | return err; |
| 2695 | 2687 | |
| 2696 | offset = track_offset + (sector_data - track_data); | |
| 2688 | offset = track_offset + (sector_data - &track_data[0]); | |
| 2697 | 2689 | |
| 2698 | 2690 | /* Write the sector data at that position. */ |
| 2699 | 2691 | floppy_image_write(floppy, buffer, offset, SECTOR_SIZE); |
| r245687 | r245688 | |
| 2725 | 2717 | imgtrack = track / 2; |
| 2726 | 2718 | } |
| 2727 | 2719 | |
| 2728 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size); | |
| 2720 | err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, &track_data[0], tag->track_size); | |
| 2729 | 2721 | if (err) |
| 2730 | 2722 | { |
| 2731 | 2723 | return err; |
| r245687 | r245688 | |
| 2735 | 2727 | |
| 2736 | 2728 | if (tag->first_idam==0) /* should we check for every track? */ |
| 2737 | 2729 | { |
| 2738 | if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2730 | if (determine_offset(tag->format, &track_data[0], &tag->first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2739 | 2731 | { |
| 2740 | 2732 | return FLOPPY_ERROR_SEEKERROR; |
| 2741 | 2733 | } |
| r245687 | r245688 | |
| 2745 | 2737 | sector_index = sector_index+1; |
| 2746 | 2738 | while (i++ < tag->track_size && sector_index>0) |
| 2747 | 2739 | { |
| 2748 | byte = read_byte(tag->format, tag->first_idam, track_data, i); | |
| 2740 | byte = read_byte(tag->format, tag->first_idam, &track_data[0], i); | |
| 2749 | 2741 | if (byte == TI99_IDAM) |
| 2750 | 2742 | { |
| 2751 | 2743 | sector_index--; |
| r245687 | r245688 | |
| 2788 | 2780 | { |
| 2789 | 2781 | while (i++ < tag->track_size) |
| 2790 | 2782 | { |
| 2791 | byte = read_byte(tag->format, tag->first_idam, track_data, i); | |
| 2783 | byte = read_byte(tag->format, tag->first_idam, &track_data[0], i); | |
| 2792 | 2784 | if (byte == TI99_DAM) |
| 2793 | 2785 | break; |
| 2794 | 2786 | } |
| r245687 | r245688 | |
| 2866 | 2858 | else |
| 2867 | 2859 | geometry = &dummy_geometry; |
| 2868 | 2860 | |
| 2869 | floppy_image_read(floppy, track_data, 0, 13000); | |
| 2861 | floppy_image_read(floppy, &track_data[0], 0, 13000); | |
| 2870 | 2862 | |
| 2871 | if (determine_offset(TI99_MFM, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2863 | if (determine_offset(TI99_MFM, &track_data[0], &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2872 | 2864 | { |
| 2873 | 2865 | /* MFM failed. */ |
| 2874 | if (determine_offset(TI99_FM, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2866 | if (determine_offset(TI99_FM, &track_data[0], &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 2875 | 2867 | { |
| 2876 | 2868 | LOG_FORMATS("IDAM not found. Unformatted disk.\n"); |
| 2877 | 2869 | |
| r245687 | r245688 | |
| 2976 | 2968 | |
| 2977 | 2969 | while (i++ < 13000 && head == 0 && track == 0) |
| 2978 | 2970 | { |
| 2979 | byte = read_byte(format, first_idam, track_data, i); | |
| 2971 | byte = read_byte(format, first_idam, &track_data[0], i); | |
| 2980 | 2972 | switch (state) |
| 2981 | 2973 | { |
| 2982 | 2974 | case 0: |
| r245687 | r245688 | |
| 3016 | 3008 | // head 0 or for head 1. |
| 3017 | 3009 | |
| 3018 | 3010 | geometry->sides = 1; |
| 3019 | floppy_image_read(floppy, track_data, size-tracklength, tracklength); | |
| 3020 | if (determine_offset(format, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 3011 | floppy_image_read(floppy, &track_data[0], size-tracklength, tracklength); | |
| 3012 | if (determine_offset(format, &track_data[0], &first_idam)==FLOPPY_ERROR_SEEKERROR) | |
| 3021 | 3013 | { |
| 3022 | 3014 | /* error ... what now? */ |
| 3023 | 3015 | LOG_FORMATS("Error when reading last track. Image broken.\n"); |
| r245687 | r245688 | |
|---|---|---|
| 236 | 236 | |
| 237 | 237 | // Allocate the storage for the list of testable formats for a |
| 238 | 238 | // given cell size |
| 239 | d | |
| 239 | std::vector<int> candidates; | |
| 240 | 240 | |
| 241 | 241 | // Format we're finally choosing |
| 242 | 242 | int chosen_candidate = -1; |
| r245687 | r245688 | |
| 246 | 246 | for(;;) { |
| 247 | 247 | // Build the list of all formats for the immediatly superior cell size |
| 248 | 248 | int cur_cell_size = 0; |
| 249 | | |
| 249 | candidates.clear(); | |
| 250 | 250 | for(int i=0; i != formats_count; i++) { |
| 251 | 251 | if(image->get_form_factor() == floppy_image::FF_UNKNOWN || |
| 252 | 252 | image->get_form_factor() == formats[i].form_factor) { |
| 253 | 253 | if(formats[i].cell_size == cur_cell_size) |
| 254 | candidates | |
| 254 | candidates.push_back(i); | |
| 255 | 255 | else if((!cur_cell_size || formats[i].cell_size < cur_cell_size) && |
| 256 | 256 | formats[i].cell_size > min_cell_size) { |
| 257 | candidates[0] = i; | |
| 258 | candidates_count = 1; | |
| 257 | candidates.clear(); | |
| 258 | candidates.push_back(i); | |
| 259 | 259 | cur_cell_size = formats[i].cell_size; |
| 260 | 260 | } |
| 261 | 261 | } |
| r245687 | r245688 | |
| 265 | 265 | |
| 266 | 266 | // No candidates with a cell size bigger than the previously |
| 267 | 267 | // tested one, we're done |
| 268 | if( | |
| 268 | if(candidates.empty()) | |
| 269 | 269 | break; |
| 270 | 270 | |
| 271 | 271 | // Filter with track 0 head 0 |
| 272 | check_compatibility(image, candidates | |
| 272 | check_compatibility(image, candidates); | |
| 273 | 273 | |
| 274 | 274 | // Nobody matches, try with the next cell size |
| 275 | if( | |
| 275 | if(candidates.empty()) | |
| 276 | 276 | continue; |
| 277 | 277 | |
| 278 | 278 | // We have a match at that cell size, we just need to find the |
| 279 | 279 | // best one given the geometry |
| 280 | 280 | |
| 281 | 281 | // If there's only one, we're done |
| 282 | if(candidates | |
| 282 | if(candidates.size() == 1) { | |
| 283 | 283 | chosen_candidate = candidates[0]; |
| 284 | 284 | break; |
| 285 | 285 | } |
| r245687 | r245688 | |
| 288 | 288 | int tracks, heads; |
| 289 | 289 | image->get_actual_geometry(tracks, heads); |
| 290 | 290 | chosen_candidate = candidates[0]; |
| 291 | for(int i=1; i != candidates | |
| 291 | for(unsigned int i=1; i != candidates.size(); i++) { | |
| 292 | 292 | const format &cc = formats[chosen_candidate]; |
| 293 | 293 | const format &cn = formats[candidates[i]]; |
| 294 | 294 | |
| r245687 | r245688 | |
| 344 | 344 | return true; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | void upd765_format::check_compatibility(floppy_image *image, | |
| 347 | void upd765_format::check_compatibility(floppy_image *image, std::vector<int> &candidates) | |
| 348 | 348 | { |
| 349 | 349 | UINT8 bitstream[500000/8]; |
| 350 | 350 | UINT8 sectdata[50000]; |
| r245687 | r245688 | |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Check compatibility with every candidate, copy in-place |
| 368 | int *ok_cands = candidates; | |
| 369 | for(int i=0; i != candidates_count; i++) { | |
| 368 | int *ok_cands = &candidates[0]; | |
| 369 | for(unsigned int i=0; i != candidates.size(); i++) { | |
| 370 | 370 | const format &f = formats[candidates[i]]; |
| 371 | 371 | int ns = 0; |
| 372 | 372 | for(int j=0; j<256; j++) |
| r245687 | r245688 | |
| 394 | 394 | fail: |
| 395 | 395 | ; |
| 396 | 396 | } |
| 397 | candidates | |
| 397 | candidates.resize(ok_cands - &candidates[0]); | |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 |
| r245687 | r245688 | |
|---|---|---|
| 47 | 47 | int find_size(io_generic *io, UINT32 form_factor); |
| 48 | 48 | int compute_track_size(const format &f) const; |
| 49 | 49 | virtual void build_sector_description(const format &d, UINT8 *sectdata, desc_s *sectors, int track, int head) const; |
| 50 | void check_compatibility(floppy_image *image, | |
| 50 | void check_compatibility(floppy_image *image, std::vector<int> &candidates); | |
| 51 | 51 | void extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head); |
| 52 | 52 | |
| 53 | 53 | private: |
| r245687 | r245688 | |
|---|---|---|
| 260 | 260 | dynamic_buffer img; |
| 261 | 261 | img.resize(size); |
| 262 | 262 | |
| 263 | io_generic_read(io, img, 0, size); | |
| 263 | io_generic_read(io, &img[0], 0, size); | |
| 264 | 264 | |
| 265 | log_boot_sector(img); | |
| 265 | log_boot_sector(&img[0]); | |
| 266 | 266 | |
| 267 | 267 | int track_offset = 0; |
| 268 | 268 | |
| r245687 | r245688 | |
| 286 | 286 | |
| 287 | 287 | desc_s sectors[40]; |
| 288 | 288 | |
| 289 | build_sector_description(f, img, track_offset, sectors, sector_count); | |
| 289 | build_sector_description(f, &img[0], track_offset, sectors, sector_count); | |
| 290 | 290 | generate_track(desc, track, head, sectors, sector_count, total_size, image); |
| 291 | 291 | |
| 292 | 292 | track_offset += track_size; |
| r245687 | r245688 | |
|---|---|---|
| 226 | 226 | |
| 227 | 227 | // Allocate the storage for the list of testable formats for a |
| 228 | 228 | // given cell size |
| 229 | d | |
| 229 | std::vector<int> candidates; | |
| 230 | 230 | |
| 231 | 231 | // Format we're finally choosing |
| 232 | 232 | int chosen_candidate = -1; |
| r245687 | r245688 | |
| 236 | 236 | for(;;) { |
| 237 | 237 | // Build the list of all formats for the immediatly superior cell size |
| 238 | 238 | int cur_cell_size = 0; |
| 239 | | |
| 239 | candidates.clear(); | |
| 240 | 240 | for(int i=0; i != formats_count; i++) { |
| 241 | 241 | if(image->get_form_factor() == floppy_image::FF_UNKNOWN || |
| 242 | 242 | image->get_form_factor() == formats[i].form_factor) { |
| 243 | 243 | if(formats[i].cell_size == cur_cell_size) |
| 244 | candidates | |
| 244 | candidates.push_back(i); | |
| 245 | 245 | else if((!cur_cell_size || formats[i].cell_size < cur_cell_size) && |
| 246 | 246 | formats[i].cell_size > min_cell_size) { |
| 247 | candidates[0] = i; | |
| 248 | candidates_count = 1; | |
| 247 | candidates.clear(); | |
| 248 | candidates.push_back(i); | |
| 249 | 249 | cur_cell_size = formats[i].cell_size; |
| 250 | 250 | } |
| 251 | 251 | } |
| r245687 | r245688 | |
| 255 | 255 | |
| 256 | 256 | // No candidates with a cell size bigger than the previously |
| 257 | 257 | // tested one, we're done |
| 258 | if( | |
| 258 | if(candidates.empty()) | |
| 259 | 259 | break; |
| 260 | 260 | |
| 261 | 261 | // Filter with track 0 head 0 |
| 262 | check_compatibility(image, candidates | |
| 262 | check_compatibility(image, candidates); | |
| 263 | 263 | |
| 264 | 264 | // Nobody matches, try with the next cell size |
| 265 | if( | |
| 265 | if(candidates.empty()) | |
| 266 | 266 | continue; |
| 267 | 267 | |
| 268 | 268 | // We have a match at that cell size, we just need to find the |
| 269 | 269 | // best one given the geometry |
| 270 | 270 | |
| 271 | 271 | // If there's only one, we're done |
| 272 | if(candidates | |
| 272 | if(candidates.size() == 1) { | |
| 273 | 273 | chosen_candidate = candidates[0]; |
| 274 | 274 | break; |
| 275 | 275 | } |
| r245687 | r245688 | |
| 278 | 278 | int tracks, heads; |
| 279 | 279 | image->get_actual_geometry(tracks, heads); |
| 280 | 280 | chosen_candidate = candidates[0]; |
| 281 | for(int i=1; i != candidates | |
| 281 | for(unsigned int i=1; i != candidates.size(); i++) { | |
| 282 | 282 | const format &cc = formats[chosen_candidate]; |
| 283 | 283 | const format &cn = formats[candidates[i]]; |
| 284 | 284 | |
| r245687 | r245688 | |
| 343 | 343 | return (track * f.head_count + head) * compute_track_size(f); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | void wd177x_format::check_compatibility(floppy_image *image, | |
| 346 | void wd177x_format::check_compatibility(floppy_image *image, std::vector<int> &candidates) | |
| 347 | 347 | { |
| 348 | 348 | UINT8 bitstream[500000/8]; |
| 349 | 349 | UINT8 sectdata[50000]; |
| r245687 | r245688 | |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | // Check compatibility with every candidate, copy in-place |
| 367 | int *ok_cands = candidates; | |
| 368 | for(int i=0; i != candidates_count; i++) { | |
| 367 | int *ok_cands = &candidates[0]; | |
| 368 | for(unsigned int i=0; i != candidates.size(); i++) { | |
| 369 | 369 | const format &f = formats[candidates[i]]; |
| 370 | 370 | int ns = 0; |
| 371 | 371 | for(int j=0; j<256; j++) |
| r245687 | r245688 | |
| 393 | 393 | fail: |
| 394 | 394 | ; |
| 395 | 395 | } |
| 396 | candidates | |
| 396 | candidates.resize(ok_cands - &candidates[0]); | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | void wd177x_format::extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head) |
| r245687 | r245688 | |
|---|---|---|
| 49 | 49 | |
| 50 | 50 | int compute_track_size(const format &f) const; |
| 51 | 51 | void build_sector_description(const format &d, UINT8 *sectdata, desc_s *sectors) const; |
| 52 | void check_compatibility(floppy_image *image, | |
| 52 | void check_compatibility(floppy_image *image, std::vector<int> &candidates); | |
| 53 | 53 | void extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head); |
| 54 | 54 | }; |
| 55 | 55 |
| r245687 | r245688 | |
|---|---|---|
| 177 | 177 | UINT8 *track_data; |
| 178 | 178 | void *track_data_v; |
| 179 | 179 | UINT32 max_track_size; |
| 180 | d | |
| 180 | std::vector<int> sector_map; | |
| 181 | 181 | dynamic_buffer local_sector; |
| 182 | 182 | int local_sector_size; |
| 183 | 183 | int sector_position; |
| r245687 | r245688 | |
| 208 | 208 | track_data = (UINT8 *) track_data_v; |
| 209 | 209 | |
| 210 | 210 | /* set up sector map */ |
| 211 | sector_map.resize_and_clear(sectors, 0xFF); | |
| 211 | sector_map.resize(sectors); | |
| 212 | memset(§or_map, 0xff, sectors); | |
| 212 | 213 | |
| 213 | 214 | physical_sector = 0; |
| 214 | 215 | for (logical_sector = 0; logical_sector < sectors; logical_sector++) |
| r245687 | r245688 | |
| 231 | 232 | sector_length + |
| 232 | 233 | DMK_DATA_CRC_LEN + |
| 233 | 234 | DMK_DATA_GAP_LEN); |
| 234 | local_sector.resize_and_clear(local_sector_size); | |
| 235 | local_sector.resize(local_sector_size); | |
| 236 | memset(&local_sector, 0, local_sector_size); | |
| 235 | 237 | |
| 236 | 238 | /* set up track table of contents */ |
| 237 | 239 | physical_sector = 0; |
| r245687 | r245688 | |
| 391 | 393 | DMK_ID_GAP_LEN + |
| 392 | 394 | DMK_DAM_LEN + |
| 393 | 395 | DMK_DATA_GAP_LEN); |
| 394 | local_idam.resize_and_clear(local_idam_size); | |
| 396 | local_idam.resize(local_idam_size); | |
| 397 | memset(&local_idam[0], 0, local_idam_size); | |
| 395 | 398 | |
| 396 | 399 | /* search for matching IDAM */ |
| 397 | 400 | for (i = 0; i < DMK_TOC_LEN / 2; i++) |
| r245687 | r245688 | |
| 570 | 573 | |
| 571 | 574 | /* set up a local physical sector space (DAM + data + crc + GAP) */ |
| 572 | 575 | local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN); |
| 573 | local_sector.resize_and_clear(local_sector_size); | |
| 576 | local_sector.resize(local_sector_size); | |
| 577 | memset(&local_sector, 0, local_sector_size); | |
| 574 | 578 | |
| 575 | 579 | /* get sector data */ |
| 576 | 580 | /* create a local copy of sector data including DAM (for crc calculation) */ |
| r245687 | r245688 | |
| 582 | 586 | crc_on_disk += local_sector[sector_length + 1 + 1]; |
| 583 | 587 | |
| 584 | 588 | /* crc calculated including DAM */ |
| 585 | calculated_crc = ccitt_crc16(0xffff, local_sector, sector_length+1); | |
| 589 | calculated_crc = ccitt_crc16(0xffff, &local_sector[0], sector_length+1); | |
| 586 | 590 | if (calculated_crc != crc_on_disk) |
| 587 | 591 | { |
| 588 | 592 | err = FLOPPY_ERROR_INVALIDIMAGE; |
| r245687 | r245688 | |
| 590 | 594 | } |
| 591 | 595 | |
| 592 | 596 | /* copy local sector data excluding DAM */ |
| 593 | memcpy(buffer, local_sector | |
| 597 | memcpy(buffer, &local_sector[1], MIN(sector_length, buflen)); | |
| 594 | 598 | |
| 595 | 599 | done: |
| 596 | 600 | return err; |
| r245687 | r245688 | |
| 615 | 619 | |
| 616 | 620 | /* set up a local physical sector space */ |
| 617 | 621 | local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN); |
| 618 | local_sector.resize_and_clear(local_sector_size); | |
| 622 | local_sector.resize(local_sector_size); | |
| 623 | memset(&local_sector[0], 0, local_sector_size); | |
| 619 | 624 | if(!ddam) |
| 620 | 625 | local_sector[0] = 0xFB; |
| 621 | 626 | else |
| r245687 | r245688 | |
| 629 | 634 | |
| 630 | 635 | memcpy(&local_sector[1], buffer, buflen); |
| 631 | 636 | |
| 632 | crc = ccitt_crc16(0xffff, local_sector, DMK_DAM_LEN + sector_length); | |
| 637 | crc = ccitt_crc16(0xffff, &local_sector[0], DMK_DAM_LEN + sector_length); | |
| 633 | 638 | local_sector[DMK_DAM_LEN + sector_length + 0] = crc >> 8; |
| 634 | 639 | local_sector[DMK_DAM_LEN + sector_length + 1] = crc >> 0; |
| 635 | 640 |
| r245687 | r245688 | |
|---|---|---|
| 308 | 308 | |
| 309 | 309 | // fill in the header |
| 310 | 310 | buffer.resize(12 + metadatasize + numsamples * channels * 2 + bitmap.width() * bitmap.height() * 2); |
| 311 | UINT8 *dest = buffer; | |
| 311 | UINT8 *dest = &buffer[0]; | |
| 312 | 312 | *dest++ = 'c'; |
| 313 | 313 | *dest++ = 'h'; |
| 314 | 314 | *dest++ = 'a'; |
| r245687 | r245688 | |
| 549 | 549 | { |
| 550 | 550 | // resize our RLE buffer |
| 551 | 551 | m_rlebuffer.resize(items_per_row * row_count); |
| 552 | UINT16 *dest = m_rlebuffer; | |
| 552 | UINT16 *dest = &m_rlebuffer[0]; | |
| 553 | 553 | |
| 554 | 554 | // iterate over rows |
| 555 | 555 | m_encoder.histo_reset(); |
| r245687 | r245688 | |
| 599 | 599 | |
| 600 | 600 | // compute the tree for our histogram |
| 601 | 601 | m_encoder.compute_tree_from_histo(); |
| 602 | return m_rlebuffer; | |
| 602 | return &m_rlebuffer[0]; | |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 |
| r245687 | r245688 | |
|---|---|---|
| 113 | 113 | // internal state |
| 114 | 114 | int m_rlecount; |
| 115 | 115 | huffman_encoder<256 + 16> m_encoder; |
| 116 | d | |
| 116 | std::vector<UINT16> m_rlebuffer; | |
| 117 | 117 | }; |
| 118 | 118 | |
| 119 | 119 | // internal helpers |
| r245687 | r245688 | |
|---|---|---|
| 379 | 379 | // v3/v4 map entries |
| 380 | 380 | case 3: |
| 381 | 381 | case 4: |
| 382 | rawmap = m_rawmap | |
| 382 | rawmap = &m_rawmap[16 * hunknum]; | |
| 383 | 383 | switch (rawmap[15] & V34_MAP_ENTRY_FLAG_TYPE_MASK) |
| 384 | 384 | { |
| 385 | 385 | case V34_MAP_ENTRY_TYPE_COMPRESSED: |
| r245687 | r245688 | |
| 411 | 411 | |
| 412 | 412 | // v5 map entries |
| 413 | 413 | case 5: |
| 414 | rawmap = m_rawmap | |
| 414 | rawmap = &m_rawmap[m_mapentrybytes * hunknum]; | |
| 415 | 415 | |
| 416 | 416 | // uncompressed case |
| 417 | 417 | if (!compressed()) |
| r245687 | r245688 | |
| 704 | 704 | |
| 705 | 705 | // reset map information |
| 706 | 706 | m_mapentrybytes = 0; |
| 707 | m_rawmap. | |
| 707 | m_rawmap.clear(); | |
| 708 | 708 | |
| 709 | 709 | // reset compression management |
| 710 | 710 | for (int decompnum = 0; decompnum < ARRAY_LENGTH(m_decompressor); decompnum++) |
| r245687 | r245688 | |
| 712 | 712 | delete m_decompressor[decompnum]; |
| 713 | 713 | m_decompressor[decompnum] = NULL; |
| 714 | 714 | } |
| 715 | m_compressed. | |
| 715 | m_compressed.clear(); | |
| 716 | 716 | |
| 717 | 717 | // reset caching |
| 718 | m_cache. | |
| 718 | m_cache.clear(); | |
| 719 | 719 | m_cachehunk = ~0; |
| 720 | 720 | } |
| 721 | 721 | |
| r245687 | r245688 | |
| 748 | 748 | // v3/v4 map entries |
| 749 | 749 | case 3: |
| 750 | 750 | case 4: |
| 751 | rawmap = m_rawmap | |
| 751 | rawmap = &m_rawmap[16 * hunknum]; | |
| 752 | 752 | blockoffs = be_read(&rawmap[0], 8); |
| 753 | 753 | blockcrc = be_read(&rawmap[8], 4); |
| 754 | 754 | switch (rawmap[15] & V34_MAP_ENTRY_FLAG_TYPE_MASK) |
| 755 | 755 | { |
| 756 | 756 | case V34_MAP_ENTRY_TYPE_COMPRESSED: |
| 757 | 757 | blocklen = be_read(&rawmap[12], 2) + (rawmap[14] << 16); |
| 758 | file_read(blockoffs, m_compressed, blocklen); | |
| 759 | m_decompressor[0]->decompress(m_compressed, blocklen, dest, m_hunkbytes); | |
| 758 | file_read(blockoffs, &m_compressed[0], blocklen); | |
| 759 | m_decompressor[0]->decompress(&m_compressed[0], blocklen, dest, m_hunkbytes); | |
| 760 | 760 | if (!(rawmap[15] & V34_MAP_ENTRY_FLAG_NO_CRC) && dest != NULL && crc32_creator::simple(dest, m_hunkbytes) != blockcrc) |
| 761 | 761 | throw CHDERR_DECOMPRESSION_ERROR; |
| 762 | 762 | return CHDERR_NONE; |
| r245687 | r245688 | |
| 787 | 787 | |
| 788 | 788 | // v5 map entries |
| 789 | 789 | case 5: |
| 790 | rawmap = m_rawmap | |
| 790 | rawmap = &m_rawmap[m_mapentrybytes * hunknum]; | |
| 791 | 791 | |
| 792 | 792 | // uncompressed case |
| 793 | 793 | if (!compressed()) |
| r245687 | r245688 | |
| 814 | 814 | case COMPRESSION_TYPE_1: |
| 815 | 815 | case COMPRESSION_TYPE_2: |
| 816 | 816 | case COMPRESSION_TYPE_3: |
| 817 | file_read(blockoffs, m_compressed, blocklen); | |
| 818 | m_decompressor[rawmap[0]]->decompress(m_compressed, blocklen, dest, m_hunkbytes); | |
| 817 | file_read(blockoffs, &m_compressed[0], blocklen); | |
| 818 | m_decompressor[rawmap[0]]->decompress(&m_compressed[0], blocklen, dest, m_hunkbytes); | |
| 819 | 819 | if (!m_decompressor[rawmap[0]]->lossy() && dest != NULL && crc16_creator::simple(dest, m_hunkbytes) != blockcrc) |
| 820 | 820 | throw CHDERR_DECOMPRESSION_ERROR; |
| 821 | if (m_decompressor[rawmap[0]]->lossy() && crc16_creator::simple(m_compressed, blocklen) != blockcrc) | |
| 821 | if (m_decompressor[rawmap[0]]->lossy() && crc16_creator::simple(&m_compressed[0], blocklen) != blockcrc) | |
| 822 | 822 | throw CHDERR_DECOMPRESSION_ERROR; |
| 823 | 823 | return CHDERR_NONE; |
| 824 | 824 | |
| r245687 | r245688 | |
| 877 | 877 | throw CHDERR_FILE_NOT_WRITEABLE; |
| 878 | 878 | |
| 879 | 879 | // see if we have allocated the space on disk for this hunk |
| 880 | UINT8 *rawmap = m_rawmap | |
| 880 | UINT8 *rawmap = &m_rawmap[hunknum * 4]; | |
| 881 | 881 | UINT32 rawentry = be_read(rawmap, 4); |
| 882 | 882 | |
| 883 | 883 | // if not, allocate one now |
| r245687 | r245688 | |
| 905 | 905 | file_write(m_mapoffset + hunknum * 4, rawmap, 4); |
| 906 | 906 | |
| 907 | 907 | // update the cached hunk if we just wrote it |
| 908 | if (hunknum == m_cachehunk && buffer != m_cache) | |
| 909 | memcpy(m_cache, buffer, m_hunkbytes); | |
| 908 | if (hunknum == m_cachehunk && buffer != &m_cache[0]) | |
| 909 | memcpy(&m_cache[0], buffer, m_hunkbytes); | |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | // otherwise, just overwrite |
| r245687 | r245688 | |
| 972 | 972 | { |
| 973 | 973 | if (curhunk != m_cachehunk) |
| 974 | 974 | { |
| 975 | err = read_hunk(curhunk, m_cache); | |
| 975 | err = read_hunk(curhunk, &m_cache[0]); | |
| 976 | 976 | if (err != CHDERR_NONE) |
| 977 | 977 | return err; |
| 978 | 978 | m_cachehunk = curhunk; |
| r245687 | r245688 | |
| 1016 | 1016 | { |
| 1017 | 1017 | if (curhunk != m_cachehunk) |
| 1018 | 1018 | { |
| 1019 | err = read_hunk(curhunk, m_cache); | |
| 1019 | err = read_hunk(curhunk, &m_cache[0]); | |
| 1020 | 1020 | if (err != CHDERR_NONE) |
| 1021 | 1021 | return err; |
| 1022 | 1022 | m_cachehunk = curhunk; |
| 1023 | 1023 | } |
| 1024 | 1024 | memcpy(&m_cache[startoffs], source, endoffs + 1 - startoffs); |
| 1025 | err = write_hunk(curhunk, m_cache); | |
| 1025 | err = write_hunk(curhunk, &m_cache[0]); | |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | // handle errors and advance |
| r245687 | r245688 | |
| 1078 | 1078 | |
| 1079 | 1079 | // read the metadata |
| 1080 | 1080 | output.resize(metaentry.length); |
| 1081 | file_read(metaentry.offset + METADATA_HEADER_SIZE, output, metaentry.length); | |
| 1081 | file_read(metaentry.offset + METADATA_HEADER_SIZE, &output[0], metaentry.length); | |
| 1082 | 1082 | return CHDERR_NONE; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| r245687 | r245688 | |
| 1124 | 1124 | |
| 1125 | 1125 | // read the metadata |
| 1126 | 1126 | output.resize(metaentry.length); |
| 1127 | file_read(metaentry.offset + METADATA_HEADER_SIZE, output, metaentry.length); | |
| 1127 | file_read(metaentry.offset + METADATA_HEADER_SIZE, &output[0], metaentry.length); | |
| 1128 | 1128 | resulttag = metaentry.metatag; |
| 1129 | 1129 | resultflags = metaentry.flags; |
| 1130 | 1130 | return CHDERR_NONE; |
| r245687 | r245688 | |
| 1259 | 1259 | { |
| 1260 | 1260 | // read the metadata item |
| 1261 | 1261 | filedata.resize(metaentry.length); |
| 1262 | source.file_read(metaentry.offset + METADATA_HEADER_SIZE, filedata, metaentry.length); | |
| 1262 | source.file_read(metaentry.offset + METADATA_HEADER_SIZE, &filedata[0], metaentry.length); | |
| 1263 | 1263 | |
| 1264 | 1264 | // write it to the destination |
| 1265 | chd_error err = write_metadata(metaentry.metatag, (UINT32)-1, filedata, metaentry.length, metaentry.flags); | |
| 1265 | chd_error err = write_metadata(metaentry.metatag, (UINT32)-1, &filedata[0], metaentry.length, metaentry.flags); | |
| 1266 | 1266 | if (err != CHDERR_NONE) |
| 1267 | 1267 | throw err; |
| 1268 | 1268 | } |
| r245687 | r245688 | |
| 1291 | 1291 | |
| 1292 | 1292 | // iterate over metadata |
| 1293 | 1293 | dynamic_buffer filedata; |
| 1294 | d | |
| 1294 | std::vector<metadata_hash> hasharray; | |
| 1295 | 1295 | metadata_entry metaentry; |
| 1296 | 1296 | for (bool has_data = metadata_find(CHDMETATAG_WILDCARD, 0, metaentry); has_data; has_data = metadata_find(CHDMETATAG_WILDCARD, 0, metaentry, true)) |
| 1297 | 1297 | { |
| r245687 | r245688 | |
| 1301 | 1301 | |
| 1302 | 1302 | // allocate memory and read the data |
| 1303 | 1303 | filedata.resize(metaentry.length); |
| 1304 | file_read(metaentry.offset + METADATA_HEADER_SIZE, filedata, metaentry.length); | |
| 1304 | file_read(metaentry.offset + METADATA_HEADER_SIZE, &filedata[0], metaentry.length); | |
| 1305 | 1305 | |
| 1306 | 1306 | // create an entry for this metadata and add it |
| 1307 | 1307 | metadata_hash hashentry; |
| 1308 | 1308 | be_write(hashentry.tag, metaentry.metatag, 4); |
| 1309 | hashentry.sha1 = sha1_creator::simple(filedata, metaentry.length); | |
| 1310 | hasharray.append(hashentry); | |
| 1309 | hashentry.sha1 = sha1_creator::simple(&filedata[0], metaentry.length); | |
| 1310 | hasharray.push_back(hashentry); | |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | 1313 | // sort the array |
| 1314 | if (hasharray.count() != 0) | |
| 1315 | qsort(&hasharray[0], hasharray.count(), sizeof(hasharray[0]), metadata_hash_compare); | |
| 1314 | if (!hasharray.empty()) | |
| 1315 | qsort(&hasharray[0], hasharray.size(), sizeof(hasharray[0]), metadata_hash_compare); | |
| 1316 | 1316 | |
| 1317 | 1317 | // read the raw data hash from our header and start a new SHA1 with that data |
| 1318 | 1318 | sha1_creator overall_sha1; |
| 1319 | 1319 | overall_sha1.append(&rawsha1, sizeof(rawsha1)); |
| 1320 | if (hasharray.count() != 0) | |
| 1321 | overall_sha1.append(&hasharray[0], hasharray.count() * sizeof(hasharray[0])); | |
| 1320 | if (!hasharray.empty()) | |
| 1321 | overall_sha1.append(&hasharray[0], hasharray.size() * sizeof(hasharray[0])); | |
| 1322 | 1322 | return overall_sha1.finish(); |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| r245687 | r245688 | |
| 1586 | 1586 | try |
| 1587 | 1587 | { |
| 1588 | 1588 | // first get a CRC-16 of the original rawmap |
| 1589 | crc16_t mapcrc = crc16_creator::simple(m_rawmap, m_hunkcount * 12); | |
| 1589 | crc16_t mapcrc = crc16_creator::simple(&m_rawmap[0], m_hunkcount * 12); | |
| 1590 | 1590 | |
| 1591 | 1591 | // create a buffer to hold the RLE data |
| 1592 | 1592 | dynamic_buffer compression_rle(m_hunkcount); |
| 1593 | UINT8 *dest = compression_rle; | |
| 1593 | UINT8 *dest = &compression_rle[0]; | |
| 1594 | 1594 | |
| 1595 | 1595 | // use a huffman encoder for 16 different codes, maximum length is 8 bits |
| 1596 | 1596 | huffman_encoder<16, 8> encoder; |
| r245687 | r245688 | |
| 1673 | 1673 | |
| 1674 | 1674 | // compute a tree and export it to the buffer |
| 1675 | 1675 | dynamic_buffer compressed(m_hunkcount * 6); |
| 1676 | bitstream_out bitbuf(&compressed[16], compressed. | |
| 1676 | bitstream_out bitbuf(&compressed[16], compressed.size() - 16); | |
| 1677 | 1677 | huffman_error err = encoder.compute_tree_from_histo(); |
| 1678 | 1678 | if (err != HUFFERR_NONE) |
| 1679 | 1679 | throw CHDERR_COMPRESSION_ERROR; |
| r245687 | r245688 | |
| 1682 | 1682 | throw CHDERR_COMPRESSION_ERROR; |
| 1683 | 1683 | |
| 1684 | 1684 | // encode the data |
| 1685 | for (UINT8 *src = compression_rle; src < dest; src++) | |
| 1685 | for (UINT8 *src = &compression_rle[0]; src < dest; src++) | |
| 1686 | 1686 | encoder.encode_one(bitbuf, *src); |
| 1687 | 1687 | |
| 1688 | 1688 | // determine the number of bits we need to hold the a length |
| r245687 | r245688 | |
| 1694 | 1694 | // for each compression type, output the relevant data |
| 1695 | 1695 | lastcomp = 0; |
| 1696 | 1696 | count = 0; |
| 1697 | UINT8 *src = compression_rle; | |
| 1697 | UINT8 *src = &compression_rle[0]; | |
| 1698 | 1698 | UINT64 firstoffs = 0; |
| 1699 | 1699 | for (int hunknum = 0; hunknum < m_hunkcount; hunknum++) |
| 1700 | 1700 | { |
| r245687 | r245688 | |
| 1768 | 1768 | compressed[15] = 0; |
| 1769 | 1769 | |
| 1770 | 1770 | // write the result |
| 1771 | m_mapoffset = file_append(compressed, complen + 16); | |
| 1771 | m_mapoffset = file_append(&compressed[0], complen + 16); | |
| 1772 | 1772 | |
| 1773 | 1773 | // then write the map offset |
| 1774 | 1774 | UINT8 rawbuf[sizeof(UINT64)]; |
| r245687 | r245688 | |
| 1792 | 1792 | // if no offset, we haven't written it yet |
| 1793 | 1793 | if (m_mapoffset == 0) |
| 1794 | 1794 | { |
| 1795 | memset(m_rawmap, 0xff, m_rawmap. | |
| 1795 | memset(&m_rawmap[0], 0xff, m_rawmap.size()); | |
| 1796 | 1796 | return; |
| 1797 | 1797 | } |
| 1798 | 1798 | |
| r245687 | r245688 | |
| 1808 | 1808 | |
| 1809 | 1809 | // now read the map |
| 1810 | 1810 | dynamic_buffer compressed(mapbytes); |
| 1811 | file_read(m_mapoffset + 16, compressed, mapbytes); | |
| 1812 | bitstream_in bitbuf(compressed, compressed.count()); | |
| 1811 | file_read(m_mapoffset + 16, &compressed[0], mapbytes); | |
| 1812 | bitstream_in bitbuf(&compressed[0], compressed.size()); | |
| 1813 | 1813 | |
| 1814 | 1814 | // first decode the compression types |
| 1815 | 1815 | huffman_decoder<16, 8> decoder; |
| r245687 | r245688 | |
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | 1898 | // verify the final CRC |
| 1899 | if (crc16_creator::simple(m_rawmap, m_hunkcount * 12) != mapcrc) | |
| 1899 | if (crc16_creator::simple(&m_rawmap[0], m_hunkcount * 12) != mapcrc) | |
| 1900 | 1900 | throw CHDERR_DECOMPRESSION_ERROR; |
| 1901 | 1901 | } |
| 1902 | 1902 | |
| r245687 | r245688 | |
| 2084 | 2084 | if (m_version >= 5 && compressed()) |
| 2085 | 2085 | decompress_v5_map(); |
| 2086 | 2086 | else |
| 2087 | file_read(m_mapoffset, m_rawmap, m_rawmap. | |
| 2087 | file_read(m_mapoffset, &m_rawmap[0], m_rawmap.size()); | |
| 2088 | 2088 | |
| 2089 | 2089 | // allocate the temporary compressed buffer and a buffer for caching |
| 2090 | 2090 | m_compressed.resize(m_hunkbytes); |
| r245687 | r245688 | |
| 2369 | 2369 | m_read_error = false; |
| 2370 | 2370 | |
| 2371 | 2371 | // reset work item state |
| 2372 | m_work_buffer.resize_and_clear(hunk_bytes() * (WORK_BUFFER_HUNKS + 1)); | |
| 2372 | m_work_buffer.resize(hunk_bytes() * (WORK_BUFFER_HUNKS + 1)); | |
| 2373 | memset(&m_work_buffer[0], 0, m_work_buffer.size()); | |
| 2373 | 2374 | m_compressed_buffer.resize(hunk_bytes() * WORK_BUFFER_HUNKS); |
| 2374 | 2375 | for (int itemnum = 0; itemnum < WORK_BUFFER_HUNKS; itemnum++) |
| 2375 | 2376 | { |
| 2376 | 2377 | work_item &item = m_work_item[itemnum]; |
| 2377 | 2378 | item.m_compressor = this; |
| 2378 | item.m_data = m_work_buffer + hunk_bytes() * itemnum; | |
| 2379 | item.m_compressed = m_compressed_buffer + hunk_bytes() * itemnum; | |
| 2379 | item.m_data = &m_work_buffer[hunk_bytes() * itemnum]; | |
| 2380 | item.m_compressed = &m_compressed_buffer[hunk_bytes() * itemnum]; | |
| 2380 | 2381 | item.m_hash.resize(hunk_bytes() / unit_bytes()); |
| 2381 | 2382 | } |
| 2382 | 2383 | |
| r245687 | r245688 | |
| 2626 | 2627 | try |
| 2627 | 2628 | { |
| 2628 | 2629 | // do the read |
| 2629 | UINT8 *dest = m_work_buffer + (m_read_done_offset % work_buffer_bytes); | |
| 2630 | assert(dest == m_work_buffer || dest == m_work_buffer + work_buffer_bytes/2); | |
| 2630 | UINT8 *dest = &m_work_buffer[0] + (m_read_done_offset % work_buffer_bytes); | |
| 2631 | assert(dest == &m_work_buffer[0] || dest == &m_work_buffer[work_buffer_bytes/2]); | |
| 2631 | 2632 | UINT64 end_offset = m_read_done_offset + numbytes; |
| 2632 | 2633 | |
| 2633 | 2634 | // if walking the parent, read in hunks from the parent CHD |
| r245687 | r245688 | |
|---|---|---|
| 353 | 353 | chd_error read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, dynamic_buffer &output, chd_metadata_tag &resulttag, UINT8 &resultflags); |
| 354 | 354 | chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags = CHD_MDFLAGS_CHECKSUM); |
| 355 | 355 | chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const astring &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, input.c_str(), input.len() + 1, flags); } |
| 356 | chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const dynamic_buffer &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, input, input. | |
| 356 | chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const dynamic_buffer &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, &input[0], input.size(), flags); } | |
| 357 | 357 | chd_error delete_metadata(chd_metadata_tag metatag, UINT32 metaindex); |
| 358 | 358 | chd_error clone_all_metadata(chd_file &source); |
| 359 | 359 | |
| r245687 | r245688 | |
| 539 | 539 | UINT32 m_complen; // compressed data length |
| 540 | 540 | INT8 m_compression; // type of compression used |
| 541 | 541 | chd_compressor_group *m_codecs; // codec instance |
| 542 | d | |
| 542 | std::vector<hash_pair> m_hash; // array of hashes | |
| 543 | 543 | }; |
| 544 | 544 | |
| 545 | 545 | // internal helpers |
| r245687 | r245688 | |
|---|---|---|
| 670 | 670 | try |
| 671 | 671 | { |
| 672 | 672 | // if this is the best one, copy the data into the permanent buffer |
| 673 | UINT32 compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, m_compress_test); | |
| 673 | UINT32 compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, &m_compress_test[0]); | |
| 674 | 674 | #if CHDCODEC_VERIFY_COMPRESSION |
| 675 | 675 | try |
| 676 | 676 | { |
| r245687 | r245688 | |
| 699 | 699 | { |
| 700 | 700 | compression = codecnum; |
| 701 | 701 | complen = compbytes; |
| 702 | memcpy(compressed, m_compress_test, compbytes); | |
| 702 | memcpy(compressed, &m_compress_test[0], compbytes); | |
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | catch (...) { } |
| r245687 | r245688 | |
| 1425 | 1425 | |
| 1426 | 1426 | // reset and encode the audio portion |
| 1427 | 1427 | m_encoder.reset(dest, hunkbytes()); |
| 1428 | UINT8 *buffer = m_buffer; | |
| 1428 | UINT8 *buffer = &m_buffer[0]; | |
| 1429 | 1429 | if (!m_encoder.encode_interleaved(reinterpret_cast<INT16 *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian)) |
| 1430 | 1430 | throw CHDERR_COMPRESSION_ERROR; |
| 1431 | 1431 | |
| r245687 | r245688 | |
| 1525 | 1525 | UINT32 frames = destlen / CD_FRAME_SIZE; |
| 1526 | 1526 | if (!m_decoder.reset(44100, 2, chd_cd_flac_compressor::blocksize(frames * CD_MAX_SECTOR_DATA), src, complen)) |
| 1527 | 1527 | throw CHDERR_DECOMPRESSION_ERROR; |
| 1528 | UINT8 *buffer = m_buffer; | |
| 1528 | UINT8 *buffer = &m_buffer[0]; | |
| 1529 | 1529 | if (!m_decoder.decode_interleaved(reinterpret_cast<INT16 *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian)) |
| 1530 | 1530 | throw CHDERR_DECOMPRESSION_ERROR; |
| 1531 | 1531 |
| r245687 | r245688 | |
|---|---|---|
| 750 | 750 | data.resize(size); |
| 751 | 751 | |
| 752 | 752 | /* read the data */ |
| 753 | if (core_fread(file, data, size) != size) | |
| 753 | if (core_fread(file, &data[0], size) != size) | |
| 754 | 754 | { |
| 755 | 755 | core_fclose(file); |
| 756 | data. | |
| 756 | data.clear(); | |
| 757 | 757 | return FILERR_FAILURE; |
| 758 | 758 | } |
| 759 | 759 |
| r245687 | r245688 | |
|---|---|---|
| 16 | 16 | #include "osdcore.h" |
| 17 | 17 | #include "corealloc.h" |
| 18 | 18 | |
| 19 | #include <vector> | |
| 20 | ||
| 19 | 21 | // TEMPORARY helper to catch is_pod assertions in the debugger |
| 20 | 22 | #if 0 |
| 21 | 23 | #undef assert |
| r245687 | r245688 | |
| 57 | 59 | }; |
| 58 | 60 | |
| 59 | 61 | |
| 60 | // ======================> dynamic_array | |
| 61 | 62 | |
| 62 | // an array that is dynamically sized and can optionally auto-expand | |
| 63 | template<class _ElementType> | |
| 64 | class dynamic_array | |
| 65 | { | |
| 66 | private: | |
| 67 | // we don't support deep copying | |
| 68 | dynamic_array(const dynamic_array &); | |
| 69 | dynamic_array &operator=(const dynamic_array &); | |
| 63 | typedef std::vector<UINT8> dynamic_buffer; | |
| 70 | 64 | |
| 71 | public: | |
| 72 | // construction/destruction | |
| 73 | dynamic_array(int initial = 0, int clearvalue = -1) | |
| 74 | : m_array(NULL), | |
| 75 | m_count(0), | |
| 76 | m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; if (clearvalue != -1) clear(clearvalue); } | |
| 77 | virtual ~dynamic_array() { reset(); } | |
| 78 | 65 | |
| 79 | // operators | |
| 80 | operator _ElementType *() { return &m_array[0]; } | |
| 81 | operator const _ElementType *() const { return &m_array[0]; } | |
| 82 | _ElementType &operator[](int index) { assert(index < m_count); return m_array[index]; } | |
| 83 | const _ElementType &operator[](int index) const { assert(index < m_count); return m_array[index]; } | |
| 84 | ||
| 85 | // simple getters | |
| 86 | int count() const { return m_count; } | |
| 87 | int bytes() const { return m_count * sizeof(_ElementType); } | |
| 88 | ||
| 89 | // core operations | |
| 90 | _ElementType &append() { if (m_count == m_allocated) expand_and_keep_internal((m_allocated == 0) ? 16 : (m_allocated << 1)); return m_array[m_count++]; } | |
| 91 | const _ElementType &append(const _ElementType &element) { return (append() = element); } | |
| 92 | void reset() { global_free_array(m_array); m_array = NULL; m_count = m_allocated = 0; } | |
| 93 | void resize(int count) { if (count > m_allocated) expand_internal(count); m_count = count; } | |
| 94 | void resize_keep(int count) { if (count > m_allocated) expand_and_keep_internal(count); m_count = count; } | |
| 95 | void clear(UINT8 data = 0) { clear_internal(0, m_count, data); } | |
| 96 | ||
| 97 | // compound operations | |
| 98 | void resize_and_clear(int count, UINT8 data = 0) { resize(count); clear(data); } | |
| 99 | void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); } | |
| 100 | ||
| 101 | // batch operations | |
| 102 | void copyfrom(const dynamic_array<_ElementType> &source) | |
| 103 | { | |
| 104 | resize(source.count()); | |
| 105 | for (int i=0; i < source.count(); i++) | |
| 106 | m_array[i] = source[i]; | |
| 107 | } | |
| 108 | ||
| 109 | private: | |
| 110 | // internal helpers | |
| 111 | void expand_internal(int count) | |
| 112 | { | |
| 113 | global_free_array(m_array); | |
| 114 | m_array = global_alloc_array(_ElementType, count); | |
| 115 | m_allocated = count; | |
| 116 | } | |
| 117 | ||
| 118 | void expand_and_keep_internal(int count) | |
| 119 | { | |
| 120 | _ElementType *oldarray = m_array; | |
| 121 | int oldcount = m_count; | |
| 122 | m_array = global_alloc_array(_ElementType, count); | |
| 123 | m_allocated = count; | |
| 124 | for (int index = 0; index < oldcount; index++) | |
| 125 | m_array[index] = oldarray[index]; | |
| 126 | global_free_array(oldarray); | |
| 127 | } | |
| 128 | ||
| 129 | #if defined(__GNUC__) && !defined(SDLMAME_MACOSX) | |
| 130 | void clear_internal(UINT32 start, UINT32 count, UINT8 data) { assert(__is_pod(_ElementType)); memset((void *)&m_array[start], data, count * sizeof(*m_array)); } | |
| 131 | #else | |
| 132 | void clear_internal(UINT32 start, UINT32 count, UINT8 data) { memset(&m_array[start], data, count * sizeof(*m_array)); } | |
| 133 | #endif | |
| 134 | ||
| 135 | // internal state | |
| 136 | _ElementType * m_array; // allocated array | |
| 137 | int m_count; // number of objects accessed in the list | |
| 138 | int m_allocated; // amount of space allocated for the array | |
| 139 | }; | |
| 140 | ||
| 141 | typedef dynamic_array<UINT8> dynamic_buffer; | |
| 142 | ||
| 143 | ||
| 144 | 66 | // ======================> simple_list |
| 145 | 67 | |
| 146 | 68 | // a simple_list is a singly-linked list whose 'next' pointer is owned |
| r245687 | r245688 | |
|---|---|---|
| 317 | 317 | { |
| 318 | 318 | // first RLE compress the lengths of all the nodes |
| 319 | 319 | dynamic_buffer rle_data(m_numcodes); |
| 320 | UINT8 *dest = rle_data; | |
| 321 | dynamic_array<UINT16> rle_lengths(m_numcodes/3); | |
| 322 | UINT16 *lengths = rle_lengths; | |
| 320 | UINT8 *dest = &rle_data[0]; | |
| 321 | std::vector<UINT16> rle_lengths(m_numcodes/3); | |
| 322 | UINT16 *lengths = &rle_lengths[0]; | |
| 323 | 323 | int last = ~0; |
| 324 | 324 | int repcount = 0; |
| 325 | 325 | |
| r245687 | r245688 | |
| 393 | 393 | temp >>= 1, rlefullbits++; |
| 394 | 394 | |
| 395 | 395 | // now encode the RLE data |
| 396 | lengths = rle_lengths; | |
| 397 | for (UINT8 *src = rle_data; src < dest; src++) | |
| 396 | lengths = &rle_lengths[0]; | |
| 397 | for (UINT8 *src = &rle_data[0]; src < dest; src++) | |
| 398 | 398 | { |
| 399 | 399 | // encode the data |
| 400 | 400 | UINT8 data = *src; |
| r245687 | r245688 | |
| 523 | 523 | int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight) |
| 524 | 524 | { |
| 525 | 525 | // make a list of all non-zero nodes |
| 526 | d | |
| 526 | std::vector<node_t *> list(m_numcodes * 2); | |
| 527 | 527 | int listitems = 0; |
| 528 | 528 | memset(m_huffnode, 0, m_numcodes * sizeof(m_huffnode[0])); |
| 529 | 529 | for (int curcode = 0; curcode < m_numcodes; curcode++) |
| r245687 | r245688 | |
| 545 | 545 | } |
| 546 | 546 | */ |
| 547 | 547 | // sort the list by weight, largest weight first |
| 548 | qsort(list, listitems, sizeof(list[0]), tree_node_compare); | |
| 548 | qsort(&list[0], listitems, sizeof(list[0]), tree_node_compare); | |
| 549 | 549 | /* |
| 550 | 550 | fprintf(stderr, "Post-sort:\n"); |
| 551 | 551 | for (int i = 0; i < listitems; i++) { |
| r245687 | r245688 | |
|---|---|---|
| 79 | 79 | { |
| 80 | 80 | // resize to the correct number of dwords and mark all entries dirty |
| 81 | 81 | UINT32 dirty_dwords = (colors + 31) / 32; |
| 82 | m_dirty.resize_and_clear(dirty_dwords, 0xff); | |
| 82 | m_dirty.resize(dirty_dwords); | |
| 83 | memset(&m_dirty[0], 0xff, dirty_dwords*4); | |
| 83 | 84 | |
| 84 | 85 | // mark all entries dirty |
| 85 | 86 | m_dirty[dirty_dwords - 1] &= (1 << (colors % 32)) - 1; |
| r245687 | r245688 | |
| 111 | 112 | { |
| 112 | 113 | // erase relevant entries in the new live one |
| 113 | 114 | memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(UINT32)); |
| 114 | m_mindirty = m_dirty. | |
| 115 | m_mindirty = m_dirty.size() * 32 - 1; | |
| 115 | 116 | m_maxdirty = 0; |
| 116 | 117 | } |
| 117 | 118 |
| r245687 | r245688 | |
|---|---|---|
| 118 | 118 | |
| 119 | 119 | private: |
| 120 | 120 | // internal state |
| 121 | d | |
| 121 | std::vector<UINT32> m_dirty; // bitmap of dirty entries | |
| 122 | 122 | UINT32 m_mindirty; // minimum dirty entry |
| 123 | 123 | UINT32 m_maxdirty; // minimum dirty entry |
| 124 | 124 | }; |
| r245687 | r245688 | |
| 169 | 169 | void entry_set_contrast(UINT32 index, float contrast); |
| 170 | 170 | |
| 171 | 171 | // entry list getters |
| 172 | const rgb_t *entry_list_raw() const { return m_entry_color; } | |
| 173 | const rgb_t *entry_list_adjusted() const { return m_adjusted_color; } | |
| 174 | const rgb_t *entry_list_adjusted_rgb15() const { return m_adjusted_rgb15; } | |
| 172 | const rgb_t *entry_list_raw() const { return &m_entry_color[0]; } | |
| 173 | const rgb_t *entry_list_adjusted() const { return &m_adjusted_color[0]; } | |
| 174 | const rgb_t *entry_list_adjusted_rgb15() const { return &m_adjusted_rgb15[0]; } | |
| 175 | 175 | |
| 176 | 176 | // group adjustments |
| 177 | 177 | void group_set_brightness(UINT32 group, float brightness); |
| r245687 | r245688 | |
| 199 | 199 | float m_gamma; // overall gamma value |
| 200 | 200 | UINT8 m_gamma_map[256]; // gamma map |
| 201 | 201 | |
| 202 | dynamic_array<rgb_t> m_entry_color; // array of raw colors | |
| 203 | dynamic_array<float> m_entry_contrast; // contrast value for each entry | |
| 204 | dynamic_array<rgb_t> m_adjusted_color; // array of adjusted colors | |
| 205 | dynamic_array<rgb_t> m_adjusted_rgb15; // array of adjusted colors as RGB15 | |
| 202 | std::vector<rgb_t> m_entry_color; // array of raw colors | |
| 203 | std::vector<float> m_entry_contrast; // contrast value for each entry | |
| 204 | std::vector<rgb_t> m_adjusted_color; // array of adjusted colors | |
| 205 | std::vector<rgb_t> m_adjusted_rgb15; // array of adjusted colors as RGB15 | |
| 206 | 206 | |
| 207 | dynamic_array<float> m_group_bright; // brightness value for each group | |
| 208 | dynamic_array<float> m_group_contrast; // contrast value for each group | |
| 207 | std::vector<float> m_group_bright; // brightness value for each group | |
| 208 | std::vector<float> m_group_contrast; // contrast value for each group | |
| 209 | 209 | |
| 210 | 210 | palette_client *m_client_list; // list of clients for this palette |
| 211 | 211 | }; |
| r245687 | r245688 | |
|---|---|---|
| 297 | 297 | |
| 298 | 298 | //m_isa->install_device(0x3bf, 0x3bf, 0, 0, NULL, write8_delegate( FUNC(isa8_cga_4enlinea_device::_4enlinea_mode_control_w), this ) ); |
| 299 | 299 | m_isa->install_device(0x3d0, 0x3df, 0, 0, read8_delegate( FUNC(isa8_cga_4enlinea_device::_4enlinea_io_read), this ), write8_delegate( FUNC(isa8_cga_device::io_write), this ) ); |
| 300 | m_isa->install_bank(0x8000, 0xbfff, 0, 0, "bank1", m_vram); | |
| 300 | m_isa->install_bank(0x8000, 0xbfff, 0, 0, "bank1", &m_vram[0]); | |
| 301 | 301 | |
| 302 | 302 | /* Initialise the cga palette */ |
| 303 | 303 | int i; |
| r245687 | r245688 | |
|---|---|---|
| 2740 | 2740 | buf1[addr] = rom[x]; |
| 2741 | 2741 | } |
| 2742 | 2742 | |
| 2743 | memcpy(rom, buf1, length); | |
| 2743 | memcpy(rom, &buf1[0], length); | |
| 2744 | 2744 | } |
| 2745 | 2745 | |
| 2746 | 2746 | |
| r245687 | r245688 | |
| 3120 | 3120 | for (int i = 0; i < len; i++) |
| 3121 | 3121 | buffer[BITSWAP16(i, 15,14,13,12,11,10,8,9, 7,6,5,4,3,2,1,0)] = rom[i]; |
| 3122 | 3122 | |
| 3123 | memcpy(rom, buffer, len); | |
| 3123 | memcpy(rom, &buffer[0], len); | |
| 3124 | 3124 | } |
| 3125 | 3125 | |
| 3126 | 3126 |
| r245687 | r245688 | |
|---|---|---|
| 690 | 690 | dynamic_buffer original(length); |
| 691 | 691 | UINT32 srcaddr; |
| 692 | 692 | |
| 693 | memcpy(original, rom, length); | |
| 693 | memcpy(&original[0], rom, length); | |
| 694 | 694 | for (srcaddr = 0; srcaddr < length; srcaddr++) |
| 695 | 695 | { |
| 696 | 696 | UINT32 dstaddr = srcaddr; |
| r245687 | r245688 | |
| 709 | 709 | dynamic_buffer original(length); |
| 710 | 710 | UINT32 srcaddr; |
| 711 | 711 | |
| 712 | memcpy(original, rom, length); | |
| 712 | memcpy(&original[0], rom, length); | |
| 713 | 713 | for (srcaddr = 0; srcaddr < length; srcaddr++) |
| 714 | 714 | { |
| 715 | 715 | UINT32 dstaddr = srcaddr; |
| r245687 | r245688 | |
| 727 | 727 | dynamic_buffer original(length); |
| 728 | 728 | UINT32 srcaddr; |
| 729 | 729 | |
| 730 | memcpy(original, rom, length); | |
| 730 | memcpy(&original[0], rom, length); | |
| 731 | 731 | for (srcaddr = 0; srcaddr < length; srcaddr++) |
| 732 | 732 | { |
| 733 | 733 | UINT32 dstaddr = srcaddr; |
| r245687 | r245688 | |
|---|---|---|
| 1936 | 1936 | memcpy(&buffer[tile * 8], &srcgfx[srctile * 8], 8); |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | memcpy(srcgfx, buffer, 0x18000); | |
| 1939 | memcpy(srcgfx, &buffer[0], 0x18000); | |
| 1940 | 1940 | |
| 1941 | 1941 | m_bootleg_id = BLOCK2; |
| 1942 | 1942 | arkanoid_bootleg_init(); |
| r245687 | r245688 | |
|---|---|---|
| 2090 | 2090 | |
| 2091 | 2091 | void astra_addresslines( UINT16* src, size_t srcsize, int small ) |
| 2092 | 2092 | { |
| 2093 | d | |
| 2093 | std::vector<UINT16> dst(srcsize/2); | |
| 2094 | 2094 | |
| 2095 | 2095 | int blocksize; |
| 2096 | 2096 | |
| r245687 | r245688 | |
| 2106 | 2106 | } |
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | memcpy(src,dst, srcsize); | |
| 2109 | memcpy(src,&dst[0], srcsize); | |
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | 2112 |
| r245687 | r245688 | |
|---|---|---|
| 700 | 700 | buf1[addr] = rom[x]; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | memcpy(rom, buf1, length); | |
| 703 | memcpy(rom, &buf1[0], length); | |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | READ32_MEMBER(backfire_state::backfire_speedup_r) |
| r245687 | r245688 | |
|---|---|---|
| 1665 | 1665 | |
| 1666 | 1666 | dynamic_buffer tmp(0x8000); |
| 1667 | 1667 | rom = memregion("audiocpu")->base() + 0x8000; |
| 1668 | memcpy(tmp, rom, 0x8000); | |
| 1668 | memcpy(&tmp[0], rom, 0x8000); | |
| 1669 | 1669 | |
| 1670 | 1670 | for (i = 0; i < 0x8000; i++) |
| 1671 | 1671 | { |
| r245687 | r245688 | |
|---|---|---|
| 782 | 782 | int startblock = -1; |
| 783 | 783 | int endblock = -1; |
| 784 | 784 | |
| 785 | d | |
| 785 | std::vector<int> reelsizes; | |
| 786 | 786 | |
| 787 | 787 | // these are for sc4dnd ONLY, need to work out how the code calculates them |
| 788 | 788 | |
| r245687 | r245688 | |
| 790 | 790 | // code that points at these is likely to be complex because it's conditional on the game code / mode.. |
| 791 | 791 | if (!strcmp(machine.system().name, "sc4dnd")) |
| 792 | 792 | { |
| 793 | reelsizes.append(16); | |
| 794 | reelsizes.append(16); | |
| 795 | reelsizes.append(16); | |
| 796 | reelsizes.append(16); | |
| 797 | reelsizes.append(12); | |
| 798 | reelsizes.append(16); | |
| 799 | reelsizes.append(16); | |
| 793 | reelsizes.push_back(16); | |
| 794 | reelsizes.push_back(16); | |
| 795 | reelsizes.push_back(16); | |
| 796 | reelsizes.push_back(16); | |
| 797 | reelsizes.push_back(12); | |
| 798 | reelsizes.push_back(16); | |
| 799 | reelsizes.push_back(16); | |
| 800 | 800 | |
| 801 | 801 | startblock = 0x8d74c; |
| 802 | 802 | } |
| 803 | 803 | else if (!strcmp(machine.system().name, "sc4dndtp")) |
| 804 | 804 | { |
| 805 | reelsizes.append(16); | |
| 806 | reelsizes.append(16); | |
| 807 | reelsizes.append(16); | |
| 808 | reelsizes.append(12); | |
| 809 | reelsizes.append(16); | |
| 810 | reelsizes.append(16); | |
| 811 | reelsizes.append(16); | |
| 805 | reelsizes.push_back(16); | |
| 806 | reelsizes.push_back(16); | |
| 807 | reelsizes.push_back(16); | |
| 808 | reelsizes.push_back(12); | |
| 809 | reelsizes.push_back(16); | |
| 810 | reelsizes.push_back(16); | |
| 811 | reelsizes.push_back(16); | |
| 812 | 812 | |
| 813 | 813 | startblock = 0x9d252; |
| 814 | 814 | } |
| 815 | 815 | else if (!strcmp(machine.system().name, "sc4dnddw")) |
| 816 | 816 | { |
| 817 | reelsizes.append(16); | |
| 818 | reelsizes.append(16); | |
| 819 | reelsizes.append(16); | |
| 820 | reelsizes.append(12); | |
| 821 | reelsizes.append(20); | |
| 822 | reelsizes.append(20); | |
| 823 | reelsizes.append(20); | |
| 817 | reelsizes.push_back(16); | |
| 818 | reelsizes.push_back(16); | |
| 819 | reelsizes.push_back(16); | |
| 820 | reelsizes.push_back(12); | |
| 821 | reelsizes.push_back(20); | |
| 822 | reelsizes.push_back(20); | |
| 823 | reelsizes.push_back(20); | |
| 824 | 824 | |
| 825 | 825 | startblock = 0x9b8c8; |
| 826 | 826 | } |
| r245687 | r245688 | |
| 828 | 828 | |
| 829 | 829 | int total_reel_symbols = 0; |
| 830 | 830 | |
| 831 | for (int i = 0; i < reelsizes. | |
| 831 | for (unsigned int i = 0; i < reelsizes.size(); i++) | |
| 832 | 832 | { |
| 833 | 833 | total_reel_symbols += reelsizes[i]; |
| 834 | 834 | } |
| r245687 | r245688 | |
|---|---|---|
| 610 | 610 | |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | memcpy(src, buffer, len); | |
| 613 | memcpy(src, &buffer[0], len); | |
| 614 | 614 | } |
| 615 | 615 | GAME( 1987, blktiger, 0, blktiger, blktiger, driver_device, 0, ROT0, "Capcom", "Black Tiger", GAME_SUPPORTS_SAVE ) |
| 616 | 616 | GAME( 1987, blktigera, blktiger, blktiger, blktiger, driver_device, 0, ROT0, "Capcom", "Black Tiger (older)", GAME_SUPPORTS_SAVE ) |
| r245687 | r245688 | |
|---|---|---|
| 4818 | 4818 | int i; |
| 4819 | 4819 | for (i = 0; i < len; i++) |
| 4820 | 4820 | buffer[i ^ 0xdf88] = src[BITSWAP24(i,23,22,21,20,19,9,7,3,15,4,17,14,18,2,16,5,11,8,6,13,1,10,12,0)]; |
| 4821 | memcpy(src, buffer, len); | |
| 4821 | memcpy(src, &buffer[0], len); | |
| 4822 | 4822 | } |
| 4823 | 4823 | |
| 4824 | 4824 | unpack_sprites("sprites0"); |
| r245687 | r245688 | |
| 4885 | 4885 | buffer[j ^ 7] = (src[i] >> 4) | (src[i] << 4); |
| 4886 | 4886 | } |
| 4887 | 4887 | |
| 4888 | memcpy(src,buffer,len); | |
| 4888 | memcpy(src,&buffer[0],len); | |
| 4889 | 4889 | } |
| 4890 | 4890 | |
| 4891 | 4891 | unpack_sprites("sprites0"); |
| r245687 | r245688 | |
| 4933 | 4933 | int i; |
| 4934 | 4934 | for (i = 0; i < len; i++) |
| 4935 | 4935 | buffer[i ^ 0x950c4] = src[BITSWAP24(i,23,22,21,20,15,10,12,6,11,1,13,3,16,17,2,5,14,7,18,8,4,19,9,0)]; |
| 4936 | memcpy(src, buffer, len); | |
| 4936 | memcpy(src, &buffer[0], len); | |
| 4937 | 4937 | } |
| 4938 | 4938 | |
| 4939 | 4939 | sailormn_unpack_tiles("layer2"); |
| r245687 | r245688 | |
|---|---|---|
| 1746 | 1746 | dynamic_buffer buf(length); |
| 1747 | 1747 | int i; |
| 1748 | 1748 | |
| 1749 | memcpy(buf,rom,length); | |
| 1749 | memcpy(&buf[0],rom,length); | |
| 1750 | 1750 | |
| 1751 | 1751 | for(i = 0; i < length; i++) |
| 1752 | 1752 | { |
| r245687 | r245688 | |
|---|---|---|
| 8646 | 8646 | int i; |
| 8647 | 8647 | int length = memregion( "gfx" )->bytes(); |
| 8648 | 8648 | UINT16 *rom = (UINT16 *)memregion("gfx")->base(); |
| 8649 | d | |
| 8649 | std::vector<UINT16> buf( length ); | |
| 8650 | 8650 | |
| 8651 | memcpy (buf, rom, length); | |
| 8651 | memcpy (&buf[0], rom, length); | |
| 8652 | 8652 | |
| 8653 | 8653 | for (i = 0; i < length/2; i++) { |
| 8654 | 8654 | rom[i] = buf[((i & ~7) >> 2) | ((i & 4) << 18) | ((i & 2) >> 1) | ((i & 1) << 21)]; |
| r245687 | r245688 | |
|---|---|---|
| 237 | 237 | { |
| 238 | 238 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x0000, 0x03ff, "bank3"); |
| 239 | 239 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x0000, 0x03ff, write8_delegate(FUNC(palette_device::write), m_palette.target())); |
| 240 | membank("bank3")->set_base(m_paletteram); | |
| 240 | membank("bank3")->set_base(&m_paletteram[0]); | |
| 241 | 241 | } |
| 242 | 242 | else |
| 243 | 243 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x0000, 0x03ff, "bank1"); /* RAM */ |
| r245687 | r245688 | |
|---|---|---|
| 436 | 436 | /* adr line swaps */ |
| 437 | 437 | ROM = memregion("user1")->base(); |
| 438 | 438 | len = memregion("user1")->bytes(); |
| 439 | memcpy( buffer, ROM, len ); | |
| 439 | memcpy( &buffer[0], ROM, len ); | |
| 440 | 440 | |
| 441 | 441 | for(i=0;i<len;i++) |
| 442 | 442 | { |
| r245687 | r245688 | |
| 445 | 445 | |
| 446 | 446 | ROM = memregion("user2")->base(); |
| 447 | 447 | len = memregion("user2")->bytes(); |
| 448 | memcpy( buffer, ROM, len ); | |
| 448 | memcpy( &buffer[0], ROM, len ); | |
| 449 | 449 | for(i=0;i<len;i++) |
| 450 | 450 | { |
| 451 | 451 | ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; |
| r245687 | r245688 | |
| 453 | 453 | |
| 454 | 454 | ROM = memregion("user3")->base(); |
| 455 | 455 | len = memregion("user3")->bytes(); |
| 456 | memcpy( buffer, ROM, len ); | |
| 456 | memcpy( &buffer[0], ROM, len ); | |
| 457 | 457 | for(i=0;i<len;i++) |
| 458 | 458 | { |
| 459 | 459 | ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; |
| r245687 | r245688 | |
| 461 | 461 | |
| 462 | 462 | ROM = memregion("user4")->base(); |
| 463 | 463 | len = memregion("user4")->bytes(); |
| 464 | memcpy( buffer, ROM, len ); | |
| 464 | memcpy( &buffer[0], ROM, len ); | |
| 465 | 465 | for(i=0;i<len;i++) |
| 466 | 466 | { |
| 467 | 467 | ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; |
| r245687 | r245688 | |
|---|---|---|
| 979 | 979 | /* Playfield 4 also has access to the char graphics, make things easier |
| 980 | 980 | by just copying the chars to both banks (if I just used a different gfx |
| 981 | 981 | bank then the colours would be wrong). */ |
| 982 | memcpy(tmp + 0x000000, dst + 0x80000, 0x80000); | |
| 983 | memcpy(dst + 0x090000, tmp + 0x00000, 0x80000); | |
| 982 | memcpy(&tmp[0x000000], dst + 0x80000, 0x80000); | |
| 983 | memcpy(dst + 0x090000, &tmp[0x00000], 0x80000); | |
| 984 | 984 | memcpy(dst + 0x080000, src + 0x00000, 0x10000); |
| 985 | 985 | memcpy(dst + 0x110000, src + 0x10000, 0x10000); |
| 986 | 986 | } |
| r245687 | r245688 | |
| 994 | 994 | /* Playfield 4 also has access to the char graphics, make things easier |
| 995 | 995 | by just copying the chars to both banks (if I just used a different gfx |
| 996 | 996 | bank then the colours would be wrong). */ |
| 997 | memcpy(tmp + 0x000000, dst + 0x80000, 0x80000); | |
| 998 | memcpy(dst + 0x090000, tmp + 0x00000, 0x80000); | |
| 997 | memcpy(&tmp[0x000000], dst + 0x80000, 0x80000); | |
| 998 | memcpy(dst + 0x090000, &tmp[0x00000], 0x80000); | |
| 999 | 999 | memcpy(dst + 0x080000, src + 0x00000, 0x10000); |
| 1000 | 1000 | memcpy(dst + 0x110000, src + 0x10000, 0x10000); |
| 1001 | 1001 | } |
| r245687 | r245688 | |
|---|---|---|
| 662 | 662 | UINT32 oldaddr, newadr, length,j; |
| 663 | 663 | UINT8 *src, *dst; |
| 664 | 664 | dynamic_buffer temp(0x10000); |
| 665 | src = temp; | |
| 665 | src = &temp[0]; | |
| 666 | 666 | dst = memregion("gfx1")->base(); |
| 667 | 667 | length = memregion("gfx1")->bytes(); |
| 668 | 668 | memcpy(src, dst, length); |
| r245687 | r245688 | |
|---|---|---|
| 653 | 653 | buf1[addr] = rom[x]; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | memcpy(rom,buf1,length); | |
| 656 | memcpy(rom,&buf1[0],length); | |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | DRIVER_INIT_MEMBER(deco156_state,hvysmsh) |
| r245687 | r245688 | |
|---|---|---|
| 3699 | 3699 | dynamic_buffer tmp(0x80000); |
| 3700 | 3700 | |
| 3701 | 3701 | /* Reorder bitplanes to make decoding easier */ |
| 3702 | memcpy(tmp,RAM+0x80000,0x80000); | |
| 3702 | memcpy(&tmp[0],RAM+0x80000,0x80000); | |
| 3703 | 3703 | memcpy(RAM+0x80000,RAM+0x100000,0x80000); |
| 3704 | memcpy(RAM+0x100000,tmp,0x80000); | |
| 3704 | memcpy(RAM+0x100000,&tmp[0],0x80000); | |
| 3705 | 3705 | |
| 3706 | 3706 | RAM = memregion("gfx2")->base(); |
| 3707 | memcpy(tmp,RAM+0x80000,0x80000); | |
| 3707 | memcpy(&tmp[0],RAM+0x80000,0x80000); | |
| 3708 | 3708 | memcpy(RAM+0x80000,RAM+0x100000,0x80000); |
| 3709 | memcpy(RAM+0x100000,tmp,0x80000); | |
| 3709 | memcpy(RAM+0x100000,&tmp[0],0x80000); | |
| 3710 | 3710 | |
| 3711 | 3711 | deco56_decrypt_gfx(machine(), "gfx1"); /* 141 */ |
| 3712 | 3712 | deco56_decrypt_gfx(machine(), "gfx2"); /* 141 */ |
| r245687 | r245688 | |
| 3718 | 3718 | dynamic_buffer tmp(0x80000); |
| 3719 | 3719 | |
| 3720 | 3720 | /* Reorder bitplanes to make decoding easier */ |
| 3721 | memcpy(tmp,RAM+0x80000,0x80000); | |
| 3721 | memcpy(&tmp[0],RAM+0x80000,0x80000); | |
| 3722 | 3722 | memcpy(RAM+0x80000,RAM+0x100000,0x80000); |
| 3723 | memcpy(RAM+0x100000,tmp,0x80000); | |
| 3723 | memcpy(RAM+0x100000,&tmp[0],0x80000); | |
| 3724 | 3724 | |
| 3725 | 3725 | RAM = memregion("gfx2")->base(); |
| 3726 | memcpy(tmp,RAM+0x80000,0x80000); | |
| 3726 | memcpy(&tmp[0],RAM+0x80000,0x80000); | |
| 3727 | 3727 | memcpy(RAM+0x80000,RAM+0x100000,0x80000); |
| 3728 | memcpy(RAM+0x100000,tmp,0x80000); | |
| 3728 | memcpy(RAM+0x100000,&tmp[0],0x80000); | |
| 3729 | 3729 | |
| 3730 | 3730 | deco56_decrypt_gfx(machine(), "gfx1"); /* 141 */ |
| 3731 | 3731 | deco74_decrypt_gfx(machine(), "gfx2"); |
| r245687 | r245688 | |
|---|---|---|
| 819 | 819 | buf1[addr] = rom[x]; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | memcpy(rom,buf1,length); | |
| 822 | memcpy(rom,&buf1[0],length); | |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | READ32_MEMBER(deco_mlc_state::avengrgs_speedup_r) |
| r245687 | r245688 | |
|---|---|---|
| 5458 | 5458 | /* Address lines scrambling on the blitter data roms */ |
| 5459 | 5459 | { |
| 5460 | 5460 | dynamic_buffer rom(0xc0000); |
| 5461 | memcpy(rom, gfx, 0xc0000); | |
| 5461 | memcpy(&rom[0], gfx, 0xc0000); | |
| 5462 | 5462 | for (i = 0; i < 0xc0000; i++) |
| 5463 | 5463 | gfx[i] = rom[BITSWAP24(i,23,22,21,20,19,18,14,15, 16,17,13,12,11,10,9,8, 7,6,5,4,3,2,1,0)]; |
| 5464 | 5464 | } |
| r245687 | r245688 | |
| 6290 | 6290 | size_t size = memregion("maincpu")->bytes(); |
| 6291 | 6291 | dynamic_buffer rom1(size); |
| 6292 | 6292 | |
| 6293 | memcpy(rom1, rom, size); | |
| 6293 | memcpy(&rom1[0], rom, size); | |
| 6294 | 6294 | for (i = 0; i < size; i++) |
| 6295 | 6295 | rom[i] = BITSWAP8(rom1[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8, 1,6,5,4,3,2,7, 0)], 7,6, 1,4,3,2,5,0); |
| 6296 | 6296 | } |
| r245687 | r245688 | |
| 6302 | 6302 | size_t size = memregion("maincpu")->bytes(); |
| 6303 | 6303 | dynamic_buffer rom1(size); |
| 6304 | 6304 | |
| 6305 | memcpy(rom1, rom, size); | |
| 6305 | memcpy(&rom1[0], rom, size); | |
| 6306 | 6306 | for (i = 0; i < size; i++) |
| 6307 | 6307 | { |
| 6308 | 6308 | j = i & ~0x7e00; |
| r245687 | r245688 | |
|---|---|---|
| 513 | 513 | dynamic_buffer temp(0x10000); |
| 514 | 514 | |
| 515 | 515 | /* make a temporary copy of the character data */ |
| 516 | src = temp; | |
| 516 | src = &temp[0]; | |
| 517 | 517 | dst = memregion("gfx1")->base(); |
| 518 | 518 | length = memregion("gfx1")->bytes(); |
| 519 | 519 | memcpy(src, dst, length); |
| r245687 | r245688 | |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /* make a temporary copy of the sprite data */ |
| 534 | src = temp; | |
| 534 | src = &temp[0]; | |
| 535 | 535 | dst = memregion("gfx2")->base(); |
| 536 | 536 | length = memregion("gfx2")->bytes(); |
| 537 | 537 | memcpy(src, dst, length); |
| r245687 | r245688 | |
|---|---|---|
| 328 | 328 | dynamic_buffer temp(0x10000); |
| 329 | 329 | |
| 330 | 330 | /* make a temporary copy of the character data */ |
| 331 | src = temp; | |
| 331 | src = &temp[0]; | |
| 332 | 332 | dst = memregion("gfx1")->base(); |
| 333 | 333 | length = memregion("gfx1")->bytes(); |
| 334 | 334 | memcpy(src, dst, length); |
| r245687 | r245688 | |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /* make a temporary copy of the sprite data */ |
| 349 | src = temp; | |
| 349 | src = &temp[0]; | |
| 350 | 350 | dst = memregion("gfx2")->base(); |
| 351 | 351 | length = memregion("gfx2")->bytes(); |
| 352 | 352 | memcpy(src, dst, length); |
| r245687 | r245688 | |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /* make a temporary copy of the character data */ |
| 370 | src = temp; | |
| 370 | src = &temp[0]; | |
| 371 | 371 | dst = memregion("gfx3")->base(); |
| 372 | 372 | length = memregion("gfx3")->bytes(); |
| 373 | 373 | memcpy(src, dst, length); |
| r245687 | r245688 | |
| 386 | 386 | dst[newaddr] = src[oldaddr]; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | src = temp; | |
| 389 | src = &temp[0]; | |
| 390 | 390 | dst = memregion("user1")->base(); |
| 391 | 391 | length = memregion("user1")->bytes(); |
| 392 | 392 | memcpy(src, dst, length); |
| r245687 | r245688 | |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
| 401 | src = temp; | |
| 401 | src = &temp[0]; | |
| 402 | 402 | dst = memregion("user2")->base(); |
| 403 | 403 | length = memregion("user2")->bytes(); |
| 404 | 404 | memcpy(src, dst, length); |
| r245687 | r245688 | |
|---|---|---|
| 427 | 427 | dynamic_buffer buf(len); |
| 428 | 428 | for (int i = 0; i < len; i++) |
| 429 | 429 | buf[i ^ 0x1ff] = ROM[i]; |
| 430 | memcpy(ROM, buf, len); | |
| 430 | memcpy(ROM, &buf[0], len); | |
| 431 | 431 | |
| 432 | 432 | m_pot_clear_timer = timer_alloc(TIMER_POT_CLEAR); |
| 433 | 433 | m_quarter_timer = timer_alloc(TIMER_QUARTER); |
| r245687 | r245688 | |
|---|---|---|
| 140 | 140 | |
| 141 | 141 | // address line swap |
| 142 | 142 | dynamic_buffer buf(memsize); |
| 143 | memcpy(buf, mem, memsize); | |
| 143 | memcpy(&buf[0], mem, memsize); | |
| 144 | 144 | for ( i = 0; i < memsize; i++ ) |
| 145 | 145 | { |
| 146 | 146 | mem[BITSWAP16(i,11,9,8,13,14,15,12,7,6,5,4,3,2,1,0,10)] = buf[i]; |
| r245687 | r245688 | |
|---|---|---|
| 5883 | 5883 | |
| 5884 | 5884 | { |
| 5885 | 5885 | dynamic_buffer buffer(size); |
| 5886 | memcpy(buffer, rom, size); | |
| 5886 | memcpy(&buffer[0], rom, size); | |
| 5887 | 5887 | |
| 5888 | 5888 | |
| 5889 | 5889 | /* address lines swap: fedcba9876543210 -> fedcba9820134567 */ |
| r245687 | r245688 | |
| 5902 | 5902 | |
| 5903 | 5903 | { |
| 5904 | 5904 | dynamic_buffer buffer(sizeg); |
| 5905 | memcpy(buffer, gfxrom, sizeg); | |
| 5905 | memcpy(&buffer[0], gfxrom, sizeg); | |
| 5906 | 5906 | |
| 5907 | 5907 | /* address lines swap: fedcba9876543210 -> fedcb67584a39012 */ |
| 5908 | 5908 | |
| r245687 | r245688 | |
| 5927 | 5927 | |
| 5928 | 5928 | { |
| 5929 | 5929 | dynamic_buffer buffer(sizep); |
| 5930 | memcpy(buffer, prom, sizep); | |
| 5930 | memcpy(&buffer[0], prom, sizep); | |
| 5931 | 5931 | |
| 5932 | 5932 | |
| 5933 | 5933 | /* address lines swap: fedcba9876543210 -> fedcba9487652013 */ |
| r245687 | r245688 | |
| 6068 | 6068 | |
| 6069 | 6069 | { |
| 6070 | 6070 | dynamic_buffer buffer(size); |
| 6071 | memcpy(buffer, rom, size); | |
| 6071 | memcpy(&buffer[0], rom, size); | |
| 6072 | 6072 | |
| 6073 | 6073 | |
| 6074 | 6074 | /* address lines swap: fedcba9876543210 -> fedcba9867543210 */ |
| r245687 | r245688 | |
| 6087 | 6087 | |
| 6088 | 6088 | { |
| 6089 | 6089 | dynamic_buffer buffer(sizeg); |
| 6090 | memcpy(buffer, gfxrom, sizeg); | |
| 6090 | memcpy(&buffer[0], gfxrom, sizeg); | |
| 6091 | 6091 | |
| 6092 | 6092 | /* address lines swap: fedcba9876543210 -> fedcb67584a39012 */ |
| 6093 | 6093 | |
| r245687 | r245688 | |
| 6172 | 6172 | |
| 6173 | 6173 | { |
| 6174 | 6174 | dynamic_buffer buffer(size); |
| 6175 | memcpy(buffer, rom, size); | |
| 6175 | memcpy(&buffer[0], rom, size); | |
| 6176 | 6176 | |
| 6177 | 6177 | |
| 6178 | 6178 | /* address lines swap: fedcba9876543210 -> fedcba9867543210 */ |
| r245687 | r245688 | |
| 6191 | 6191 | |
| 6192 | 6192 | { |
| 6193 | 6193 | dynamic_buffer buffer(sizeg); |
| 6194 | memcpy(buffer, gfxrom, sizeg); | |
| 6194 | memcpy(&buffer[0], gfxrom, sizeg); | |
| 6195 | 6195 | |
| 6196 | 6196 | /* address lines swap: fedcba9876543210 -> fedcb67584a39012 */ |
| 6197 | 6197 |
| r245687 | r245688 | |
|---|---|---|
| 1561 | 1561 | { |
| 1562 | 1562 | dynamic_buffer buffer(size); |
| 1563 | 1563 | |
| 1564 | memcpy(buffer, ROM, size); | |
| 1564 | memcpy(&buffer[0], ROM, size); | |
| 1565 | 1565 | for( i = 0; i < size; i++ ) |
| 1566 | 1566 | { |
| 1567 | 1567 | ROM[i] = buffer[BITSWAP24(i,23,22,21,20, |
| r245687 | r245688 | |
| 1578 | 1578 | { |
| 1579 | 1579 | dynamic_buffer buffer(size); |
| 1580 | 1580 | |
| 1581 | memcpy(buffer,ROM,size); | |
| 1581 | memcpy(&buffer[0],ROM,size); | |
| 1582 | 1582 | for( i = 0; i < size; i++ ) |
| 1583 | 1583 | { |
| 1584 | 1584 | ROM[i] = buffer[BITSWAP24(i,23,22,21,20, |
| r245687 | r245688 | |
| 1623 | 1623 | 7,6,4, |
| 1624 | 1624 | 3,2,1,0)]; |
| 1625 | 1625 | } |
| 1626 | memcpy(src, buffer, len); | |
| 1626 | memcpy(src, &buffer[0], len); | |
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | 1629 | { |
| r245687 | r245688 | |
| 1639 | 1639 | 7,5,4, |
| 1640 | 1640 | 3,2,1,0)]; |
| 1641 | 1641 | } |
| 1642 | memcpy(src, buffer, len); | |
| 1642 | memcpy(src, &buffer[0], len); | |
| 1643 | 1643 | } |
| 1644 | 1644 | } |
| 1645 | 1645 |
| r245687 | r245688 | |
|---|---|---|
| 5767 | 5767 | dynamic_buffer scratch(romlength); |
| 5768 | 5768 | UINT32 offs; |
| 5769 | 5769 | |
| 5770 | memcpy(scratch, rombase, romlength); | |
| 5770 | memcpy(&scratch[0], rombase, romlength); | |
| 5771 | 5771 | for (offs = 0; offs < romlength; offs++) |
| 5772 | 5772 | { |
| 5773 | 5773 | UINT32 srcoffs = offs & 0x9bf; |
| r245687 | r245688 | |
| 5786 | 5786 | dynamic_buffer scratch(romlength); |
| 5787 | 5787 | UINT32 offs; |
| 5788 | 5788 | |
| 5789 | memcpy(scratch, rombase, romlength); | |
| 5789 | memcpy(&scratch[0], rombase, romlength); | |
| 5790 | 5790 | for (offs = 0; offs < romlength; offs++) |
| 5791 | 5791 | { |
| 5792 | 5792 | UINT32 srcoffs = offs & 0xa7f; |
| r245687 | r245688 | |
|---|---|---|
| 3019 | 3019 | |
| 3020 | 3020 | for (int i=0;i<88;i++) |
| 3021 | 3021 | { |
| 3022 | memcpy(buffer | |
| 3022 | memcpy(&buffer[i*0x100], rom+ckonggx_remap[i], 0x100); | |
| 3023 | 3023 | |
| 3024 | 3024 | } |
| 3025 | 3025 | |
| 3026 | memcpy(rom, buffer, 0x5800); | |
| 3026 | memcpy(rom, &buffer[0], 0x5800); | |
| 3027 | 3027 | } |
| 3028 | 3028 | |
| 3029 | 3029 |
| r245687 | r245688 | |
|---|---|---|
| 1673 | 1673 | /* highly strange -- the address bits on the chip at 2J (and only that |
| 1674 | 1674 | chip) are scrambled -- this is verified on the schematics! */ |
| 1675 | 1675 | |
| 1676 | memcpy(data, &gfx2_base[0x88000], 0x8000); | |
| 1676 | memcpy(&data[0], &gfx2_base[0x88000], 0x8000); | |
| 1677 | 1677 | for (i = 0; i < 0x8000; i++) |
| 1678 | 1678 | { |
| 1679 | 1679 | int srcoffs = (i & 0x4000) | ((i << 11) & 0x3800) | ((i >> 3) & 0x07ff); |
| r245687 | r245688 | |
|---|---|---|
| 12424 | 12424 | }; |
| 12425 | 12425 | |
| 12426 | 12426 | dynamic_buffer buffer(0x10000); |
| 12427 | memcpy(buffer,ROM,0x10000); | |
| 12427 | memcpy(&buffer[0],ROM,0x10000); | |
| 12428 | 12428 | |
| 12429 | 12429 | // swap some 0x800 blocks around.. |
| 12430 | 12430 | for (A =0;A<32; A++) |
| 12431 | 12431 | { |
| 12432 | memcpy(ROM+A*0x800,buffer | |
| 12432 | memcpy(ROM+A*0x800,&buffer[cherry_swaptables[A]],0x800); | |
| 12433 | 12433 | } |
| 12434 | 12434 | } |
| 12435 | 12435 |
| r245687 | r245688 | |
|---|---|---|
| 246 | 246 | emu_timer *m_blitter_reset_timer; |
| 247 | 247 | offs_t m_collision_detection; |
| 248 | 248 | int m_latch_delay; |
| 249 | d | |
| 249 | std::vector<UINT8> m_paletteram; | |
| 250 | 250 | |
| 251 | 251 | DECLARE_WRITE8_MEMBER(bgtile_w); |
| 252 | 252 | DECLARE_READ8_MEMBER(blitter_status_r); |
| r245687 | r245688 | |
| 1191 | 1191 | int bit0, bit1, bit2, bit3, bit4; |
| 1192 | 1192 | |
| 1193 | 1193 | // the four 16x4-bit SN74S189 SRAM chips are assumed be the game's 32-byte palette RAM |
| 1194 | sram_189 = m_paletteram; | |
| 1194 | sram_189 = &m_paletteram[0]; | |
| 1195 | 1195 | |
| 1196 | 1196 | // each of the three 32-byte 6330 PROM is wired to an RGB component output |
| 1197 | 1197 | prom_6330 = memregion("proms")->base(); |
| r245687 | r245688 | |
|---|---|---|
| 1396 | 1396 | |
| 1397 | 1397 | for (i=0;i<gfxregionsize/2;i+=tilesize) |
| 1398 | 1398 | { |
| 1399 | memcpy((buffer+i*2)+tilesize, gfxregion+i, tilesize); | |
| 1400 | memcpy((buffer+i*2), gfxregion+i+(gfxregionsize/2), tilesize); | |
| 1399 | memcpy(&buffer[i*2+tilesize], gfxregion+i, tilesize); | |
| 1400 | memcpy(&buffer[i*2], gfxregion+i+(gfxregionsize/2), tilesize); | |
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | memcpy(gfxregion, buffer, gfxregionsize); | |
| 1403 | memcpy(gfxregion, &buffer[0], gfxregionsize); | |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | DRIVER_INIT_MEMBER(hng64_state,hng64_reorder_gfx) |
| r245687 | r245688 | |
|---|---|---|
| 792 | 792 | int i,j; |
| 793 | 793 | int rom_size = 0x80000; |
| 794 | 794 | UINT16 *src = (UINT16 *) (memregion("maincpu")->base()); |
| 795 | d | |
| 795 | std::vector<UINT16> result_data(rom_size/2); | |
| 796 | 796 | |
| 797 | 797 | for (i=0; i<rom_size/2; i++) |
| 798 | 798 | { |
| r245687 | r245688 | |
| 812 | 812 | result_data[j] = x; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | memcpy(src,result_data,rom_size); | |
| 815 | memcpy(src,&result_data[0],rom_size); | |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | |
| r245687 | r245688 | |
| 822 | 822 | int i,j; |
| 823 | 823 | int rom_size = 0x80000; |
| 824 | 824 | UINT16 *src = (UINT16 *) (memregion("maincpu")->base()); |
| 825 | d | |
| 825 | std::vector<UINT16> result_data(rom_size/2); | |
| 826 | 826 | |
| 827 | 827 | for (i=0; i<rom_size/2; i++) |
| 828 | 828 | { |
| r245687 | r245688 | |
| 850 | 850 | result_data[j] = x; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | memcpy(src,result_data,rom_size); | |
| 853 | memcpy(src,&result_data[0],rom_size); | |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | |
| r245687 | r245688 | |
| 979 | 979 | for (i=0; i<rom_size; i++) |
| 980 | 980 | result_data[i] = src[BITSWAP24(i, 23,22,21,20, 19, 17,16,15, 13,12, 10,9,8,7,6,5,4, 2,1, 3, 11, 14, 18, 0)]; |
| 981 | 981 | |
| 982 | memcpy(src,result_data,rom_size); | |
| 982 | memcpy(src,&result_data[0],rom_size); | |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | void igs011_state::drgnwrld_gfx_decrypt() |
| r245687 | r245688 | |
| 992 | 992 | for (i=0; i<rom_size; i++) |
| 993 | 993 | result_data[i] = src[BITSWAP24(i, 23,22,21,20,19,18,17,16,15, 12, 13, 14, 11,10,9,8,7,6,5,4,3,2,1,0)]; |
| 994 | 994 | |
| 995 | memcpy(src,result_data,rom_size); | |
| 995 | memcpy(src,&result_data[0],rom_size); | |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 |
| r245687 | r245688 | |
|---|---|---|
| 689 | 689 | dynamic_buffer tmp(length); |
| 690 | 690 | int i; |
| 691 | 691 | |
| 692 | memcpy(tmp,rom,length); | |
| 692 | memcpy(&tmp[0],rom,length); | |
| 693 | 693 | for (i = 0;i < length;i++) |
| 694 | 694 | { |
| 695 | 695 | int addr = (i & ~0xffff) | BITSWAP16(i,15,14,13,12,11,10,6,7,8,9,5,4,3,2,1,0); |
| r245687 | r245688 | |
| 983 | 983 | int i; |
| 984 | 984 | |
| 985 | 985 | int addr; |
| 986 | memcpy(tmp, rom, length); | |
| 986 | memcpy(&tmp[0], rom, length); | |
| 987 | 987 | for (i = 0; i < length; i++) |
| 988 | 988 | { |
| 989 | 989 | addr = (i & ~0xffffff) | BITSWAP24(i,23,22,21,20,19,18,17,1,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,0); |
| r245687 | r245688 | |
| 1207 | 1207 | dynamic_buffer tmp(length); |
| 1208 | 1208 | int i; |
| 1209 | 1209 | |
| 1210 | memcpy(tmp,rom,length); | |
| 1210 | memcpy(&tmp[0],rom,length); | |
| 1211 | 1211 | for (i = 0;i < length;i++) |
| 1212 | 1212 | { |
| 1213 | 1213 | int addr = (i & ~0xff) | BITSWAP8(i,7,4,5,6,3,2,1,0); |
| r245687 | r245688 | |
|---|---|---|
| 296 | 296 | |
| 297 | 297 | for (i=0; i<rom_size; i+=0x200) |
| 298 | 298 | { |
| 299 | memcpy(src+i+0x000,result_data+i+0x000,0x80); | |
| 300 | memcpy(src+i+0x080,result_data+i+0x100,0x80); | |
| 301 | memcpy(src+i+0x100,result_data+i+0x080,0x80); | |
| 302 | memcpy(src+i+0x180,result_data+i+0x180,0x80); | |
| 299 | memcpy(src+i+0x000,&result_data[i+0x000],0x80); | |
| 300 | memcpy(src+i+0x080,&result_data[i+0x100],0x80); | |
| 301 | memcpy(src+i+0x100,&result_data[i+0x080],0x80); | |
| 302 | memcpy(src+i+0x180,&result_data[i+0x180],0x80); | |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 |
| r245687 | r245688 | |
|---|---|---|
| 2328 | 2328 | rom = memregion("gfx1")->base(); |
| 2329 | 2329 | length = memregion("gfx1")->bytes(); |
| 2330 | 2330 | dynamic_buffer tmp(length); |
| 2331 | memcpy(tmp,rom,length); | |
| 2331 | memcpy(&tmp[0],rom,length); | |
| 2332 | 2332 | for (A = 0;A < length;A++) |
| 2333 | 2333 | { |
| 2334 | 2334 | int addr = (A & ~0xffff) | BITSWAP16(A,15,14,13,12,11,10,9,8,7,6,5,4,3,0,1,2); |
| r245687 | r245688 | |
|---|---|---|
| 1320 | 1320 | for (i = 0; i < len; i++) |
| 1321 | 1321 | temp[i] = eeprom[BITSWAP8(i,7,5,4,3,2,1,0,6)]; |
| 1322 | 1322 | |
| 1323 | memcpy(eeprom, temp, len); | |
| 1323 | memcpy(eeprom, &temp[0], len); | |
| 1324 | 1324 | |
| 1325 | 1325 | } |
| 1326 | 1326 | } |
| r245687 | r245688 | |
|---|---|---|
| 854 | 854 | |
| 855 | 855 | /* Unscrambling address lines */ |
| 856 | 856 | dynamic_buffer buf(memsize); |
| 857 | memcpy(buf, mem, memsize); | |
| 857 | memcpy(&buf[0], mem, memsize); | |
| 858 | 858 | for ( i = 0; i < memsize; i++ ) |
| 859 | 859 | { |
| 860 | 860 | mem[BITSWAP16(i,15,14,5,6,3,0,12,1,9,13,4,7,10,8,2,11)] = buf[i]; |
| r245687 | r245688 | |
|---|---|---|
| 1073 | 1073 | 7,4, |
| 1074 | 1074 | 3,2,1,0)]; |
| 1075 | 1075 | } |
| 1076 | memcpy(src,buffer,len); | |
| 1076 | memcpy(src,&buffer[0],len); | |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | } |
| r245687 | r245688 | |
|---|---|---|
| 3692 | 3692 | |
| 3693 | 3693 | dynamic_buffer buffer(size); |
| 3694 | 3694 | |
| 3695 | memcpy(buffer,rom,size); | |
| 3695 | memcpy(&buffer[0],rom,size); | |
| 3696 | 3696 | |
| 3697 | 3697 | /* address lines swap: ..dcba9876543210 -> ..acb8937654d210 */ |
| 3698 | 3698 | for (i = 0;i < size;i++) |
| r245687 | r245688 | |
| 3718 | 3718 | |
| 3719 | 3719 | dynamic_buffer buffer(size); |
| 3720 | 3720 | |
| 3721 | memcpy(buffer,rom,size); | |
| 3721 | memcpy(&buffer[0],rom,size); | |
| 3722 | 3722 | |
| 3723 | 3723 | /* address lines swap: fedcba9876543210 -> fe8cb39d7654a210 */ |
| 3724 | 3724 | for (i = 0;i < size;i++) |
| r245687 | r245688 | |
| 3742 | 3742 | |
| 3743 | 3743 | dynamic_buffer buffer(size); |
| 3744 | 3744 | |
| 3745 | memcpy(buffer,rom,size); | |
| 3745 | memcpy(&buffer[0],rom,size); | |
| 3746 | 3746 | |
| 3747 | 3747 | /* address lines swap: fedcba9876543210 -> fe3cbd9a76548210 */ |
| 3748 | 3748 | for (i = 0;i < size;i++) |
| r245687 | r245688 | |
|---|---|---|
| 122 | 122 | PALETTE_INIT_MEMBER(meyc8088_state, meyc8088) |
| 123 | 123 | { |
| 124 | 124 | const UINT8 *color_prom = memregion("proms")->base(); |
| 125 | d | |
| 125 | std::vector<rgb_t> rgb; | |
| 126 | 126 | |
| 127 | 127 | compute_res_net_all(rgb, color_prom, meyc8088_decode_info, meyc8088_net_info); |
| 128 | palette.set_pen_colors(0, rgb | |
| 128 | palette.set_pen_colors(0, rgb); | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | UINT32 meyc8088_state::screen_update_meyc8088(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r245687 | r245688 | |
|---|---|---|
| 2249 | 2249 | /* bank f */12, 12, |
| 2250 | 2250 | }; |
| 2251 | 2251 | |
| 2252 | memcpy(source, dst, len); | |
| 2252 | memcpy(&source[0], dst, len); | |
| 2253 | 2253 | for (x = 0; x < 40; x += 2) |
| 2254 | 2254 | { |
| 2255 | 2255 | if (tablebank[x] != -1) |
| r245687 | r245688 | |
|---|---|---|
| 474 | 474 | memcpy(&temprom[j*0x40],&igrosoft_gamble_gfx[romoffset+(jscr*0x40)],0x40); |
| 475 | 475 | |
| 476 | 476 | } |
| 477 | memcpy(&igrosoft_gamble_gfx[romoffset],temprom,igrosoft_gamble_ROM_SIZE); | |
| 477 | memcpy(&igrosoft_gamble_gfx[romoffset],&temprom[0],igrosoft_gamble_ROM_SIZE); | |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
| r245687 | r245688 | |
| 507 | 507 | dynamic_buffer temprom(igrosoft_gamble_ROM_SIZE); |
| 508 | 508 | |
| 509 | 509 | /* ROMs decode */ |
| 510 | rom_decodel(&igrosoft_gamble_gfx[0x000000], temprom, xor12, xor_addr); | |
| 511 | rom_decodel(&igrosoft_gamble_gfx[0x100000], temprom, xor12, xor_addr); | |
| 512 | rom_decodel(&igrosoft_gamble_gfx[0x200000], temprom, xor34, xor_addr); | |
| 513 | rom_decodel(&igrosoft_gamble_gfx[0x300000], temprom, xor34, xor_addr); | |
| 514 | rom_decodeh(&igrosoft_gamble_gfx[0x080000], temprom, xor56, xor_addr); | |
| 515 | rom_decodeh(&igrosoft_gamble_gfx[0x180000], temprom, xor56, xor_addr); | |
| 516 | rom_decodeh(&igrosoft_gamble_gfx[0x280000], temprom, xor78, xor_addr); | |
| 517 | rom_decodeh(&igrosoft_gamble_gfx[0x380000], temprom, xor78, xor_addr); | |
| 510 | rom_decodel(&igrosoft_gamble_gfx[0x000000], &temprom[0], xor12, xor_addr); | |
| 511 | rom_decodel(&igrosoft_gamble_gfx[0x100000], &temprom[0], xor12, xor_addr); | |
| 512 | rom_decodel(&igrosoft_gamble_gfx[0x200000], &temprom[0], xor34, xor_addr); | |
| 513 | rom_decodel(&igrosoft_gamble_gfx[0x300000], &temprom[0], xor34, xor_addr); | |
| 514 | rom_decodeh(&igrosoft_gamble_gfx[0x080000], &temprom[0], xor56, xor_addr); | |
| 515 | rom_decodeh(&igrosoft_gamble_gfx[0x180000], &temprom[0], xor56, xor_addr); | |
| 516 | rom_decodeh(&igrosoft_gamble_gfx[0x280000], &temprom[0], xor78, xor_addr); | |
| 517 | rom_decodeh(&igrosoft_gamble_gfx[0x380000], &temprom[0], xor78, xor_addr); | |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | INLINE void roment_decodel(UINT8 *romptr, UINT8 *tmprom, UINT8 xor_data, UINT32 xor_add) |
| r245687 | r245688 | |
| 546 | 546 | dynamic_buffer temprom(igrosoft_gamble_ROM_SIZE); |
| 547 | 547 | |
| 548 | 548 | /* ROMs decode */ |
| 549 | roment_decodel(&igrosoft_gamble_gfx[0x000000], temprom, xor12, xor_addr); | |
| 550 | roment_decodel(&igrosoft_gamble_gfx[0x100000], temprom, xor12, xor_addr); | |
| 551 | roment_decodel(&igrosoft_gamble_gfx[0x200000], temprom, xor34, xor_addr); | |
| 552 | roment_decodel(&igrosoft_gamble_gfx[0x300000], temprom, xor34, xor_addr); | |
| 553 | roment_decodeh(&igrosoft_gamble_gfx[0x080000], temprom, xor56, xor_addr); | |
| 554 | roment_decodeh(&igrosoft_gamble_gfx[0x180000], temprom, xor56, xor_addr); | |
| 555 | roment_decodeh(&igrosoft_gamble_gfx[0x280000], temprom, xor78, xor_addr); | |
| 556 | roment_decodeh(&igrosoft_gamble_gfx[0x380000], temprom, xor78, xor_addr); | |
| 549 | roment_decodel(&igrosoft_gamble_gfx[0x000000], &temprom[0], xor12, xor_addr); | |
| 550 | roment_decodel(&igrosoft_gamble_gfx[0x100000], &temprom[0], xor12, xor_addr); | |
| 551 | roment_decodel(&igrosoft_gamble_gfx[0x200000], &temprom[0], xor34, xor_addr); | |
| 552 | roment_decodel(&igrosoft_gamble_gfx[0x300000], &temprom[0], xor34, xor_addr); | |
| 553 | roment_decodeh(&igrosoft_gamble_gfx[0x080000], &temprom[0], xor56, xor_addr); | |
| 554 | roment_decodeh(&igrosoft_gamble_gfx[0x180000], &temprom[0], xor56, xor_addr); | |
| 555 | roment_decodeh(&igrosoft_gamble_gfx[0x280000], &temprom[0], xor78, xor_addr); | |
| 556 | roment_decodeh(&igrosoft_gamble_gfx[0x380000], &temprom[0], xor78, xor_addr); | |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | DRIVER_INIT_MEMBER(igrosoft_gamble_state,island2l) |
| r245687 | r245688 | |
|---|---|---|
| 1456 | 1456 | |
| 1457 | 1457 | rom = memregion("maincpu")->base(); |
| 1458 | 1458 | size = 0x8000; |
| 1459 | memcpy(buf, rom, size); | |
| 1459 | memcpy(&buf[0], rom, size); | |
| 1460 | 1460 | for (i = 0; i < size; i++) |
| 1461 | 1461 | { |
| 1462 | 1462 | addr = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,8,11,12,10,9,7,6,5,4,3,2,1,0); |
| r245687 | r245688 | |
| 1465 | 1465 | |
| 1466 | 1466 | rom = memregion("user1")->base(); |
| 1467 | 1467 | size = 0x80000; |
| 1468 | memcpy(buf, rom, size); | |
| 1468 | memcpy(&buf[0], rom, size); | |
| 1469 | 1469 | for (i = 0; i < size; i++) |
| 1470 | 1470 | { |
| 1471 | 1471 | addr = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,8,11,12,10,9,7,6,5,4,3,2,1,0); |
| r245687 | r245688 | |
| 1473 | 1473 | } |
| 1474 | 1474 | rom = memregion("gfx1")->base(); |
| 1475 | 1475 | size = 0x80000; |
| 1476 | memcpy(buf, rom, size); | |
| 1476 | memcpy(&buf[0], rom, size); | |
| 1477 | 1477 | for (i = 0; i < size; i++) |
| 1478 | 1478 | { |
| 1479 | 1479 | addr = BITSWAP24(i,23,22,21,20,19,18,17,15,16,11,10,12,13,14,8,9,1,3,5,7,6,4,2,0); |
| r245687 | r245688 | |
|---|---|---|
| 1516 | 1516 | UINT8 *mono = gfx + size; |
| 1517 | 1517 | int i; |
| 1518 | 1518 | |
| 1519 | memcpy( buffer, gfx, size ); | |
| 1519 | memcpy( &buffer[0], gfx, size ); | |
| 1520 | 1520 | |
| 1521 | 1521 | for ( i = 0; i < size; i += 2 ) |
| 1522 | 1522 | { |
| r245687 | r245688 | |
| 1539 | 1539 | UINT8 *mono = gfx + size; |
| 1540 | 1540 | int i; |
| 1541 | 1541 | |
| 1542 | memcpy( buffer, gfx, size ); | |
| 1542 | memcpy( &buffer[0], gfx, size ); | |
| 1543 | 1543 | |
| 1544 | 1544 | for ( i = 0; i < size; i += 2 ) |
| 1545 | 1545 | { |
| r245687 | r245688 | |
|---|---|---|
| 1454 | 1454 | temp[da] = src[sa]; |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | memcpy(src, temp, length); | |
| 1457 | memcpy(src, &temp[0], length); | |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | void ninjakd2_state::gfx_unscramble() |
| r245687 | r245688 | |
|---|---|---|
| 5235 | 5235 | size_t size = machine.root_device().memregion( "maincpu" )->bytes(); |
| 5236 | 5236 | dynamic_buffer buffer( size ); |
| 5237 | 5237 | |
| 5238 | memcpy( buffer, RAM, size ); | |
| 5238 | memcpy( &buffer[0], RAM, size ); | |
| 5239 | 5239 | for( i = 0; i < size; i++ ) |
| 5240 | 5240 | { |
| 5241 | 5241 | RAM[ i ] = buffer[ BITSWAP24( i, a23, a22, a21, a20, a19, a18, a17, a16, a15, a14, a13, a12, |
| r245687 | r245688 | |
|---|---|---|
| 963 | 963 | temp[da] = src[sa]; |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | memcpy(src, temp, length); | |
| 966 | memcpy(src, &temp[0], length); | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 |
| r245687 | r245688 | |
|---|---|---|
| 797 | 797 | //rearrange bg tilemaps a bit.... |
| 798 | 798 | rom = memregion("user1")->base(); |
| 799 | 799 | size = memregion("user1")->bytes(); |
| 800 | memcpy(buf,rom, size); | |
| 800 | memcpy(&buf[0],rom, size); | |
| 801 | 801 | |
| 802 | 802 | for(j=0;j<16;j++) |
| 803 | 803 | { |
| r245687 | r245688 | |
| 809 | 809 | |
| 810 | 810 | rom = memregion("user2")->base(); |
| 811 | 811 | size = memregion("user2")->bytes(); |
| 812 | memcpy(buf,rom, size); | |
| 812 | memcpy(&buf[0],rom, size); | |
| 813 | 813 | |
| 814 | 814 | for(j=0;j<16;j++) |
| 815 | 815 | { |
| r245687 | r245688 | |
|---|---|---|
| 296 | 296 | |
| 297 | 297 | // address line swap |
| 298 | 298 | dynamic_buffer buf(memsize); |
| 299 | memcpy(buf, mem, memsize); | |
| 299 | memcpy(&buf[0], mem, memsize); | |
| 300 | 300 | for (int i = 0; i < memsize; i++) |
| 301 | 301 | { |
| 302 | 302 | mem[i] = buf[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,5,11,10,9,8,7,6,12,4,3,2,1,0)]; |
| r245687 | r245688 | |
|---|---|---|
| 327 | 327 | { |
| 328 | 328 | UINT16 *rom = (UINT16 *)memregion("maincpu")->base(); |
| 329 | 329 | size_t rom_size = memregion("maincpu")->bytes(); |
| 330 | d | |
| 330 | std::vector<UINT16> buf(rom_size/2); | |
| 331 | 331 | |
| 332 | memcpy (buf, rom, rom_size); | |
| 332 | memcpy (&buf[0], rom, rom_size); | |
| 333 | 333 | |
| 334 | 334 | for (int i=0; i<rom_size/2; i++) |
| 335 | 335 | { |
| r245687 | r245688 | |
| 357 | 357 | dynamic_buffer buf(rom_size); |
| 358 | 358 | |
| 359 | 359 | rom = memregion("gfx1")->base(); |
| 360 | memcpy (buf, rom, rom_size); | |
| 360 | memcpy (&buf[0], rom, rom_size); | |
| 361 | 361 | |
| 362 | 362 | for (i=0; i<rom_size/4; i++) |
| 363 | 363 | { |
| r245687 | r245688 | |
| 380 | 380 | dynamic_buffer buf(rom_size); |
| 381 | 381 | |
| 382 | 382 | rom = memregion("gfx2")->base(); |
| 383 | memcpy (buf, rom, rom_size); | |
| 383 | memcpy (&buf[0], rom, rom_size); | |
| 384 | 384 | |
| 385 | 385 | for (i=0; i<rom_size/4; i++) |
| 386 | 386 | { |
| r245687 | r245688 | |
| 404 | 404 | dynamic_buffer buf(rom_size); |
| 405 | 405 | |
| 406 | 406 | rom = memregion("oki")->base(); |
| 407 | memcpy (buf, rom, rom_size); | |
| 407 | memcpy (&buf[0], rom, rom_size); | |
| 408 | 408 | |
| 409 | 409 | for (i=0; i<rom_size; i++) |
| 410 | 410 | { |
| r245687 | r245688 | |
|---|---|---|
| 670 | 670 | int i; |
| 671 | 671 | for (i = 0;i < len; i++) |
| 672 | 672 | buffer[i] = BITSWAP8(rom[BITSWAP16(i,15,14,13,12,11,10,8,7,0,1,2,4,5,9,3,6) ^ 0xfc],3,4,2,5,1,6,0,7); |
| 673 | memcpy(rom,buffer,len); | |
| 673 | memcpy(rom,&buffer[0],len); | |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | save_item(NAME(m_prot0)); |
| r245687 | r245688 | |
| 689 | 689 | int i; |
| 690 | 690 | for (i = 0;i < len; i++) |
| 691 | 691 | buffer[i] = BITSWAP8(rom[BITSWAP16(i,15,14,13,12,11,10,8,7,6,3,9,5,4,2,1,0) ^ 0x3f],3,4,2,5,1,6,0,7); |
| 692 | memcpy(rom,buffer,len); | |
| 692 | memcpy(rom,&buffer[0],len); | |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | save_item(NAME(m_prot0)); |
| r245687 | r245688 | |
|---|---|---|
| 108 | 108 | optional_device<gfxdecode_device> m_gfxdecode; |
| 109 | 109 | required_device<palette_device> m_palette; |
| 110 | 110 | |
| 111 | d | |
| 111 | std::vector<UINT16> m_vram_rearranged; | |
| 112 | 112 | |
| 113 | 113 | int tilemap_base[4]; |
| 114 | 114 |
| r245687 | r245688 | |
|---|---|---|
| 889 | 889 | int i; |
| 890 | 890 | for (i = 0; i < len; i ++) |
| 891 | 891 | buffer[i] = src[BITSWAP32(i,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,5,6,4,3,2,1,0)]; |
| 892 | memcpy(src, buffer, len); | |
| 892 | memcpy(src, &buffer[0], len); | |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | /* |
| r245687 | r245688 | |
|---|---|---|
| 1392 | 1392 | /* banking */ |
| 1393 | 1393 | dest = memregion(region)->base(); |
| 1394 | 1394 | dynamic_buffer temp(0x4000); |
| 1395 | memcpy(temp, dest, 0x4000); | |
| 1395 | memcpy(&temp[0], dest, 0x4000); | |
| 1396 | 1396 | |
| 1397 | 1397 | /* 16 effective total banks */ |
| 1398 | 1398 | for (i = 0; i < 16; i++) |
| r245687 | r245688 | |
|---|---|---|
| 7431 | 7431 | DRIVER_INIT_CALL(generic_5521); |
| 7432 | 7432 | |
| 7433 | 7433 | // decrypt the bios... |
| 7434 | d | |
| 7434 | std::vector<UINT16> temp(0x20000/2); | |
| 7435 | 7435 | UINT16 *rom = (UINT16 *)memregion("bios")->base(); |
| 7436 | 7436 | for (int addr = 0; addr < 0x20000/2; addr++) |
| 7437 | 7437 | temp[addr ^ 0x4127] = BITSWAP16(rom[addr], 6, 14, 4, 2, 12, 10, 8, 0, 1, 9, 11, 13, 3, 5, 7, 15); |
| 7438 | memcpy(rom, temp, 0x20000); | |
| 7438 | memcpy(rom, &temp[0], 0x20000); | |
| 7439 | 7439 | } |
| 7440 | 7440 | |
| 7441 | 7441 | DRIVER_INIT_MEMBER(isgsm_state,shinfz) |
| 7442 | 7442 | { |
| 7443 | 7443 | init_isgsm(); |
| 7444 | 7444 | |
| 7445 | d | |
| 7445 | std::vector<UINT16> temp(0x200000/2); | |
| 7446 | 7446 | UINT16 *rom = (UINT16 *)memregion("gamecart_rgn")->base(); |
| 7447 | 7447 | for (int addr = 0; addr < 0x200000/2; addr++) |
| 7448 | 7448 | temp[addr ^ 0x68956] = BITSWAP16(rom[addr], 8, 4, 12, 3, 6, 7, 1, 0, 15, 11, 5, 14, 10, 2, 9, 13); |
| 7449 | memcpy(rom, temp, 0x200000); | |
| 7449 | memcpy(rom, &temp[0], 0x200000); | |
| 7450 | 7450 | |
| 7451 | 7451 | m_read_xor = 0x66; |
| 7452 | 7452 | m_security_callback = security_callback_delegate(FUNC(isgsm_state::shinfz_security), this); |
| r245687 | r245688 | |
| 7456 | 7456 | { |
| 7457 | 7457 | init_isgsm(); |
| 7458 | 7458 | |
| 7459 | d | |
| 7459 | std::vector<UINT16> temp(0x80000/2); | |
| 7460 | 7460 | UINT16 *rom = (UINT16 *)memregion("gamecart_rgn")->base(); |
| 7461 | 7461 | for (int addr = 0; addr < 0x80000/2; addr++) |
| 7462 | 7462 | temp[addr ^ 0x2A6E6] = BITSWAP16(rom[addr], 4, 0, 12, 5, 7, 3, 1, 14, 10, 11, 9, 6, 15, 2, 13, 8); |
| 7463 | memcpy(rom, temp, 0x80000); | |
| 7463 | memcpy(rom, &temp[0], 0x80000); | |
| 7464 | 7464 | |
| 7465 | 7465 | m_read_xor = 0x73; |
| 7466 | 7466 | m_security_callback = security_callback_delegate(FUNC(isgsm_state::tetrbx_security), this); |
| r245687 | r245688 | |
|---|---|---|
| 11427 | 11427 | buf[rpos] = rom[rpos*2+1]; |
| 11428 | 11428 | } |
| 11429 | 11429 | |
| 11430 | memcpy( rom, buf, rom_size ); | |
| 11430 | memcpy( rom, &buf[0], rom_size ); | |
| 11431 | 11431 | |
| 11432 | 11432 | rom = memregion("gfx3")->base() + 0x40000; |
| 11433 | 11433 | |
| r245687 | r245688 | |
| 11436 | 11436 | buf[rpos] = rom[rpos*2+1]; |
| 11437 | 11437 | } |
| 11438 | 11438 | |
| 11439 | memcpy( rom, buf, rom_size ); | |
| 11439 | memcpy( rom, &buf[0], rom_size ); | |
| 11440 | 11440 | } |
| 11441 | 11441 | |
| 11442 | 11442 |
| r245687 | r245688 | |
|---|---|---|
| 134 | 134 | required_shared_ptr<UINT8> m_nvram; |
| 135 | 135 | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 136 | 136 | required_device<gfxdecode_device> m_gfxdecode; |
| 137 | d | |
| 137 | std::vector<UINT8> m_paletteram; | |
| 138 | 138 | required_device<screen_device> m_screen; |
| 139 | 139 | required_device<palette_device> m_palette; |
| 140 | 140 | |
| r245687 | r245688 | |
| 1509 | 1509 | m_rambank = data; |
| 1510 | 1510 | switch (data) |
| 1511 | 1511 | { |
| 1512 | case 0x52: membank("palbank")->set_base(m_nvram); break; | |
| 1513 | case 0x64: membank("palbank")->set_base(m_paletteram); break; | |
| 1512 | case 0x52: membank("palbank")->set_base(m_nvram); break; | |
| 1513 | case 0x64: membank("palbank")->set_base(&m_paletteram[0]); break; | |
| 1514 | 1514 | default: |
| 1515 | 1515 | logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", machine().describe_context(), data, m_reg2); |
| 1516 | 1516 | return; |
| r245687 | r245688 | |
| 2656 | 2656 | m_rombank = 0x0f; |
| 2657 | 2657 | |
| 2658 | 2658 | // RAM banks |
| 2659 | m_paletteram.resize_and_clear(0x3000); | |
| 2659 | m_paletteram.resize(0x3000); | |
| 2660 | memset(&m_paletteram[0], 0, 0x3000); | |
| 2660 | 2661 | m_palette->basemem().set(m_paletteram, ENDIANNESS_BIG, 2); |
| 2661 | membank("palbank")->set_base(m_paletteram); | |
| 2662 | membank("palbank")->set_base(&m_paletteram[0]); | |
| 2662 | 2663 | m_rambank = 0x64; |
| 2663 | 2664 | |
| 2664 | 2665 | m_spriteram.allocate(0x1000 * 5); |
| r245687 | r245688 | |
| 2768 | 2769 | DRIVER_INIT_MEMBER(sigmab98_state,haekaka) |
| 2769 | 2770 | { |
| 2770 | 2771 | // RAM banks |
| 2771 | m_paletteram.resize_and_clear(0x200); | |
| 2772 | m_paletteram.resize(0x200); | |
| 2773 | memset(&m_paletteram[0], 0, 0x200); | |
| 2772 | 2774 | m_palette->basemem().set(m_paletteram, ENDIANNESS_BIG, 2); |
| 2773 | 2775 | |
| 2774 | 2776 | m_spriteram.allocate(0x1000); |
| r245687 | r245688 | |
|---|---|---|
| 1016 | 1016 | buf1[addr] = rom[x]; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | memcpy(rom, buf1, length); | |
| 1019 | memcpy(rom, &buf1[0], length); | |
| 1020 | 1020 | |
| 1021 | 1021 | deco56_decrypt_gfx(machine(), "gfx1"); |
| 1022 | 1022 | deco156_decrypt(machine()); |
| r245687 | r245688 | |
|---|---|---|
| 2594 | 2594 | if (i&1) buffer[i] = BITSWAP8(src[i],6,7,5,4,3,2,1,0); |
| 2595 | 2595 | else buffer[i] = src[i]; |
| 2596 | 2596 | |
| 2597 | memcpy(src,buffer,len); | |
| 2597 | memcpy(src,&buffer[0],len); | |
| 2598 | 2598 | } |
| 2599 | 2599 | |
| 2600 | 2600 | src = memregion("soundcpu")->base(); |
| r245687 | r245688 | |
| 2606 | 2606 | int i; |
| 2607 | 2607 | for (i = 0;i < len; i++) |
| 2608 | 2608 | buffer[i] = src[i^0x4000]; |
| 2609 | memcpy(src,buffer,len); | |
| 2609 | memcpy(src,&buffer[0],len); | |
| 2610 | 2610 | } |
| 2611 | 2611 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x200000, 0x200001, read16_delegate(FUNC(snowbros_state::_4in1_02_read),this)); |
| 2612 | 2612 | } |
| r245687 | r245688 | |
| 2622 | 2622 | int i; |
| 2623 | 2623 | for (i = 0;i < len; i++) |
| 2624 | 2624 | buffer[i] = src[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,3,4,1,2,0)]; |
| 2625 | memcpy(src,buffer,len); | |
| 2625 | memcpy(src,&buffer[0],len); | |
| 2626 | 2626 | } |
| 2627 | 2627 | |
| 2628 | 2628 | save_item(NAME(m_sb3_music_is_playing)); |
| r245687 | r245688 | |
|---|---|---|
| 296 | 296 | for (int i=0;i<0x200;i++) |
| 297 | 297 | { |
| 298 | 298 | int j = BITSWAP16(i, 15,14,13,12,11,10,9,8,0,1,2,3,4,5,6,7); |
| 299 | memcpy(temp | |
| 299 | memcpy(&temp[i*128], rom+j*128, 128); | |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | memcpy(rom,temp,0x200*128); | |
| 302 | memcpy(rom,&temp[0],0x200*128); | |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 |
| r245687 | r245688 | |
|---|---|---|
| 177 | 177 | dynamic_buffer src(len); |
| 178 | 178 | |
| 179 | 179 | int i,idx=0; |
| 180 | memcpy(src, dest, len); | |
| 180 | memcpy(&src[0], dest, len); | |
| 181 | 181 | for(i=0;i<64*1024;i+=4) |
| 182 | 182 | { |
| 183 | 183 | if(i&0x8000) |
| r245687 | r245688 | |
|---|---|---|
| 4001 | 4001 | // unscramble the sprite ROM address lines |
| 4002 | 4002 | UINT32 *gfxdata = reinterpret_cast<UINT32 *>(memregion("k051960")->base()); |
| 4003 | 4003 | int len = memregion("k051960")->bytes() / 4; |
| 4004 | dynamic_array<UINT32> temp(len); | |
| 4005 | memcpy(temp, gfxdata, len * 4); | |
| 4004 | std::vector<UINT32> temp(len); | |
| 4005 | memcpy(&temp[0], gfxdata, len * 4); | |
| 4006 | 4006 | for (int A = 0; A < len; A++) |
| 4007 | 4007 | { |
| 4008 | 4008 | // the bits to scramble are the low 8 ones |
| r245687 | r245688 | |
| 4027 | 4027 | const UINT8 *code_conv_table = memregion("proms")->base(); |
| 4028 | 4028 | UINT32 *gfxdata = reinterpret_cast<UINT32 *>(memregion("k051960")->base()); |
| 4029 | 4029 | int len = memregion("k051960")->bytes() / 4; |
| 4030 | dynamic_array<UINT32> temp(len); | |
| 4031 | memcpy(temp, gfxdata, len * 4); | |
| 4030 | std::vector<UINT32> temp(len); | |
| 4031 | memcpy(&temp[0], gfxdata, len * 4); | |
| 4032 | 4032 | |
| 4033 | 4033 | for (int A = 0; A < len; A++) |
| 4034 | 4034 | { |
| r245687 | r245688 | |
|---|---|---|
| 750 | 750 | dynamic_buffer buffer(0x20000); |
| 751 | 751 | int i; |
| 752 | 752 | |
| 753 | memcpy(buffer,ROM,0x20000); | |
| 753 | memcpy(&buffer[0],ROM,0x20000); | |
| 754 | 754 | for( i = 0; i < 0x20000; i++ ) |
| 755 | 755 | { |
| 756 | 756 | ROM[i] = buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,13,14,15,12,11,10,9,8,7,6,5,4,3,2,1,0)]; |
| r245687 | r245688 | |
| 772 | 772 | for (offs = 0; offs < len; offs += 0x20000) |
| 773 | 773 | { |
| 774 | 774 | UINT8 *base = &rom[offs]; |
| 775 | memcpy (temp, base, 65536 * 2); | |
| 775 | memcpy (&temp[0], base, 65536 * 2); | |
| 776 | 776 | for (i = 0; i < 16; i++) |
| 777 | 777 | { |
| 778 | 778 | memcpy (&base[0x00000 + i * 0x800], &temp[0x0000 + i * 0x2000], 0x800); |
| r245687 | r245688 | |
| 786 | 786 | for (offs = 0; offs < len; offs += 0x20000) |
| 787 | 787 | { |
| 788 | 788 | UINT8 *base = &rom[offs]; |
| 789 | memcpy (temp, base, 65536 * 2); | |
| 789 | memcpy (&temp[0], base, 65536 * 2); | |
| 790 | 790 | for (i = 0; i < 16; i++) |
| 791 | 791 | { |
| 792 | 792 | memcpy (&base[0x00000 + i * 0x800], &temp[0x0000 + i * 0x2000], 0x800); |
| r245687 | r245688 | |
| 840 | 840 | dynamic_buffer buffer(0x20000); |
| 841 | 841 | int i; |
| 842 | 842 | |
| 843 | memcpy(buffer,ROM,0x20000); | |
| 843 | memcpy(&buffer[0],ROM,0x20000); | |
| 844 | 844 | for( i = 0; i < 0x20000; i++ ) |
| 845 | 845 | { |
| 846 | 846 | ROM[i] = buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,13,14,15,12,11,10,9,8,7,6,5,4,3,2,1,0)]; |
| r245687 | r245688 | |
|---|---|---|
| 575 | 575 | UINT8 *rom = memregion("maincpu")->base(); |
| 576 | 576 | dynamic_buffer buffer(0x2000); |
| 577 | 577 | |
| 578 | memcpy(buffer, rom, 0x2000); | |
| 578 | memcpy(&buffer[0], rom, 0x2000); | |
| 579 | 579 | |
| 580 | 580 | /* The first CPU ROM has the address and data lines scrambled */ |
| 581 | 581 | for (A = 0; A < 0x2000; A++) |
| r245687 | r245688 | |
|---|---|---|
| 3534 | 3534 | void tumbleb_state::suprtrio_decrypt_code() |
| 3535 | 3535 | { |
| 3536 | 3536 | UINT16 *rom = (UINT16 *)memregion("maincpu")->base(); |
| 3537 | d | |
| 3537 | std::vector<UINT16> buf(0x80000/2); | |
| 3538 | 3538 | int i; |
| 3539 | 3539 | |
| 3540 | 3540 | /* decrypt main ROMs */ |
| 3541 | memcpy(buf, rom, 0x80000); | |
| 3541 | memcpy(&buf[0], rom, 0x80000); | |
| 3542 | 3542 | for (i = 0; i < 0x40000; i++) |
| 3543 | 3543 | { |
| 3544 | 3544 | int j = i ^ 0x06; |
| r245687 | r245688 | |
| 3551 | 3551 | void tumbleb_state::suprtrio_decrypt_gfx() |
| 3552 | 3552 | { |
| 3553 | 3553 | UINT16 *rom = (UINT16 *)memregion("tilegfx")->base(); |
| 3554 | d | |
| 3554 | std::vector<UINT16> buf(0x100000/2); | |
| 3555 | 3555 | int i; |
| 3556 | 3556 | |
| 3557 | 3557 | /* decrypt tiles */ |
| 3558 | memcpy(buf, rom, 0x100000); | |
| 3558 | memcpy(&buf[0], rom, 0x100000); | |
| 3559 | 3559 | for (i = 0; i < 0x80000; i++) |
| 3560 | 3560 | { |
| 3561 | 3561 | int j = i ^ 0x02; |
| r245687 | r245688 | |
|---|---|---|
| 153 | 153 | space.install_read_bank(m_video_banking_base + 0x2000, m_video_banking_base + 0x2fff, "bank4" ); |
| 154 | 154 | space.install_write_handler(m_video_banking_base + 0x2000, m_video_banking_base + 0x2fff, write8_delegate(FUNC(palette_device::write), m_palette.target()) ); |
| 155 | 155 | space.install_readwrite_handler(m_video_banking_base + 0x0000, m_video_banking_base + 0x0fff, read8_delegate(FUNC(k053247_device::k053247_r), (k053247_device*)m_k053246), write8_delegate(FUNC(k053247_device::k053247_w), (k053247_device*)m_k053246) ); |
| 156 | membank("bank4")->set_base(m_paletteram); | |
| 156 | membank("bank4")->set_base(&m_paletteram[0]); | |
| 157 | 157 | } |
| 158 | 158 | else |
| 159 | 159 | { |
| r245687 | r245688 | |
|---|---|---|
| 1301 | 1301 | dynamic_buffer buffer(len); |
| 1302 | 1302 | int i; |
| 1303 | 1303 | |
| 1304 | memcpy(buffer,src,len); | |
| 1304 | memcpy(&buffer[0],src,len); | |
| 1305 | 1305 | for (i = 0;i < len;i++) |
| 1306 | 1306 | { |
| 1307 | 1307 | src[i] = |
| r245687 | r245688 | |
| 1419 | 1419 | UINT8 *finish = base + 2*bank_size*i; |
| 1420 | 1420 | UINT8 *dest = finish - 2*bank_size; |
| 1421 | 1421 | |
| 1422 | UINT8 *p1 = temp; | |
| 1423 | UINT8 *p2 = temp+bank_size/2; | |
| 1422 | UINT8 *p1 = &temp[0]; | |
| 1423 | UINT8 *p2 = &temp[bank_size/2]; | |
| 1424 | 1424 | |
| 1425 | 1425 | UINT8 data; |
| 1426 | 1426 | |
| 1427 | memcpy (temp, base+bank_size*(i-1), bank_size); | |
| 1427 | memcpy (&temp[0], base+bank_size*(i-1), bank_size); | |
| 1428 | 1428 | |
| 1429 | 1429 | do { |
| 1430 | 1430 | data = *p1++; |
| r245687 | r245688 | |
|---|---|---|
| 427 | 427 | |
| 428 | 428 | // protection module reverse engineered by HIGHWAYMAN |
| 429 | 429 | |
| 430 | memcpy(buffer,ROM,0x8000); | |
| 430 | memcpy(&buffer[0],ROM,0x8000); | |
| 431 | 431 | |
| 432 | 432 | for (i = 0x0000; i <= 0x1fff; i++) |
| 433 | 433 | ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; |
| r245687 | r245688 | |
|---|---|---|
| 22 | 22 | |
| 23 | 23 | /* memory pointers */ |
| 24 | 24 | required_shared_ptr<UINT8> m_ram; |
| 25 | d | |
| 25 | std::vector<UINT8> m_paletteram; | |
| 26 | 26 | |
| 27 | 27 | /* video-related */ |
| 28 | 28 | int m_layer_colorbase[3]; |
| r245687 | r245688 | |
|---|---|---|
| 22 | 22 | m_palette(*this, "palette") { } |
| 23 | 23 | |
| 24 | 24 | /* memory pointers */ |
| 25 | d | |
| 25 | std::vector<UINT8> m_paletteram; | |
| 26 | 26 | |
| 27 | 27 | /* video-related */ |
| 28 | 28 | int m_layer_colorbase[3]; |
| r245687 | r245688 | |
|---|---|---|
| 26 | 26 | |
| 27 | 27 | /* video-related */ |
| 28 | 28 | tilemap_t *m_bg_tilemap; |
| 29 | dynamic_array<UINT8> m_paletteram; | |
| 30 | dynamic_array<UINT8> m_paletteram_ext; | |
| 29 | std::vector<UINT8> m_paletteram; | |
| 30 | std::vector<UINT8> m_paletteram_ext; | |
| 31 | 31 | UINT8 m_gfxctrl; |
| 32 | 32 | UINT8 m_char_bank; |
| 33 | 33 | UINT8 m_palette_bank; |
| r245687 | r245688 | |
|---|---|---|
| 323 | 323 | void setLighting(const UINT16* packet); |
| 324 | 324 | void set3dFlags(const UINT16* packet); |
| 325 | 325 | void setCameraProjectionMatrix(const UINT16* packet); |
| 326 | void recoverPolygonBlock(const UINT16* packet, struct polygon | |
| 326 | void recoverPolygonBlock(const UINT16* packet, std::vector<struct polygon> &polys, int* numPolys); | |
| 327 | 327 | void hng64_mark_all_tiles_dirty(int tilemap); |
| 328 | 328 | void hng64_mark_tile_dirty(int tilemap, int tile_index); |
| 329 | 329 |
| r245687 | r245688 | |
|---|---|---|
| 23 | 23 | required_shared_ptr<UINT8> m_videoram; |
| 24 | 24 | UINT8 * m_spriteram; |
| 25 | 25 | required_shared_ptr<UINT8> m_scrlram; |
| 26 | dynamic_array<UINT8> m_paletteram; | |
| 27 | dynamic_array<UINT8> m_paletteram_ext; | |
| 26 | std::vector<UINT8> m_paletteram; | |
| 27 | std::vector<UINT8> m_paletteram_ext; | |
| 28 | 28 | |
| 29 | 29 | /* video-related */ |
| 30 | 30 | tilemap_t *m_bg_tilemap; |
| r245687 | r245688 | |
|---|---|---|
| 56 | 56 | UINT16 m_pf_master_control[4]; |
| 57 | 57 | INT32 m_sprite_list; |
| 58 | 58 | UINT8 m_palette_bank; |
| 59 | d | |
| 59 | std::vector<UINT16> m_paletteram; | |
| 60 | 60 | |
| 61 | 61 | DECLARE_READ16_MEMBER(m92_eeprom_r); |
| 62 | 62 | DECLARE_WRITE16_MEMBER(m92_eeprom_w); |
| r245687 | r245688 | |
|---|---|---|
| 41 | 41 | |
| 42 | 42 | /* video-related */ |
| 43 | 43 | tilemap_t *m_bg_tilemap; |
| 44 | d | |
| 44 | std::vector<UINT8> m_objram; /* Sprite RAM */ | |
| 45 | 45 | int m_flipscreen; |
| 46 | 46 | int m_video_bank; |
| 47 | 47 | int m_paletteram_bank; |
| 48 | d | |
| 48 | std::vector<UINT8> m_paletteram; | |
| 49 | 49 | |
| 50 | 50 | /* sound-related */ |
| 51 | 51 | int m_sample_buffer; |
| r245687 | r245688 | |
|---|---|---|
| 65 | 65 | required_shared_ptr<UINT16> m_spriteram; |
| 66 | 66 | |
| 67 | 67 | // this has to be UINT8 to be in the right byte order for the tilemap system |
| 68 | d | |
| 68 | std::vector<UINT8> m_shaperam; | |
| 69 | 69 | |
| 70 | 70 | UINT16 *m_prgrom; |
| 71 | 71 | UINT16 *m_maskrom; |
| r245687 | r245688 | |
|---|---|---|
| 194 | 194 | UINT16 get_video_control( ); |
| 195 | 195 | |
| 196 | 196 | // color/palette related |
| 197 | d | |
| 197 | std::vector<UINT16> m_paletteram; | |
| 198 | 198 | UINT8 m_palette_lookup[32][4]; |
| 199 | 199 | const pen_t *m_bg_pen; |
| 200 | 200 | int m_screen_shadow; |
| r245687 | r245688 | |
|---|---|---|
| 25 | 25 | |
| 26 | 26 | /* video-related */ |
| 27 | 27 | tilemap_t *m_bg_tilemap; |
| 28 | dynamic_array<UINT8> m_paletteram; | |
| 29 | dynamic_array<UINT8> m_paletteram_ext; | |
| 28 | std::vector<UINT8> m_paletteram; | |
| 29 | std::vector<UINT8> m_paletteram_ext; | |
| 30 | 30 | UINT8 m_gfxctrl; |
| 31 | 31 | UINT8 m_char_bank; |
| 32 | 32 | UINT8 m_palette_bank; |
| r245687 | r245688 | |
|---|---|---|
| 52 | 52 | required_device<screen_device> m_screen; |
| 53 | 53 | required_device<palette_device> m_palette; |
| 54 | 54 | |
| 55 | d | |
| 55 | std::vector<UINT8> m_paletteram; | |
| 56 | 56 | |
| 57 | 57 | UINT8 m_sound_state[2]; |
| 58 | 58 | UINT8 m_sound_rate; |
| r245687 | r245688 | |
|---|---|---|
| 27 | 27 | tilemap_t *m_tilemap; |
| 28 | 28 | bool m_display_disable; |
| 29 | 29 | UINT32 m_bank_vidram; |
| 30 | d | |
| 30 | std::vector<UINT8> m_vidram; | |
| 31 | 31 | DECLARE_READ8_MEMBER(irq_ack_r); |
| 32 | 32 | DECLARE_WRITE8_MEMBER(rombank_w); |
| 33 | 33 | DECLARE_WRITE8_MEMBER(sound_w); |
| r245687 | r245688 | |
|---|---|---|
| 25 | 25 | /* memory pointers */ |
| 26 | 26 | required_shared_ptr<UINT8> m_ram; |
| 27 | 27 | UINT8 m_pmcram[0x800]; |
| 28 | d | |
| 28 | std::vector<UINT8> m_paletteram; | |
| 29 | 29 | |
| 30 | 30 | /* video-related */ |
| 31 | 31 | int m_layer_colorbase[3]; |
| r245687 | r245688 | |
|---|---|---|
| 656 | 656 | int get_timing_command( void ); |
| 657 | 657 | |
| 658 | 658 | direntryT curroot; // root entry of current filesystem |
| 659 | d | |
| 659 | std::vector<direntryT> curdir; // current directory | |
| 660 | 660 | int numfiles; // # of entries in current directory |
| 661 | 661 | int firstfile; // first non-directory file |
| 662 | 662 |
| r245687 | r245688 | |
|---|---|---|
| 30 | 30 | m_palette(*this, "palette") { } |
| 31 | 31 | |
| 32 | 32 | /* memory pointers */ |
| 33 | d | |
| 33 | std::vector<UINT8> m_paletteram; | |
| 34 | 34 | |
| 35 | 35 | /* video-related */ |
| 36 | 36 | int m_layer_colorbase[3]; |
| r245687 | r245688 | |
|---|---|---|
| 1183 | 1183 | { |
| 1184 | 1184 | // bank 0 comes from the copy we made earlier |
| 1185 | 1185 | if (bank == 0) |
| 1186 | memcpy(m_slapstic, m_slapstic_bank0, 0x2000); | |
| 1186 | memcpy(m_slapstic, &m_slapstic_bank0[0], 0x2000); | |
| 1187 | 1187 | else |
| 1188 | 1188 | memcpy(m_slapstic, &m_slapstic[bank * 0x1000], 0x2000); |
| 1189 | 1189 | |
| r245687 | r245688 | |
| 1254 | 1254 | |
| 1255 | 1255 | // allocate memory for a copy of bank 0 |
| 1256 | 1256 | m_slapstic_bank0.resize(0x2000); |
| 1257 | memcpy(m_slapstic_bank0, m_slapstic, 0x2000); | |
| 1257 | memcpy(&m_slapstic_bank0[0], m_slapstic, 0x2000); | |
| 1258 | 1258 | |
| 1259 | 1259 | // ensure we recopy memory for the bank |
| 1260 | 1260 | m_slapstic_bank = 0xff; |
| r245687 | r245688 | |
|---|---|---|
| 27 | 27 | dynamic_buffer tmp(0x10000); |
| 28 | 28 | int i; |
| 29 | 29 | |
| 30 | memcpy(tmp, rom, 0x10000); | |
| 30 | memcpy(&tmp[0], rom, 0x10000); | |
| 31 | 31 | |
| 32 | 32 | for ( i = 0; i < 256; i++ ) |
| 33 | 33 | { |
| r245687 | r245688 | |
|---|---|---|
| 54 | 54 | UINT16 *rom = (UINT16 *)machine.root_device().memregion(cputag)->base(); |
| 55 | 55 | int size = machine.root_device().memregion(cputag)->bytes(); |
| 56 | 56 | UINT16 *opcodes = auto_alloc_array(machine, UINT16, size / 2); |
| 57 | d | |
| 57 | std::vector<UINT16> buf(size / 2); | |
| 58 | 58 | |
| 59 | memcpy(buf, rom, size); | |
| 59 | memcpy(&buf[0], rom, size); | |
| 60 | 60 | |
| 61 | 61 | space.set_decrypted_region(0, size - 1, opcodes); |
| 62 | 62 | ((m68000_base_device*)machine.device(cputag))->set_encrypted_opcode_range(0, size); |
| r245687 | r245688 | |
|---|---|---|
| 126 | 126 | { |
| 127 | 127 | UINT32 *rom = (UINT32 *)machine.root_device().memregion("maincpu")->base(); |
| 128 | 128 | int length = machine.root_device().memregion("maincpu")->bytes(); |
| 129 | d | |
| 129 | std::vector<UINT32> buf(length/4); | |
| 130 | 130 | |
| 131 | memcpy(buf, rom, length); | |
| 132 | decrypt(buf, rom, length); | |
| 131 | memcpy(&buf[0], rom, length); | |
| 132 | decrypt(&buf[0], rom, length); | |
| 133 | 133 | } |
| r245687 | r245688 | |
|---|---|---|
| 602 | 602 | { |
| 603 | 603 | UINT16 *rom = (UINT16 *)machine.root_device().memregion(rgntag)->base(); |
| 604 | 604 | int len = machine.root_device().memregion(rgntag)->bytes()/2; |
| 605 | d | |
| 605 | std::vector<UINT16> buffer(len); | |
| 606 | 606 | int i; |
| 607 | 607 | |
| 608 | 608 | /* we work on 16-bit words but data is loaded as 8-bit, so swap bytes on LSB machines */ |
| r245687 | r245688 | |
| 610 | 610 | for (i = 0;i < len;i++) |
| 611 | 611 | rom[i] = BIG_ENDIANIZE_INT16(rom[i]); |
| 612 | 612 | |
| 613 | memcpy(buffer,rom,len*2); | |
| 613 | memcpy(&buffer[0],rom,len*2); | |
| 614 | 614 | |
| 615 | 615 | for (i = 0;i < len;i++) |
| 616 | 616 | { |
| r245687 | r245688 | |
|---|---|---|
| 258 | 258 | m_decrypted_opcodes.resize(romsize/2); |
| 259 | 259 | |
| 260 | 260 | // copy the plaintext |
| 261 | memcpy(m_plaintext, rombase, romsize); | |
| 261 | memcpy(&m_plaintext[0], rombase, romsize); | |
| 262 | 262 | |
| 263 | 263 | // decrypt it, overwriting original data with the decrypted data |
| 264 | decrypt(0x000000, romsize, m_plaintext, m_decrypted_opcodes, rombase); | |
| 264 | decrypt(0x000000, romsize, &m_plaintext[0], &m_decrypted_opcodes[0], rombase); | |
| 265 | 265 | |
| 266 | 266 | // mark the ROM region as decrypted, pointing to the opcodes (if it is mapped) |
| 267 | 267 | address_space &program = space(AS_PROGRAM); |
| 268 | 268 | if (program.get_read_ptr(0) != NULL) |
| 269 | program.set_decrypted_region(0x000000, romsize - 1, m_decrypted_opcodes); | |
| 269 | program.set_decrypted_region(0x000000, romsize - 1, &m_decrypted_opcodes[0]); | |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 |
| r245687 | r245688 | |
|---|---|---|
| 54 | 54 | |
| 55 | 55 | // internal state |
| 56 | 56 | const UINT8 * m_key; |
| 57 | dynamic_array<UINT16> m_plaintext; | |
| 58 | dynamic_array<UINT16> m_decrypted_opcodes; | |
| 57 | std::vector<UINT16> m_plaintext; | |
| 58 | std::vector<UINT16> m_decrypted_opcodes; | |
| 59 | 59 | |
| 60 | 60 | // internal types |
| 61 | 61 | struct decrypt_parameters |
| r245687 | r245688 | |
|---|---|---|
| 498 | 498 | { |
| 499 | 499 | // reset all allocated cache buffers |
| 500 | 500 | for (int cache = 0; cache < 256; cache++) |
| 501 | m_decrypted_opcodes[cache]. | |
| 501 | m_decrypted_opcodes[cache].clear(); | |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | |
| r245687 | r245688 | |
| 528 | 528 | UINT16 *fd1094_decryption_cache::decrypted_opcodes(UINT8 state) |
| 529 | 529 | { |
| 530 | 530 | // if we have already decrypted this state, use it |
| 531 | if (m_decrypted_opcodes[state].count() > 0) | |
| 532 | return m_decrypted_opcodes[state]; | |
| 531 | if (!m_decrypted_opcodes[state].empty()) | |
| 532 | return &m_decrypted_opcodes[state][0]; | |
| 533 | 533 | |
| 534 | 534 | // otherwise, allocate and decrypt |
| 535 | 535 | m_decrypted_opcodes[state].resize(m_size); |
| 536 | m_fd1094.decrypt(m_baseaddress, m_size, m_rgnoffset, m_decrypted_opcodes[state], state); | |
| 537 | return m_decrypted_opcodes[state]; | |
| 536 | m_fd1094.decrypt(m_baseaddress, m_size, m_rgnoffset, &m_decrypted_opcodes[state][0], state); | |
| 537 | return &m_decrypted_opcodes[state][0]; | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 |
| r245687 | r245688 | |
|---|---|---|
| 54 | 54 | UINT32 m_baseaddress; |
| 55 | 55 | UINT32 m_size; |
| 56 | 56 | UINT32 m_rgnoffset; |
| 57 | d | |
| 57 | std::vector<UINT16> m_decrypted_opcodes[256]; | |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 |
| r245687 | r245688 | |
|---|---|---|
| 135 | 135 | result_data[i] = source_data[j]; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | memcpy (source_data, result_data, source_size); | |
| 138 | memcpy (source_data, &result_data[0], source_size); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
| r245687 | r245688 | |
| 187 | 187 | result_data[i] = source_data[j] ^ (i & 0xff) ^ data_xor; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | memcpy (source_data, result_data, source_size); | |
| 190 | memcpy (source_data, &result_data[0], source_size); | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | void decrypt_ms32_bg(running_machine &machine, int addr_xor,int data_xor, const char *region) |
| r245687 | r245688 | |
| 239 | 239 | result_data[i] = source_data[j] ^ (i & 0xff) ^ data_xor; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | memcpy (source_data, result_data, source_size); | |
| 242 | memcpy (source_data, &result_data[0], source_size); | |
| 243 | 243 | } |
| r245687 | r245688 | |
|---|---|---|
| 1555 | 1555 | int length; |
| 1556 | 1556 | #endif |
| 1557 | 1557 | |
| 1558 | memset(tmpdstram, 0x00,0x2000); | |
| 1558 | memset(&tmpdstram[0], 0x00,0x2000); | |
| 1559 | 1559 | |
| 1560 | 1560 | #if VERBOSE_OUTPUT |
| 1561 | 1561 | length = decompress_table(x, tmpdstram, 0); |
| r245687 | r245688 | |
|---|---|---|
| 185 | 185 | }; |
| 186 | 186 | |
| 187 | 187 | UINT16 *rom = (UINT16 *)memregion("mainbios")->base(); |
| 188 | d | |
| 188 | std::vector<UINT16> buf(0x80000/2); | |
| 189 | 189 | int i, addr; |
| 190 | 190 | |
| 191 | 191 | for (i = 0; i < 0x80000/2; i++) |
| r245687 | r245688 | |
| 208 | 208 | if (buf[i] & 0x0020) buf[i] ^= 0x0008; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | memcpy(rom, buf, 0x80000); | |
| 211 | memcpy(rom, &buf[0], 0x80000); | |
| 212 | 212 | } |
| r245687 | r245688 | |
|---|---|---|
| 366 | 366 | { |
| 367 | 367 | int i, j; |
| 368 | 368 | UINT16 *src = (UINT16 *)(memregion("tiles")->base() + 0x180000); |
| 369 | d | |
| 369 | std::vector<UINT16> dst(0x800000); | |
| 370 | 370 | |
| 371 | 371 | for (i = 0; i < 0x800000 / 2; i++) |
| 372 | 372 | { |
| r245687 | r245688 | |
| 375 | 375 | dst[j] = BITSWAP16(src[i], 1, 14, 8, 7, 0, 15, 6, 9, 13, 2, 5, 10, 12, 3, 4, 11); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | memcpy( src, dst, 0x800000 ); | |
| 378 | memcpy( src, &dst[0], 0x800000 ); | |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | void pgm_arm_type1_state::pgm_decode_kovlsqh2_sprites( UINT8 *src ) |
| r245687 | r245688 | |
| 390 | 390 | dst[j] = src[i]; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | memcpy( src, dst, 0x800000 ); | |
| 393 | memcpy( src, &dst[0], 0x800000 ); | |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | void pgm_arm_type1_state::pgm_decode_kovlsqh2_samples() |
| r245687 | r245688 | |
| 409 | 409 | { |
| 410 | 410 | int i; |
| 411 | 411 | UINT16 *src = (UINT16 *)(memregion("maincpu")->base() + 0x100000); |
| 412 | d | |
| 412 | std::vector<UINT16> dst(0x400000); | |
| 413 | 413 | |
| 414 | 414 | for (i = 0; i < 0x400000 / 2; i++) |
| 415 | 415 | { |
| r245687 | r245688 | |
| 418 | 418 | dst[j] = BITSWAP16(src[i], 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 4, 5, 3, 2, 1, 0); |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | memcpy( src, dst, 0x400000 ); | |
| 421 | memcpy( src, &dst[0], 0x400000 ); | |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | void pgm_arm_type1_state::pgm_decode_kovqhsgs2_program() |
| 425 | 425 | { |
| 426 | 426 | int i; |
| 427 | 427 | UINT16 *src = (UINT16 *)(memregion("maincpu")->base() + 0x100000); |
| 428 | d | |
| 428 | std::vector<UINT16> dst(0x400000); | |
| 429 | 429 | |
| 430 | 430 | for (i = 0; i < 0x400000 / 2; i++) |
| 431 | 431 | { |
| r245687 | r245688 | |
| 434 | 434 | dst[j] = src[i]; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | memcpy( src, dst, 0x400000 ); | |
| 437 | memcpy( src, &dst[0], 0x400000 ); | |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 |
| r245687 | r245688 | |
|---|---|---|
| 737 | 737 | { |
| 738 | 738 | for (int i = j; i < 0x800000; i += 0x800) |
| 739 | 739 | { |
| 740 | memcpy(buffer | |
| 740 | memcpy(&buffer[writeaddress], src + i, 0x200); | |
| 741 | 741 | writeaddress += 0x200; |
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | memcpy(src, buffer, 0x800000); | |
| 744 | memcpy(src, &buffer[0], 0x800000); | |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | |
| r245687 | r245688 | |
| 756 | 756 | { |
| 757 | 757 | for (int i = j; i < 0x100000; i += 0x40000) |
| 758 | 758 | { |
| 759 | memcpy(buffer | |
| 759 | memcpy(&buffer[writeaddress], src + i + k, 0x10000); | |
| 760 | 760 | writeaddress += 0x10000; |
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | memcpy(src, buffer, 0x800000); | |
| 764 | memcpy(src, &buffer[0], 0x800000); | |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | INPUT_PORTS_START( happy6 ) |
| r245687 | r245688 | |
|---|---|---|
| 376 | 376 | |
| 377 | 377 | dynamic_buffer scratch(len); |
| 378 | 378 | |
| 379 | memcpy(scratch, RAM, len); | |
| 379 | memcpy(&scratch[0], RAM, len); | |
| 380 | 380 | |
| 381 | 381 | for (i = 0; i < len; i++) |
| 382 | 382 | { |
| r245687 | r245688 | |
| 409 | 409 | |
| 410 | 410 | dynamic_buffer scratch(len); |
| 411 | 411 | |
| 412 | memcpy(scratch, RAM, len); | |
| 412 | memcpy(&scratch[0], RAM, len); | |
| 413 | 413 | |
| 414 | 414 | for (i = 0; i < len; i++) |
| 415 | 415 | { |
| r245687 | r245688 | |
|---|---|---|
| 638 | 638 | |
| 639 | 639 | // clear out all fd1089 stuff |
| 640 | 640 | m_fd1089 = NULL; |
| 641 | m_fd1089_decrypted. | |
| 641 | m_fd1089_decrypted.clear(); | |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| r245687 | r245688 | |
| 691 | 691 | if (m_fd1089 != NULL) |
| 692 | 692 | { |
| 693 | 693 | m_fd1089_decrypted.resize((m_end + 1 - m_start) / 2); |
| 694 | m_fd1089->decrypt(m_start, m_end + 1 - m_start, m_rgnoffs, m_fd1089_decrypted, reinterpret_cast<UINT16 *>(m_srcptr)); | |
| 695 | m_bank->set_base_decrypted(m_fd1089_decrypted); | |
| 694 | m_fd1089->decrypt(m_start, m_end + 1 - m_start, m_rgnoffs, &m_fd1089_decrypted[0], reinterpret_cast<UINT16 *>(m_srcptr)); | |
| 695 | m_bank->set_base_decrypted(&m_fd1089_decrypted[0]); | |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | // fd1094 case |
| r245687 | r245688 | |
|---|---|---|
| 140 | 140 | |
| 141 | 141 | // updating |
| 142 | 142 | void update(); |
| 143 | void reset() { m_fd1089_decrypted. | |
| 143 | void reset() { m_fd1089_decrypted.clear(); if (m_fd1094_cache != NULL) m_fd1094_cache->reset(); } | |
| 144 | 144 | |
| 145 | 145 | private: |
| 146 | 146 | // internal state |
| r245687 | r245688 | |
| 150 | 150 | offs_t m_rgnoffs; |
| 151 | 151 | UINT8 * m_srcptr; |
| 152 | 152 | fd1089_base_device * m_fd1089; |
| 153 | d | |
| 153 | std::vector<UINT16> m_fd1089_decrypted; | |
| 154 | 154 | auto_pointer<fd1094_decryption_cache> m_fd1094_cache; |
| 155 | 155 | }; |
| 156 | 156 |
| r245687 | r245688 | |
|---|---|---|
| 40 | 40 | dynamic_buffer temp(0x100000); |
| 41 | 41 | |
| 42 | 42 | // make copy of ROM so original can be overwritten |
| 43 | memcpy(temp, rom, 0x10000); | |
| 43 | memcpy(&temp[0], rom, 0x10000); | |
| 44 | 44 | |
| 45 | 45 | // unscramble the address lines |
| 46 | 46 | for(i = 0; i < 0x10000; i++) |
| r245687 | r245688 | |
|---|---|---|
| 56 | 56 | int i; |
| 57 | 57 | |
| 58 | 58 | dynamic_buffer temp(m_stars_length); |
| 59 | memcpy(temp, m_stars_rom, m_stars_length); | |
| 59 | memcpy(&temp[0], m_stars_rom, m_stars_length); | |
| 60 | 60 | |
| 61 | 61 | for (i = 0; i < m_stars_length; i++) |
| 62 | 62 | m_stars_rom[(i & ~0xff) + (i << 5 & 0xe0) + (i >> 3 & 0x1f)] = temp[i]; |
| r245687 | r245688 | |
|---|---|---|
| 93 | 93 | int bank() const { return m_bank; } |
| 94 | 94 | int xscroll() const { return m_xscroll; } |
| 95 | 95 | int yscroll() const { return m_yscroll; } |
| 96 | dynamic_array<UINT16> &code_lookup() { return m_codelookup; } | |
| 97 | dynamic_array<UINT8> &color_lookup() { return m_colorlookup; } | |
| 98 | dynamic_array<UINT8> &gfx_lookup() { return m_gfxlookup; } | |
| 96 | std::vector<UINT16> &code_lookup() { return m_codelookup; } | |
| 97 | std::vector<UINT8> &color_lookup() { return m_colorlookup; } | |
| 98 | std::vector<UINT8> &gfx_lookup() { return m_gfxlookup; } | |
| 99 | 99 | |
| 100 | 100 | // setters |
| 101 | 101 | void set_bank(int bank) { m_bank = bank; } |
| r245687 | r245688 | |
| 212 | 212 | |
| 213 | 213 | // arrays |
| 214 | 214 | optional_shared_ptr<UINT16> m_slipram; // pointer to the SLIP RAM |
| 215 | dynamic_array<UINT16> m_codelookup; // lookup table for codes | |
| 216 | dynamic_array<UINT8> m_colorlookup; // lookup table for colors | |
| 217 | dynamic_array<UINT8> m_gfxlookup; // lookup table for graphics | |
| 215 | std::vector<UINT16> m_codelookup; // lookup table for codes | |
| 216 | std::vector<UINT8> m_colorlookup; // lookup table for colors | |
| 217 | std::vector<UINT8> m_gfxlookup; // lookup table for graphics | |
| 218 | 218 | |
| 219 | 219 | UINT16 m_activelist[MAX_PER_BANK*4]; // active list |
| 220 | 220 | UINT16 * m_activelast; // last entry in the active list |
| r245687 | r245688 | |
|---|---|---|
| 162 | 162 | const UINT16 * m_rombase; // pointer to the base of the GFX ROM |
| 163 | 163 | int m_romlength; // length of the GFX ROM |
| 164 | 164 | int m_objectcount; // number of objects in the ROM |
| 165 | d | |
| 165 | std::vector<object_info> m_info; // list of info records | |
| 166 | 166 | |
| 167 | 167 | // rendering state |
| 168 | 168 | bitmap_ind16 m_vram[2][2]; // pointers to VRAM bitmaps and backbuffers |
| r245687 | r245688 | |
|---|---|---|
| 150 | 150 | decode_gfx(m_playfield_lookup, motable); |
| 151 | 151 | |
| 152 | 152 | /* modify the motion object code lookup */ |
| 153 | dynamic_array<UINT16> &codelookup = m_mob->code_lookup(); | |
| 154 | for (int i = 0; i < codelookup.count(); i++) | |
| 153 | std::vector<UINT16> &codelookup = m_mob->code_lookup(); | |
| 154 | for (unsigned int i = 0; i < codelookup.size(); i++) | |
| 155 | 155 | codelookup[i] = (i & 0xff) | ((motable[i >> 8] & 0xff) << 8); |
| 156 | 156 | |
| 157 | 157 | /* modify the motion object color and gfx lookups */ |
| 158 | dynamic_array<UINT8> &colorlookup = m_mob->color_lookup(); | |
| 159 | dynamic_array<UINT8> &gfxlookup = m_mob->gfx_lookup(); | |
| 160 | for (int i = 0; i < colorlookup.count(); i++) | |
| 158 | std::vector<UINT8> &colorlookup = m_mob->color_lookup(); | |
| 159 | std::vector<UINT8> &gfxlookup = m_mob->gfx_lookup(); | |
| 160 | for (unsigned int i = 0; i < colorlookup.size(); i++) | |
| 161 | 161 | { |
| 162 | 162 | colorlookup[i] = ((motable[i] >> 12) & 15) << 1; |
| 163 | 163 | gfxlookup[i] = (motable[i] >> 8) & 15; |
| r245687 | r245688 | |
|---|---|---|
| 465 | 465 | { |
| 466 | 466 | int x, y; |
| 467 | 467 | |
| 468 | memcpy(s, p, 0x40000); | |
| 468 | memcpy(&s[0], p, 0x40000); | |
| 469 | 469 | |
| 470 | 470 | y = 0; |
| 471 | 471 | |
| r245687 | r245688 | |
| 474 | 474 | x = 0; |
| 475 | 475 | while ( x < 64 ) |
| 476 | 476 | { |
| 477 | UINT8 *src = s | |
| 477 | UINT8 *src = &s[(y*256*8)+(x*4)]; | |
| 478 | 478 | |
| 479 | 479 | *p++ = src[0*256+0];*p++ = src[0*256+1];*p++ = src[0*256+2];*p++ = src[0*256+3]; |
| 480 | 480 | *p++ = src[1*256+0];*p++ = src[1*256+1];*p++ = src[1*256+2];*p++ = src[1*256+3]; |
| r245687 | r245688 | |
|---|---|---|
| 106 | 106 | switch (offset & 0x1800) |
| 107 | 107 | { |
| 108 | 108 | case 0x0000: |
| 109 | RAM = m_ram_r; | |
| 109 | RAM = &m_ram_r[0]; | |
| 110 | 110 | break; |
| 111 | 111 | case 0x0800: |
| 112 | RAM = m_ram_g; | |
| 112 | RAM = &m_ram_g[0]; | |
| 113 | 113 | break; |
| 114 | 114 | case 0x1000: |
| 115 | RAM = m_ram_b; | |
| 115 | RAM = &m_ram_b[0]; | |
| 116 | 116 | break; |
| 117 | 117 | default: // case 0x1800 (internal registers) |
| 118 | 118 | { |
| r245687 | r245688 | |
| 135 | 135 | switch (offset & 0x1800) |
| 136 | 136 | { |
| 137 | 137 | case 0x0000: |
| 138 | RAM = m_ram_r; | |
| 138 | RAM = &m_ram_r[0]; | |
| 139 | 139 | break; |
| 140 | 140 | case 0x0800: |
| 141 | RAM = m_ram_g; | |
| 141 | RAM = &m_ram_g[0]; | |
| 142 | 142 | break; |
| 143 | 143 | case 0x1000: |
| 144 | RAM = m_ram_b; | |
| 144 | RAM = &m_ram_b[0]; | |
| 145 | 145 | break; |
| 146 | 146 | default: // case 0x1800 (internal registers) |
| 147 | 147 | { |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | |
| 34 | 34 | private: |
| 35 | 35 | // internal state |
| 36 | dynamic_array<UINT8> m_ram_r; | |
| 37 | dynamic_array<UINT8> m_ram_g; | |
| 38 | dynamic_array<UINT8> m_ram_b; | |
| 36 | std::vector<UINT8> m_ram_r; | |
| 37 | std::vector<UINT8> m_ram_g; | |
| 38 | std::vector<UINT8> m_ram_b; | |
| 39 | 39 | UINT16 m_regs[8]; |
| 40 | 40 | }; |
| 41 | 41 |
| r245687 | r245688 | |
|---|---|---|
| 33 | 33 | PALETTE_INIT_MEMBER(carjmbre_state, carjmbre) |
| 34 | 34 | { |
| 35 | 35 | const UINT8 *color_prom = memregion("proms")->base(); |
| 36 | d | |
| 36 | std::vector<rgb_t> rgb; | |
| 37 | 37 | |
| 38 | 38 | compute_res_net_all(rgb, color_prom, carjmbre_decode_info, carjmbre_net_info); |
| 39 | palette.set_pen_colors(0, rgb | |
| 39 | palette.set_pen_colors(0, rgb); | |
| 40 | 40 | palette.palette()->normalize_range(0, 63); |
| 41 | 41 | } |
| 42 | 42 |
| r245687 | r245688 | |
|---|---|---|
| 199 | 199 | PALETTE_INIT_MEMBER(dkong_state,dkong2b) |
| 200 | 200 | { |
| 201 | 201 | const UINT8 *color_prom = memregion("proms")->base(); |
| 202 | d | |
| 202 | std::vector<rgb_t> rgb; | |
| 203 | 203 | int i; |
| 204 | 204 | |
| 205 | 205 | compute_res_net_all(rgb, color_prom, dkong_decode_info, dkong_net_info); |
| 206 | palette.set_pen_colors(0, rgb | |
| 206 | palette.set_pen_colors(0, rgb); | |
| 207 | 207 | |
| 208 | 208 | /* Now treat tri-state black background generation */ |
| 209 | 209 | |
| r245687 | r245688 | |
| 428 | 428 | PALETTE_INIT_MEMBER(dkong_state,dkong3) |
| 429 | 429 | { |
| 430 | 430 | const UINT8 *color_prom = memregion("proms")->base(); |
| 431 | d | |
| 431 | std::vector<rgb_t> rgb; | |
| 432 | 432 | |
| 433 | 433 | compute_res_net_all(rgb, color_prom, dkong3_decode_info, dkong3_net_info); |
| 434 | palette.set_pen_colors(0, rgb | |
| 434 | palette.set_pen_colors(0, rgb); | |
| 435 | 435 | palette.palette()->normalize_range(0, 255); |
| 436 | 436 | |
| 437 | 437 | color_prom += 1024; |
| r245687 | r245688 | |
|---|---|---|
| 82 | 82 | VIDEO_START_MEMBER(gauntlet_state,gauntlet) |
| 83 | 83 | { |
| 84 | 84 | /* modify the motion object code lookup table to account for the code XOR */ |
| 85 | dynamic_array<UINT16> &codelookup = m_mob->code_lookup(); | |
| 86 | for (int i = 0; i < codelookup.count(); i++) | |
| 85 | std::vector<UINT16> &codelookup = m_mob->code_lookup(); | |
| 86 | for (unsigned int i = 0; i < codelookup.size(); i++) | |
| 87 | 87 | codelookup[i] ^= 0x800; |
| 88 | 88 | |
| 89 | 89 | /* set up the base color for the playfield */ |
| r245687 | r245688 | |
|---|---|---|
| 284 | 284 | |
| 285 | 285 | // Operation 0100 |
| 286 | 286 | // Polygon rasterization. |
| 287 | void hng64_state::recoverPolygonBlock(const UINT16* packet, struct polygon | |
| 287 | void hng64_state::recoverPolygonBlock(const UINT16* packet, std::vector<struct polygon> &polys, int* numPolys) | |
| 288 | 288 | { |
| 289 | 289 | /*////////////// |
| 290 | 290 | // PACKET FORMAT |
| r245687 | r245688 | |
| 865 | 865 | { |
| 866 | 866 | /* A temporary place to put some polygons. This will optimize away if the compiler's any good. */ |
| 867 | 867 | int numPolys = 0; |
| 868 | d | |
| 868 | std::vector<polygon> polys(1024*5); | |
| 869 | 869 | |
| 870 | 870 | //printf("packet type : %04x %04x|%04x %04x|%04x %04x|%04x %04x | %04x %04x %04x %04x %04x %04x %04x %04x\n", packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7], packet[8], packet[9], packet[10], packet[11], packet[12], packet[13], packet[14], packet[15]); |
| 871 | 871 |
| r245687 | r245688 | |
|---|---|---|
| 160 | 160 | m_gfx[0]->set_colors(m_palette->entries() / m_gfx[0]->depth()); |
| 161 | 161 | |
| 162 | 162 | m_tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k051316_device::get_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); |
| 163 | m_ram.resize_and_clear(0x800); | |
| 163 | m_ram.resize(0x800); | |
| 164 | memset(&m_ram[0], 0, 0x800); | |
| 164 | 165 | |
| 165 | 166 | if (m_layermask) |
| 166 | 167 | { |
| r245687 | r245688 | |
|---|---|---|
| 78 | 78 | |
| 79 | 79 | private: |
| 80 | 80 | // internal state |
| 81 | d | |
| 81 | std::vector<UINT8> m_ram; | |
| 82 | 82 | UINT8 m_ctrlram[16]; |
| 83 | 83 | tilemap_t *m_tmap; |
| 84 | 84 |
| r245687 | r245688 | |
|---|---|---|
| 370 | 370 | |
| 371 | 371 | // calculate physical pixel location |
| 372 | 372 | // each offset unit represents 256 pixels and should wrap at ROM boundary for safety |
| 373 | pix_ptr = &m_unpacked_rom[((offset << 8) % m_unpacked_rom. | |
| 373 | pix_ptr = &m_unpacked_rom[((offset << 8) % m_unpacked_rom.size())]; | |
| 374 | 374 | |
| 375 | 375 | // get scanline zoom factor |
| 376 | 376 | // For example, 0x20 doubles the length, 0x40 maintains a one-to-one length, |
| r245687 | r245688 | |
| 426 | 426 | return; // make sure we only do DMA transfer once per frame |
| 427 | 427 | |
| 428 | 428 | m_frame = current_frame; |
| 429 | memcpy(m_buffer[m_page], m_ram, 0x1000); | |
| 429 | memcpy(m_buffer[m_page], &m_ram[0], 0x1000); | |
| 430 | 430 | m_page ^= 1; |
| 431 | 431 | } |
| 432 | 432 |
| r245687 | r245688 | |
|---|---|---|
| 41 | 41 | |
| 42 | 42 | // internal state |
| 43 | 43 | dynamic_buffer m_unpacked_rom; |
| 44 | d | |
| 44 | std::vector<UINT16> m_ram; | |
| 45 | 45 | UINT16 *m_buffer[2]; |
| 46 | 46 | UINT8 m_regs[8]; |
| 47 | 47 | UINT8 m_page; |
| r245687 | r245688 | |
|---|---|---|
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | |
| 282 | m_videoram.resize_and_clear(0x2000 * (K056832_PAGE_COUNT + 1) / 2); | |
| 282 | m_videoram.resize(0x2000 * (K056832_PAGE_COUNT + 1) / 2); | |
| 283 | memset(&m_videoram[0], 0, 2*m_videoram.size()); | |
| 283 | 284 | |
| 284 | 285 | m_tilemap[0x0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(k056832_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); |
| 285 | 286 | m_tilemap[0x1] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(k056832_device::get_tile_info1),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); |
| r245687 | r245688 | |
|---|---|---|
| 125 | 125 | tilemap_t *m_tilemap[K056832_PAGE_COUNT]; |
| 126 | 126 | bitmap_ind16 *m_pixmap[K056832_PAGE_COUNT]; |
| 127 | 127 | |
| 128 | d | |
| 128 | std::vector<UINT16> m_videoram; | |
| 129 | 129 | |
| 130 | 130 | UINT16 m_regs[0x20]; // 157/832 regs group 1 |
| 131 | 131 | UINT16 m_regsb[4]; // 157/832 regs group 2, board dependent |
| r245687 | r245688 | |
|---|---|---|
| 200 | 200 | PALETTE_INIT_MEMBER(m62_state, m62) |
| 201 | 201 | { |
| 202 | 202 | const UINT8 *color_prom = memregion("proms")->base(); |
| 203 | d | |
| 203 | std::vector<rgb_t> rgb; | |
| 204 | 204 | |
| 205 | 205 | compute_res_net_all(rgb, color_prom, m62_tile_decode_info, m62_tile_net_info); |
| 206 | palette.set_pen_colors(0x000, rgb | |
| 206 | palette.set_pen_colors(0x000, rgb); | |
| 207 | 207 | |
| 208 | 208 | compute_res_net_all(rgb, color_prom, m62_sprite_decode_info, m62_sprite_net_info); |
| 209 | palette.set_pen_colors(0x100, rgb | |
| 209 | palette.set_pen_colors(0x100, rgb); | |
| 210 | 210 | |
| 211 | 211 | m62_amplify_contrast(palette.palette(),0); |
| 212 | 212 | |
| r245687 | r245688 | |
| 218 | 218 | PALETTE_INIT_MEMBER(m62_state,lotlot) |
| 219 | 219 | { |
| 220 | 220 | const UINT8 *color_prom = memregion("proms")->base(); |
| 221 | d | |
| 221 | std::vector<rgb_t> rgb; | |
| 222 | 222 | |
| 223 | 223 | compute_res_net_all(rgb, color_prom, lotlot_tile_decode_info, m62_tile_net_info); |
| 224 | palette.set_pen_colors(0x000, rgb | |
| 224 | palette.set_pen_colors(0x000, rgb); | |
| 225 | 225 | |
| 226 | 226 | compute_res_net_all(rgb, color_prom, lotlot_sprite_decode_info, m62_sprite_net_info); |
| 227 | palette.set_pen_colors(0x180, rgb | |
| 227 | palette.set_pen_colors(0x180, rgb); | |
| 228 | 228 | |
| 229 | 229 | m62_amplify_contrast(palette.palette(),0); |
| 230 | 230 | |
| r245687 | r245688 | |
| 236 | 236 | PALETTE_INIT_MEMBER(m62_state,battroad) |
| 237 | 237 | { |
| 238 | 238 | const UINT8 *color_prom = memregion("proms")->base(); |
| 239 | d | |
| 239 | std::vector<rgb_t> rgb; | |
| 240 | 240 | |
| 241 | 241 | // m62 palette |
| 242 | 242 | compute_res_net_all(rgb, color_prom, m62_tile_decode_info, m62_tile_net_info); |
| 243 | palette.set_pen_colors(0x000, rgb | |
| 243 | palette.set_pen_colors(0x000, rgb); | |
| 244 | 244 | |
| 245 | 245 | compute_res_net_all(rgb, color_prom, m62_sprite_decode_info, m62_sprite_net_info); |
| 246 | palette.set_pen_colors(0x100, rgb | |
| 246 | palette.set_pen_colors(0x100, rgb); | |
| 247 | 247 | |
| 248 | 248 | m62_amplify_contrast(palette.palette(),0x200); |
| 249 | 249 | |
| 250 | 250 | // custom palette for foreground |
| 251 | 251 | compute_res_net_all(rgb, color_prom, battroad_char_decode_info, battroad_char_net_info); |
| 252 | palette.set_pen_colors(0x200, rgb | |
| 252 | palette.set_pen_colors(0x200, rgb); | |
| 253 | 253 | |
| 254 | 254 | /* we'll need this at run time */ |
| 255 | 255 | m_sprite_height_prom = color_prom + 0x620; |
| r245687 | r245688 | |
| 259 | 259 | PALETTE_INIT_MEMBER(m62_state,spelunk2) |
| 260 | 260 | { |
| 261 | 261 | const UINT8 *color_prom = memregion("proms")->base(); |
| 262 | d | |
| 262 | std::vector<rgb_t> rgb; | |
| 263 | 263 | |
| 264 | 264 | compute_res_net_all(rgb, color_prom, spelunk2_tile_decode_info, m62_tile_net_info); |
| 265 | palette.set_pen_colors(0x000, rgb | |
| 265 | palette.set_pen_colors(0x000, rgb); | |
| 266 | 266 | |
| 267 | 267 | compute_res_net_all(rgb, color_prom, spelunk2_sprite_decode_info, m62_sprite_net_info); |
| 268 | palette.set_pen_colors(0x200, rgb | |
| 268 | palette.set_pen_colors(0x200, rgb); | |
| 269 | 269 | |
| 270 | 270 | m62_amplify_contrast(palette.palette(),0); |
| 271 | 271 |
| r245687 | r245688 | |
|---|---|---|
| 65 | 65 | PALETTE_INIT_MEMBER(mario_state, mario) |
| 66 | 66 | { |
| 67 | 67 | const UINT8 *color_prom = memregion("proms")->base(); |
| 68 | d | |
| 68 | std::vector<rgb_t> rgb; | |
| 69 | 69 | |
| 70 | 70 | if (m_monitor == 0) |
| 71 | 71 | compute_res_net_all(rgb, color_prom, mario_decode_info, mario_net_info); |
| 72 | 72 | else |
| 73 | 73 | compute_res_net_all(rgb, color_prom+256, mario_decode_info, mario_net_info_std); |
| 74 | 74 | |
| 75 | palette.set_pen_colors(0, rgb | |
| 75 | palette.set_pen_colors(0, rgb); | |
| 76 | 76 | palette.palette()->normalize_range(0, 255); |
| 77 | 77 | } |
| 78 | 78 |
| r245687 | r245688 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | struct vector { | |
| 17 | struct vector_t { | |
| 18 | 18 | float x, y, z; |
| 19 | 19 | }; |
| 20 | 20 | |
| r245687 | r245688 | |
| 31 | 31 | float a_bottom, a_top, a_left, a_right; |
| 32 | 32 | float vxx, vyy, vzz, ayy, ayyc, ayys; |
| 33 | 33 | float trans_mat[12]; |
| 34 | struct vector light; | |
| 34 | struct vector_t light; | |
| 35 | 35 | struct lightparam lightparams[32]; |
| 36 | 36 | }; |
| 37 | 37 | |
| r245687 | r245688 | |
| 81 | 81 | p->z = view->ayys*xx+view->ayyc*zz; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | static void transform_vector(struct view *view, struct vector *p) | |
| 84 | static void transform_vector(struct view *view, struct vector_t *p) | |
| 85 | 85 | { |
| 86 | struct vector q = *p; | |
| 86 | struct vector_t q = *p; | |
| 87 | 87 | float *trans = view->trans_mat; |
| 88 | 88 | p->x = trans[0]*q.x+trans[3]*q.y+trans[6]*q.z; |
| 89 | 89 | p->y = trans[1]*q.x+trans[4]*q.y+trans[7]*q.z; |
| 90 | 90 | p->z = trans[2]*q.x+trans[5]*q.y+trans[8]*q.z; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | static void normalize_vector(struct vector *p) | |
| 93 | static void normalize_vector(struct vector_t *p) | |
| 94 | 94 | { |
| 95 | 95 | float norm = sqrt(p->x*p->x+p->y*p->y+p->z*p->z); |
| 96 | 96 | if(norm) { |
| r245687 | r245688 | |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | static float mult_vector(const struct vector *p, const struct vector *q) | |
| 103 | static float mult_vector(const struct vector_t *p, const struct vector_t *q) | |
| 104 | 104 | { |
| 105 | 105 | return p->x*q->x+p->y*q->y+p->z*q->z; |
| 106 | 106 | } |
| r245687 | r245688 | |
| 696 | 696 | #ifdef UNUSED_DEFINITION |
| 697 | 697 | static const UINT8 num_of_times[]={1,1,1,1,2,2,2,3}; |
| 698 | 698 | #endif |
| 699 | static float compute_specular(struct vector *normal, struct vector *light,float diffuse,int lmode) | |
| 699 | static float compute_specular(struct vector_t *normal, struct vector_t *light,float diffuse,int lmode) | |
| 700 | 700 | { |
| 701 | 701 | #if 0 |
| 702 | 702 | float s; |
| r245687 | r245688 | |
| 728 | 728 | int i; |
| 729 | 729 | UINT32 flags; |
| 730 | 730 | struct point *old_p0, *old_p1, *p0, *p1; |
| 731 | struct vector vn; | |
| 731 | struct vector_t vn; | |
| 732 | 732 | int link, type; |
| 733 | 733 | #if 0 |
| 734 | 734 | int dump; |
| r245687 | r245688 | |
|---|---|---|
| 187 | 187 | |
| 188 | 188 | m_shaperam.resize(0x8000); |
| 189 | 189 | |
| 190 | m_gfxdecode->gfx(2)->set_source(m_shaperam); | |
| 190 | m_gfxdecode->gfx(2)->set_source(&m_shaperam[0]); | |
| 191 | 191 | } /* namcona1_vh_start */ |
| 192 | 192 | |
| 193 | 193 | /*************************************************************************/ |
| r245687 | r245688 | |
|---|---|---|
| 124 | 124 | { |
| 125 | 125 | create_rgb_lookups(); |
| 126 | 126 | |
| 127 | m_paletteram.resize_and_clear(0x1000 * 2); | |
| 127 | m_paletteram.resize(0x1000 * 2); | |
| 128 | memset(&m_paletteram[0], 0, 0x1000 * 2 * sizeof(m_paletteram[0])); | |
| 128 | 129 | |
| 129 | 130 | m_screen_shadow = 0; |
| 130 | 131 | m_palette_bank = 0; |
| r245687 | r245688 | |
|---|---|---|
| 711 | 711 | void neosprite_optimized_device::optimize_sprite_data() |
| 712 | 712 | { |
| 713 | 713 | m_sprite_gfx_address_mask = neogeohelper_optimize_sprite_data(m_sprite_gfx, m_region_sprites, m_region_sprites_size); |
| 714 | m_spritegfx8 = m_sprite_gfx; | |
| 714 | m_spritegfx8 = &m_sprite_gfx[0]; | |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | void neosprite_optimized_device::set_optimized_sprite_data(UINT8* sprdata, UINT32 mask) |
| r245687 | r245688 | |
|---|---|---|
| 113 | 113 | virtual void optimize_sprite_data(); |
| 114 | 114 | virtual void set_optimized_sprite_data(UINT8* sprdata, UINT32 mask); |
| 115 | 115 | virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens); |
| 116 | d | |
| 116 | std::vector<UINT8> m_sprite_gfx; | |
| 117 | 117 | UINT8* m_spritegfx8; |
| 118 | 118 | |
| 119 | 119 | }; |
| r245687 | r245688 | |
|---|---|---|
| 79 | 79 | { |
| 80 | 80 | const UINT8 *color_prom = memregion("proms")->base(); |
| 81 | 81 | int i; |
| 82 | d | |
| 82 | std::vector<rgb_t> rgb; | |
| 83 | 83 | |
| 84 | 84 | compute_res_net_all(rgb, color_prom, phoenix_decode_info, phoenix_net_info); |
| 85 | 85 | /* native order */ |
| r245687 | r245688 | |
| 96 | 96 | { |
| 97 | 97 | const UINT8 *color_prom = memregion("proms")->base(); |
| 98 | 98 | int i; |
| 99 | d | |
| 99 | std::vector<rgb_t> rgb; | |
| 100 | 100 | |
| 101 | 101 | compute_res_net_all(rgb, color_prom, phoenix_decode_info, survival_net_info); |
| 102 | 102 | /* native order */ |
| r245687 | r245688 | |
| 113 | 113 | { |
| 114 | 114 | const UINT8 *color_prom = memregion("proms")->base(); |
| 115 | 115 | int i; |
| 116 | d | |
| 116 | std::vector<rgb_t> rgb; | |
| 117 | 117 | |
| 118 | 118 | compute_res_net_all(rgb, color_prom, phoenix_decode_info, pleiades_net_info); |
| 119 | 119 | /* native order */ |
| r245687 | r245688 | |
|---|---|---|
| 160 | 160 | |
| 161 | 161 | #if USE_NEW_COLOR |
| 162 | 162 | /* sprites */ |
| 163 | d | |
| 163 | std::vector<rgb_t> rgb; | |
| 164 | 164 | UINT8 cpi[512]; |
| 165 | 165 | |
| 166 | 166 | for (i=0; i<512; i++) |
| 167 | 167 | cpi[i] = color_prom[i] ^ m_invertmask; |
| 168 | 168 | |
| 169 | 169 | compute_res_net_all(rgb, &cpi[0], popeye_7052_decode_info, popeye_7052_obj_net_info); |
| 170 | m_palette->set_pen_colors(48, rgb | |
| 170 | m_palette->set_pen_colors(48, rgb); | |
| 171 | 171 | #else |
| 172 | 172 | for (i = 0;i < 256;i++) |
| 173 | 173 | { |
| r245687 | r245688 | |
| 220 | 220 | |
| 221 | 221 | #if USE_NEW_COLOR |
| 222 | 222 | UINT8 cpi[16]; |
| 223 | d | |
| 223 | std::vector<rgb_t> rgb; | |
| 224 | 224 | for (i=0; i<16; i++) |
| 225 | 225 | cpi[i] = color_prom[i] ^ m_invertmask; |
| 226 | 226 | |
| 227 | 227 | compute_res_net_all(rgb, &cpi[0], popeye_7051_decode_info, popeye_7051_bck_net_info); |
| 228 | m_palette->set_pen_colors(0, rgb | |
| 228 | m_palette->set_pen_colors(0, rgb); | |
| 229 | 229 | |
| 230 | 230 | #else |
| 231 | 231 | for (i = 0;i < 16;i++) |
| r245687 | r245688 | |
|---|---|---|
| 41 | 41 | PALETTE_INIT_MEMBER(popper_state, popper) |
| 42 | 42 | { |
| 43 | 43 | const UINT8 *color_prom = memregion("proms")->base(); |
| 44 | d | |
| 44 | std::vector<rgb_t> rgb; | |
| 45 | 45 | |
| 46 | 46 | compute_res_net_all(rgb, color_prom, popper_decode_info, popper_net_info); |
| 47 | palette.set_pen_colors(0, rgb | |
| 47 | palette.set_pen_colors(0, rgb); | |
| 48 | 48 | palette.palette()->normalize_range(0, 63); |
| 49 | 49 | } |
| 50 | 50 |
| r245687 | r245688 | |
|---|---|---|
| 77 | 77 | PALETTE_INIT_MEMBER(skyfox_state, skyfox) |
| 78 | 78 | { |
| 79 | 79 | const UINT8 *color_prom = memregion("proms")->base(); |
| 80 | d | |
| 80 | std::vector<rgb_t> rgb; | |
| 81 | 81 | |
| 82 | 82 | compute_res_net_all(rgb, color_prom, skyfox_decode_info, skyfox_net_info); |
| 83 | palette.set_pen_colors(0, rgb | |
| 83 | palette.set_pen_colors(0, rgb); | |
| 84 | 84 | |
| 85 | 85 | /* Grey scale for the background??? is wrong */ |
| 86 | 86 | for (int i = 0; i < 256; i++) |
| r245687 | r245688 | |
|---|---|---|
| 16 | 16 | { |
| 17 | 17 | m_display_disable = false; |
| 18 | 18 | m_bank_vidram = 0; |
| 19 | m_vidram.resize_and_clear(0x1000 * 2); | |
| 19 | m_vidram.resize(0x1000 * 2); | |
| 20 | memset(&m_vidram[0], 0, 0x1000*2); | |
| 20 | 21 | m_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(speedspn_state::get_tile_info),this),TILEMAP_SCAN_COLS, 8, 8,64,32); |
| 21 | 22 | |
| 22 | 23 | save_item(NAME(m_display_disable)); |
| r245687 | r245688 | |
| 61 | 62 | void speedspn_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 62 | 63 | { |
| 63 | 64 | gfx_element *gfx = m_gfxdecode->gfx(1); |
| 64 | UINT8 *source = m_vidram | |
| 65 | UINT8 *source = &m_vidram[0x1000]; | |
| 65 | 66 | UINT8 *finish = source + 0x1000; |
| 66 | 67 | |
| 67 | 68 | while( source<finish ) |
| r245687 | r245688 | |
|---|---|---|
| 35 | 35 | PALETTE_INIT_MEMBER(tagteam_state, tagteam) |
| 36 | 36 | { |
| 37 | 37 | const UINT8 *color_prom = memregion("proms")->base(); |
| 38 | d | |
| 38 | std::vector<rgb_t> rgb; | |
| 39 | 39 | |
| 40 | 40 | compute_res_net_all(rgb, color_prom, tagteam_decode_info, tagteam_net_info); |
| 41 | palette.set_pen_colors(0x00, rgb | |
| 41 | palette.set_pen_colors(0x00, rgb); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 |
| r245687 | r245688 | |
|---|---|---|
| 25 | 25 | |
| 26 | 26 | void tc0150rod_device::device_start() |
| 27 | 27 | { |
| 28 | m_ram.resize_and_clear(TC0150ROD_RAM_SIZE / 2); | |
| 28 | m_ram.resize(TC0150ROD_RAM_SIZE / 2); | |
| 29 | memset(&m_ram[0], 0, TC0150ROD_RAM_SIZE); | |
| 29 | 30 | save_item(NAME(m_ram)); |
| 30 | 31 | |
| 31 | 32 | m_roadgfx = (UINT16 *)region()->base(); |
| r245687 | r245688 | |
|---|---|---|
| 17 | 17 | |
| 18 | 18 | private: |
| 19 | 19 | // internal state |
| 20 | d | |
| 20 | std::vector<UINT16> m_ram; | |
| 21 | 21 | UINT16 *m_roadgfx; |
| 22 | 22 | }; |
| 23 | 23 |
| r245687 | r245688 | |
|---|---|---|
| 291 | 291 | m_tilemap[3][i]->set_scroll_rows(512); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | m_ram.resize_and_clear(TC0480SCP_RAM_SIZE / 2); | |
| 294 | m_ram.resize(TC0480SCP_RAM_SIZE / 2); | |
| 295 | memset(&m_ram[0], 0, TC0480SCP_RAM_SIZE); | |
| 295 | 296 | set_layer_ptrs(); |
| 296 | 297 | |
| 297 | 298 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| r245687 | r245688 | |
| 383 | 384 | { |
| 384 | 385 | if (!m_dblwidth) |
| 385 | 386 | { |
| 386 | m_bg_ram[0] = m_ram + 0x0000; //0000 | |
| 387 | m_bg_ram[1] = m_ram + 0x0800; //1000 | |
| 388 | m_bg_ram[2] = m_ram + 0x1000; //2000 | |
| 389 | m_bg_ram[3] = m_ram + 0x1800; //3000 | |
| 390 | m_bgscroll_ram[0] = m_ram + 0x2000; //4000 | |
| 391 | m_bgscroll_ram[1] = m_ram + 0x2200; //4400 | |
| 392 | m_bgscroll_ram[2] = m_ram + 0x2400; //4800 | |
| 393 | m_bgscroll_ram[3] = m_ram + 0x2600; //4c00 | |
| 394 | m_rowzoom_ram[2] = m_ram + 0x3000; //6000 | |
| 395 | m_rowzoom_ram[3] = m_ram + 0x3200; //6400 | |
| 396 | m_bgcolumn_ram[2] = m_ram + 0x3400; //6800 | |
| 397 | m_bgcolumn_ram[3] = m_ram + 0x3600; //6c00 | |
| 398 | m_tx_ram = m_ram + 0x6000; //c000 | |
| 399 | m_char_ram = m_ram + 0x7000; //e000 | |
| 387 | m_bg_ram[0] = &m_ram[0x0000]; //0000 | |
| 388 | m_bg_ram[1] = &m_ram[0x0800]; //1000 | |
| 389 | m_bg_ram[2] = &m_ram[0x1000]; //2000 | |
| 390 | m_bg_ram[3] = &m_ram[0x1800]; //3000 | |
| 391 | m_bgscroll_ram[0] = &m_ram[0x2000]; //4000 | |
| 392 | m_bgscroll_ram[1] = &m_ram[0x2200]; //4400 | |
| 393 | m_bgscroll_ram[2] = &m_ram[0x2400]; //4800 | |
| 394 | m_bgscroll_ram[3] = &m_ram[0x2600]; //4c00 | |
| 395 | m_rowzoom_ram[2] = &m_ram[0x3000]; //6000 | |
| 396 | m_rowzoom_ram[3] = &m_ram[0x3200]; //6400 | |
| 397 | m_bgcolumn_ram[2] = &m_ram[0x3400]; //6800 | |
| 398 | m_bgcolumn_ram[3] = &m_ram[0x3600]; //6c00 | |
| 399 | m_tx_ram = &m_ram[0x6000]; //c000 | |
| 400 | m_char_ram = &m_ram[0x7000]; //e000 | |
| 400 | 401 | } |
| 401 | 402 | else |
| 402 | 403 | { |
| 403 | m_bg_ram[0] = m_ram + 0x0000; //0000 | |
| 404 | m_bg_ram[1] = m_ram + 0x1000; //2000 | |
| 405 | m_bg_ram[2] = m_ram + 0x2000; //4000 | |
| 406 | m_bg_ram[3] = m_ram + 0x3000; //6000 | |
| 407 | m_bgscroll_ram[0] = m_ram + 0x4000; //8000 | |
| 408 | m_bgscroll_ram[1] = m_ram + 0x4200; //8400 | |
| 409 | m_bgscroll_ram[2] = m_ram + 0x4400; //8800 | |
| 410 | m_bgscroll_ram[3] = m_ram + 0x4600; //8c00 | |
| 411 | m_rowzoom_ram[2] = m_ram + 0x5000; //a000 | |
| 412 | m_rowzoom_ram[3] = m_ram + 0x5200; //a400 | |
| 413 | m_bgcolumn_ram[2] = m_ram + 0x5400; //a800 | |
| 414 | m_bgcolumn_ram[3] = m_ram + 0x5600; //ac00 | |
| 415 | m_tx_ram = m_ram + 0x6000; //c000 | |
| 416 | m_char_ram = m_ram + 0x7000; //e000 | |
| 404 | m_bg_ram[0] = &m_ram[0x0000]; //0000 | |
| 405 | m_bg_ram[1] = &m_ram[0x1000]; //2000 | |
| 406 | m_bg_ram[2] = &m_ram[0x2000]; //4000 | |
| 407 | m_bg_ram[3] = &m_ram[0x3000]; //6000 | |
| 408 | m_bgscroll_ram[0] = &m_ram[0x4000]; //8000 | |
| 409 | m_bgscroll_ram[1] = &m_ram[0x4200]; //8400 | |
| 410 | m_bgscroll_ram[2] = &m_ram[0x4400]; //8800 | |
| 411 | m_bgscroll_ram[3] = &m_ram[0x4600]; //8c00 | |
| 412 | m_rowzoom_ram[2] = &m_ram[0x5000]; //a000 | |
| 413 | m_rowzoom_ram[3] = &m_ram[0x5200]; //a400 | |
| 414 | m_bgcolumn_ram[2] = &m_ram[0x5400]; //a800 | |
| 415 | m_bgcolumn_ram[3] = &m_ram[0x5600]; //ac00 | |
| 416 | m_tx_ram = &m_ram[0x6000]; //c000 | |
| 417 | m_char_ram = &m_ram[0x7000]; //e000 | |
| 417 | 418 | } |
| 418 | 419 | } |
| 419 | 420 |
| r245687 | r245688 | |
|---|---|---|
| 69 | 69 | // internal state |
| 70 | 70 | UINT16 m_ctrl[0x18]; |
| 71 | 71 | |
| 72 | d | |
| 72 | std::vector<UINT16> m_ram; | |
| 73 | 73 | UINT16 * m_bg_ram[4]; |
| 74 | 74 | UINT16 * m_tx_ram; |
| 75 | 75 | UINT16 * m_char_ram; |
| r245687 | r245688 | |
|---|---|---|
| 247 | 247 | buffer[i*2] = (src[i] & 0xf0) >> 4; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | memcpy(src, buffer, len); | |
| 250 | memcpy(src, &buffer[0], len); | |
| 251 | 251 | |
| 252 | 252 | /* decode the graphics */ |
| 253 | 253 | m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, bg_layout, memregion(region)->base(), 0, 64, 0x0a00))); |
| r245687 | r245688 | |
|---|---|---|
| 56 | 56 | screen_buffer.resize(128*32); |
| 57 | 57 | bitcounts.resize(256); |
| 58 | 58 | |
| 59 | dmd0->configure_entries(0, 0x10, ram, 0x200); | |
| 60 | dmd2->configure_entries(0, 0x10, ram, 0x200); | |
| 61 | dmd4->configure_entries(0, 0x10, ram, 0x200); | |
| 62 | dmd6->configure_entries(0, 0x10, ram, 0x200); | |
| 63 | dmd8->configure_entries(0, 0x10, ram, 0x200); | |
| 64 | dmda->configure_entries(0, 0x10, ram, 0x200); | |
| 59 | dmd0->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 60 | dmd2->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 61 | dmd4->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 62 | dmd6->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 63 | dmd8->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 64 | dmda->configure_entries(0, 0x10, &ram[0], 0x200); | |
| 65 | 65 | |
| 66 | memset(ram, 0x00, 0x2000); | |
| 66 | memset(&ram[0], 0x00, 0x2000); | |
| 67 | 67 | |
| 68 | 68 | for(int i=0; i<256; i++) { |
| 69 | 69 | int bc = i; |
| r245687 | r245688 | |
| 90 | 90 | dmd8->set_entry(4); |
| 91 | 91 | dmda->set_entry(5); |
| 92 | 92 | |
| 93 | memset(screen_buffer, 0x00, 128*32); | |
| 93 | memset(&screen_buffer[0], 0x00, 128*32); | |
| 94 | 94 | visible_page = 0; |
| 95 | 95 | firq_scanline = 0; |
| 96 | 96 | cur_scanline = 0; |
| r245687 | r245688 | |
| 98 | 98 | |
| 99 | 99 | UINT32 wpc_dmd_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 100 | 100 | { |
| 101 | const UINT8 *src = screen_buffer; | |
| 101 | const UINT8 *src = &screen_buffer[0]; | |
| 102 | 102 | for(int y=0; y<32; y++) { |
| 103 | 103 | UINT32 *pix0 = reinterpret_cast<UINT32 *>(bitmap.raw_pixptr(y*4)); |
| 104 | 104 | UINT32 *pix1 = reinterpret_cast<UINT32 *>(bitmap.raw_pixptr(y*4+1)); |
| r245687 | r245688 | |
| 143 | 143 | |
| 144 | 144 | TIMER_DEVICE_CALLBACK_MEMBER(wpc_dmd_device::scanline_timer) |
| 145 | 145 | { |
| 146 | const UINT8 *src = ram | |
| 146 | const UINT8 *src = &ram[0x200*(visible_page & 0xf) + 16*cur_scanline]; | |
| 147 | 147 | UINT8 *base = &screen_buffer[128*cur_scanline]; |
| 148 | 148 | |
| 149 | 149 | for(int x1=0; x1<16; x1++) { |
| r245687 | r245688 | |
|---|---|---|
| 39 | 39 | required_memory_bank dmd0, dmd2, dmd4, dmd6, dmd8, dmda; |
| 40 | 40 | |
| 41 | 41 | UINT8 cur_scanline, visible_page, firq_scanline; |
| 42 | d | |
| 42 | std::vector<UINT8> ram, screen_buffer, bitcounts; | |
| 43 | 43 | |
| 44 | 44 | virtual void device_start(); |
| 45 | 45 | virtual void device_reset(); |
| r245687 | r245688 | |
|---|---|---|
| 486 | 486 | |
| 487 | 487 | dynamic_buffer data; |
| 488 | 488 | data.resize(quickload_size); |
| 489 | image.fread(data, quickload_size); | |
| 489 | image.fread(&data[0], quickload_size); | |
| 490 | 490 | for (int i = 1; i < quickload_size; i++) |
| 491 | 491 | space.write_byte(address++, data[i]); |
| 492 | 492 |
| r245687 | r245688 | |
|---|---|---|
| 51 | 51 | private: |
| 52 | 52 | required_device<address_map_bank_device> m_bootrom; |
| 53 | 53 | required_memory_bank m_wom; |
| 54 | d | |
| 54 | std::vector<UINT16> m_wom_ram; | |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | 57 | class a2000_state : public amiga_state |
| r245687 | r245688 | |
| 557 | 557 | |
| 558 | 558 | // allocate 256kb for wom |
| 559 | 559 | m_wom_ram.resize(256 * 1024 / 2); |
| 560 | m_wom->set_base(m_wom_ram); | |
| 560 | m_wom->set_base(&m_wom_ram[0]); | |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | void a1000_state::machine_reset() |
| r245687 | r245688 | |
|---|---|---|
| 301 | 301 | DEVICE_IMAGE_UNLOAD_MEMBER( beta_state, beta_eprom ) |
| 302 | 302 | { |
| 303 | 303 | if (image.software_entry() == NULL) |
| 304 | image.fwrite(m_eprom_rom, 0x800); | |
| 304 | image.fwrite(&m_eprom_rom[0], 0x800); | |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /* Machine Initialization */ |
| r245687 | r245688 | |
| 313 | 313 | m_eprom_rom.resize(0x800); |
| 314 | 314 | |
| 315 | 315 | if (!m_eprom->exists()) |
| 316 | memset(m_eprom_rom, 0xff, 0x800); | |
| 316 | memset(&m_eprom_rom[0], 0xff, 0x800); | |
| 317 | 317 | else |
| 318 | 318 | { |
| 319 | 319 | astring region_tag; |
| 320 | memcpy(m_eprom_rom, memregion(region_tag.cpy(m_eprom->tag()).cat(GENERIC_ROM_REGION_TAG).c_str())->base(), 0x800); | |
| 320 | memcpy(&m_eprom_rom[0], memregion(region_tag.cpy(m_eprom->tag()).cat(GENERIC_ROM_REGION_TAG).c_str())->base(), 0x800); | |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // state saving |
| r245687 | r245688 | |
|---|---|---|
| 242 | 242 | else |
| 243 | 243 | { |
| 244 | 244 | quick_data.resize(quick_length); |
| 245 | read_ = image.fread( quick_data, quick_length); | |
| 245 | read_ = image.fread( &quick_data[0], quick_length); | |
| 246 | 246 | if (read_ != quick_length) |
| 247 | 247 | { |
| 248 | 248 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 481 | 481 | |
| 482 | 482 | m_cart->rom_alloc(size, GENERIC_ROM32_WIDTH, ENDIANNESS_LITTLE); |
| 483 | 483 | |
| 484 | SRC = temp; | |
| 484 | SRC = &temp[0]; | |
| 485 | 485 | DST = m_cart->get_rom_base(); |
| 486 | m_cart->common_load_rom(temp, size, "rom"); | |
| 486 | m_cart->common_load_rom(&temp[0], size, "rom"); | |
| 487 | 487 | |
| 488 | 488 | // fix endianness |
| 489 | 489 | for (int i = 0; i < 0x200000; i += 4) |
| r245687 | r245688 | |
|---|---|---|
| 213 | 213 | else |
| 214 | 214 | { |
| 215 | 215 | dynamic_buffer quick_data(quick_length); |
| 216 | int read_ = image.fread( quick_data, quick_length); | |
| 216 | int read_ = image.fread( &quick_data[0], quick_length); | |
| 217 | 217 | if (read_ != quick_length) |
| 218 | 218 | { |
| 219 | 219 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 350 | 350 | |
| 351 | 351 | quick_length = image.length(); |
| 352 | 352 | quick_data.resize(quick_length); |
| 353 | read_ = image.fread( quick_data, quick_length); | |
| 353 | read_ = image.fread( &quick_data[0], quick_length); | |
| 354 | 354 | if (read_ != quick_length) |
| 355 | 355 | { |
| 356 | 356 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 659 | 659 | quick_length = image.length(); |
| 660 | 660 | quick_data.resize(quick_length); |
| 661 | 661 | |
| 662 | read_ = image.fread( quick_data, quick_length); | |
| 662 | read_ = image.fread( &quick_data[0], quick_length); | |
| 663 | 663 | if (read_ != quick_length) |
| 664 | 664 | { |
| 665 | 665 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 68 | 68 | UINT32 screen_update_hp16500a(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 69 | 69 | |
| 70 | 70 | required_device<cpu_device> m_maincpu; |
| 71 | d | |
| 71 | std::vector<UINT8> m_vram; | |
| 72 | 72 | |
| 73 | 73 | UINT8 m_mask, m_val; |
| 74 | 74 |
| r245687 | r245688 | |
|---|---|---|
| 340 | 340 | else |
| 341 | 341 | { |
| 342 | 342 | dynamic_buffer quick_data(quick_length); |
| 343 | read_ = image.fread( quick_data, quick_length); | |
| 343 | read_ = image.fread( &quick_data[0], quick_length); | |
| 344 | 344 | if (read_ != quick_length) |
| 345 | 345 | { |
| 346 | 346 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 168 | 168 | |
| 169 | 169 | data.resize(length); |
| 170 | 170 | |
| 171 | if (image.fread( data, length) != length) | |
| 171 | if (image.fread( &data[0], length) != length) | |
| 172 | 172 | { |
| 173 | 173 | return IMAGE_INIT_FAIL; |
| 174 | 174 | } |
| r245687 | r245688 | |
|---|---|---|
| 479 | 479 | { |
| 480 | 480 | length = image.length(); |
| 481 | 481 | temp_copy.resize(length); |
| 482 | image.fread(temp_copy, length); | |
| 482 | image.fread(&temp_copy[0], length); | |
| 483 | 483 | } |
| 484 | 484 | else |
| 485 | 485 | { |
| 486 | 486 | length = image.get_software_region_length("rom"); |
| 487 | 487 | temp_copy.resize(length); |
| 488 | memcpy(temp_copy, image.get_software_region("rom"), length); | |
| 488 | memcpy(&temp_copy[0], image.get_software_region("rom"), length); | |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /* Copy the cart image in the locations the driver expects */ |
| 492 | 492 | // Notice that, by using pick_integer, we are sure the code works on both LE and BE machines |
| 493 | 493 | ROM16 = (UINT16 *) memregion("gamecart")->base(); |
| 494 | 494 | for (i = 0; i < length; i += 2) |
| 495 | ROM16[i / 2] = pick_integer_be(temp_copy, i, 2); | |
| 495 | ROM16[i / 2] = pick_integer_be(&temp_copy[0], i, 2); | |
| 496 | 496 | |
| 497 | 497 | ROM32 = (UINT32 *) memregion("gamecart_sh2")->base(); |
| 498 | 498 | for (i = 0; i < length; i += 4) |
| 499 | ROM32[i / 4] = pick_integer_be(temp_copy, i, 4); | |
| 499 | ROM32[i / 4] = pick_integer_be(&temp_copy[0], i, 4); | |
| 500 | 500 | |
| 501 | 501 | ROM16 = (UINT16 *) memregion("maincpu")->base(); |
| 502 | 502 | for (i = 0x00; i < length; i += 2) |
| 503 | ROM16[i / 2] = pick_integer_be(temp_copy, i, 2); | |
| 503 | ROM16[i / 2] = pick_integer_be(&temp_copy[0], i, 2); | |
| 504 | 504 | |
| 505 | 505 | return IMAGE_INIT_PASS; |
| 506 | 506 | } |
| r245687 | r245688 | |
|---|---|---|
| 132 | 132 | |
| 133 | 133 | void pcd_state::machine_start() |
| 134 | 134 | { |
| 135 | m_gfxdecode->set_gfx(0, global_alloc(gfx_element(machine().device<palette_device>("palette"), pcd_charlayout, m_charram, 0, 1, 0))); | |
| 135 | m_gfxdecode->set_gfx(0, global_alloc(gfx_element(machine().device<palette_device>("palette"), pcd_charlayout, &m_charram[0], 0, 1, 0))); | |
| 136 | 136 | m_req_hack = timer_alloc(); |
| 137 | 137 | } |
| 138 | 138 |
| r245687 | r245688 | |
|---|---|---|
| 409 | 409 | b = BITSWAP8(b, 3, 2, 1, 0, 7, 6, 5, 4); |
| 410 | 410 | temp_copy[j & 0xfff] = b; |
| 411 | 411 | } |
| 412 | memcpy(ROM, temp_copy, 0x1000); | |
| 412 | memcpy(ROM, &temp_copy[0], 0x1000); | |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 |
| r245687 | r245688 | |
|---|---|---|
| 114 | 114 | else |
| 115 | 115 | { |
| 116 | 116 | quick_data.resize(quick_length); |
| 117 | read_ = image.fread( quick_data, quick_length); | |
| 117 | read_ = image.fread( &quick_data[0], quick_length); | |
| 118 | 118 | if (read_ != quick_length) |
| 119 | 119 | { |
| 120 | 120 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 394 | 394 | n_uncompressed = 0x200000; |
| 395 | 395 | p_n_uncompressed.resize( n_uncompressed ); |
| 396 | 396 | |
| 397 | if( uncompress( p_n_uncompressed, &n_uncompressed, p_n_compressed, n_compressed ) != Z_OK ) | |
| 397 | if( uncompress( &p_n_uncompressed[0], &n_uncompressed, p_n_compressed, n_compressed ) != Z_OK ) | |
| 398 | 398 | { |
| 399 | 399 | logerror( "psx_exe_load: psf uncompress failed\n" ); |
| 400 | 400 | } |
| 401 | else if( !load_psxexe( cpu, p_n_uncompressed, n_uncompressed ) ) | |
| 401 | else if( !load_psxexe( cpu, &p_n_uncompressed[0], n_uncompressed ) ) | |
| 402 | 402 | { |
| 403 | 403 | logerror( "psx_exe_load: psf load failed\n" ); |
| 404 | 404 | } |
| r245687 | r245688 | |
|---|---|---|
| 285 | 285 | else |
| 286 | 286 | { |
| 287 | 287 | quick_data.resize(quick_length); |
| 288 | read_ = image.fread( quick_data, quick_length); | |
| 288 | read_ = image.fread( &quick_data[0], quick_length); | |
| 289 | 289 | if (read_ != quick_length) |
| 290 | 290 | { |
| 291 | 291 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 571 | 571 | UINT32 img_start = 0; |
| 572 | 572 | |
| 573 | 573 | dynamic_buffer data(image.length()); |
| 574 | image.fread(data, image.length()); | |
| 574 | image.fread(&data[0], image.length()); | |
| 575 | 575 | |
| 576 | 576 | if(strncmp((const char*)&data[0], magic, 21)) |
| 577 | 577 | return IMAGE_INIT_FAIL; |
| r245687 | r245688 | |
|---|---|---|
| 431 | 431 | m_sprite_final_bitmap.allocate(1024, 1024, BITMAP_FORMAT_IND16); |
| 432 | 432 | |
| 433 | 433 | m_vram_addr_swapped.resize(0x20000); // hack for 1bpp layer at startup |
| 434 | m_gfxdecode->gfx(4)->set_source(m_vram_addr_swapped); | |
| 434 | m_gfxdecode->gfx(4)->set_source(&m_vram_addr_swapped[0]); | |
| 435 | 435 | m_gfxdecode->gfx(4)->set_xormask(0); |
| 436 | 436 | |
| 437 | 437 | m_tilemap_sizes[0][0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(supracan_state::get_supracan_tilemap0_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); |
| r245687 | r245688 | |
|---|---|---|
| 124 | 124 | UINT16 *m_rom6b; |
| 125 | 125 | |
| 126 | 126 | // AMS RAM (1 Mib) |
| 127 | d | |
| 127 | std::vector<UINT16> m_ram; | |
| 128 | 128 | |
| 129 | 129 | // Scratch pad ram (1 KiB) |
| 130 | d | |
| 130 | std::vector<UINT16> m_scratchpad; | |
| 131 | 131 | |
| 132 | 132 | // First joystick. 6 for TI-99/4A |
| 133 | 133 | int m_firstjoy; |
| r245687 | r245688 | |
|---|---|---|
| 614 | 614 | DOCK = m_dock->get_rom_base(); |
| 615 | 615 | |
| 616 | 616 | // check header |
| 617 | image.fread(header, 9); | |
| 617 | image.fread(&header[0], 9); | |
| 618 | 618 | |
| 619 | 619 | for (int i = 0; i < 8; i++) |
| 620 | 620 | if (header[i + 1] & 0x02) chunks_in_file++; |
| r245687 | r245688 | |
|---|---|---|
| 244 | 244 | if (image.software_entry() == NULL) |
| 245 | 245 | { |
| 246 | 246 | dynamic_buffer data(size); |
| 247 | image.fread(data, size); | |
| 247 | image.fread(&data[0], size); | |
| 248 | 248 | |
| 249 | 249 | if (!strncmp((const char*)&data[0], "UZEBOX", 6)) |
| 250 | memcpy(m_cart->get_rom_base(), data | |
| 250 | memcpy(m_cart->get_rom_base(), &data[0x200], size - 0x200); | |
| 251 | 251 | else |
| 252 | memcpy(m_cart->get_rom_base(), data, size); | |
| 252 | memcpy(m_cart->get_rom_base(), &data[0], size); | |
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | memcpy(m_cart->get_rom_base(), image.get_software_region("rom"), size); |
| r245687 | r245688 | |
|---|---|---|
| 404 | 404 | |
| 405 | 405 | quick_length = image.length(); |
| 406 | 406 | quick_data.resize(quick_length); |
| 407 | read_ = image.fread( quick_data, quick_length); | |
| 407 | read_ = image.fread( &quick_data[0], quick_length); | |
| 408 | 408 | if (read_ != quick_length) |
| 409 | 409 | { |
| 410 | 410 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| r245687 | r245688 | |
|---|---|---|
| 118 | 118 | required_shared_ptr<UINT16> m_p_palette; |
| 119 | 119 | required_shared_ptr<UINT16> m_p_spriteram; |
| 120 | 120 | |
| 121 | d | |
| 121 | std::vector<UINT16> m_p_cart; | |
| 122 | 122 | |
| 123 | 123 | UINT32 m_current_bank; |
| 124 | 124 | |
| r245687 | r245688 | |
| 585 | 585 | { |
| 586 | 586 | m_current_bank = bank; |
| 587 | 587 | if (m_cart_rom) |
| 588 | memcpy(m_p_cart, m_cart_rom->base() + 0x400000 * bank * 2, 0x400000 * 2); | |
| 588 | memcpy(&m_p_cart[0], m_cart_rom->base() + 0x400000 * bank * 2, 0x400000 * 2); | |
| 589 | 589 | else |
| 590 | memcpy(m_p_cart, m_bios_rom->base() + 0x400000 * bank * 2, 0x400000 * 2); | |
| 590 | memcpy(&m_p_cart[0], m_bios_rom->base() + 0x400000 * bank * 2, 0x400000 * 2); | |
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| r245687 | r245688 | |
| 1025 | 1025 | { |
| 1026 | 1026 | astring region_tag; |
| 1027 | 1027 | m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG).c_str()); |
| 1028 | memcpy(m_p_cart, m_cart_rom->base(), 0x400000 * 2); | |
| 1028 | memcpy(&m_p_cart[0], m_cart_rom->base(), 0x400000 * 2); | |
| 1029 | 1029 | } |
| 1030 | 1030 | else if (m_spg243_mode == SPG243_VII) // Vii bios is banked |
| 1031 | memcpy(m_p_cart, m_bios_rom->base(), 0x400000 * 2); | |
| 1031 | memcpy(&m_p_cart[0], m_bios_rom->base(), 0x400000 * 2); | |
| 1032 | 1032 | else |
| 1033 | memcpy(m_p_cart, memregion("maincpu")->base(), 0x400000 * 2); | |
| 1033 | memcpy(&m_p_cart[0], memregion("maincpu")->base(), 0x400000 * 2); | |
| 1034 | 1034 | |
| 1035 | 1035 | m_video_regs[0x36] = 0xffff; |
| 1036 | 1036 | m_video_regs[0x37] = 0xffff; |
| r245687 | r245688 | |
|---|---|---|
| 863 | 863 | { |
| 864 | 864 | if(m_sysport.sram_writeprotect == 0x31) |
| 865 | 865 | { |
| 866 | COMBINE_DATA(m_nvram | |
| 866 | COMBINE_DATA(&m_nvram[offset]); | |
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | 869 | |
| r245687 | r245688 | |
| 1571 | 1571 | unsigned char* rom = memregion("maincpu")->base(); |
| 1572 | 1572 | unsigned char* user2 = memregion("user2")->base(); |
| 1573 | 1573 | |
| 1574 | machine().device<nvram_device>("nvram")->set_base(m_nvram, m_nvram. | |
| 1574 | machine().device<nvram_device>("nvram")->set_base(&m_nvram[0], m_nvram.size()*sizeof(m_nvram[0])); | |
| 1575 | 1575 | |
| 1576 | 1576 | #ifdef USE_PREDEFINED_SRAM |
| 1577 | 1577 | { |
| r245687 | r245688 | |
|---|---|---|
| 85 | 85 | required_ioport m_io_key7; |
| 86 | 86 | required_ioport m_ioc_options; |
| 87 | 87 | |
| 88 | d | |
| 88 | std::vector<UINT8> m_ipc_ram; | |
| 89 | 89 | |
| 90 | 90 | bool imds2_in_ipc_rom(offs_t offset) const; |
| 91 | 91 |
| r245687 | r245688 | |
|---|---|---|
| 106 | 106 | required_ioport m_md6b; |
| 107 | 107 | required_ioport m_md6b_extra; |
| 108 | 108 | |
| 109 | dynamic_array<UINT16> m_nvram; | |
| 110 | dynamic_array<UINT16> m_tvram; | |
| 111 | dynamic_array<UINT16> m_gvram; | |
| 112 | dynamic_array<UINT16> m_spritereg; | |
| 109 | std::vector<UINT16> m_nvram; | |
| 110 | std::vector<UINT16> m_tvram; | |
| 111 | std::vector<UINT16> m_gvram; | |
| 112 | std::vector<UINT16> m_spritereg; | |
| 113 | 113 | |
| 114 | 114 | bitmap_ind16 *m_pcgbitmap; |
| 115 | 115 | bitmap_ind16 *m_gfxbitmap; |
| r245687 | r245688 | |
|---|---|---|
| 3169 | 3169 | snapshot.resize(snapshot_size); |
| 3170 | 3170 | |
| 3171 | 3171 | /* read whole file */ |
| 3172 | image.fread(snapshot, snapshot_size); | |
| 3172 | image.fread(&snapshot[0], snapshot_size); | |
| 3173 | 3173 | |
| 3174 | if (memcmp(snapshot, "MV - SNA", 8)) | |
| 3174 | if (memcmp(&snapshot[0], "MV - SNA", 8)) | |
| 3175 | 3175 | { |
| 3176 | 3176 | return IMAGE_INIT_FAIL; |
| 3177 | 3177 | } |
| 3178 | 3178 | |
| 3179 | amstrad_handle_snapshot(snapshot); | |
| 3179 | amstrad_handle_snapshot(&snapshot[0]); | |
| 3180 | 3180 | return IMAGE_INIT_PASS; |
| 3181 | 3181 | } |
| 3182 | 3182 | |
| r245687 | r245688 | |
| 3238 | 3238 | UINT8 *crt = m_cart->get_rom_base(); |
| 3239 | 3239 | dynamic_buffer temp_copy; |
| 3240 | 3240 | temp_copy.resize(size); |
| 3241 | image.fread(temp_copy, size); | |
| 3241 | image.fread(&temp_copy[0], size); | |
| 3242 | 3242 | |
| 3243 | 3243 | // RIFF chunk bits |
| 3244 | 3244 | char chunkid[4]; // chunk ID (4 character code - cb00, cb01, cb02... upto cb31 (max 512kB), other chunks are ignored) |
| r245687 | r245688 | |
| 3260 | 3260 | // read some chunks |
| 3261 | 3261 | while (bytes_to_read > 0) |
| 3262 | 3262 | { |
| 3263 | memcpy(chunkid, temp_copy | |
| 3263 | memcpy(chunkid, &temp_copy[offset], 4); | |
| 3264 | 3264 | bytes_to_read -= 4; |
| 3265 | 3265 | offset += 4; |
| 3266 | 3266 | |
| 3267 | memcpy(chunklen, temp_copy | |
| 3267 | memcpy(chunklen, &temp_copy[offset], 4); | |
| 3268 | 3268 | bytes_to_read -= 4; |
| 3269 | 3269 | offset += 4; |
| 3270 | 3270 | |
| r245687 | r245688 | |
| 3285 | 3285 | if (chunksize > 0x4000) |
| 3286 | 3286 | chunksize = 0x4000; |
| 3287 | 3287 | |
| 3288 | memcpy(crt + 0x4000 * ramblock, temp_copy | |
| 3288 | memcpy(crt + 0x4000 * ramblock, &temp_copy[offset], chunksize); | |
| 3289 | 3289 | bytes_to_read -= chunksize; |
| 3290 | 3290 | offset += chunksize; |
| 3291 | 3291 | logerror("CPR: Loaded %i-byte chunk into RAM block %i\n", chunksize, ramblock); |
| r245687 | r245688 | |
|---|---|---|
| 71 | 71 | |
| 72 | 72 | data.resize(snapshot_size); |
| 73 | 73 | |
| 74 | bytesread = image.fread( data, snapshot_size); | |
| 74 | bytesread = image.fread( &data[0], snapshot_size); | |
| 75 | 75 | if (bytesread != snapshot_size) |
| 76 | 76 | goto error; |
| 77 | 77 |
| r245687 | r245688 | |
|---|---|---|
| 47 | 47 | UINT32 size = MIN(image.length(), RAMDISK_SIZE); |
| 48 | 48 | |
| 49 | 49 | dynamic_buffer buffer(size); |
| 50 | image.fread(buffer, size); | |
| 50 | image.fread(&buffer[0], size); | |
| 51 | 51 | for (int byte = 0; byte < size; byte++) |
| 52 | 52 | dest.write_byte(0x400000 + byte, buffer[byte]); |
| 53 | 53 |
| r245687 | r245688 | |
|---|---|---|
| 41 | 41 | return IMAGE_INIT_FAIL; |
| 42 | 42 | |
| 43 | 43 | dynamic_buffer data(size); |
| 44 | image.fread( data, size); | |
| 44 | image.fread( &data[0], size); | |
| 45 | 45 | |
| 46 | 46 | header = (struct kcc_header *) &data[0]; |
| 47 | 47 | addr = (header->load_address_l & 0x0ff) | ((header->load_address_h & 0x0ff)<<8); |
| r245687 | r245688 | |
|---|---|---|
| 303 | 303 | { |
| 304 | 304 | dynamic_buffer lviv_snapshot_data(LVIV_SNAPSHOT_SIZE); |
| 305 | 305 | |
| 306 | image.fread( lviv_snapshot_data, LVIV_SNAPSHOT_SIZE); | |
| 306 | image.fread( &lviv_snapshot_data[0], LVIV_SNAPSHOT_SIZE); | |
| 307 | 307 | |
| 308 | if(lviv_verify_snapshot(lviv_snapshot_data, snapshot_size) == IMAGE_VERIFY_FAIL) | |
| 308 | if(lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size) == IMAGE_VERIFY_FAIL) | |
| 309 | 309 | { |
| 310 | 310 | return IMAGE_INIT_FAIL; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | lviv_setup_snapshot (lviv_snapshot_data); | |
| 313 | lviv_setup_snapshot (&lviv_snapshot_data[0]); | |
| 314 | 314 | |
| 315 | 315 | dump_registers(); |
| 316 | 316 |
| r245687 | r245688 | |
|---|---|---|
| 1691 | 1691 | address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1692 | 1692 | |
| 1693 | 1693 | m_backupram.resize(0x2000); |
| 1694 | subdevice<nvram_device>("backupram")->set_base(m_backupram, 0x2000); | |
| 1694 | subdevice<nvram_device>("backupram")->set_base(&m_backupram[0], 0x2000); | |
| 1695 | 1695 | |
| 1696 | 1696 | segacd_4meg_prgbank = 0; |
| 1697 | 1697 |
| r245687 | r245688 | |
|---|---|---|
| 56 | 56 | required_shared_ptr<UINT16> m_font_bits; |
| 57 | 57 | |
| 58 | 58 | // can't use a memshare because it's 8-bit RAM in a 16-bit address space |
| 59 | d | |
| 59 | std::vector<UINT8> m_backupram; | |
| 60 | 60 | |
| 61 | 61 | UINT8 m_font_color; |
| 62 | 62 |
| r245687 | r245688 | |
|---|---|---|
| 836 | 836 | { |
| 837 | 837 | int snapshot_size = 8263; /* magic size */ |
| 838 | 838 | dynamic_buffer snapshot_buff(snapshot_size, 0); |
| 839 | d | |
| 839 | std::vector<char> buff(quickload_size + 1); | |
| 840 | 840 | int rc; |
| 841 | 841 | |
| 842 | image.fread( | |
| 842 | image.fread(&buff[0], quickload_size); | |
| 843 | 843 | |
| 844 | 844 | buff[quickload_size] = '\0'; |
| 845 | 845 | |
| 846 | 846 | if (buff[0] == ':') |
| 847 | rc = parse_intel_hex(snapshot_buff, buff); | |
| 847 | rc = parse_intel_hex(&snapshot_buff[0], &buff[0]); | |
| 848 | 848 | else |
| 849 | rc = parse_zillion_hex(snapshot_buff, buff); | |
| 849 | rc = parse_zillion_hex(&snapshot_buff[0], &buff[0]); | |
| 850 | 850 | if (rc == IMAGE_INIT_PASS) |
| 851 | microtan_snapshot_copy(snapshot_buff, snapshot_size); | |
| 851 | microtan_snapshot_copy(&snapshot_buff[0], snapshot_size); | |
| 852 | 852 | return rc; |
| 853 | 853 | } |
| r245687 | r245688 | |
|---|---|---|
| 58 | 58 | |
| 59 | 59 | m_sram.resize(0x800); |
| 60 | 60 | |
| 61 | m_nvram->set_base( | |
| 61 | m_nvram->set_base(&m_sram[0], 0x000); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| r245687 | r245688 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | case 0x09: // Data |
| 83 | if (m_address < m_sram. | |
| 83 | if (m_address < m_sram.size()) | |
| 84 | 84 | { |
| 85 | 85 | return m_sram[m_address]; |
| 86 | 86 | } |
| r245687 | r245688 | |
| 153 | 153 | break; |
| 154 | 154 | |
| 155 | 155 | case 0x09: // Data |
| 156 | if (m_address < m_sram. | |
| 156 | if (m_address < m_sram.size()) | |
| 157 | 157 | { |
| 158 | 158 | m_sram[m_address] = data; |
| 159 | 159 | } |
| r245687 | r245688 | |
|---|---|---|
| 303 | 303 | { |
| 304 | 304 | dynamic_buffer snapshot_data(snapshot_size); |
| 305 | 305 | |
| 306 | if (image.fread(snapshot_data, snapshot_size) != snapshot_size) | |
| 306 | if (image.fread(&snapshot_data[0], snapshot_size) != snapshot_size) | |
| 307 | 307 | { |
| 308 | 308 | return IMAGE_INIT_FAIL; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | if (strncmp((char *) | |
| 311 | if (strncmp((char *)&snapshot_data[0], "PS01", 4)) | |
| 312 | 312 | { |
| 313 | 313 | return IMAGE_INIT_FAIL; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | primo_setup_pss(snapshot_data, snapshot_size); | |
| 316 | primo_setup_pss(&snapshot_data[0], snapshot_size); | |
| 317 | 317 | |
| 318 | 318 | return IMAGE_INIT_PASS; |
| 319 | 319 | } |
| r245687 | r245688 | |
| 345 | 345 | { |
| 346 | 346 | dynamic_buffer quickload_data(quickload_size); |
| 347 | 347 | |
| 348 | if (image.fread(quickload_data, quickload_size) != quickload_size) | |
| 348 | if (image.fread(&quickload_data[0], quickload_size) != quickload_size) | |
| 349 | 349 | { |
| 350 | 350 | return IMAGE_INIT_FAIL; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | primo_setup_pp(quickload_data, quickload_size); | |
| 353 | primo_setup_pp(&quickload_data[0], quickload_size); | |
| 354 | 354 | |
| 355 | 355 | return IMAGE_INIT_PASS; |
| 356 | 356 | } |
| r245687 | r245688 | |
|---|---|---|
| 114 | 114 | { |
| 115 | 115 | dynamic_buffer snapshot_data(snapshot_size); |
| 116 | 116 | |
| 117 | image.fread(snapshot_data, snapshot_size); | |
| 117 | image.fread(&snapshot_data[0], snapshot_size); | |
| 118 | 118 | |
| 119 | 119 | if (!core_stricmp(file_type, "sna")) |
| 120 | 120 | { |
| r245687 | r245688 | |
| 123 | 123 | logerror("Invalid .SNA file size.\n"); |
| 124 | 124 | goto error; |
| 125 | 125 | } |
| 126 | spectrum_setup_sna(machine(), snapshot_data, snapshot_size); | |
| 126 | spectrum_setup_sna(machine(), &snapshot_data[0], snapshot_size); | |
| 127 | 127 | } |
| 128 | 128 | else if (!core_stricmp(file_type, "sp")) |
| 129 | 129 | { |
| r245687 | r245688 | |
| 135 | 135 | goto error; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | spectrum_setup_sp(machine(), snapshot_data, snapshot_size); | |
| 138 | spectrum_setup_sp(machine(), &snapshot_data[0], snapshot_size); | |
| 139 | 139 | } |
| 140 | 140 | else if (!core_stricmp(file_type, "ach")) |
| 141 | 141 | { |
| r245687 | r245688 | |
| 144 | 144 | logerror("Invalid .ACH file size.\n"); |
| 145 | 145 | goto error; |
| 146 | 146 | } |
| 147 | spectrum_setup_ach(machine(), snapshot_data, snapshot_size); | |
| 147 | spectrum_setup_ach(machine(), &snapshot_data[0], snapshot_size); | |
| 148 | 148 | } |
| 149 | 149 | else if (!core_stricmp(file_type, "prg")) |
| 150 | 150 | { |
| r245687 | r245688 | |
| 153 | 153 | logerror("Invalid .PRG file size.\n"); |
| 154 | 154 | goto error; |
| 155 | 155 | } |
| 156 | spectrum_setup_prg(machine(), snapshot_data, snapshot_size); | |
| 156 | spectrum_setup_prg(machine(), &snapshot_data[0], snapshot_size); | |
| 157 | 157 | } |
| 158 | 158 | else if (!core_stricmp(file_type, "plusd")) |
| 159 | 159 | { |
| r245687 | r245688 | |
| 162 | 162 | logerror("Invalid .PLUSD file size.\n"); |
| 163 | 163 | goto error; |
| 164 | 164 | } |
| 165 | spectrum_setup_plusd(machine(), snapshot_data, snapshot_size); | |
| 165 | spectrum_setup_plusd(machine(), &snapshot_data[0], snapshot_size); | |
| 166 | 166 | } |
| 167 | 167 | else if (!core_stricmp(file_type, "sem")) |
| 168 | 168 | { |
| r245687 | r245688 | |
| 176 | 176 | goto error; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | spectrum_setup_sem(machine(), snapshot_data, snapshot_size); | |
| 179 | spectrum_setup_sem(machine(), &snapshot_data[0], snapshot_size); | |
| 180 | 180 | } |
| 181 | 181 | else if (!core_stricmp(file_type, "sit")) |
| 182 | 182 | { |
| r245687 | r245688 | |
| 185 | 185 | logerror("Invalid .SIT file size.\n"); |
| 186 | 186 | goto error; |
| 187 | 187 | } |
| 188 | spectrum_setup_sit(machine(), snapshot_data, snapshot_size); | |
| 188 | spectrum_setup_sit(machine(), &snapshot_data[0], snapshot_size); | |
| 189 | 189 | } |
| 190 | 190 | else if (!core_stricmp(file_type, "zx")) |
| 191 | 191 | { |
| r245687 | r245688 | |
| 194 | 194 | logerror("Invalid .ZX file size.\n"); |
| 195 | 195 | goto error; |
| 196 | 196 | } |
| 197 | spectrum_setup_zx(machine(), snapshot_data, snapshot_size); | |
| 197 | spectrum_setup_zx(machine(), &snapshot_data[0], snapshot_size); | |
| 198 | 198 | } |
| 199 | 199 | else if (!core_stricmp(file_type, "snp")) |
| 200 | 200 | { |
| r245687 | r245688 | |
| 203 | 203 | logerror("Invalid .SNP file size.\n"); |
| 204 | 204 | goto error; |
| 205 | 205 | } |
| 206 | spectrum_setup_snp(machine(), snapshot_data, snapshot_size); | |
| 206 | spectrum_setup_snp(machine(), &snapshot_data[0], snapshot_size); | |
| 207 | 207 | } |
| 208 | 208 | else if (!core_stricmp(file_type, "snx")) |
| 209 | 209 | { |
| r245687 | r245688 | |
| 213 | 213 | logerror("Invalid .SNX file size.\n"); |
| 214 | 214 | goto error; |
| 215 | 215 | } |
| 216 | spectrum_setup_snx(machine(), snapshot_data, snapshot_size); | |
| 216 | spectrum_setup_snx(machine(), &snapshot_data[0], snapshot_size); | |
| 217 | 217 | } |
| 218 | 218 | else if (!core_stricmp(file_type, "frz")) |
| 219 | 219 | { |
| r245687 | r245688 | |
| 222 | 222 | logerror("Invalid .FRZ file size.\n"); |
| 223 | 223 | goto error; |
| 224 | 224 | } |
| 225 | spectrum_setup_frz(machine(), snapshot_data, snapshot_size); | |
| 225 | spectrum_setup_frz(machine(), &snapshot_data[0], snapshot_size); | |
| 226 | 226 | } |
| 227 | 227 | else |
| 228 | 228 | { |
| 229 | spectrum_setup_z80(machine(), snapshot_data, snapshot_size); | |
| 229 | spectrum_setup_z80(machine(), &snapshot_data[0], snapshot_size); | |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | return IMAGE_INIT_PASS; |
| r245687 | r245688 | |
| 2447 | 2447 | { |
| 2448 | 2448 | dynamic_buffer quickload_data(quickload_size); |
| 2449 | 2449 | |
| 2450 | image.fread(quickload_data, quickload_size); | |
| 2450 | image.fread(&quickload_data[0], quickload_size); | |
| 2451 | 2451 | |
| 2452 | 2452 | if (!core_stricmp(file_type, "scr")) |
| 2453 | 2453 | { |
| r245687 | r245688 | |
| 2456 | 2456 | logerror("Invalid .SCR file size.\n"); |
| 2457 | 2457 | goto error; |
| 2458 | 2458 | } |
| 2459 | spectrum_setup_scr(machine(), quickload_data, quickload_size); | |
| 2459 | spectrum_setup_scr(machine(), &quickload_data[0], quickload_size); | |
| 2460 | 2460 | } |
| 2461 | 2461 | else if (!core_stricmp(file_type, "raw")) |
| 2462 | 2462 | { |
| r245687 | r245688 | |
| 2465 | 2465 | logerror("Invalid .RAW file size.\n"); |
| 2466 | 2466 | goto error; |
| 2467 | 2467 | } |
| 2468 | spectrum_setup_raw(machine(), quickload_data, quickload_size); | |
| 2468 | spectrum_setup_raw(machine(), &quickload_data[0], quickload_size); | |
| 2469 | 2469 | } |
| 2470 | 2470 | |
| 2471 | 2471 | return IMAGE_INIT_PASS; |
| r245687 | r245688 | |
|---|---|---|
| 432 | 432 | // The upper 2KB will be set to FFs and will never be written to |
| 433 | 433 | m_svi806_ram.resize(0x1000); |
| 434 | 434 | save_item(NAME(m_svi806_ram)); |
| 435 | memset(m_svi806_ram, 0x00, 0x800); | |
| 436 | memset(m_svi806_ram + 0x800, 0xff, 0x800); | |
| 435 | memset(&m_svi806_ram[0], 0x00, 0x800); | |
| 436 | memset(&m_svi806_ram[0x800], 0xff, 0x800); | |
| 437 | 437 | |
| 438 | 438 | m_svi806_gfx = memregion("gfx1")->base(); |
| 439 | 439 | |
| r245687 | r245688 | |
| 649 | 649 | if (m_svi806_present) |
| 650 | 650 | { |
| 651 | 651 | if (m_svi806_ram_enabled) |
| 652 | m_bank4->set_base(m_svi806_ram); | |
| 652 | m_bank4->set_base(&m_svi806_ram[0]); | |
| 653 | 653 | else |
| 654 | 654 | m_bank4->set_base(m_bank_high2_ptr + 0x3000); |
| 655 | 655 | } |
| r245687 | r245688 | |
|---|---|---|
| 1179 | 1179 | |
| 1180 | 1180 | ti8x_snapshot_data.resize(snapshot_size); |
| 1181 | 1181 | |
| 1182 | image.fread( ti8x_snapshot_data, snapshot_size); | |
| 1182 | image.fread( &ti8x_snapshot_data[0], snapshot_size); | |
| 1183 | 1183 | |
| 1184 | 1184 | if (!strncmp(machine().system().name, "ti85", 4)) |
| 1185 | ti85_setup_snapshot(ti8x_snapshot_data); | |
| 1185 | ti85_setup_snapshot(&ti8x_snapshot_data[0]); | |
| 1186 | 1186 | else if (!strncmp(machine().system().name, "ti86", 4)) |
| 1187 | ti86_setup_snapshot(ti8x_snapshot_data); | |
| 1187 | ti86_setup_snapshot(&ti8x_snapshot_data[0]); | |
| 1188 | 1188 | |
| 1189 | 1189 | return IMAGE_INIT_PASS; |
| 1190 | 1190 | } |
| r245687 | r245688 | |
|---|---|---|
| 2315 | 2315 | |
| 2316 | 2316 | zip_file* zipfile; |
| 2317 | 2317 | |
| 2318 | d | |
| 2318 | std::vector<char> layout_text; | |
| 2319 | 2319 | xml_data_node *layout_xml = NULL; |
| 2320 | 2320 | xml_data_node *romset_node; |
| 2321 | 2321 | xml_data_node *configuration_node; |
| r245687 | r245688 | |
| 2344 | 2344 | layout_text.resize(header->uncompressed_length + 1); |
| 2345 | 2345 | |
| 2346 | 2346 | /* uncompress the layout text */ |
| 2347 | ziperr = zip_file_decompress(zipfile, layout_text, header->uncompressed_length); | |
| 2347 | ziperr = zip_file_decompress(zipfile, &layout_text[0], header->uncompressed_length); | |
| 2348 | 2348 | if (ziperr != ZIPERR_NONE) |
| 2349 | 2349 | { |
| 2350 | 2350 | if (ziperr == ZIPERR_UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED); |
| r245687 | r245688 | |
| 2354 | 2354 | layout_text[header->uncompressed_length] = '\0'; // Null-terminate |
| 2355 | 2355 | |
| 2356 | 2356 | /* parse the layout text */ |
| 2357 | layout_xml = xml_string_read(layout_text, NULL); | |
| 2357 | layout_xml = xml_string_read(&layout_text[0], NULL); | |
| 2358 | 2358 | if (layout_xml == NULL) throw rpk_exception(RPK_XML_ERROR); |
| 2359 | 2359 | |
| 2360 | 2360 | // Now we work within the XML tree |
| r245687 | r245688 | |
|---|---|---|
| 66 | 66 | WRITE16_MEMBER( x68k_hdc_image_device::hdc_w ) |
| 67 | 67 | { |
| 68 | 68 | unsigned int lba = 0; |
| 69 | d | |
| 69 | std::vector<char> blk; | |
| 70 | 70 | switch(offset) |
| 71 | 71 | { |
| 72 | 72 | case 0x00: // data I/O |
| r245687 | r245688 | |
| 265 | 265 | lba |= m_command[2] << 8; |
| 266 | 266 | lba |= (m_command[1] & 0x1f) << 16; |
| 267 | 267 | fseek(lba * 256,SEEK_SET); |
| 268 | blk.resize_and_clear(256*33); | |
| 268 | blk.resize(256*33); | |
| 269 | memset(&blk[0], 0, 256*33); | |
| 269 | 270 | // formats 33 256-byte blocks |
| 270 | fwrite(blk,256*33); | |
| 271 | fwrite(&blk[0],256*33); | |
| 271 | 272 | logerror("SASI: FORMAT UNIT (LBA 0x%06x)\n",lba); |
| 272 | 273 | break; |
| 273 | 274 | default: |
| r245687 | r245688 | |
|---|---|---|
| 318 | 318 | |
| 319 | 319 | if (direction) |
| 320 | 320 | { |
| 321 | err = floppy_read_sector(floppy, head, track, sector, offset, buffer, length); | |
| 321 | err = floppy_read_sector(floppy, head, track, sector, offset, &buffer[0], length); | |
| 322 | 322 | if (err) |
| 323 | 323 | goto done; |
| 324 | stream_write(f, buffer, length); | |
| 324 | stream_write(f, &buffer[0], length); | |
| 325 | 325 | } |
| 326 | 326 | else |
| 327 | 327 | { |
| 328 | stream_read(f, buffer, length); | |
| 329 | err = floppy_write_sector(floppy, head, track, sector, offset, buffer, length, 0); /* TODO: pass ddam argument from imgtool */ | |
| 328 | stream_read(f, &buffer[0], length); | |
| 329 | err = floppy_write_sector(floppy, head, track, sector, offset, &buffer[0], length, 0); /* TODO: pass ddam argument from imgtool */ | |
| 330 | 330 | if (err) |
| 331 | 331 | goto done; |
| 332 | 332 | } |
| r245687 | r245688 | |
|---|---|---|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /* alloc and zero buffer */ |
| 104 | cache.resize_and_clear(hunksize); | |
| 104 | cache.resize(hunksize); | |
| 105 | memset(&cache[0], 0, hunksize); | |
| 105 | 106 | |
| 106 | 107 | /* zero out every hunk */ |
| 107 | 108 | totalhunks = (logicalbytes + hunksize - 1) / hunksize; |
| 108 | 109 | for (hunknum = 0; hunknum < totalhunks; hunknum++) |
| 109 | 110 | { |
| 110 | rc = chd.write_units(hunknum, cache); | |
| 111 | rc = chd.write_units(hunknum, &cache[0]); | |
| 111 | 112 | if (rc) |
| 112 | 113 | { |
| 113 | 114 | err = IMGTOOLERR_WRITEERROR; |
| r245687 | r245688 | |
|---|---|---|
| 643 | 643 | |
| 644 | 644 | buffer.resize(size); |
| 645 | 645 | |
| 646 | err = imgtool_image_read_sector(img, track, head, sector, buffer, size); | |
| 646 | err = imgtool_image_read_sector(img, track, head, sector, &buffer[0], size); | |
| 647 | 647 | if (err) |
| 648 | 648 | goto done; |
| 649 | 649 | |
| r245687 | r245688 | |
| 655 | 655 | goto done; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | stream_write(stream, buffer, size); | |
| 658 | stream_write(stream, &buffer[0], size); | |
| 659 | 659 | |
| 660 | 660 | done: |
| 661 | 661 | if (stream) |
| r245687 | r245688 | |
| 695 | 695 | |
| 696 | 696 | buffer.resize(size); |
| 697 | 697 | |
| 698 | stream_read(stream, buffer, size); | |
| 698 | stream_read(stream, &buffer[0], size); | |
| 699 | 699 | |
| 700 | err = imgtool_image_write_sector(img, track, head, sector, buffer, size); | |
| 700 | err = imgtool_image_write_sector(img, track, head, sector, &buffer[0], size); | |
| 701 | 701 | if (err) |
| 702 | 702 | goto done; |
| 703 | 703 |
| r245687 | r245688 | |
|---|---|---|
| 744 | 744 | allocation_bitmap_lsns = (allocation_bitmap_bits / 8 + sector_bytes - 1) / sector_bytes; |
| 745 | 745 | format_flags = ((heads > 1) ? 0x01 : 0x00) | ((tracks > 40) ? 0x02 : 0x00); |
| 746 | 746 | |
| 747 | memset(header, 0, sector_bytes); | |
| 748 | place_integer_be(header, 0, 3, heads * tracks * sectors); | |
| 749 | place_integer_be(header, 3, 1, sectors); | |
| 750 | place_integer_be(header, 4, 2, (allocation_bitmap_bits + 7) / 8); | |
| 751 | place_integer_be(header, 6, 2, cluster_size); | |
| 752 | place_integer_be(header, 8, 3, 1 + allocation_bitmap_lsns); | |
| 753 | place_integer_be(header, 11, 2, owner_id); | |
| 754 | place_integer_be(header, 13, 1, attributes); | |
| 755 | place_integer_be(header, 14, 2, disk_id); | |
| 756 | place_integer_be(header, 16, 1, format_flags); | |
| 757 | place_integer_be(header, 17, 2, sectors); | |
| 758 | place_string(header, 31, 32, title); | |
| 759 | place_integer_be(header, 103, 2, sector_bytes / 256); | |
| 747 | memset(&header[0], 0, sector_bytes); | |
| 748 | place_integer_be(&header[0], 0, 3, heads * tracks * sectors); | |
| 749 | place_integer_be(&header[0], 3, 1, sectors); | |
| 750 | place_integer_be(&header[0], 4, 2, (allocation_bitmap_bits + 7) / 8); | |
| 751 | place_integer_be(&header[0], 6, 2, cluster_size); | |
| 752 | place_integer_be(&header[0], 8, 3, 1 + allocation_bitmap_lsns); | |
| 753 | place_integer_be(&header[0], 11, 2, owner_id); | |
| 754 | place_integer_be(&header[0], 13, 1, attributes); | |
| 755 | place_integer_be(&header[0], 14, 2, disk_id); | |
| 756 | place_integer_be(&header[0], 16, 1, format_flags); | |
| 757 | place_integer_be(&header[0], 17, 2, sectors); | |
| 758 | place_string(&header[0], 31, 32, title); | |
| 759 | place_integer_be(&header[0], 103, 2, sector_bytes / 256); | |
| 760 | 760 | |
| 761 | 761 | /* path descriptor options */ |
| 762 | place_integer_be(header, 0x3f+0x00, 1, 1); /* device class */ | |
| 763 | place_integer_be(header, 0x3f+0x01, 1, 1); /* drive number */ | |
| 764 | place_integer_be(header, 0x3f+0x03, 1, 0x20); /* device type */ | |
| 765 | place_integer_be(header, 0x3f+0x04, 1, 1); /* density capability */ | |
| 766 | place_integer_be(header, 0x3f+0x05, 2, tracks); /* number of tracks */ | |
| 767 | place_integer_be(header, 0x3f+0x07, 1, heads); /* number of sides */ | |
| 768 | place_integer_be(header, 0x3f+0x09, 2, sectors); /* sectors per track */ | |
| 769 | place_integer_be(header, 0x3f+0x0b, 2, sectors); /* sectors on track zero */ | |
| 770 | place_integer_be(header, 0x3f+0x0d, 1, 3); /* sector interleave factor */ | |
| 771 | place_integer_be(header, 0x3f+0x0e, 1, 8); /* default sectors per allocation */ | |
| 762 | place_integer_be(&header[0], 0x3f+0x00, 1, 1); /* device class */ | |
| 763 | place_integer_be(&header[0], 0x3f+0x01, 1, 1); /* drive number */ | |
| 764 | place_integer_be(&header[0], 0x3f+0x03, 1, 0x20); /* device type */ | |
| 765 | place_integer_be(&header[0], 0x3f+0x04, 1, 1); /* density capability */ | |
| 766 | place_integer_be(&header[0], 0x3f+0x05, 2, tracks); /* number of tracks */ | |
| 767 | place_integer_be(&header[0], 0x3f+0x07, 1, heads); /* number of sides */ | |
| 768 | place_integer_be(&header[0], 0x3f+0x09, 2, sectors); /* sectors per track */ | |
| 769 | place_integer_be(&header[0], 0x3f+0x0b, 2, sectors); /* sectors on track zero */ | |
| 770 | place_integer_be(&header[0], 0x3f+0x0d, 1, 3); /* sector interleave factor */ | |
| 771 | place_integer_be(&header[0], 0x3f+0x0e, 1, 8); /* default sectors per allocation */ | |
| 772 | 772 | |
| 773 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id, 0, header, sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 773 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id, 0, &header[0], sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 774 | 774 | if (err) |
| 775 | 775 | goto done; |
| 776 | 776 | |
| r245687 | r245688 | |
| 778 | 778 | |
| 779 | 779 | for (i = 0; i < allocation_bitmap_lsns; i++) |
| 780 | 780 | { |
| 781 | memset(header, 0x00, sector_bytes); | |
| 781 | memset(&header[0], 0x00, sector_bytes); | |
| 782 | 782 | |
| 783 | 783 | if (total_allocated_sectors > (8 * 256)) |
| 784 | 784 | { |
| 785 | memset(header, 0xff, sector_bytes); | |
| 785 | memset(&header[0], 0xff, sector_bytes); | |
| 786 | 786 | total_allocated_sectors -= (8 * 256); |
| 787 | 787 | } |
| 788 | 788 | else if (total_allocated_sectors > 1 ) |
| r245687 | r245688 | |
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 1 + i, 0, header, sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 803 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 1 + i, 0, &header[0], sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 804 | 804 | if (err) |
| 805 | 805 | goto done; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | memset(header, 0, sector_bytes); | |
| 808 | memset(&header[0], 0, sector_bytes); | |
| 809 | 809 | header[0x00] = 0xBF; |
| 810 | 810 | header[0x01] = 0x00; |
| 811 | 811 | header[0x02] = 0x00; |
| r245687 | r245688 | |
| 822 | 822 | header[0x0D] = (UINT8) (ltime->tm_year % 100); |
| 823 | 823 | header[0x0E] = (UINT8) ltime->tm_mon; |
| 824 | 824 | header[0x0F] = (UINT8) ltime->tm_mday; |
| 825 | place_integer_be(header, 0x10, 3, 1 + allocation_bitmap_lsns + 1); | |
| 826 | place_integer_be(header, 0x13, 2, 8); | |
| 825 | place_integer_be(&header[0], 0x10, 3, 1 + allocation_bitmap_lsns + 1); | |
| 826 | place_integer_be(&header[0], 0x13, 2, 8); | |
| 827 | 827 | |
| 828 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 1 + allocation_bitmap_lsns, 0, header, sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 828 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 1 + allocation_bitmap_lsns, 0, &header[0], sector_bytes, 0); /* TODO: pass ddam argument from imgtool */ | |
| 829 | 829 | if (err) |
| 830 | 830 | goto done; |
| 831 | 831 | |
| 832 | memset(header, 0, sector_bytes); | |
| 832 | memset(&header[0], 0, sector_bytes); | |
| 833 | 833 | header[0x00] = 0x2E; |
| 834 | 834 | header[0x01] = 0xAE; |
| 835 | 835 | header[0x1F] = 1 + allocation_bitmap_lsns; |
| 836 | 836 | header[0x20] = 0xAE; |
| 837 | 837 | header[0x3F] = 1 + allocation_bitmap_lsns; |
| 838 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 2 + allocation_bitmap_lsns, 0, header, sector_bytes, 0); /* TOOD: pass ddam argument from imgtool */ | |
| 838 | err = (imgtoolerr_t)floppy_write_sector(imgtool_floppy(img), 0, 0, first_sector_id + 2 + allocation_bitmap_lsns, 0, &header[0], sector_bytes, 0); /* TOOD: pass ddam argument from imgtool */ | |
| 839 | 839 | if (err) |
| 840 | 840 | goto done; |
| 841 | 841 | |
| r245687 | r245688 | |
| 1055 | 1055 | { |
| 1056 | 1056 | write_size = (size_t) MIN(sz, (UINT64) disk_info->sector_size); |
| 1057 | 1057 | |
| 1058 | stream_read(sourcef, buf, write_size); | |
| 1058 | stream_read(sourcef, &buf[0], write_size); | |
| 1059 | 1059 | |
| 1060 | 1060 | while(count == 0) |
| 1061 | 1061 | { |
| r245687 | r245688 | |
| 1064 | 1064 | count = file_info.sector_map[i].count; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | err = os9_write_lsn(image, lsn, 0, buf, write_size); | |
| 1067 | err = os9_write_lsn(image, lsn, 0, &buf[0], write_size); | |
| 1068 | 1068 | if (err) |
| 1069 | 1069 | goto done; |
| 1070 | 1070 |
| r245687 | r245688 | |
|---|---|---|
| 288 | 288 | dynamic_buffer buffer(size); |
| 289 | 289 | |
| 290 | 290 | stream_seek(instream, 6, SEEK_SET); |
| 291 | stream_read(instream, buffer, size); | |
| 291 | stream_read(instream, &buffer[0], size); | |
| 292 | 292 | |
| 293 | stream_write(outstream, buffer, size); | |
| 293 | stream_write(outstream, &buffer[0], size); | |
| 294 | 294 | |
| 295 | 295 | // end of pack |
| 296 | 296 | stream_fill(outstream, 0xff, 2); |
| r245687 | r245688 | |
|---|---|---|
| 21 | 21 | void advision_state::video_start() |
| 22 | 22 | { |
| 23 | 23 | m_video_hpos = 0; |
| 24 | m_display.resize_and_clear(8 * 8 * 256); | |
| 24 | m_display.resize(8 * 8 * 256); | |
| 25 | memset(&m_display[0], 0, 8*8*256); | |
| 25 | 26 | save_item(NAME(m_display)); |
| 26 | 27 | save_item(NAME(m_video_hpos)); |
| 27 | 28 | } |
| r245687 | r245688 | |
|---|---|---|
| 90 | 90 | |
| 91 | 91 | if (m_vdp_type == VDP_TYPE_WSC) |
| 92 | 92 | { |
| 93 | m_vram.resize_and_clear(0x10000); | |
| 94 | m_palette_vram = m_vram + 0xfe00; | |
| 93 | m_vram.resize(0x10000); | |
| 94 | memset(&m_vram[0], 0, 0x10000); | |
| 95 | m_palette_vram = &m_vram[0xfe00]; | |
| 95 | 96 | } |
| 96 | 97 | else |
| 97 | 98 | { |
| 98 | m_vram.resize_and_clear(0x4000); | |
| 99 | m_palette_vram = m_vram; | |
| 99 | m_vram.resize(0x4000); | |
| 100 | memset(&m_vram[0], 0, 0x4000); | |
| 101 | m_palette_vram = &m_vram[0]; | |
| 100 | 102 | } |
| 101 | 103 | |
| 102 | 104 | common_save(); |
| r245687 | r245688 | |
|---|---|---|
| 98 | 98 | |
| 99 | 99 | // update RAM in each plane |
| 100 | 100 | if(planes & 1) |
| 101 | memcpy(m_tvram | |
| 101 | memcpy(&m_tvram[dest_ram],&m_tvram[src_ram],512); | |
| 102 | 102 | if(planes & 2) |
| 103 | memcpy(m_tvram | |
| 103 | memcpy(&m_tvram[dest_ram+0x10000],&m_tvram[src_ram+0x10000],512); | |
| 104 | 104 | if(planes & 4) |
| 105 | memcpy(m_tvram | |
| 105 | memcpy(&m_tvram[dest_ram+0x20000],&m_tvram[src_ram+0x20000],512); | |
| 106 | 106 | if(planes & 8) |
| 107 | memcpy(m_tvram | |
| 107 | memcpy(&m_tvram[dest_ram+0x30000],&m_tvram[src_ram+0x30000],512); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_operation_end) |
| r245687 | r245688 | |
| 440 | 440 | m_crtc.operation = data; |
| 441 | 441 | if(data & 0x02) // high-speed graphic screen clear |
| 442 | 442 | { |
| 443 | memset(m_gvram,0,0x40000); | |
| 443 | memset(&m_gvram[0],0,0x40000); | |
| 444 | 444 | timer_set(attotime::from_msec(10), TIMER_X68K_CRTC_OPERATION_END, 0x02); // time taken to do operation is a complete guess. |
| 445 | 445 | } |
| 446 | 446 | break; |
| r245687 | r245688 | |
| 501 | 501 | if(m_crtc.reg[20] & 0x0800) // G-VRAM set to buffer |
| 502 | 502 | { |
| 503 | 503 | if(offset < 0x40000) |
| 504 | COMBINE_DATA(m_gvram | |
| 504 | COMBINE_DATA(&m_gvram[offset]); | |
| 505 | 505 | } |
| 506 | 506 | else |
| 507 | 507 | { |
| r245687 | r245688 | |
| 509 | 509 | { |
| 510 | 510 | case 0x0300: |
| 511 | 511 | if(offset < 0x40000) |
| 512 | COMBINE_DATA(m_gvram | |
| 512 | COMBINE_DATA(&m_gvram[offset]); | |
| 513 | 513 | break; |
| 514 | 514 | case 0x0100: |
| 515 | 515 | if(offset < 0x40000) |
| r245687 | r245688 | |
| 565 | 565 | { |
| 566 | 566 | if(wr & (1 << plane)) |
| 567 | 567 | { |
| 568 | COMBINE_DATA(m_tvram | |
| 568 | COMBINE_DATA(&m_tvram[offset+0x10000*plane]); | |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | else |
| 573 | 573 | { |
| 574 | COMBINE_DATA(m_tvram | |
| 574 | COMBINE_DATA(&m_tvram[offset]); | |
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | |
| r245687 | r245688 | |
| 623 | 623 | |
| 624 | 624 | WRITE16_MEMBER(x68k_state::x68k_spritereg_w ) |
| 625 | 625 | { |
| 626 | COMBINE_DATA(m_spritereg | |
| 626 | COMBINE_DATA(&m_spritereg[offset]); | |
| 627 | 627 | switch(offset) |
| 628 | 628 | { |
| 629 | 629 | case 0x400: |
| r245687 | r245688 | |
|---|---|---|
| 165 | 165 | |
| 166 | 166 | osd_common_t::~osd_common_t() |
| 167 | 167 | { |
| 168 | for(int i= 0; i < m_video_names. | |
| 168 | for(unsigned int i= 0; i < m_video_names.size(); ++i) | |
| 169 | 169 | osd_free(const_cast<char*>(m_video_names[i])); |
| 170 | 170 | //m_video_options,reset(); |
| 171 | 171 | osd_output::pop(this); |
| r245687 | r245688 | |
| 210 | 210 | const char *names[20]; |
| 211 | 211 | int num; |
| 212 | 212 | m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); |
| 213 | d | |
| 213 | std::vector<const char *> dnames; | |
| 214 | 214 | for (int i = 0; i < num; i++) |
| 215 | dnames. | |
| 215 | dnames.push_back(names[i]); | |
| 216 | 216 | update_option(OSD_FONT_PROVIDER, dnames); |
| 217 | 217 | |
| 218 | 218 | m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); |
| 219 | dnames. | |
| 219 | dnames.clear(); | |
| 220 | 220 | for (int i = 0; i < num; i++) |
| 221 | dnames. | |
| 221 | dnames.push_back(names[i]); | |
| 222 | 222 | update_option(OSD_SOUND_PROVIDER, dnames); |
| 223 | 223 | |
| 224 | 224 | #if 0 |
| 225 | 225 | // Register midi options and update options |
| 226 | 226 | m_mod_man.get_module_names(OSD_MIDI_PROVIDER, 20, &num, names); |
| 227 | dnames. | |
| 227 | dnames.clear(); | |
| 228 | 228 | for (int i = 0; i < num; i++) |
| 229 | dnames. | |
| 229 | dnames.push_back(names[i]); | |
| 230 | 230 | update_option(OSD_MIDI_PROVIDER, dnames); |
| 231 | 231 | #endif |
| 232 | 232 | |
| 233 | 233 | // Register debugger options and update options |
| 234 | 234 | m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); |
| 235 | dnames. | |
| 235 | dnames.clear(); | |
| 236 | 236 | for (int i = 0; i < num; i++) |
| 237 | dnames. | |
| 237 | dnames.push_back(names[i]); | |
| 238 | 238 | update_option(OSD_DEBUG_PROVIDER, dnames); |
| 239 | 239 | |
| 240 | 240 | // Register video options and update options |
| r245687 | r245688 | |
| 243 | 243 | update_option(OSDOPTION_VIDEO, m_video_names); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | void osd_common_t::update_option(const char * key, d | |
| 246 | void osd_common_t::update_option(const char * key, std::vector<const char *> &values) | |
| 247 | 247 | { |
| 248 | 248 | astring current_value(m_options.description(key)); |
| 249 | 249 | astring new_option_value(""); |
| 250 | for (int index = 0; index < values. | |
| 250 | for (unsigned int index = 0; index < values.size(); index++) | |
| 251 | 251 | { |
| 252 | 252 | astring t(values[index]); |
| 253 | 253 | if (new_option_value.len() > 0) |
| 254 | 254 | { |
| 255 | if( index != (values. | |
| 255 | if( index != (values.size()-1)) | |
| 256 | 256 | new_option_value.cat(", "); |
| 257 | 257 | else |
| 258 | 258 | new_option_value.cat(" or "); |
| r245687 | r245688 | |
| 633 | 633 | void osd_common_t::video_options_add(const char *name, void *type) |
| 634 | 634 | { |
| 635 | 635 | //m_video_options.add(name, type, false); |
| 636 | m_video_names. | |
| 636 | m_video_names.push_back(core_strdup(name)); | |
| 637 | 637 | } |
| r245687 | r245688 | |
|---|---|---|
| 236 | 236 | osd_module_manager m_mod_man; |
| 237 | 237 | font_module *m_font_module; |
| 238 | 238 | |
| 239 | void update_option(const char * key, d | |
| 239 | void update_option(const char * key, std::vector<const char *> &values); | |
| 240 | 240 | // FIXME: should be elsewhere |
| 241 | 241 | osd_module *select_module_options(const core_options &opts, const astring &opt_name) |
| 242 | 242 | { |
| r245687 | r245688 | |
| 263 | 263 | midi_module* m_midi; |
| 264 | 264 | private: |
| 265 | 265 | //tagmap_t<osd_video_type> m_video_options; |
| 266 | d | |
| 266 | std::vector<const char *> m_video_names; | |
| 267 | 267 | }; |
| 268 | 268 | |
| 269 | 269 |
| r245687 | r245688 | |
|---|---|---|
| 192 | 192 | |
| 193 | 193 | UINT8 m_stack_depth; |
| 194 | 194 | UINT8 m_entry_stride; |
| 195 | d | |
| 195 | std::vector<FPTR> m_buffer; | |
| 196 | 196 | FPTR * m_buffer_ptr; |
| 197 | 197 | FPTR * m_buffer_end; |
| 198 | 198 | }; |
| r245687 | r245688 | |
|---|---|---|
| 431 | 431 | { |
| 432 | 432 | // read the sound samples |
| 433 | 433 | m_audio[chnum].resize(samples); |
| 434 | samplesptr[chnum] = m_audio[chnum]; | |
| 435 | avi_error avierr = avi_read_sound_samples(&m_file, chnum, first_sample, samples, m_audio[chnum]); | |
| 434 | samplesptr[chnum] = &m_audio[chnum][0]; | |
| 435 | avi_error avierr = avi_read_sound_samples(&m_file, chnum, first_sample, samples, &m_audio[chnum][0]); | |
| 436 | 436 | if (avierr != AVIERR_NONE) |
| 437 | 437 | report_error(1, "Error reading audio samples %d-%d from channel %d: %s", first_sample, samples, chnum, avi_error_string(avierr)); |
| 438 | 438 | } |
| r245687 | r245688 | |
| 455 | 455 | avhuff_error averr = avhuff_encoder::assemble_data(m_rawdata, subbitmap, channels, samples, samplesptr); |
| 456 | 456 | if (averr != AVHERR_NONE) |
| 457 | 457 | report_error(1, "Error assembling data for frame %d", framenum); |
| 458 | if (m_rawdata.count() < m_info.bytes_per_frame) | |
| 459 | m_rawdata.resize_keep_and_clear_new(m_info.bytes_per_frame); | |
| 458 | if (m_rawdata.size() < m_info.bytes_per_frame) | |
| 459 | { | |
| 460 | int old_size = m_rawdata.size(); | |
| 461 | m_rawdata.resize(m_info.bytes_per_frame); | |
| 462 | memset(&m_rawdata[old_size], 0, m_info.bytes_per_frame - old_size); | |
| 463 | } | |
| 460 | 464 | |
| 461 | 465 | // copy to the destination |
| 462 | 466 | UINT64 start_offset = UINT64(framenum) * UINT64(m_info.bytes_per_frame); |
| r245687 | r245688 | |
| 480 | 484 | bitmap_yuy16 m_bitmap; |
| 481 | 485 | UINT32 m_start_frame; |
| 482 | 486 | UINT32 m_frame_count; |
| 483 | d | |
| 487 | std::vector<INT16> m_audio[8]; | |
| 484 | 488 | dynamic_buffer m_ldframedata; |
| 485 | 489 | dynamic_buffer m_rawdata; |
| 486 | 490 | }; |
| r245687 | r245688 | |
| 1371 | 1375 | |
| 1372 | 1376 | // print out metadata |
| 1373 | 1377 | dynamic_buffer buffer; |
| 1374 | d | |
| 1378 | std::vector<metadata_index_info> info; | |
| 1375 | 1379 | for (int index = 0; ; index++) |
| 1376 | 1380 | { |
| 1377 | 1381 | // get the indexed metadata item; stop when we hit an error |
| r245687 | r245688 | |
| 1383 | 1387 | |
| 1384 | 1388 | // determine our index |
| 1385 | 1389 | UINT32 metaindex = ~0; |
| 1386 | for (int cur = 0; cur < info. | |
| 1390 | for (unsigned int cur = 0; cur < info.size(); cur++) | |
| 1387 | 1391 | if (info[cur].tag == metatag) |
| 1388 | 1392 | { |
| 1389 | 1393 | metaindex = ++info[cur].index; |
| r245687 | r245688 | |
| 1394 | 1398 | if (metaindex == ~0) |
| 1395 | 1399 | { |
| 1396 | 1400 | metadata_index_info curinfo = { metatag, 0 }; |
| 1397 | info. | |
| 1401 | info.push_back(curinfo); | |
| 1398 | 1402 | metaindex = 0; |
| 1399 | 1403 | } |
| 1400 | 1404 | |
| 1401 | 1405 | // print either a string representation or a hex representation of the tag |
| 1402 | 1406 | if (isprint((metatag >> 24) & 0xff) && isprint((metatag >> 16) & 0xff) && isprint((metatag >> 8) & 0xff) && isprint(metatag & 0xff)) |
| 1403 | printf("Metadata: Tag='%c%c%c%c' Index=%d Length=%d bytes\n", (metatag >> 24) & 0xff, (metatag >> 16) & 0xff, (metatag >> 8) & 0xff, metatag & 0xff, metaindex, buffer. | |
| 1407 | printf("Metadata: Tag='%c%c%c%c' Index=%d Length=%d bytes\n", (metatag >> 24) & 0xff, (metatag >> 16) & 0xff, (metatag >> 8) & 0xff, metatag & 0xff, metaindex, int(buffer.size())); | |
| 1404 | 1408 | else |
| 1405 | printf("Metadata: Tag=%08x Index=%d Length=%d bytes\n", metatag, metaindex, buffer. | |
| 1409 | printf("Metadata: Tag=%08x Index=%d Length=%d bytes\n", metatag, metaindex, int(buffer.size())); | |
| 1406 | 1410 | printf(" "); |
| 1407 | 1411 | |
| 1408 | 1412 | // print up to 60 characters of metadata |
| 1409 | UINT32 count = MIN(60, buffer. | |
| 1413 | UINT32 count = MIN(60, buffer.size()); | |
| 1410 | 1414 | for (int chnum = 0; chnum < count; chnum++) |
| 1411 | 1415 | printf("%c", isprint(UINT8(buffer[chnum])) ? buffer[chnum] : '.'); |
| 1412 | 1416 | printf("\n"); |
| r245687 | r245688 | |
| 1501 | 1505 | progress(false, "Verifying, %.1f%% complete... \r", 100.0 * double(offset) / double(input_chd.logical_bytes())); |
| 1502 | 1506 | |
| 1503 | 1507 | // determine how much to read |
| 1504 | UINT32 bytes_to_read = MIN((UINT32)buffer.count(), input_chd.logical_bytes() - offset); | |
| 1505 | chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); | |
| 1508 | UINT32 bytes_to_read = MIN((UINT32)buffer.size(), input_chd.logical_bytes() - offset); | |
| 1509 | chd_error err = input_chd.read_bytes(offset, &buffer[0], bytes_to_read); | |
| 1506 | 1510 | if (err != CHDERR_NONE) |
| 1507 | 1511 | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->c_str(), chd_file::error_string(err)); |
| 1508 | 1512 | |
| 1509 | 1513 | // add to the checksum |
| 1510 | rawsha1.append(buffer, bytes_to_read); | |
| 1514 | rawsha1.append(&buffer[0], bytes_to_read); | |
| 1511 | 1515 | offset += bytes_to_read; |
| 1512 | 1516 | } |
| 1513 | 1517 | sha1_t computed_sha1 = rawsha1.finish(); |
| r245687 | r245688 | |
| 1743 | 1747 | report_error(1, "Error reading ident file (%s)", ident_str->c_str()); |
| 1744 | 1748 | |
| 1745 | 1749 | // must be at least 14 bytes; extract CHS data from there |
| 1746 | if (identdata. | |
| 1750 | if (identdata.size() < 14) | |
| 1747 | 1751 | report_error(1, "Ident file '%s' is invalid (too short)", ident_str->c_str()); |
| 1748 | 1752 | cylinders = (identdata[3] << 8) | identdata[2]; |
| 1749 | 1753 | heads = (identdata[7] << 8) | identdata[6]; |
| r245687 | r245688 | |
| 1817 | 1821 | report_error(1, "Error adding hard disk metadata: %s", chd_file::error_string(err)); |
| 1818 | 1822 | |
| 1819 | 1823 | // write the ident if present |
| 1820 | if (identdata. | |
| 1824 | if (!identdata.empty()) | |
| 1821 | 1825 | { |
| 1822 | 1826 | err = chd->write_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, identdata); |
| 1823 | 1827 | if (err != CHDERR_NONE) |
| r245687 | r245688 | |
| 2245 | 2249 | progress(false, "Extracting, %.1f%% complete... \r", 100.0 * double(offset - input_start) / double(input_end - input_start)); |
| 2246 | 2250 | |
| 2247 | 2251 | // determine how much to read |
| 2248 | UINT32 bytes_to_read = MIN((UINT32)buffer.count(), input_end - offset); | |
| 2249 | chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); | |
| 2252 | UINT32 bytes_to_read = MIN((UINT32)buffer.size(), input_end - offset); | |
| 2253 | chd_error err = input_chd.read_bytes(offset, &buffer[0], bytes_to_read); | |
| 2250 | 2254 | if (err != CHDERR_NONE) |
| 2251 | 2255 | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->c_str(), chd_file::error_string(err)); |
| 2252 | 2256 | |
| 2253 | 2257 | // write to the output |
| 2254 | UINT32 count = core_fwrite(output_file, buffer, bytes_to_read); | |
| 2258 | UINT32 count = core_fwrite(output_file, &buffer[0], bytes_to_read); | |
| 2255 | 2259 | if (count != bytes_to_read) |
| 2256 | 2260 | report_error(1, "Error writing to file; check disk space (%s)", output_file_str->c_str()); |
| 2257 | 2261 | |
| r245687 | r245688 | |
| 2444 | 2448 | } |
| 2445 | 2449 | |
| 2446 | 2450 | // write it out if we need to |
| 2447 | if (bufferoffs == buffer. | |
| 2451 | if (bufferoffs == buffer.size() || frame == actualframes - 1) | |
| 2448 | 2452 | { |
| 2449 | 2453 | core_fseek(output_bin_file, outputoffs, SEEK_SET); |
| 2450 | UINT32 byteswritten = core_fwrite(output_bin_file, buffer, bufferoffs); | |
| 2454 | UINT32 byteswritten = core_fwrite(output_bin_file, &buffer[0], bufferoffs); | |
| 2451 | 2455 | if (byteswritten != bufferoffs) |
| 2452 | 2456 | report_error(1, "Error writing frame %d to file (%s): %s\n", frame, output_file_str->c_str(), chd_file::error_string(CHDERR_WRITE_ERROR)); |
| 2453 | 2457 | outputoffs += bufferoffs; |
| r245687 | r245688 | |
| 2567 | 2571 | |
| 2568 | 2572 | // create the codec configuration |
| 2569 | 2573 | avhuff_decompress_config avconfig; |
| 2570 | d | |
| 2574 | std::vector<INT16> audio_data[16]; | |
| 2571 | 2575 | UINT32 actsamples; |
| 2572 | 2576 | avconfig.maxsamples = max_samples_per_frame; |
| 2573 | 2577 | avconfig.actsamples = &actsamples; |
| 2574 | 2578 | for (int chnum = 0; chnum < ARRAY_LENGTH(audio_data); chnum++) |
| 2575 | 2579 | { |
| 2576 | 2580 | audio_data[chnum].resize(max_samples_per_frame); |
| 2577 | avconfig.audio[chnum] = audio_data[chnum]; | |
| 2581 | avconfig.audio[chnum] = &audio_data[chnum][0]; | |
| 2578 | 2582 | } |
| 2579 | 2583 | |
| 2580 | 2584 | // iterate over frames |
| r245687 | r245688 | |
| 2693 | 2697 | if (text_str != NULL) |
| 2694 | 2698 | printf("Text: %s\n", text.c_str()); |
| 2695 | 2699 | else |
| 2696 | printf("Data: %s (%d bytes)\n", file_str->c_str(), file. | |
| 2700 | printf("Data: %s (%d bytes)\n", file_str->c_str(), int(file.size())); | |
| 2697 | 2701 | |
| 2698 | 2702 | // write the metadata |
| 2699 | 2703 | chd_error err; |
| 2700 | 2704 | if (text_str != NULL) |
| 2701 | 2705 | err = input_chd.write_metadata(tag, index, text, flags); |
| 2702 | 2706 | else |
| 2703 | err = input_chd.write_metadata(tag, index, file, flags); | |
| 2707 | err = input_chd.write_metadata(tag, index, &file[0], flags); | |
| 2704 | 2708 | if (err != CHDERR_NONE) |
| 2705 | 2709 | report_error(1, "Error adding metadata: %s", chd_file::error_string(err)); |
| 2706 | 2710 | else |
| r245687 | r245688 | |
| 2798 | 2802 | report_error(1, "Unable to open file (%s)", output_file_str->c_str()); |
| 2799 | 2803 | |
| 2800 | 2804 | // output the metadata |
| 2801 | UINT32 count = core_fwrite(output_file, buffer, buffer.count()); | |
| 2802 | if (count != buffer.count()) | |
| 2805 | UINT32 count = core_fwrite(output_file, &buffer[0], buffer.size()); | |
| 2806 | if (count != buffer.size()) | |
| 2803 | 2807 | report_error(1, "Error writing file (%s)", output_file_str->c_str()); |
| 2804 | 2808 | core_fclose(output_file); |
| 2805 | 2809 | |
| 2806 | 2810 | // provide some feedback |
| 2807 | 2811 | astring tempstr; |
| 2808 | printf("File (%s) written, %s bytes\n", output_file_str->c_str(), big_int_string(tempstr, buffer. | |
| 2812 | printf("File (%s) written, %s bytes\n", output_file_str->c_str(), big_int_string(tempstr, buffer.size())); | |
| 2809 | 2813 | } |
| 2810 | 2814 | |
| 2811 | 2815 | // flush to stdout |
| 2812 | 2816 | else |
| 2813 | 2817 | { |
| 2814 | fwrite(buffer, 1, buffer. | |
| 2818 | fwrite(&buffer[0], 1, buffer.size(), stdout); | |
| 2815 | 2819 | fflush(stdout); |
| 2816 | 2820 | } |
| 2817 | 2821 | } |
| r245687 | r245688 | |
|---|---|---|
| 55 | 55 | int channels; |
| 56 | 56 | int interlaced; |
| 57 | 57 | bitmap_yuy16 bitmap; |
| 58 | dynamic_array<INT16> lsound; | |
| 59 | dynamic_array<INT16> rsound; | |
| 58 | std::vector<INT16> lsound; | |
| 59 | std::vector<INT16> rsound; | |
| 60 | 60 | UINT32 samples; |
| 61 | 61 | }; |
| 62 | 62 | |
| r245687 | r245688 | |
| 239 | 239 | // configure the codec |
| 240 | 240 | avhuff_decompress_config avconfig; |
| 241 | 241 | avconfig.video.wrap(info.bitmap, info.bitmap.cliprect()); |
| 242 | avconfig.maxsamples = info.lsound. | |
| 242 | avconfig.maxsamples = info.lsound.size(); | |
| 243 | 243 | avconfig.actsamples = &info.samples; |
| 244 | avconfig.audio[0] = info.lsound + soundoffs; | |
| 245 | avconfig.audio[1] = info.rsound + soundoffs; | |
| 244 | avconfig.audio[0] = &info.lsound[soundoffs]; | |
| 245 | avconfig.audio[1] = &info.rsound[soundoffs]; | |
| 246 | 246 | |
| 247 | 247 | // configure the decompressor for this field |
| 248 | 248 | file.codec_configure(CHD_CODEC_AVHUFF, AVHUFF_CODEC_DECOMPRESS_CONFIG, &avconfig); |
| r245687 | r245688 | |
| 267 | 267 | static bool find_edge_near_field(chd_file &srcfile, UINT32 fieldnum, movie_info &info, bool report_best_field, INT32 &delta) |
| 268 | 268 | { |
| 269 | 269 | // clear the sound buffers |
| 270 | memset(info.lsound, 0, info.lsound.count() * 2); | |
| 271 | memset(info.rsound, 0, info.rsound.count() * 2); | |
| 270 | memset(&info.lsound[0], 0, info.lsound.size() * 2); | |
| 271 | memset(&info.rsound[0], 0, info.rsound.size() * 2); | |
| 272 | 272 | |
| 273 | 273 | // read 1 second around the target area |
| 274 | 274 | int fields_to_read = info.iframerate / 1000000; |
| r245687 | r245688 | |
| 473 | 473 | |
| 474 | 474 | // assemble the final frame |
| 475 | 475 | dynamic_buffer buffer; |
| 476 | INT16 *sampledata[2] = { m_info.lsound, m_info.rsound }; | |
| 476 | INT16 *sampledata[2] = { &m_info.lsound[0], &m_info.rsound[0] }; | |
| 477 | 477 | avhuff_encoder::assemble_data(buffer, m_info.bitmap, m_info.channels, m_info.samples, sampledata); |
| 478 | memcpy(dest, buffer, MIN(buffer.count(), datasize)); | |
| 479 | if (buffer.count() < datasize) | |
| 480 | memset(&dest[buffer.count()], 0, datasize - buffer.count()); | |
| 478 | memcpy(dest, &buffer[0], MIN(buffer.size(), datasize)); | |
| 479 | if (buffer.size() < datasize) | |
| 480 | memset(&dest[buffer.size()], 0, datasize - buffer.size()); | |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 |
| r245687 | r245688 | |
|---|---|---|
| 762 | 762 | bitmap_yuy16 bitmap(info.width, info.height); |
| 763 | 763 | |
| 764 | 764 | // allocate sound buffers |
| 765 | dynamic_array<INT16> lsound(info.samplerate); | |
| 766 | dynamic_array<INT16> rsound(info.samplerate); | |
| 765 | std::vector<INT16> lsound(info.samplerate); | |
| 766 | std::vector<INT16> rsound(info.samplerate); | |
| 767 | 767 | |
| 768 | 768 | // loop over frames |
| 769 | 769 | int frame = 0; |
| 770 | 770 | int samples = 0; |
| 771 | while (isavi ? read_avi(file, frame, bitmap, lsound, rsound, samples) : read_chd(file, frame, bitmap, lsound, rsound, samples)) | |
| 771 | while (isavi ? read_avi(file, frame, bitmap, &lsound[0], &rsound[0], samples) : read_chd(file, frame, bitmap, &lsound[0], &rsound[0], samples)) | |
| 772 | 772 | { |
| 773 | 773 | verify_video(video, frame, bitmap); |
| 774 | verify_audio(audio, lsound, rsound, samples); | |
| 774 | verify_audio(audio, &lsound[0], &rsound[0], samples); | |
| 775 | 775 | frame++; |
| 776 | 776 | } |
| 777 | 777 |
| https://github.com/mamedev/mame/commit/278cf84e5503d1829e837e21dc8c238bc8cab577 |
| Previous | 199869 Revisions | Next |