summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/generalplus_gpl_unknown.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/generalplus_gpl_unknown.cpp')
-rw-r--r--src/mame/drivers/generalplus_gpl_unknown.cpp373
1 files changed, 246 insertions, 127 deletions
diff --git a/src/mame/drivers/generalplus_gpl_unknown.cpp b/src/mame/drivers/generalplus_gpl_unknown.cpp
index c59c342aa5e..5d2dfa7d39f 100644
--- a/src/mame/drivers/generalplus_gpl_unknown.cpp
+++ b/src/mame/drivers/generalplus_gpl_unknown.cpp
@@ -80,6 +80,15 @@ the first piece of code copied appears to attempt to checksum the internal BIOS!
#include "speaker.h"
+#define LOG_GPL_UNKNOWN (1U << 1)
+#define LOG_GPL_UNKNOWN_SELECT_SIM (1U << 2)
+
+#define LOG_ALL (LOG_GPL_UNKNOWN | LOG_GPL_UNKNOWN_SELECT_SIM)
+#define VERBOSE (0)
+
+#include "logmacro.h"
+
+
class pcp8718_state : public driver_device
{
public:
@@ -133,6 +142,9 @@ private:
uint16_t unk_7860_r();
uint16_t unk_780f_r();
+ void unk_7860_w(uint16_t data);
+ uint16_t m_7860;
+
void unk_7868_w(uint16_t data);
uint16_t unk_7868_r();
uint16_t m_7868;
@@ -176,6 +188,10 @@ private:
uint32_t m_spiaddress;
+ uint16_t unk_78a1_r();
+ uint16_t m_78a1;
+ void unk_78d8_w(uint16_t data);
+
enum spistate : const int
{
SPI_STATE_READY = 0,
@@ -213,18 +229,15 @@ private:
uint16_t unk_7870_r();
required_ioport m_io_p1;
required_ioport m_io_p2;
+
+ uint16_t m_stored_gamenum;
+ int m_addval;
+
+ DECLARE_WRITE_LINE_MEMBER(screen_vblank);
};
uint32_t pcp8718_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- m_mainram[0x12] |= 0x8000; // some code waits on this, what is it?
-
- for (int x = 8; x < 8 + 4; x++)
- {
- if (m_mainram[x] > 0)
- m_mainram[x] -= 1;
- }
-
int count = 0;
for (int y = 0; y < 256; y++)
{
@@ -250,9 +263,7 @@ uint32_t pcp8718_state::screen_update(screen_device &screen, bitmap_rgb32 &bitma
-void pcp8718_state::machine_start()
-{
-}
+
static INPUT_PORTS_START( pcp8718 )
PORT_START("IN0")
@@ -345,7 +356,20 @@ uint16_t pcp8718_state::unk_7abf_r()
uint16_t pcp8718_state::unk_7860_r()
{
- return (machine().rand() & 0x0008) | (m_io_p2->read() & 0xfff7);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: unk_7860_r (IO port)\n", machine().describe_context());
+
+ uint16_t ret = (m_io_p2->read() & 0xfff7);
+
+ if ((m_7860 & 0x20))
+ ret |= 0x08;
+
+ return ret;
+}
+
+void pcp8718_state::unk_7860_w(uint16_t data)
+{
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: unk_7860_w %04x (IO port)\n", machine().describe_context(), data);
+ m_7860 = data;
}
@@ -358,7 +382,7 @@ uint16_t pcp8718_state::unk_780f_r()
uint16_t pcp8718_state::spi_misc_control_r()
{
- //logerror("%06x: spi_misc_control_r\n", machine().describe_context());
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: spi_misc_control_r\n", machine().describe_context());
return 0x0000;
}
@@ -368,13 +392,13 @@ uint16_t pcp8718_state::spi_rx_fifo_r()
if (m_spistate == SPI_STATE_READING_FAST)
return spi_rx_fast();
- //logerror("%06x: spi_rx_fifo_r\n", machine().describe_context());
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: spi_rx_fifo_r\n", machine().describe_context());
return spi_rx();
}
void pcp8718_state::spi_process_tx_data(uint8_t data)
{
- //logerror("transmitting %02x\n", data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"transmitting %02x\n", data);
switch (m_spistate)
{
@@ -382,18 +406,18 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
{
if (data == 0x03)
{
- logerror("set to read mode (need address) %02x\n", data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to read mode (need address) %02x\n", data);
m_spistate = SPI_STATE_WAITING_HIGH_ADDR;
}
else if (data == 0x0b)
{
- logerror("set to fast read mode (need address) %02x\n", data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to fast read mode (need address) %02x\n", data);
m_spistate = SPI_STATE_WAITING_HIGH_ADDR_FAST;
//machine().debug_break();
}
else
{
- logerror("invalid state request %02x\n", data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"invalid state request %02x\n", data);
}
break;
}
@@ -401,7 +425,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_HIGH_ADDR:
{
m_spiaddress = (m_spiaddress & 0xff00ffff) | data << 16;
- // logerror("set to high address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to high address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_WAITING_MID_ADDR;
break;
}
@@ -409,7 +433,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_MID_ADDR:
{
m_spiaddress = (m_spiaddress & 0xffff00ff) | data << 8;
- // logerror("set to mid address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to mid address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_WAITING_LOW_ADDR;
break;
}
@@ -417,7 +441,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_LOW_ADDR:
{
m_spiaddress = (m_spiaddress & 0xffffff00) | data;
- logerror("set to low address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to low address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_READING;
break;
}
@@ -425,7 +449,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_READING:
{
// writes when in read mode clock in data?
- // logerror("write while in read mode (clock data?)\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"write while in read mode (clock data?)\n", data, m_spiaddress);
break;
}
@@ -445,7 +469,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_HIGH_ADDR_FAST:
{
m_spiaddress = (m_spiaddress & 0xff00ffff) | data << 16;
- logerror("set to high address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to high address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_WAITING_MID_ADDR_FAST;
break;
}
@@ -453,7 +477,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_MID_ADDR_FAST:
{
m_spiaddress = (m_spiaddress & 0xffff00ff) | data << 8;
- logerror("set to mid address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to mid address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_WAITING_LOW_ADDR_FAST;
break;
}
@@ -461,7 +485,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_LOW_ADDR_FAST:
{
m_spiaddress = (m_spiaddress & 0xffffff00) | data;
- logerror("set to low address %02x address is now %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"set to low address %02x address is now %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_WAITING_LOW_ADDR_FAST_DUMMY;
break;
@@ -469,7 +493,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_WAITING_LOW_ADDR_FAST_DUMMY:
{
- logerror("dummy write %08x\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"dummy write %08x\n", data, m_spiaddress);
m_spistate = SPI_STATE_READING_FAST;
break;
}
@@ -477,7 +501,7 @@ void pcp8718_state::spi_process_tx_data(uint8_t data)
case SPI_STATE_READING_FAST:
{
// writes when in read mode clock in data?
- // logerror("write while in read mode (clock data?)\n", data, m_spiaddress);
+ LOGMASKED(LOG_GPL_UNKNOWN,"write while in read mode (clock data?)\n", data, m_spiaddress);
break;
}
@@ -499,14 +523,14 @@ uint8_t pcp8718_state::spi_process_rx()
// if (dat == 0x4e)
// dat = 0x5e;
- //logerror("reading SPI %02x from SPI Address %08x (adjusted word offset %08x)\n", dat, m_spiaddress, (m_spiaddress/2)+0x20000);
+ LOGMASKED(LOG_GPL_UNKNOWN,"reading SPI %02x from SPI Address %08x (adjusted word offset %08x)\n", dat, m_spiaddress, (m_spiaddress/2)+0x20000);
m_spiaddress++;
return dat;
}
default:
{
- logerror("reading FIFO in unknown state\n");
+ LOGMASKED(LOG_GPL_UNKNOWN,"reading FIFO in unknown state\n");
return 0x00;
}
}
@@ -543,7 +567,7 @@ uint8_t pcp8718_state::spi_rx_fast()
void pcp8718_state::spi_tx_fifo_w(uint16_t data)
{
data &= 0x00ff;
- //logerror("%06x: spi_tx_fifo_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: spi_tx_fifo_w %04x\n", machine().describe_context(), data);
spi_process_tx_data(data);
}
@@ -552,12 +576,19 @@ void pcp8718_state::spi_tx_fifo_w(uint16_t data)
// it's accessed after each large data transfer, probably to reset the SPI into 'ready for command' state?
void pcp8718_state::unk_7868_w(uint16_t data)
{
- //logerror("%06x: unk_7868_w %04x (Port B + SPI reset?)\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: unk_7868_w %04x (Port B + SPI reset?)\n", machine().describe_context(), data);
- for (int i = 0; i < 4; i++)
- m_rx_fifo[i] = 0xff;
+ if ((m_7868 & 0x0100) != (data & 0x0100))
+ {
+ if (!(data & 0x0100))
+ {
+ for (int i = 0; i < 4; i++)
+ m_rx_fifo[i] = 0xff;
+
+ m_spistate = SPI_STATE_READY;
+ }
+ }
- m_spistate = SPI_STATE_READY;
m_7868 = data;
}
@@ -568,7 +599,7 @@ uint16_t pcp8718_state::unk_7868_r()
void pcp8718_state::bankswitch_707e_w(uint16_t data)
{
- logerror("%06x: bankswitch_707e_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: bankswitch_707e_w %04x\n", machine().describe_context(), data);
m_707e_bank = data;
}
@@ -580,7 +611,7 @@ uint16_t pcp8718_state::bankswitch_707e_r()
void pcp8718_state::bankswitch_703a_w(uint16_t data)
{
- logerror("%06x: bankswitch_703a_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: bankswitch_703a_w %04x\n", machine().describe_context(), data);
m_703a_bank = data;
}
@@ -633,7 +664,7 @@ void pcp8718_state::system_dma_params_channel0_w(offs_t offset, uint16_t data)
{
case 0:
{
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Mode)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Mode)\n", machine().describe_context(), offset, data);
#if 1
@@ -642,20 +673,32 @@ void pcp8718_state::system_dma_params_channel0_w(offs_t offset, uint16_t data)
uint32_t dest = m_dmaregs[2] | (m_dmaregs[5] << 16) ;
uint32_t length = m_dmaregs[3] | (m_dmaregs[6] << 16);
- if ((mode != 0x0200) && (mode != 0x4009))
+ if ((mode != 0x0200) && (mode != 0x4009) && (mode != 0x6009))
fatalerror("unknown dma mode write %04x\n", data);
- if (mode == 0x4009)
+ if ((mode == 0x4009) || (mode == 0x6009))
{
address_space& mem = m_maincpu->space(AS_PROGRAM);
- // source and dest are swapped compared to gpl16250 hookup? probably mode?
for (int i = 0; i < length; i++)
{
uint16_t dat = mem.read_word(source);
- mem.write_word(dest, dat);
- dest++;
+ if (mode & 0x2000)
+ {
+ // Racing Car and Elevator Action need this logic, the code in gpl16250 should probably be like this
+ // but currently gets used in non-increment mode
+ mem.write_word(dest, dat & 0xff);
+ dest++;
+ mem.write_word(dest, dat >> 8);
+ dest++;
+ }
+ else
+ {
+ mem.write_word(dest, dat);
+ dest++;
+ }
+
source++;
}
}
@@ -663,38 +706,38 @@ void pcp8718_state::system_dma_params_channel0_w(offs_t offset, uint16_t data)
break;
}
case 1:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Source Low)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Source Low)\n", machine().describe_context(), offset, data);
break;
case 2:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Dest Low)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Dest Low)\n", machine().describe_context(), offset, data);
break;
case 3:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Length Low)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Length Low)\n", machine().describe_context(), offset, data);
break;
case 4:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Source High)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Source High)\n", machine().describe_context(), offset, data);
break;
case 5:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Dest High)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Dest High)\n", machine().describe_context(), offset, data);
break;
case 6:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA Length High)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA Length High)\n", machine().describe_context(), offset, data);
break;
case 7:
- logerror("%06x: system_dma_params_channel0_w %01x %04x (DMA unknown)\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_w %01x %04x (DMA unknown)\n", machine().describe_context(), offset, data);
break;
}
}
uint16_t pcp8718_state::system_dma_params_channel0_r(offs_t offset)
{
- logerror("%06x: system_dma_params_channel0_r %01x\n", machine().describe_context(), offset);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: system_dma_params_channel0_r %01x\n", machine().describe_context(), offset);
return m_dmaregs[offset];
}
@@ -706,9 +749,23 @@ uint16_t pcp8718_state::unk_7870_r()
void pcp8718_state::spi_control_w(uint16_t data)
{
- logerror("%06x: spi_control_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: spi_control_w %04x\n", machine().describe_context(), data);
+}
+
+uint16_t pcp8718_state::unk_78a1_r()
+{
+ // checked in interrupt, code skipped entirely if this isn't set
+ return m_78a1;
+}
+
+void pcp8718_state::unk_78d8_w(uint16_t data)
+{
+ // written in IRQ, possible ack
+ if (data & 0x8000)
+ m_78a1 &= ~0x8000;
}
+
void pcp8718_state::map(address_map &map)
{
// there are calls to 01xxx and 02xxx regions
@@ -728,14 +785,18 @@ void pcp8718_state::map(address_map &map)
map(0x00780f, 0x00780f).r(FUNC(pcp8718_state::unk_780f_r));
- map(0x007860, 0x007860).r(FUNC(pcp8718_state::unk_7860_r));
+ map(0x007860, 0x007860).rw(FUNC(pcp8718_state::unk_7860_r),FUNC(pcp8718_state::unk_7860_w));
+ map(0x007862, 0x007862).nopw();
+ map(0x007863, 0x007863).nopw();
+
+ map(0x007868, 0x007868).rw(FUNC(pcp8718_state::unk_7868_r), FUNC(pcp8718_state::unk_7868_w));
map(0x007870, 0x007870).r(FUNC(pcp8718_state::unk_7870_r)); // I/O
- map(0x007862, 0x007862).nopw();
+ map(0x0078a1, 0x0078a1).r(FUNC(pcp8718_state::unk_78a1_r));
+ map(0x0078d8, 0x0078d8).w(FUNC(pcp8718_state::unk_78d8_w));
- map(0x007868, 0x007868).rw(FUNC(pcp8718_state::unk_7868_r), FUNC(pcp8718_state::unk_7868_w));
map(0x007940, 0x007940).w(FUNC(pcp8718_state::spi_control_w));
// 7941 SPI Transmit Status
@@ -748,7 +809,6 @@ void pcp8718_state::map(address_map &map)
map(0x007abf, 0x007abf).r(FUNC(pcp8718_state::unk_7abf_r));
-
// there are calls to 0x0f000 (internal ROM?)
map(0x00f000, 0x00ffff).rom().region("maincpu", 0x00000);
@@ -787,7 +847,7 @@ void pcp8718_state::lcd_command_w(uint16_t data)
void pcp8718_state::lcd_w(uint16_t data)
{
data &= 0xff; // definitely looks like 8-bit port as 16-bit values are shifted and rewritten
- logerror("%06x: lcd_w %02x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GPL_UNKNOWN,"%06x: lcd_w %02x\n", machine().describe_context(), data);
if ((m_lcdstate == LCD_STATE_PROCESSING_COMMAND) && (m_lastlcdcommand == 0x22))
{
@@ -811,56 +871,12 @@ uint16_t pcp8718_state::simulate_f000_r(offs_t offset)
if ((offset + 0xf000) == (realpc))
{
-#if 0
- // still simulate this as it uses 'fast read' mode which doesn't work in the SPI handler at the moment
- if (realpc == 0xf000)
- {
- address_space& mem = m_maincpu->space(AS_PROGRAM);
-
- uint32_t source = (mem.read_word(0x001e) << 16) | mem.read_word(0x001d);
-
- if (source >= 0x20000)
- {
- uint16_t data = m_spirom[((source - 0x20000) * 2) + 0] | (m_spirom[((source - 0x20000) * 2) + 1] << 8);
- uint16_t data2 = m_spirom[((source - 0x20000) * 2) + 2] | (m_spirom[((source - 0x20000) * 2) + 3] << 8);
- uint16_t data3 = m_spirom[((source - 0x20000) * 2) + 4] | (m_spirom[((source - 0x20000) * 2) + 5] << 8);
- uint16_t data4 = m_spirom[((source - 0x20000) * 2) + 6] | (m_spirom[((source - 0x20000) * 2) + 7] << 8);
-
- logerror("call to 0xf000 - copying 4 words from %08x to 04/05/06/07\n", source); // some code only uses 04, but other code copies pointers and expects results in 04 and 05
-
- mem.write_word(0x0004, data);
- mem.write_word(0x0005, data2);
- mem.write_word(0x0006, data3);
- mem.write_word(0x0007, data4);
-
- }
-
- return 0x9a90; // retf
- }
- else if (realpc == 0xf58f)
- {
- // logerror("call to 0xf58f - unknown function\n");
- return m_mainrom[offset];
- }
- else if (realpc == 0xfb26) // done with a call, and also a pc =
- {
- // logerror("call to 0xfb26 - unknown function\n");
- return m_mainrom[offset];
- }
- else if (realpc == 0xf56f) // done with a pc =
- {
- // logerror("call to 0xf56f - unknown function\n");
- return m_mainrom[offset];
- }
- else
- {
- return m_mainrom[offset];
- }
-#endif
+ //LOGMASKED(LOG_GPL_UNKNOWN,"simulate_f000_r reading BIOS area (for BIOS call?) %04x\n", offset);
+ return m_mainrom[offset];
}
else
{
- // logerror("simulate_f000_r reading BIOS area (for checksum?) %04x\n", offset);
+ //LOGMASKED(LOG_GPL_UNKNOWN,"simulate_f000_r reading BIOS area (for checksum?) %04x\n", offset);
return m_mainrom[offset];
}
}
@@ -871,7 +887,7 @@ uint16_t pcp8718_state::ramcall_2060_logger_r()
{
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x2060 in RAM (set SPI to read mode, set address, do dummy FIFO reads)\n");
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x2060 in RAM (set SPI to read mode, set address, do dummy FIFO reads)\n");
}
return m_mainram[0x2060];
}
@@ -880,7 +896,7 @@ uint16_t pcp8718_state::ramcall_2189_logger_r()
{
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x2189 in RAM (unknown)\n");
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x2189 in RAM (unknown)\n");
}
return m_mainram[0x2189];
}
@@ -891,19 +907,115 @@ uint16_t pcp8718_state::ramcall_2829_logger_r()
// this in turn calls 28f7 but has restore logic too
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x2829 in RAM (load+call function from SPI address %08x)\n", (m_mainram[0x1e] << 16) | m_mainram[0x1d]);
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x2829 in RAM (load+call function from SPI address %08x)\n", (m_mainram[0x1e] << 16) | m_mainram[0x1d]);
}
return m_mainram[0x2829];
}
-
-
uint16_t pcp8718_state::ramcall_287a_logger_r()
{
+ // this transmits to a device, then reads back the result, needed for menu navigation?!
+ // TODO: data should transmit etc. over bits in the I/O ports, this is HLE, although
+ // most of this code will end up in a simulation handler for whatever this device is
+
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x287a in RAM (unknown)\n");
+ if (m_maincpu->pc() == 0x287a)
+ {
+ // 1d = command, 1e = param?
+ int command = m_mainram[0x1d] & 0xff;
+ int param = m_mainram[0x1e] & 0xff;
+
+ if ((command) == 0x00) // request result low
+ {
+ m_maincpu->set_state_int(UNSP_R1, m_stored_gamenum & 0xff);
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x (request result low)\n", command);
+ }
+ else if ((command) == 0x01) // request result high
+ {
+ m_maincpu->set_state_int(UNSP_R1, (m_stored_gamenum>>8) & 0xff);
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x (request result high)\n", command);
+ }
+ else if ((command) == 0x02)
+ {
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x %02x (set data low)\n", command, param);
+ m_stored_gamenum = (m_stored_gamenum & 0xff00) | (m_mainram[0x1e] & 0x00ff);
+ }
+ else if ((command) == 0x03)
+ {
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x %02x (set data high)\n", command, param);
+ m_stored_gamenum = (m_stored_gamenum & 0x00ff) | ((m_mainram[0x1e] & 0x00ff) << 8);
+ }
+ else if ((command) == 0x04)
+ {
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x %02x (set add value)\n", command, param);
+ // used with down
+ if (param == 0x03)
+ m_addval = 4;
+ else if (param == 0x00)
+ m_addval = 0;
+
+ // used if you try to scroll up or left past 0 and the value becomes too large (a negative number)
+ // actually writes 0x314 split into 2 commands, so the 2nd write to 0x04 with param then instead 0b/16 sequence of writes instead of 26/0c adds to the high byte?
+ if (param == 0x14)
+ m_addval = 0x314;
+
+ }
+ else if ((command) == 0x05)
+ {
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x %02x (set subtract value)\n", command, param);
+
+ // used if you try to scroll down past the and the value becomes too large
+ // actually writes 0x313 split into 2 commands, so the 2nd write to 0x05 with param then instead 0b/16 sequence of writes instead of 26/0c subtracts from the high byte?
+ if (param == 0x13)
+ m_addval = -0x314; // why 314, it writes 313
+
+ }
+ else if ((command) == 0x10)
+ {
+ // this is followed by 0x1b, written if you try to move right off last entry
+ m_stored_gamenum = 0x00;
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x (reset value)\n", command);
+ }
+ else if (command == 0x26)
+ {
+ // used in direction handlers after writing the first command
+ m_stored_gamenum += m_addval;
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x\n", command);
+ }
+ else if (command == 0x30)
+ {
+ // used with right
+ m_addval = 1;
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x\n", command);
+ // 26/0c called after this, then another fixed command value, then 0b/16
+ // unlike commands 04/05 there's no parameter byte written here, must be derived from the command?
+ }
+ else if (command == 0x37)
+ {
+ // used with left
+ m_addval = -1;
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x\n", command);
+ // 26/0c called after this, then another fixed command value, then 0b/16
+ // unlike commands 04/05 there's no parameter byte written here, must be derived from the command?
+ }
+ else if (command == 0x39)
+ {
+ // used with up
+ m_addval = -4;
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x\n", command);
+ // 26/0c called after this, then another fixed command value, then 0b/16
+ // unlike commands 04/05 there's no parameter byte written here, must be derived from the command?
+ }
+ else
+ {
+ LOGMASKED(LOG_GPL_UNKNOWN_SELECT_SIM,"call to 0x287a in RAM (transmit / receive) %02x\n", command);
+ }
+
+ // hack retf
+ return 0x9a90;
+ }
}
return m_mainram[0x287a];
}
@@ -913,7 +1025,7 @@ uint16_t pcp8718_state::ramcall_28f7_logger_r()
if (!machine().side_effects_disabled())
{
// no restore logic?
- // logerror("call to 0x28f7 in RAM (load+GO TO function from SPI address %08x)\n", (m_mainram[0x1e] << 16) | m_mainram[0x1d]);
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x28f7 in RAM (load+GO TO function from SPI address %08x)\n", (m_mainram[0x1e] << 16) | m_mainram[0x1d]);
}
return m_mainram[0x28f7];
}
@@ -922,7 +1034,7 @@ uint16_t pcp8718_state::ramcall_2079_logger_r()
{
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x2079 in RAM (maybe drawing related?)\n"); // called in the 'dummy' loop that doesn't actually draw? and other places? as well as after the actual draw command below in the real loop
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x2079 in RAM (maybe drawing related?)\n"); // called in the 'dummy' loop that doesn't actually draw? and other places? as well as after the actual draw command below in the real loop
}
return m_mainram[0x2079];
}
@@ -931,26 +1043,17 @@ uint16_t pcp8718_state::ramcall_2434_logger_r()
{
if (!machine().side_effects_disabled())
{
- // logerror("call to 0x2434 in RAM (drawing related?)\n"); // [1d] as the tile / sprite number, [1e] as xpos, [1f] as ypos, [20] as 0. [21] as ff in some title drawing calls
+ LOGMASKED(LOG_GPL_UNKNOWN,"call to 0x2434 in RAM (drawing related?)\n"); // [1d] as the tile / sprite number, [1e] as xpos, [1f] as ypos, [20] as 0. [21] as ff in some title drawing calls
}
return m_mainram[0x2434];
}
-
+void pcp8718_state::machine_start()
+{
+}
void pcp8718_state::machine_reset()
{
- // this looks like it might actually be part of the IRQ handler (increase counter at 00 at the very start) rather than where we should end up after startup
- // it also looks like (from the pc = 2xxx opcodes) that maybe this code should be being executed in RAM as those don't give correct offsets in the data segment.
- //m_maincpu->set_state_int(UNSP_PC, 0x4000);
- //m_maincpu->set_state_int(UNSP_SR, 0x0000);
-
- //uint16_t* ROM = (uint16_t*)memregion("maincpu")->base();
- //ROM[0x0000] = 0x9a90; // retf from internal ROM call to 0xf000 (unknown purpose)
-
- // there doesn't appear to be any code to set the SP, so it must be done by the internal ROM
- //m_maincpu->set_state_int(UNSP_SP, 0x5fff);
-
m_maincpu->space(AS_PROGRAM).install_read_handler(0xf000, 0xffff, read16sm_delegate(*this, FUNC(pcp8718_state::simulate_f000_r)));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x2060, 0x2060, read16smo_delegate(*this, FUNC(pcp8718_state::ramcall_2060_logger_r)));
@@ -970,15 +1073,30 @@ void pcp8718_state::machine_reset()
m_spistate = SPI_STATE_READY;
m_spiaddress = 0;
- for (int i = 0; i < 0x20000; i++)
- m_displaybuffer[i] = i&0xff;
+ for (int i = 0; i < 320*240*2; i++)
+ m_displaybuffer[i] = 0x00;
m_lcdaddr = 0;
m_lcdstate = LCD_STATE_READY;
m_lastlcdcommand = 0;
+
+ m_78a1 = 0;
}
+WRITE_LINE_MEMBER(pcp8718_state::screen_vblank)
+{
+ if (state)
+ {
+ // probably a timer
+ m_maincpu->set_input_line(UNSP_IRQ4_LINE, ASSERT_LINE);
+ m_78a1 |= 0x8000;
+ }
+ else
+ {
+ m_maincpu->set_input_line(UNSP_IRQ4_LINE, CLEAR_LINE);
+ }
+}
void pcp8718_state::pcp8718(machine_config &config)
{
@@ -988,11 +1106,12 @@ void pcp8718_state::pcp8718(machine_config &config)
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60);
- m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
+ m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(10));
m_screen->set_size(64*8, 32*8);
m_screen->set_visarea(0*8, 320-1, 0*8, 240-1);
m_screen->set_screen_update(FUNC(pcp8718_state::screen_update));
//m_screen->set_palette(m_palette);
+ m_screen->screen_vblank().set(FUNC(pcp8718_state::screen_vblank));
PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x8000);
}