mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
vt1682.cpp - (plug & play) Pushed ALU and Timers into devices, fixed some game logic, fixed some graphical issues (#5932)
* vt1682 alu is now a device (nw) * prepare to make times devices (nw) * push timer logic into devices (nw) * naming fixes (nw) * useful trampoline (nw) * (nw) * hmm timer math, I'm not sure about timer math (nw) * messing with rasters (nw) * move zone40 to vt1682, while it definitely isn't plain 1682 I think it's more likely closer to it than it is to SunPlus
This commit is contained in:
parent
9efc500cc0
commit
98d315d40e
@ -2878,6 +2878,10 @@ files {
|
||||
MAME_DIR .. "src/mame/drivers/vt1682.cpp",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_io.h",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_io.cpp",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_alu.h",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_alu.cpp",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_timer.h",
|
||||
MAME_DIR .. "src/mame/machine/vt1682_timer.cpp",
|
||||
MAME_DIR .. "src/mame/machine/m6502_vt1682.cpp",
|
||||
MAME_DIR .. "src/mame/machine/m6502_vt1682.h",
|
||||
}
|
||||
|
@ -3431,11 +3431,6 @@ ROM_START( lexizeus )
|
||||
ROM_LOAD16_WORD_SWAP( "lexibook1g900us.bin", 0x0000, 0x800000, CRC(c2370806) SHA1(cbb599c29c09b62b6a9951c724cd9fc496309cf9))
|
||||
ROM_END
|
||||
|
||||
ROM_START( zone40 )
|
||||
ROM_REGION( 0x4000000, "maincpu", ROMREGION_ERASE00 )
|
||||
ROM_LOAD16_WORD_SWAP( "zone40.bin", 0x0000, 0x4000000, CRC(4ba1444f) SHA1(de83046ab93421486668a247972ad6d3cda19440) )
|
||||
ROM_END
|
||||
|
||||
ROM_START( zone60 )
|
||||
ROM_REGION( 0x4000000, "maincpu", ROMREGION_ERASE00 )
|
||||
ROM_LOAD16_WORD_SWAP( "zone60.bin", 0x0000, 0x4000000, CRC(4cb637d1) SHA1(1f97cbdb4299ac0fbafc2a3aa592066cb0727066))
|
||||
@ -3570,17 +3565,6 @@ void spg2xx_game_state::init_zeus()
|
||||
}
|
||||
}
|
||||
|
||||
void spg2xx_game_state::init_zone40()
|
||||
{
|
||||
uint16_t *ROM = (uint16_t*)memregion("maincpu")->base();
|
||||
int size = memregion("maincpu")->bytes();
|
||||
|
||||
for (int i = 0; i < size/2; i++)
|
||||
{
|
||||
ROM[i] = ROM[i] ^ 0xbb88;
|
||||
}
|
||||
//there is also bitswapping as above, and some kind of address scramble as the vectors are not exactly where expected
|
||||
}
|
||||
|
||||
void spg2xx_game_state::init_taikeegr()
|
||||
{
|
||||
@ -3677,11 +3661,6 @@ CONS( 2006, icanpian, 0, 0, icanpian, icanpian, icanpian_state, empty_
|
||||
// Toyquest games
|
||||
CONS( 2005, tvgogo, 0, 0, tvgogo, tvgogo, tvgogo_state, empty_init, "Toyquest", "TV Go Go", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND )
|
||||
|
||||
|
||||
// might not fit here. First 0x8000 bytes are blank (not too uncommon for these) then rest of rom looks like it's probably encrypted at least
|
||||
// could be later model VT based instead? even after decrypting (simple word xor) the vectors have a different format and are at a different location to the SunPlus titles
|
||||
CONS( 2009, zone40, 0, 0, non_spg_base, wirels60, spg2xx_game_state, init_zone40, "Jungle Soft / Ultimate Products (HK) Ltd", "Zone 40", MACHINE_NO_SOUND | MACHINE_NOT_WORKING )
|
||||
|
||||
// Similar, SPG260?, scrambled
|
||||
CONS( 200?, lexizeus, 0, 0, lexizeus, lexizeus, spg2xx_game_state, init_zeus, "Lexibook", "Zeus IG900 20-in-1 (US?)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING )
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
349
src/mame/machine/vt1682_alu.cpp
Normal file
349
src/mame/machine/vt1682_alu.cpp
Normal file
@ -0,0 +1,349 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:David Haywood
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/vt1682_alu.h"
|
||||
|
||||
#define LOG_ALU (1U << 1)
|
||||
|
||||
#define LOG_ALL ( LOG_ALU )
|
||||
|
||||
#define VERBOSE (0)
|
||||
#include "logmacro.h"
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(VT_VT1682_ALU, vrt_vt1682_alu_device, "vt1682alu", "VRT VT1682 ALU")
|
||||
|
||||
vrt_vt1682_alu_device::vrt_vt1682_alu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, VT_VT1682_ALU, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
void vrt_vt1682_alu_device::device_start()
|
||||
{
|
||||
save_item(NAME(m_alu_oprand));
|
||||
save_item(NAME(m_alu_oprand_mult));
|
||||
save_item(NAME(m_alu_oprand_div));
|
||||
save_item(NAME(m_alu_out));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void vrt_vt1682_alu_device::device_reset()
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
m_alu_oprand[i] = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
m_alu_oprand_mult[i] = 0;
|
||||
m_alu_oprand_div[i] = 0;
|
||||
}
|
||||
|
||||
for (int i=0;i<6;i++)
|
||||
m_alu_out[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2130 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Oprand 1
|
||||
0x40 - ALU Oprand 1
|
||||
0x20 - ALU Oprand 1
|
||||
0x10 - ALU Oprand 1
|
||||
0x08 - ALU Oprand 1
|
||||
0x04 - ALU Oprand 1
|
||||
0x02 - ALU Oprand 1
|
||||
0x01 - ALU Oprand 1
|
||||
|
||||
Address 0x2130 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 1
|
||||
0x40 - ALU Output 1
|
||||
0x20 - ALU Output 1
|
||||
0x10 - ALU Output 1
|
||||
0x08 - ALU Output 1
|
||||
0x04 - ALU Output 1
|
||||
0x02 - ALU Output 1
|
||||
0x01 - ALU Output 1
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_1_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[0];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_1_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_1_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_1_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand[0] = data;
|
||||
}
|
||||
|
||||
/*
|
||||
Address 0x2131 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Oprand 2
|
||||
0x40 - ALU Oprand 2
|
||||
0x20 - ALU Oprand 2
|
||||
0x10 - ALU Oprand 2
|
||||
0x08 - ALU Oprand 2
|
||||
0x04 - ALU Oprand 2
|
||||
0x02 - ALU Oprand 2
|
||||
0x01 - ALU Oprand 2
|
||||
|
||||
Address 0x2131 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 2
|
||||
0x40 - ALU Output 2
|
||||
0x20 - ALU Output 2
|
||||
0x10 - ALU Output 2
|
||||
0x08 - ALU Output 2
|
||||
0x04 - ALU Output 2
|
||||
0x02 - ALU Output 2
|
||||
0x01 - ALU Output 2
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_2_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[1];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_2_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_2_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_2_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand[1] = data;
|
||||
}
|
||||
|
||||
/*
|
||||
Address 0x2132 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Oprand 3
|
||||
0x40 - ALU Oprand 3
|
||||
0x20 - ALU Oprand 3
|
||||
0x10 - ALU Oprand 3
|
||||
0x08 - ALU Oprand 3
|
||||
0x04 - ALU Oprand 3
|
||||
0x02 - ALU Oprand 3
|
||||
0x01 - ALU Oprand 3
|
||||
|
||||
Address 0x2132 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 3
|
||||
0x40 - ALU Output 3
|
||||
0x20 - ALU Output 3
|
||||
0x10 - ALU Output 3
|
||||
0x08 - ALU Output 3
|
||||
0x04 - ALU Output 3
|
||||
0x02 - ALU Output 3
|
||||
0x01 - ALU Output 3
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_3_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[2];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_3_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_3_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_3_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand[2] = data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2133 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Oprand 4
|
||||
0x40 - ALU Oprand 4
|
||||
0x20 - ALU Oprand 4
|
||||
0x10 - ALU Oprand 4
|
||||
0x08 - ALU Oprand 4
|
||||
0x04 - ALU Oprand 4
|
||||
0x02 - ALU Oprand 4
|
||||
0x01 - ALU Oprand 4
|
||||
|
||||
Address 0x2133 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 4
|
||||
0x40 - ALU Output 4
|
||||
0x20 - ALU Output 4
|
||||
0x10 - ALU Output 4
|
||||
0x08 - ALU Output 4
|
||||
0x04 - ALU Output 4
|
||||
0x02 - ALU Output 4
|
||||
0x01 - ALU Output 4
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_4_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[3];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_4_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_4_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_4_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand[3] = data;
|
||||
}
|
||||
|
||||
/*
|
||||
Address 0x2134 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Mul Oprand 5
|
||||
0x40 - ALU Mul Oprand 5
|
||||
0x20 - ALU Mul Oprand 5
|
||||
0x10 - ALU Mul Oprand 5
|
||||
0x08 - ALU Mul Oprand 5
|
||||
0x04 - ALU Mul Oprand 5
|
||||
0x02 - ALU Mul Oprand 5
|
||||
0x01 - ALU Mul Oprand 5
|
||||
|
||||
Address 0x2134 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 5
|
||||
0x40 - ALU Output 5
|
||||
0x20 - ALU Output 5
|
||||
0x10 - ALU Output 5
|
||||
0x08 - ALU Output 5
|
||||
0x04 - ALU Output 5
|
||||
0x02 - ALU Output 5
|
||||
0x01 - ALU Output 5
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_5_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[4];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_5_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_5_mult_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_5_mult_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand_mult[0] = data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2135 WRITE (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Mul Oprand 6
|
||||
0x40 - ALU Mul Oprand 6
|
||||
0x20 - ALU Mul Oprand 6
|
||||
0x10 - ALU Mul Oprand 6
|
||||
0x08 - ALU Mul Oprand 6
|
||||
0x04 - ALU Mul Oprand 6
|
||||
0x02 - ALU Mul Oprand 6
|
||||
0x01 - ALU Mul Oprand 6
|
||||
|
||||
Address 0x2135 READ (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Output 6
|
||||
0x40 - ALU Output 6
|
||||
0x20 - ALU Output 6
|
||||
0x10 - ALU Output 6
|
||||
0x08 - ALU Output 6
|
||||
0x04 - ALU Output 6
|
||||
0x02 - ALU Output 6
|
||||
0x01 - ALU Output 6
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_alu_device::alu_out_6_r)
|
||||
{
|
||||
uint8_t ret = m_alu_out[5];
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_out_6_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_6_mult_w)
|
||||
{
|
||||
// used one of the 32in1 menus
|
||||
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_6_mult_w writing: %02x\n", machine().describe_context(), data);
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "------------------------------------------ MULTIPLICATION REQUESTED ------------------------------------\n");
|
||||
m_alu_oprand_mult[1] = data;
|
||||
|
||||
int param1 = (m_alu_oprand_mult[1] << 8) | m_alu_oprand_mult[0];
|
||||
int param2 = (m_alu_oprand[1] << 8) | m_alu_oprand[0];
|
||||
|
||||
uint32_t result = param1 * param2;
|
||||
|
||||
m_alu_out[0] = result & 0xff;
|
||||
m_alu_out[1] = (result >> 8) & 0xff;
|
||||
m_alu_out[2] = (result >> 16) & 0xff;
|
||||
m_alu_out[3] = (result >> 24) & 0xff;
|
||||
|
||||
// oprands 5/6 cleared?
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2136 WRITE ONLY (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Div Oprand 5
|
||||
0x40 - ALU Div Oprand 5
|
||||
0x20 - ALU Div Oprand 5
|
||||
0x10 - ALU Div Oprand 5
|
||||
0x08 - ALU Div Oprand 5
|
||||
0x04 - ALU Div Oprand 5
|
||||
0x02 - ALU Div Oprand 5
|
||||
0x01 - ALU Div Oprand 5
|
||||
|
||||
*/
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_5_div_w)
|
||||
{
|
||||
if (!m_is_sound_alu) LOGMASKED(LOG_ALU, "%s: alu_oprand_5_div_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand_div[0] = data;
|
||||
}
|
||||
|
||||
/*
|
||||
Address 0x2137 WRITE ONLY (MAIN CPU & SOUND CPU)
|
||||
|
||||
0x80 - ALU Div Oprand 6
|
||||
0x40 - ALU Div Oprand 6
|
||||
0x20 - ALU Div Oprand 6
|
||||
0x10 - ALU Div Oprand 6
|
||||
0x08 - ALU Div Oprand 6
|
||||
0x04 - ALU Div Oprand 6
|
||||
0x02 - ALU Div Oprand 6
|
||||
0x01 - ALU Div Oprand 6
|
||||
*/
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_alu_device::alu_oprand_6_div_w)
|
||||
{
|
||||
//LOGMASKED(LOG_ALU, "%s: alu_oprand_6_div_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_alu_oprand_div[1] = data;
|
||||
|
||||
uint32_t param1 = (m_alu_oprand[3] << 24) | (m_alu_oprand[2] << 16) | (m_alu_oprand[1] << 8) | m_alu_oprand[0];
|
||||
// sources say the mult registers areu sed here, but that makes little sense?
|
||||
uint32_t param2 = (m_alu_oprand_div[1] << 8) | m_alu_oprand_div[0];
|
||||
|
||||
if (param2 != 0)
|
||||
{
|
||||
//if (!m_is_sound_alu) popmessage("------------------------------------------ DIVISION REQUESTED ------------------------------------\n");
|
||||
|
||||
uint32_t result = param1 / param2;
|
||||
|
||||
m_alu_out[0] = result & 0xff;
|
||||
m_alu_out[1] = (result >> 8) & 0xff;
|
||||
m_alu_out[2] = (result >> 16) & 0xff;
|
||||
m_alu_out[3] = (result >> 24) & 0xff;
|
||||
|
||||
// should be the remainder?
|
||||
m_alu_out[4] = 0x00;// machine().rand();
|
||||
m_alu_out[5] = 0x00;// machine().rand();
|
||||
|
||||
}
|
||||
}
|
50
src/mame/machine/vt1682_alu.h
Normal file
50
src/mame/machine/vt1682_alu.h
Normal file
@ -0,0 +1,50 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:David Haywood
|
||||
|
||||
#ifndef MAME_MACHINE_VT1682_ALU_H
|
||||
#define MAME_MACHINE_VT1682_ALU_H
|
||||
|
||||
#pragma once
|
||||
|
||||
DECLARE_DEVICE_TYPE(VT_VT1682_ALU, vrt_vt1682_alu_device)
|
||||
|
||||
class vrt_vt1682_alu_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
vrt_vt1682_alu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// so that we can filter logging, sound ALU gets used hundreds of times a frame, so logging it is unwise
|
||||
void set_sound_alu() { m_is_sound_alu = true; }
|
||||
|
||||
DECLARE_READ8_MEMBER(alu_out_1_r);
|
||||
DECLARE_READ8_MEMBER(alu_out_2_r);
|
||||
DECLARE_READ8_MEMBER(alu_out_3_r);
|
||||
DECLARE_READ8_MEMBER(alu_out_4_r);
|
||||
DECLARE_READ8_MEMBER(alu_out_5_r);
|
||||
DECLARE_READ8_MEMBER(alu_out_6_r);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_1_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_2_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_3_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_4_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_5_mult_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_6_mult_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_5_div_w);
|
||||
DECLARE_WRITE8_MEMBER(alu_oprand_6_div_w);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
bool m_is_sound_alu;
|
||||
|
||||
uint8_t m_alu_oprand[4];
|
||||
uint8_t m_alu_oprand_mult[2];
|
||||
uint8_t m_alu_oprand_div[2];
|
||||
uint8_t m_alu_out[6];
|
||||
};
|
||||
|
||||
#endif // MAME_MACHINE_VT1682_ALU_H
|
@ -1,6 +1,7 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:David Haywood
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/vt1682_io.h"
|
||||
|
||||
#define LOG_IO (1U << 1)
|
||||
|
194
src/mame/machine/vt1682_timer.cpp
Normal file
194
src/mame/machine/vt1682_timer.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:David Haywood
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/vt1682_timer.h"
|
||||
|
||||
#define LOG_TIMER (1U << 1)
|
||||
|
||||
#define LOG_ALL ( LOG_TIMER )
|
||||
|
||||
#define VERBOSE (LOG_TIMER)
|
||||
#include "logmacro.h"
|
||||
|
||||
// NOTE, system timer base clock can also be changed with "0x210B TSYNEN"
|
||||
// this can be handled externally by changing device clock?
|
||||
|
||||
DEFINE_DEVICE_TYPE(VT_VT1682_TIMER, vrt_vt1682_timer_device, "vt1682timer", "VRT VT1682 Timer")
|
||||
|
||||
vrt_vt1682_timer_device::vrt_vt1682_timer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, VT_VT1682_TIMER, tag, owner, clock),
|
||||
m_timer(*this, "snd_timera"),
|
||||
m_irq_cb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
void vrt_vt1682_timer_device::device_start()
|
||||
{
|
||||
save_item(NAME(m_timer_preload_7_0));
|
||||
save_item(NAME(m_timer_preload_15_8));
|
||||
save_item(NAME(m_timer_enable));
|
||||
|
||||
m_irq_cb.resolve();
|
||||
}
|
||||
|
||||
void vrt_vt1682_timer_device::device_reset()
|
||||
{
|
||||
m_timer_preload_7_0 = 0;
|
||||
m_timer_preload_15_8 = 0;
|
||||
m_timer_enable = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2100 r/w (SOUND CPU, Timer A)
|
||||
Address 0x2110 r/w (SOUND CPU, Timer B)
|
||||
|
||||
Address 0x2101 r/w (MAIN CPU, Timer)
|
||||
|
||||
0x80 - Timer xx Preload:7
|
||||
0x40 - Timer xx Preload:6
|
||||
0x20 - Timer xx Preload:5
|
||||
0x10 - Timer xx Preload:4
|
||||
0x08 - Timer xx Preload:3
|
||||
0x04 - Timer xx Preload:2
|
||||
0x02 - Timer xx Preload:1
|
||||
0x01 - Timer xx Preload:0
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_preload_7_0_r)
|
||||
{
|
||||
uint8_t ret = m_timer_preload_7_0;
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_preload_7_0_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_preload_7_0_w)
|
||||
{
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_preload_7_0_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_timer_preload_7_0 = data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2101 r/w (SOUND CPU, Timer A)
|
||||
Address 0x2111 r/w (SOUND CPU, Timer B)
|
||||
|
||||
Address 0x2104 r/w (MAIN CPU, Timer)
|
||||
|
||||
0x80 - Timer xx Preload:15
|
||||
0x40 - Timer xx Preload:14
|
||||
0x20 - Timer xx Preload:13
|
||||
0x10 - Timer xx Preload:12
|
||||
0x08 - Timer xx Preload:11
|
||||
0x04 - Timer xx Preload:10
|
||||
0x02 - Timer xx Preload:9
|
||||
0x01 - Timer xx Preload:8
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_preload_15_8_r)
|
||||
{
|
||||
uint8_t ret = m_timer_preload_15_8;
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_preload_15_8_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_preload_15_8_w)
|
||||
{
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_preload_15_8_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_timer_preload_15_8 = data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Address 0x2102 r/w (SOUND CPU, Timer A)
|
||||
Address 0x2112 r/w (SOUND CPU, Timer B)
|
||||
|
||||
Address 0x2102 r/w (MAIN CPU, Timer)
|
||||
|
||||
0x80 - (unused)
|
||||
0x40 - (unused)
|
||||
0x20 - (unused)
|
||||
0x10 - (unused)
|
||||
0x08 - (unused)
|
||||
0x04 - (unused)
|
||||
0x02 - TMRxx IRQ
|
||||
0x01 - TMRxx EN
|
||||
*/
|
||||
|
||||
READ8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_enable_r)
|
||||
{
|
||||
uint8_t ret = m_timer_enable;
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_enable_r returning: %02x\n", machine().describe_context(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_enable_w)
|
||||
{
|
||||
// Timer A notes
|
||||
// For NTSC
|
||||
//Period = (65536 - Timer _PreLoad) / 21.4772 MHz
|
||||
//Timer PreLoad = 65536 - (Period in seconds) * 21.4772 * 1000000 )
|
||||
|
||||
// For PAL
|
||||
// Period = (65536 - Timer PreLoad) / 26.601712 MHz
|
||||
//Timer PreLoad = 65536 - (Period in seconds) * 26.601712 * 1000000 )
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER, "%s: vt1682_timer_enable_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_timer_enable = data;
|
||||
|
||||
if (m_timer_enable & 0x01)
|
||||
{
|
||||
uint16_t preload = (m_timer_preload_15_8 << 8) | m_timer_preload_7_0;
|
||||
|
||||
double period = (double)(65536 - preload) / (clock() / 1000000); // in microseconds?
|
||||
if (!m_is_sound_timer) LOGMASKED(LOG_TIMER, "preload %d period in usec %f\n", preload, period );
|
||||
m_timer->adjust(attotime::from_usec(period), 0, attotime::from_usec(period));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timer->adjust(attotime::never);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(vrt_vt1682_timer_device::timer_expired)
|
||||
{
|
||||
if (m_timer_enable & 0x02)
|
||||
{
|
||||
m_irq_cb(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Address 0x2103 r/w (SOUND CPU, Timer A)
|
||||
Address 0x2113 r/w (SOUND CPU, Timer B)
|
||||
|
||||
Address 0x2103 r/w (MAIN CPU, Timer) (read or write?)
|
||||
|
||||
0x80 - Timer xx IRQ Clear
|
||||
0x40 - Timer xx IRQ Clear
|
||||
0x20 - Timer xx IRQ Clear
|
||||
0x10 - Timer xx IRQ Clear
|
||||
0x08 - Timer xx IRQ Clear
|
||||
0x04 - Timer xx IRQ Clear
|
||||
0x02 - Timer xx IRQ Clear
|
||||
0x01 - Timer xx IRQ Clear
|
||||
|
||||
*/
|
||||
|
||||
WRITE8_MEMBER(vrt_vt1682_timer_device::vt1682_timer_irqclear_w)
|
||||
{
|
||||
//if (!m_is_sound_timer) LOGMASKED(LOG_TIMER,"%s: vt1682_timer_irqclear_w writing: %02x\n", machine().describe_context(), data);
|
||||
m_irq_cb(false);
|
||||
}
|
||||
|
||||
void vrt_vt1682_timer_device::device_add_mconfig(machine_config& config)
|
||||
{
|
||||
TIMER(config, m_timer).configure_periodic(FUNC(vrt_vt1682_timer_device::timer_expired), attotime::never);
|
||||
}
|
55
src/mame/machine/vt1682_timer.h
Normal file
55
src/mame/machine/vt1682_timer.h
Normal file
@ -0,0 +1,55 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:David Haywood
|
||||
|
||||
#ifndef MAME_MACHINE_VT1682_TIMER_H
|
||||
#define MAME_MACHINE_VT1682_TIMER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "machine/timer.h"
|
||||
|
||||
DECLARE_DEVICE_TYPE(VT_VT1682_TIMER, vrt_vt1682_timer_device)
|
||||
|
||||
class vrt_vt1682_timer_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
vrt_vt1682_timer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
auto write_irq_callback() { return m_irq_cb.bind(); }
|
||||
|
||||
// so that we can filter logging, sound timer gets used hundreds of times a frame, so logging it is unwise
|
||||
void set_sound_timer() { m_is_sound_timer = true; }
|
||||
|
||||
DECLARE_READ8_MEMBER(vt1682_timer_preload_7_0_r);
|
||||
DECLARE_WRITE8_MEMBER(vt1682_timer_preload_7_0_w);
|
||||
|
||||
DECLARE_READ8_MEMBER(vt1682_timer_preload_15_8_r);
|
||||
DECLARE_WRITE8_MEMBER(vt1682_timer_preload_15_8_w);
|
||||
|
||||
DECLARE_READ8_MEMBER(vt1682_timer_enable_r);
|
||||
DECLARE_WRITE8_MEMBER(vt1682_timer_enable_w);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(vt1682_timer_irqclear_w);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
|
||||
private:
|
||||
bool m_is_sound_timer;
|
||||
required_device<timer_device> m_timer;
|
||||
|
||||
|
||||
uint8_t m_timer_preload_7_0;
|
||||
uint8_t m_timer_preload_15_8;
|
||||
uint8_t m_timer_enable;
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(timer_expired);
|
||||
|
||||
devcb_write_line m_irq_cb;
|
||||
};
|
||||
|
||||
#endif // MAME_MACHINE_VT1682_TIMER_H
|
@ -31103,6 +31103,7 @@ zdog
|
||||
@source:vt1682.cpp
|
||||
ii8in1
|
||||
ii32in1
|
||||
zone40 // Zone 40
|
||||
|
||||
@source:newbrain.cpp
|
||||
newbrain //
|
||||
@ -39548,7 +39549,6 @@ jak_sbfc //
|
||||
lexizeus // Lexibook
|
||||
vii // KenSingTon / Jungle Soft / Siatronics Vii
|
||||
wirels60 // Wireless 60
|
||||
zone40 // Zone 40
|
||||
zone60 // Zone 60
|
||||
rad_skat //
|
||||
rad_skatp //
|
||||
|
Loading…
Reference in New Issue
Block a user