mulcd: Switch to a svg [O. Galibert]

This commit is contained in:
Olivier Galibert 2020-11-04 09:33:39 +01:00
parent 8597660681
commit 02bf25aa6f
4 changed files with 35 additions and 55 deletions

View File

@ -1701,7 +1701,6 @@ generate: \
$(GENDIR)/version.cpp \
$(patsubst %.po,%.mo,$(call rwildcard, language/, *.po)) \
$(patsubst $(SRC)/%.lay,$(GENDIR)/%.lh,$(LAYOUTS)) \
$(GENDIR)/mame/machine/mulcd.hxx \
$(GENDIR)/includes/SDL2
$(GENDIR)/includes/SDL2:
@ -1738,10 +1737,6 @@ $(GENDIR)/%.lh: $(SRC)/%.lay scripts/build/complay.py | $(GEN_FOLDERS)
@echo Compressing $<...
$(SILENT)$(PYTHON) scripts/build/complay.py $< $@ layout_$(basename $(notdir $<))
$(GENDIR)/mame/machine/mulcd.hxx: $(SRC)/mame/machine/mulcd.ppm scripts/build/file2str.py | $(GEN_FOLDERS)
@echo Converting $<...
$(SILENT)$(PYTHON) scripts/build/file2str.py $< $@ mulcd_bkg uint8_t
%.mo: %.po
@echo Converting translation $<...
ifdef IGNORE_BAD_LOCALISATION

View File

@ -7,11 +7,12 @@
#include "emu.h"
#include "mulcd.h"
#include "../machine/mulcd.hxx"
DEFINE_DEVICE_TYPE(MULCD, mulcd_device, "mulcd", "Yamaha MU/VL70/FS1R common LCD")
ROM_START( mulcd )
ROM_REGION( 524998, "screen", 0)
ROM_LOAD( "mulcd.svg", 0, 524998, CRC(fe07d6c6) SHA1(57a760f77f0f458c8657491f77db2057edc767aa))
ROM_REGION( 0x1000, "hd44780", 0)
// Hand made, 3 characters unused
ROM_LOAD( "mu100-font.bin", 0x0000, 0x1000, BAD_DUMP CRC(a7d6c1d6) SHA1(9f0398d678bdf607cb34d83ee535f3b7fcc97c41) )
@ -24,12 +25,15 @@ const tiny_rom_entry *mulcd_device::device_rom_region() const
mulcd_device::mulcd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, MULCD, tag, owner, clock),
m_lcd(*this, "hd44780")
m_lcd(*this, "hd44780"),
m_outputs(*this, "%03x.%d.%d", 0U, 0U, 0U),
m_led_outputs(*this, "LED%d", 0U)
{
}
void mulcd_device::device_start()
{
m_outputs.resolve();
}
void mulcd_device::device_reset()
@ -38,51 +42,32 @@ void mulcd_device::device_reset()
m_leds = 0;
}
float mulcd_device::lightlevel(const u8 *src, const u8 *render)
void mulcd_device::set_contrast(float contrast)
{
u8 l = *src;
if(l == 0)
return 1.0;
int slot = (src[1] << 8) | src[2];
if(slot >= 0xff00)
return (255-l)/255.0;
int bit = slot & 7;
int adr = (slot >> 3);
if(render[adr] & (1 << bit))
return 1-(1-(255-l)/255.0f)*m_contrast;
return 0.95f;
m_contrast = contrast;
}
u32 mulcd_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
void mulcd_device::set_leds(u8 leds)
{
m_leds = leds;
for(int x=0; x != 6; x++)
m_led_outputs[x] = (leds >> x) & 1;
}
WRITE_LINE_MEMBER(mulcd_device::render_w)
{
if(!state)
return;
const u8 *render = m_lcd->render();
const u8 *src = mulcd_bkg + 15;
for(int y=0; y<241; y++) {
u32 *pix = reinterpret_cast<u32 *>(bitmap.raw_pixptr(y));
for(int x=0; x<800; x++) {
float light = lightlevel(src, render);
u32 col = (int(0xef*light) << 16) | (int(0xf5*light) << 8);
*pix++ = col;
src += 3;
for(int x=0; x != 64; x++) {
for(int y=0; y != 8; y++) {
u8 v = *render++;
for(int z=0; z != 5; z++)
m_outputs[x][y][z] = (v >> z) & 1;
}
for(int x=800; x<900; x++)
*pix++ = 0;
render += 8;
}
for(int i=0; i<6; i++)
if(m_leds & (1 << i)) {
int x = 830 + 40*(i & 1);
int y = 55 + 65*(i >> 1);
for(int yy=-9; yy <= 9; yy++) {
int dx = int(sqrt((float)(99-yy*yy)));
u32 *pix = reinterpret_cast<u32 *>(bitmap.raw_pixptr(y+yy)) + (x-dx);
for(int xx=0; xx<2*dx+1; xx++)
*pix++ = 0x00ff00;
}
}
return 0;
}
void mulcd_device::device_add_mconfig(machine_config &config)
@ -90,10 +75,10 @@ void mulcd_device::device_add_mconfig(machine_config &config)
HD44780(config, m_lcd);
m_lcd->set_lcd_size(4, 20);
auto &screen = SCREEN(config, "screen", SCREEN_TYPE_LCD);
auto &screen = SCREEN(config, "screen", SCREEN_TYPE_SVG);
screen.set_refresh_hz(50);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate, asynchronous updating anyway */
screen.set_screen_update(FUNC(mulcd_device::screen_update));
screen.set_size(900, 241);
screen.set_visarea(0, 899, 0, 240);
screen.set_size(900, 272);
screen.set_visarea_full();
screen.screen_vblank().set(FUNC(mulcd_device::render_w));
}

View File

@ -17,14 +17,13 @@ class mulcd_device : public device_t
public:
mulcd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
void set_contrast(float contrast) { m_contrast = contrast; }
void set_leds(u8 leds) { m_leds = leds; }
void set_contrast(float contrast);
void set_leds(u8 leds);
u8 data_read() { return m_lcd->data_r(); }
u8 control_read() { return m_lcd->control_r(); }
void data_write(u8 data) { m_lcd->data_w(data); }
void control_write(u8 data) { m_lcd->control_w(data); }
protected:
virtual void device_start() override;
virtual void device_reset() override;
@ -33,12 +32,13 @@ protected:
private:
required_device<hd44780_device> m_lcd;
output_finder<64, 8, 5> m_outputs;
output_finder<6> m_led_outputs;
float m_contrast;
u8 m_leds;
float lightlevel(const u8 *src, const u8 *render);
u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(render_w);
};
DECLARE_DEVICE_TYPE(MULCD, mulcd_device)

Binary file not shown.