From 296c4a6ed666b69ee3b7cb7a08272472ac8fefd5 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Sun, 15 Jan 2017 05:04:55 +0000 Subject: [PATCH] new driver: d_dreamwl.. semicom games: dream world, cute fighter, baryon future assault, rolling crush, gaia. addition of this driver means we finally beat the mighty fbalpha-68020 bug!! --- makefile.burn_rules | 2 +- src/burn/drv/pst90s/d_dreamwld.cpp | 1195 ++++++++++++++++++++++++++++ 2 files changed, 1196 insertions(+), 1 deletion(-) create mode 100644 src/burn/drv/pst90s/d_dreamwld.cpp diff --git a/makefile.burn_rules b/makefile.burn_rules index 1fbef3cee..821cc7a64 100644 --- a/makefile.burn_rules +++ b/makefile.burn_rules @@ -60,7 +60,7 @@ drvobj = d_dodonpachi.o d_donpachi.o d_esprade.o d_feversos.o d_gaia.o d_guwang d_wrally.o d_wwfsstar.o d_xain.o d_xxmissio.o d_zodiack.o \ \ d_1945kiii.o d_aerofgt.o d_airbustr.o d_aquarium.o d_blmbycar.o d_bloodbro.o d_crospang.o d_crshrace.o d_dcon.o d_ddragon3.o \ - d_deniam.o d_diverboy.o d_dooyong.o d_drgnmst.o d_drtomy.o d_egghunt.o d_esd16.o d_f1gp.o d_funybubl.o d_fuukifg3.o d_gaelco.o \ + d_deniam.o d_diverboy.o d_dooyong.o d_dreamwld.o d_drgnmst.o d_drtomy.o d_egghunt.o d_esd16.o d_f1gp.o d_funybubl.o d_fuukifg3.o d_gaelco.o \ d_gaelco2.o d_gaiden.o d_galpanic.o d_galspnbl.o d_gotcha.o d_gumbo.o d_hyperpac.o d_jchan.o d_kaneko16.o d_lordgun.o d_macrossp.o \ d_mcatadv.o d_metro.o d_midas.o d_mugsmash.o d_mwarr.o d_news.o d_nmg5.o d_nmk16.o d_ohmygod.o d_onetwo.o d_pass.o d_pirates.o d_playmark.o \ d_powerins.o d_pushman.o d_raiden.o d_raiden2.o d_sandscrp.o d_seta.o d_seta2.o d_shadfrce.o d_silkroad.o d_silvmil.o d_speedspn.o d_ssv.o \ diff --git a/src/burn/drv/pst90s/d_dreamwld.cpp b/src/burn/drv/pst90s/d_dreamwld.cpp new file mode 100644 index 000000000..1ce744b29 --- /dev/null +++ b/src/burn/drv/pst90s/d_dreamwld.cpp @@ -0,0 +1,1195 @@ +// FB Alpha Dream World / Baryon driver module +// Based on MAME driver by David Haywood + +#include "tiles_generic.h" +#include "m68000_intf.h" +#include "msm6295.h" + +static UINT8 *AllMem; +static UINT8 *MemEnd; +static UINT8 *AllRam; +static UINT8 *RamEnd; +static UINT8 *Drv68KROM; +static UINT8 *DrvGfxROM0; +static UINT8 *DrvGfxROM1; +static UINT8 *DrvGfxROM2; +static UINT8 *DrvSndROM0; +static UINT8 *DrvSndROM1; +static UINT8 *DrvProtData; +static UINT8 *DrvSprRAM; +static UINT8 *DrvSprBuf; +static UINT8 *DrvSprBuf2; +static UINT8 *DrvPalRAM; +static UINT8 *Drv68KRAM; +static UINT8 *DrvBg1RAM; +static UINT8 *DrvBg2RAM; +static UINT8 *DrvBgScrollRAM; + +static UINT32 *DrvPalette; +static UINT8 DrvRecalc; + +static UINT8 DrvReset; +static UINT8 DrvJoy1[16]; +static UINT8 DrvJoy2[16]; +static UINT16 DrvInputs[2]; +static UINT8 DrvDips[4]; + +static UINT8 *DrvOkiBank; +static INT32 protindex = 0; +static INT32 protsize; + +static struct BurnInputInfo CommonInputList[] = { + {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" }, + {"P1 Start", BIT_DIGITAL, DrvJoy1 + 24, "p1 start" }, + {"P1 Up", BIT_DIGITAL, DrvJoy1 + 31, "p1 up" }, + {"P1 Down", BIT_DIGITAL, DrvJoy1 + 30, "p1 down" }, + {"P1 Left", BIT_DIGITAL, DrvJoy1 + 28, "p1 left" }, + {"P1 Right", BIT_DIGITAL, DrvJoy1 + 29, "p1 right" }, + {"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 27, "p1 fire 1" }, + {"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 26, "p1 fire 2" }, + {"P1 Button 3", BIT_DIGITAL, DrvJoy1 + 25, "p1 fire 3" }, + + {"P2 Coin", BIT_DIGITAL, DrvJoy1 + 1, "p2 coin" }, + {"P2 Start", BIT_DIGITAL, DrvJoy1 + 16, "p2 start" }, + {"P2 Up", BIT_DIGITAL, DrvJoy1 + 23, "p2 up" }, + {"P2 Down", BIT_DIGITAL, DrvJoy1 + 22, "p2 down" }, + {"P2 Left", BIT_DIGITAL, DrvJoy1 + 20, "p2 left" }, + {"P2 Right", BIT_DIGITAL, DrvJoy1 + 21, "p2 right" }, + {"P2 Button 1", BIT_DIGITAL, DrvJoy1 + 19, "p2 fire 1" }, + {"P2 Button 2", BIT_DIGITAL, DrvJoy1 + 18, "p2 fire 2" }, + {"P2 Button 3", BIT_DIGITAL, DrvJoy1 + 17, "p2 fire 3" }, + + {"Reset", BIT_DIGITAL, &DrvReset, "reset" }, + {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" }, + {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip" }, +}; + +STDINPUTINFO(Common) + +static struct BurnDIPInfo DreamwldDIPList[]= +{ + {0x13, 0xff, 0xff, 0xff, NULL }, + {0x14, 0xff, 0xff, 0xff, NULL }, + + {0 , 0xfe, 0 , 4, "Lives" }, + {0x13, 0x01, 0x03, 0x02, "2" }, + {0x13, 0x01, 0x03, 0x03, "3" }, + {0x13, 0x01, 0x03, 0x01, "4" }, + {0x13, 0x01, 0x03, 0x00, "5" }, + + {0 , 0xfe, 0 , 2, "Free Play" }, + {0x13, 0x01, 0x80, 0x80, "Off" }, + {0x13, 0x01, 0x80, 0x00, "On" }, + + {0 , 0xfe, 0 , 8, "Coinage" }, + {0x14, 0x01, 0x0e, 0x00, "5 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x02, "4 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x04, "3 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x06, "2 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0e, "1 Coin 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0a, "2 Coins 3 Credits" }, + {0x14, 0x01, 0x0e, 0x0c, "1 Coin 2 Credits" }, + {0x14, 0x01, 0x0e, 0x08, "1 Coin 3 Credits" }, + + {0 , 0xfe, 0 , 2, "Service Mode" }, + {0x14, 0x01, 0x80, 0x80, "Off" }, + {0x14, 0x01, 0x80, 0x00, "On" }, +}; + +STDDIPINFO(Dreamwld) + +static struct BurnDIPInfo BaryonDIPList[]= +{ + {0x13, 0xff, 0xff, 0xff, NULL }, + {0x14, 0xff, 0xff, 0xfe, NULL }, + + {0 , 0xfe, 0 , 4, "Lives" }, + {0x13, 0x01, 0x03, 0x02, "2" }, + {0x13, 0x01, 0x03, 0x03, "3" }, + {0x13, 0x01, 0x03, 0x01, "4" }, + {0x13, 0x01, 0x03, 0x00, "5" }, + + {0 , 0xfe, 0 , 2, "Bomb Stock" }, + {0x13, 0x01, 0x04, 0x04, "2" }, + {0x13, 0x01, 0x04, 0x00, "3" }, + + {0 , 0xfe, 0 , 2, "Free Play" }, + {0x13, 0x01, 0x80, 0x80, "Off" }, + {0x13, 0x01, 0x80, 0x00, "On" }, + + {0 , 0xfe, 0 , 2, "Demo Sounds" }, + {0x14, 0x01, 0x01, 0x01, "Off" }, + {0x14, 0x01, 0x01, 0x00, "On" }, + + {0 , 0xfe, 0 , 8, "Coinage" }, + {0x14, 0x01, 0x0e, 0x00, "5 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x02, "4 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x04, "3 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x06, "2 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0e, "1 Coin 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0a, "2 Coins 3 Credits" }, + {0x14, 0x01, 0x0e, 0x0c, "1 Coin 2 Credits" }, + {0x14, 0x01, 0x0e, 0x08, "1 Coin 3 Credits" }, + + {0 , 0xfe, 0 , 2, "Service Mode" }, + {0x14, 0x01, 0x80, 0x80, "Off" }, + {0x14, 0x01, 0x80, 0x00, "On" }, +}; + +STDDIPINFO(Baryon) + +static struct BurnDIPInfo RolcrushDIPList[]= +{ + {0x13, 0xff, 0xff, 0xff, NULL }, + {0x14, 0xff, 0xff, 0xfe, NULL }, + + {0 , 0xfe, 0 , 2, "Free Play" }, + {0x13, 0x01, 0x80, 0x80, "Off" }, + {0x13, 0x01, 0x80, 0x00, "On" }, + + {0 , 0xfe, 0 , 2, "Demo Sounds" }, + {0x14, 0x01, 0x01, 0x01, "Off" }, + {0x14, 0x01, 0x01, 0x00, "On" }, + + {0 , 0xfe, 0 , 8, "Coinage" }, + {0x14, 0x01, 0x0e, 0x00, "5 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x02, "4 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x04, "3 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x06, "2 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0e, "1 Coin 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0a, "2 Coins 3 Credits" }, + {0x14, 0x01, 0x0e, 0x0c, "1 Coin 2 Credits" }, + {0x14, 0x01, 0x0e, 0x08, "1 Coin 3 Credits" }, + + {0 , 0xfe, 0 , 8, "Difficulty" }, + {0x14, 0x01, 0x70, 0x20, "Level 1" }, + {0x14, 0x01, 0x70, 0x10, "Level 2" }, + {0x14, 0x01, 0x70, 0x00, "Level 3" }, + {0x14, 0x01, 0x70, 0x70, "Level 4" }, + {0x14, 0x01, 0x70, 0x60, "Level 5" }, + {0x14, 0x01, 0x70, 0x50, "Level 6" }, + {0x14, 0x01, 0x70, 0x40, "Level 7" }, + {0x14, 0x01, 0x70, 0x30, "Level 8" }, + + {0 , 0xfe, 0 , 2, "Service Mode" }, + {0x14, 0x01, 0x80, 0x80, "Off" }, + {0x14, 0x01, 0x80, 0x00, "On" }, +}; + +STDDIPINFO(Rolcrush) + +static struct BurnDIPInfo CutefghtDIPList[]= +{ + {0x13, 0xff, 0xff, 0xff, NULL }, + {0x14, 0xff, 0xff, 0xfe, NULL }, + + {0 , 0xfe, 0 , 4, "Ticket Payout" }, + {0x13, 0x01, 0x60, 0x00, "No" }, + {0x13, 0x01, 0x60, 0x20, "Little" }, + {0x13, 0x01, 0x60, 0x60, "Normal" }, + {0x13, 0x01, 0x60, 0x40, "Much" }, + + {0 , 0xfe, 0 , 2, "Free Play" }, + {0x13, 0x01, 0x80, 0x80, "Off" }, + {0x13, 0x01, 0x80, 0x00, "On" }, + + {0 , 0xfe, 0 , 2, "Demo Sounds" }, + {0x14, 0x01, 0x01, 0x01, "Off" }, + {0x14, 0x01, 0x01, 0x00, "On" }, + + {0 , 0xfe, 0 , 8, "Coinage" }, + {0x14, 0x01, 0x0e, 0x00, "5 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x02, "4 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x04, "3 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x06, "2 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0e, "1 Coin 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0a, "2 Coins 3 Credits" }, + {0x14, 0x01, 0x0e, 0x0c, "1 Coin 2 Credits" }, + {0x14, 0x01, 0x0e, 0x08, "1 Coin 3 Credits" }, + + {0 , 0xfe, 0 , 8, "Difficulty" }, + {0x14, 0x01, 0x70, 0x20, "Level 1" }, + {0x14, 0x01, 0x70, 0x10, "Level 2" }, + {0x14, 0x01, 0x70, 0x00, "Level 3" }, + {0x14, 0x01, 0x70, 0x70, "Level 4" }, + {0x14, 0x01, 0x70, 0x60, "Level 5" }, + {0x14, 0x01, 0x70, 0x50, "Level 6" }, + {0x14, 0x01, 0x70, 0x40, "Level 7" }, + {0x14, 0x01, 0x70, 0x30, "Level 8" }, + + {0 , 0xfe, 0 , 2, "Service Mode" }, + {0x14, 0x01, 0x80, 0x80, "Off" }, + {0x14, 0x01, 0x80, 0x00, "On" }, +}; + +STDDIPINFO(Cutefght) + +static struct BurnDIPInfo GaialastDIPList[]= +{ + {0x13, 0xff, 0xff, 0xf1, NULL }, + {0x14, 0xff, 0xff, 0xfe, NULL }, + + {0 , 0xfe, 0 , 4, "Lives" }, + {0x13, 0x01, 0x03, 0x02, "1" }, + {0x13, 0x01, 0x03, 0x03, "2" }, + {0x13, 0x01, 0x03, 0x01, "3" }, + {0x13, 0x01, 0x03, 0x00, "4" }, + + {0 , 0xfe, 0 , 2, "Bomb Stock" }, + {0x13, 0x01, 0x04, 0x04, "2" }, + {0x13, 0x01, 0x04, 0x00, "3" }, + + {0 , 0xfe, 0 , 2, "Lock Vertical Scroll" }, + {0x13, 0x01, 0x08, 0x08, "Off" }, + {0x13, 0x01, 0x08, 0x00, "On" }, + + {0 , 0xfe, 0 , 2, "Free Play" }, + {0x13, 0x01, 0x80, 0x80, "Off" }, + {0x13, 0x01, 0x80, 0x00, "On" }, + + {0 , 0xfe, 0 , 2, "Demo Sounds" }, + {0x14, 0x01, 0x01, 0x01, "Off" }, + {0x14, 0x01, 0x01, 0x00, "On" }, + + {0 , 0xfe, 0 , 8, "Coinage" }, + {0x14, 0x01, 0x0e, 0x00, "5 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x02, "4 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x04, "3 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x06, "2 Coins 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0e, "1 Coin 1 Credits" }, + {0x14, 0x01, 0x0e, 0x0a, "2 Coins 3 Credits" }, + {0x14, 0x01, 0x0e, 0x0c, "1 Coin 2 Credits" }, + {0x14, 0x01, 0x0e, 0x08, "1 Coin 3 Credits" }, + + {0 , 0xfe, 0 , 8, "Difficulty" }, + {0x14, 0x01, 0x70, 0x20, "Level 1" }, + {0x14, 0x01, 0x70, 0x10, "Level 2" }, + {0x14, 0x01, 0x70, 0x00, "Level 3" }, + {0x14, 0x01, 0x70, 0x70, "Level 4" }, + {0x14, 0x01, 0x70, 0x60, "Level 5" }, + {0x14, 0x01, 0x70, 0x50, "Level 6" }, + {0x14, 0x01, 0x70, 0x40, "Level 7" }, + {0x14, 0x01, 0x70, 0x30, "Level 8" }, + + {0 , 0xfe, 0 , 2, "Service Mode" }, + {0x14, 0x01, 0x80, 0x80, "Off" }, + {0x14, 0x01, 0x80, 0x00, "On" }, +}; + +STDDIPINFO(Gaialast) + +inline static void palette_write(INT32 offset) +{ + offset &= 0x1ffe; + + UINT16 data = *((UINT16 *)(DrvPalRAM + offset)); + UINT8 r, g, b; + offset >>= 1; + + r = (data >> 10) & 0x1f; + g = (data >> 5) & 0x1f; + b = (data >> 0) & 0x1f; + + r = (r << 3) | (r >> 2); + g = (g << 3) | (g >> 2); + b = (b << 3) | (b >> 2); + + DrvPalette[offset] = BurnHighCol(r, g, b, 0); +} + +static void dreamwld_oki_setbank(INT32 chip, INT32 bank) +{ + DrvOkiBank[chip] = bank & 3; + UINT8 *sound = (chip) ? DrvSndROM1 : DrvSndROM0; + + MSM6295SetBank(chip, sound + 0x30000 + (0x10000 * DrvOkiBank[chip]), 0x30000, 0x3ffff); +} + +static UINT8 __fastcall dreamwld_read_byte(UINT32 address) +{ + switch (address) + { + case 0xc00000: + case 0xc00001: + case 0xc00002: + case 0xc00003: + return DrvInputs[(~address >> 1) & 1] >> ((~address & 1) << 3); + + case 0xc00004: + case 0xc00005: + case 0xc00006: + case 0xc00007: + return DrvDips[address & 1]; + + case 0xc00018: + return MSM6295ReadStatus(0); + + case 0xc00028: + return MSM6295ReadStatus(1); + + case 0xc00030: + protindex++; + return DrvProtData[(protindex-1) % protsize]; + } + + bprintf (PRINT_NORMAL, _T("%5.5x, rb\n"), address); + + return 0; +} + +static UINT16 __fastcall dreamwld_read_word(UINT32 address) +{ + switch (address) + { + case 0xc00000: + case 0xc00002: + return DrvInputs[(~address >> 1) & 1]; + + case 0xc00004: + case 0xc00006: + return (DrvDips[1] << 8) | DrvDips[0]; + } + + bprintf (PRINT_NORMAL, _T("%5.5x, rw\n"), address); + + return 0; +} + +static void __fastcall dreamwld_write_byte(UINT32 address, UINT8 data) +{ + + if ((address&0xffff00) == 0xb300) return; // garbage writes (cute fighter) + + switch (address) + { + case 0xc0000c: + case 0xc0000f: + dreamwld_oki_setbank(0, data & 3); + return; + + case 0xc00018: + MSM6295Command(0, data); + return; + + case 0x000001: + case 0x000002: + case 0xc0fffc: + case 0xc0fffd: + case 0xc0fffe: + case 0xc0ffff: + case 0xc00010: + case 0xc00020: + // NOP + return; + + case 0xc0002c: + case 0xc0002f: + dreamwld_oki_setbank(1, data & 3); + return; + + case 0xc00028: + MSM6295Command(1, data); + return; + } + + bprintf (PRINT_NORMAL, _T("%5.5x, %2.2x wb\n"), address, data); +} + +static tilemap_callback( background ) +{ + UINT16 *ram = (UINT16*)DrvBg1RAM; + UINT32 *lnscroll = (UINT32 *)DrvBgScrollRAM; + INT32 bank = (lnscroll[0x104] >> 9) & 0x2000; + + TILE_SET_INFO(0, (ram[offs] & 0x1fff) + bank, (ram[offs] >> 13) + 0x80, 0); +} + +static tilemap_callback( foreground ) +{ + UINT16 *ram = (UINT16*)DrvBg2RAM; + UINT32 *lnscroll = (UINT32 *)DrvBgScrollRAM; + INT32 bank = (lnscroll[0x105] >> 9) & 0x2000; + + TILE_SET_INFO(0, (ram[offs] & 0x1fff) + bank, (ram[offs] >> 13) + 0xc0, 0); +} + +static INT32 DrvDoReset() +{ + DrvReset = 0; + + memset (AllRam, 0, RamEnd - AllRam); + + SekOpen(0); + SekReset(); + SekClose(); + + MSM6295Reset(0); + MSM6295Reset(1); // dreamwld + + protindex = 0; + + dreamwld_oki_setbank(0, 0); + dreamwld_oki_setbank(1, 0); // dreamwld + + return 0; +} + +static void DrvGfxDecode(UINT8 *src, INT32 len) +{ + for (INT32 i = (len - 1) * 2; i >= 0; i-=2) { + src[i + 0] = src[i/2] >> 4; + src[i + 1] = src[i/2] & 0x0f; + } +} + +static INT32 MemIndex() +{ + UINT8 *Next; Next = AllMem; + + Drv68KROM = Next; Next += 0x0200000; + + DrvProtData = Next; Next += 0x0001000; + + MSM6295ROM = Next; + DrvSndROM0 = Next; Next += 0x0080000; + DrvSndROM1 = Next; Next += 0x0080000; + + DrvGfxROM0 = Next; Next += 0x1000000; + DrvGfxROM1 = Next; Next += 0x0800000; + DrvGfxROM2 = Next; Next += 0x0040000; + + DrvPalette = (UINT32*)Next; Next += 0x02000 * sizeof(UINT32); + + AllRam = Next; + + DrvBgScrollRAM = Next; Next += 0x0002000; + DrvSprRAM = Next; Next += 0x0002000; + DrvSprBuf = Next; Next += 0x0002000; + DrvSprBuf2 = Next; Next += 0x0002000; + DrvPalRAM = Next; Next += 0x0002000; + DrvBg1RAM = Next; Next += 0x0002000; + DrvBg2RAM = Next; Next += 0x0002000; + Drv68KRAM = Next; Next += 0x0020000; + + DrvOkiBank = Next; Next += 0x0000002; + + RamEnd = Next; + + MemEnd = Next; + + return 0; +} + +static INT32 DreamwldRomLoad() +{ + if (BurnLoadRom(Drv68KROM + 0x000003, 0, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000002, 1, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000001, 2, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000000, 3, 4)) return 1; + + if (BurnLoadRom(DrvProtData, 5, 1)) return 1; + protsize = 0x6c9; + + if (BurnLoadRom(DrvSndROM0, 6, 1)) return 1; + if (BurnLoadRom(DrvSndROM1, 7, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM0, 8, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM1, 9, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM2 + 0x00000, 10, 2)) return 1; + if (BurnLoadRom(DrvGfxROM2 + 0x00001, 11, 2)) return 1; + + return 0; +} + +static INT32 BaryonRomLoad() +{ + if (BurnLoadRom(Drv68KROM + 0x000003, 0, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000001, 1, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000002, 2, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000000, 3, 4)) return 1; + + if (BurnLoadRom(DrvProtData, 5, 1)) return 1; + protsize = 0x6bd; + + if (BurnLoadRom(DrvSndROM0, 6, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM0, 7, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x200000, 8, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM1, 9, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM2 + 0x00000, 10, 2)) return 1; + if (BurnLoadRom(DrvGfxROM2 + 0x00001, 11, 2)) return 1; + + return 0; +} + +static INT32 CutefghtRomLoad() +{ + if (BurnLoadRom(Drv68KROM + 0x000003, 0, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000001, 1, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000002, 2, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000000, 3, 4)) return 1; + + if (BurnLoadRom(DrvProtData, 5, 1)) return 1; + protsize = 0x701; + + if (BurnLoadRom(DrvSndROM0, 6, 1)) return 1; + if (BurnLoadRom(DrvSndROM1, 7, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM0, 8, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x200000, 9, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x400000, 10, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x600000, 11, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM1, 12, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM2 + 0x00000, 13, 2)) return 1; + if (BurnLoadRom(DrvGfxROM2 + 0x00001, 14, 2)) return 1; + + return 0; +} + +static INT32 RolcrushRomLoad() +{ + if (BurnLoadRom(Drv68KROM + 0x000003, 0, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000001, 1, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000002, 2, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000000, 3, 4)) return 1; + + if (BurnLoadRom(DrvProtData, 5, 1)) return 1; + protsize = 0x745; + + if (BurnLoadRom(DrvSndROM0, 6, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM0, 7, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM1, 8, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM2 + 0x00000, 9, 2)) return 1; + if (BurnLoadRom(DrvGfxROM2 + 0x00001, 10, 2)) return 1; + + return 0; +} + +static INT32 GaialastRomLoad() +{ + if (BurnLoadRom(Drv68KROM + 0x000003, 0, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000001, 1, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000002, 2, 4)) return 1; + if (BurnLoadRom(Drv68KROM + 0x000000, 3, 4)) return 1; + + if (BurnLoadRom(DrvProtData, 5, 1)) return 1; + protsize = 0x6c9; + + if (BurnLoadRom(DrvSndROM0, 6, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM0, 7, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x200000, 8, 1)) return 1; + if (BurnLoadRom(DrvGfxROM0 + 0x400000, 9, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM1, 10, 1)) return 1; + + if (BurnLoadRom(DrvGfxROM2 + 0x00000, 11, 2)) return 1; + if (BurnLoadRom(DrvGfxROM2 + 0x00001, 12, 2)) return 1; + + return 0; +} + +static INT32 DrvInit(INT32 (*pInitCallback)()) +{ + BurnSetRefreshRate(57.79); + + AllMem = NULL; + MemIndex(); + INT32 nLen = MemEnd - (UINT8 *)0; + if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; + memset(AllMem, 0, nLen); + MemIndex(); + + { + if (pInitCallback) { + if (pInitCallback()) return 1; + } + + DrvGfxDecode(DrvGfxROM0, 0x800000); + DrvGfxDecode(DrvGfxROM1, 0x400000); + } + + SekInit(0, 0x68ec020); + SekOpen(0); + SekMapMemory(Drv68KROM, 0x000000, 0x1fffff, MAP_ROM); + SekMapMemory(DrvSprRAM, 0x400000, 0x401fff, MAP_RAM); + SekMapMemory(DrvPalRAM, 0x600000, 0x601fff, MAP_RAM); + SekMapMemory(DrvBg1RAM, 0x800000, 0x801fff, MAP_RAM); + SekMapMemory(DrvBg2RAM, 0x802000, 0x803fff, MAP_RAM); + SekMapMemory(DrvBgScrollRAM, 0x804000, 0x805fff, MAP_RAM); + SekMapMemory(Drv68KRAM, 0xfe0000, 0xffffff, MAP_RAM); + SekSetWriteByteHandler(0, dreamwld_write_byte); + //SekSetWriteWordHandler(0, dreamwld_write_word); + //SekSetWriteLongHandler(0, dreamwld_write_long); + SekSetReadByteHandler(0, dreamwld_read_byte); + SekSetReadWordHandler(0, dreamwld_read_word); + //SekSetReadLongHandler(0, dreamwld_read_long); + SekClose(); + + MSM6295Init(0, 1000000 / 165, 1); + MSM6295Init(1, 1000000 / 165, 1); // dreamwld + MSM6295SetRoute(0, 0.45, BURN_SND_ROUTE_BOTH); + MSM6295SetRoute(1, 0.45, BURN_SND_ROUTE_BOTH); + MSM6295SetBank(0, DrvSndROM0, 0, 0x2ffff); + MSM6295SetBank(1, DrvSndROM1, 0, 0x2ffff); + + GenericTilesInit(); + GenericTilemapInit(0, TILEMAP_SCAN_ROWS, background_map_callback, 16, 16, 64, 64); + GenericTilemapInit(1, TILEMAP_SCAN_ROWS, foreground_map_callback, 16, 16, 64, 64); + GenericTilemapSetGfx(0, DrvGfxROM1, 4, 16, 16, 0x400000, 0, 0xff); + GenericTilemapSetTransparent(1, 0); + + DrvDoReset(); + + return 0; +} + +static INT32 DrvExit() +{ + SekExit(); + + MSM6295Exit(0); + MSM6295Exit(1); + + GenericTilesExit(); + + BurnFree (AllMem); + + return 0; +} + +static void draw_layer(INT32 layer) +{ + UINT32 *scroll = (UINT32 *)DrvBgScrollRAM; + UINT16 *lnscroll = (UINT16 *)DrvBgScrollRAM; + + INT32 ctrl = scroll[0x104 + layer] >> 16; + + INT32 scrolly = scroll[0x100 + (layer * 2)] >> 16; + INT32 scrollx = (scroll[0x101 + (layer * 2)] >> 16) + (layer ? 5 : 3); + + GenericTilemapSetScrollY(layer, scrolly + 32); + + //bprintf (0, _T("CTRL %d %8.8x\n"), layer, scroll[0x104 + layer] >> 16); + + if ((ctrl & 0x0200) == 0x200) // row scroll + { + GenericTilemapSetScrollRows(layer, 1024/16); + + scroll += layer * 0x100; + + for (INT32 y = 0; y < 256; y += 16) + { + GenericTilemapSetScrollRow(layer, ((y + scrolly + 32) & 0xff) / 16, scrollx + (scroll[y / 16] >> 16)); + } + } + else if ((ctrl & 0x0300) == 0x100) // line scroll + { + GenericTilemapSetScrollRows(layer, 1024); + + scroll += layer * 0x100; + + for (INT32 y = 0; y < 256; y++) + { + GenericTilemapSetScrollRow(layer, (y + scrolly + 32) & 0x3ff, (scrollx + (lnscroll[(y + 32) & 0xff]))); + } + } + else if ((ctrl & 0x0300) == 0) // normal scroll + { + GenericTilemapSetScrollRows(layer, 1); + + GenericTilemapSetScrollX(layer, scrollx); + } + + GenericTilemapDraw(layer, pTransDraw, 0); +} + +static void draw_sprites() +{ + UINT16 *source = (UINT16*)DrvSprBuf2; + UINT16 *finish = source + 0x2000/2; + UINT16 *redirect = (UINT16 *)DrvGfxROM2; + + while (source < finish) + { + INT32 xpos, ypos, tileno, code, colour, xflip, yflip; + INT32 xsize, ysize, xinc, yinc, xct, yct; + + xpos = (source[1]&0x01ff); + ypos = (source[0]&0x01ff); + xsize = (source[1]&0x0e00) >> 9; + ysize = (source[0]&0x0e00) >> 9; + tileno = (source[3]&0xffff); + if (source[2]&1) tileno += 0x10000; // fix sprites in cute fighter -dink + colour = (source[2]&0x3f00) >> 8; + xflip = (source[2]&0x4000); + yflip = (source[2]&0x8000); + + xinc = 16; + yinc = 16; + + if (xflip) + { + xinc = -16; + xpos += 16*xsize; + } + + if (yflip) + { + yinc = -16; + ypos += 16 * ysize; + } + + xpos -= 16; + + for (yct=0;yct