summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2020-02-05 11:36:25 -0600
committer cracyc <cracyc@users.noreply.github.com>2020-02-05 11:36:25 -0600
commitf292f3bb84b9a4e6817fa95e092bc3c148e04984 (patch)
tree620c96a338140849e59e630908dbe248798f2912
parent532d76f8cf752852ff0bb7bdf02bb6a0fc006ab0 (diff)
fmtowns: fix cdda volume and 1 layer 15bit color (nw)
-rw-r--r--src/mame/drivers/fmtowns.cpp40
-rw-r--r--src/mame/includes/fmtowns.h3
-rw-r--r--src/mame/video/fmtowns.cpp18
3 files changed, 43 insertions, 18 deletions
diff --git a/src/mame/drivers/fmtowns.cpp b/src/mame/drivers/fmtowns.cpp
index 318a15e8cc8..eca2a30caaa 100644
--- a/src/mame/drivers/fmtowns.cpp
+++ b/src/mame/drivers/fmtowns.cpp
@@ -239,6 +239,7 @@ Notes:
#include "screen.h"
#include "softlist.h"
#include "speaker.h"
+#include <math.h>
// CD controller IRQ types
@@ -2037,20 +2038,20 @@ WRITE_LINE_MEMBER(towns_state::towns_scsi_drq)
// Volume ports - I/O ports 0x4e0-0x4e3
// 0x4e0 = input volume level
// 0x4e1 = input channel select
-// 4 = Line in, left channel
-// 5 = Line in, right channel
+// 0 = Line in, left channel
+// 1 = Line in, right channel
// 0x4e2 = output volume level
// 0x4e3 = output channel select
+// 0 = CD-DA left channel
+// 1 = CD-DA right channel
// 2 = MIC
// 3 = MODEM
-// 4 = CD-DA left channel
-// 5 = CD-DA right channel
READ8_MEMBER(towns_state::towns_volume_r)
{
switch(offset)
{
case 2:
- return(m_towns_volume[m_towns_volume_select]);
+ return(m_towns_volume[m_towns_volume_select & 3]);
case 3:
return m_towns_volume_select;
default:
@@ -2058,20 +2059,35 @@ READ8_MEMBER(towns_state::towns_volume_r)
}
}
+void towns_state::cdda_db_to_gain(float db)
+{
+ float gain = powf(10, db / 20);
+ int port = m_towns_volume_select & 3;
+ if(port > 1)
+ return;
+ if(db == -1)
+ gain = 0;
+ m_cdda->set_output_gain(port, gain);
+}
+
WRITE8_MEMBER(towns_state::towns_volume_w)
{
switch(offset)
{
case 2:
- m_towns_volume[m_towns_volume_select] = data;
- if(m_towns_volume_select == 4)
- m_cdda->set_output_gain(0, data / 64.0f);
- if(m_towns_volume_select == 5)
- m_cdda->set_output_gain(1, data / 64.0f);
+ if(!(m_towns_volume_select & 4) || (m_towns_volume_select & 0x18))
+ return;
+ m_towns_volume[m_towns_volume_select & 3] = data;
+ cdda_db_to_gain(~(data & 0x3f) * -0.5f);
break;
case 3: // select channel
- if(data < 8)
- m_towns_volume_select = data;
+ m_towns_volume_select = data;
+ if(!(data & 4))
+ cdda_db_to_gain(-1);
+ else if(data & 8)
+ cdda_db_to_gain(0);
+ else if(data & 0x10)
+ cdda_db_to_gain(-32.0f);
break;
default:
logerror("SND: Volume port %i set to %02x\n",offset,data);
diff --git a/src/mame/includes/fmtowns.h b/src/mame/includes/fmtowns.h
index 1bddfe303aa..8d69e4a59c3 100644
--- a/src/mame/includes/fmtowns.h
+++ b/src/mame/includes/fmtowns.h
@@ -233,7 +233,7 @@ private:
uint8_t m_towns_mouse_output;
uint8_t m_towns_mouse_x;
uint8_t m_towns_mouse_y;
- uint8_t m_towns_volume[8]; // volume ports
+ uint8_t m_towns_volume[4]; // volume ports
uint8_t m_towns_volume_select;
uint8_t m_towns_scsi_control;
uint8_t m_towns_scsi_status;
@@ -366,6 +366,7 @@ private:
uint8_t speaker_get_spk();
void speaker_set_spkrdata(uint8_t data);
uint8_t towns_cdrom_read_byte_software();
+ void cdda_db_to_gain(float db);
required_ioport m_ctrltype;
required_ioport_array<4> m_kb_ports;
diff --git a/src/mame/video/fmtowns.cpp b/src/mame/video/fmtowns.cpp
index dcb776954ac..fe5d227d1b9 100644
--- a/src/mame/video/fmtowns.cpp
+++ b/src/mame/video/fmtowns.cpp
@@ -1109,16 +1109,24 @@ void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const
}
off += line * linesize;
- off &= ~0x01;
+ off &= ~1;
for(x=rect->min_x;x<rect->max_x;x+=hzoom)
{
+ int offpage;
+ int curoff;
if(m_video.towns_video_reg[0] & 0x10)
- off &= 0x3ffff; // 2 layers
+ {
+ curoff = off & 0x3ffff;
+ offpage = layer;
+ }
else
- off &= 0x7ffff; // 1 layer
- colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)];
- if(colour < 0x8000 || !(m_video.towns_video_reg[0] & 0x10))
+ {
+ offpage = (off & 4) >> 2;
+ curoff = ((off & 0x7fff8) >> 1) | (off & 3);
+ }
+ colour = (m_towns_gfxvram[curoff+(offpage*0x40000)+1] << 8) | m_towns_gfxvram[curoff+(offpage*0x40000)];
+ if(colour < 0x8000)
{
for (pixel = 0; pixel < hzoom; pixel++)
bitmap.pix32(scanline, x+pixel) =