Skip to content

Commit

Permalink
casio/cz230s.cpp: Added Casio CZ-230S and SZ-1. (mamedev#11969)
Browse files Browse the repository at this point in the history
* cpu/upd7810: Added support for internal RAM.
* sound/upd934g.cpp: Corrected channel mapping for play sample command.
* video/mn1252.cpp: Added Panasonic MN1252 LCD controller emulation.
* casio/ra3.cpp: Added RA-5 8 KiB RAM cartridge.

New working systems
----------
Casio CZ-230S [BCM, =CO=Windler, Devin Acker]
Casio SZ-1 [BCM, Devin Acker]
  • Loading branch information
devinacker authored and Ryan Holtz committed Jan 28, 2024
1 parent 893c9ae commit bbd2f48
Show file tree
Hide file tree
Showing 14 changed files with 1,729 additions and 25 deletions.
12 changes: 12 additions & 0 deletions scripts/src/video.lua
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,18 @@ if (VIDEOS["MOS8563"]~=null) then
}
end

--------------------------------------------------
--
--@src/devices/video/mn1252.h,VIDEOS["MN1252"] = true
--------------------------------------------------

if (VIDEOS["MN1252"]~=null) then
files {
MAME_DIR .. "src/devices/video/mn1252.cpp",
MAME_DIR .. "src/devices/video/mn1252.h",
}
end

--------------------------------------------------
--
--@src/devices/video/pc_vga.h,VIDEOS["PC_VGA"] = true
Expand Down
7 changes: 5 additions & 2 deletions src/devices/cpu/upd7810/upd7810.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void upd7810_device::upd_internal_128_ram_map(address_map &map)

void upd7810_device::upd_internal_256_ram_map(address_map &map)
{
map(0xff00, 0xffff).ram();
map(0xff00, 0xffff).view(m_ram_view);
m_ram_view[0](0xff00, 0xffff).ram();
}

void upd7810_device::upd_internal_4096_rom_128_ram_map(address_map &map)
Expand All @@ -401,7 +402,8 @@ void upd7810_device::upd_internal_4096_rom_128_ram_map(address_map &map)
void upd7810_device::upd_internal_4096_rom_256_ram_map(address_map &map)
{
map(0x0000, 0x0fff).rom();
map(0xff00, 0xffff).ram();
map(0xff00, 0xffff).view(m_ram_view);
m_ram_view[0](0xff00, 0xffff).ram();
}

upd7810_device::upd7810_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal_map)
Expand All @@ -424,6 +426,7 @@ upd7810_device::upd7810_device(const machine_config &mconfig, device_type type,
, m_pf_out_cb(*this)
, m_pt_in_cb(*this, 0) // TODO: uPD7807 only
, m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0, internal_map)
, m_ram_view(*this, "ram_view")
, m_pa_pullups(0xff)
, m_pb_pullups(0xff)
, m_pc_pullups(0xff)
Expand Down
1 change: 1 addition & 0 deletions src/devices/cpu/upd7810/upd7810.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class upd7810_device : public cpu_device
static const struct opcode_s s_opXX_78c06[256];

address_space_config m_program_config;
memory_view m_ram_view;

PAIR m_ppc; /* previous program counter */
PAIR m_pc; /* program counter */
Expand Down
5 changes: 5 additions & 0 deletions src/devices/cpu/upd7810/upd7810_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,11 @@ void upd7810_device::MOV_TMM_A()
void upd7810_device::MOV_MM_A()
{
MM = A;

if (BIT(A, 3))
m_ram_view.select(0);
else
m_ram_view.disable();
}

/* 4d d1: 0100 1101 1101 0001 */
Expand Down
40 changes: 18 additions & 22 deletions src/devices/sound/upd934g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
TODO:
- Correct MUTED and ACCENTED (currently just changes volume)
- T1 input
- 8 channels?
***************************************************************************/

#include "emu.h"
#include "upd934g.h"

#define VERBOSE (0)
#include "logmacro.h"

//**************************************************************************
// DEVICE DEFINITIONS
Expand Down Expand Up @@ -54,13 +55,9 @@ void upd934g_device::device_start()
// register for save states
save_pointer(NAME(m_addr), 16);

for (unsigned i = 0; i < 4; i++)
{
save_item(NAME(m_channel[i].pos), i);
save_item(NAME(m_channel[i].playing), i);
save_item(NAME(m_channel[i].volume), i);
save_item(NAME(m_channel[i].effect), i);
}
save_item(STRUCT_MEMBER(m_channel, pos));
save_item(STRUCT_MEMBER(m_channel, playing));
save_item(STRUCT_MEMBER(m_channel, effect));

save_item(NAME(m_sample));
save_item(NAME(m_ready));
Expand Down Expand Up @@ -93,13 +90,13 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_

