From 4c925fd81b5555030c80a530c637d920fc19d95d Mon Sep 17 00:00:00 2001 From: esmjanus Date: Mon, 23 Oct 2017 19:40:32 -0500 Subject: [PATCH] - Added support for Tengai Makyou Zero english translation. Based on DougRPG source code. - Removed some unused variables. --- dsp4emu.cpp | 14 +++++++------- memmap.cpp | 42 +++++++++++++++++++++++++++++++++++++----- spc7110dec.cpp | 4 +++- spc7110dec.h | 2 ++ spc7110emu.cpp | 3 ++- spc7110emu.h | 2 ++ 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/dsp4emu.cpp b/dsp4emu.cpp index 09418d8..0b8a36a 100644 --- a/dsp4emu.cpp +++ b/dsp4emu.cpp @@ -1267,9 +1267,9 @@ void DSP4_Op09() if(sprite_type == 1) { int16 plane; - int16 car_left, car_right, car_left_a; - int16 focal_back, focal_front; - uint8 distance, id; + int16 car_left, car_right;//, car_left_a; + int16 focal_back;//, focal_front; + //uint8 distance, id; // we already have 4 bytes we want DSP4.in_count = 6+12; @@ -1280,11 +1280,11 @@ void DSP4_Op09() // filter inputs project_y1 = DSP4_READ_WORD(0x00); // 0x9000 = DSP4_READ_WORD(0x02); - id = DSP4.parameters[0x04]; - distance = DSP4.parameters[0x05]; + //id = DSP4.parameters[0x04]; + //distance = DSP4.parameters[0x05]; focal_back = DSP4_READ_WORD(0x06); - focal_front = DSP4_READ_WORD(0x08); - car_left_a = DSP4_READ_WORD(0x0a); + //focal_front = DSP4_READ_WORD(0x08); + //car_left_a = DSP4_READ_WORD(0x0a); car_left = DSP4_READ_WORD(0x0c); plane = DSP4_READ_WORD(0x0e); car_right = DSP4_READ_WORD(0x10); diff --git a/memmap.cpp b/memmap.cpp index 8ce3b72..1e9f2ec 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -657,7 +657,7 @@ int CMemory::LoadROMMore(int TotalFileSize,int &retry_count) int hi_score = ScoreHiROM (FALSE); int lo_score = ScoreLoROM (FALSE); - uint8* RomHeader=ROM; + //uint8* RomHeader=ROM; ExtendedFormat=NOPE; @@ -716,7 +716,7 @@ int CMemory::LoadROMMore(int TotalFileSize,int &retry_count) ExtendedFormat = BIGFIRST; hi_score=swappedhirom; lo_score=swappedlorom; - RomHeader=ROM+0x400000; + //RomHeader=ROM+0x400000; } else ExtendedFormat = SMALLFIRST; @@ -3305,13 +3305,13 @@ void CMemory::JumboLoROMMap (bool8 Interleaved) int i; uint32 OFFSET0 = 0x400000; - uint32 OFFSET1 = 0x400000; + //uint32 OFFSET1 = 0x400000; uint32 OFFSET2 = 0x000000; if (Interleaved) { OFFSET0 = 0x000000; - OFFSET1 = 0x000000; + //OFFSET1 = 0x000000; OFFSET2 = CalculatedSize-0x400000; //changed to work with interleaved DKJM2. } // Banks 00->3f and 80->bf @@ -3399,6 +3399,24 @@ void CMemory::JumboLoROMMap (bool8 Interleaved) WriteProtectROM (); } +static uint32 map_mirror (uint32 size, uint32 pos) +{ + // from bsnes + if (size == 0) + return (0); + if (pos < size) + return (pos); + + uint32 mask = 1 << 31; + while (!(pos & mask)) + mask >>= 1; + + if (size <= (pos & mask)) + return (map_mirror(size, pos - mask)); + else + return (mask + map_mirror(size - mask, pos - mask)); +} + void CMemory::SPC7110HiROMMap () { int c; @@ -3458,7 +3476,21 @@ void CMemory::SPC7110HiROMMap () BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE; } } - + + uint32 p, addr; + + for (c = 0x40; c <= 0x4f; c++) + { + for (i = 0x0000; i <= 0xffff; i += 0x1000) + { + p = (c << 4) | (i >> 12); + addr = (c - 0x40) << 16; + Map[p] = ROM + 0x600000 + map_mirror(CalculatedSize, addr); + BlockIsROM[p] = TRUE; + BlockIsRAM[p] = FALSE; + } + } + for (c = 0; c < 0x10; c++) { Map [0x500 + c] = (uint8 *) MAP_SPC7110_DRAM; diff --git a/spc7110dec.cpp b/spc7110dec.cpp index 8623f0e..976ab07 100644 --- a/spc7110dec.cpp +++ b/spc7110dec.cpp @@ -42,7 +42,7 @@ void SPC7110Decomp::write(uint8 data) { } uint8 SPC7110Decomp::dataread() { - unsigned size = memory_cartrom_size() - 0x100000; + unsigned size = memory_cartrom_size() - programmrom_size; while(decomp_offset >= size) decomp_offset -= size; return memory_cartrom_read(0x100000 + decomp_offset++); } @@ -519,6 +519,8 @@ SPC7110Decomp::SPC7110Decomp() { + map(3, 24) + map(2, 16) + map(1, 8) + map(0, 0); #undef map } + + programmrom_size = (memory_cartrom_size() > 0x500000) ? 0x200000 : 0x100000; } SPC7110Decomp::~SPC7110Decomp() { diff --git a/spc7110dec.h b/spc7110dec.h index 3a9c7ce..bead433 100644 --- a/spc7110dec.h +++ b/spc7110dec.h @@ -31,6 +31,8 @@ class SPC7110Decomp { unsigned decomp_mode; unsigned decomp_offset; + unsigned programmrom_size; + //read() will spool chunks half the size of decomp_buffer_size enum { decomp_buffer_size = SPC7110_DECOMP_BUFFER_SIZE }; //must be >= 64, and must be a power of two uint8 *decomp_buffer; diff --git a/spc7110emu.cpp b/spc7110emu.cpp index 364116a..fa7dd91 100644 --- a/spc7110emu.cpp +++ b/spc7110emu.cpp @@ -91,7 +91,7 @@ void SPC7110::reset() { } unsigned SPC7110::datarom_addr(unsigned addr) { - unsigned size = memory_cartrom_size() - 0x100000; + unsigned size = memory_cartrom_size() - programmrom_size; while(addr >= size) addr -= size; return addr + 0x100000; } @@ -642,4 +642,5 @@ void SPC7110::mmio_write(unsigned addr, uint8 data) { } SPC7110::SPC7110() { + programmrom_size = (memory_cartrom_size() > 0x500000) ? 0x200000 : 0x100000; } diff --git a/spc7110emu.h b/spc7110emu.h index 5f66fec..f968907 100644 --- a/spc7110emu.h +++ b/spc7110emu.h @@ -131,6 +131,8 @@ class SPC7110 { unsigned rtc_index; static const unsigned months[12]; + + unsigned programmrom_size; }; #endif