mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
pc6001.cpp: major encapsulation clean-ups [Angelo Salese]
This commit is contained in:
parent
aadfca9eea
commit
c5e901fbcb
@ -2472,6 +2472,8 @@ files {
|
||||
MAME_DIR .. "src/mame/machine/pce_cd.h",
|
||||
MAME_DIR .. "src/mame/drivers/pcfx.cpp",
|
||||
MAME_DIR .. "src/mame/drivers/pc6001.cpp",
|
||||
MAME_DIR .. "src/mame/includes/pc6001.h",
|
||||
MAME_DIR .. "src/mame/video/pc6001.cpp",
|
||||
MAME_DIR .. "src/mame/drivers/pc8401a.cpp",
|
||||
MAME_DIR .. "src/mame/includes/pc8401a.h",
|
||||
MAME_DIR .. "src/mame/video/pc8401a.cpp",
|
||||
|
File diff suppressed because it is too large
Load Diff
252
src/mame/includes/pc6001.h
Normal file
252
src/mame/includes/pc6001.h
Normal file
@ -0,0 +1,252 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Angelo Salese
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __PC6001__
|
||||
#define __PC6001__
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include "machine/i8251.h"
|
||||
#include "machine/i8255.h"
|
||||
#include "machine/timer.h"
|
||||
#include "sound/ay8910.h"
|
||||
#include "sound/upd7752.h"
|
||||
#include "sound/wave.h"
|
||||
#include "video/mc6847.h"
|
||||
|
||||
#include "bus/generic/slot.h"
|
||||
#include "bus/generic/carts.h"
|
||||
|
||||
#include "speaker.h"
|
||||
|
||||
#include "formats/p6001_cas.h"
|
||||
|
||||
class pc6001_state : public driver_device
|
||||
{
|
||||
public:
|
||||
pc6001_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_ppi(*this, "ppi8255"),
|
||||
m_ram(*this, "ram"),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_cassette(*this, "cassette"),
|
||||
m_cas_hack(*this, "cas_hack"),
|
||||
m_cart(*this, "cartslot"),
|
||||
m_region_maincpu(*this, "maincpu"),
|
||||
m_region_gfx1(*this, "gfx1"),
|
||||
m_io_mode4_dsw(*this, "MODE4_DSW"),
|
||||
m_io_p1(*this, "P1"),
|
||||
m_io_p2(*this, "P2"),
|
||||
m_io_keys(*this, {"key1", "key2", "key3"}),
|
||||
m_io_key_modifiers(*this, "key_modifiers"),
|
||||
m_bank1(*this, "bank1"),
|
||||
m_palette(*this, "palette") { }
|
||||
|
||||
DECLARE_WRITE8_MEMBER(system_latch_w);
|
||||
DECLARE_READ8_MEMBER(nec_ppi8255_r);
|
||||
DECLARE_WRITE8_MEMBER(nec_ppi8255_w);
|
||||
|
||||
DECLARE_PALETTE_INIT(pc6001);
|
||||
|
||||
uint32_t screen_update_pc6001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
|
||||
INTERRUPT_GEN_MEMBER(vrtc_irq);
|
||||
TIMER_CALLBACK_MEMBER(audio_callback);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(cassette_callback);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(keyboard_callback);
|
||||
|
||||
DECLARE_READ8_MEMBER(ppi_porta_r);
|
||||
DECLARE_WRITE8_MEMBER(ppi_porta_w);
|
||||
DECLARE_READ8_MEMBER(ppi_portb_r);
|
||||
DECLARE_WRITE8_MEMBER(ppi_portb_w);
|
||||
DECLARE_WRITE8_MEMBER(ppi_portc_w);
|
||||
DECLARE_READ8_MEMBER(ppi_portc_r);
|
||||
|
||||
IRQ_CALLBACK_MEMBER(irq_callback);
|
||||
|
||||
void pc6001(machine_config &config);
|
||||
protected:
|
||||
required_device<i8255_device> m_ppi;
|
||||
optional_shared_ptr<uint8_t> m_ram;
|
||||
required_device<cpu_device> m_maincpu;
|
||||
optional_device<cassette_image_device> m_cassette;
|
||||
optional_device<generic_slot_device> m_cas_hack;
|
||||
required_device<generic_slot_device> m_cart;
|
||||
required_memory_region m_region_maincpu;
|
||||
required_memory_region m_region_gfx1;
|
||||
required_ioport m_io_mode4_dsw;
|
||||
required_ioport m_io_p1;
|
||||
required_ioport m_io_p2;
|
||||
required_ioport_array<3> m_io_keys;
|
||||
required_ioport m_io_key_modifiers;
|
||||
required_memory_bank m_bank1;
|
||||
required_device<palette_device> m_palette;
|
||||
|
||||
memory_region *m_cart_rom;
|
||||
uint8_t m_timer_irq_vector;
|
||||
uint16_t m_timer_hz_div;
|
||||
|
||||
virtual void machine_start() override;
|
||||
virtual void machine_reset() override;
|
||||
virtual void video_start() override;
|
||||
|
||||
// i/o functions
|
||||
uint8_t check_joy_press();
|
||||
uint8_t check_keyboard_press();
|
||||
inline void cassette_latch_control(bool new_state);
|
||||
inline void ppi_control_hack_w(uint8_t data);
|
||||
|
||||
// video functions
|
||||
void draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr);
|
||||
void draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &cliprect, int attr);
|
||||
void draw_tile_3bpp(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr);
|
||||
void draw_tile_text(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr,int has_mc6847);
|
||||
void draw_border(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr,int has_mc6847);
|
||||
void pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &cliprect, int has_mc6847);
|
||||
|
||||
emu_timer *m_timer_irq_timer;
|
||||
uint8_t *m_video_ram;
|
||||
uint8_t m_irq_vector;
|
||||
uint8_t m_cas_switch;
|
||||
uint8_t m_sys_latch;
|
||||
uint32_t m_cas_offset;
|
||||
uint32_t m_cas_maxsize;
|
||||
uint8_t m_gfx_bank_on;
|
||||
uint8_t m_bank_opt;
|
||||
uint8_t m_timer_irq_mask;
|
||||
uint8_t m_timer_irq_mask2;
|
||||
uint8_t m_port_c_8255;
|
||||
uint8_t m_cur_keycode;
|
||||
|
||||
private:
|
||||
uint32_t m_old_key1;
|
||||
uint32_t m_old_key2;
|
||||
uint32_t m_old_key3;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class pc6001mk2_state : public pc6001_state
|
||||
{
|
||||
public:
|
||||
pc6001mk2_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: pc6001_state(mconfig, type, tag),
|
||||
m_bank2(*this, "bank2"),
|
||||
m_bank3(*this, "bank3"),
|
||||
m_bank4(*this, "bank4"),
|
||||
m_bank5(*this, "bank5"),
|
||||
m_bank6(*this, "bank6"),
|
||||
m_bank7(*this, "bank7"),
|
||||
m_bank8(*this, "bank8")
|
||||
{}
|
||||
|
||||
DECLARE_READ8_MEMBER(mk2_bank_r0_r);
|
||||
DECLARE_READ8_MEMBER(mk2_bank_r1_r);
|
||||
DECLARE_READ8_MEMBER(mk2_bank_w0_r);
|
||||
DECLARE_WRITE8_MEMBER(mk2_bank_r0_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_bank_r1_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_bank_w0_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_opt_bank_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram0_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram1_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram2_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram3_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram4_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram5_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram6_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_work_ram7_w);
|
||||
DECLARE_WRITE8_MEMBER(necmk2_ppi8255_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_system_latch_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_vram_bank_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_col_bank_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_0xf3_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_timer_adj_w);
|
||||
DECLARE_WRITE8_MEMBER(mk2_timer_irqv_w);
|
||||
|
||||
DECLARE_MACHINE_RESET(pc6001mk2);
|
||||
DECLARE_PALETTE_INIT(pc6001mk2);
|
||||
void pc6001mk2(machine_config &config);
|
||||
|
||||
uint32_t screen_update_pc6001mk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
|
||||
protected:
|
||||
uint8_t m_bgcol_bank;
|
||||
required_memory_bank m_bank2;
|
||||
required_memory_bank m_bank3;
|
||||
required_memory_bank m_bank4;
|
||||
required_memory_bank m_bank5;
|
||||
required_memory_bank m_bank6;
|
||||
required_memory_bank m_bank7;
|
||||
required_memory_bank m_bank8;
|
||||
|
||||
private:
|
||||
uint8_t m_bank_r0;
|
||||
uint8_t m_bank_r1;
|
||||
uint8_t m_bank_w;
|
||||
uint8_t m_ex_vram_bank;
|
||||
uint8_t m_exgfx_text_mode;
|
||||
uint32_t m_cgrom_bank_addr;
|
||||
uint8_t m_exgfx_bitmap_mode;
|
||||
uint8_t m_exgfx_2bpp_mode;
|
||||
|
||||
void vram_bank_change(uint8_t vram_bank);
|
||||
};
|
||||
|
||||
class pc6601_state : public pc6001mk2_state
|
||||
{
|
||||
public:
|
||||
pc6601_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: pc6001mk2_state(mconfig, type, tag)
|
||||
{}
|
||||
|
||||
DECLARE_READ8_MEMBER(fdc_r);
|
||||
DECLARE_WRITE8_MEMBER(fdc_w);
|
||||
|
||||
void pc6601(machine_config &config);
|
||||
};
|
||||
|
||||
class pc6001sr_state : public pc6601_state
|
||||
{
|
||||
public:
|
||||
pc6001sr_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: pc6601_state(mconfig, type, tag)
|
||||
{};
|
||||
|
||||
DECLARE_READ8_MEMBER(sr_bank_rn_r);
|
||||
DECLARE_WRITE8_MEMBER(sr_bank_rn_w);
|
||||
DECLARE_READ8_MEMBER(sr_bank_wn_r);
|
||||
DECLARE_WRITE8_MEMBER(sr_bank_wn_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram0_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram1_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram2_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram3_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram4_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram5_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram6_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_work_ram7_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_mode_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_vram_bank_w);
|
||||
DECLARE_WRITE8_MEMBER(sr_system_latch_w);
|
||||
DECLARE_WRITE8_MEMBER(necsr_ppi8255_w);
|
||||
|
||||
INTERRUPT_GEN_MEMBER(sr_vrtc_irq);
|
||||
|
||||
DECLARE_MACHINE_RESET(pc6001sr);
|
||||
|
||||
uint32_t screen_update_pc6001sr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
|
||||
void pc6001sr(machine_config &config);
|
||||
|
||||
private:
|
||||
uint8_t m_sr_bank_r[8];
|
||||
uint8_t m_sr_bank_w[8];
|
||||
uint8_t m_kludge;
|
||||
uint8_t m_sr_video_mode;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
614
src/mame/video/pc6001.cpp
Normal file
614
src/mame/video/pc6001.cpp
Normal file
@ -0,0 +1,614 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Angelo Salese
|
||||
/*******************************************************************
|
||||
*
|
||||
* PC6xxx video related functions
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "includes/pc6001.h"
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
* Palette Inits
|
||||
*
|
||||
****************************************/
|
||||
|
||||
static const rgb_t defcolors[] =
|
||||
{
|
||||
rgb_t(0x07, 0xff, 0x00), /* GREEN */
|
||||
rgb_t(0xff, 0xff, 0x00), /* YELLOW */
|
||||
rgb_t(0x3b, 0x08, 0xff), /* BLUE */
|
||||
rgb_t(0xcc, 0x00, 0x3b), /* RED */
|
||||
rgb_t(0xff, 0xff, 0xff), /* BUFF */
|
||||
rgb_t(0x07, 0xe3, 0x99), /* CYAN */
|
||||
rgb_t(0xff, 0x1c, 0xff), /* MAGENTA */
|
||||
rgb_t(0xff, 0x81, 0x00), /* ORANGE */
|
||||
|
||||
/* MC6847 specific */
|
||||
rgb_t(0x00, 0x7c, 0x00), /* ALPHANUMERIC DARK GREEN */
|
||||
rgb_t(0x07, 0xff, 0x00), /* ALPHANUMERIC BRIGHT GREEN */
|
||||
rgb_t(0x91, 0x00, 0x00), /* ALPHANUMERIC DARK ORANGE */
|
||||
rgb_t(0xff, 0x81, 0x00) /* ALPHANUMERIC BRIGHT ORANGE */
|
||||
};
|
||||
|
||||
static const rgb_t mk2_defcolors[] =
|
||||
{
|
||||
rgb_t(0x00, 0x00, 0x00), /* BLACK */
|
||||
rgb_t(0xff, 0xaf, 0x00), /* ORANGE */
|
||||
rgb_t(0x00, 0xff, 0xaf), /* tone of GREEN */
|
||||
rgb_t(0xaf, 0xff, 0x00), /* tone of GREEN */
|
||||
rgb_t(0xaf, 0x00, 0xff), /* VIOLET */
|
||||
rgb_t(0xff, 0x00, 0xaf), /* SCARLET */
|
||||
rgb_t(0x00, 0xaf, 0xff), /* LIGHT BLUE */
|
||||
rgb_t(0xaf, 0xaf, 0xaf), /* GRAY */
|
||||
rgb_t(0x00, 0x00, 0x00), /* BLACK */
|
||||
rgb_t(0xff, 0x00, 0x00), /* RED */
|
||||
rgb_t(0x00, 0xff, 0x00), /* GREEN */
|
||||
rgb_t(0xff, 0xff, 0x00), /* YELLOW */
|
||||
rgb_t(0x00, 0x00, 0xff), /* BLUE */
|
||||
rgb_t(0xff, 0x00, 0xff), /* PINK */
|
||||
rgb_t(0x00, 0xff, 0xff), /* CYAN */
|
||||
rgb_t(0xff, 0xff, 0xff) /* WHITE */
|
||||
};
|
||||
|
||||
PALETTE_INIT_MEMBER(pc6001_state, pc6001)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<8+4;i++)
|
||||
palette.set_pen_color(i+8,defcolors[i]);
|
||||
}
|
||||
|
||||
PALETTE_INIT_MEMBER(pc6001mk2_state,pc6001mk2)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<8;i++)
|
||||
palette.set_pen_color(i+8,defcolors[i]);
|
||||
|
||||
for(i=0x10;i<0x20;i++)
|
||||
palette.set_pen_color(i,mk2_defcolors[i-0x10]);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
* Video functions
|
||||
*
|
||||
****************************************/
|
||||
|
||||
// MC6847 old interfacing code
|
||||
#ifdef UNUSED_FUNCTION
|
||||
ATTR_CONST pc6001_state::uint8_t pc6001_get_attributes(uint8_t c,int scanline, int pos)
|
||||
{
|
||||
uint8_t result = 0x00;
|
||||
uint8_t val = m_video_ram [(scanline / 12) * 0x20 + pos];
|
||||
|
||||
if (val & 0x01) {
|
||||
result |= M6847_INV;
|
||||
}
|
||||
if (val & 0x40)
|
||||
result |= M6847_AG | M6847_GM1; //TODO
|
||||
|
||||
result |= M6847_INTEXT; // always use external ROM
|
||||
return result;
|
||||
}
|
||||
|
||||
const pc6001_state::uint8_t *pc6001_get_video_ram(int scanline)
|
||||
{
|
||||
return m_video_ram +0x0200+ (scanline / 12) * 0x20;
|
||||
}
|
||||
|
||||
uint8_t pc6001_state::pc6001_get_char_rom(uint8_t ch, int line)
|
||||
{
|
||||
uint8_t *gfx = m_region_gfx1->base();
|
||||
return gfx[ch*16+line];
|
||||
}
|
||||
#endif
|
||||
|
||||
void pc6001_state::video_start()
|
||||
{
|
||||
#if 0
|
||||
m6847_config cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
cfg.type = M6847_VERSION_M6847T1_NTSC;
|
||||
cfg.get_attributes = pc6001_get_attributes;
|
||||
cfg.get_video_ram = pc6001_get_video_ram;
|
||||
cfg.get_char_rom = pc6001_get_char_rom;
|
||||
m6847_init(machine(), &cfg);
|
||||
#endif
|
||||
m_video_ram = auto_alloc_array(machine(), uint8_t, 0x4000);
|
||||
}
|
||||
|
||||
/* this is known as gfx mode 4 */
|
||||
void pc6001_state::draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr)
|
||||
{
|
||||
int x,y,xi;
|
||||
int fgcol,color;
|
||||
int col_setting;
|
||||
static const uint8_t pen_gattr[4][4] = {
|
||||
{ 0, 1, 6, 2 }, //Red / Blue
|
||||
{ 0, 6, 1, 2 }, //Blue / Red
|
||||
{ 0, 5, 2, 2 }, //Pink / Green
|
||||
{ 0, 2, 5, 2 }, //Green / Pink
|
||||
};
|
||||
static const uint8_t pen_wattr[4][4] = {
|
||||
{ 0, 1, 6, 7 }, //Red / Blue
|
||||
{ 0, 6, 1, 7 }, //Blue / Red
|
||||
{ 0, 5, 2, 7 }, //Pink / Green
|
||||
{ 0, 2, 5, 7 }, //Green / Pink
|
||||
};
|
||||
col_setting = m_io_mode4_dsw->read() & 7;
|
||||
|
||||
if((attr & 0x0c) != 0x0c)
|
||||
popmessage("Mode 4 vram attr != 0x0c, contact MESSdev");
|
||||
|
||||
for(y=0;y<192;y++)
|
||||
{
|
||||
for(x=0;x<32;x++)
|
||||
{
|
||||
int tile = m_video_ram[(x+(y*32))+0x200];
|
||||
|
||||
if(col_setting == 0x00) //monochrome
|
||||
{
|
||||
for(xi=0;xi<8;xi++)
|
||||
{
|
||||
fgcol = (attr & 2) ? 7 : 2;
|
||||
|
||||
color = ((tile)>>(7-xi) & 1) ? fgcol : 0;
|
||||
|
||||
bitmap.pix16((y+24), (x*8+xi)+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(xi=0;xi<4;xi++)
|
||||
{
|
||||
fgcol = ((tile)>>(6-(xi*2)) & 3);
|
||||
|
||||
color = (attr & 2) ? (pen_wattr[col_setting-1][fgcol]) : (pen_gattr[col_setting-1][fgcol]);
|
||||
|
||||
bitmap.pix16((y+24), ((x*8+xi*2)+0)+32) = m_palette->pen(color);
|
||||
bitmap.pix16((y+24), ((x*8+xi*2)+1)+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &cliprect, int attr)
|
||||
{
|
||||
int color,x,y,xi,yi;
|
||||
|
||||
int shrink_x = 2*4;
|
||||
int shrink_y = (attr & 8) ? 1 : 2;
|
||||
int w = (shrink_x == 8) ? 32 : 16;
|
||||
int col_bank = ((attr & 2)<<1);
|
||||
|
||||
if(attr & 4)
|
||||
{
|
||||
for(y=0;y<(192/shrink_y);y++)
|
||||
{
|
||||
for(x=0;x<w;x++)
|
||||
{
|
||||
int tile = m_video_ram[(x+(y*32))+0x200];
|
||||
|
||||
for(yi=0;yi<shrink_y;yi++)
|
||||
{
|
||||
for(xi=0;xi<shrink_x;xi++)
|
||||
{
|
||||
int i;
|
||||
i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
|
||||
color = ((tile >> i) & 3)+8;
|
||||
color+= col_bank;
|
||||
|
||||
bitmap.pix16(((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* TODO: clean this up */
|
||||
{
|
||||
for(y=0;y<(192/shrink_y);y+=3)
|
||||
{
|
||||
for(x=0;x<w;x++)
|
||||
{
|
||||
int tile = m_video_ram[(x+((y/3)*32))+0x200];
|
||||
|
||||
for(yi=0;yi<shrink_y;yi++)
|
||||
{
|
||||
for(xi=0;xi<shrink_x;xi++)
|
||||
{
|
||||
int i;
|
||||
i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
|
||||
color = ((tile >> i) & 3)+8;
|
||||
color+= col_bank;
|
||||
|
||||
bitmap.pix16((((y+0)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
|
||||
bitmap.pix16((((y+1)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
|
||||
bitmap.pix16((((y+2)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pc6001_state::draw_tile_3bpp(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr)
|
||||
{
|
||||
int color,pen,xi,yi;
|
||||
|
||||
if(attr & 0x10) //2x2 squares on a single cell
|
||||
pen = (tile & 0x70)>>4;
|
||||
else //2x3
|
||||
pen = (tile & 0xc0) >> 6 | (attr & 2)<<1;
|
||||
|
||||
for(yi=0;yi<12;yi++)
|
||||
{
|
||||
for(xi=0;xi<8;xi++)
|
||||
{
|
||||
int i;
|
||||
i = (xi & 4)>>2; //x-axis
|
||||
if(attr & 0x10) //2x2
|
||||
{
|
||||
i+= (yi >= 6) ? 2 : 0; //y-axis
|
||||
}
|
||||
else //2x3
|
||||
{
|
||||
i+= (yi & 4)>>1; //y-axis 1
|
||||
i+= (yi & 8)>>1; //y-axis 2
|
||||
}
|
||||
|
||||
color = ((tile >> i) & 1) ? pen+8 : 0;
|
||||
|
||||
bitmap.pix16(((y*12+(11-yi))+24), (x*8+(7-xi))+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pc6001_state::draw_tile_text(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr,int has_mc6847)
|
||||
{
|
||||
int xi,yi,pen,fgcol,color;
|
||||
uint8_t *gfx_data = m_region_gfx1->base();
|
||||
|
||||
for(yi=0;yi<12;yi++)
|
||||
{
|
||||
for(xi=0;xi<8;xi++)
|
||||
{
|
||||
pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
|
||||
|
||||
if(has_mc6847)
|
||||
{
|
||||
fgcol = (attr & 2) ? 0x12 : 0x10;
|
||||
|
||||
if(attr & 1)
|
||||
color = pen ? (fgcol+0) : (fgcol+1);
|
||||
else
|
||||
color = pen ? (fgcol+1) : (fgcol+0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fgcol = (attr & 2) ? 2 : 7;
|
||||
|
||||
if(attr & 1)
|
||||
color = pen ? 0 : fgcol;
|
||||
else
|
||||
color = pen ? fgcol : 0;
|
||||
}
|
||||
|
||||
bitmap.pix16(((y*12+yi)+24), (x*8+xi)+32) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pc6001_state::draw_border(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr,int has_mc6847)
|
||||
{
|
||||
int x,y,color;
|
||||
|
||||
for(y=0;y<240;y++)
|
||||
{
|
||||
for(x=0;x<320;x++)
|
||||
{
|
||||
if(!has_mc6847) //mk2 border color is always black
|
||||
color = 0;
|
||||
else if((attr & 0x90) == 0x80) //2bpp
|
||||
color = ((attr & 2)<<1) + 8;
|
||||
else if((attr & 0x90) == 0x90) //1bpp
|
||||
color = (attr & 2) ? 7 : 2;
|
||||
else
|
||||
color = 0; //FIXME: other modes not yet checked
|
||||
|
||||
bitmap.pix16(y, x) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pc6001_state::pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &cliprect, int has_mc6847)
|
||||
{
|
||||
int x,y;
|
||||
int tile,attr;
|
||||
|
||||
attr = m_video_ram[0];
|
||||
|
||||
draw_border(bitmap,cliprect,attr,has_mc6847);
|
||||
|
||||
if(attr & 0x80) // gfx mode
|
||||
{
|
||||
if(attr & 0x10) // 256x192x1 mode (FIXME: might be a different trigger)
|
||||
{
|
||||
draw_gfx_mode4(bitmap,cliprect,attr);
|
||||
}
|
||||
else // 128x192x2 mode
|
||||
{
|
||||
draw_bitmap_2bpp(bitmap,cliprect,attr);
|
||||
}
|
||||
}
|
||||
else // text mode
|
||||
{
|
||||
for(y=0;y<16;y++)
|
||||
{
|
||||
for(x=0;x<32;x++)
|
||||
{
|
||||
tile = m_video_ram[(x+(y*32))+0x200];
|
||||
attr = m_video_ram[(x+(y*32)) & 0x1ff];
|
||||
|
||||
if(attr & 0x40)
|
||||
{
|
||||
draw_tile_3bpp(bitmap,cliprect,x,y,tile,attr);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_tile_text(bitmap,cliprect,x,y,tile,attr,has_mc6847);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pc6001_state::screen_update_pc6001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
pc6001_screen_draw(bitmap,cliprect,1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
int x,y,tile,attr;
|
||||
|
||||
/* note: bitmap mode have priority over everything else, check American Truck */
|
||||
if(m_exgfx_bitmap_mode)
|
||||
{
|
||||
int count,color,i;
|
||||
|
||||
count = 0;
|
||||
|
||||
for(y=0;y<200;y++)
|
||||
{
|
||||
for(x=0;x<160;x+=4)
|
||||
{
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
int pen[2];
|
||||
#if 0
|
||||
/* palette reference: */
|
||||
static const uint8_t pal_num[] = { 0x00, 0x04, 0x01, 0x05,
|
||||
0x02, 0x06, 0x03, 0x07,
|
||||
0x08, 0x0c, 0x09, 0x0d,
|
||||
0x0a, 0x0e, 0x0b, 0x0f };
|
||||
|
||||
color |= pal_num[(pen[0] & 3) | ((pen[1] & 3) << 2)];
|
||||
#endif
|
||||
|
||||
pen[0] = m_video_ram[count+0x0000] >> (6-i*2) & 3;
|
||||
pen[1] = m_video_ram[count+0x2000] >> (6-i*2) & 3;
|
||||
|
||||
color = 0x10;
|
||||
color |= ((pen[0] & 1) << 2);
|
||||
color |= ((pen[0] & 2) >> 1);
|
||||
color |= ((pen[1] & 1) << 1);
|
||||
color |= ((pen[1] & 2) << 2);
|
||||
|
||||
if (cliprect.contains((x+i)*2+0, y))
|
||||
bitmap.pix16(y, (x+i)*2+0) = m_palette->pen(color);
|
||||
if (cliprect.contains((x+i)*2+1, y))
|
||||
bitmap.pix16(y, (x+i)*2+1) = m_palette->pen(color);
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_exgfx_2bpp_mode)
|
||||
{
|
||||
int count,color,i;
|
||||
|
||||
count = 0;
|
||||
|
||||
for(y=0;y<200;y++)
|
||||
{
|
||||
for(x=0;x<320;x+=8)
|
||||
{
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
int pen[2];
|
||||
#if 0
|
||||
/* palette reference: */
|
||||
static const uint8_t pal_num[] = { 0x00, 0x04, 0x01, 0x05 };
|
||||
|
||||
color |= pal_num[(pen[0] & 1) | ((pen[1] & 1) << 1)];
|
||||
#endif
|
||||
|
||||
pen[0] = m_video_ram[count+0x0000] >> (7-i) & 1;
|
||||
pen[1] = m_video_ram[count+0x2000] >> (7-i) & 1;
|
||||
|
||||
if(m_bgcol_bank & 4) //PC-6001 emulation mode
|
||||
{
|
||||
color = 0x08;
|
||||
color |= (pen[0]) | (pen[1]<<1);
|
||||
color |= (m_bgcol_bank & 1) << 2;
|
||||
}
|
||||
else //Mk-2 mode
|
||||
{
|
||||
color = 0x10;
|
||||
color |= ((pen[0] & 1) << 2);
|
||||
color |= ((pen[1] & 1) >> 0);
|
||||
color |= ((m_bgcol_bank & 1) << 1);
|
||||
color |= ((m_bgcol_bank & 2) << 2);
|
||||
}
|
||||
|
||||
if (cliprect.contains(x+i, y))
|
||||
bitmap.pix16(y, (x+i)) = m_palette->pen(color);
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(m_exgfx_text_mode)
|
||||
{
|
||||
int xi,yi,pen,fgcol,bgcol,color;
|
||||
uint8_t *gfx_data = m_region_gfx1->base();
|
||||
|
||||
for(y=0;y<20;y++)
|
||||
{
|
||||
for(x=0;x<40;x++)
|
||||
{
|
||||
/*
|
||||
exgfx attr format:
|
||||
x--- ---- rom bank select
|
||||
-xxx ---- bg color
|
||||
---- xxxx fg color
|
||||
Note that the exgfx banks a different gfx ROM
|
||||
*/
|
||||
tile = m_video_ram[(x+(y*40))+0x400] + 0x200;
|
||||
attr = m_video_ram[(x+(y*40)) & 0x3ff];
|
||||
tile+= ((attr & 0x80) << 1);
|
||||
|
||||
for(yi=0;yi<12;yi++)
|
||||
{
|
||||
for(xi=0;xi<8;xi++)
|
||||
{
|
||||
pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
|
||||
|
||||
fgcol = (attr & 0x0f) + 0x10;
|
||||
bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
|
||||
|
||||
color = pen ? fgcol : bgcol;
|
||||
|
||||
if (cliprect.contains(x*8+xi, y*12+yi))
|
||||
bitmap.pix16(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//attr = m_video_ram[0];
|
||||
pc6001_screen_draw(bitmap,cliprect,0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pc6001sr_state::screen_update_pc6001sr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
int x,y,tile,attr;
|
||||
int xi,yi,pen,fgcol,bgcol,color;
|
||||
uint8_t *gfx_data = m_region_gfx1->base();
|
||||
|
||||
|
||||
if(m_sr_video_mode & 8) // text mode
|
||||
{
|
||||
for(y=0;y<20;y++)
|
||||
{
|
||||
for(x=0;x<40;x++)
|
||||
{
|
||||
tile = m_video_ram[(x+(y*40))*2+0];
|
||||
attr = m_video_ram[(x+(y*40))*2+1];
|
||||
tile+= ((attr & 0x80) << 1);
|
||||
|
||||
for(yi=0;yi<12;yi++)
|
||||
{
|
||||
for(xi=0;xi<8;xi++)
|
||||
{
|
||||
pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
|
||||
|
||||
fgcol = (attr & 0x0f) + 0x10;
|
||||
bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
|
||||
|
||||
color = pen ? fgcol : bgcol;
|
||||
|
||||
if (cliprect.contains(x*8+xi, y*12+yi))
|
||||
bitmap.pix16(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //4bpp bitmap mode (TODO)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
|
||||
for(y=0;y<200;y+=2)
|
||||
{
|
||||
for(x=0;x<320;x+=4)
|
||||
{
|
||||
color = m_video_ram[count] & 0x0f;
|
||||
|
||||
if (cliprect.contains(x+0, y+0))
|
||||
bitmap.pix16((y+0), (x+0)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = (m_video_ram[count] & 0xf0) >> 4;
|
||||
|
||||
if (cliprect.contains(x+1, y+0))
|
||||
bitmap.pix16((y+0), (x+1)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = m_video_ram[count+1] & 0x0f;
|
||||
|
||||
if (cliprect.contains(x+2, y+0))
|
||||
bitmap.pix16((y+0), (x+2)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = (m_video_ram[count+1] & 0xf0) >> 4;
|
||||
|
||||
if (cliprect.contains(x+3, y+0))
|
||||
bitmap.pix16((y+0), (x+3)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = m_video_ram[count+2] & 0x0f;
|
||||
|
||||
if (cliprect.contains(x+0, y+1))
|
||||
bitmap.pix16((y+1), (x+0)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = (m_video_ram[count+2] & 0xf0) >> 4;
|
||||
|
||||
if (cliprect.contains(x+1, y+1))
|
||||
bitmap.pix16((y+1), (x+1)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = m_video_ram[count+3] & 0x0f;
|
||||
|
||||
if (cliprect.contains(x+2, y+1))
|
||||
bitmap.pix16((y+1), (x+2)) = m_palette->pen(color+0x10);
|
||||
|
||||
color = (m_video_ram[count+3] & 0xf0) >> 4;
|
||||
|
||||
if (cliprect.contains(x+3, y+1))
|
||||
bitmap.pix16((y+1), (x+3)) = m_palette->pen(color+0x10);
|
||||
|
||||
|
||||
count+=4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user