for (unsigned i = 0; i < outputs[ch].samples(); i++)
{
int8_t raw = static_cast<int8_t>(read_byte(m_channel[ch].pos));
int16_t raw = static_cast<int8_t>(read_byte(m_channel[ch].pos)) * 4;

// normal, muted, accented
const double adjust[] = { 0, 0.7, 0.4, 1.0 };
raw *= adjust[m_channel[ch].effect];

outputs[ch].put_int(i, raw * (m_channel[ch].volume + 1), 32768 / 64);
outputs[ch].put_int(i, raw, 32768 / 64);

if (++m_channel[ch].pos >= end)
{
Expand Down Expand Up @@ -127,24 +124,23 @@ void upd934g_device::write(offs_t offset, uint8_t data)
// format of data written here is:
// 76------ command
// --5432-- sample number
// ------10 volume?
// ------10 output channel
m_sample = (data >> 2) & 0x0f;

switch (data >> 6)
{
case 0:
logerror("CMD STORE ADDRESS sample %x\n", m_sample);
LOG("CMD STORE ADDRESS sample %x\n", m_sample);
break;
case 1:
case 2:
case 3:
logerror("CMD PLAY sample %x (channel %d, effect %d)\n", m_sample, m_sample >> 1, data >> 6);
if (m_sample < 8)
case 1: // normal
case 2: // muted
case 3: // accented
{
m_channel[m_sample >> 1].pos = m_addr[m_sample];
m_channel[m_sample >> 1].playing = m_sample;
m_channel[m_sample >> 1].volume = data & 0x03;
m_channel[m_sample >> 1].effect = data >> 6;
const u8 ch = (data & 3) ^ 2; // effective order seems to be "2, 3, 0, 1"
LOG("CMD PLAY sample %x (channel %d, effect %d)\n", m_sample, ch, data >> 6);
m_channel[ch].pos = m_addr[m_sample];
m_channel[ch].playing = m_sample;
m_channel[ch].effect = data >> 6;
}
break;
}
Expand All @@ -154,7 +150,7 @@ void upd934g_device::write(offs_t offset, uint8_t data)
break;
case 2:
m_addr[m_sample] = (m_addr[m_sample] & 0x00ff) | (data << 8);
logerror(" sample %x address = %04x\n", m_sample, m_addr[m_sample]);
LOG(" sample %x address = %04x\n", m_sample, m_addr[m_sample]);
break;
case 3:
m_ready = true;
Expand Down
1 change: 0 additions & 1 deletion src/devices/sound/upd934g.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class upd934g_device : public device_t, public device_sound_interface, public de
{
uint16_t pos;
int playing;
int volume;
int effect;
}
m_channel[4];
Expand Down
103 changes: 103 additions & 0 deletions src/devices/video/mn1252.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// license:BSD-3-Clause
// copyright-holders:Devin Acker
/***************************************************************************
Panasonic MN1252 LCD controller
***************************************************************************/

#include "emu.h"
#include "mn1252.h"

#include <cassert>


DEFINE_DEVICE_TYPE(MN1252, mn1252_device, "mn1252", "Panasonic MN1252 LCD controller")

const u8 mn1252_device::OUTPUT_DIGITS[0x40] =
{
// bit 0..7 = segment a..h (from datasheet)
0x00, 0x77, 0x7f, 0x39, 0x3f, 0x79, 0x71, 0x3d,
0x76, 0x06, 0x1e, 0xf0, 0x38, 0xb7, 0xb6, 0xbf,
0x73, 0xbf, 0xf3, 0x6d, 0x07, 0x3e, 0xa6, 0xbe,
0xf2, 0x6e, 0x5b, 0x48, 0x0f, 0x46, 0x49, 0x44,
0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38,
0x7c, 0x58, 0x5e, 0x54, 0x5c, 0x40, 0x21, 0x0c,
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
0x7f, 0x6f, 0x01, 0x36, 0x5f, 0x7b, 0x74, 0x62
};

mn1252_device::mn1252_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, MN1252, tag, owner, clock)
{
}

/**************************************************************************/
void mn1252_device::device_start()
{
save_item(NAME(m_data));
save_item(NAME(m_first_nibble));
save_item(NAME(m_nibble_count));
save_item(NAME(m_ce));
save_item(NAME(m_std));
save_item(NAME(m_output));
}

/**************************************************************************/
void mn1252_device::device_reset()
{
m_data = m_first_nibble = 0;
m_nibble_count = 0;
m_ce = m_std = 0;

std::fill(std::begin(m_output), std::end(m_output), 0);
}

/**************************************************************************/
u16 mn1252_device::output(offs_t digit) const
{
assert(digit < 6);
return m_output[digit];
}

/**************************************************************************/
void mn1252_device::data_w(u8 data)
{
m_data = data & 0xf;
}

/**************************************************************************/
void mn1252_device::ce_w(int state)
{
if (!m_ce && state)
{
m_nibble_count = 0;
}

m_ce = state;
}

/**************************************************************************/
void mn1252_device::std_w(int state)
{
if (m_ce && m_std && !state && m_nibble_count < 12)
{
if (!(m_nibble_count % 2))
{
m_first_nibble = m_data;
}
else
{
const u8 data = (m_first_nibble << 4) | m_data;
u16 output = OUTPUT_DIGITS[data & 0x3f];
if (BIT(data, 6)) output |= 0x80; // segment h
if (BIT(data, 7)) output |= 0x100; // segment p

m_output[m_nibble_count / 2] = output;
}

m_nibble_count++;
}

m_std = state;
}
42 changes: 42 additions & 0 deletions src/devices/video/mn1252.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// license:BSD-3-Clause
// copyright-holders:Devin Acker
/***************************************************************************
Panasonic MN1252 LCD controller
***************************************************************************/

#ifndef MAME_VIDEO_MN1252_H
#define MAME_VIDEO_MN1252_H

#pragma once

class mn1252_device : public device_t
{
public:
mn1252_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);

u16 output(offs_t digit) const;

void data_w(u8 data);
void ce_w(int state);
void std_w(int state);

protected:
virtual void device_start() override;
virtual void device_reset() override;

private:
static const u8 OUTPUT_DIGITS[0x40];

u8 m_data;
u8 m_first_nibble;
u8 m_nibble_count;
u8 m_ce, m_std;

u16 m_output[6];
};

DECLARE_DEVICE_TYPE(MN1252, mn1252_device)

#endif // MAME_VIDEO_MN1252_H

0 comments on commit bbd2f48

Please sign in to comment.