From 1fc48ce120a376c288daeeed98daccecf1b60d7b Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 30 Sep 2015 17:21:14 +0200 Subject: move mess into mame (nw) --- src/mess/video/733_asr.c | 815 --------- src/mess/video/733_asr.h | 88 - src/mess/video/911_chr.h | 3516 ------------------------------------ src/mess/video/911_key.h | 4028 ------------------------------------------ src/mess/video/911_vdt.c | 844 --------- src/mess/video/911_vdt.h | 118 -- src/mess/video/abc1600.c | 1259 ------------- src/mess/video/abc1600.h | 151 -- src/mess/video/abc80.c | 205 --- src/mess/video/abc800.c | 311 ---- src/mess/video/abc802.c | 220 --- src/mess/video/abc806.c | 507 ------ src/mess/video/ac1.c | 61 - src/mess/video/advision.c | 110 -- src/mess/video/alesis.c | 167 -- src/mess/video/apollo.c | 1978 --------------------- src/mess/video/apple1.c | 392 ---- src/mess/video/apple2.c | 1540 ---------------- src/mess/video/apple2.h | 61 - src/mess/video/apple2gs.c | 168 -- src/mess/video/apple3.c | 518 ------ src/mess/video/aquarius.c | 80 - src/mess/video/arcadia.c | 676 ------- src/mess/video/atarist.c | 1131 ------------ src/mess/video/atarist.h | 41 - src/mess/video/aussiebyte.c | 196 -- src/mess/video/avigo.c | 118 -- src/mess/video/b2m.c | 60 - src/mess/video/bbc.c | 306 ---- src/mess/video/bk.c | 40 - src/mess/video/busicom.c | 1860 ------------------- src/mess/video/cgc7900.c | 237 --- src/mess/video/channelf.c | 71 - src/mess/video/comquest.c | 24 - src/mess/video/comx35.c | 126 -- src/mess/video/crt.c | 184 -- src/mess/video/crt.h | 93 - src/mess/video/dai.c | 764 -------- src/mess/video/dgn_beta.c | 286 --- src/mess/video/electron.c | 273 --- src/mess/video/fm7.c | 1493 ---------------- src/mess/video/fmtowns.c | 1729 ------------------ src/mess/video/galaxy.c | 134 -- src/mess/video/galeb.c | 45 - src/mess/video/gamecom.c | 71 - src/mess/video/gb_lcd.c | 2852 ------------------------------ src/mess/video/gb_lcd.h | 215 --- src/mess/video/gba.c | 1901 -------------------- src/mess/video/gime.c | 2077 ---------------------- src/mess/video/gime.h | 311 ---- src/mess/video/hec2video.c | 141 -- src/mess/video/hp48.c | 203 --- src/mess/video/intv.c | 137 -- src/mess/video/k1ge.c | 918 ---------- src/mess/video/k1ge.h | 92 - src/mess/video/kaypro.c | 312 ---- src/mess/video/kc.c | 240 --- src/mess/video/kramermc.c | 46 - src/mess/video/kyocera.c | 89 - src/mess/video/llc.c | 96 - src/mess/video/lviv.c | 91 - src/mess/video/mac.c | 1257 ------------- src/mess/video/maria.c | 484 ----- src/mess/video/maria.h | 72 - src/mess/video/mbc55x.c | 186 -- src/mess/video/mbee.c | 495 ------ src/mess/video/mc80.c | 173 -- src/mess/video/microtan.c | 57 - src/mess/video/mikro80.c | 40 - src/mess/video/mikromik.c | 126 -- src/mess/video/mz700.c | 128 -- src/mess/video/mz80.c | 143 -- src/mess/video/nc.c | 120 -- src/mess/video/nes.c | 62 - src/mess/video/newbrain.c | 130 -- src/mess/video/newport.c | 1667 ----------------- src/mess/video/newport.h | 163 -- src/mess/video/nick.c | 1055 ----------- src/mess/video/nick.h | 178 -- src/mess/video/ondra.c | 47 - src/mess/video/orao.c | 38 - src/mess/video/orion.c | 114 -- src/mess/video/osi.c | 180 -- src/mess/video/p2000m.c | 60 - src/mess/video/pc1251.c | 163 -- src/mess/video/pc1350.c | 165 -- src/mess/video/pc1401.c | 213 --- src/mess/video/pc1403.c | 246 --- src/mess/video/pc1512.c | 606 ------- src/mess/video/pc4.c | 196 -- src/mess/video/pc8401a.c | 102 -- src/mess/video/pc_t1t.c | 1033 ----------- src/mess/video/pc_t1t.h | 147 -- src/mess/video/pcd.c | 396 ----- src/mess/video/pcd.h | 98 - src/mess/video/pcw.c | 187 -- src/mess/video/pcw16.c | 268 --- src/mess/video/pdp1.c | 591 ------- src/mess/video/pecom.c | 109 -- src/mess/video/pk8020.c | 59 - src/mess/video/pocketc.c | 70 - src/mess/video/poisk1.c | 322 ---- src/mess/video/poisk1.h | 10 - src/mess/video/poly88.c | 102 -- src/mess/video/pp01.c | 56 - src/mess/video/primo.c | 47 - src/mess/video/rm380z.c | 406 ----- src/mess/video/rmnimbus.c | 514 ------ src/mess/video/samcoupe.c | 171 -- src/mess/video/special.c | 153 -- src/mess/video/spectrum.c | 298 ---- src/mess/video/ssystem3.c | 236 --- src/mess/video/stic.c | 974 ---------- src/mess/video/stic.h | 559 ------ src/mess/video/super80.c | 426 ----- src/mess/video/thomson.c | 1387 --------------- src/mess/video/ti85.c | 194 -- src/mess/video/timex.c | 270 --- src/mess/video/tmc1800.c | 70 - src/mess/video/tmc600.c | 141 -- src/mess/video/trs80.c | 588 ------ src/mess/video/tx0.c | 469 ----- src/mess/video/ut88.c | 44 - src/mess/video/uv201.c | 589 ------ src/mess/video/uv201.h | 159 -- src/mess/video/v1050.c | 124 -- src/mess/video/vc4000.c | 650 ------- src/mess/video/vector06.c | 61 - src/mess/video/vtech2.c | 312 ---- src/mess/video/vtvideo.c | 956 ---------- src/mess/video/vtvideo.h | 113 -- src/mess/video/wswan_video.c | 1216 ------------- src/mess/video/wswan_video.h | 149 -- src/mess/video/x68k.c | 1267 ------------- src/mess/video/z88.c | 175 -- src/mess/video/zx.c | 223 --- src/mess/video/zx8301.c | 334 ---- src/mess/video/zx8301.h | 123 -- 138 files changed, 62328 deletions(-) delete mode 100644 src/mess/video/733_asr.c delete mode 100644 src/mess/video/733_asr.h delete mode 100644 src/mess/video/911_chr.h delete mode 100644 src/mess/video/911_key.h delete mode 100644 src/mess/video/911_vdt.c delete mode 100644 src/mess/video/911_vdt.h delete mode 100644 src/mess/video/abc1600.c delete mode 100644 src/mess/video/abc1600.h delete mode 100644 src/mess/video/abc80.c delete mode 100644 src/mess/video/abc800.c delete mode 100644 src/mess/video/abc802.c delete mode 100644 src/mess/video/abc806.c delete mode 100644 src/mess/video/ac1.c delete mode 100644 src/mess/video/advision.c delete mode 100644 src/mess/video/alesis.c delete mode 100644 src/mess/video/apollo.c delete mode 100644 src/mess/video/apple1.c delete mode 100644 src/mess/video/apple2.c delete mode 100644 src/mess/video/apple2.h delete mode 100644 src/mess/video/apple2gs.c delete mode 100644 src/mess/video/apple3.c delete mode 100644 src/mess/video/aquarius.c delete mode 100644 src/mess/video/arcadia.c delete mode 100644 src/mess/video/atarist.c delete mode 100644 src/mess/video/atarist.h delete mode 100644 src/mess/video/aussiebyte.c delete mode 100644 src/mess/video/avigo.c delete mode 100644 src/mess/video/b2m.c delete mode 100644 src/mess/video/bbc.c delete mode 100644 src/mess/video/bk.c delete mode 100644 src/mess/video/busicom.c delete mode 100644 src/mess/video/cgc7900.c delete mode 100644 src/mess/video/channelf.c delete mode 100644 src/mess/video/comquest.c delete mode 100644 src/mess/video/comx35.c delete mode 100644 src/mess/video/crt.c delete mode 100644 src/mess/video/crt.h delete mode 100644 src/mess/video/dai.c delete mode 100644 src/mess/video/dgn_beta.c delete mode 100644 src/mess/video/electron.c delete mode 100644 src/mess/video/fm7.c delete mode 100644 src/mess/video/fmtowns.c delete mode 100644 src/mess/video/galaxy.c delete mode 100644 src/mess/video/galeb.c delete mode 100644 src/mess/video/gamecom.c delete mode 100644 src/mess/video/gb_lcd.c delete mode 100644 src/mess/video/gb_lcd.h delete mode 100644 src/mess/video/gba.c delete mode 100644 src/mess/video/gime.c delete mode 100644 src/mess/video/gime.h delete mode 100644 src/mess/video/hec2video.c delete mode 100644 src/mess/video/hp48.c delete mode 100644 src/mess/video/intv.c delete mode 100644 src/mess/video/k1ge.c delete mode 100644 src/mess/video/k1ge.h delete mode 100644 src/mess/video/kaypro.c delete mode 100644 src/mess/video/kc.c delete mode 100644 src/mess/video/kramermc.c delete mode 100644 src/mess/video/kyocera.c delete mode 100644 src/mess/video/llc.c delete mode 100644 src/mess/video/lviv.c delete mode 100644 src/mess/video/mac.c delete mode 100644 src/mess/video/maria.c delete mode 100644 src/mess/video/maria.h delete mode 100644 src/mess/video/mbc55x.c delete mode 100644 src/mess/video/mbee.c delete mode 100644 src/mess/video/mc80.c delete mode 100644 src/mess/video/microtan.c delete mode 100644 src/mess/video/mikro80.c delete mode 100644 src/mess/video/mikromik.c delete mode 100644 src/mess/video/mz700.c delete mode 100644 src/mess/video/mz80.c delete mode 100644 src/mess/video/nc.c delete mode 100644 src/mess/video/nes.c delete mode 100644 src/mess/video/newbrain.c delete mode 100644 src/mess/video/newport.c delete mode 100644 src/mess/video/newport.h delete mode 100644 src/mess/video/nick.c delete mode 100644 src/mess/video/nick.h delete mode 100644 src/mess/video/ondra.c delete mode 100644 src/mess/video/orao.c delete mode 100644 src/mess/video/orion.c delete mode 100644 src/mess/video/osi.c delete mode 100644 src/mess/video/p2000m.c delete mode 100644 src/mess/video/pc1251.c delete mode 100644 src/mess/video/pc1350.c delete mode 100644 src/mess/video/pc1401.c delete mode 100644 src/mess/video/pc1403.c delete mode 100644 src/mess/video/pc1512.c delete mode 100644 src/mess/video/pc4.c delete mode 100644 src/mess/video/pc8401a.c delete mode 100644 src/mess/video/pc_t1t.c delete mode 100644 src/mess/video/pc_t1t.h delete mode 100644 src/mess/video/pcd.c delete mode 100644 src/mess/video/pcd.h delete mode 100644 src/mess/video/pcw.c delete mode 100644 src/mess/video/pcw16.c delete mode 100644 src/mess/video/pdp1.c delete mode 100644 src/mess/video/pecom.c delete mode 100644 src/mess/video/pk8020.c delete mode 100644 src/mess/video/pocketc.c delete mode 100644 src/mess/video/poisk1.c delete mode 100644 src/mess/video/poisk1.h delete mode 100644 src/mess/video/poly88.c delete mode 100644 src/mess/video/pp01.c delete mode 100644 src/mess/video/primo.c delete mode 100644 src/mess/video/rm380z.c delete mode 100644 src/mess/video/rmnimbus.c delete mode 100644 src/mess/video/samcoupe.c delete mode 100644 src/mess/video/special.c delete mode 100644 src/mess/video/spectrum.c delete mode 100644 src/mess/video/ssystem3.c delete mode 100644 src/mess/video/stic.c delete mode 100644 src/mess/video/stic.h delete mode 100644 src/mess/video/super80.c delete mode 100644 src/mess/video/thomson.c delete mode 100644 src/mess/video/ti85.c delete mode 100644 src/mess/video/timex.c delete mode 100644 src/mess/video/tmc1800.c delete mode 100644 src/mess/video/tmc600.c delete mode 100644 src/mess/video/trs80.c delete mode 100644 src/mess/video/tx0.c delete mode 100644 src/mess/video/ut88.c delete mode 100644 src/mess/video/uv201.c delete mode 100644 src/mess/video/uv201.h delete mode 100644 src/mess/video/v1050.c delete mode 100644 src/mess/video/vc4000.c delete mode 100644 src/mess/video/vector06.c delete mode 100644 src/mess/video/vtech2.c delete mode 100644 src/mess/video/vtvideo.c delete mode 100644 src/mess/video/vtvideo.h delete mode 100644 src/mess/video/wswan_video.c delete mode 100644 src/mess/video/wswan_video.h delete mode 100644 src/mess/video/x68k.c delete mode 100644 src/mess/video/z88.c delete mode 100644 src/mess/video/zx.c delete mode 100644 src/mess/video/zx8301.c delete mode 100644 src/mess/video/zx8301.h (limited to 'src/mess/video') diff --git a/src/mess/video/733_asr.c b/src/mess/video/733_asr.c deleted file mode 100644 index da1286d69f5..00000000000 --- a/src/mess/video/733_asr.c +++ /dev/null @@ -1,815 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - 733 ASR emulation - - We are emulating a TI Model 733 ASR ("Silent 700") data terminal, - interfaced through a TI asynchronous EIA/TTY interface module. - - The ASR features a printer, a keyboard and a tape unit (which is not - emulated). The ASR is attached to the computer with a serial interface. - - References: - 945401-9701 Model 990/4 Computer System Field Maintenance Manual p. C-1, - 945250-9701 990 Computer Family Systems Handbook pp. 5-9 through 5-16, - 0943442-9701 Model 990 Computer Reference Manual Preliminary pp. 3-13 - through 3-21 and 3-39 through 3-44. - - TODO: - * separate ASR emulation from EIA interface emulation? - * implement tape interface? - - Raphael Nabet 2003 - - Rewritten as class - Michael Zapf, 2014 -*/ - -#include "emu.h" -#include "733_asr.h" - -enum -{ - /*ASROutQueueSize = 32,*/ - - asr_window_offset_x = 0, - asr_window_offset_y = 0, - asr_window_width = 640, - asr_window_height = 480, - asr_scroll_step = 8 -}; - -enum -{ - AS_wrq_mask = 1 << 3, - AS_rrq_mask = 1 << 4, - AS_dsr_mask = 1 << 6, - AS_int_mask = 1 << 7, - - AM_dtr_mask = 1 << 1, - AM_rts_mask = 1 << 2, - AM_enint_mask = 1 << 6 -}; - -enum -{ - asrfontdata_size = 96/*128*/*8 -}; - -static const gfx_layout fontlayout = -{ - 6, 8, /* 6*8 characters */ - /*96*/128, /* 96 characters */ - 1, /* 1 bit per pixel */ - { 0 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, - 8*8 /* every char takes 8 consecutive bytes */ -}; - -static GFXDECODE_START( asr733 ) - GFXDECODE_ENTRY( asr733_chr_region, 0, fontlayout, 0, 1 ) -GFXDECODE_END - -PALETTE_INIT_MEMBER(asr733_device, asr733) -{ - palette.set_pen_color(0,rgb_t::white); /* white */ - palette.set_pen_color(1,rgb_t::black); /* black */ -} - - -const device_type ASR733 = &device_creator; - -asr733_device::asr733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ASR733, "733 ASR", tag, owner, clock, "asr733", __FILE__), - m_palette(*this, "palette"), - m_gfxdecode(*this, "gfxdecode"), - m_keyint_line(*this), - m_lineint_line(*this) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void asr733_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void asr733_device::device_start() -{ - screen_device *screen = machine().first_screen(); - int width = screen->width(); - int height = screen->height(); - const rectangle &visarea = screen->visible_area(); - - m_last_key_pressed = 0x80; - m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); - - m_bitmap->fill(0, visarea); - - m_keyint_line.resolve(); - m_lineint_line.resolve(); - - m_line_timer = timer_alloc(0); - - UINT8 *dst; - - static const unsigned char fontdata6x8[asrfontdata_size] = - { /* ASCII characters */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, - 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00, - 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08, - 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00, - 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00, - 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00, - 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00, - 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00, - 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00, - 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00, - 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00, - 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60, - 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00, - 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00, - 0x70,0x88,0xb8,0xa8,0xb8,0x80,0x70,0x00,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00, - 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00, - 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00, - 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00, - 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, - 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00, - 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00, - 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, - 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08, - 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, - 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, - 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00, - 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00, - 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00, - 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00, - 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc, - 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00, - 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00, - 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, - 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70, - 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00, - 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00, - 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00, - 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08, - 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00, - 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00, - 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00, - 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70, - 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00, - 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00 - }; - - dst = machine().root_device().memregion(asr733_chr_region)->base(); - - memcpy(dst, fontdata6x8, asrfontdata_size); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void asr733_device::device_reset() -{ - /*m_OutQueueLen = 0;*/ - - m_status = AS_dsr_mask | AS_wrq_mask; - m_mode = 0; - m_line_timer->adjust(attotime::from_msec(0), 0, attotime::from_hz(60)); - - set_interrupt_line(); -} - -void asr733_device::set_interrupt_line() -{ - if ((m_mode & AM_enint_mask) && (m_new_status_flag)) /* right??? */ - { - m_status |= AS_int_mask; - m_keyint_line(ASSERT_LINE); - } - else - { - m_status &= ~AS_int_mask; - m_keyint_line(CLEAR_LINE); - } -} - -/* write a single char on screen */ -void asr733_device::draw_char(int character, int x, int y, int color) -{ - m_gfxdecode->gfx(0)->opaque(*m_bitmap, m_bitmap->cliprect(), character-32, color, 0, 0, x+1, y); -} - -void asr733_device::linefeed() -{ - UINT8 buf[asr_window_width]; - - for (int y=asr_window_offset_y; ypens()); - } - - const rectangle asr_scroll_clear_window( - asr_window_offset_x, /* min_x */ - asr_window_offset_x+asr_window_width-1, /* max_x */ - asr_window_offset_y+asr_window_height-asr_scroll_step, /* min_y */ - asr_window_offset_y+asr_window_height-1 /* max_y */ - ); - m_bitmap->fill(0, asr_scroll_clear_window); -} - -void asr733_device::transmit(UINT8 data) -{ - switch (data) - { - /* aux device control chars */ - case 0x05: - /* ENQ -> "WRU": ??? */ - break; - - case 0x11: - /* DC1 -> "X-ON": transmit on??? */ - break; - - case 0x12: - /* DC2 -> "X-OFF": transmit off??? */ - break; - - case 0x13: - /* DC3 -> "TAPE": tape on??? */ - break; - - case 0x14: - /* DC4 -> "-T-A-P-E-" ("TAPE" with overstrike): tape off??? */ - break; - - - /* printer control chars */ - case 0x07: - /* BELL: 250ms beep */ - break; - - case 0x08: - /* BS: backspace */ - if (m_x > 0) - m_x--; - break; - - case 0x0A: - /* LF: line feed */ - linefeed(); - break; - - case 0x0D: - /* CR: carriage return */ - m_x = 0; - break; - - - default: - if ((data < 0x20) || (data == 0x7f) || (data >= 0x80)) - /* ignore control characters */ - break; - - if (m_x == 80) - { - m_x = 0; - linefeed(); - } - draw_char(data, asr_window_offset_x + m_x*8, asr_window_offset_y+asr_window_height-8, 0); - m_x++; - break; - } - - m_status |= AS_wrq_mask; - m_new_status_flag = 1; /* right??? */ - set_interrupt_line(); -} - -#if 0 -void asr733_device::receive_callback(int dummy) -{ - (void) dummy; - - m_recv_buf = m_OutQueue[m_OutQueueHead]; - m_OutQueueHead = (m_OutQueueHead + 1) % ASROutQueueSize; - m_OutQueueLen--; - - m_status |= AS_rrq_mask; - m_new_status_flag = 1; /* right??? */ - set_interrupt_line(); -} -#endif - -/* - 0-7: receive buffer - 8: XMITING transmit in progress, 1 if transmitting - 9: TIMERR timing error, 1 if error - 10: RCR reverse channel receive, not used - "ASR733/33 ID" 1 -> TTY (???) (2270509-9701 pp. G-9 & G-10) - 11: WRQ write request, 1 if ready to transmit - 12: RRQ read request, 1 if ready to receive - 13: DCD data carrier detect, not used - 14: DSR data set ready, 1 if online - 15: INT interrupt, 1 if interrupt -*/ -READ8_MEMBER( asr733_device::cru_r ) -{ - int reply = 0; - - switch (offset) - { - case 0: - /* receive buffer */ - reply = m_recv_buf; - break; - - case 1: - /* status register */ - reply = m_status; - break; - } - - return reply; -} - -/* - 0-7: transmit buffer - 8: not used - 9: DTR data terminal ready (set to 1) - 10: RTS request to send (set to 1) - 11: CLRWRQ clear write request (write any value to execute) - 12: CLRRRQ clear read request (write any value to execute) - 13: CLRNSF clear new status flag - clear DSR/DCD interrupts (write any value to execute) - 14: enable interrupts, 1 to enable interrupts - 15: diagnostic mode, 0 for normal mode -*/ -WRITE8_MEMBER( asr733_device::cru_w ) -{ - switch (offset) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - /* transmit buffer */ - if (data) - m_xmit_buf |= 1 << offset; - else - m_xmit_buf &= ~ (1 << offset); - if ((offset == 7) && (m_mode & AM_dtr_mask) && (m_mode & AM_rts_mask)) /* right??? */ - transmit(m_xmit_buf); - break; - - case 8: /* not used */ - break; - - case 9: /* data terminal ready (set to 1) */ - case 10: /* request to send (set to 1) */ - case 14: /* enable interrupts, 1 to enable interrupts */ - case 15: /* diagnostic mode, 0 for normal mode */ - if (data) - m_mode |= 1 << (offset - 8); - else - m_mode &= ~ (1 << (offset - 8)); - if (offset == 14) - set_interrupt_line(); - break; - - case 11: /* clear write request (write any value to execute) */ - case 12: /* clear read request (write any value to execute) */ - m_status &= ~ (1 << (offset - 8)); - set_interrupt_line(); - break; - - case 13: /* clear new status flag - whatever it means (write any value to execute) */ - m_new_status_flag = 0; - set_interrupt_line(); - break; - } -} - -/* - Video refresh -*/ -void asr733_device::refresh(bitmap_ind16 &bitmap, int x, int y) -{ - copybitmap(bitmap, *m_bitmap, 0, 0, x, y, m_bitmap->cliprect()); -} - - -/* - Time callbacks -*/ -void asr733_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - check_keyboard(); - m_lineint_line(ASSERT_LINE); - m_lineint_line(CLEAR_LINE); -} - -static const unsigned char key_translate[3][51] = -{ - { /* unshifted */ - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0', - ':', - '-', - - 0x1b, - 'Q', - 'W', - 'E', - 'R', - 'T', - 'Y', - 'U', - 'I', - 'O', - 'P', - 0x0a, - 0x0d, - - 0, - 'A', - 'S', - 'D', - 'F', - 'G', - 'H', - 'J', - 'K', - 'L', - ';', - 0x08, - 0, - - 0, - 'Z', - 'X', - 'C', - 'V', - 'B', - 'N', - 'M', - ',', - '.', - '/', - 0, - - ' ' - }, - { /* shifted */ - '!', - '"', - '#', - '$', - '%', - '&', - '^', - '(', - ')', - ' ', - '*', - '=', - - 0x1b, - 'Q', - 'W', - 'E', - 'R', - 'T', - 'Y', - 'U', - 'I', - '_', - '@', - 0x0a, - 0x0d, - - 0, - 'A', - 'S', - 'D', - 'F', - 'G', - 'H', - 'J', - 0, - '/', - '+', - 0x08, - 0, - - 0, - 'Z', - 'X', - 'C', - 'V', - 'B', - '^', - '|', - '<', - '>', - '?', - 0, - - ' ' - }, - { /* control */ - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0', - ':', - '-', - - 0x1b, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0f, - 0x10, - 0x0a, - 0x0d, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0a, - 0x0b, - 0x0c, - ';', - 0x08, - 0, - - 0, - 0x1a, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0e, - 0x0d, - ',', - '.', - '/', - 0, - - ' ' - } -}; - - -/* - keyboard handler: should be called regularly by machine code, for instance - every Video Blank Interrupt. -*/ -void asr733_device::check_keyboard() -{ - enum modifier_state_t - { - /* key modifier states */ - unshifted = 0, shift, control, - /* special value to stop repeat if the modifier state changes */ - special_debounce = -1 - } ; - - enum { repeat_delay = 5 /* approx. 1/10s */ }; - - //UINT16 key_buf[6]; - UINT16 key_buf[4]; - int i, j; - modifier_state_t modifier_state; - int repeat_mode; - - static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; - - /* read current key state */ - /* 2008-05 FP: in 733_asr.h there are only 4 input ports defined... */ - /* for (i = 0; i < 6; i++) */ - for (i = 0; i < 4; i++) - { - key_buf[i] = ioport(keynames[i])->read(); - } - - /* process key modifiers */ - if (key_buf[1] & 0x0200) - modifier_state = control; - else if ((key_buf[2] & 0x0040) || (key_buf[3] & 0x0002)) - modifier_state = shift; - else - modifier_state = unshifted; - - /* test repeat key */ - repeat_mode = key_buf[2] & 0x0020; - - /* remove modifier keys */ - key_buf[1] &= ~0x0200; - key_buf[2] &= ~0x0060; - key_buf[3] &= ~0x0002; - - if (! repeat_mode) - /* reset REPEAT timer if the REPEAT key is not pressed */ - m_repeat_timer = 0; - - if ( !(m_last_key_pressed & 0x80) && (key_buf[m_last_key_pressed >> 4] & (1 << (m_last_key_pressed & 0xf)))) - { - /* last key has not been released */ - if (modifier_state == m_last_modifier_state) - { - /* handle REPEAT mode if applicable */ - if ((repeat_mode) && (++m_repeat_timer == repeat_delay)) - { - if (m_status & AS_rrq_mask) - { /* keyboard buffer full */ - m_repeat_timer--; - } - else - { /* repeat current key */ - m_status |= AS_rrq_mask; - m_new_status_flag = 1; /* right??? */ - set_interrupt_line(); - m_repeat_timer = 0; - } - } - } - else - { - m_repeat_timer = 0; - m_last_modifier_state = special_debounce; - } - } - else - { - m_last_key_pressed = 0x80; - - if (m_status & AS_rrq_mask) - { /* keyboard buffer full */ - /* do nothing */ - } - else - { - //for (i=0; i<6; i++) - for (i=0; i<4; i++) - { - for (j=0; j<16; j++) - { - if (key_buf[i] & (1 << j)) - { - m_last_key_pressed = (i << 4) | j; - m_last_modifier_state = modifier_state; - - m_recv_buf = (int)key_translate[modifier_state][m_last_key_pressed]; - m_status |= AS_rrq_mask; - m_new_status_flag = 1; /* right??? */ - set_interrupt_line(); - return; - } - } - } - } - } -} - -UINT32 asr733_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - refresh(bitmap, 0, 0); - return 0; -} - -static MACHINE_CONFIG_FRAGMENT( asr733 ) - MCFG_GFXDECODE_ADD("gfxdecode", "palette", asr733) - - MCFG_PALETTE_ADD("palette", 2) - MCFG_PALETTE_INIT_OWNER(asr733_device, asr733) - - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ - MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, asr733_device, screen_update) - - MCFG_SCREEN_SIZE(640, 480) - MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) - MCFG_SCREEN_PALETTE("palette") -MACHINE_CONFIG_END - -INPUT_PORTS_START( asr733 ) - PORT_START("KEY0") /* keys 1-16 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(":") PORT_CODE(KEYCODE_MINUS) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_EQUALS) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) \ - \ - PORT_START("KEY1") /* keys 17-32 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_CLOSEBRACE) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) \ - \ - PORT_START("KEY2") /* keys 33-48 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RUB OUT") PORT_CODE(KEYCODE_BACKSPACE) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("REPEAT") PORT_CODE(KEYCODE_RALT) \ - /* hack for my mac that does not disciminate the right ALT key */ \ - /* PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("REPEAT") PORT_CODE(KEYCODE_LALT) */ \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) \ - \ - PORT_START("KEY3") /* keys 49-51 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_RSHIFT) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(SPACE)") PORT_CODE(KEYCODE_SPACE) -INPUT_PORTS_END - -ioport_constructor asr733_device::device_input_ports() const -{ - return INPUT_PORTS_NAME( asr733 ); -} - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor asr733_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( asr733 ); -} diff --git a/src/mess/video/733_asr.h b/src/mess/video/733_asr.h deleted file mode 100644 index 6182a21eb52..00000000000 --- a/src/mess/video/733_asr.h +++ /dev/null @@ -1,88 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet - -#define asr733_chr_region ":gfx1" - -enum -{ - /* 8 bytes per character definition */ - asr733_single_char_len = 8, - asr733_chr_region_len = 128*asr733_single_char_len -}; - -class asr733_device : public device_t -{ -public: - asr733_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_PALETTE_INIT(asr733); - - DECLARE_READ8_MEMBER(cru_r); - DECLARE_WRITE8_MEMBER(cru_w); - - template static devcb_base &static_set_keyint_callback(device_t &device, _Object object) - { - return downcast(device).m_keyint_line.set_callback(object); - } - template static devcb_base &static_set_lineint_callback(device_t &device, _Object object) - { - return downcast(device).m_lineint_line.set_callback(object); - } - - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - void device_config_complete(); - void device_start(); - void device_reset(); - machine_config_constructor device_mconfig_additions() const; - void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - ioport_constructor device_input_ports() const; - -private: - // internal state -#if 0 - UINT8 m_OutQueue[ASROutQueueSize]; - int m_OutQueueHead; - int m_OutQueueLen; -#endif - - void check_keyboard(); - void refresh(bitmap_ind16 &bitmap, int x, int y); - - void set_interrupt_line(); - void draw_char(int character, int x, int y, int color); - void linefeed(); - void transmit(UINT8 data); - - emu_timer *m_line_timer; // screen line timer - - UINT8 m_recv_buf; - UINT8 m_xmit_buf; - - UINT8 m_status; - UINT8 m_mode; - UINT8 m_last_key_pressed; - int m_last_modifier_state; - - unsigned char m_repeat_timer; - int m_new_status_flag; - - int m_x; - - bitmap_ind16* m_bitmap; - - required_device m_palette; - required_device m_gfxdecode; - devcb_write_line m_keyint_line; - devcb_write_line m_lineint_line; -}; - -extern const device_type ASR733; - -#define MCFG_ASR733_KEYINT_HANDLER( _intcallb ) \ - devcb = &asr733_device::static_set_keyint_callback( *device, DEVCB_##_intcallb ); - -#define MCFG_ASR733_LINEINT_HANDLER( _intcallb ) \ - devcb = &asr733_device::static_set_lineint_callback( *device, DEVCB_##_intcallb ); diff --git a/src/mess/video/911_chr.h b/src/mess/video/911_chr.h deleted file mode 100644 index 6d24b5d0415..00000000000 --- a/src/mess/video/911_chr.h +++ /dev/null @@ -1,3516 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - 911_chr.h: character definitions for 911_vdt.c - - We define the character matrix for each character. - - The US terminal uses the standard 7-bit ASCII character set, with - additional graphic characters in the 32 first positions. - - The various European terminals use variants of the 7-bit ASCII character - set with national characters instead of various punctuation characters. - I think these national character sets were standardized at a point, but - I don't know how close to this standard the character sets used by the - 911 VDT are. - - The Japanese terminal uses 8-bit character codes. The 128 first characters - are identical to the US character set (except that '\' is replaced by the - Yen symbol), and the next 128 characters include the katakana syllabus. - Kanji ideograms are not supported in this scheme. - - The Arabic terminal uses 8-bit character codes, too. It requires - additional code in the TI990 OS for correct operation, as the keyboard - returns codes for isolated characters (i.e. without ligatures), which need - to be substituted with codes with correct context-dependent ligatures. - And both OS and application programs need to support the fact that the - writing direction can be either right-to-left or left-to-right, according - to whether the characters are Latin or Arabic. - - As the original ROMs have not been dumped yet, I recreated the matrices - from various matrix printouts in TI documentation. -*/ -/* - The Arabic character set is not implemented, because documentation is ambiguous - (it says there are 115 characters, but I can hardly see 80 characters in the - attached table), and the character matrices are not documented. -*/ - - -/* - Offsets in the char_defs array -*/ -enum -{ - /* US ASCII: 128 characters (32 symbols + 95 ASCII + 1 blank (delete character)) */ - char_defs_US_base = 0, - /* additionnal katakana set (128 characters, including JIS set) */ - char_defs_katakana_base = char_defs_US_base+128, - /* extra symbols for national character sets */ - char_defs_pound = char_defs_katakana_base+128, /* pound sign (UK 0x23, French WP 0x23) */ - char_defs_yen, /* yen sign (Japan 0x5C) */ - char_defs_auml, /* Latin small letter a with diaeresis (Swedish/Finish 0x7B, German 0x7B) */ - char_defs_Auml, /* Latin capital letter A with diaeresis (Swedish/Finish 0x5B, German 0x5B) */ - char_defs_Aring, /* Latin capital letter A with ring above (Swedish/Finish 0x5D, Norwegian/Danish 0x5D) */ - char_defs_uuml, /* Latin small letter u with diaeresis (Swedish/Finish 0x7E, German 0x7D) */ - char_defs_aring, /* Latin small letter a with ring above (Swedish/Finish 0x7D, Norwegian/Danish 0x7D) */ - char_defs_Uuml, /* Latin capital letter U with diaeresis (German 0x5D) */ - char_defs_ouml, /* Latin small letter o with diaeresis (German 0x7C) */ - char_defs_Ouml, /* Latin capital letter O with diaeresis (German 0x5C) */ - char_defs_szlig, /* Latin small letter sharp s (German 0x7E) */ - char_defs_aelig, /* Latin small letter ae (Norwegian/Danish 0x7B) */ - char_defs_AElig, /* Latin capital letter AE (Norwegian/Danish 0x5B) */ - char_defs_oslash, /* Latin small letter o with stroke (Norwegian/Danish 0x7C) */ - char_defs_Oslash, /* Latin capital letter O with stroke (Norwegian/Danish 0x5C) */ - char_defs_agrave, /* Latin small letter a with grave (French WP 0x40) */ - char_defs_deg, /* degree sign (French WP 0x5B) */ - char_defs_ccedil, /* Latin small letter c with cedilla (French WP 0x5C) */ - char_defs_sect, /* section sign (French WP 0x5D) */ - char_defs_egrave, /* Latin small letter e with grave (French WP 0x7B) */ - char_defs_ugrave, /* Latin small letter u with grave (French WP 0x7C) */ - char_defs_eacute, /* Latin small letter e with acute (French WP 0x7D) */ - char_defs_uml, /* diaeresis (French WP 0x7E) */ - - char_defs_count /* total character count */ -}; - -/* structure used to describe differences between national character sets and -US character set */ -/* much more compact than defining the complete 128-char vector */ -struct char_override_t -{ - unsigned char char_index; /* char to replace */ - unsigned short symbol_index; /* replacement symbol */ -}; - -/* One UK-specific character */ -static const char_override_t UK_overrides[1] = -{ - { 0x23, char_defs_pound } -}; - -/* One Japan-specific character (see below for the 128 additionnal characters) */ -static const char_override_t japanese_overrides[1] = -{ - { 0x5C, char_defs_yen } -}; - -/* 5 Sweden/Finland-specific characters */ -static const char_override_t swedish_overrides[/*5*/7] = -{ - { 0x7B, char_defs_auml }, - { 0x5B, char_defs_Auml }, - { 0x5D, char_defs_Aring }, - { 0x7E, char_defs_uuml }, - { 0x7D, char_defs_aring }, - /* next characters described in D-4 but not 1-10 */ - { 0x5C, char_defs_Ouml }, - { 0x7C, char_defs_ouml } -}; - -/* 7 German-specific characters */ -static const char_override_t german_overrides[7] = -{ - { 0x5D, char_defs_Uuml }, - { 0x7D, char_defs_uuml }, - { 0x7C, char_defs_ouml }, - { 0x5C, char_defs_Ouml }, - { 0x7B, char_defs_auml }, - { 0x7E, char_defs_szlig }, - { 0x5B, char_defs_Auml } /* 945423-9701 rev. B p. 1-10 says 0x5D, but it must be a mistake */ -}; - -/* 6 Norway/Denmark-specific characters */ -static const char_override_t norwegian_overrides[6] = -{ - { 0x5D, char_defs_Aring }, - { 0x7B, char_defs_aelig }, - { 0x5B, char_defs_AElig }, - { 0x7D, char_defs_aring }, - { 0x7C, char_defs_oslash}, - { 0x5C, char_defs_Oslash} -}; - -/* 9 French-specific characters (word-processing model only: the data-processing model uses -the US character set, although the keyboard mapping is different from the US model) */ -/* WARNING: I have created the character matrices from scratch, as I have no printout of -the original matrices. */ -static const char_override_t frenchWP_overrides[9] = -{ - { 0x23, char_defs_pound }, - { 0x40, char_defs_agrave}, - { 0x5B, char_defs_deg }, - { 0x5C, char_defs_ccedil}, - { 0x5D, char_defs_sect }, - { 0x7B, char_defs_eacute}, /* 945423-9701 rev. B says char_defs_egrave, but it must be a mistake */ - { 0x7C, char_defs_ugrave}, - { 0x7D, char_defs_egrave}, /* 945423-9701 rev. B says char_defs_eacute, but it must be a mistake */ - { 0x7E, char_defs_uml } -}; - -/* - char_defs array: character matrices for each character -*/ -static const UINT8 char_defs[char_defs_count][10] = -{ -/* US character set: 128 7*10 character matrix */ - { /* 0x00 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c - }, - { /* 0x01 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c - }, - { /* 0x02 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x03 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x04 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x05 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x06 */ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x07 */ - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x08 */ - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x09 */ - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x0A */ - 0x00, - 0x00, - 0x00, - 0x1f, - 0x1f, - 0x1f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x0B */ - 0x1c, - 0x1c, - 0x1c, - 0x7c, - 0x7c, - 0x7c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x0C */ - 0x00, - 0x00, - 0x00, - 0x7f, - 0x7f, - 0x7f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x0D */ - 0x1c, - 0x1c, - 0x1c, - 0x1f, - 0x1f, - 0x1f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x0E */ - 0x01, - 0x03, - 0x06, - 0x04, - 0x08, - 0x08, - 0x10, - 0x30, - 0x60, - 0x40 - }, - { /* 0x0F */ - 0x00, - 0x00, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x7f, - 0x00, - 0x00, - 0x00 - }, - { /* 0x10 */ - 0x00, - 0x00, - 0x00, - 0x40, - 0x40, - 0x40, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x11 */ - 0x00, - 0x00, - 0x00, - 0x60, - 0x60, - 0x60, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x12 */ - 0x00, - 0x00, - 0x00, - 0x70, - 0x70, - 0x70, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x13 */ - 0x00, - 0x00, - 0x00, - 0x78, - 0x78, - 0x78, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x14*/ - 0x00, - 0x00, - 0x00, - 0x7c, - 0x7c, - 0x7c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x15 */ - 0x00, - 0x00, - 0x00, - 0x7e, - 0x7e, - 0x7e, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x16 */ - 0x00, - 0x00, - 0x00, - 0x7f, - 0x7f, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x17*/ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x18 */ - 0x1c, - 0x1c, - 0x1c, - 0x7f, - 0x7f, - 0x7f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x19 */ - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f - }, - { /* 0x1A */ - 0x00, - 0x00, - 0x00, - 0x7c, - 0x7c, - 0x7c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x1B */ - 0x1c, - 0x1c, - 0x1c, - 0x1f, - 0x1f, - 0x1f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x1C */ - 0x1c, - 0x1c, - 0x1c, - 0x7f, - 0x7f, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x1D */ - 0x1c, - 0x1c, - 0x1c, - 0x7c, - 0x7c, - 0x7c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x1E */ - 0x40, - 0x60, - 0x30, - 0x10, - 0x08, - 0x08, - 0x04, - 0x06, - 0x03, - 0x01 - }, - { /* 0x1F */ - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22 - }, - { /* 0x20 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x21 */ - 0x00, - 0x18, - 0x18, - 0x18, - 0x18, - 0x18, - 0x00, - 0x18, - 0x00, - 0x00 - }, - { /* 0x22 */ - 0x00, - 0x14, - 0x14, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x23 */ - 0x00, - 0x00, - 0x14, - 0x36, - 0x00, - 0x36, - 0x14, - 0x00, - 0x00, - 0x00 - }, - { /* 0x24 */ - 0x00, - 0x1c, - 0x2a, - 0x28, - 0x1c, - 0x0a, - 0x2a, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x25 */ - 0x00, - 0x30, - 0x32, - 0x04, - 0x08, - 0x10, - 0x26, - 0x06, - 0x00, - 0x00 - }, - { /* 0x26 */ - 0x00, - 0x10, - 0x28, - 0x28, - 0x10, - 0x2a, - 0x24, - 0x1a, - 0x00, - 0x00 - }, - { /* 0x27 */ - 0x00, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x28 */ - 0x00, - 0x02, - 0x04, - 0x08, - 0x08, - 0x08, - 0x04, - 0x02, - 0x00, - 0x00 - }, - { /* 0x29 */ - 0x00, - 0x20, - 0x10, - 0x08, - 0x08, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00 - }, - { /* 0x2A */ - 0x00, - 0x00, - 0x08, - 0x1c, - 0x3e, - 0x1c, - 0x08, - 0x00, - 0x00, - 0x00 - }, - { /* 0x2B */ - 0x00, - 0x00, - 0x08, - 0x08, - 0x3e, - 0x08, - 0x08, - 0x00, - 0x00, - 0x00 - }, - { /* 0x2C */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x18, - 0x18, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0x2D */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x2E */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x18, - 0x18, - 0x00, - 0x00 - }, - { /* 0x2F */ - 0x00, - 0x00, - 0x02, - 0x04, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00, - 0x00 - }, - { /* 0x30 */ - 0x00, - 0x0c, - 0x12, - 0x12, - 0x12, - 0x12, - 0x12, - 0x0c, - 0x00, - 0x00 - }, - { /* 0x31 */ - 0x00, - 0x08, - 0x18, - 0x08, - 0x08, - 0x08, - 0x08, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x32 */ - 0x00, - 0x1c, - 0x22, - 0x02, - 0x1c, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x33 */ - 0x00, - 0x1c, - 0x22, - 0x02, - 0x0c, - 0x02, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x34 */ - 0x00, - 0x04, - 0x0c, - 0x14, - 0x24, - 0x3e, - 0x04, - 0x04, - 0x00, - 0x00 - }, - { /* 0x35 */ - 0x00, - 0x3e, - 0x20, - 0x3c, - 0x02, - 0x02, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x36 */ - 0x00, - 0x0c, - 0x10, - 0x20, - 0x3c, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x37 */ - 0x00, - 0x3e, - 0x02, - 0x04, - 0x08, - 0x10, - 0x10, - 0x10, - 0x00, - 0x00 - }, - { /* 0x38 */ - 0x00, - 0x1c, - 0x22, - 0x22, - 0x1c, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x39 */ - 0x00, - 0x1c, - 0x22, - 0x22, - 0x1e, - 0x02, - 0x04, - 0x18, - 0x00, - 0x00 - }, - { /* 0x3A */ - 0x00, - 0x00, - 0x18, - 0x18, - 0x00, - 0x18, - 0x18, - 0x00, - 0x00, - 0x00 - }, - { /* 0x3B */ - 0x00, - 0x18, - 0x18, - 0x00, - 0x18, - 0x18, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0x3C */ - 0x00, - 0x02, - 0x04, - 0x08, - 0x10, - 0x08, - 0x04, - 0x02, - 0x00, - 0x00 - }, - { /* 0x3D */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x3e, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x3E */ - 0x00, - 0x20, - 0x10, - 0x08, - 0x04, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00 - }, - { /* 0x3F */ - 0x00, - 0x1c, - 0x22, - 0x04, - 0x08, - 0x08, - 0x00, - 0x08, - 0x00, - 0x00 - }, - { /* 0x40 */ - 0x00, - 0x1c, - 0x22, - 0x2e, - 0x2a, - 0x2e, - 0x20, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x41 */ - 0x00, - 0x1c, - 0x22, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x42 */ - 0x00, - 0x3c, - 0x12, - 0x12, - 0x1c, - 0x12, - 0x12, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x43 */ - 0x00, - 0x1c, - 0x22, - 0x20, - 0x20, - 0x20, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x44 */ - 0x00, - 0x3c, - 0x12, - 0x12, - 0x12, - 0x12, - 0x12, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x45 */ - 0x00, - 0x3e, - 0x20, - 0x20, - 0x3c, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x46 */ - 0x00, - 0x3e, - 0x20, - 0x20, - 0x3c, - 0x20, - 0x20, - 0x20, - 0x00, - 0x00 - }, - { /* 0x47 */ - 0x00, - 0x1e, - 0x20, - 0x20, - 0x2e, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x48 */ - 0x00, - 0x22, - 0x22, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x49 */ - 0x00, - 0x1c, - 0x08, - 0x08, - 0x08, - 0x08, - 0x08, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x4A */ - 0x00, - 0x02, - 0x02, - 0x02, - 0x02, - 0x02, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x4B */ - 0x00, - 0x22, - 0x24, - 0x28, - 0x30, - 0x28, - 0x24, - 0x22, - 0x00, - 0x00 - }, - { /* 0x4C */ - 0x00, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x4D */ - 0x00, - 0x22, - 0x36, - 0x2a, - 0x22, - 0x22, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x4E */ - 0x00, - 0x22, - 0x32, - 0x2a, - 0x26, - 0x22, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x4F */ - 0x00, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x50 */ - 0x00, - 0x3c, - 0x22, - 0x22, - 0x3c, - 0x20, - 0x20, - 0x20, - 0x00, - 0x00 - }, - { /* 0x51 */ - 0x00, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x2a, - 0x24, - 0x3a, - 0x00, - 0x00 - }, - { /* 0x52 */ - 0x00, - 0x3c, - 0x22, - 0x22, - 0x3c, - 0x28, - 0x24, - 0x22, - 0x00, - 0x00 - }, - { /* 0x53 */ - 0x00, - 0x1c, - 0x20, - 0x10, - 0x08, - 0x04, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x54 */ - 0x00, - 0x3e, - 0x08, - 0x08, - 0x08, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x55 */ - 0x00, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x56 */ - 0x00, - 0x22, - 0x22, - 0x22, - 0x14, - 0x14, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x57 */ - 0x00, - 0x22, - 0x22, - 0x22, - 0x2a, - 0x2a, - 0x2a, - 0x14, - 0x00, - 0x00 - }, - { /* 0x58 */ - 0x00, - 0x22, - 0x22, - 0x14, - 0x08, - 0x14, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x59 */ - 0x00, - 0x22, - 0x22, - 0x14, - 0x08, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x5A */ - 0x00, - 0x3e, - 0x02, - 0x04, - 0x08, - 0x10, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x5B */ - 0x00, - 0x0e, - 0x08, - 0x08, - 0x08, - 0x08, - 0x08, - 0x0e, - 0x00, - 0x00 - }, - { /* 0x5C */ - 0x00, - 0x00, - 0x20, - 0x10, - 0x08, - 0x04, - 0x02, - 0x00, - 0x00, - 0x00 - }, - { /* 0x5D */ - 0x00, - 0x38, - 0x08, - 0x08, - 0x08, - 0x08, - 0x08, - 0x38, - 0x00, - 0x00 - }, - { /* 0x5E */ - 0x00, - 0x08, - 0x14, - 0x22, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x5F */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x60 */ - 0x00, - 0x10, - 0x08, - 0x04, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x61 */ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x62 */ - 0x00, - 0x00, - 0x00, - 0x3c, - 0x12, - 0x1c, - 0x12, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x63 */ - 0x00, - 0x00, - 0x00, - 0x1e, - 0x20, - 0x20, - 0x20, - 0x1e, - 0x00, - 0x00 - }, - { /* 0x64 */ - 0x00, - 0x00, - 0x00, - 0x3c, - 0x12, - 0x12, - 0x12, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x65 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x20, - 0x3c, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x66 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x20, - 0x3c, - 0x20, - 0x20, - 0x00, - 0x00 - }, - { /* 0x67 */ - 0x00, - 0x00, - 0x00, - 0x1e, - 0x20, - 0x2e, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x68 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x69 */ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x08, - 0x08, - 0x08, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x6A */ - 0x00, - 0x00, - 0x00, - 0x0e, - 0x04, - 0x04, - 0x24, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x6B */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x24, - 0x38, - 0x24, - 0x22, - 0x00, - 0x00 - }, - { /* 0x6C */ - 0x00, - 0x00, - 0x00, - 0x20, - 0x20, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x6D */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x36, - 0x2a, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* 0x6E */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x32, - 0x2a, - 0x26, - 0x22, - 0x00, - 0x00 - }, - { /* 0x6F */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x70 */ - 0x00, - 0x00, - 0x00, - 0x3c, - 0x22, - 0x3c, - 0x20, - 0x20, - 0x00, - 0x00 - }, - { /* 0x71 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x22, - 0x2a, - 0x24, - 0x3a, - 0x00, - 0x00 - }, - { /* 0x72 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x22, - 0x3e, - 0x24, - 0x22, - 0x00, - 0x00 - }, - { /* 0x73 */ - 0x00, - 0x00, - 0x00, - 0x1e, - 0x20, - 0x1c, - 0x02, - 0x3c, - 0x00, - 0x00 - }, - { /* 0x74 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x08, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x75 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x22, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0x76 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x22, - 0x24, - 0x28, - 0x10, - 0x00, - 0x00 - }, - { /* 0x77 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x22, - 0x2a, - 0x36, - 0x22, - 0x00, - 0x00 - }, - { /* 0x78 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x14, - 0x08, - 0x14, - 0x22, - 0x00, - 0x00 - }, - { /* 0x79 */ - 0x00, - 0x00, - 0x00, - 0x22, - 0x14, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x7A */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x04, - 0x08, - 0x10, - 0x3e, - 0x00, - 0x00 - }, - { /* 0x7B */ - 0x00, - 0x06, - 0x08, - 0x08, - 0x10, - 0x08, - 0x08, - 0x06, - 0x00, - 0x00 - }, - { /* 0x7C */ - 0x00, - 0x08, - 0x08, - 0x08, - 0x00, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0x7D */ - 0x00, - 0x30, - 0x08, - 0x08, - 0x04, - 0x08, - 0x08, - 0x30, - 0x00, - 0x00 - }, - { /* 0x7E */ - 0x00, - 0x10, - 0x2a, - 0x04, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x7F */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - - -/* 128 additional characters for Japanese terminals */ - { /* 0x80 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c - }, - { /* 0x81 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c - }, - { /* 0x82 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x83 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x84 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x85 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x86 */ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x87 */ - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x88 */ - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x89 */ - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x8A */ - 0x00, - 0x00, - 0x00, - 0x1f, - 0x1f, - 0x1f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x8B */ - 0x1c, - 0x1c, - 0x1c, - 0x7c, - 0x7c, - 0x7c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x8C */ - 0x00, - 0x00, - 0x00, - 0x7f, - 0x7f, - 0x7f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x8D */ - 0x1c, - 0x1c, - 0x1c, - 0x1f, - 0x1f, - 0x1f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x8E */ - 0x01, - 0x03, - 0x06, - 0x04, - 0x08, - 0x08, - 0x10, - 0x30, - 0x30, - 0x20 - }, - { /* 0x8F */ - 0x00, - 0x00, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x7f, - 0x00, - 0x00, - 0x00 - }, - { /* 0x90 */ - 0x00, - 0x00, - 0x00, - 0x40, - 0x40, - 0x40, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x91 */ - 0x00, - 0x00, - 0x00, - 0x60, - 0x60, - 0x60, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x92 */ - 0x00, - 0x00, - 0x00, - 0x70, - 0x70, - 0x70, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x93 */ - 0x00, - 0x00, - 0x00, - 0x78, - 0x78, - 0x78, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x94*/ - 0x00, - 0x00, - 0x00, - 0x7c, - 0x7c, - 0x7c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x95 */ - 0x00, - 0x00, - 0x00, - 0x7e, - 0x7e, - 0x7e, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x96 */ - 0x00, - 0x00, - 0x00, - 0x7f, - 0x7f, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x97*/ - 0x00, - 0x00, - 0x00, - 0x1c, - 0x1c, - 0x1c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x98 */ - 0x1c, - 0x1c, - 0x1c, - 0x7f, - 0x7f, - 0x7f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x99 */ - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f, - 0x7f - }, - { /* 0x9A */ - 0x00, - 0x00, - 0x00, - 0x7c, - 0x7c, - 0x7c, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x9B */ - 0x1c, - 0x1c, - 0x1c, - 0x1f, - 0x1f, - 0x1f, - 0x1c, - 0x1c, - 0x1c, - 0x1c - }, - { /* 0x9C */ - 0x1c, - 0x1c, - 0x1c, - 0x7f, - 0x7f, - 0x7f, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x9D */ - 0x1c, - 0x1c, - 0x1c, - 0x7c, - 0x7c, - 0x7c, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0x9E */ - 0x40, - 0x60, - 0x30, - 0x10, - 0x08, - 0x08, - 0x04, - 0x06, - 0x06, - 0x02 - }, - { /* 0x9F */ - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22, - 0x22 - }, - { /* 0xA0 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xA1 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x38, - 0x28, - 0x38, - 0x00, - 0x00 - }, - { /* 0xA2 */ - 0x00, - 0x0e, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xA3 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x08, - 0x08, - 0x08, - 0x38, - 0x00, - 0x00 - }, - { /* 0xA4 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x10, - 0x08, - 0x00, - 0x00 - }, - { /* 0xA5 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x10, - 0x10, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xA6 */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x1e, - 0x02, - 0x04, - 0x08, - 0x00, - 0x00 - }, - { /* 0xA7 */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x02, - 0x0c, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xA8 */ - 0x00, - 0x00, - 0x00, - 0x04, - 0x08, - 0x18, - 0x28, - 0x08, - 0x00, - 0x00 - }, - { /* 0xA9 */ - 0x00, - 0x00, - 0x00, - 0x08, - 0x3e, - 0x22, - 0x02, - 0x0c, - 0x00, - 0x00 - }, - { /* 0xAA */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x08, - 0x08, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xAB */ - 0x00, - 0x00, - 0x00, - 0x04, - 0x3e, - 0x0c, - 0x14, - 0x24, - 0x00, - 0x00 - }, - { /* 0xAC */ - 0x00, - 0x00, - 0x00, - 0x10, - 0x3e, - 0x12, - 0x14, - 0x10, - 0x00, - 0x00 - }, - { /* 0xAD */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x1c, - 0x04, - 0x04, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xAE */ - 0x00, - 0x00, - 0x00, - 0x3c, - 0x04, - 0x3c, - 0x04, - 0x3c, - 0x00, - 0x00 - }, - { /* 0xAF */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x2a, - 0x2a, - 0x02, - 0x0c, - 0x00, - 0x00 - }, - { /* 0xB0 */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xB1 */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x0c, - 0x08, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xB2 */ - 0x00, - 0x04, - 0x08, - 0x18, - 0x28, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0xB3 */ - 0x00, - 0x08, - 0x3e, - 0x22, - 0x02, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xB4 */ - 0x00, - 0x00, - 0x3e, - 0x08, - 0x08, - 0x08, - 0x08, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xB5 */ - 0x00, - 0x04, - 0x3e, - 0x04, - 0x0c, - 0x14, - 0x24, - 0x04, - 0x00, - 0x00 - }, - { /* 0xB6 */ - 0x00, - 0x08, - 0x08, - 0x3e, - 0x0a, - 0x0a, - 0x12, - 0x24, - 0x00, - 0x00 - }, - { /* 0xB7 */ - 0x00, - 0x08, - 0x3e, - 0x08, - 0x3e, - 0x08, - 0x08, - 0x08, - 0x00, - 0x00 - }, - { /* 0xB8 */ - 0x00, - 0x00, - 0x1e, - 0x12, - 0x22, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xB9 */ - 0x00, - 0x10, - 0x10, - 0x1e, - 0x24, - 0x04, - 0x04, - 0x08, - 0x00, - 0x00 - }, - { /* 0xBA */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x02, - 0x02, - 0x02, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xBB */ - 0x00, - 0x14, - 0x3e, - 0x14, - 0x14, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xBC */ - 0x00, - 0x00, - 0x30, - 0x00, - 0x32, - 0x02, - 0x04, - 0x38, - 0x00, - 0x00 - }, - { /* 0xBD */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x04, - 0x08, - 0x14, - 0x22, - 0x00, - 0x00 - }, - { /* 0xBE */ - 0x00, - 0x10, - 0x3e, - 0x12, - 0x14, - 0x10, - 0x10, - 0x1e, - 0x00, - 0x00 - }, - { /* 0xBF */ - 0x00, - 0x00, - 0x22, - 0x22, - 0x12, - 0x02, - 0x04, - 0x18, - 0x00, - 0x00 - }, - { /* 0xC0 */ - 0x00, - 0x00, - 0x1e, - 0x12, - 0x2a, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xC1 */ - 0x00, - 0x04, - 0x38, - 0x08, - 0x3e, - 0x08, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xC2 */ - 0x00, - 0x00, - 0x2a, - 0x2a, - 0x2a, - 0x02, - 0x04, - 0x08, - 0x00, - 0x00 - }, - { /* 0xC3 */ - 0x00, - 0x00, - 0x1c, - 0x00, - 0x3e, - 0x08, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xC4 */ - 0x00, - 0x10, - 0x10, - 0x10, - 0x18, - 0x14, - 0x10, - 0x10, - 0x00, - 0x00 - }, - { /* 0xC5 */ - 0x00, - 0x08, - 0x08, - 0x3e, - 0x08, - 0x08, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xC6 */ - 0x00, - 0x00, - 0x1c, - 0x00, - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xC7 */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x14, - 0x08, - 0x14, - 0x20, - 0x00, - 0x00 - }, - { /* 0xC8 */ - 0x00, - 0x08, - 0x3e, - 0x04, - 0x08, - 0x1c, - 0x2a, - 0x08, - 0x00, - 0x00 - }, - { /* 0xC9 */ - 0x00, - 0x04, - 0x04, - 0x04, - 0x04, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xCA */ - 0x00, - 0x00, - 0x04, - 0x02, - 0x12, - 0x12, - 0x12, - 0x22, - 0x00, - 0x00 - }, - { /* 0xCB */ - 0x00, - 0x00, - 0x20, - 0x20, - 0x3e, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xCC */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x02, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xCD */ - 0x00, - 0x00, - 0x10, - 0x28, - 0x04, - 0x02, - 0x02, - 0x00, - 0x00, - 0x00 - }, - { /* 0xCE */ - 0x00, - 0x08, - 0x3e, - 0x08, - 0x2a, - 0x2a, - 0x2a, - 0x08, - 0x00, - 0x00 - }, - { /* 0xCF */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x02, - 0x14, - 0x08, - 0x04, - 0x00, - 0x00 - }, - { /* 0xD0 */ - 0x00, - 0x10, - 0x0e, - 0x00, - 0x0e, - 0x00, - 0x10, - 0x0e, - 0x00, - 0x00 - }, - { /* 0xD1 */ - 0x00, - 0x00, - 0x04, - 0x08, - 0x10, - 0x22, - 0x3e, - 0x02, - 0x00, - 0x00 - }, - { /* 0xD2 */ - 0x00, - 0x00, - 0x02, - 0x02, - 0x14, - 0x08, - 0x14, - 0x20, - 0x00, - 0x00 - }, - { /* 0xD3 */ - 0x00, - 0x00, - 0x3c, - 0x10, - 0x3e, - 0x10, - 0x10, - 0x1e, - 0x00, - 0x00 - }, - { /* 0xD4 */ - 0x00, - 0x10, - 0x10, - 0x3e, - 0x12, - 0x14, - 0x10, - 0x10, - 0x00, - 0x00 - }, - { /* 0xD5 */ - 0x00, - 0x00, - 0x1c, - 0x04, - 0x04, - 0x04, - 0x04, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xD6 */ - 0x00, - 0x00, - 0x3e, - 0x02, - 0x3e, - 0x02, - 0x02, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xD7 */ - 0x00, - 0x00, - 0x1c, - 0x00, - 0x3e, - 0x02, - 0x02, - 0x0c, - 0x00, - 0x00 - }, - { /* 0xD8 */ - 0x00, - 0x00, - 0x12, - 0x12, - 0x12, - 0x02, - 0x04, - 0x08, - 0x00, - 0x00 - }, - { /* 0xD9 */ - 0x00, - 0x00, - 0x28, - 0x28, - 0x28, - 0x2a, - 0x2a, - 0x2c, - 0x00, - 0x00 - }, - { /* 0xDA */ - 0x00, - 0x00, - 0x20, - 0x20, - 0x22, - 0x24, - 0x28, - 0x30, - 0x00, - 0x00 - }, - { /* 0xDB */ - 0x00, - 0x00, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x22, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xDC */ - 0x00, - 0x00, - 0x3e, - 0x22, - 0x22, - 0x02, - 0x04, - 0x08, - 0x00, - 0x00 - }, - { /* 0xDD */ - 0x00, - 0x00, - 0x30, - 0x00, - 0x02, - 0x02, - 0x04, - 0x38, - 0x00, - 0x00 - }, - { /* 0xDE */ - 0x00, - 0x28, - 0x28, - 0x28, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xDF */ - 0x00, - 0x38, - 0x28, - 0x38, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xE0 */ - 0x00, - 0x1c, - 0x22, - 0x04, - 0x08, - 0x08, - 0x00, - 0x08, - 0x00, - 0x00 - }, - { /* 0xE1 */ - 0x00, - 0x18, - 0x18, - 0x18, - 0x18, - 0x00, - 0x18, - 0x18, - 0x00, - 0x00 - }, - { /* 0xE2 */ - 0x00, - 0x14, - 0x14, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xE3 */ - 0x00, - 0x00, - 0x14, - 0x36, - 0x00, - 0x36, - 0x14, - 0x00, - 0x00, - 0x00 - }, - { /* 0xE4 */ - 0x00, - 0x1c, - 0x2a, - 0x28, - 0x1c, - 0x0a, - 0x2a, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xE5 */ - 0x00, - 0x30, - 0x32, - 0x04, - 0x08, - 0x10, - 0x26, - 0x06, - 0x00, - 0x00 - }, - { /* 0xE6 */ - 0x00, - 0x10, - 0x28, - 0x28, - 0x10, - 0x2a, - 0x24, - 0x1a, - 0x00, - 0x00 - }, - { /* 0xE7 */ - 0x00, - 0x04, - 0x08, - 0x10, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xE8 */ - 0x00, - 0x02, - 0x04, - 0x08, - 0x08, - 0x08, - 0x04, - 0x02, - 0x00, - 0x00 - }, - { /* 0xE9 */ - 0x00, - 0x20, - 0x10, - 0x08, - 0x08, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00 - }, - { /* 0xEA */ - 0x00, - 0x00, - 0x08, - 0x1c, - 0x3e, - 0x1c, - 0x08, - 0x00, - 0x00, - 0x00 - }, - { /* 0xEB */ - 0x00, - 0x00, - 0x08, - 0x08, - 0x3e, - 0x08, - 0x08, - 0x00, - 0x00, - 0x00 - }, - { /* 0xEC */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x18, - 0x18, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xED */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xEE */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x18, - 0x18, - 0x00, - 0x00 - }, - { /* 0xEF */ - 0x00, - 0x00, - 0x02, - 0x04, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00, - 0x00 - }, - { /* 0xF0 */ - 0x00, - 0x0c, - 0x12, - 0x12, - 0x12, - 0x12, - 0x12, - 0x0c, - 0x00, - 0x00 - }, - { /* 0xF1 */ - 0x00, - 0x08, - 0x18, - 0x08, - 0x08, - 0x08, - 0x08, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xF2 */ - 0x00, - 0x1c, - 0x22, - 0x02, - 0x1c, - 0x20, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* 0xF3 */ - 0x00, - 0x1c, - 0x22, - 0x02, - 0x0c, - 0x02, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xF4 */ - 0x00, - 0x04, - 0x0c, - 0x14, - 0x24, - 0x3e, - 0x04, - 0x04, - 0x00, - 0x00 - }, - { /* 0xF5 */ - 0x00, - 0x3e, - 0x20, - 0x3c, - 0x02, - 0x02, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xF6 */ - 0x00, - 0x0c, - 0x10, - 0x20, - 0x3c, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xF7 */ - 0x00, - 0x3e, - 0x02, - 0x04, - 0x08, - 0x10, - 0x10, - 0x10, - 0x00, - 0x00 - }, - { /* 0xF8 */ - 0x00, - 0x1c, - 0x22, - 0x22, - 0x1c, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* 0xF9 */ - 0x00, - 0x1c, - 0x22, - 0x22, - 0x1e, - 0x02, - 0x04, - 0x18, - 0x00, - 0x00 - }, - { /* 0xFA */ - 0x00, - 0x00, - 0x18, - 0x18, - 0x00, - 0x18, - 0x18, - 0x00, - 0x00, - 0x00 - }, - { /* 0xFB */ - 0x00, - 0x18, - 0x18, - 0x00, - 0x18, - 0x18, - 0x08, - 0x10, - 0x00, - 0x00 - }, - { /* 0xFC */ - 0x00, - 0x02, - 0x04, - 0x08, - 0x10, - 0x08, - 0x04, - 0x02, - 0x00, - 0x00 - }, - { /* 0xFD */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x00, - 0x3e, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* 0xFE */ - 0x00, - 0x20, - 0x10, - 0x08, - 0x04, - 0x08, - 0x10, - 0x20, - 0x00, - 0x00 - }, - { /* 0xFF */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - - -/* extra symbols for various national terminals, which use slightly modified -variants of the US character set */ - { /* pound */ - 0x00, - 0x0c, - 0x12, - 0x10, - 0x38, - 0x10, - 0x3a, - 0x34, - 0x00, - 0x00 - }, - { /* yen */ - 0x00, - 0x22, - 0x14, - 0x08, - 0x3e, - 0x08, - 0x3e, - 0x08, - 0x00, - 0x00 - }, - { /* auml */ - 0x00, - 0x00, - 0x22, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x00, - 0x00 - }, - { /* Auml */ - 0x00, - 0x22, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* Aring */ - 0x00, - 0x08, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x22, - 0x00, - 0x00 - }, - { /* uuml */ - 0x00, - 0x00, - 0x22, - 0x00, - 0x22, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* aring */ - 0x00, - 0x00, - 0x08, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x00, - 0x00 - }, - - { /* Uuml */ - 0x00, - 0x22, - 0x00, - 0x22, - 0x22, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - - { /* ouml */ - 0x00, - 0x00, - 0x22, - 0x00, - 0x3e, - 0x22, - 0x22, - 0x3e, - 0x00, - 0x00 - }, - { /* Ouml */ - 0x00, - 0x22, - 0x00, - 0x3e, - 0x22, - 0x22, - 0x22, - 0x3e, - 0x00, - 0x00 - }, - { /* szlig */ - 0x00, - 0x18, - 0x24, - 0x24, - 0x2c, - 0x22, - 0x22, - 0x2c, - 0x00, - 0x00 - }, - { /* aelig */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x28, - 0x3e, - 0x28, - 0x2e, - 0x00, - 0x00 - }, - { /* AElig */ - 0x00, - 0x3e, - 0x28, - 0x28, - 0x3e, - 0x28, - 0x28, - 0x2e, - 0x00, - 0x00 - }, - { /* Oslash */ - 0x00, - 0x00, - 0x00, - 0x3e, - 0x26, - 0x2a, - 0x32, - 0x3e, - 0x00, - 0x00 - }, - { /* oslash */ - 0x00, - 0x3e, - 0x22, - 0x26, - 0x2a, - 0x32, - 0x22, - 0x3e, - 0x00, - 0x00 - }, -/* WARNING: I have created the next 8 French character matrices from scratch, -as I have no printout of the original matrices. */ - { /* agrave */ - 0x00, - 0x10, - 0x08, - 0x00, - 0x1c, - 0x22, - 0x3e, - 0x22, - 0x00, - 0x00 - }, - { /* deg */ - 0x00, - 0x38, - 0x28, - 0x38, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - }, - { /* ccedil */ - 0x00, - 0x00, - 0x00, - 0x1e, - 0x20, - 0x20, - 0x20, - 0x1e, - 0x08, - 0x04 - }, - { /* sect */ - 0x00, - 0x1c, - 0x20, - 0x1c, - 0x22, - 0x1c, - 0x02, - 0x1c, - 0x00, - 0x00 - }, - { /* egrave */ - 0x00, - 0x10, - 0x08, - 0x3e, - 0x20, - 0x3c, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* ugrave */ - 0x00, - 0x10, - 0x08, - 0x22, - 0x22, - 0x22, - 0x22, - 0x1c, - 0x00, - 0x00 - }, - { /* eacute */ - 0x00, - 0x04, - 0x08, - 0x3e, - 0x20, - 0x3c, - 0x20, - 0x3e, - 0x00, - 0x00 - }, - { /* uml */ - 0x00, - 0x22, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - } -}; diff --git a/src/mess/video/911_key.h b/src/mess/video/911_key.h deleted file mode 100644 index 108bf85fd7d..00000000000 --- a/src/mess/video/911_key.h +++ /dev/null @@ -1,4028 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - key translation table for both US and UK terminals - - The only difference is that the US # character is a Pound character in UK. -*/ -static const unsigned char US_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x3B, - 0x27, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x7A, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3B, - 0x27, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5B, - 0x5D, - 0x3D, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x8A, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3A, - 0x22, - 0, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x7C, - 0x60, - 0x7E, - 0x1D, - 0x7F, - 0x5C, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x7B, - 0x7D, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x1A, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - } -}; - - -/* - key translation table for French terminals -*/ -static const unsigned char French_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x61, - 0x7A, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x71, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x6D, - 0x27, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x77, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x3B, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x41, - 0x5A, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x51, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x4D, - 0x27, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x57, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x3B, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5B, - 0x5D, - 0x3D, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x41, - 0x5A, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x8A, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x51, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x4D, - 0x22, - 0, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x57, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x3A, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x7C, - 0x60, - 0x7E, - 0x1D, - 0x7F, - 0x5C, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x01, - 0x1A, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x11, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x0D, - 0x7D, - 0, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x17, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x7B, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - } -}; - - -/* - key translation table for German terminals -*/ -static const unsigned char German_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x7E, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x7A, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x7D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x7C, - 0x7B, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x79, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x27, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x5A, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5C, - 0x5B, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x59, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5F, - 0x3D, - 0x22, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x5A, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x8A, - 0x8C, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5C, - 0x5B, - 0x3A, - 0x83, /* 945423-9701 rev. B says 0x85, but it must be a mistake */ - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x59, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x7C, - 0x60, - 0x00, - 0x1D, - 0x7F, - 0x00, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x1A, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x00, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x19, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - } -}; - - -/* - key translation table for Swedish/Finnish terminals -*/ -static const unsigned char Swedish_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x7E, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x7D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x7C, - 0x7B, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x7A, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x27, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5C, - 0x5B, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5F, - 0x3D, - 0x22, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x8A, - 0x8C, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5C, - 0x5B, - 0x3A, - 0x83, /* 945423-9701 rev. B says 0x85, but it must be a mistake */ - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x00, - 0x60, - 0x00, - 0x1D, - 0x7F, - 0x00, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x00, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x1A, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - } -}; - - -/* - key translation table for Norwegian/Danish terminals -*/ -static const unsigned char Norwegian_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x27, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x7D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x7B, - 0x7C, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x7A, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x27, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x88, - 0x87, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5B, - 0x5C, - 0x3B, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5F, - 0x3D, - 0x22, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x5D, - 0x8A, /* 945423-9701 rev. B says 0x88, but it must be a mistake */ - 0x8C, /* 945423-9701 rev. B says 0x87, but it must be a mistake */ - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x5B, - 0x5C, - 0x3A, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x00, - 0x60, - 0x00, - 0x1D, - 0x7F, - 0x00, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x00, - 0x88, /* 945423-9701 rev. B says 0x8A, but it must be a mistake */ - 0x87, /* 945423-9701 rev. B says 0x8C, but it must be a mistake */ - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x1A, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0x0D - } -}; - - -/* - key translation table for Japanese katakana terminals -*/ -static const unsigned char Japanese_key_translate[6][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x3B, - 0x27, - 0x5C, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x7A, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3B, - 0x27, - 0x5C, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5B, - 0x5D, - 0x3D, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x8A, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3A, - 0x22, - 0x00, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x7C, - 0x60, - 0x7E, - 0x1D, - 0x7F, - 0x5C, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays the back quote character, whereas it actually display the Yen symbol) */ - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x7B, - 0x7D, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x1A, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* katakana */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0xC7, - 0xCC, - 0xB1, - 0xB3, - 0xB4, - 0xB5, - 0xD4, - 0xD5, - 0xD6, - 0xDC, - 0xCE, - 0xCD, - 0xDB, - 0x1B, /* 945423-9701 rev. B says 0x00, but it must be a mistake */ - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0xC0, - 0xC3, - 0xB2, - 0xBD, - 0xB6, - 0xDD, - 0xC5, - 0xC6, - 0xD7, - 0xBE, - 0x88, /* 945423-9701 rev. B says 0x00, but it must be a mistake */ - 0x87, /* 945423-9701 rev. B says 0x00, but it must be a mistake */ - 0x0D, /* 945423-9701 rev. B says 0x00, but it must be a mistake */ - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0xC1, - 0xC4, - 0xBC, - 0xCA, - 0xB7, - 0xB8, - 0xCF, - 0xC9, - 0xD8, /* 945423-9701 rev. B says 0xC8, but it must be a mistake */ - 0xDA, - 0xB9, - 0xD1, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0xC2, - 0xBB, - 0xBF, - 0xCB, - 0xBA, - 0xD0, - 0xD3, - 0xC8, - 0xD9, - 0xD2, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* shifted katakana */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x00, - 0x00, - 0xA7, - 0xA9, - 0xAA, - 0xAB, - 0xAC, - 0xAD, - 0xAE, - 0xA6, - 0xDE, - 0xDF, - 0xB0, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x00, - 0x00, - 0xAB, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x8A, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xA2, - 0xA3, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0xAF, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xA4, - 0xA1, - 0xA5, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - } -}; - - -#if 0 -/* - key translation table for Arabic terminals -*/ -static const unsigned char Arabic_key_translate[6][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x71, - 0x77, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x61, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x3B, - 0x27, - 0x5C, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x7A, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x6D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x2B, - 0x2D, - 0x5F, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3B, - 0x27, - 0x5C, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x2C, - 0x2E, - 0x2F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x21, - 0x40, - 0x23, - 0x24, - 0x25, - 0x5E, - 0x26, - 0x2A, - 0x28, - 0x29, - 0x5B, - 0x5D, - 0x3D, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x51, - 0x57, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x8A, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x41, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x3A, - 0x22, - 0x00, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x5A, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x4D, - 0x3C, - 0x3E, - 0x3F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x7C, - 0x60, - 0x7E, - 0x1D, - 0x7F, - 0x5C, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x11, - 0x17, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x88, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x01, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x7B, - 0x7D, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x1A, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x0D, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2E, - - 0, - 0x20, - 0 - }, - { /* arabic */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0xC7, - 0xCC, - 0xB1, - 0xB3, - 0xB4, - 0xB5, - 0xD4, - 0xD5, - 0xD6, - 0xDC, - 0xCE, - 0xCD, - 0xDB, - 0x1B, - - 0x37, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x38, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x39, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0xC0, - 0xC3, - 0xB2, - 0xBD, - 0xB6, - 0xDD, - 0xC5, - 0xC6, - 0xD7, - 0xBE, - 0x88, - 0x87, - 0x0D, - - 0x34, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x35, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x36, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x88, - 0x82, - 0x8A, - - 0, - 0xC1, - 0xC4, - 0xBC, - 0xCA, - 0xB7, - 0xB8, - 0xCF, - 0xC9, - 0xD8, - 0xDA, - 0xB9, - 0xD1, - 0x85, - - 0x31, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x32, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x33, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x86, - 0x8B, - 0x84, - - 0, - 0xC2, - 0xBB, - 0xBF, - 0xCB, - 0xBA, - 0xD0, - 0xD3, - 0xC8, - 0xD9, - 0xD2, - 0, - - 0x30, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x2E, - - 0, - 0x20, - 0 - }, - { /* shifted arabic */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x00, - 0x00, - 0xA7, - 0xA9, - 0xAA, - 0xAB, - 0xAC, - 0xAD, - 0xAE, - 0xA6, - 0xDE, - 0xDF, - 0xB0, - 0x1B, - - 0x37, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x38, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x39, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x00, - 0x00, - 0xAB, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x8A, - 0x8C, - 0x0D, - - 0x34, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x35, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x36, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xA2, - 0xA3, - 0x83, - - 0x31, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x32, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x33, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - - - 0x86, - 0x8B, - 0x84, - - 0, - 0xAF, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xA4, - 0xA1, - 0xA5, - 0, - - 0x30, /* 945423-9701 rev. B says so, but it might be a mistake (it claims it displays arabic-style digits, whereas it actually displays western-style digits) */ - 0x2E, - - 0, - 0x20, - 0 - } -}; -#endif - - -/* - key translation table for French word-processing terminals -*/ -static const unsigned char FrenchWP_key_translate[4][91] = -{ - { /* lower case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x26, - 0x7B, - 0x22, - 0x27, - 0x28, - 0x5D, - 0x7D, - 0x21, - 0x5C, - 0x40, - 0x29, - 0x2D, - 0x24, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x61, - 0x7A, - 0x65, - 0x72, - 0x74, - 0x79, - 0x75, - 0x69, - 0x6F, - 0x70, - 0x5E, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x71, - 0x73, - 0x64, - 0x66, - 0x67, - 0x68, - 0x6A, - 0x6B, - 0x6C, - 0x6D, - 0x7C, - 0x2A, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x77, - 0x78, - 0x63, - 0x76, - 0x62, - 0x6E, - 0x2C, - 0x3B, - 0x3A, - 0x3D, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* upper case */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x5B, - 0x5F, - 0x23, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x41, - 0x5A, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x7E, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x51, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x4D, - 0x25, - 0x60, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x57, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x3F, - 0x2E, - 0x2F, - 0x2B, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* shifted */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x30, - 0x5B, - 0x5F, - 0x23, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x41, - 0x5A, - 0x45, - 0x52, - 0x54, - 0x59, - 0x55, - 0x49, - 0x4F, - 0x50, - 0x7E, - 0x8C, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x51, - 0x53, - 0x44, - 0x46, - 0x47, - 0x48, - 0x4A, - 0x4B, - 0x4C, - 0x4D, - 0x25, - 0x60, - 0x83, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x57, - 0x58, - 0x43, - 0x56, - 0x42, - 0x4E, - 0x3F, - 0x2E, - 0x2F, - 0x2B, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - }, - { /* control */ - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9B, - 0x9C, - - - 0x80, - 0x81, - 0x9F, - - 0, - 0x90, - 0x91, - 0x00, - 0xA1, - 0x8D, - 0x8E, - 0x8F, - 0x3C, - 0x3E, - 0x00, - 0x1D, - 0x7F, - 0x00, - 0x1B, - - 0x37, - 0x38, - 0x39, - - - 0x9A, - 0x89, - 0, - - 0xA0, - 0x01, - 0x1A, - 0x05, - 0x12, - 0x14, - 0x19, - 0x15, - 0x09, - 0x0F, - 0x10, - 0x00, - 0x87, - 0x0D, - - 0x34, - 0x35, - 0x36, - - - 0x88, - 0x82, - 0x8A, - - 0, - 0x11, - 0x13, - 0x04, - 0x06, - 0x07, - 0x08, - 0x0A, - 0x0B, - 0x0C, - 0x0D, - 0x00, - 0x00, - 0x85, - - 0x31, - 0x32, - 0x33, - - - 0x86, - 0x8B, - 0x84, - - 0, - 0x17, - 0x18, - 0x03, - 0x16, - 0x02, - 0x0E, - 0x00, - 0x1C, - 0x1E, - 0x1F, - 0, - - 0x30, - 0x2C, - - 0, - 0x20, - 0 - } -}; diff --git a/src/mess/video/911_vdt.c b/src/mess/video/911_vdt.c deleted file mode 100644 index c0d30600681..00000000000 --- a/src/mess/video/911_vdt.c +++ /dev/null @@ -1,844 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - TI 911 VDT core. To be operated with the TI 990 line of computers (can be connected to - any model, as communication uses the CRU bus). - - Raphael Nabet 2002 - -TODO: - * add more flexibility, so that we can create multiple-terminal configurations. - * support test mode??? -*/ - - -#include "emu.h" -#include "911_vdt.h" -#include "911_chr.h" -#include "911_key.h" - -#define MAX_VDT 1 - -static const gfx_layout fontlayout_7bit = -{ - 7, 10, /* 7*10 characters */ - 128, /* 128 characters */ - 1, /* 1 bit per pixel */ - { 0 }, - { 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8 }, - 10*8 /* every char takes 10 consecutive bytes */ -}; - -static const gfx_layout fontlayout_8bit = -{ - 7, 10, /* 7*10 characters */ - 128, /* 128 characters */ - 1, /* 1 bit per pixel */ - { 0 }, - { 1, 2, 3, 4, 5, 6, 7 }, /* straightforward layout */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8 }, - 10*8 /* every char takes 10 consecutive bytes */ -}; - -static GFXDECODE_START( vdt911 ) - // Caution: Array must use same order as vdt911_model_t - // US - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_US_chr_offset, fontlayout_7bit, 0, 4 ) - - // UK - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_UK_chr_offset, fontlayout_7bit, 0, 4 ) - - // French (without accented characters) - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_US_chr_offset, fontlayout_7bit, 0, 4 ) - - // German - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_german_chr_offset, fontlayout_7bit, 0, 4 ) - - // Swedish - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_swedish_chr_offset, fontlayout_7bit, 0, 4 ) - - // Norwegian - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_norwegian_chr_offset, fontlayout_7bit, 0, 4 ) - - // Japanese - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_japanese_chr_offset, fontlayout_8bit, 0, 4 ) - - // Arabic - // GFXDECODE_ENTRY( vdt911_chr_region, vdt911_arabic_chr_offset, fontlayout_8bit, 0, 4 ) - - // FrenchWP (contains accented characters) - GFXDECODE_ENTRY( vdt911_chr_region, vdt911_frenchWP_chr_offset, fontlayout_7bit, 0, 4 ) -GFXDECODE_END - -static const unsigned char vdt911_colors[] = -{ - 0x00,0x00,0x00, /* black */ - 0xC0,0xC0,0xC0, /* low intensity */ - 0xFF,0xFF,0xFF /* high intensity */ -}; - -static const unsigned short vdt911_palette[] = -{ - 0, 2, /* high intensity */ - 0, 1, /* low intensity */ - 2, 0, /* high intensity, reverse */ - 2, 1 /* low intensity, reverse */ -}; - -/* - Macros for model features -*/ -/* TRUE for Japanese and Arabic terminals, which use 8-bit charcodes and keyboard shift modes */ -#define USES_8BIT_CHARCODES() ((m_model == vdt911_model_Japanese) /*|| (m_model == vdt911_model_Arabic)*/) -/* TRUE for keyboards which have this extra key (on the left of TAB/SKIP) - (Most localized keyboards have it) */ -#define HAS_EXTRA_KEY_67() (! ((m_model == vdt911_model_US) || (m_model == vdt911_model_UK) || (m_model == vdt911_model_French))) -/* TRUE for keyboards which have this extra key (on the right of space), - AND do not use it as a modifier */ -#define HAS_EXTRA_KEY_91() ((m_model == vdt911_model_German) || (m_model == vdt911_model_Swedish) || (m_model == vdt911_model_Norwegian)) - -/* - Initialize vdt911 palette -*/ -PALETTE_INIT_MEMBER(vdt911_device, vdt911) -{ - UINT8 i, r, g, b; - - for ( i = 0; i < 3; i++ ) - { - r = vdt911_colors[i*3]; g = vdt911_colors[i*3+1]; b = vdt911_colors[i*3+2]; - palette.set_indirect_color(i, rgb_t(r, g, b)); - } - - for(i=0;i<8;i++) - palette.set_pen_indirect(i, vdt911_palette[i]); -} - -/* - Copy a character bitmap array to another location in memory -*/ -static void copy_character_matrix_array(const UINT8 char_array[128][10], UINT8 *dest) -{ - int i, j; - - for (i=0; i<128; i++) - for (j=0; j<10; j++) - *(dest++) = char_array[i][j]; -} - -/* - Patch a character bitmap array according to an array of char_override_t -*/ -static void apply_char_overrides(int nb_char_overrides, const char_override_t char_overrides[], UINT8 *dest) -{ - int i, j; - - for (i=0; i; - -vdt911_device::vdt911_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, VDT911, "911 VDT", tag, owner, clock, "vdt911", __FILE__), - m_beeper(*this, "beeper"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_keyint_line(*this), - m_lineint_line(*this) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void vdt911_device::device_config_complete() -{ -} - -enum -{ - BLINK_TIMER, - BEEP_TIMER, - LINE_TIMER -}; - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void vdt911_device::device_start() -{ - m_last_key_pressed = 0x80; - - m_keyboard_data_ready = false; - m_display_enable = false; - m_blink_state = false; - - m_keyint_line.resolve(); - m_lineint_line.resolve(); - - /* set up cursor blink clock. 2Hz frequency -> .25s half-period. */ - /*m_blink_clock =*/ - - // m_beeper->set_frequency(2000); - - m_blink_timer = timer_alloc(BLINK_TIMER); - m_beep_timer = timer_alloc(BEEP_TIMER); - m_line_timer = timer_alloc(LINE_TIMER); - - m_blink_timer->adjust(attotime::from_msec(0), 0, attotime::from_msec(250)); - - UINT8 *base; - UINT8 *chr = machine().root_device().memregion(vdt911_chr_region)->base(); - - /* set up US character definitions */ - base = chr+vdt911_US_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - - /* set up UK character definitions */ - base = chr+vdt911_UK_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(UK_overrides)/sizeof(char_override_t), UK_overrides, base); - - /* French character set is identical to US character set */ - - /* set up German character definitions */ - base = chr+vdt911_german_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(german_overrides)/sizeof(char_override_t), german_overrides, base); - - /* set up Swedish/Finnish character definitions */ - base = chr+vdt911_swedish_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(swedish_overrides)/sizeof(char_override_t), swedish_overrides, base); - - /* set up Norwegian/Danish character definitions */ - base = chr+vdt911_norwegian_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(norwegian_overrides)/sizeof(char_override_t), norwegian_overrides, base); - - /* set up French word processing character definitions */ - base = chr+vdt911_frenchWP_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(frenchWP_overrides)/sizeof(char_override_t), frenchWP_overrides, base); - - /* set up Katakana Japanese character definitions */ - base = chr+vdt911_japanese_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(japanese_overrides)/sizeof(char_override_t), japanese_overrides, base); - base = chr+vdt911_japanese_chr_offset+128*vdt911_single_char_len; - copy_character_matrix_array(char_defs+char_defs_katakana_base, base); - -#if 0 - /* set up Arabic character definitions */ - base = chr+vdt911_arabic_chr_offset; - copy_character_matrix_array(char_defs+char_defs_US_base, base); - apply_char_overrides(sizeof(arabic_overrides)/sizeof(char_override_t), arabic_overrides, base); - base = chr+vdt911_arabic_chr_offset+128*vdt911_single_char_len; - copy_character_matrix_array(char_defs+char_defs_arabic_base, base); -#endif -} - - -void vdt911_device::device_reset() -{ - m_model = (vdt911_model_t)ioport("LOCALE")->read(); - m_screen_size = (vdt911_screen_size_t)ioport("SCREEN")->read(); - - if (m_screen_size == char_960) - m_cursor_address_mask = 0x3ff; /* 1kb of RAM */ - else - m_cursor_address_mask = 0x7ff; /* 2 kb of RAM */ - - m_line_timer->adjust(attotime::from_msec(0), 0, attotime::from_hz(get_refresh_rate())); -} - -/* - Timer callbacks -*/ -void vdt911_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case BLINK_TIMER: - m_blink_state = !m_blink_state; - break; - case BEEP_TIMER: - m_beeper->set_state(0); - break; - case LINE_TIMER: - check_keyboard(); - m_lineint_line(ASSERT_LINE); - m_lineint_line(CLEAR_LINE); - break; - } -} - -/* - CRU interface read -*/ -READ8_MEMBER( vdt911_device::cru_r ) -{ - int reply=0; - - offset &= 0x1; - - if (!m_word_select) - { /* select word 0 */ - switch (offset) - { - case 0: - reply = m_display_RAM[m_cursor_address]; - break; - - case 1: - reply = m_keyboard_data & 0x7f; - if (m_keyboard_data_ready) - reply |= 0x80; - break; - } - } - else - { /* select word 1 */ - switch (offset) - { - case 0: - reply = m_cursor_address & 0xff; - break; - - case 1: - reply = (m_cursor_address >> 8) & 0x07; - if (m_keyboard_data & 0x80) - reply |= 0x08; - /*if (!m_terminal_ready) - reply |= 0x10;*/ - if (m_previous_word_select) - reply |= 0x20; - /*if (m_keyboard_parity_error) - reply |= 0x40;*/ - if (m_keyboard_data_ready) - reply |= 0x80; - break; - } - } - - return reply; -} - -/* - CRU interface write -*/ -WRITE8_MEMBER( vdt911_device::cru_w ) -{ - offset &= 0xf; - - if (!m_word_select) - { /* select word 0 */ - switch (offset) - { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - /* display memory write data */ - if (data) - m_data_reg |= (1 << offset); - else - m_data_reg &= ~ (1 << offset); - break; - - case 0x8: - /* write data strobe */ - m_display_RAM[m_cursor_address] = m_data_reg; - break; - - case 0x9: - /* test mode */ - /* ... */ - break; - - case 0xa: - /* cursor move */ - if (data) - m_cursor_address--; - else - m_cursor_address++; - m_cursor_address &= m_cursor_address_mask; - break; - - case 0xb: - /* blinking cursor enable */ - m_blinking_cursor_enable = data; - break; - - case 0xc: - /* keyboard interrupt enable */ - m_keyboard_interrupt_enable = data; - m_keyint_line(m_keyboard_interrupt_enable && m_keyboard_data_ready); - break; - - case 0xd: - /* dual intensity enable */ - m_dual_intensity_enable = data; - break; - - case 0xe: - /* display enable */ - m_display_enable = data; - break; - - case 0xf: - /* select word */ - m_previous_word_select = m_word_select; - m_word_select = data; - break; - } - } - else - { /* select word 1 */ - switch (offset) - { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x8: - case 0x9: - case 0xa: - /* cursor address */ - if (data) - m_cursor_address |= (1 << offset); - else - m_cursor_address &= ~ (1 << offset); - m_cursor_address &= m_cursor_address_mask; - break; - - case 0xb: - /* not used */ - break; - - case 0xc: - /* display cursor */ - m_display_cursor = data; - break; - - case 0xd: - /* keyboard acknowledge */ - if (m_keyboard_data_ready) - { - m_keyboard_data_ready = 0; - if (m_keyboard_interrupt_enable) - m_keyint_line(CLEAR_LINE); - } - /*m_keyboard_parity_error = 0;*/ - break; - - case 0xe: - /* beep enable strobe - not tested */ - m_beeper->set_state(1); - m_beep_timer->adjust(attotime::from_usec(300)); - break; - - case 0xf: - /* select word */ - m_previous_word_select = m_word_select; - m_word_select = data; - break; - } - } -} - -/* - Video refresh -*/ -void vdt911_device::refresh(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y) -{ - gfx_element *gfx = m_gfxdecode->gfx(m_model); - int height = (m_screen_size == char_960) ? 12 : /*25*/24; - - int use_8bit_charcodes = USES_8BIT_CHARCODES(); - int address = 0; - int i, j; - int cur_char; - int color; - - /*if (use_8bit_charcodes) - color = vdt->dual_intensity_enable ? 1 : 0;*/ - - if (!m_display_enable) - { - rectangle my_rect(x, x + 80*7 - 1, y, y + height*10 - 1); - - bitmap.fill(0, my_rect); - } - else - { - for (i=0; iopaque(bitmap, cliprect, cur_char, color, 0, 0, - x+j*7, y+i*10); - } - } - } -} - -static const unsigned char (*const key_translate[])[91] = -{ /* array must use same order as vdt911_model_t!!! */ - /* US */ - US_key_translate, - /* UK */ - US_key_translate, - /* French */ - French_key_translate, - /* German */ - German_key_translate, - /* Swedish */ - Swedish_key_translate, - /* Norwegian */ - Norwegian_key_translate, - /* Japanese */ - Japanese_key_translate, - /* Arabic */ - /*Arabic_key_translate,*/ - /* FrenchWP */ - FrenchWP_key_translate -}; - -/* - keyboard handler: should be called regularly by machine code, for instance - every Video Blank Interrupt. -*/ -void vdt911_device::check_keyboard() -{ - enum modifier_state_t - { - /* states for Western keyboards and katakana/Arabic keyboards in romaji/Latin mode */ - lower_case = 0, upper_case, shift, control, - /* states for katakana/Arabic keyboards in katakana/Arabic mode */ - foreign, foreign_shift, - /* special value to stop repeat if the modifier state changes */ - special_debounce = -1 - }; - - static unsigned char repeat_timer; - enum { repeat_delay = 5 /* approx. 1/10s */ }; - - UINT16 key_buf[6]; - int i, j; - modifier_state_t modifier_state; - int repeat_mode; - - static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5" }; - - /* read current key state */ - for (i = 0; i < 6; i++) - { - key_buf[i] = ioport(keynames[i])->read(); - } - - /* parse modifier keys */ - if ((USES_8BIT_CHARCODES()) - && ((key_buf[5] & 0x0400) || ((!(key_buf[5] & 0x0100)) && m_foreign_mode))) - { /* we are in katakana/Arabic mode */ - m_foreign_mode = true; - - if ((key_buf[4] & 0x0400) || (key_buf[5] & 0x0020)) - modifier_state = foreign_shift; - else - modifier_state = foreign; - } - else - { /* we are using a Western keyboard, or a katakana/Arabic keyboard in - romaji/Latin mode */ - m_foreign_mode = false; - - if (key_buf[3] & 0x0040) - modifier_state = control; - else if ((key_buf[4] & 0x0400) || (key_buf[5] & 0x0020)) - modifier_state = shift; - else if ((key_buf[0] & 0x2000)) - modifier_state = upper_case; - else - modifier_state = lower_case; - } - - - /* test repeat key */ - repeat_mode = key_buf[2] & 0x0002; - - - /* remove modifier keys */ - key_buf[0] &= ~0x2000; - key_buf[2] &= ~0x0002; - key_buf[3] &= ~0x0040; - key_buf[4] &= ~0x0400; - key_buf[5] &= ~0x0120; - - /* remove unused keys */ - if (! HAS_EXTRA_KEY_91()) - key_buf[5] &= ~0x0400; - - if (! HAS_EXTRA_KEY_67()) - key_buf[4] &= ~0x0004; - - - if (! repeat_mode) - /* reset REPEAT timer if the REPEAT key is not pressed */ - repeat_timer = 0; - - if (!(m_last_key_pressed & 0x80) && (key_buf[m_last_key_pressed >> 4] & (1 << (m_last_key_pressed & 0xf)))) - { - /* last key has not been released */ - if (modifier_state == m_last_modifier_state) - { - /* handle REPEAT mode if applicable */ - if ((repeat_mode) && (++repeat_timer == repeat_delay)) - { - if (m_keyboard_data_ready) - { /* keyboard buffer full */ - repeat_timer--; - } - else - { /* repeat current key */ - m_keyboard_data_ready = 1; - repeat_timer = 0; - } - } - } - else - { - repeat_timer = 0; - m_last_modifier_state = special_debounce; - } - } - else - { - m_last_key_pressed = 0x80; - - if (m_keyboard_data_ready) - { /* keyboard buffer full */ - /* do nothing */ - } - else - { - for (i=0; i<6; i++) - { - for (j=0; j<16; j++) - { - if (key_buf[i] & (1 << j)) - { - m_last_key_pressed = (i << 4) | j; - m_last_modifier_state = modifier_state; - - m_keyboard_data = (int)key_translate[m_model][modifier_state][m_last_key_pressed]; - m_keyboard_data_ready = 1; - if (m_keyboard_interrupt_enable) - m_keyint_line(ASSERT_LINE); - return; - } - } - } - } - } -} - -int vdt911_device::get_refresh_rate() -{ - // European models have 50 Hz - return ((m_model == vdt911_model_US) || (m_model == vdt911_model_Japanese))? 60 : 50; -} - -UINT32 vdt911_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - refresh(bitmap, cliprect, 0, 0); - return 0; -} - -INPUT_PORTS_START( vdt911 ) - PORT_START( "LOCALE" ) - PORT_CONFNAME( 0x0f, 0x00, "Terminal language" ) - PORT_CONFSETTING( vdt911_model_US, "English US" ) - PORT_CONFSETTING( vdt911_model_UK, "English UK" ) - PORT_CONFSETTING( vdt911_model_French, "French" ) - PORT_CONFSETTING( vdt911_model_German, "German" ) - PORT_CONFSETTING( vdt911_model_Swedish, "Swedish" ) - PORT_CONFSETTING( vdt911_model_Norwegian, "Norwegian" ) - PORT_CONFSETTING( vdt911_model_Japanese, "Japanese" ) - // PORT_CONFSETTING( vdt911_model_Arabic, "Arabic" ) - PORT_CONFSETTING( vdt911_model_FrenchWP, "French Word Processing" ) - - PORT_START( "SCREEN" ) - PORT_CONFNAME( 0x01, char_960, "Terminal screen size" ) - PORT_CONFSETTING( char_960, "960 chars (12 lines)") - PORT_CONFSETTING( char_1920, "1920 chars (24 lines)") - - PORT_START("KEY0") /* keys 1-16 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CMD") PORT_CODE(KEYCODE_F9) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(red)") PORT_CODE(KEYCODE_F10) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ERASE FIELD") PORT_CODE(KEYCODE_END) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ERASE INPUT") PORT_CODE(KEYCODE_PGDN) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(grey)") PORT_CODE(KEYCODE_F11) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("UPPER CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE\ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2 @") PORT_CODE(KEYCODE_2) \ - \ - PORT_START("KEY1") /* keys 17-32 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6 ^") PORT_CODE(KEYCODE_6) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7 &") PORT_CODE(KEYCODE_7) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8 *") PORT_CODE(KEYCODE_8) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9 (") PORT_CODE(KEYCODE_9) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0 )") PORT_CODE(KEYCODE_0) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("+ [") PORT_CODE(KEYCODE_MINUS) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- ]") PORT_CODE(KEYCODE_EQUALS) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("_ =") PORT_CODE(KEYCODE_BACKSPACE) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7 (numpad)") PORT_CODE(KEYCODE_7_PAD) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8 (numpad)") PORT_CODE(KEYCODE_8_PAD) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9 (numpad)") PORT_CODE(KEYCODE_9_PAD) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PRINT") PORT_CODE(KEYCODE_PRTSCR) \ - \ - PORT_START("KEY2") /* keys 33-48 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(up)") PORT_CODE(KEYCODE_UP) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("REPEAT") PORT_CODE(KEYCODE_LALT) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER_PAD) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CHAR (left/right)") PORT_CODE(KEYCODE_OPENBRACE) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("FIELD (left/right)") PORT_CODE(KEYCODE_CLOSEBRACE) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) \ - \ - PORT_START("KEY3") /* keys 49-64 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4 (numpad)") PORT_CODE(KEYCODE_4_PAD) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5 (numpad)") PORT_CODE(KEYCODE_5_PAD) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6 (numpad)") PORT_CODE(KEYCODE_6_PAD) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(left)") PORT_CODE(KEYCODE_LEFT) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("HOME") PORT_CODE(KEYCODE_HOME) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(right)") PORT_CODE(KEYCODE_RIGHT) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CONTROL") PORT_CODE(KEYCODE_LCONTROL) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) \ - \ - PORT_START("KEY4") /* keys 65-80 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("; :") PORT_CODE(KEYCODE_COLON) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("' \"") PORT_CODE(KEYCODE_QUOTE) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(not on US keyboard)") PORT_CODE(KEYCODE_BACKSLASH) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SKIP TAB") PORT_CODE(KEYCODE_TAB) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1 (numpad)") PORT_CODE(KEYCODE_1_PAD) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2 (numpad)") PORT_CODE(KEYCODE_2_PAD) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3 (numpad)") PORT_CODE(KEYCODE_3_PAD) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INS CHAR") PORT_CODE(KEYCODE_INSERT) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(down)") PORT_CODE(KEYCODE_DOWN) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("DEL CHAR") PORT_CODE(KEYCODE_DEL) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) \ - PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) \ - PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) \ - PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) \ - PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) \ - PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) \ - \ - PORT_START("KEY5") /* keys 81-91 */ \ - PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) \ - PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) \ - PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) \ - PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) \ - PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) \ - PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_RSHIFT) \ - PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0 (numpad)") PORT_CODE(KEYCODE_0_PAD) \ - PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". (numpad)") PORT_CODE(KEYCODE_DEL_PAD) \ - PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(not on US keyboard)") PORT_CODE(KEYCODE_MINUS_PAD) \ - PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) \ - PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(not on US keyboard)") PORT_CODE(KEYCODE_PLUS_PAD) -INPUT_PORTS_END - -static MACHINE_CONFIG_FRAGMENT( vdt911 ) - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ - MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, vdt911_device, screen_update) - - MCFG_SCREEN_SIZE(560, 280) - MCFG_SCREEN_VISIBLE_AREA(0, 560-1, 0, /*250*/280-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_SOUND_ADD("beeper", BEEP, 0) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 0.50) - - MCFG_PALETTE_ADD("palette", 8) - MCFG_PALETTE_INDIRECT_ENTRIES(3) - MCFG_PALETTE_INIT_OWNER(vdt911_device, vdt911) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", vdt911) -MACHINE_CONFIG_END - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor vdt911_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( vdt911 ); -} - -ioport_constructor vdt911_device::device_input_ports() const -{ - return INPUT_PORTS_NAME( vdt911 ); -} diff --git a/src/mess/video/911_vdt.h b/src/mess/video/911_vdt.h deleted file mode 100644 index 7eb0f55dbc1..00000000000 --- a/src/mess/video/911_vdt.h +++ /dev/null @@ -1,118 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet - -#include "sound/beep.h" - -#define vdt911_chr_region ":gfx1" -enum -{ - /* 10 bytes per character definition */ - vdt911_single_char_len = 10, - - vdt911_US_chr_offset = 0, - vdt911_UK_chr_offset = vdt911_US_chr_offset+128*vdt911_single_char_len, - vdt911_german_chr_offset = vdt911_UK_chr_offset+128*vdt911_single_char_len, - vdt911_swedish_chr_offset = vdt911_german_chr_offset+128*vdt911_single_char_len, - vdt911_norwegian_chr_offset = vdt911_swedish_chr_offset+128*vdt911_single_char_len, - vdt911_frenchWP_chr_offset = vdt911_norwegian_chr_offset+128*vdt911_single_char_len, - vdt911_japanese_chr_offset = vdt911_frenchWP_chr_offset+128*vdt911_single_char_len, - - vdt911_chr_region_len = vdt911_japanese_chr_offset+256*vdt911_single_char_len -}; - -enum vdt911_screen_size_t { char_960 = 0, char_1920 }; -enum vdt911_model_t -{ - vdt911_model_US = 0, - vdt911_model_UK, - vdt911_model_French, - vdt911_model_German, - vdt911_model_Swedish, // Swedish/Finnish - vdt911_model_Norwegian, // Norwegian/Danish - vdt911_model_Japanese, // Katakana Japanese - /*vdt911_model_Arabic,*/ // Arabic - vdt911_model_FrenchWP // French word processing -}; - -class vdt911_device : public device_t -{ -public: - vdt911_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_READ8_MEMBER(cru_r); - DECLARE_WRITE8_MEMBER(cru_w); - - DECLARE_PALETTE_INIT(vdt911); - - template static devcb_base &static_set_keyint_callback(device_t &device, _Object object) - { - return downcast(device).m_keyint_line.set_callback(object); - } - - template static devcb_base &static_set_lineint_callback(device_t &device, _Object object) - { - return downcast(device).m_lineint_line.set_callback(object); - } - - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - void device_config_complete(); - void device_start(); - void device_reset(); - - machine_config_constructor device_mconfig_additions() const; - ioport_constructor device_input_ports() const; - - void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - -private: - void refresh(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y); - int get_refresh_rate(); - void check_keyboard(); - - vdt911_screen_size_t m_screen_size; // char_960 for 960-char, 12-line model; char_1920 for 1920-char, 24-line model - vdt911_model_t m_model; // country code - - UINT8 m_data_reg; // dt911 write buffer - UINT8 m_display_RAM[2048]; // vdt911 char buffer (1kbyte for 960-char model, 2kbytes for 1920-char model) - - unsigned int m_cursor_address; // current cursor address (controlled by the computer, affects both display and I/O protocol) - unsigned int m_cursor_address_mask; // 1023 for 960-char model, 2047 for 1920-char model - - emu_timer *m_beep_timer; // beep clock (beeps ends when timer times out) - emu_timer *m_blink_timer; // cursor blink clock - emu_timer *m_line_timer; // screen line timer - - UINT8 m_keyboard_data; // last code pressed on keyboard - bool m_keyboard_data_ready; // true if there is a new code in keyboard_data - bool m_keyboard_interrupt_enable; // true when keybord interrupts are enabled - - bool m_display_enable; // screen is black when false - bool m_dual_intensity_enable; // if true, MSBit of ASCII codes controls character highlight - bool m_display_cursor; // if true, the current cursor location is displayed on screen - bool m_blinking_cursor_enable; // if true, the cursor will blink when displayed - bool m_blink_state; // current cursor blink state - - bool m_word_select; // CRU interface mode - bool m_previous_word_select; // value of word_select is saved here - - UINT8 m_last_key_pressed; - int m_last_modifier_state; - char m_foreign_mode; - - required_device m_beeper; - required_device m_gfxdecode; - required_device m_palette; - devcb_write_line m_keyint_line; - devcb_write_line m_lineint_line; -}; - -extern const device_type VDT911; - -#define MCFG_VDT911_KEYINT_HANDLER( _intcallb ) \ - devcb = &vdt911_device::static_set_keyint_callback( *device, DEVCB_##_intcallb ); - -#define MCFG_VDT911_LINEINT_HANDLER( _intcallb ) \ - devcb = &vdt911_device::static_set_lineint_callback( *device, DEVCB_##_intcallb ); diff --git a/src/mess/video/abc1600.c b/src/mess/video/abc1600.c deleted file mode 100644 index 2a312cb3ae7..00000000000 --- a/src/mess/video/abc1600.c +++ /dev/null @@ -1,1259 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Luxor ABC 1600 Mover emulation - -**********************************************************************/ - -#include "includes/abc1600.h" -#include "abc1600.lh" - - - -//************************************************************************** -// CONSTANTS / MACROS -//************************************************************************** - -#define LOG 0 - - -#define SY6845E_TAG "sy6845e" - - -// video RAM -#define VIDEORAM_SIZE 0x40000 -#define VIDEORAM16_MASK 0x3ffff -#define VIDEORAM8_MASK 0x7fffe - - -// flag register -#define L_P BIT(m_flag, 0) -#define BLANK BIT(m_flag, 1) -#define PIX_POL BIT(m_flag, 2) -#define FRAME_POL BIT(m_flag, 3) -#define HOLD_FY BIT(m_flag, 4) -#define HOLD_FX BIT(m_flag, 5) -#define COMP_MOVE BIT(m_flag, 6) -#define REPLACE BIT(m_flag, 7) - - - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -const device_type ABC1600_MOVER = &device_creator; - - -DEVICE_ADDRESS_MAP_START( vram_map, 8, abc1600_mover_device ) - AM_RANGE(0x00000, 0x7ffff) AM_READWRITE(video_ram_r, video_ram_w) -ADDRESS_MAP_END - -DEVICE_ADDRESS_MAP_START( crtc_map, 8, abc1600_mover_device ) - AM_RANGE(0x00, 0x00) AM_MIRROR(0xfe) AM_DEVREADWRITE(SY6845E_TAG, mc6845_device, status_r, address_w) - AM_RANGE(0x01, 0x01) AM_MIRROR(0xfe) AM_DEVREADWRITE(SY6845E_TAG, mc6845_device, register_r, register_w) -ADDRESS_MAP_END - -DEVICE_ADDRESS_MAP_START( io_map, 8, abc1600_mover_device ) - AM_RANGE(0x000, 0x000) AM_MIRROR(0xff) AM_READ(iord0_r) - AM_RANGE(0x000, 0x000) AM_MIRROR(0xf8) AM_WRITE(ldsx_hb_w) - AM_RANGE(0x001, 0x001) AM_MIRROR(0xf8) AM_WRITE(ldsx_lb_w) - AM_RANGE(0x002, 0x002) AM_MIRROR(0xf8) AM_WRITE(ldsy_hb_w) - AM_RANGE(0x003, 0x003) AM_MIRROR(0xf8) AM_WRITE(ldsy_lb_w) - AM_RANGE(0x004, 0x004) AM_MIRROR(0xf8) AM_WRITE(ldtx_hb_w) - AM_RANGE(0x005, 0x005) AM_MIRROR(0xf8) AM_WRITE(ldtx_lb_w) - AM_RANGE(0x006, 0x006) AM_MIRROR(0xf8) AM_WRITE(ldty_hb_w) - AM_RANGE(0x007, 0x007) AM_MIRROR(0xf8) AM_WRITE(ldty_lb_w) - AM_RANGE(0x100, 0x100) AM_MIRROR(0xf8) AM_WRITE(ldfx_hb_w) - AM_RANGE(0x101, 0x101) AM_MIRROR(0xf8) AM_WRITE(ldfx_lb_w) - AM_RANGE(0x102, 0x102) AM_MIRROR(0xf8) AM_WRITE(ldfy_hb_w) - AM_RANGE(0x103, 0x103) AM_MIRROR(0xf8) AM_WRITE(ldfy_lb_w) - AM_RANGE(0x105, 0x105) AM_MIRROR(0xf8) AM_WRITE(wrml_w) - AM_RANGE(0x107, 0x107) AM_MIRROR(0xf8) AM_WRITE(wrdl_w) - AM_RANGE(0x200, 0x200) AM_MIRROR(0xf8) AM_WRITE(wrmask_strobe_hb_w) - AM_RANGE(0x201, 0x201) AM_MIRROR(0xf8) AM_WRITE(wrmask_strobe_lb_w) - AM_RANGE(0x202, 0x202) AM_MIRROR(0xf8) AM_WRITE(enable_clocks_w) - AM_RANGE(0x203, 0x203) AM_MIRROR(0xf8) AM_WRITE(flag_strobe_w) - AM_RANGE(0x204, 0x204) AM_MIRROR(0xf8) AM_WRITE(endisp_w) -ADDRESS_MAP_END - - -static ADDRESS_MAP_START( mover_map, AS_0, 16, abc1600_mover_device ) - AM_RANGE(0x00000, 0x7ffff) AM_RAM -ADDRESS_MAP_END - - -//------------------------------------------------- -// ROM( abc1600_mover ) -//------------------------------------------------- - -ROM_START( abc1600_mover ) - ROM_REGION16_BE( 0x2000, "wrmsk", 0 ) - ROM_LOAD16_BYTE( "wrmskl 6490362-01.1g", 0x0001, 0x1000, CRC(bc737538) SHA1(80e2c3757eb7f713018808d6e41ebef612425028) ) - ROM_LOAD16_BYTE( "wrmskh 6490363-01.1j", 0x0000, 0x1000, CRC(6b7c9f0b) SHA1(7155a993adcf08a5a8a2f22becf9fd66fda698be) ) - - ROM_REGION( 0x200, "shinf", 0 ) - ROM_LOAD( "shinf 6490361-01.1f", 0x000, 0x200, CRC(20260f8f) SHA1(29bf49c64e7cc7592e88cde2768ac57c7ce5e085) ) - - ROM_REGION16_BE( 0x40, "drmsk", 0 ) - ROM_LOAD16_BYTE( "drmskl 6490359-01.1k", 0x01, 0x20, CRC(6e71087c) SHA1(0acf67700d6227f4b315cf8fb0fb31c0e7fb9496) ) - ROM_LOAD16_BYTE( "drmskh 6490358-01.1l", 0x00, 0x20, CRC(a4a9a9dc) SHA1(d8575c0335d6021cbb5f7bcd298b41c35294a80a) ) - - ROM_REGION( 0x104, "plds", 0 ) - ROM_LOAD( "drmsk 6490360-01.1m", 0x000, 0x104, CRC(5f7143c1) SHA1(1129917845f8e505998b15288f02bf907487e4ac) ) // mover word mixer @ 1m,1n,1t,2t -ROM_END - - -//------------------------------------------------- -// rom_region - device-specific ROM region -//------------------------------------------------- - -const rom_entry *abc1600_mover_device::device_rom_region() const -{ - return ROM_NAME( abc1600_mover ); -} - - -//------------------------------------------------- -// mc6845 -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::get_crtca(UINT16 ma, UINT8 ra, UINT8 column) -{ - /* - - bit description - - CRTCA0 0 - CRTCA1 0 - CRTCA2 CC1/MA1 - CRTCA3 CC2/MA2 - CRTCA4 CC3/MA3 - CRTCA5 CC4/MA4 - CRTCA6 RA0 - CRTCA7 RA1 - CRTCA8 RA2 - CRTCA9 RA3 - CRTCA10 CR0/MA8 - CRTCA11 CR1/MA9 - CRTCA12 CR2/MA10 - CRTCA13 CR3/MA11 - CRTCA14 CR4/MA12 - CRTCA15 CR5/MA13 - - */ - - UINT8 cc = (ma & 0xff) + column; - UINT8 cr = ma >> 8; - - return (cr << 10) | ((ra & 0x0f) << 6) | ((cc << 1) & 0x3c); -} - -MC6845_UPDATE_ROW(abc1600_mover_device::crtc_update_row) -{ - int x = 0; - const pen_t *pen = m_palette->pens(); - - for (int column = 0; column < x_count; column += 2) - { - UINT16 dma = get_crtca(ma, ra, column); - - // data is read out of video RAM in nibble mode by strobing CAS 4 times - for (int cas = 0; cas < 4; cas++) - { - UINT16 data = read_videoram(dma + cas); - - for (int bit = 0; bit < 16; bit++) - { - int color = ((BIT(data, 15) ^ PIX_POL) && !BLANK) && de; - - bitmap.pix32(vbp + y, hbp + x++) = pen[color]; - - data <<= 1; - } - } - } -} - -MC6845_ON_UPDATE_ADDR_CHANGED( abc1600_mover_device::crtc_update ) -{ -} - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc1600_mover ) -//------------------------------------------------- - -static MACHINE_CONFIG_FRAGMENT( abc1600_mover ) - MCFG_DEFAULT_LAYOUT(layout_abc1600) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) // not accurate - MCFG_SCREEN_UPDATE_DRIVER(abc1600_mover_device, screen_update) - MCFG_SCREEN_SIZE(958, 1067) - MCFG_SCREEN_VISIBLE_AREA(0, 958-1, 0, 1067-1) - - MCFG_PALETTE_ADD_MONOCHROME_GREEN("palette") - - MCFG_MC6845_ADD(SY6845E_TAG, SY6845E, SCREEN_TAG, XTAL_64MHz/32) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(32) - MCFG_MC6845_UPDATE_ROW_CB(abc1600_mover_device, crtc_update_row) - MCFG_MC6845_ADDR_CHANGED_CB(abc1600_mover_device, crtc_update) -MACHINE_CONFIG_END - - -//------------------------------------------------- -// machine_config_additions - device-specific -// machine configurations -//------------------------------------------------- - -machine_config_constructor abc1600_mover_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( abc1600_mover ); -} - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// abc1600_mover_device - constructor -//------------------------------------------------- - -abc1600_mover_device::abc1600_mover_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, ABC1600_MOVER, "ABC 1600 Mover", tag, owner, clock, "abc1600mover", __FILE__), - device_memory_interface(mconfig, *this), - m_space_config("vram", ENDIANNESS_BIG, 16, 18, -1, *ADDRESS_MAP_NAME(mover_map)), - m_crtc(*this, SY6845E_TAG), - m_palette(*this, "palette"), - m_wrmsk_rom(*this, "wrmsk"), - m_shinf_rom(*this, "shinf"), - m_drmsk_rom(*this, "drmsk") -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void abc1600_mover_device::device_start() -{ - // state saving - save_item(NAME(m_endisp)); - save_item(NAME(m_clocks_disabled)); - save_item(NAME(m_gmdi)); - save_item(NAME(m_wrm)); - save_item(NAME(m_ms)); - save_item(NAME(m_ds)); - save_item(NAME(m_flag)); - save_item(NAME(m_xsize)); - save_item(NAME(m_ysize)); - save_item(NAME(m_udx)); - save_item(NAME(m_udy)); - save_item(NAME(m_xfrom)); - save_item(NAME(m_xto)); - save_item(NAME(m_yto)); - save_item(NAME(m_ty)); - save_item(NAME(m_mfa)); - save_item(NAME(m_mta)); - save_item(NAME(m_sh)); - save_item(NAME(m_mdor)); - save_item(NAME(m_hold_1w_cyk)); - save_item(NAME(m_wrms0)); - save_item(NAME(m_wrms1)); - save_item(NAME(m_rmc)); - save_item(NAME(m_cmc)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void abc1600_mover_device::device_reset() -{ - // disable display - m_clocks_disabled = 1; - m_endisp = 0; -} - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -const address_space_config *abc1600_mover_device::memory_space_config(address_spacenum spacenum) const -{ - return (spacenum == AS_0) ? &m_space_config : NULL; -} - - -//------------------------------------------------- -// read_videoram - -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::read_videoram(offs_t offset) -{ - return space().read_word((offset & VIDEORAM16_MASK) << 1); -} - - -//------------------------------------------------- -// write_videoram - -//------------------------------------------------- - -inline void abc1600_mover_device::write_videoram(offs_t offset, UINT16 data, UINT16 mask) -{ - UINT16 old_data = read_videoram(offset); - - space().write_word((offset & VIDEORAM16_MASK) << 1, (data & mask) | (old_data & (mask ^ 0xffff))); -} - - -//------------------------------------------------- -// video_ram_r - -//------------------------------------------------- - -READ8_MEMBER( abc1600_mover_device::video_ram_r ) -{ - offs_t addr = (offset & VIDEORAM8_MASK) >> 1; - UINT8 data = 0; - - if (offset & 0x01) - { - data = read_videoram(addr) & 0xff; - } - else - { - data = read_videoram(addr) >> 8; - } - - return data; -} - - -//------------------------------------------------- -// video_ram_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::video_ram_w ) -{ - offs_t addr = (offset & VIDEORAM8_MASK) >> 1; - - if (offset & 0x01) - { - if (REPLACE) - { - // WRPORT_LB - m_wrm = (m_wrm & 0xff00) | data; - if (LOG) logerror("WRM LB %02x -> %04x\n", data, m_wrm); - } - else - { - // DATAPORT_LB - m_gmdi = (m_gmdi & 0xff00) | data; - if (LOG) logerror("GMDI LB %02x -> %04x\n", data, m_gmdi); - } - - write_videoram(addr, m_gmdi, m_wrm & 0x00ff); - - if (LOG) logerror("Video RAM write LB to %05x : %04x\n", addr, read_videoram(addr)); - } - else - { - if (REPLACE) - { - // WRPORT_HB - m_wrm = (data << 8) | (m_wrm & 0xff); - if (LOG) logerror("WRM HB %02x -> %04x\n", data, m_wrm); - } - else - { - // DATAPORT_HB - m_gmdi = (data << 8) | (m_gmdi & 0xff); - if (LOG) logerror("GMDI HB %02x -> %04x\n", data, m_gmdi); - } - - write_videoram(addr, m_gmdi, m_wrm & 0xff00); - - if (LOG) logerror("Video RAM write HB to %05x : %04x\n", addr, read_videoram(addr)); - } -} - - -//------------------------------------------------- -// iord0_r - -//------------------------------------------------- - -READ8_MEMBER( abc1600_mover_device::iord0_r ) -{ - /* - - bit description - - 0 0 - 1 SCREENPOS - 2 - 3 - 4 - 5 - 6 VSYNC - 7 BUSY - - */ - - UINT8 data = 0; - - // monitor orientation (portrait/landscape) - data |= machine().render().first_target()->view() << 1; - - // vertical sync - data |= m_crtc->vsync_r() << 6; - - return data; -} - - -//------------------------------------------------- -// ldsx_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldsx_hb_w ) -{ - /* - - bit description - - 0 XSIZE8 - 1 XSIZE9 - 2 U/D* Y - 3 U/D* X - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDSX HB: %02x\n", machine().describe_context(), data); - - m_xsize = ((data & 0x03) << 8) | (m_xsize & 0xff); - m_udy = BIT(data, 2); - m_udx = BIT(data, 3); -} - - -//------------------------------------------------- -// ldsx_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldsx_lb_w ) -{ - /* - - bit description - - 0 XSIZE0 - 1 XSIZE1 - 2 XSIZE2 - 3 XSIZE3 - 4 XSIZE4 - 5 XSIZE5 - 6 XSIZE6 - 7 XSIZE7 - - */ - - if (LOG) logerror("%s LDSX LB: %02x\n", machine().describe_context(), data); - - m_xsize = (m_xsize & 0x300) | data; -} - - -//------------------------------------------------- -// ldsy_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldsy_hb_w ) -{ - /* - - bit description - - 0 YSIZE8 - 1 YSIZE9 - 2 YSIZE10 - 3 YSIZE11 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDSY HB: %02x\n", machine().describe_context(), data); - - m_ysize = ((data & 0x0f) << 8) | (m_ysize & 0xff); -} - - -//------------------------------------------------- -// ldsy_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldsy_lb_w ) -{ - /* - - bit description - - 0 YSIZE0 - 1 YSIZE1 - 2 YSIZE2 - 3 YSIZE3 - 4 YSIZE4 - 5 YSIZE5 - 6 YSIZE6 - 7 YSIZE7 - - */ - - if (LOG) logerror("%s LDSY LB: %02x\n", machine().describe_context(), data); - - m_ysize = (m_ysize & 0xf00) | data; -} - - -//------------------------------------------------- -// ldtx_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldtx_hb_w ) -{ - /* - - bit description - - 0 XTO8, MTA4 - 1 XTO9, MTA5 - 2 - 3 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDTX HB: %02x\n", machine().describe_context(), data); - - m_xto = ((data & 0x03) << 8) | (m_xto & 0xff); - m_mta = (m_mta & 0x3ffcf) | ((data & 0x03) << 4); -} - - -//------------------------------------------------- -// ldtx_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldtx_lb_w ) -{ - /* - - bit description - - 0 XTO0 - 1 XTO1 - 2 XTO2 - 3 XTO3 - 4 XTO4, MTA0 - 5 XTO5, MTA1 - 6 XTO6, MTA2 - 7 XTO7, MTA3 - - */ - - if (LOG) logerror("%s LDTX LB: %02x\n", machine().describe_context(), data); - - m_xto = (m_xto & 0x300) | data; - m_mta = (m_mta & 0x3fff0) | (data >> 4); -} - - -//------------------------------------------------- -// ldty_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldty_hb_w ) -{ - /* - - bit description - - 0 YTO8, MTA14 - 1 YTO9, MTA15 - 2 YTO10, MTA16 - 3 YTO11, MTA17 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDTY HB: %02x\n", machine().describe_context(), data); - - if (L_P) return; - - m_ty = ((data & 0x0f) << 8) | (m_yto & 0xff); - m_yto = ((data & 0x0f) << 8) | (m_yto & 0xff); - m_mta = ((data & 0x0f) << 14) | (m_mta & 0x3fff); -} - - -//------------------------------------------------- -// ldty_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldty_lb_w ) -{ - /* - - bit description - - 0 YTO0, MTA6 - 1 YTO1, MTA7 - 2 YTO2, MTA8 - 3 YTO3, MTA9 - 4 YTO4, MTA10 - 5 YTO5, MTA11 - 6 YTO6, MTA12 - 7 YTO7, MTA13 - - */ - - if (LOG) logerror("%s LDTY LB: %02x\n", machine().describe_context(), data); - - if (L_P) return; - - m_ty = (m_ty & 0xf00) | data; - m_yto = (m_yto & 0xf00) | data; - m_mta = (m_mta & 0x3c03f) | (data << 6); -} - - -//------------------------------------------------- -// ldfx_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldfx_hb_w ) -{ - /* - - bit description - - 0 XFROM8, MFA4 - 1 XFROM9, MFA5 - 2 - 3 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDFX HB: %02x\n", machine().describe_context(), data); - - m_xfrom = ((data & 0x03) << 8) | (m_xfrom & 0xff); - m_mfa = (m_mfa & 0x3ffcf) | ((data & 0x03) << 4); -} - - -//------------------------------------------------- -// ldfx_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldfx_lb_w ) -{ - /* - - bit description - - 0 XFROM0 - 1 XFROM1 - 2 XFROM2 - 3 XFROM3 - 4 XFROM4, MFA0 - 5 XFROM5, MFA1 - 6 XFROM6, MFA2 - 7 XFROM7, MFA3 - - */ - - if (LOG) logerror("%s LDFX LB: %02x\n", machine().describe_context(), data); - - m_xfrom = (m_xfrom & 0x300) | data; - m_mfa = (m_mfa & 0x3fff0) | (data >> 4); -} - - -//------------------------------------------------- -// ldfy_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldfy_hb_w ) -{ - /* - - bit description - - 0 MFA14 - 1 MFA15 - 2 MFA16 - 3 MFA17 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("%s LDFY HB: %02x\n", machine().describe_context(), data); - - m_mfa = ((data & 0x0f) << 14) | (m_mfa & 0x3fff); -} - - -//------------------------------------------------- -// ldfy_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::ldfy_lb_w ) -{ - /* - - bit description - - 0 MFA6 - 1 MFA7 - 2 MFA8 - 3 MFA9 - 4 MFA10 - 5 MFA11 - 6 MFA12 - 7 MFA13 - - */ - - if (LOG) logerror("%s LDFY LB: %02x\n", machine().describe_context(), data); - - m_mfa = (m_mfa & 0x3c03f) | (data << 6); - - mover(); -} - - -//------------------------------------------------- -// wrml_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::wrml_w ) -{ - /* - - bit description - - 0 MOVE CYK CLK - 1 DISP CYC SEL / DISP CYK PRE FETCH (+1 PIXCLK) - 2 DATA CLK - 3 _DISP MEM WE - 4 _CAS HB - 5 DTACK CLK / BLANK TEST (+2 PIXCLK) - 6 DISPREC CLK - 7 _RAS HB - - */ - - if (LOG) logerror("MS %u : %02x\n", (offset >> 4) & 0x0f, data); - - if (m_clocks_disabled) - { - m_ms[(offset >> 4) & 0x0f] = data; - } -} - - -//------------------------------------------------- -// wrdl_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::wrdl_w ) -{ - /* - - bit description - - 0 MOVE CYK CLK - 1 DISP CYC SEL / DISP CYK PRE FETCH (+1 PIXCLK) - 2 DATA CLK - 3 _DISP MEM WE - 4 _CAS HB - 5 DTACK CLK / BLANK TEST (+2 PIXCLK) - 6 DISPREC CLK - 7 _RAS HB - - */ - - if (LOG) logerror("WS %u : %02x\n", (offset >> 4) & 0x0f, data); - - if (m_clocks_disabled) - { - m_ds[(offset >> 4) & 0x0f] = data; - } -} - - -//------------------------------------------------- -// wrmask_strobe_hb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::wrmask_strobe_hb_w ) -{ - if (REPLACE) - { - // DATAPORT_HB - m_gmdi = (data << 8) | (m_gmdi & 0xff); - if (LOG) logerror("GMDI HB %04x\n", m_gmdi); - } - else - { - // WRPORT_HB - m_wrm = (data << 8) | (m_wrm & 0xff); - if (LOG) logerror("WRM HB %04x\n", m_gmdi); - } -} - - -//------------------------------------------------- -// wrmask_strobe_lb_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::wrmask_strobe_lb_w ) -{ - if (REPLACE) - { - // DATAPORT_LB - m_gmdi = (m_gmdi & 0xff00) | data; - if (LOG) logerror("GMDI LB %04x\n", m_gmdi); - } - else - { - // WRPORT_LB - m_wrm = (m_wrm & 0xff00) | data; - if (LOG) logerror("WRM LB %04x\n", m_gmdi); - } -} - - -//------------------------------------------------- -// enable_clocks_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::enable_clocks_w ) -{ - if (LOG) logerror("ENABLE CLOCKS\n"); - m_clocks_disabled = 0; -} - - -//------------------------------------------------- -// flag_strobe_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::flag_strobe_w ) -{ - /* - - bit description - - 0 L/_P FLAG - 1 BLANK FLAG - 2 PIX POL - 3 FRAME POL - 4 HOLD FY - 5 HOLD FX - 6 COMP MOVE FLAG - 7 REPLACE/SET & RESET - - */ - - m_flag = data; - if (LOG) logerror("FLAG %02x\n", m_flag); -} - - -//------------------------------------------------- -// endisp_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc1600_mover_device::endisp_w ) -{ - m_endisp = 1; - if (LOG) logerror("ENDISP\n"); -} - - - -//************************************************************************** -// MOVER -//************************************************************************** - -//------------------------------------------------- -// clock_mfa_x - -//------------------------------------------------- - -inline void abc1600_mover_device::clock_mfa_x() -{ - UINT16 mfa_y = m_mfa >> 6; - UINT8 mfa_x = m_mfa & 0x3f; - - if (!HOLD_FX) - { - mfa_x += m_udx ? 1 : -1; - mfa_x &= 0x3f; - } - - m_mfa = (mfa_y << 6) | mfa_x; -} - - -//------------------------------------------------- -// clock_mfa_y - -//------------------------------------------------- - -inline void abc1600_mover_device::clock_mfa_y() -{ - UINT16 mfa_y = m_mfa >> 6; - UINT8 mfa_x = m_mfa & 0x3f; - - if (!HOLD_FY) - { - mfa_y += m_udy ? 1 : -1; - mfa_y &= 0xfff; - } - - m_mfa = (mfa_y << 6) | mfa_x; -} - - -//------------------------------------------------- -// clock_mta_x - -//------------------------------------------------- - -inline void abc1600_mover_device::clock_mta_x() -{ - UINT16 mta_y = m_mta >> 6; - UINT8 mta_x = m_mta & 0x3f; - - mta_x += m_udx ? 1 : -1; - mta_x &= 0x3f; - - m_mta = (mta_y << 6) | mta_x; -} - - -//------------------------------------------------- -// clock_mta_y - -//------------------------------------------------- - -inline void abc1600_mover_device::clock_mta_y() -{ - UINT16 mta_y = m_mta >> 6; - UINT8 mta_x = m_mta & 0x3f; - - mta_y += m_udy ? 1 : -1; - mta_y &= 0xfff; - - m_mta = (mta_y << 6) | mta_x; -} - - -//------------------------------------------------- -// load_mfa_x - -//------------------------------------------------- - -inline void abc1600_mover_device::load_mfa_x() -{ - UINT16 mfa_y = m_mfa >> 6; - UINT8 mfa_x = m_xfrom >> 4; - - m_mfa = (mfa_y << 6) | mfa_x; -} - - -//------------------------------------------------- -// load_mta_x - -//------------------------------------------------- - -inline void abc1600_mover_device::load_mta_x() -{ - UINT16 mta_y = m_mta >> 6; - UINT8 mta_x = m_xto >> 4; - - m_mta = (mta_y << 6) | mta_x; -} - - -//------------------------------------------------- -// load_xy_reg - -//------------------------------------------------- - -inline void abc1600_mover_device::load_xy_reg() -{ - if (L_P) return; - - UINT16 sum = m_xto + m_xsize; - - m_xto = sum & 0x3ff; - m_yto = m_ty & 0xfff; - m_mta = (m_ty << 6) | (sum >> 4); -} - - -//------------------------------------------------- -// compare_mta_x - -//------------------------------------------------- - -inline void abc1600_mover_device::compare_mta_x() -{ - UINT8 mta_x_end = ((m_xto + m_xsize) >> 4) & 0x3f; - UINT8 mta_x = m_mta & 0x3f; - - if (mta_x == mta_x_end) - { - m_cmc = 0; - } - - m_wrms1 = m_cmc & m_amm; -} - - -//------------------------------------------------- -// compare_mta_y - -//------------------------------------------------- - -inline void abc1600_mover_device::compare_mta_y() -{ - int mta_y_end = (m_yto + m_ysize) & 0xfff; - UINT16 mta_y = m_mta >> 6; - - if (mta_y == mta_y_end) - { - m_rmc = 0; - } -} - - -//------------------------------------------------- -// get_shinf - -//------------------------------------------------- - -inline void abc1600_mover_device::get_shinf() -{ - /* - - bit description - - A0 XFROM0 - A1 XFROM1 - A2 XFROM2 - A3 XFROM3 - A4 XTO0 - A5 XTO1 - A6 XTO2 - A7 XTO3 - A8 U/D* X - - */ - - UINT16 shinf_addr = (m_udx << 8) | ((m_xto & 0x0f) << 4) | (m_xfrom & 0x0f); - UINT8 shinf = m_shinf_rom[shinf_addr]; - - m_sh = shinf & 0x0f; - m_hold_1w_cyk = BIT(shinf, 5); -} - - -//------------------------------------------------- -// get_drmsk - -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::get_drmsk() -{ - /* - - bit description - - A0 SH0 - A1 SH1 - A2 SH2 - A3 SH3 - A4 U/D* X - - */ - - UINT16 drmsk_addr = (m_udx << 4) | (m_sh & 0x0f); - return m_drmsk_rom[drmsk_addr]; -} - - -//------------------------------------------------- -// get_wrmsk - get mover write mask -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::get_wrmsk() -{ - /* - - bit description - - A0 XTO0 - A1 XTO1 - A2 XTO2 - A3 XTO3 - A4 XSIZE0 - A5 XSIZE1 - A6 XSIZE2 - A7 XSIZE3 - A8 U/D* X - A9 ANDED MASKS - A10 WRMS0 - A11 WRMS1 - - */ - - UINT16 wrmsk_addr = (m_wrms1 << 11) | (m_wrms0 << 10) | ((!m_wrms1 && !m_wrms0) << 9) | (m_udx << 8) | ((m_xsize & 0x0f) << 4) | (m_xto & 0x0f); - return m_wrmsk_rom[wrmsk_addr] ^ 0xffff; -} - - -//------------------------------------------------- -// barrel_shift - -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::barrel_shift(UINT16 gmdr) -{ - UINT16 rot = gmdr; - - for (int sh = 0; sh < m_sh; sh++) - { - int msb = BIT(rot, 15); - rot <<= 1; - rot |= msb; - } - - return rot; -} - - -//------------------------------------------------- -// word_mixer - -//------------------------------------------------- - -inline UINT16 abc1600_mover_device::word_mixer(UINT16 rot) -{ - UINT16 drmsk = get_drmsk(); - UINT16 gmdi = (rot & drmsk) | (m_mdor & (drmsk ^ 0xffff)); - - if (COMP_MOVE) - { - gmdi ^= 0xffff; - } - - m_mdor = rot; - - return gmdi; -} - - -//------------------------------------------------- -// mover - -//------------------------------------------------- - -void abc1600_mover_device::mover() -{ - if (LOG) logerror("XFROM %u XSIZE %u YSIZE %u XTO %u YTO %u MFA %05x MTA %05x U/D*X %u U/D*Y %u\n", m_xfrom, m_xsize, m_ysize, m_xto, m_yto, m_mfa, m_mta, m_udx, m_udy); - - m_amm = 1; - - m_rmc = 1; - get_shinf(); - - do - { - compare_mta_y(); - - load_mfa_x(); - load_mta_x(); - m_cmc = 1; - m_wrms0 = 0; - - if (m_hold_1w_cyk) - { - // read one word in advance - UINT16 gmdr = read_videoram(m_mfa); - UINT16 rot = barrel_shift(gmdr); - word_mixer(rot); - - clock_mfa_x(); - } - - do - { - compare_mta_x(); - - UINT16 gmdr = read_videoram(m_mfa); - UINT16 rot = barrel_shift(gmdr); - UINT16 gmdi = word_mixer(rot); - UINT16 mask = get_wrmsk(); - - write_videoram(m_mta, gmdi, mask); - - clock_mfa_x(); - clock_mta_x(); - - m_wrms0 = 1; - } - while (m_cmc); - - clock_mfa_y(); - clock_mta_y(); - } - while (m_rmc); - - load_xy_reg(); - - m_amm = 0; -} - -UINT32 abc1600_mover_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - if (m_endisp) - { - bitmap.fill(m_palette->pen(FRAME_POL), cliprect); - m_crtc->screen_update(screen, bitmap, cliprect); - } - else - { - bitmap.fill(rgb_t::black, cliprect); - } - - return 0; -} diff --git a/src/mess/video/abc1600.h b/src/mess/video/abc1600.h deleted file mode 100644 index 172967c783d..00000000000 --- a/src/mess/video/abc1600.h +++ /dev/null @@ -1,151 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Luxor ABC 1600 Mover emulation - -**********************************************************************/ - -#pragma once - -#ifndef __ABC1600_MOVER__ -#define __ABC1600_MOVER__ - -#include "emu.h" -#include "video/mc6845.h" - - - -///************************************************************************* -// INTERFACE CONFIGURATION MACROS -///************************************************************************* - -#define ABC1600_MOVER_TAG "mover" - - -#define MCFG_ABC1600_MOVER_ADD() \ - MCFG_DEVICE_ADD(ABC1600_MOVER_TAG, ABC1600_MOVER, 0) - - - -///************************************************************************* -// TYPE DEFINITIONS -///************************************************************************* - -// ======================> abc1600_mover_device - -class abc1600_mover_device : public device_t, - public device_memory_interface -{ -public: - // construction/destruction - abc1600_mover_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - // optional information overrides - virtual const rom_entry *device_rom_region() const; - virtual machine_config_constructor device_mconfig_additions() const; - - virtual DECLARE_ADDRESS_MAP(vram_map, 8); - virtual DECLARE_ADDRESS_MAP(crtc_map, 8); - virtual DECLARE_ADDRESS_MAP(io_map, 8); - - UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - - MC6845_UPDATE_ROW(crtc_update_row); - MC6845_ON_UPDATE_ADDR_CHANGED(crtc_update); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - - // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; - -private: - inline UINT16 get_drmsk(); - inline void get_shinf(); - inline UINT16 get_wrmsk(); - inline UINT16 barrel_shift(UINT16 gmdr); - inline UINT16 word_mixer(UINT16 rot); - inline void clock_mfa_x(); - inline void clock_mfa_y(); - inline void clock_mta_x(); - inline void clock_mta_y(); - inline void load_mfa_x(); - inline void load_mta_x(); - inline void compare_mta_x(); - inline void compare_mta_y(); - inline void load_xy_reg(); - void mover(); - - DECLARE_READ8_MEMBER( video_ram_r ); - DECLARE_WRITE8_MEMBER( video_ram_w ); - - DECLARE_READ8_MEMBER( iord0_r ); - DECLARE_WRITE8_MEMBER( ldsx_hb_w ); - DECLARE_WRITE8_MEMBER( ldsx_lb_w ); - DECLARE_WRITE8_MEMBER( ldsy_hb_w ); - DECLARE_WRITE8_MEMBER( ldsy_lb_w ); - DECLARE_WRITE8_MEMBER( ldtx_hb_w ); - DECLARE_WRITE8_MEMBER( ldtx_lb_w ); - DECLARE_WRITE8_MEMBER( ldty_hb_w ); - DECLARE_WRITE8_MEMBER( ldty_lb_w ); - DECLARE_WRITE8_MEMBER( ldfx_hb_w ); - DECLARE_WRITE8_MEMBER( ldfx_lb_w ); - DECLARE_WRITE8_MEMBER( ldfy_hb_w ); - DECLARE_WRITE8_MEMBER( ldfy_lb_w ); - DECLARE_WRITE8_MEMBER( wrml_w ); - DECLARE_WRITE8_MEMBER( wrdl_w ); - DECLARE_WRITE8_MEMBER( wrmask_strobe_hb_w ); - DECLARE_WRITE8_MEMBER( wrmask_strobe_lb_w ); - DECLARE_WRITE8_MEMBER( enable_clocks_w ); - DECLARE_WRITE8_MEMBER( flag_strobe_w ); - DECLARE_WRITE8_MEMBER( endisp_w ); - - inline UINT16 read_videoram(offs_t offset); - inline void write_videoram(offs_t offset, UINT16 data, UINT16 mask); - inline UINT16 get_crtca(UINT16 ma, UINT8 ra, UINT8 column); - - const address_space_config m_space_config; - - required_device m_crtc; - required_device m_palette; - required_region_ptr m_wrmsk_rom; - required_region_ptr m_shinf_rom; - required_region_ptr m_drmsk_rom; - - int m_endisp; // enable display - int m_clocks_disabled; // clocks disabled - UINT16 m_gmdi; // video RAM data latch - UINT16 m_wrm; // write mask latch - UINT8 m_ms[16]; // mover sequence control - UINT8 m_ds[16]; // display sequence control - UINT8 m_flag; // flags - UINT16 m_xsize; // X size - UINT16 m_ysize; // Y size - int m_udx; // up/down X - int m_udy; // up/down Y - UINT16 m_xfrom; // X from - UINT16 m_xto; // X to - UINT16 m_yto; // Y to - UINT16 m_ty; // to Y - UINT32 m_mfa; // mover from address - UINT32 m_mta; // mover to address - UINT8 m_sh; // - UINT16 m_mdor; // - int m_hold_1w_cyk; // - int m_wrms0; // - int m_wrms1; // - int m_rmc; // row match count - int m_cmc; // column match count - int m_amm; // active mover mask -}; - - -// device type definition -extern const device_type ABC1600_MOVER; - - - -#endif diff --git a/src/mess/video/abc80.c b/src/mess/video/abc80.c deleted file mode 100644 index 30272f3b0ea..00000000000 --- a/src/mess/video/abc80.c +++ /dev/null @@ -1,205 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/***************************************************************************** - * - * video/abc80.c - * - ****************************************************************************/ - -#include "emu.h" -#include "includes/abc80.h" - - - -//------------------------------------------------- -// gfx_layout charlayout -//------------------------------------------------- - -static const gfx_layout charlayout = -{ - 6, 10, - 128, - 1, - { 0 }, - { 0, 1, 2, 3, 4, 5 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8 }, - 10*8 -}; - - -//------------------------------------------------- -// GFXDECODE( abc80 ) -//------------------------------------------------- - -static GFXDECODE_START( abc80 ) - GFXDECODE_ENTRY( "chargen", 0, charlayout, 0, 1 ) // normal characters - GFXDECODE_ENTRY( "chargen", 0x500, charlayout, 0, 1 ) // graphics characters -GFXDECODE_END - - -//------------------------------------------------- -// update_screen - -//------------------------------------------------- - -void abc80_state::update_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int c = 0; - int r = 0; - int mode = 0; - - for (int y = 0; y < 312; y++) - { - UINT8 vsync_data = m_vsync_prom->base()[y]; - UINT8 l = m_line_prom->base()[y]; - int dv = (vsync_data & ABC80_K2_DV) ? 1 : 0; - - if (!(vsync_data & ABC80_K2_FRAME_RESET)) - { - // reset F2 - r = 0; - } - - for (int sx = 0; sx < 64; sx++) - { - UINT8 hsync_data = m_hsync_prom->base()[sx]; - int dh = (hsync_data & ABC80_K5_DH) ? 1 : 0; - UINT8 data = 0; - - if (hsync_data & ABC80_K5_LINE_END) - { - // reset F4 - c = 0; - - // reset J5 - mode = 0; - } - - /* - - Video RAM Addressing Scheme - - A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 - R2 R1 R0 xx xx xx xx C2 C1 C0 - - A6 A5 A4 A3 = 00 C5 C4 C3 + R4 R3 R4 R3 - - */ - - int a = (c >> 3) & 0x07; - int b = ((r >> 1) & 0x0c) | ((r >> 3) & 0x03); - int s = (a + b) & 0x0f; - UINT16 videoram_addr = ((r & 0x07) << 7) | (s << 3) | (c & 0x07); - UINT8 videoram_data = m_latch; - UINT8 attr_addr = ((dh & dv) << 7) | (videoram_data & 0x7f); - UINT8 attr_data = m_attr_prom->base()[attr_addr]; - - int blank = (attr_data & ABC80_J3_BLANK) ? 1 : 0; - int j = (attr_data & ABC80_J3_TEXT) ? 1 : 0; - int k = (attr_data & ABC80_J3_GRAPHICS) ? 1 : 0; - int versal = (attr_data & ABC80_J3_VERSAL) ? 1 : 0; - int cursor = (videoram_data & ABC80_CHAR_CURSOR) ? 1 : 0; - - if (!j && k) mode = 0; - if (j && !k) mode = 1; - if (j && k) mode = !mode; - - if (mode & versal) - { - // graphics mode - int r0 = 1, r1 = 1, r2 = 1; - - if (l < 3) r0 = 0; else if (l < 7) r1 = 0; else r2 = 0; - - int c0 = BIT(videoram_data, 0) | r0; - int c1 = BIT(videoram_data, 1) | r0; - int c2 = BIT(videoram_data, 2) | r1; - int c3 = BIT(videoram_data, 3) | r1; - int c4 = BIT(videoram_data, 4) | r2; - int c5 = BIT(videoram_data, 6) | r2; - - if (!(c0 & c2 & c4)) data |= 0xe0; - if (!(c1 & c3 & c5)) data |= 0x1c; - } - else - { - // text mode - UINT16 chargen_addr = ((videoram_data & 0x7f) * 10) + l; - - data = m_char_rom->base()[chargen_addr]; - } - - // shift out pixels - for (int bit = 0; bit < 6; bit++) - { - int color = BIT(data, 7); - int x = (sx * 6) + bit; - - color ^= (cursor & m_blink); - color &= blank; - - bitmap.pix32(y, x) = m_palette->pen(color); - - data <<= 1; - } - - m_latch = m_video_ram[videoram_addr]; - - if (hsync_data & ABC80_K5_ROW_START) - { - // clock F4 - c++; - } - } - - if (vsync_data & ABC80_K2_FRAME_END) - { - // clock F2 - r++; - } - } -} - - -void abc80_state::video_start() -{ - screen_device *screen = machine().device(SCREEN_TAG); - - // start timers - m_pio_timer = timer_alloc(TIMER_ID_PIO); - m_pio_timer->adjust(screen->time_until_pos(0, 0), 0, screen->scan_period()); - - m_blink_timer = timer_alloc(TIMER_ID_BLINK); - m_blink_timer->adjust(attotime::from_hz(XTAL_11_9808MHz/2/6/64/312/16), 0, attotime::from_hz(XTAL_11_9808MHz/2/6/64/312/16)); - - m_vsync_on_timer = timer_alloc(TIMER_ID_VSYNC_ON); - m_vsync_on_timer->adjust(screen->time_until_pos(0, 0), 0, screen->frame_period()); - - m_vsync_off_timer = timer_alloc(TIMER_ID_VSYNC_OFF); - m_vsync_off_timer->adjust(screen->time_until_pos(16, 0), 0, screen->frame_period()); - - // allocate memory - m_video_ram.allocate(0x400); -} - - -UINT32 abc80_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - update_screen(bitmap, cliprect); - - return 0; -} - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc80_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( abc80_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(abc80_state, screen_update) - - MCFG_SCREEN_RAW_PARAMS(XTAL_11_9808MHz/2, ABC80_HTOTAL, ABC80_HBEND, ABC80_HBSTART, ABC80_VTOTAL, ABC80_VBEND, ABC80_VBSTART) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", abc80) - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") -MACHINE_CONFIG_END diff --git a/src/mess/video/abc800.c b/src/mess/video/abc800.c deleted file mode 100644 index ee9fc3a19de..00000000000 --- a/src/mess/video/abc800.c +++ /dev/null @@ -1,311 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/***************************************************************************** - * - * video/abc800.c - * - ****************************************************************************/ - -#include "includes/abc80x.h" - - - -// these are needed because the MC6845 emulation does -// not position the active display area correctly -#define HORIZONTAL_PORCH_HACK 115 -#define VERTICAL_PORCH_HACK 29 - - - -//************************************************************************** -// HIGH RESOLUTION GRAPHICS -//************************************************************************** - -//------------------------------------------------- -// hrs_w - high resolution scanline write -//------------------------------------------------- - -WRITE8_MEMBER( abc800_state::hrs_w ) -{ - m_hrs = data; -} - - -//------------------------------------------------- -// hrc_w - high resolution color write -//------------------------------------------------- - -WRITE8_MEMBER( abc800_state::hrc_w ) -{ - m_fgctl = data; -} - - - -//************************************************************************** -// ABC 800 COLOR -//************************************************************************** - -//------------------------------------------------- -// translate_trom_offset - -//------------------------------------------------- - -offs_t abc800c_state::translate_trom_offset(offs_t offset) -{ - int row = offset / 40; - int col = offset % 40; - - offset = ((row & 0x07) * 0x80) + col; - - if (row & 0x08) offset += 0x28; - if (row & 0x10) offset += 0x50; - - return offset; -} - - -//------------------------------------------------- -// hr_update - high resolution screen update -//------------------------------------------------- - -void abc800c_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - const pen_t *pen = m_palette->pens(); - - UINT16 addr = 0; - - for (int y = m_hrs; y < MIN(cliprect.max_y + 1, m_hrs + 480); y += 2) - { - int x = 0; - - for (int sx = 0; sx < 64; sx++) - { - UINT8 data = m_video_ram[addr++]; - - for (int dot = 0; dot < 4; dot++) - { - UINT16 fgctl_addr = ((m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03); - UINT8 fgctl = m_fgctl_prom->base()[fgctl_addr]; - int color = fgctl & 0x07; - - if (color) - { - bool black = bitmap.pix32(y, x) == rgb_t::black; - bool opaque = !BIT(fgctl, 3); - - if (black || opaque) - { - bitmap.pix32(y, x) = pen[color]; - bitmap.pix32(y, x + 1) = pen[color]; - - bitmap.pix32(y + 1, x) = pen[color]; - bitmap.pix32(y + 1, x + 1) = pen[color]; - } - } - - data <<= 2; - x += 2; - } - } - } -} - - -void abc800_state::video_start() -{ - // register for state saving - save_item(NAME(m_hrs)); - save_item(NAME(m_fgctl)); -} - - -//------------------------------------------------- -// SCREEN_UPDATE( abc800c ) -//------------------------------------------------- - -UINT32 abc800c_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - // clear screen - bitmap.fill(rgb_t::black, cliprect); - - // draw text - if (!BIT(m_fgctl, 7)) - { - m_trom->screen_update(screen, bitmap, cliprect); - } - - // draw HR graphics - hr_update(bitmap, cliprect); - - return 0; -} - - -//------------------------------------------------- -// SAA5050_INTERFACE( trom_intf ) -//------------------------------------------------- - -READ8_MEMBER( abc800c_state::char_ram_r ) -{ - return m_char_ram[translate_trom_offset(offset)]; -} - - -//------------------------------------------------- -// PALETTE_INIT( abc800c ) -//------------------------------------------------- - -PALETTE_INIT_MEMBER( abc800c_state, abc800c ) -{ - palette.set_pen_color(0, rgb_t(0x00, 0x00, 0x00)); // black - palette.set_pen_color(1, rgb_t(0xff, 0x00, 0x00)); // red - palette.set_pen_color(2, rgb_t(0x00, 0xff, 0x00)); // green - palette.set_pen_color(3, rgb_t(0xff, 0xff, 0x00)); // yellow - palette.set_pen_color(4, rgb_t(0x00, 0x00, 0xff)); // blue - palette.set_pen_color(5, rgb_t(0xff, 0x00, 0xff)); // magenta - palette.set_pen_color(6, rgb_t(0x00, 0xff, 0xff)); // cyan - palette.set_pen_color(7, rgb_t(0xff, 0xff, 0xff)); // white -} - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc800c_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( abc800c_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(abc800c_state, screen_update) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_SIZE(480, 480) - MCFG_SCREEN_VISIBLE_AREA(0, 480-1, 0, 480-1) - - MCFG_PALETTE_ADD("palette", 8) - MCFG_PALETTE_INIT_OWNER(abc800c_state, abc800c) - - MCFG_DEVICE_ADD(SAA5052_TAG, SAA5052, XTAL_12MHz/2) - MCFG_SAA5050_D_CALLBACK(READ8(abc800c_state, char_ram_r)) - MCFG_SAA5050_SCREEN_SIZE(40, 24, 40) -MACHINE_CONFIG_END - - - -//************************************************************************** -// ABC 800 MONOCHROME -//************************************************************************** - -//------------------------------------------------- -// hr_update - high resolution screen update -//------------------------------------------------- - -void abc800m_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT16 addr = 0; - - const pen_t *pen = m_palette->pens(); - - for (int y = m_hrs + VERTICAL_PORCH_HACK; y < MIN(cliprect.max_y + 1, m_hrs + VERTICAL_PORCH_HACK + 240); y++) - { - int x = HORIZONTAL_PORCH_HACK; - - for (int sx = 0; sx < 64; sx++) - { - UINT8 data = m_video_ram[addr++]; - - for (int dot = 0; dot < 4; dot++) - { - UINT16 fgctl_addr = ((m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03); - int color = (m_fgctl_prom->base()[fgctl_addr] & 0x07) ? 1 : 0; - - bitmap.pix32(y, x++) = pen[color]; - bitmap.pix32(y, x++) = pen[color]; - - data <<= 2; - } - } - } -} - - -//------------------------------------------------- -// MC6845_UPDATE_ROW( abc800m_update_row ) -//------------------------------------------------- - -MC6845_UPDATE_ROW( abc800m_state::abc800m_update_row ) -{ - int column; - rgb_t fgpen = m_palette->pen(1); - - y += vbp; - - for (column = 0; column < x_count; column++) - { - int bit; - - UINT16 address = (m_char_ram[(ma + column) & 0x7ff] << 4) | (ra & 0x0f); - UINT8 data = (m_char_rom->base()[address & 0x7ff] & 0x3f); - - if (column == cursor_x) - { - data = 0x3f; - } - - data <<= 2; - - for (bit = 0; bit < ABC800_CHAR_WIDTH; bit++) - { - int x = hbp + (column * ABC800_CHAR_WIDTH) + bit; - - if (BIT(data, 7) && de) - { - bitmap.pix32(y, x) = fgpen; - } - - data <<= 1; - } - } -} - - -//------------------------------------------------- -// SCREEN_UPDATE( abc800m ) -//------------------------------------------------- - -UINT32 abc800m_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - // clear screen - bitmap.fill(rgb_t::black, cliprect); - - // draw HR graphics - hr_update(bitmap, cliprect); - - // draw text - if (!BIT(m_fgctl, 7)) - { - m_crtc->screen_update(screen, bitmap, cliprect); - } - - return 0; -} - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc800m_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( abc800m_video ) - MCFG_MC6845_ADD(MC6845_TAG, MC6845, SCREEN_TAG, ABC800_CCLK) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(ABC800_CHAR_WIDTH) - MCFG_MC6845_UPDATE_ROW_CB(abc800m_state, abc800m_update_row) - MCFG_MC6845_OUT_VSYNC_CB(DEVWRITELINE(Z80DART_TAG, z80dart_device, rib_w)) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(abc800m_state, screen_update) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_SIZE(768, 312) - MCFG_SCREEN_VISIBLE_AREA(0,768-1, 0, 312-1) - - MCFG_PALETTE_ADD_MONOCHROME_YELLOW("palette") -MACHINE_CONFIG_END diff --git a/src/mess/video/abc802.c b/src/mess/video/abc802.c deleted file mode 100644 index 667f8cfe931..00000000000 --- a/src/mess/video/abc802.c +++ /dev/null @@ -1,220 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/***************************************************************************** - * - * video/abc802.c - * - ****************************************************************************/ - -#include "includes/abc80x.h" - - - -//------------------------------------------------- -// MC6845_UPDATE_ROW( abc802_update_row ) -//------------------------------------------------- - -MC6845_UPDATE_ROW( abc802_state::abc802_update_row ) -{ - /* - - PAL16R4 equation: - - IF (VCC) *OS = FC + RF / RC - *RG: = HS / *RG + *ATE / *RG + ATD / *RG + LL / - *RG + AT1 / *RG + AT0 / ATE + *ATD + *LL + - *AT1 + *AT0 - *RI: = *RI + *INV / *RI + LL / *INV + *LL - *RF: = HS / *RF + *ATE / *RF + ATD / *RF + LL / - *RF + AT1 / *RF + AT0 / ATE + *ATD + *LL + - *AT1 + AT0 - *RC: = HS / *RC + *ATE / *RC + *ATD / *RC + LL / - *RC + *ATI / *RC + AT0 / ATE + *LL + *AT1 + - *AT0 - IF (VCC) *O0 = *CUR + *AT0 / *CUR + ATE - *O1 = *CUR + *AT1 / *CUR + ATE - - - + = AND - / = OR - * = Inverted - - ATD Attribute data - ATE Attribute enable - AT0,AT1 Attribute address - CUR Cursor - FC FLSH clock - HS Horizontal sync - INV Inverted signal input - LL Load when Low - OEL Output Enable when Low - RC Row clear - RF Row flash - RG Row graphic - RI Row inverted - - */ - - const pen_t *pen = m_palette->pens(); - - int rf = 0, rc = 0, rg = 0; - - y += vbp; - - for (int column = 0; column < x_count; column++) - { - UINT8 code = m_char_ram[(ma + column) & 0x7ff]; - UINT16 address = code << 4; - UINT8 ra_latch = ra; - UINT8 data; - - int ri = (code & ABC802_INV) ? 1 : 0; - - if (column == cursor_x) - { - ra_latch = 0x0f; - } - - if ((m_flshclk && rf) || rc) - { - ra_latch = 0x0e; - } - - if (rg) - { - address |= 0x800; - } - - data = m_char_rom->base()[(address + ra_latch) & 0xfff]; - - if (data & ABC802_ATE) - { - int attr = data & 0x03; - int value = (data & ABC802_ATD) ? 1 : 0; - - switch (attr) - { - case 0x00: - // Row Graphic - rg = value; - break; - - case 0x01: - // Row Flash - rf = value; - break; - - case 0x02: - // Row Clear - rc = value; - break; - - case 0x03: - // undefined - break; - } - } - else - { - data <<= 2; - - if (m_80_40_mux) - { - for (int bit = 0; bit < ABC800_CHAR_WIDTH; bit++) - { - int x = hbp + ((column + 3) * ABC800_CHAR_WIDTH) + bit; - int color = (BIT(data, 7) ^ ri) && de; - - bitmap.pix32(y, x) = pen[color]; - - data <<= 1; - } - } - else - { - for (int bit = 0; bit < ABC800_CHAR_WIDTH; bit++) - { - int x = hbp + ((column + 3) * ABC800_CHAR_WIDTH) + (bit << 1); - int color = (BIT(data, 7) ^ ri) && de; - - bitmap.pix32(y, x) = pen[color]; - bitmap.pix32(y, x + 1) = pen[color]; - - data <<= 1; - } - - column++; - } - } - } -} - - -//------------------------------------------------- -// vs_w - vertical sync write -//------------------------------------------------- - -WRITE_LINE_MEMBER( abc802_state::vs_w ) -{ - if (!state) - { - // flash clock - if (m_flshclk_ctr & 0x20) - { - m_flshclk = !m_flshclk; - m_flshclk_ctr = 0; - } - else - { - m_flshclk_ctr++; - } - } - - // signal _DEW to DART - m_dart->rib_w(!state); -} - - -void abc802_state::video_start() -{ - // register for state saving - save_item(NAME(m_flshclk_ctr)); - save_item(NAME(m_flshclk)); - save_item(NAME(m_80_40_mux)); -} - - -//------------------------------------------------- -// SCREEN_UPDATE( abc802 ) -//------------------------------------------------- - -UINT32 abc802_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - // draw text - m_crtc->screen_update(screen, bitmap, cliprect); - - return 0; -} - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc802_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( abc802_video ) - MCFG_MC6845_ADD(MC6845_TAG, MC6845, SCREEN_TAG, ABC800_CCLK) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(ABC800_CHAR_WIDTH) - MCFG_MC6845_UPDATE_ROW_CB(abc802_state, abc802_update_row) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(abc802_state, vs_w)) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(abc802_state, screen_update) - - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_SIZE(768, 312) - MCFG_SCREEN_VISIBLE_AREA(0,768-1, 0, 312-1) - - MCFG_PALETTE_ADD_MONOCHROME_AMBER("palette") -MACHINE_CONFIG_END diff --git a/src/mess/video/abc806.c b/src/mess/video/abc806.c deleted file mode 100644 index f958b025b1c..00000000000 --- a/src/mess/video/abc806.c +++ /dev/null @@ -1,507 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/***************************************************************************** - * - * video/abc806.c - * - ****************************************************************************/ - -#include "includes/abc80x.h" - - - -#define HORIZONTAL_PORCH_HACK 109 -#define VERTICAL_PORCH_HACK 27 - - - -//------------------------------------------------- -// hrs_w - high resolution memory banking -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::hrs_w ) -{ - /* - - bit signal description - - 0 VM14 visible screen memory area bit 0 - 1 VM15 visible screen memory area bit 1 - 2 VM16 visible screen memory area bit 2 - 3 VM17 visible screen memory area bit 3 - 4 F14 cpu accessible screen memory area bit 0 - 5 F15 cpu accessible screen memory area bit 1 - 6 F16 cpu accessible screen memory area bit 2 - 7 F17 cpu accessible screen memory area bit 3 - - */ - - m_hrs = data; -} - - -//------------------------------------------------- -// hrc_w - high resolution color write -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::hrc_w ) -{ - int reg = (offset >> 8) & 0x0f; - - m_hrc[reg] = data; -} - - -//------------------------------------------------- -// charram_r - character RAM read -//------------------------------------------------- - -READ8_MEMBER( abc806_state::charram_r ) -{ - m_attr_data = m_attr_ram[offset]; - - return m_char_ram[offset]; -} - - -//------------------------------------------------- -// charram_w - character RAM write -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::charram_w ) -{ - m_attr_ram[offset] = m_attr_data; - - m_char_ram[offset] = data; -} - - -//------------------------------------------------- -// ami_r - attribute memory read -//------------------------------------------------- - -READ8_MEMBER( abc806_state::ami_r ) -{ - return m_attr_data; -} - - -//------------------------------------------------- -// amo_w - attribute memory write -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::amo_w ) -{ - m_attr_data = data; -} - - -//------------------------------------------------- -// cli_r - palette PROM read -//------------------------------------------------- - -READ8_MEMBER( abc806_state::cli_r ) -{ - /* - - bit description - - 0 HRU II data bit 0 - 1 HRU II data bit 1 - 2 HRU II data bit 2 - 3 HRU II data bit 3 - 4 - 5 - 6 - 7 RTC data output - - */ - - UINT16 hru2_addr = (m_hru2_a8 << 8) | (offset >> 8); - UINT8 data = m_hru2_prom->base()[hru2_addr] & 0x0f; - - logerror("HRU II %03x : %01x\n", hru2_addr, data); - - data |= m_rtc->dio_r() << 7; - - return data; -} - - -//------------------------------------------------- -// sti_r - protection device read -//------------------------------------------------- - -READ8_MEMBER( abc806_state::sti_r ) -{ - /* - - bit description - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 PROT DOUT - - */ - - return 0x7f; -} - - -//------------------------------------------------- -// sto_w - -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::sto_w ) -{ - int level = BIT(data, 7); - - switch (data & 0x07) - { - case 0: - // external memory enable - m_eme = level; - break; - case 1: - // 40/80 column display - m_40 = level; - break; - case 2: - // HRU II address line 8, PROT A0 - m_hru2_a8 = level; - break; - case 3: - // PROT INI - break; - case 4: - // text display enable - m_txoff = level; - break; - case 5: - // RTC chip select - m_rtc->cs_w(!level); - break; - case 6: - // RTC clock - m_rtc->clk_w(level); - break; - case 7: - // RTC data in, PROT DIN - m_rtc->dio_w(level); - break; - } -} - - -//------------------------------------------------- -// sso_w - sync offset write -//------------------------------------------------- - -WRITE8_MEMBER( abc806_state::sso_w ) -{ - m_sync = data & 0x3f; -} - - -//------------------------------------------------- -// MC6845_UPDATE_ROW( abc806_update_row ) -//------------------------------------------------- - -MC6845_UPDATE_ROW( abc806_state::abc806_update_row ) -{ - const pen_t *pen = m_palette->pens(); - - int fg_color = 7; - int bg_color = 0; - int underline = 0; - int flash = 0; - int e5 = m_40; - int e6 = m_40; - int th = 0; - - y += m_sync + vbp; - - for (int column = 0; column < x_count; column++) - { - UINT8 data = m_char_ram[(ma + column) & 0x7ff]; - UINT8 attr = m_attr_ram[(ma + column) & 0x7ff]; - UINT8 rad_data; - - if ((attr & 0x07) == ((attr >> 3) & 0x07)) - { - // special case - switch (attr >> 6) - { - case 0: - // use previously selected attributes - break; - - case 1: - // reserved for future use - break; - - case 2: - // blank - fg_color = 0; - bg_color = 0; - underline = 0; - flash = 0; - break; - - case 3: - // double width - e5 = BIT(attr, 0); - e6 = BIT(attr, 1); - - // read attributes from next byte - attr = m_attr_ram[(ma + column + 1) & 0x7ff]; - - if (attr != 0x00) - { - fg_color = attr & 0x07; - bg_color = (attr >> 3) & 0x07; - underline = BIT(attr, 6); - flash = BIT(attr, 7); - } - break; - } - } - else - { - // normal case - fg_color = attr & 0x07; - bg_color = (attr >> 3) & 0x07; - underline = BIT(attr, 6); - flash = BIT(attr, 7); - e5 = m_40; - e6 = m_40; - } - - if (column == cursor_x) - { - rad_data = 0x0f; - } - else - { - UINT16 rad_addr = (e6 << 8) | (e5 << 7) | (flash << 6) | (underline << 4) | (m_flshclk << 5) | (ra & 0x0f); - rad_data = m_rad_prom->base()[rad_addr] & 0x0f; - } - - UINT16 chargen_addr = (th << 12) | (data << 4) | rad_data; - UINT8 chargen_data = m_char_rom->base()[chargen_addr & 0xfff] << 2; - int x = hbp + (column + 4) * ABC800_CHAR_WIDTH; - - for (int bit = 0; bit < ABC800_CHAR_WIDTH; bit++) - { - int color = BIT(chargen_data, 7) ? fg_color : bg_color; - if (!de) color = 0; - - bitmap.pix32(y, x++) = pen[color]; - - if (e5 || e6) - { - bitmap.pix32(y, x++) = pen[color]; - } - - chargen_data <<= 1; - } - - if (e5 || e6) - { - column++; - } - } -} - - -//------------------------------------------------- -// hs_w - horizontal sync write -//------------------------------------------------- - -WRITE_LINE_MEMBER( abc806_state::hs_w ) -{ - int vsync; - - if (!state) - { - m_v50_addr++; - - // clock current vsync value into the shift register - m_vsync_shift <<= 1; - m_vsync_shift |= m_vsync; - - vsync = BIT(m_vsync_shift, m_sync); - - if (!m_d_vsync && vsync) - { - // clear V50 address - m_v50_addr = 0; - } - else if (m_d_vsync && !vsync) - { - // flash clock - if (m_flshclk_ctr & 0x20) - { - m_flshclk = !m_flshclk; - m_flshclk_ctr = 0; - } - else - { - m_flshclk_ctr++; - } - } - - if (m_d_vsync != vsync) - { - // signal _DEW to DART - m_dart->rib_w(!vsync); - } - - m_d_vsync = vsync; - } -} - - -//------------------------------------------------- -// vs_w - vertical sync write -//------------------------------------------------- - -WRITE_LINE_MEMBER( abc806_state::vs_w ) -{ - m_vsync = state; -} - - -//------------------------------------------------- -// hr_update - high resolution screen update -//------------------------------------------------- - -void abc806_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - const pen_t *pen = m_palette->pens(); - - UINT32 addr = (m_hrs & 0x0f) << 15; - - for (int y = m_sync + VERTICAL_PORCH_HACK; y < MIN(cliprect.max_y + 1, m_sync + VERTICAL_PORCH_HACK + 240); y++) - { - for (int sx = 0; sx < 128; sx++) - { - UINT8 data = m_video_ram[addr++]; - UINT16 dot = (m_hrc[data >> 4] << 8) | m_hrc[data & 0x0f]; - - for (int pixel = 0; pixel < 4; pixel++) - { - int x = HORIZONTAL_PORCH_HACK + (ABC800_CHAR_WIDTH * 4) - 16 + (sx * 4) + pixel; - - if (BIT(dot, 15) || (bitmap.pix32(y, x) == rgb_t::black)) - { - bitmap.pix32(y, x) = pen[(dot >> 12) & 0x07]; - } - - dot <<= 4; - } - } - } -} - - -void abc806_state::video_start() -{ - // initialize variables - for (int i = 0; i < 16; i++) - { - m_hrc[i] = 0; - } - - m_sync = 10; - m_d_vsync = 1; - m_vsync = 1; - m_40 = 1; - - // allocate memory - m_char_ram.allocate(ABC806_CHAR_RAM_SIZE); - m_attr_ram.allocate(ABC806_ATTR_RAM_SIZE); - - // register for state saving - save_item(NAME(m_txoff)); - save_item(NAME(m_40)); - save_item(NAME(m_flshclk_ctr)); - save_item(NAME(m_flshclk)); - save_item(NAME(m_attr_data)); - save_item(NAME(m_hrs)); - save_item(NAME(m_hrc)); - save_item(NAME(m_sync)); - save_item(NAME(m_v50_addr)); - save_item(NAME(m_hru2_a8)); - save_item(NAME(m_vsync_shift)); - save_item(NAME(m_vsync)); - save_item(NAME(m_d_vsync)); -} - - -//------------------------------------------------- -// SCREEN_UPDATE( abc806 ) -//------------------------------------------------- - -UINT32 abc806_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - // clear screen - bitmap.fill(rgb_t::black, cliprect); - - if (!m_txoff) - { - // draw text - m_crtc->screen_update(screen, bitmap, cliprect); - } - - // draw HR graphics - hr_update(bitmap, cliprect); - - return 0; -} - - -//------------------------------------------------- -// PALETTE_INIT( abc806 ) -//------------------------------------------------- - -PALETTE_INIT_MEMBER( abc806_state, abc806 ) -{ - palette.set_pen_color(0, rgb_t(0x00, 0x00, 0x00)); // black - palette.set_pen_color(1, rgb_t(0xff, 0x00, 0x00)); // red - palette.set_pen_color(2, rgb_t(0x00, 0xff, 0x00)); // green - palette.set_pen_color(3, rgb_t(0xff, 0xff, 0x00)); // yellow - palette.set_pen_color(4, rgb_t(0x00, 0x00, 0xff)); // blue - palette.set_pen_color(5, rgb_t(0xff, 0x00, 0xff)); // magenta - palette.set_pen_color(6, rgb_t(0x00, 0xff, 0xff)); // cyan - palette.set_pen_color(7, rgb_t(0xff, 0xff, 0xff)); // white -} - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( abc806_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( abc806_video ) - MCFG_MC6845_ADD(MC6845_TAG, MC6845, SCREEN_TAG, ABC800_CCLK) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(ABC800_CHAR_WIDTH) - MCFG_MC6845_UPDATE_ROW_CB(abc806_state, abc806_update_row) - MCFG_MC6845_OUT_HSYNC_CB(WRITELINE(abc806_state, hs_w)) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(abc806_state, vs_w)) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(abc806_state, screen_update) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_SIZE(768, 312) - MCFG_SCREEN_VISIBLE_AREA(0, 768-1, 0, 312-1) - - MCFG_PALETTE_ADD("palette", 8) - MCFG_PALETTE_INIT_OWNER(abc806_state, abc806) -MACHINE_CONFIG_END diff --git a/src/mess/video/ac1.c b/src/mess/video/ac1.c deleted file mode 100644 index 8af6b695baa..00000000000 --- a/src/mess/video/ac1.c +++ /dev/null @@ -1,61 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - AC1 video driver by Miodrag Milanovic - - 15/01/2009 Preliminary driver. - -****************************************************************************/ - -#include "emu.h" -#include "includes/ac1.h" - -#define AC1_VIDEO_MEMORY 0x1000 - -const gfx_layout ac1_charlayout = -{ - 6, 8, /* 6x8 characters */ - 256, /* 256 characters */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {7, 6, 5, 4, 3, 2}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -void ac1_state::video_start() -{ -} - -UINT32 ac1_state::screen_update_ac1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - address_space &space = m_maincpu->space(AS_PROGRAM); - - for(y = 0; y < 16; y++ ) - { - for(x = 0; x < 64; x++ ) - { - int code = space.read_byte(AC1_VIDEO_MEMORY + x + y*64); - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code , 0, 0,0, 63*6-x*6,15*8-y*8); - } - } - return 0; -} - -UINT32 ac1_state::screen_update_ac1_32(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - address_space &space = m_maincpu->space(AS_PROGRAM); - - for(y = 0; y < 32; y++ ) - { - for(x = 0; x < 64; x++ ) - { - int code = space.read_byte(AC1_VIDEO_MEMORY + x + y*64); - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code , 0, 0,0, 63*6-x*6,31*8-y*8); - } - } - return 0; -} diff --git a/src/mess/video/advision.c b/src/mess/video/advision.c deleted file mode 100644 index 086f61c6175..00000000000 --- a/src/mess/video/advision.c +++ /dev/null @@ -1,110 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/*************************************************************************** - - video/advision.c - - Routines to control the Adventurevision video hardware - - Video hardware is composed of a vertical array of 40 LEDs which is - reflected off a spinning mirror, to give a resolution of 150 x 40 at 15 FPS. - -***************************************************************************/ - -#include "emu.h" -#include "includes/advision.h" - -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -void advision_state::video_start() -{ - m_video_hpos = 0; - m_display.resize(8 * 8 * 256); - memset(&m_display[0], 0, 8*8*256); - save_item(NAME(m_display)); - save_item(NAME(m_video_hpos)); -} - -/*************************************************************************** - - Initialise the palette. - -***************************************************************************/ - -PALETTE_INIT_MEMBER(advision_state, advision) -{ - for (int i = 0; i < 8; i++) - { - /* 8 shades of RED */ - m_palette->set_pen_color(i, i * 0x22, 0x00, 0x00); - } -} - -/*************************************************************************** - - Update the display data. - -***************************************************************************/ - -void advision_state::vh_write(int data) -{ - if (m_video_bank >= 1 && m_video_bank <=5) - { - m_led_latch[m_video_bank] = data; - } -} - -void advision_state::vh_update(int x) -{ - UINT8 *dst = &m_display[x]; - - for (int y = 0; y < 8; y++) - { - UINT8 data = m_led_latch[7 - y]; - - for (int i = 0; i < 8; i++) - { - if (!BIT(data, 7 - i)) - dst[i * 256] = 8; - } - - m_led_latch[7 - y] = 0xff; - dst += 8 * 256; - } -} - - -/*************************************************************************** - - Refresh the video screen - -***************************************************************************/ - -UINT32 advision_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - if ((m_frame_count++ % 4) == 0) - { - m_frame_start = 1; - m_video_hpos = 0; - } - - for (int x = 0; x < 150; x++) - { - UINT8 *led = &m_display[x]; - - for (int y = 0; y < 128; y+=2) - { - if (*led > 0) - bitmap.pix16(30 + y, 85 + x) = --(*led); - else - bitmap.pix16(30 + y, 85 + x) = 0; - - led += 256; - } - } - return 0; -} diff --git a/src/mess/video/alesis.c b/src/mess/video/alesis.c deleted file mode 100644 index 08f4554a4f2..00000000000 --- a/src/mess/video/alesis.c +++ /dev/null @@ -1,167 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sandro Ronco -/*************************************************************************** - - Alesis SR-16 LCD emulation - -****************************************************************************/ - -#include "emu.h" -#include "includes/alesis.h" - - -void alesis_state::update_lcd_symbols(bitmap_ind16 &bitmap, UINT8 pos, UINT8 y, UINT8 x, int state) -{ - if (pos == 6) - { - switch(x) - { - case 0: - switch(y) - { - case 0: output_set_value("a_next", state); break; - case 1: output_set_value("b_next", state); break; - case 2: output_set_value("fill_next", state); break; - case 3: output_set_value("user_next", state); break; - case 4: output_set_value("play", state); break; - case 5: output_set_value("record", state); break; - case 6: output_set_value("compose", state); break; - case 7: output_set_value("perform", state); break; - } - break; - case 1: - if (y == 0) - { - output_set_value("song", state); - } - else if (y < 8) - { - if (state) - m_lcd_digits[0] |= (1<<(y-1)); - else - m_lcd_digits[0] &= ~(1<<(y-1)); - - output_set_value("digit0", BITSWAP8(m_lcd_digits[0],7,3,1,4,6,5,2,0)); - } - break; - case 2: - if (y == 0) - { - output_set_value("pattern", state); - } - else if (y < 8) - { - if (state) - m_lcd_digits[1] |= (1<<(y-1)); - else - m_lcd_digits[1] &= ~(1<<(y-1)); - - output_set_value("digit1", BITSWAP8(m_lcd_digits[1],7,3,1,4,6,5,2,0)); - } - break; - case 3: - switch(y) - { - case 0: output_set_value("b", state); break; - case 1: output_set_value("a", state); break; - case 2: output_set_value("fill", state); break; - case 3: output_set_value("user", state); break; - case 4: output_set_value("edited", state); break; - case 5: output_set_value("set", state); break; - case 6: output_set_value("drum", state); break; - case 7: output_set_value("press_play", state); break; - } - break; - case 4: - if (y == 7) - { - output_set_value("metronome", state); - } - else if (y < 7) - { - if (state) - m_lcd_digits[4] |= (1<> 5) -#define CR0_MODE_0 0 -#define CR0_MODE_1 1 -#define CR0_MODE_VECTOR 2 -#define CR0_MODE_3 3 -#define CR0_MODE_BLT 4 -#define CR0_MODE_NORMAL 7 -#define CR0_SHIFT(a) ((a) & 0x1f) - -// control register 1 -#define CR1_INV 0x80 -#define CR1_AD_BIT 0x80 // 4- and 8-plane color -#define CR1_DADDR_16 0x40 -#define CR1_DV_CK 0x40 // 4- and 8-plane color -#define CR1_DH_CK 0x20 -#define CR1_ROP_EN 0x10 -#define CR1_RESET 0x08 -#define CR1_DP_CK 0x04 -#define CR1_SYNC_EN 0x02 -#define CR1_DISP_EN 0x01 - -// control register 2 -#define CR2_S_DATA(a) ((a) >> 6) -#define CR2_CONST_ACCESS 0x00 -#define CR2_PIXEL_ACCESS 0x01 -#define CR2_SHIFT_ACCESS 0x02 -#define CR2_PLANE_ACCESS 0x03 -#define CR2_S_PLANE(a) (((a) >> 4) & 0x03) -#define CR2_D_PLANE(a) ((a) & 0x0f) -#define CR2B_S_PLANE(a) ((a) & 0x07) -#define CR2A_D_PLANE(a) (a) - -// Lookup table control register -#define LUT_AD_CS 0x80 -#define LUT_CPAL_CS 0x40 -#define LUT_FIFO_CS 0x20 -#define LUT_FIFO_RST 0x10 -#define LUT_ST_LUK 0x08 -#define LUT_R_W 0x04 -#define LUT_C1 0x02 -#define LUT_C0 0x01 -#define LUT_C1_C0(a) ((a)& (LUT_C1|LUT_C0)) - - -apollo_graphics_15i::bt458::bt458(running_machine &running_machine) -{ - m_machine = &running_machine; -} - -void apollo_graphics_15i::bt458::start() -{ - MLOG1(("start apollo_graphics_15i::bt458")); -} - -void apollo_graphics_15i::bt458::reset() -{ - MLOG1(("reset apollo_graphics_15i::bt458")); - - m_color_counter = 0; - m_red = 0; - m_green = 0; - - m_address_register = 0; - memset(m_color_palette_RAM, 0, sizeof(m_color_palette_RAM)); - memset(m_overlay_color, 0, sizeof(m_overlay_color)); - m_read_mask_register = 0; - m_blink_mask_register = 0; - m_command_register = 0; - m_control_test_register = 0; -} - -void apollo_graphics_15i::bt458::write(UINT8 data, UINT8 c10) -{ - MLOG1(("writing Bt458 data=%02x C1,C0=%d", data, c10)); - switch (c10) - { - case 0: // address register - m_address_register = data; - m_color_counter = 0; - MLOG1(("bt458::write 0: addr=%02x", data)); - break; - case 1: // color palette RAM - switch (m_color_counter) - { - case 0: - m_red = data; - m_color_counter++; - break; - case 1: - m_green = data; - m_color_counter++; - break; - case 2: - m_color_palette_RAM[m_address_register] = (m_red << 16) | (m_green << 8) | data; - m_address_register++; - m_color_counter = 0; - break; - } - break; - case 2: // registers - switch (m_address_register) - { - case 0x04: - m_read_mask_register = data; - MLOG1(("bt458::write: writing Bt458 m_read_mask_register=%02x", data)) - break; - case 0x05: - m_blink_mask_register = data; - MLOG1(("bt458::write: writing Bt458 m_blink_mask_register=%02x", data)) - break; - case 0x06: - m_command_register = data; - MLOG1(("bt458::write: writing Bt458 m_command_register=%02x", data)) - break; - case 0x07: - m_control_test_register = data; - break; - default: - MLOG1(("bt458::write: writing unexpected Bt458 data=%02x C1,C0=%d at %02x", data, c10, m_address_register)) - break; - } - break; - case 3: // overlay color - switch (m_address_register) - { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - m_overlay_color[m_address_register] = data; - MLOG1(("bt458::write: writing Bt458 m_overlay_color[%d]=%02x",m_address_register, data)); - break; - default: - MLOG1(("bt458::write: writing unexpected Bt458 data=%02x C1,C0=%d at %02x", data, c10, m_address_register)); - break; - } - break; - default: - MLOG1(("bt458::write: writing unexpected Bt458 data=%02x C1,C0=%d", data, c10)) - ; - break; - } -} - -UINT8 apollo_graphics_15i::bt458::read(UINT8 c10) -{ - UINT8 data = 0xff; - - switch (c10) - { - case 0: // address register - data = m_address_register; - break; - case 1: // color palette RAM - switch (m_color_counter) - { - case 0: // red - data = (m_color_palette_RAM[m_address_register] >> 16) & 0xff; - m_color_counter++; - break; - case 1: // Green - data = (m_color_palette_RAM[m_address_register] >> 8) & 0xff; - m_color_counter++; - break; - case 2: // blue - data = m_color_palette_RAM[m_address_register] & 0xff; - m_address_register++; - m_color_counter = 0; - break; - } - break; - case 2: // registers - switch (m_address_register) - { - case 0x04: - data = m_read_mask_register; - MLOG1(("bt458::read: reading Bt458 m_read_mask_register=%02x", data)) - break; - case 0x05: - data = m_blink_mask_register; - MLOG1(("bt458::read: reading Bt458 m_blink_mask_register=%02x", data)) - break; - case 0x06: - data = m_command_register; - MLOG1(("bt458::read: reading Bt458 m_command_register=%02x", data)) - break; - case 0x07: - { - UINT32 rgb = m_color_palette_RAM[0]; - switch (m_control_test_register & 0x0f) - { - case 0x01: data = 0x01 | ((rgb >> 16) & 0xf0); break; - case 0x09: data = 0x09 | ((rgb >> 12) & 0xf0); break; - case 0x02: data = 0x02 | ((rgb >> 8) & 0xf0); break; - case 0x0a: data = 0x0a | ((rgb >> 4) & 0xf0); break; - case 0x04: data = 0x04 | ((rgb >> 0) & 0xf0); break; - case 0x0c: data = 0x0c | ((rgb << 4) & 0xf0); break; - default: data = 0xff; break; - } - } - break; - default: - MLOG1(("bt458::read: reading unexpected Bt458 data=%02x C1,C0=%d at %02x", data, c10, m_address_register)) - break; - } - break; - default: - MLOG1(("bt458::read: reading unexpected Bt458 data=%02x C1,C0=%d at %02x", data, c10, m_address_register)) - break; - } - -// MLOG1(("reading Bt458 data=%02x cs=%d", m_data, c10)); - return data; -} - -UINT32 apollo_graphics_15i::bt458::get_rgb(UINT8 index) -{ - return m_color_palette_RAM[index]; -} - -/*************************************************************************** - Monochrome Controller Registers at 0x5d800 - 0x5dc07 - ***************************************************************************/ - -const char *apollo_graphics_15i::cr_text(offs_t offset, UINT8 data, UINT8 rw) -{ - static const char *cr0[8] = - { "cr0 mode=0 CPU dest BLT", "cr0 mode=1 Alternating BLT", - "cr0 mode=2 Vector mode", "cr0 mode=3 CPU Source BLT", - "cr0 mode=4 Double access BLT ", "cr0 mode=5 ???", - "cr0 mode=6 ???", "cr0 mode=7 Normal" }; - - static const char *cr2[4] = - { "cr2 Constant access", "cr2 Pixel access", "cr2 ???", - "cr2 Plane access" }; - - static const char *cr2b[4] = - { "cr2b Constant access", "cr2b Pixel access", "cr2b ???", - "cr2b Plane access" }; - - switch (offset & 0x407) - { - case 0: - return rw ? "sr" : "we"; - case 1: - return rw ? "id" : "we"; - case 2: - case 3: - return "rop0"; - case 4: - case 5: - return m_n_planes == 8 ? "rop1" : "mem refresh"; - case 6: - case 7: - return m_n_planes == 8 ? "mem refresh" : "???"; - case 0x400: - return cr0[data >> 5]; - case 0x401: - return m_n_planes == 8 ? "LUT data" : "red"; - case 0x402: - return "cr1"; - case 0x403: - return m_n_planes == 8 ? "LUT ctrl" : "green"; - case 0x404: - return m_n_planes == 8 ? "cr2a" : cr2[data >> 6]; - case 0x405: - return m_n_planes == 8 ? cr2b[data >> 6] : "blue"; - case 0x406: - return "cr3"; - case 0x407: - return m_n_planes == 8 ? "cr3b" : "a/d"; - default: - return "???"; - } -} - -void apollo_graphics_15i::log_cr1(const char * text) -{ - MLOG2(("%s: cr0=%02x cr1=%02x sr=%02x pixel_clock=%3d/%3d bl=%d vb=%d vs=%d hs=%d hc=%d vck=%d hck=%d pck=%d vd=%d", - text, - m_cr0, - m_cr1, - m_sr, - m_p_clock, - m_data_clock, - m_sr & SR_BLANK ? 1 : 0, - m_sr & SR_V_BLANK ? 1 : 0, - m_sr & SR_V_SYNC ? 1 : 0, - m_sr & SR_H_SYNC ? 1 : 0, - m_sr & SR_H_CK ? 1 : 0, - m_cr1 & CR1_DV_CK ? 1 : 0, - m_cr1 & CR1_DH_CK ? 1 : 0, - m_cr1 & CR1_DP_CK ? 1 : 0, - m_sr & SR_V_DATA ? 1 : 0)); -} - -void apollo_graphics_15i::increment_h_clock() -{ - MLOG1(("increment_h_clock: sr=%02x m_h_clock=%d", m_sr, m_h_clock)); - - if (m_device_id == SCREEN_DEVICE_ID_19I) - { - // DISP7A.DEX Test 5 - // Note: 108 = 80 + 28 = 1280/16 + 448/16 - switch (m_h_clock %= 108) - { - case 8: // Not blanking - m_sr |= SR_BLANK; - break; - case 88: // blanking - m_sr &= ~SR_BLANK; - break; - case 93: // HSync active - m_sr &= ~SR_H_SYNC; - // DISP7A.DEX.1 Test 6 - increment_v_clock(); - break; - case 104: // HSync inactive - m_sr |= SR_H_SYNC; - break; - } - } - else if (m_n_planes == 1) - { - switch (m_h_clock %= 84) - { - case 1: // HSync inactive - m_sr |= SR_H_SYNC; - break; - case 8: // Not blanking - m_sr |= SR_BLANK; - break; - case 72: // blanking - m_sr &= ~SR_BLANK; - break; - case 77: // HSync active - m_sr &= ~SR_H_SYNC; - // DISP7D.DEX.1 Test 6 - increment_v_clock(); - break; - } - } - else if (m_n_planes == 4) - { - switch (m_h_clock %= 84) - { - case 8: // Not blanking - m_sr |= SR_BLANK; - if (m_sr & SR_V_BLANK) - { - m_sr |= SR_V_FLAG; - } - break; - case 73: // blanking - m_sr &= ~SR_BLANK; - if (m_sr & SR_V_BLANK) - { - m_sr &= ~SR_V_FLAG; - } - break; - } - } - else // m_n_planes == 8 - { - switch (m_h_clock %= 84) - { - case 9: // Not blanking - m_sr |= SR_BLANK; - break; - case 73: // blanking - m_sr &= ~SR_BLANK; - break; - } - } - m_h_clock++; -} - -void apollo_graphics_15i::increment_v_clock() -{ - MLOG1(("increment_v_clock: sr=%02x m_v_clock=%d", m_sr, m_v_clock)); - - if (m_device_id == SCREEN_DEVICE_ID_19I) - { - switch (m_v_clock %= 1066) - { - case 1023: // blanking - m_sr &= ~(SR_V_BLANK | SR_BLANK); - break; - case 1028: // VSync active - m_sr &= ~SR_V_SYNC; - break; - case 1032: // VSync inactive - m_sr |= SR_V_SYNC; - break; - case 1065: // not blanking - m_sr |= (SR_V_BLANK | SR_BLANK); - break; - } - } - else if (m_n_planes == 1) - { - switch (m_v_clock %= 842) - { - case 799: - m_sr &= ~SR_V_BLANK; - break; - case 804: - m_sr &= ~SR_SYNC; - break; - case 808: - m_sr |= SR_SYNC; - break; - case 841: - m_sr |= SR_V_BLANK; - break; - } - } - else if (m_n_planes == 4) - { - // DISP7B.DEX Test 6 and Test 20 - switch (m_v_clock %= 842) - { - case 799: - m_sr &= ~SR_V_BLANK; - m_sr &= ~SR_V_FLAG; - break; - case 803: - m_sr &= ~SR_SYNC; - break; - case 807: - m_sr |= SR_SYNC; - break; - case 836: - m_sr |= SR_V_FLAG; - break; - case 841: - m_sr |= SR_V_BLANK; - break; - } - } - else if (m_n_planes == 8) - { - // DISP7C.DEX Test 50 - switch (m_v_clock %= 842) - { - case 800: - m_sr &= ~SR_V_BLANK; - break; - case 804: - m_sr &= ~SR_SYNC; - break; - case 808: - m_sr |= SR_SYNC; - break; - case 0: - m_sr |= SR_V_BLANK; - break; - } - } - m_v_clock++; - m_p_clock = 0; - m_data_clock = 0; -} - -void apollo_graphics_15i::increment_p_clock() -{ - if (m_n_planes == 1) - { - if ((m_cr1 & CR1_DISP_EN) == 0) - { - m_sr &= ~SR_V_DATA; - } - else - { - int pixel_offset = (m_device_id == SCREEN_DEVICE_ID_19I) ? 10 : 8; - - if (m_p_clock > pixel_offset) - { - // FIXME: ok for DEX Test 5 6 17 19 - nok for 20 - int pixel_addr = m_v_clock * m_width + m_data_clock; - - // FIXME: ok for DEX Test 5 6 17 20 - nok for 19 - // Note: for dn3500_19i DEX Test 17 18 20 will fail !!!! - // Note: must NOT reset m_data_clock in increment_p_clock ! -// int pixel_addr = m_data_clock * 32; - - UINT16 pixel = m_image_memory[pixel_addr / 16] & (0x8000 >> (pixel_addr % 16)); - - pixel = (pixel ? 1 : 0) ^ ((m_cr1 & CR1_INV) ? 0 : 1); - - m_sr = pixel ? (m_sr | SR_V_DATA) : (m_sr & ~SR_V_DATA); - - m_data_clock++; - } - - m_p_clock++; - - // DEX Test 4: Pixel Counter Test - if ((m_p_clock % 8) == 0) - { - m_sr ^= SR_H_CK; - } - } - } - else if (m_n_planes == 4) - { - if ((m_p_clock % 8) == 0 && m_p_clock > 0) - { - m_sr ^= SR_H_CK; - } - m_p_clock++; - } - else // m_n_planes == 8 - { - if ((m_p_clock % 8) == 1 && m_p_clock > 1) - { - m_sr ^= SR_H_CK; - } - m_p_clock++; - } -} - -void apollo_graphics_15i::set_cr1(UINT8 data) -{ - UINT8 diffs = m_cr1 ^ data; - m_cr1 = data; - - UINT8 dp_clock = (diffs & CR1_DP_CK) && (m_cr1 & CR1_DP_CK) == 0; - UINT8 dh_clock = (diffs & CR1_DH_CK) && (m_cr1 & CR1_DH_CK) == 0; - UINT8 dv_clock = m_n_planes == 1 ? 0 : ((diffs & CR1_DV_CK) && (m_cr1 & CR1_DV_CK) == 0); - - if ((m_cr1 & CR1_RESET) == 0) - { - if (diffs & CR1_RESET) - { - MLOG1(("!!! set_cr1: CR1_RESET")); - - m_blt_cycle_count = 0; - m_sr &= ~SR_ALT; - m_image_offset = 0; - memset(m_guard_latch, 0, sizeof(m_guard_latch)); - - m_h_clock = 0; - m_v_clock = 0; - m_p_clock = 0; - m_data_clock = 0; - - if (m_device_id == SCREEN_DEVICE_ID_19I) - { - m_sr = SR_H_CK | SR_V_BLANK | SR_H_SYNC | SR_V_SYNC; - } - else if (m_n_planes == 1) - { - m_sr = SR_V_BLANK | SR_V_SYNC; - } - else - { - m_sr = SR_H_CK | SR_V_BLANK | SR_SYNC | SR_DONE; - } - } - log_cr1("CR1_RESET"); - } - else - { - if ((diffs & CR1_RESET) && (m_cr1 & CR1_RESET) != 0) - { - log_cr1("CR1_RESET"); - } - - if (dh_clock) - { - increment_h_clock(); - log_cr1("CR1_DH_CK"); - } - - if (dv_clock) - { - increment_v_clock(); - log_cr1("CR1_DV_CK"); - } - - if (dp_clock) - { - increment_p_clock(); - log_cr1("CR1_DP_CK"); - } - - if ((m_sr & SR_V_BLANK) == 0) - { - m_sr &= ~SR_BLANK; - } - - if (diffs & CR1_DISP_EN) - { - // update screen - m_update_flag = 1; - } - } -} - -void apollo_graphics_15i::set_cr3a(UINT8 data) -{ - m_cr3a = data; - if ((data & 0x80) == 0) - { - int shift = (data & 0x0f) >> 1; - UINT8 bit_mask = 1 << shift; - if (data & 0x01) - { - set_cr1(m_cr1 | bit_mask); - } - else - { - set_cr1(m_cr1 & ~bit_mask); - } - } -} - -void apollo_graphics_15i::set_cr3b(UINT8 data) -{ - m_cr3b = data; - if ((data & 0x80) == 0) - { - int shift = (data & 0x0f) >> 1; - UINT8 bit_mask = 1 << shift; - if (data & 0x01) - { - set_lut_cr(m_lut_control | bit_mask); - } - else - { - set_lut_cr(m_lut_control & ~bit_mask); - } - } -} - -void apollo_graphics_15i::set_lut_cr(UINT8 data) -{ - UINT8 diffs = m_lut_control ^ data; - m_lut_control = data; - - if ((diffs & LUT_CPAL_CS) && (data & LUT_CPAL_CS) != 0) - { - MLOG1(("writing Color Graphics Controller: LUT_CPAL_CS Disabled")); - while (!m_lut_fifo->is_empty()) - { - m_bt458->write(m_lut_fifo->get(), LUT_C1_C0(m_lut_control)); - } - } - - if ((diffs & LUT_FIFO_RST) && (data & LUT_FIFO_RST) == 0) - { - MLOG1(("writing Color Graphics Controller: LUT_FIFO_RST Active")); - m_lut_fifo->reset(); - m_sr |= SR_LUT_OK; - } - - if ((diffs & LUT_FIFO_CS) && (data & LUT_FIFO_CS) == 0) - { - MLOG1(("writing Color Graphics Controller: LUT_FIFO_CS Enabled")); - } - - if ((diffs & LUT_ST_LUK) && (data & LUT_ST_LUK) == 0) - { - MLOG1(("writing Color Graphics Controller: LUT_ST_LUK Active")); - m_sr &= ~SR_LUT_OK; - } -} - -READ8_MEMBER( apollo_graphics_15i::apollo_mcr_r ) -{ - UINT8 data; - switch (offset & 0x407) - { - case 0: - data = m_sr; - if (m_ad_pending) - { - m_ad_pending = 0; - m_sr &= ~SR_DONE; - } - break; - case 1: - data = m_n_planes == 1 ? m_device_id : 0xff; - break; - case 0x400: - data = m_cr0; - break; - case 0x402: - data = m_cr1; - break; - case 0x404: - data = m_cr2; - break; - case 0x406: - data = m_cr3a; - break; - default: - data = 0xff; - break; - } - - // omit excessive logging - static UINT8 status0 = 0xff; - if ((offset != 1) && (offset != 0 || data != status0)) - { - if (offset == 0) - status0 = data; - MLOG1(("reading Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); - } - - return data; -} - -WRITE8_MEMBER( apollo_graphics_15i::apollo_mcr_w ) -{ - MLOG1(("writing Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); - switch (offset & 0x407) - { - case 0: - m_write_enable_register = set_lsb0(m_write_enable_register, data); - break; - case 1: - m_write_enable_register = set_msb0(m_write_enable_register, data); - // FIXME: seems to be necessary for dex - m_blt_cycle_count = 0; - m_sr &= ~SR_ALT; - break; - case 2: - m_rop_register = set_lsb0(m_rop_register, data); - break; - case 3: - m_rop_register = set_msb0(m_rop_register, data); - set_status_rmw(); - break; - case 4: - case 5: - // trigger memory refresh in diagnostic mode - m_diag_mem_request = data; - break; - case 0x400: - m_cr0 = data; - break; - case 0x402: - set_cr1(data); - break; - case 0x404: - m_cr2 = data; - m_cr2_s_data = CR2_S_DATA(data); - m_cr2_s_plane = 0x00; - m_cr2_d_plane = 0x0e; - // for DISP7B.DEX Test 16 - m_sr |= SR_R_M_W; - break; - case 0x406: - set_cr3a(data); - break; - case 0x407: // A/D Channel Register - m_ad_pending = 1; - m_sr |= SR_DONE; - break; - } -} - -void apollo_graphics_15i::set_status_rmw() -{ - UINT8 plane, d_plane_bit; - UINT32 rop_reg; - - m_sr &= ~SR_R_M_W; - rop_reg = m_rop_register; - d_plane_bit = 0x01; - for (plane = 0; plane < m_n_planes; plane++) - { - if ((m_cr2_d_plane & d_plane_bit) == 0) - { - switch (rop_reg & 0x0f) - { - case 0: // zero - case 3: // Source - case 0x0c: // ~Source - case 0x0f: // one - break; - default: - m_sr |= SR_R_M_W; - break; - } - } - rop_reg >>= 4; - d_plane_bit <<= 1; - } -} - -UINT16 apollo_graphics_15i::rop(UINT16 dest_data, UINT16 src_data, UINT8 plane) -{ - UINT16 src_data1 = src_data; - if (m_cr1 & CR1_ROP_EN) - { - switch ((m_rop_register >> (plane * 4)) & 0x0f) - { - case 0: // zero - src_data = 0; - break; - case 1: // Source AND Destination - src_data = src_data & dest_data; - break; - case 2: // Source AND ~Destination - src_data = src_data & (~dest_data); - break; - case 3: // Source - break; - case 4: // ~Source AND Destination - src_data = (~src_data) & dest_data; - break; - case 5: // Destination - src_data = dest_data; - break; - case 6: // Source XOR Destination - src_data = src_data ^ dest_data; - break; - case 7: // Source OR Destination - src_data = src_data | dest_data; - break; - case 8: // Source NOR Destination - src_data = ~(src_data | dest_data); - break; - case 9: // Source XNOR Destination - src_data = ~(src_data ^ dest_data); - break; - case 0x0a: // ~Destination - src_data = ~dest_data; - break; - case 0x0b: // Source OR ~Destination - src_data = src_data | (~dest_data); - break; - case 0x0c: // ~Source - src_data = ~src_data; - break; - case 0x0d: // ~Source OR Destination - src_data = (~src_data) | dest_data; - break; - case 0x0e: // Source NAND Destination - src_data = ~(src_data & dest_data); - break; - case 0x0f: // One - src_data = 0xffff; - break; - } - } - MLOG2(("rop: cr0=%02x cr1=%02x cr2=%02x rop_register=%08x dest=%04x src=%04x plane=%d s_plane=%d ->%04x", m_cr0, m_cr1, m_cr2, m_rop_register,dest_data, src_data1, plane, m_cr2_s_plane, src_data )) - return src_data; -} - -void apollo_graphics_15i::set_source_data(UINT32 offset) -{ - if (m_n_planes == 1 || (m_cr1 & CR1_AD_BIT)) - { - offset += m_image_plane_size * m_cr2_s_plane; - m_guard_latch[m_cr2_s_plane] <<= 16; - m_guard_latch[m_cr2_s_plane] |= m_image_memory[offset]; - } - else - { - UINT8 plane; - for (plane = 0; plane < m_n_planes; plane++) - { - m_guard_latch[plane] <<= 16; - m_guard_latch[plane] |= m_image_memory[offset]; - offset += m_image_plane_size; - } - } -} - -UINT32 apollo_graphics_15i::get_source_data(UINT8 plane) -{ - UINT32 src_data; - - if (m_n_planes == 1 || (m_cr1 & CR1_AD_BIT)) - { - src_data = m_guard_latch[m_cr2_s_plane]; - } - else - { - src_data = m_guard_latch[plane]; - } - - switch (m_cr2_s_data) - { - case CR2_CONST_ACCESS: // 0x00 - // set source to all ones (used for vectors) - src_data = 0xffff; - break; - case CR2_PIXEL_ACCESS: // 0x01 - // replicate 4 LSB of data bus - src_data = src_data & (1 << plane) ? 0xffff : 0; - break; - case CR2_SHIFT_ACCESS: // 0x02 - // replicate LSB of shifter - src_data = src_data & 1 ? 0xffff : 0; - break; - case CR2_PLANE_ACCESS: // 0x03 - // use source data unchanged (normal use) - if (CR0_SHIFT(m_cr0) >= 16) - { - src_data = (src_data << 16) | (src_data >> 16); - } - src_data >>= (CR0_SHIFT(m_cr0) & 0x0f); - break; - } - return src_data; -} - -void apollo_graphics_15i::blt(UINT32 dest_addr, UINT16 mem_mask) -{ - UINT16 src_data, dest_data; - UINT8 d_plane_bit; - UINT8 plane; - - d_plane_bit = 0x01; - for (plane = 0; plane < m_n_planes; plane++) - { - if ((m_cr2_d_plane & d_plane_bit) == 0) - { - dest_data = m_image_memory[dest_addr]; - src_data = get_source_data(plane); - src_data = rop(dest_data, src_data, plane); - src_data &= ~(m_write_enable_register | ~mem_mask); - dest_data &= (m_write_enable_register | ~mem_mask); - m_image_memory[dest_addr] = dest_data | src_data; - } - dest_addr += m_image_plane_size; - d_plane_bit <<= 1; - } -} - -/*************************************************************************** - Monochrome graphics memory space at FA0000 - FDFFFF - Color graphics memory space at A0000 - BFFFF - ***************************************************************************/ - -READ16_MEMBER( apollo_graphics_15i::apollo_mem_r ) -{ - UINT16 data; - UINT32 src_addr; - - if (offset >= m_image_memory_size) - { - // 128 kB display buffer of 15" screen seems to be shadowed from $fa0000 to $fc0000 - MLOG1(("reading Graphics Memory at invalid offset %05x", offset)); - offset %= m_image_memory_size; - } - - src_addr = offset + m_image_plane_size * m_cr2_s_plane; - - switch (CR0_MODE(m_cr0)) - { - case CR0_MODE_VECTOR: // vector or fill mode - case CR0_MODE_3: // CPU source BLT: read internal data bus - data = m_guard_latch[m_cr2_s_plane]; - break; - - default: - set_source_data(offset); - data = m_image_memory[src_addr]; - break; - } - - // omit excessive logging - if ((offset & (m_image_plane_size - 1)) < 8) - { - MLOG1(("reading Graphics Memory with mode %d: src_addr %05x = %04x & %04x", CR0_MODE(m_cr0), src_addr, data, mem_mask)); - } - else if ((offset & (m_image_plane_size - 1)) == 8) - { - MLOG1(("...")); - } - return data; -} - -WRITE16_MEMBER( apollo_graphics_15i::apollo_mem_w ) -{ - UINT32 dest_addr; - UINT32 src_addr; - - if (offset >= m_image_memory_size) - { - // 128 kB display buffer of 15" screen seems to be shadowed from $fa0000 to $fc0000 - MLOG1(("writing Graphics Memory at invalid offset %05x = %04x & %04x ", offset, data, mem_mask)); - offset %= m_image_memory_size; - } - - // omit excessive logging - if (offset < 24) - { - MLOG1(("writing Graphics Memory with mode %d: offset=%04x data=%04x mask=%04x", CR0_MODE(m_cr0), offset, data, mem_mask)); - } - else if (offset == 24) - { - MLOG1(("...")); - } - - switch (CR0_MODE(m_cr0)) - { - case CR0_MODE_0: - // CPU destination BLT - // 1. bus write to provide display memory address - // 2. bus read to get data - src_addr = offset + m_image_plane_size * m_cr2_s_plane; - m_guard_latch[m_cr2_s_plane] <<= 16; - m_guard_latch[m_cr2_s_plane] |= m_image_memory[src_addr]; - break; - - case CR0_MODE_1: - // Alternating BLT - // alternating bus writes provide src/dest address - // second write provides Write-enables - if (++m_blt_cycle_count == 1) - { - m_sr |= SR_ALT; - set_source_data(offset); - } - else - { - m_blt_cycle_count = 0; - m_sr &= ~SR_ALT; - m_write_enable_register = data; - blt(offset, mem_mask); - } - break; - - case CR0_MODE_VECTOR: - // Vector or fill mode - // write provides Write-enables and address - m_write_enable_register = data; - blt(offset, mem_mask); - break; - - case CR0_MODE_3: - // CPU source BLT - // 1. bus write to provide src data - // 2. bus write to provide Write-enables and address - if (++m_blt_cycle_count == 1) - { - m_sr |= SR_ALT; - - // strange: must fix byte access for /systest/grtest on sr10.2 - if (mem_mask == 0xff00) - { - data >>= 8; - mem_mask >>= 8; - } - - m_guard_latch[m_cr2_s_plane] <<= 16; - m_guard_latch[m_cr2_s_plane] |= (data & mem_mask); - } - else - { - m_blt_cycle_count = 0; - m_sr &= ~SR_ALT; - - m_write_enable_register = data; - blt(offset, mem_mask); - } - break; - - case CR0_MODE_BLT: - // Double access BLT - // bus write to provide src addr on address lines - // dest addr on data lines (16-bit WORD Offset) - - set_source_data(offset); - dest_addr = (data & mem_mask); - if (m_device_id == SCREEN_DEVICE_ID_19I && (m_cr1 & CR1_DADDR_16)) - { - dest_addr += 0x10000; - } - blt(dest_addr, 0xffff); - break; - - case CR0_MODE_NORMAL: - m_guard_latch[m_cr2_s_plane] <<= 16; - m_guard_latch[m_cr2_s_plane] |= (data & mem_mask); - blt(offset, mem_mask); - break; - - default: - MLOG(("writing Graphics Memory - unexpected cr0 mode %d", CR0_MODE(m_cr0))) - ; - break; - } - m_update_flag = 1; -} - -/*************************************************************************** - Color Screen - ***************************************************************************/ - -READ8_MEMBER( apollo_graphics_15i::apollo_ccr_r ) -{ - UINT8 data; - - if (m_n_planes == 4) - { - switch (offset & 0x407) - { - case 1: - data = m_n_planes == 4 ? m_device_id : 0xff; - break; - case 0x407: - data = m_ad_result; - break; - default: - return apollo_mcr_r(space, offset, mem_mask); - } - } - else if (m_n_planes == 8) - { - switch (offset & 0x407) - { - case 1: - data = m_n_planes == 8 ? m_device_id : 0xff; - break; - case 4: - data = get_lsb1(m_rop_register); - break; - case 5: - data = get_msb1(m_rop_register); - break; - - case 0x401: - // LUT data register - if ((m_lut_control & LUT_FIFO_CS) == 0) - { - data = m_lut_fifo->get(); - } - else if ((m_lut_control & LUT_R_W) == 0) - { - MLOG1(("apollo_graphics_15i::apollo_ccr_r: reading LUT data register with unexpected RW = 0 in LUT Control register")); - data = m_lut_data; - } - else if ((m_lut_control & LUT_AD_CS) == 0) - { - data = m_ad_result; - } - else if ((m_lut_control & LUT_CPAL_CS) == 0) - { - data = m_bt458->read(LUT_C1_C0(m_lut_control)); - } - else - { - MLOG1(("apollo_graphics_15i::apollo_ccr_r: reading LUT data register with unexpected CS in LUT Control register")); - data = m_lut_data; - } - break; - case 0x403: - // LUT control register - data = m_lut_control; - break; - case 0x404: - // cr2a - data = m_cr2; - break; - case 0x405: - // cr2b - data = m_cr2b; - break; - case 0x407: - // cr3b - data = m_cr3b; - break; - default: - return apollo_mcr_r(space, offset, mem_mask); - } - } - else - { - data = 0xff; - } - - // omit excessive logging - static UINT8 status1 = 0xff; - if ((offset != 1) && (offset != 0 || data != status1)) - { - if (offset == 0) - status1 = data; - MLOG1(("reading Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 1))); - } - - return data; -} - -UINT8 apollo_graphics_15i::get_pixel(UINT32 offset, UINT16 mask) -{ - UINT8 data = 0; - UINT16 *source_ptr = m_image_memory + offset; - - if (m_n_planes == 4) - { - UINT16 data0 = source_ptr[0]; - UINT16 data1 = source_ptr[m_image_plane_size]; - UINT16 data2 = source_ptr[m_image_plane_size * 2]; - UINT16 data3 = source_ptr[m_image_plane_size * 3]; - - data = (data0 & mask) ? 1 : 0; - data |= (data1 & mask) ? 2 : 0; - data |= (data2 & mask) ? 4 : 0; - data |= (data3 & mask) ? 8 : 0; - } - else if (m_n_planes == 8) - { - UINT16 data0 = source_ptr[0]; - UINT16 data1 = source_ptr[m_image_plane_size]; - UINT16 data2 = source_ptr[m_image_plane_size * 2]; - UINT16 data3 = source_ptr[m_image_plane_size * 3]; - UINT16 data4 = source_ptr[m_image_plane_size * 4]; - UINT16 data5 = source_ptr[m_image_plane_size * 5]; - UINT16 data6 = source_ptr[m_image_plane_size * 6]; - UINT16 data7 = source_ptr[m_image_plane_size * 7]; - - data = (data0 & mask) ? 1 : 0; - data |= (data1 & mask) ? 2 : 0; - data |= (data2 & mask) ? 4 : 0; - data |= (data3 & mask) ? 8 : 0; - data |= (data4 & mask) ? 0x10 : 0; - data |= (data5 & mask) ? 0x20 : 0; - data |= (data6 & mask) ? 0x40 : 0; - data |= (data7 & mask) ? 0x80 : 0; - } - - return data; -} - -// read the 4-plane ADC value for data - -UINT8 apollo_graphics_15i::c4p_read_adc(UINT8 data) -{ - UINT8 value = 0; - - if ((data & 0x0c) == 0x04) - { - UINT8 red, green, blue; - UINT8 pixel = get_pixel((m_v_clock * m_buffer_width / 16) + m_h_clock, - 0x8000); - UINT32 rgb = m_color_lookup_table[pixel]; - - if ((m_sr & SR_BLANK) != 0) - { - // not blanking - red = 30 + ((rgb >> 16) & 0xff) / 4; - green = 60 + ((rgb >> 8) & 0xff) / 4; - blue = 30 + (rgb & 0xff) / 4; - } - else if (m_h_clock > 2) - { - // blanking - red = 20; - green = 50; - blue = 20; - } - else - { - // sync - red = 20; - green = 10; - blue = 20; - } - - switch (data & 3) - { - case 0: // Red - value = red; - break; - case 1: // Green - value = green; - break; - case 2: // Blue - value = blue; - break; - default: // unused - value = 0; - break; - } - } - return value; -} - -// read the 8-plane ADC value for data - -UINT8 apollo_graphics_15i::c8p_read_adc(UINT8 data) -{ - UINT8 value = 0; - - if ((data & 0x0c) == 0x04) - { - UINT8 red, green, blue; - UINT8 pixel = get_pixel((m_v_clock * m_buffer_width / 16) + m_h_clock, 0x8000); - UINT32 rgb = m_bt458->get_rgb(pixel); - - if ((m_sr & SR_BLANK) != 0) - { - // not blanking - red = 10 + ((rgb >> 16) & 0xff) / 2; - green = 70 + ((rgb >> 8) & 0xff) / 2; - blue = 10 + (rgb & 0xff) / 2; - } - else if (m_h_clock < 20) - { - // blanking - red = 5; - green = 60; - blue = 5; - } - else - { - // sync - red = 5; - green = 5; - blue = 5; - } - - switch (data & 3) - { - case 0: // Red - value = red; - break; - case 1: // Green - value = green; - break; - case 2: // Blue - value = blue; - break; - default: // unused - value = 0; - break; - } - } - return value; -} - -WRITE8_MEMBER( apollo_graphics_15i::apollo_ccr_w ) -{ - static const UINT8 rgb_value[16] = - { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, - 0xcc, 0xdd, 0xee, 0xff }; - - if (m_n_planes == 4) - { - switch (offset & 0x407) - { - case 0x401: - // red lookup table register - m_color_lookup_table[data >> 4] &= 0xff00ffff; - m_color_lookup_table[data >> 4] |= rgb_value[data & 0x0f] << 16; - break; - case 0x403: - // green lookup table register - m_color_lookup_table[data >> 4] &= 0xffff00ff; - m_color_lookup_table[data >> 4] |= rgb_value[data & 0x0f] << 8; - break; - case 0x404: - // cr2 - m_cr2 = data; - m_cr2_s_data = CR2_S_DATA(data); - m_cr2_s_plane = CR2_S_PLANE(data); - m_cr2_d_plane = CR2_D_PLANE(data); - // for DISP7B.DEX Test 16 - m_sr |= SR_R_M_W; - break; - case 0x405: - // blue lookup table register - m_color_lookup_table[data >> 4] &= 0xffffff00; - m_color_lookup_table[data >> 4] |= rgb_value[data & 0x0f]; - break; - case 0x407: - // A/D channel register - m_ad_result = c4p_read_adc(data); - m_ad_pending = 1; - m_sr |= SR_DONE; - break; - default: - apollo_mcr_w(space, offset, data, mem_mask); - return; - } - } - else if (m_n_planes == 8) - { - switch (offset & 0x407) - { - case 2: - m_rop_register = set_lsb0(m_rop_register, data); - break; - case 3: - m_rop_register = set_msb0(m_rop_register, data); - set_status_rmw(); - break; - case 4: - m_rop_register = set_lsb1(m_rop_register, data); - break; - case 5: - m_rop_register = set_msb1(m_rop_register, data); - set_status_rmw(); - break; - case 6: - case 7: - // trigger memory refresh in diagnostic mode - m_diag_mem_request = data; - break; - case 0x401: - // LUT data register - m_lut_data = data; - if ((m_lut_control & LUT_R_W) == 1) - { - MLOG1(("apollo_graphics_15i::apollo_ccr_w: writing LUT data register with RW = 1 in LUT Control register")); - } - else if ((m_lut_control & LUT_AD_CS) == 0) - { - m_ad_result = c8p_read_adc(data); - m_ad_pending = 1; - m_sr |= SR_DONE; - } - else if ((m_lut_control & LUT_CPAL_CS) == 0) - { - m_bt458->write(data, LUT_C1_C0(m_lut_control)); - } - else if ((m_lut_control & LUT_FIFO_CS) == 0) - { - m_lut_fifo->put(data); - } - else - { - MLOG1(("apollo_graphics_15i::apollo_ccr_w: writing LUT data register with unexpected CS in LUT Control register")); - } - break; - case 0x403: - // LUT control register - set_lut_cr(data); - break; - case 0x404: - // cr2a - m_cr2 = data; - m_cr2_d_plane = CR2A_D_PLANE(data); - m_sr |= SR_R_M_W; - break; - case 0x405: - // cr2b - m_cr2b = data; - m_cr2_s_data = CR2_S_DATA(data); - m_cr2_s_plane = CR2B_S_PLANE(data); - break; - case 0x407: - // cr3b - set_cr3b(data); - break; - default: - apollo_mcr_w(space, offset, data, mem_mask); - return; - } - } - - MLOG1(("writing Color Graphics Controller at offset %03x = %02x (%s)", offset, data, cr_text(offset, data, 0))); -} - -READ16_MEMBER( apollo_graphics_15i::apollo_cgm_r ) -{ - if (!is_mono()) - { - return apollo_mem_r(space, offset, mem_mask); - } - else - { - return 0xffff; - } -} - -WRITE16_MEMBER( apollo_graphics_15i::apollo_cgm_w ) -{ - if (!is_mono()) - { - apollo_mem_w(space, offset, data, mem_mask); - } -} - -/*************************************************************************** - VIDEO HARDWARE - ***************************************************************************/ - -UINT32 apollo_graphics_15i::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int has_changed = 0; - - if (m_update_flag && !m_update_pending) - { - has_changed = 1; - m_update_flag = 0; - m_update_pending = 1; - screen_update1(bitmap, cliprect); - m_update_pending = 0; - } - return has_changed ? 0 : UPDATE_HAS_NOT_CHANGED; -} - -void apollo_graphics_15i::screen_update1(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT16 *source_ptr = m_image_memory; - int x, y; - UINT16 data, mask; - UINT16 inverse = (m_cr1 & CR1_INV) ? 0xffff : 0; - - MLOG1(("screen_update1: size=%0x rowpixels=%d", m_image_memory_size, bitmap.rowpixels())); - - if ((m_cr1 & CR1_DISP_EN) == 0) - { - // display is disabled - for (y = 0; y < m_height; y++) - { - int dest = 0; - for (x = 0; x < m_width; x += 16) - { - for (mask = 0x8000; mask; mask >>= 1) - { - bitmap.pix32(y, dest++) = 0; - } - } - source_ptr += (m_buffer_width - m_width) / 16; - } - } - else if (m_n_planes == 4) - { - for (y = 0; y < m_height; y++) - { - int dest = 0; - for (x = 0; x < m_width; x += 16) - { - UINT16 data0 = source_ptr[0]; - UINT16 data1 = source_ptr[m_image_plane_size]; - UINT16 data2 = source_ptr[m_image_plane_size * 2]; - UINT16 data3 = source_ptr[m_image_plane_size * 3]; - source_ptr++; - for (mask = 0x8000; mask; mask >>= 1) - { - data = (data0 & mask) ? 1 : 0; - data |= (data1 & mask) ? 2 : 0; - data |= (data2 & mask) ? 4 : 0; - data |= (data3 & mask) ? 8 : 0; - bitmap.pix32(y, dest++) = m_color_lookup_table[data]; - } - } - source_ptr += (m_buffer_width - m_width) / 16; - } - } - else if (m_n_planes == 8) - { - for (y = 0; y < m_height; y++) - { - int dest = 0; - for (x = 0; x < m_width; x += 16) - { - UINT16 data0 = source_ptr[0]; - UINT16 data1 = source_ptr[m_image_plane_size]; - UINT16 data2 = source_ptr[m_image_plane_size * 2]; - UINT16 data3 = source_ptr[m_image_plane_size * 3]; - UINT16 data4 = source_ptr[m_image_plane_size * 4]; - UINT16 data5 = source_ptr[m_image_plane_size * 5]; - UINT16 data6 = source_ptr[m_image_plane_size * 6]; - UINT16 data7 = source_ptr[m_image_plane_size * 7]; - source_ptr++; - for (mask = 0x8000; mask; mask >>= 1) - { - data = (data0 & mask) ? 1 : 0; - data |= (data1 & mask) ? 2 : 0; - data |= (data2 & mask) ? 4 : 0; - data |= (data3 & mask) ? 8 : 0; - data |= (data4 & mask) ? 0x10 : 0; - data |= (data5 & mask) ? 0x20 : 0; - data |= (data6 & mask) ? 0x40 : 0; - data |= (data7 & mask) ? 0x80 : 0; - bitmap.pix32(y, dest++) = m_bt458->get_rgb(data); - } - } - source_ptr += (m_buffer_width - m_width) / 16; - } - } - else // m_n_planes == 1 - { - for (y = 0; y < m_height; y++) - { - int dest = 0; - for (x = 0; x < m_width; x += 16) - { - data = *source_ptr++ ^ inverse; - for (mask = 0x8000; mask; mask >>= 1) - { - bitmap.pix32(y, dest++) = data & mask ? 0 : 0x00ffffff; - } - } - source_ptr += (m_buffer_width - m_width) / 16; - } - } -} - -/*------------------------------------------------- - vblank_state_changed - - called on each state change of the VBLANK signal - -------------------------------------------------*/ - -void apollo_graphics_15i::vblank_state_changed(screen_device &screen, bool vblank_state) -{ - if ((m_cr1 & CR1_RESET) && (m_cr1 & CR1_SYNC_EN)) - { - if (vblank_state) - { - m_sr &= ~(SR_V_BLANK | SR_BLANK); - if (m_n_planes == 1) - { - // faking V_DATA for disp.dex test 16 - if (m_image_memory[0]) - { - m_sr |= SR_V_DATA; - } - } - else if (m_n_planes == 4) - { - m_sr &= ~SR_V_FLAG; - } - } - else - { - m_sr |= (SR_V_BLANK | SR_BLANK); - if (m_n_planes == 1) - { - m_sr &= ~SR_V_DATA; - } - else if (m_n_planes == 4) - { - m_sr |= SR_V_FLAG; - } - } - } -} - -void apollo_graphics_15i::register_vblank_callback() -{ - MLOG1(("register_vblank_callback")); - - /* register for VBLANK callbacks */ - screen_device *screen = (screen_device *)machine().device(VIDEO_SCREEN_TAG); - screen->register_vblank_callback(vblank_state_delegate(FUNC(apollo_graphics_15i::vblank_state_changed),this)); -} - - -/*************************************************************************** - MACHINE DRIVERS - ***************************************************************************/ - -MACHINE_CONFIG_FRAGMENT( apollo_graphics ) - MCFG_DEFAULT_LAYOUT( layout_apollo_15i ) - MCFG_SCREEN_ADD(VIDEO_SCREEN_TAG, RASTER) - MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) - MCFG_SCREEN_REFRESH_RATE(76) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(657)) - MCFG_SCREEN_SIZE(1024, 800) - MCFG_SCREEN_VISIBLE_AREA(0, 1023, 0, 799) - MCFG_SCREEN_UPDATE_DEVICE(APOLLO_SCREEN_TAG, apollo_graphics_15i, screen_update) -MACHINE_CONFIG_END - -const device_type APOLLO_GRAPHICS = &device_creator ; - -apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, APOLLO_GRAPHICS, "Apollo Screen", tag, owner, clock,"apollo_graphics_15i", __FILE__), - m_lut_fifo(NULL), - m_bt458(NULL) -{ -} - -apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, UINT32 clock, device_type type,const char *name, const char *shortname, const char *source) : - device_t(mconfig, type, name, tag, owner, clock, shortname, source), - m_lut_fifo(NULL), - m_bt458(NULL) -{ -} - -apollo_graphics_15i::~apollo_graphics_15i() -{ - if (m_lut_fifo) global_free(m_lut_fifo); - if (m_bt458) global_free(m_bt458); -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void apollo_graphics_15i::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void apollo_graphics_15i::device_start() -{ - MLOG1(("apollo_graphics_15i::device_start")) - - m_n_planes = 0; - m_width = 0; - m_height = 0; - m_buffer_width = 0; - m_buffer_height = 0; - - m_sr = 0; - m_device_id = 0; - m_write_enable_register = 0; - m_rop_register = 0; - m_diag_mem_request = 0; - m_cr0 = 0; - m_cr1 = 0; - m_cr2 = 0; - m_cr2b = 0; - m_cr2_s_data = 0; - m_cr2_s_plane = 0x00; - m_cr2_d_plane = 0x0e; - m_cr3a = 0; - m_cr3b = 0; - m_ad_result = 0; - m_ad_pending = 0; - - m_lut_control = 0; - m_lut_data = 0; - - m_update_flag = 0; - m_update_pending = 0; - - m_blt_cycle_count = 0; - m_image_offset = 0; - memset(m_guard_latch, 0, sizeof(m_guard_latch)); - - m_h_clock = 0; - m_v_clock = 0; - m_p_clock = 0; - m_data_clock = 0; - - m_image_memory = 0; - m_image_plane_size = 0; - m_image_memory_size = 0; - - memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); - - m_lut_fifo = NULL; - m_bt458 = NULL; -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void apollo_graphics_15i::device_reset() -{ - MLOG1(("apollo_graphics_15i::device_reset")); - - if (m_n_planes == 0) - { - if (apollo_config(APOLLO_CONF_MONO_19I)) - { - // monochrome 1280x1024 - m_n_planes = 1; - m_device_id = SCREEN_DEVICE_ID_19I; - m_width = 1280; - m_height = 1024; - m_buffer_width = 2048; - m_buffer_height = 1024; - } - else if (apollo_config(APOLLO_CONF_MONO_15I)) - { - // monochrome 1024x800 - m_n_planes = 1; - m_device_id = SCREEN_DEVICE_ID_15I; - m_width = 1024; - m_height = 800; - m_buffer_width = 1024; - m_buffer_height = 1024; - } - else if (apollo_config(APOLLO_CONF_4_PLANES)) - { - // 4-planes color 1024x800 - m_n_planes = 4; - m_device_id = SCREEN_DEVICE_ID_C4P; - m_width = 1024; - m_height = 800; - m_buffer_width = 1024; - m_buffer_height = 1024; - } - else - { - // 8-planes color 1024x800 - m_n_planes = 8; - m_device_id = SCREEN_DEVICE_ID_C8P; - m_width = 1024; - m_height = 800; - m_buffer_width = 1024; - m_buffer_height = 1024; - - if (m_lut_fifo) global_free(m_lut_fifo); - if (m_bt458) global_free(m_bt458); - - m_lut_fifo = global_alloc(lut_fifo); - - m_bt458 = global_alloc(bt458(machine())); - m_bt458->start(); - m_bt458->reset(); - } - } - - if (m_image_memory == NULL) - { - /* allocate the memory image */ - m_image_plane_size = m_buffer_height * m_buffer_width / 16; - m_image_memory_size = m_image_plane_size * m_n_planes; - m_image_memory - = auto_alloc_array(machine(), UINT16, m_image_memory_size); - assert(m_image_memory != NULL); - - MLOG1(("device reset apollo graphics: buffer=%p size=%0x", (void *) m_image_memory, m_image_memory_size)); - } - - memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table)); - memset(m_image_memory, 0, m_image_memory_size * 2); - - // register_vblank_callback(this); - - /* FIXME: register for VBLANK callbacks */ - register_vblank_callback(); -} - -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( apollo_mono19i ) - MCFG_DEFAULT_LAYOUT( layout_apollo ) - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") - MCFG_SCREEN_ADD(VIDEO_SCREEN_TAG, RASTER) - MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) - MCFG_SCREEN_REFRESH_RATE(64) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(616)) - MCFG_SCREEN_SIZE(1280, 1024) - MCFG_SCREEN_VISIBLE_AREA(0, 1279, 0, 1023) - MCFG_SCREEN_UPDATE_DEVICE(APOLLO_SCREEN_TAG, apollo_graphics_19i, screen_update) - MACHINE_CONFIG_END - -const device_type APOLLO_MONO19I = &device_creator ; - -apollo_graphics_19i::apollo_graphics_19i(const machine_config &mconfig, - const char *tag, device_t *owner, UINT32 clock) : - apollo_graphics_15i(mconfig, tag, owner, clock, APOLLO_MONO19I, - "Apollo 19\" Monochrome Screen", "apollo_graphics_19i", __FILE__) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void apollo_graphics_19i::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void apollo_graphics_19i::device_start() -{ - MLOG1(("apollo_graphics_19i::device_start")); - - apollo_graphics_15i::device_start(); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void apollo_graphics_19i::device_reset() -{ - MLOG1(("apollo_graphics_19i::device_reset")); - - if (m_n_planes == 0) - { - // monochrome 1280x1024 - m_n_planes = 1; - m_device_id = SCREEN_DEVICE_ID_19I; - m_width = 1280; - m_height = 1024; - m_buffer_width = 2048; - m_buffer_height = 1024; - } - - apollo_graphics_15i::device_reset(); - - /* FIXME: register for VBLANK callbacks */ - register_vblank_callback(); -} - - -READ16_MEMBER( apollo_graphics_15i::apollo_mgm_r ) -{ - if (is_mono()) - { - return apollo_mem_r(space, offset, mem_mask); - } - else - { - return 0xffff; - } -} - -WRITE16_MEMBER( apollo_graphics_15i::apollo_mgm_w ) -{ - if (is_mono()) - { - apollo_mem_w(space, offset, data, mem_mask); - } -} diff --git a/src/mess/video/apple1.c b/src/mess/video/apple1.c deleted file mode 100644 index f6485dc7ee5..00000000000 --- a/src/mess/video/apple1.c +++ /dev/null @@ -1,392 +0,0 @@ -// license:??? -// copyright-holders:Paul Daniels, Colin Howell, R. Belmont -/*************************************************************************** - - apple1.c - - Functions to emulate the video hardware of the Apple I. - - The Apple I video hardware was basically a dumb video terminal; in - fact it was based on Steve Wozniak's own design for a simple video - terminal. It had 40 columns by 24 lines of uppercase-only text. - Text could only be output at 60 characters per second, one character - per video frame. The cursor (a blinking @) could only be advanced - using spaces or carriage returns. Carriage returns were the only - control characters recognized. Previously written text could not be - altered, only scrolled off the top of the screen. - - The video memory used seven 1k-bit dynamic shift registers. Six of - these held the 6-bit visible character codes, and one stored the - cursor location as a simple bitmap--the bit for the cursor position - was set to 0, and all the other bits were 1. - - These shift registers were continuously recirculated, completing one - cycle per video frame. As a new line of characters was about to be - scanned by the video beam, that character line would be recirculated - into the shift registers and would simultaneously be stored into a - 6x40-bit line buffer (also a shift register). At this point, if the - cursor location was in this line, a new character could be written - into that location in the shift registers and the cursor could be - advanced. (Carriage returns were not written into the shift - registers; they only advanced the cursor.) - - The characters in the line buffer were recirculated 7 times to - display the 8 scan lines of the characters, before being replaced by - a new line of characters from the main shift registers. - - Cursor blinking was performed by a Signetics 555 timer IC whose - output was gated into the character code signals as they passed into - the line buffer. - - Character images were provided by a Signetics 2513 character - generator ROM, a chip also used in computer terminals such as the - ADM-3A. This ROM had 9 address lines and 5 data lines; it contained - 64 character images, each 5 pixels wide by 8 pixels high, with one - line of pixels being blank for vertical separation. The video - circuitry added the 2 pixels of horizontal separation for each - character. - - A special CLEAR SCREEN switch on the keyboard, directly connected to - the video hardware, could be used to clear the video memory and - return the cursor to the home position. This was completely - independent of the processor. - - A schematic of the Apple I video hardware can be found in the - Apple-1 Operation Manual; look for the schematic titled "Terminal - Section". Most of the functionality modeled here was determined by - reading this schematic. Many of the chips used were standard 74xx - TTL chips, but the shift registers used for the video memory and - line buffer were Signetics 25xx PMOS ICs. These were already - becoming obsolete when the Apple I was built, and detailed - information on them is very hard to find today. - -***************************************************************************/ - -#include "emu.h" -#include "includes/apple1.h" - - -/*************************************************************************** - - Terminal code - -***************************************************************************/ - -TILE_GET_INFO_MEMBER(apple1_state::terminal_gettileinfo) -{ - int ch, gfxfont, code, color; - - ch = m_current_terminal->mem[tile_index]; - code = ch & ((1 << m_current_terminal->char_bits) - 1); - color = ch >> m_current_terminal->char_bits; - gfxfont = m_current_terminal->gfx; - - if ((tile_index == m_current_terminal->cur_offset) && !m_current_terminal->cur_hidden && m_current_terminal->getcursorcode) - code = m_current_terminal->getcursorcode(code); - - SET_TILE_INFO_MEMBER(gfxfont, /* gfx */ - code, /* character */ - color, /* color */ - 0); /* flags */ -} - -void apple1_state::terminal_draw(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, terminal_t *terminal) -{ - m_current_terminal = terminal; - terminal->tm->draw(screen, dest, cliprect, 0, 0); - m_current_terminal = NULL; -} - -void apple1_state::verify_coords(terminal_t *terminal, int x, int y) -{ - assert(x >= 0); - assert(y >= 0); - assert(x < terminal->num_cols); - assert(y < terminal->num_rows); -} - -void apple1_state::terminal_putchar(terminal_t *terminal, int x, int y, int ch) -{ - int offs; - - verify_coords(terminal, x, y); - - offs = y * terminal->num_cols + x; - if (terminal->mem[offs] != ch) - { - terminal->mem[offs] = ch; - terminal->tm->mark_tile_dirty(offs); - } -} - -int apple1_state::terminal_getchar(terminal_t *terminal, int x, int y) -{ - int offs; - - verify_coords(terminal, x, y); - offs = y * terminal->num_cols + x; - return terminal->mem[offs]; -} - -void apple1_state::terminal_putblank(terminal_t *terminal, int x, int y) -{ - terminal_putchar(terminal, x, y, terminal->blank_char); -} - -void apple1_state::terminal_dirtycursor(terminal_t *terminal) -{ - if (terminal->cur_offset >= 0) - terminal->tm->mark_tile_dirty(terminal->cur_offset); -} - -void apple1_state::terminal_setcursor(terminal_t *terminal, int x, int y) -{ - terminal_dirtycursor(terminal); - terminal->cur_offset = y * terminal->num_cols + x; - terminal_dirtycursor(terminal); -} - -void apple1_state::terminal_hidecursor(terminal_t *terminal) -{ - terminal->cur_hidden = 1; - terminal_dirtycursor(terminal); -} - -void apple1_state::terminal_showcursor(terminal_t *terminal) -{ - terminal->cur_hidden = 0; - terminal_dirtycursor(terminal); -} - -void apple1_state::terminal_getcursor(terminal_t *terminal, int *x, int *y) -{ - *x = terminal->cur_offset % terminal->num_cols; - *y = terminal->cur_offset / terminal->num_cols; -} - -void apple1_state::terminal_fill(terminal_t *terminal, int val) -{ - int i; - for (i = 0; i < terminal->num_cols * terminal->num_rows; i++) - terminal->mem[i] = val; - terminal->tm->mark_all_dirty(); -} - -void apple1_state::terminal_clear(terminal_t *terminal) -{ - terminal_fill(terminal, terminal->blank_char); -} - -terminal_t *apple1_state::terminal_create( - int gfx, int blank_char, int char_bits, - int (*getcursorcode)(int original_code), - int num_cols, int num_rows) -{ - terminal_t *term; - int char_width, char_height; - - char_width = m_gfxdecode->gfx(gfx)->width(); - char_height = m_gfxdecode->gfx(gfx)->height(); - - term = (terminal_t *) auto_alloc_array(machine(), char, sizeof(terminal_t) - sizeof(term->mem) - + (num_cols * num_rows * sizeof(termchar_t))); - - term->tm = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(apple1_state::terminal_gettileinfo),this), TILEMAP_SCAN_ROWS, - char_width, char_height, num_cols, num_rows); - - term->gfx = gfx; - term->blank_char = blank_char; - term->char_bits = char_bits; - term->num_cols = num_cols; - term->num_rows = num_rows; - term->getcursorcode = getcursorcode; - term->cur_offset = -1; - term->cur_hidden = 0; - terminal_clear(term); - return term; -} - - -/**************************************************************************/ - - - -/* The cursor blinking is generated by a free-running timer with a - 0.52-second period. It is on for 2/3 of this period and off for - 1/3. */ -#define CURSOR_OFF_LENGTH (0.52/3) - -/**************************************************************************/ - -static int apple1_getcursorcode(int original_code) -{ - /* Cursor uses symbol 0 (an @ sign) in the character generator ROM. */ - return 0; -} - -/**************************************************************************/ - -void apple1_state::video_start() -{ - m_blink_on = 1; /* cursor is visible initially */ - m_terminal = terminal_create( - 0, /* graphics font 0 (the only one we have) */ - 32, /* Blank character is symbol 32 in the ROM */ - 8, /* use 8 bits for the character code */ - apple1_getcursorcode, - 40, 24); /* 40 columns, 24 rows */ - - terminal_setcursor(m_terminal, 0, 0); -} - -/* This function handles all writes to the video display. */ -void apple1_state::apple1_vh_dsp_w (int data) -{ - int x, y; - int cursor_x, cursor_y; - - /* While CLEAR SCREEN is being held down, the hardware is forced - to clear the video memory, so video writes have no effect. */ - if (m_vh_clrscrn_pressed) - return; - - /* The video display port only accepts the 7 lowest bits of the char. */ - data &= 0x7f; - - terminal_getcursor(m_terminal, &cursor_x, &cursor_y); - - if (data == '\r') { - /* Carriage-return moves the cursor to the start of the next - line. */ - cursor_x = 0; - cursor_y++; - } - else if (data < ' ') { - /* Except for carriage-return, the video hardware completely - ignores all control characters. */ - return; - } - else { - /* For visible characters, only 6 bits of the ASCII code are - used, because the 2513 character generator ROM only - contains 64 symbols. The low 5 bits of the ASCII code are - used directly. Bit 6 is ignored, since it is the same for - all the available characters in the ROM. Bit 7 is inverted - before being used as the high bit of the 6-bit ROM symbol - index, because the block of 32 ASCII symbols containing the - uppercase letters comes first in the ROM. */ - - int romindx = (data & 0x1f) | (((data ^ 0x40) & 0x40) >> 1); - - terminal_putchar(m_terminal, cursor_x, cursor_y, romindx); - if (cursor_x < 39) - { - cursor_x++; - } - else - { - cursor_x = 0; - cursor_y++; - } - } - - /* If the cursor went past the bottom line, scroll the text up one line. */ - if (cursor_y == 24) - { - for (y = 1; y < 24; y++) - for (x = 0; x < 40; x++) - terminal_putchar(m_terminal, x, y-1, - terminal_getchar(m_terminal, x, y)); - - for (x = 0; x < 40; x++) - terminal_putblank(m_terminal, x, 23); - - cursor_y--; - } - - terminal_setcursor(m_terminal, cursor_x, cursor_y); -} - -/* This function handles clearing the video display on cold-boot or in - response to a press of the CLEAR SCREEN switch. */ -void apple1_state::apple1_vh_dsp_clr () -{ - terminal_setcursor(m_terminal, 0, 0); - terminal_clear(m_terminal); -} - -/* Calculate how long it will take for the display to assert the RDA - signal in response to a video display write. This signal indicates - the display has completed the write and is ready to accept another - write. */ -attotime apple1_state::apple1_vh_dsp_time_to_ready () -{ - int cursor_x, cursor_y; - int cursor_scanline; - double scanline_period = m_screen->scan_period().as_double(); - double cursor_hfrac; - - /* The video hardware refreshes the screen by reading the - character codes from its circulating shift-register memory. - Because of the way this memory works, a new character can only - be written into the cursor location at the moment this location - is about to be read. This happens during the first scanline of - the cursor's character line, when the beam reaches the cursor's - horizontal position. */ - - terminal_getcursor(m_terminal, &cursor_x, &cursor_y); - cursor_scanline = cursor_y * apple1_charlayout.height; - - /* Each scanline is composed of 455 pixel times. The first 175 of - these are the horizontal blanking period; the remaining 280 are - for the visible part of the scanline. */ - cursor_hfrac = (175 + cursor_x * apple1_charlayout.width) / 455; - - if (m_screen->vpos() == cursor_scanline) { - /* video_screen_get_hpos() doesn't account for the horizontal - blanking interval; it acts as if the scanline period is - entirely composed of visible pixel times. However, we can - still use it to find what fraction of the current scanline - period has elapsed. */ - double current_hfrac = m_screen->hpos() / - m_screen->width(); - if (current_hfrac < cursor_hfrac) - return attotime::from_double(scanline_period * (cursor_hfrac - current_hfrac)); - } - - return attotime::from_double( - m_screen->time_until_pos(cursor_scanline, 0).as_double() + - scanline_period * cursor_hfrac); -} - -/* Blink the cursor on or off, as appropriate. */ -void apple1_state::apple1_vh_cursor_blink () -{ - int new_blink_on; - - /* The cursor is on for 2/3 of its blink period and off for 1/3. - This is most easily handled by dividing the total elapsed time - by the length of the off-portion of the cycle, giving us the - number of one-third-cycles elapsed, then checking the result - modulo 3. */ - - if (((int) (machine().time().as_double() / CURSOR_OFF_LENGTH)) % 3 < 2) - new_blink_on = 1; - else - new_blink_on = 0; - - if (new_blink_on != m_blink_on) { /* have we changed state? */ - if (new_blink_on) - terminal_showcursor(m_terminal); - else - terminal_hidecursor(m_terminal); - m_blink_on = new_blink_on; - } -} - -UINT32 apple1_state::screen_update_apple1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - apple1_vh_cursor_blink(); - terminal_draw(screen, bitmap, cliprect, m_terminal); - return 0; -} diff --git a/src/mess/video/apple2.c b/src/mess/video/apple2.c deleted file mode 100644 index 195fed4ce8f..00000000000 --- a/src/mess/video/apple2.c +++ /dev/null @@ -1,1540 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/*************************************************************************** - - video/apple2.c - -***************************************************************************/ - -#include "emu.h" -#include "includes/apple2.h" -#include "machine/ram.h" - -#include "video/apple2.h" - -/***************************************************************************/ - - -#define BLACK 0 -#define DKRED 1 -#define DKBLUE 2 -#define PURPLE 3 -#define DKGREEN 4 -#define DKGRAY 5 -#define BLUE 6 -#define LTBLUE 7 -#define BROWN 8 -#define ORANGE 9 -#define GRAY 10 -#define PINK 11 -#define GREEN 12 -#define YELLOW 13 -#define AQUA 14 -#define WHITE 15 - -#define ALWAYS_REFRESH 0 -#define PROFILER_VIDEOTOUCH PROFILER_USER3 - -/*************************************************************************** - HELPERS -***************************************************************************/ - -/*------------------------------------------------- - effective_a2 - calculates the effective a2 - register --------------------------------------------------*/ - -inline UINT32 apple2_state::effective_a2() -{ - return m_flags & m_a2_videomask; -} - - -/*------------------------------------------------- - compute_video_address - performs funky Apple II - video address lookup --------------------------------------------------*/ - -UINT32 apple2_state::compute_video_address(int col, int row) -{ - /* special Apple II addressing - gotta love it */ - return (((row & 0x07) << 7) | ((row & 0x18) * 5 + col)); -} - - - -/*------------------------------------------------- - adjust_begin_and_end_row - processes the cliprect --------------------------------------------------*/ - -void apple2_state::adjust_begin_and_end_row(const rectangle &cliprect, int *beginrow, int *endrow) -{ - /* assumptions of the code */ - assert((*beginrow % 8) == 0); - assert((*endrow % 8) == 7); - - *beginrow = MAX(*beginrow, cliprect.min_y - (cliprect.min_y % 8)); - *endrow = MIN(*endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - /* sanity check again */ - assert((*beginrow % 8) == 0); - assert((*endrow % 8) == 7); -} - - - -/*************************************************************************** - TEXT -***************************************************************************/ - -/*------------------------------------------------- - apple2_plot_text_character - plots a single - textual character --------------------------------------------------*/ - -inline void apple2_state::apple2_plot_text_character(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, - const UINT8 *textgfx_data, UINT32 textgfx_datalen, UINT32 my_a2) -{ - int x, y, i; - int fg = m_fgcolor; - int bg = m_bgcolor; - const UINT8 *chardata; - UINT16 color; - - if (m_sysconfig != NULL) - { - switch (m_sysconfig->read() & 0x03) - { - case 0: - break; // leave alone - - case 1: - if ((m_machinetype == APPLE_II) || (m_machinetype == LABA2P) || (m_machinetype == SPACE84)) - { - bg = WHITE; - } - else - { - fg = WHITE; - } - break; - - case 2: - if ((m_machinetype == APPLE_II) || (m_machinetype == LABA2P) || (m_machinetype == SPACE84)) - { - bg = GREEN; - } - else - { - fg = GREEN; - } - break; - - case 3: - if ((m_machinetype == APPLE_II) || (m_machinetype == LABA2P) || (m_machinetype == SPACE84)) - { - bg = ORANGE; - } - else - { - fg = ORANGE; - } - break; - } - } - - - if (my_a2 & VAR_ALTCHARSET) - { - /* we're using an alternate charset */ - code |= m_alt_charset_value; - } - else if (m_flash && (code >= 0x40) && (code <= 0x7f)) - { - /* we're flashing; swap */ - i = fg; - fg = bg; - bg = i; - } - - /* look up the character data */ - chardata = &textgfx_data[(code * 8) % textgfx_datalen]; - - /* and finally, plot the character itself */ - if ((m_machinetype == SPACE84) || (m_machinetype == LABA2P)) - { - for (y = 0; y < 8; y++) - { - for (x = 0; x < 7; x++) - { - color = (chardata[y] & (1 << (6-x))) ? bg : fg; - - for (i = 0; i < xscale; i++) - { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; - } - } - } - } - else - { - for (y = 0; y < 8; y++) - { - for (x = 0; x < 7; x++) - { - color = (chardata[y] & (1 << x)) ? bg : fg; - - for (i = 0; i < xscale; i++) - { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; - } - } - } - } -} - - - -/*------------------------------------------------- - apple2_text_draw - renders text (either 40 - column or 80 column) --------------------------------------------------*/ - -void apple2_state::apple2_text_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow) -{ - int row, col; - UINT32 start_address = (page ? 0x0800 : 0x0400); - UINT32 address; - UINT32 my_a2 = effective_a2(); - - /* perform adjustments */ - adjust_begin_and_end_row(cliprect, &beginrow, &endrow); - - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate adderss */ - address = start_address + compute_video_address(col, row / 8); - - if (my_a2 & VAR_80COL) - { - apple2_plot_text_character(bitmap, col * 14 + 0, row, 1, m_a2_videoaux[address], - m_textgfx_data, m_textgfx_datalen, my_a2); - apple2_plot_text_character(bitmap, col * 14 + 7, row, 1, m_a2_videoram[address], - m_textgfx_data, m_textgfx_datalen, my_a2); - } - else - { - apple2_plot_text_character(bitmap, col * 14, row, 2, m_a2_videoram[address], - m_textgfx_data, m_textgfx_datalen, my_a2); - } - } - } -} - - -/*------------------------------------------------- - apple2_lores_draw - renders lo-res text --------------------------------------------------*/ - -void apple2_state::apple2_lores_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow) -{ - int row, col, y, x; - UINT8 code; - UINT32 start_address = (page ? 0x0800 : 0x0400); - UINT32 address; - - /* perform adjustments */ - adjust_begin_and_end_row(cliprect, &beginrow, &endrow); - - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate adderss */ - address = start_address + compute_video_address(col, row / 8); - - /* perform the lookup */ - code = m_a2_videoram[address]; - - /* and now draw */ - for (y = 0; y < 4; y++) - { - for (x = 0; x < 14; x++) - bitmap.pix16(row + y, col * 14 + x) = (code >> 0) & 0x0F; - } - for (y = 4; y < 8; y++) - { - for (x = 0; x < 14; x++) - bitmap.pix16(row + y, col * 14 + x) = (code >> 4) & 0x0F; - } - } - } -} - - -/*************************************************************************** - HIGH RESOLUTION GRAPHICS -***************************************************************************/ - -void apple2_state::apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow) -{ - const UINT8 *vram, *vaux; - int row, col, b; - int offset; - int columns; - UINT8 vram_row[82]; - UINT16 v; - UINT16 *p; - UINT32 w; - UINT16 *artifact_map_ptr; - int mon_type = 0; - - if (m_sysconfig != NULL) - { - mon_type = m_sysconfig->read() & 0x03; - } - - /* sanity checks */ - if (beginrow < cliprect.min_y) - beginrow = cliprect.min_y; - if (endrow > cliprect.max_y) - endrow = cliprect.max_y; - if (endrow < beginrow) - return; - - if (m_machinetype == TK2000) - { - vram = m_a2_videoram + (page ? 0xa000 : 0x2000); - vaux = m_a2_videoaux + (page ? 0xa000 : 0x2000); - } - else - { - vram = m_a2_videoram + (page ? 0x4000 : 0x2000); - vaux = m_a2_videoaux + (page ? 0x4000 : 0x2000); - } - columns = ((effective_a2() & (VAR_DHIRES|VAR_80COL)) == (VAR_DHIRES|VAR_80COL)) ? 80 : 40; - - vram_row[0] = 0; - vram_row[columns + 1] = 0; - - for (row = beginrow; row <= endrow; row++) - { - for (col = 0; col < 40; col++) - { - offset = compute_video_address(col, row / 8) | ((row & 7) << 10); - - switch(columns) - { - case 40: - vram_row[1+col] = vram[offset]; - break; - - case 80: - vram_row[1+(col*2)+0] = vaux[offset]; - vram_row[1+(col*2)+1] = vram[offset]; - break; - - default: - fatalerror("Invalid column count\n"); - } - } - - p = &bitmap.pix16(row); - - for (col = 0; col < columns; col++) - { - w = (((UINT32) vram_row[col+0] & 0x7f) << 0) - | (((UINT32) vram_row[col+1] & 0x7f) << 7) - | (((UINT32) vram_row[col+2] & 0x7f) << 14); - - switch(columns) - { - case 40: - switch (mon_type) - { - case 0: - artifact_map_ptr = &m_hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; - for (b = 0; b < 7; b++) - { - v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; - *(p++) = v; - *(p++) = v; - } - break; - - case 1: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; - *(p++) = v ? GREEN : BLACK; - } - break; - - case 3: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; - *(p++) = v ? ORANGE : BLACK; - } - break; - } - break; - - case 80: - if (m_monochrome_dhr) - { - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - } - } - else - { - switch (mon_type) - { - case 0: - for (b = 0; b < 7; b++) - { - v = m_dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; - *(p++) = v; - } - break; - - case 1: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; - } - break; - - case 3: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; - } - break; - } - } - break; - - default: - fatalerror("Invalid column count\n"); - } - } - } -} - - - -/*************************************************************************** - VIDEO CORE -***************************************************************************/ - -void apple2_state::apple2_video_start(const UINT8 *vram, const UINT8 *aux_vram, UINT32 ignored_softswitches, int hires_modulo) -{ - int i, j; - UINT16 c; - UINT8 *apple2_font; - - static const UINT8 hires_artifact_color_table[] = - { - BLACK, PURPLE, GREEN, WHITE, - BLACK, BLUE, ORANGE, WHITE - }; - - static const UINT8 dhires_artifact_color_table[] = - { - BLACK, DKGREEN, BROWN, GREEN, - DKRED, DKGRAY, ORANGE, YELLOW, - DKBLUE, BLUE, GRAY, AQUA, - PURPLE, LTBLUE, PINK, WHITE - }; - - m_fgcolor = 15; - m_bgcolor = 0; - m_flash = 0; - apple2_font = memregion("gfx1")->base(); - m_alt_charset_value = memregion("gfx1")->bytes() / 16; - m_a2_videoram = vram; - m_a2_videoaux = aux_vram; - - m_textgfx_data = memregion("gfx1")->base(); - m_textgfx_datalen = memregion("gfx1")->bytes(); - - /* 2^3 dependent pixels * 2 color sets * 2 offsets */ - m_hires_artifact_map = auto_alloc_array(machine(), UINT16, 8 * 2 * 2); - - /* 2^4 dependent pixels */ - m_dhires_artifact_map = auto_alloc_array(machine(), UINT16, 16); - - /* build hires artifact map */ - for (i = 0; i < 8; i++) - { - for (j = 0; j < 2; j++) - { - if (i & 0x02) - { - if ((i & 0x05) != 0) - c = 3; - else - c = j ? 2 : 1; - } - else - { - if ((i & 0x05) == 0x05) - c = j ? 1 : 2; - else - c = 0; - } - m_hires_artifact_map[ 0 + j*8 + i] = hires_artifact_color_table[(c + 0) % hires_modulo]; - m_hires_artifact_map[16 + j*8 + i] = hires_artifact_color_table[(c + 4) % hires_modulo]; - } - } - - /* Fix for Ivel Ultra */ - if (!strcmp(machine().system().name, "ivelultr")) { - int len = memregion("gfx1")->bytes(); - for (i = 0; i < len; i++) - { - apple2_font[i] = BITSWAP8(apple2_font[i], 7, 7, 6, 5, 4, 3, 2, 1); - } - } - - /* do we need to flip the gfx? */ - if (!strcmp(machine().system().name, "apple2") - || !strcmp(machine().system().name, "apple2p") - || !strcmp(machine().system().name, "prav82") - || !strcmp(machine().system().name, "prav8m") - || !strcmp(machine().system().name, "ivelultr") - || !strcmp(machine().system().name, "apple2jp")) - { - int len = memregion("gfx1")->bytes(); - for (i = 0; i < len; i++) - { - apple2_font[i] = BITSWAP8(apple2_font[i], 7, 0, 1, 2, 3, 4, 5, 6); - } - } - - - /* build double hires artifact map */ - for (i = 0; i < 16; i++) - { - m_dhires_artifact_map[i] = dhires_artifact_color_table[i]; - } - - memset(&m_old_a2, 0, sizeof(m_old_a2)); - m_a2_videomask = ~ignored_softswitches; -} - - - -VIDEO_START_MEMBER(apple2_state,apple2) -{ - apple2_video_start(m_ram->pointer(), m_ram->pointer()+0x10000, VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 4); - - /* hack to fix the colors on apple2/apple2p */ - m_fgcolor = 0; - m_bgcolor = 15; - - m_monochrome_dhr = false; -} - - -VIDEO_START_MEMBER(apple2_state,apple2p) -{ - apple2_video_start(m_ram->pointer(), m_ram->pointer(), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 8); - - /* hack to fix the colors on apple2/apple2p */ - m_fgcolor = 0; - m_bgcolor = 15; - - m_monochrome_dhr = false; -} - - -VIDEO_START_MEMBER(apple2_state,apple2e) -{ - device_a2eauxslot_card_interface *auxslotdevice = m_a2eauxslot->get_a2eauxslot_card(); - if (auxslotdevice) - { - apple2_video_start(m_ram->pointer(), auxslotdevice->get_vram_ptr(), auxslotdevice->allow_dhr() ? 0 : VAR_DHIRES, 8); - } - else - { - apple2_video_start(m_ram->pointer(), m_ram->pointer(), VAR_80COL | VAR_DHIRES, 8); - } -} - - -VIDEO_START_MEMBER(apple2_state,apple2c) -{ - apple2_video_start(m_ram->pointer(), m_ram->pointer()+0x10000, 0, 8); -} - -UINT32 apple2_state::screen_update_apple2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int page; - UINT32 new_a2; - - /* calculate the m_flash value */ - m_flash = ((machine().time() * 4).seconds() & 1) ? 1 : 0; - - /* read out relevant softswitch variables; to see what has changed */ - new_a2 = effective_a2(); - if (new_a2 & VAR_80STORE) - new_a2 &= ~VAR_PAGE2; - new_a2 &= VAR_TEXT | VAR_MIXED | VAR_HIRES | VAR_DHIRES | VAR_80COL | VAR_PAGE2 | VAR_ALTCHARSET; - - if (ALWAYS_REFRESH || (new_a2 != m_old_a2)) - { - m_old_a2 = new_a2; - } - - /* choose which page to use */ - page = (new_a2 & VAR_PAGE2) ? 1 : 0; - - /* choose the video mode to draw */ - if (effective_a2() & VAR_TEXT) - { - /* text screen - TK2000 uses HGR for text */ - if (m_machinetype == TK2000) - { - apple2_hires_draw(bitmap, cliprect, page, 0, 191); - } - else - { - apple2_text_draw(bitmap, cliprect, page, 0, 191); - } - } - else if ((effective_a2() & VAR_HIRES) && (effective_a2() & VAR_MIXED)) - { - /* hi-res on top; text at bottom */ - apple2_hires_draw(bitmap, cliprect, page, 0, 159); - apple2_text_draw(bitmap, cliprect, page, 160, 191); - } - else if (effective_a2() & VAR_HIRES) - { - /* hi-res screen */ - apple2_hires_draw(bitmap, cliprect, page, 0, 191); - } - else if (effective_a2() & VAR_MIXED) - { - /* lo-res on top; text at bottom */ - apple2_lores_draw(bitmap, cliprect, page, 0, 159); - apple2_text_draw(bitmap, cliprect, page, 160, 191); - } - else - { - /* lo-res screen */ - apple2_lores_draw(bitmap, cliprect, page, 0, 191); - } - return 0; -} - -/* - New implementation -*/ - -const device_type APPLE2_VIDEO = &device_creator; - -//------------------------------------------------- -// a2_video_device - constructor -//------------------------------------------------- - -a2_video_device::a2_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, APPLE2_VIDEO, "Apple II video", tag, owner, clock, "a2video", __FILE__) -{ -} - -void a2_video_device::device_start() -{ - static const UINT8 hires_artifact_color_table[] = - { - BLACK, PURPLE, GREEN, WHITE, - BLACK, BLUE, ORANGE, WHITE - }; - static const UINT8 dhires_artifact_color_table[] = - { - BLACK, DKGREEN, BROWN, GREEN, - DKRED, DKGRAY, ORANGE, YELLOW, - DKBLUE, BLUE, GRAY, AQUA, - PURPLE, LTBLUE, PINK, WHITE - }; - - // generate hi-res artifact data - int i, j; - UINT16 c; - - /* 2^3 dependent pixels * 2 color sets * 2 offsets */ - m_hires_artifact_map = auto_alloc_array(machine(), UINT16, 8 * 2 * 2); - - /* build hires artifact map */ - for (i = 0; i < 8; i++) - { - for (j = 0; j < 2; j++) - { - if (i & 0x02) - { - if ((i & 0x05) != 0) - c = 3; - else - c = j ? 2 : 1; - } - else - { - if ((i & 0x05) == 0x05) - c = j ? 1 : 2; - else - c = 0; - } - m_hires_artifact_map[ 0 + j*8 + i] = hires_artifact_color_table[(c + 0) % 8]; - m_hires_artifact_map[16 + j*8 + i] = hires_artifact_color_table[(c + 4) % 8]; - } - } - - /* 2^4 dependent pixels */ - m_dhires_artifact_map = auto_alloc_array(machine(), UINT16, 16); - - /* build double hires artifact map */ - for (i = 0; i < 16; i++) - { - m_dhires_artifact_map[i] = dhires_artifact_color_table[i]; - } - - save_item(NAME(m_page2)); - save_item(NAME(m_flash)); - save_item(NAME(m_mix)); - save_item(NAME(m_graphics)); - save_item(NAME(m_hires)); - save_item(NAME(m_dhires)); - save_item(NAME(m_80col)); - save_item(NAME(m_altcharset)); -} - -void a2_video_device::device_reset() -{ - m_page2 = false; - m_graphics = false; - m_hires = false; - m_80col = false; - m_altcharset = false; - m_dhires = false; - m_flash = false; - m_mix = false; - m_sysconfig = 0; -} - -void a2_video_device::plot_text_character(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, - const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg) -{ - int x, y, i; - const UINT8 *chardata; - UINT16 color; - - if (!m_altcharset) - { - if ((code >= 0x40) && (code <= 0x7f)) - { - code &= 0x3f; - - if (m_flash) - { - i = fg; - fg = bg; - bg = i; - } - } - } - else - { - if ((code >= 0x60) && (code <= 0x7f)) - { - code |= 0x80; // map to lowercase normal - i = fg; // and flip the color - fg = bg; - bg = i; - } - } - - /* look up the character data */ - chardata = &textgfx_data[(code * 8)]; - - for (y = 0; y < 8; y++) - { - for (x = 0; x < 7; x++) - { - color = (chardata[y] & (1 << x)) ? bg : fg; - - for (i = 0; i < xscale; i++) - { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; - } - } - } -} - -void a2_video_device::plot_text_character_orig(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, - const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg) -{ - int x, y, i; - const UINT8 *chardata; - UINT16 color; - - if ((code >= 0x40) && (code <= 0x7f)) - { - if (m_flash) - { - i = fg; - fg = bg; - bg = i; - } - } - - /* look up the character data */ - chardata = &textgfx_data[(code * 8)]; - - for (y = 0; y < 8; y++) - { - for (x = 0; x < 7; x++) - { - color = (chardata[y] & (1 << (6-x))) ? fg : bg; - - for (i = 0; i < xscale; i++) - { - bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color; - } - } - } -} - -void a2_video_device::plot_text_character_ultr(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, - const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg) -{ - int x, y, i; - const UINT8 *chardata; - UINT16 color; - - if ((code >= 0x40) && (code <= 0x7f)) - { - if (m_flash) - { - i = fg; - fg = bg; - bg = i; - } - } - - /* look up the character data */ - chardata = &textgfx_data[(code * 8)]; - - for (y = 0; y < 8; y++) - { - for (x = 1; x < 8; x++) - { - color = (chardata[y] & (1 << x)) ? fg : bg; - - for (i = 0; i < xscale; i++) - { - bitmap.pix16(ypos + y, xpos + ((x-1) * xscale) + i) = color; - } - } - } -} - -void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - int row, col, y, x; - UINT8 code; - UINT32 start_address = m_page2 ? 0x0800 : 0x0400; - UINT32 address; - int fg = 0; - - switch (m_sysconfig & 0x03) - { - case 0: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - - /* perform adjustments */ - beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8)); - endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - if (!(m_sysconfig & 0x03)) - { - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate adderss */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - - /* perform the lookup */ - code = m_ram_ptr[address]; - - /* and now draw */ - for (y = 0; y < 4; y++) - { - for (x = 0; x < 14; x++) - bitmap.pix16(row + y, col * 14 + x) = (code >> 0) & 0x0F; - } - for (y = 4; y < 8; y++) - { - for (x = 0; x < 14; x++) - bitmap.pix16(row + y, col * 14 + x) = (code >> 4) & 0x0F; - } - } - } - } - else - { - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - UINT8 bits; - - /* calculate adderss */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - - /* perform the lookup */ - code = m_ram_ptr[address]; - - bits = (code >> 0) & 0x0F; - /* and now draw */ - for (y = 0; y < 4; y++) - { - for (x = 0; x < 14; x++) - { - bitmap.pix16(row + y, col * 14 + x) = bits & (1 << (x % 4)) ? fg : 0; - } - } - - bits = (code >> 4) & 0x0F; - for (y = 4; y < 8; y++) - { - for (x = 0; x < 14; x++) - bitmap.pix16(row + y, col * 14 + x) = bits & (1 << (x % 4)) ? fg : 0; - } - } - } - } -} - -void a2_video_device::dlores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - int row, col, y; - UINT8 code, auxcode; - UINT32 start_address = m_page2 ? 0x0800 : 0x0400; - UINT32 address; - static const int aux_colors[16] = { 0, 2, 4, 6, 8, 0xa, 0xc, 0xe, 1, 3, 5, 7, 9, 0xb, 0xd, 0xf }; - int fg = 0; - - switch (m_sysconfig & 0x03) - { - case 0: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - - /* perform adjustments */ - beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8)); - endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - if (!(m_sysconfig & 0x03)) - { - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate adderss */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - - /* perform the lookup */ - code = m_ram_ptr[address]; - auxcode = m_aux_ptr[address]; - - /* and now draw */ - for (y = 0; y < 4; y++) - { - UINT16 *vram = &bitmap.pix16(row + y, (col * 14)); - - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 0) & 0x0F]; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - *vram++ = (code >> 0) & 0x0F; - } - for (y = 4; y < 8; y++) - { - UINT16 *vram = &bitmap.pix16(row + y, (col * 14)); - - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = aux_colors[(auxcode >> 4) & 0x0F]; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - *vram++ = (code >> 4) & 0x0F; - } - } - } - } - else - { - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - UINT8 bits, abits; - - /* calculate adderss */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - - /* perform the lookup */ - code = m_ram_ptr[address]; - auxcode = m_aux_ptr[address]; - - bits = (code >> 0) & 0x0F; - abits = (auxcode >> 0) & 0x0F; - - /* and now draw */ - for (y = 0; y < 4; y++) - { - UINT16 *vram = &bitmap.pix16(row + y, (col * 14)); - - *vram++ = abits & (1 << 0) ? fg : 0; - *vram++ = abits & (1 << 1) ? fg : 0; - *vram++ = abits & (1 << 2) ? fg : 0; - *vram++ = abits & (1 << 3) ? fg : 0; - *vram++ = abits & (1 << 0) ? fg : 0; - *vram++ = abits & (1 << 1) ? fg : 0; - *vram++ = abits & (1 << 2) ? fg : 0; - *vram++ = bits & (1 << 0) ? fg : 0; - *vram++ = bits & (1 << 1) ? fg : 0; - *vram++ = bits & (1 << 2) ? fg : 0; - *vram++ = bits & (1 << 3) ? fg : 0; - *vram++ = bits & (1 << 0) ? fg : 0; - *vram++ = bits & (1 << 1) ? fg : 0; - *vram++ = bits & (1 << 2) ? fg : 0; - } - - bits = (code >> 4) & 0x0F; - abits = (auxcode >> 4) & 0x0F; - - for (y = 4; y < 8; y++) - { - UINT16 *vram = &bitmap.pix16(row + y, (col * 14)); - - *vram++ = abits & (1 << 0) ? fg : 0; - *vram++ = abits & (1 << 1) ? fg : 0; - *vram++ = abits & (1 << 2) ? fg : 0; - *vram++ = abits & (1 << 3) ? fg : 0; - *vram++ = abits & (1 << 0) ? fg : 0; - *vram++ = abits & (1 << 1) ? fg : 0; - *vram++ = abits & (1 << 2) ? fg : 0; - *vram++ = bits & (1 << 0) ? fg : 0; - *vram++ = bits & (1 << 1) ? fg : 0; - *vram++ = bits & (1 << 2) ? fg : 0; - *vram++ = bits & (1 << 3) ? fg : 0; - *vram++ = bits & (1 << 0) ? fg : 0; - *vram++ = bits & (1 << 1) ? fg : 0; - *vram++ = bits & (1 << 2) ? fg : 0; - } - } - } - } -} - -void a2_video_device::text_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - int row, col; - UINT32 start_address; - UINT32 address; - UINT8 *aux_page = m_ram_ptr; - int fg = 0; - int bg = 0; - - if (m_80col) - { - start_address = 0x400; - if (m_aux_ptr) - { - aux_page = m_aux_ptr; - } - } - else - { - start_address = m_page2 ? 0x800 : 0x400; - } - - beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8)); - endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - switch (m_sysconfig & 0x03) - { - case 0: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - - for (row = beginrow; row <= endrow; row += 8) - { - if (m_80col) - { - for (col = 0; col < 40; col++) - { - /* calculate address */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - - plot_text_character(bitmap, col * 14, row, 1, aux_page[address], - m_char_ptr, m_char_size, fg, bg); - plot_text_character(bitmap, col * 14 + 7, row, 1, m_ram_ptr[address], - m_char_ptr, m_char_size, fg, bg); - } - } - else - { - for (col = 0; col < 40; col++) - { - /* calculate address */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - plot_text_character(bitmap, col * 14, row, 2, m_ram_ptr[address], - m_char_ptr, m_char_size, fg, bg); - } - } - } -} - -void a2_video_device::text_update_orig(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - int row, col; - UINT32 start_address = m_page2 ? 0x800 : 0x400; - UINT32 address; - int fg = 0; - int bg = 0; - - beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8)); - endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - switch (m_sysconfig & 0x03) - { - case 0: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate address */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - plot_text_character_orig(bitmap, col * 14, row, 2, m_ram_ptr[address], - m_char_ptr, m_char_size, fg, bg); - } - } -} - -void a2_video_device::text_update_ultr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - int row, col; - UINT32 start_address = m_page2 ? 0x800 : 0x400; - UINT32 address; - int fg = 0; - int bg = 0; - - beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8)); - endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7); - - switch (m_sysconfig & 0x03) - { - case 0: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - - for (row = beginrow; row <= endrow; row += 8) - { - for (col = 0; col < 40; col++) - { - /* calculate address */ - address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)); - plot_text_character_ultr(bitmap, col * 14, row, 2, m_ram_ptr[address], - m_char_ptr, m_char_size, fg, bg); - } - } -} - -void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - const UINT8 *vram; - int row, col, b; - int offset; - UINT8 vram_row[42]; - UINT16 v; - UINT16 *p; - UINT32 w; - UINT16 *artifact_map_ptr; - int mon_type = m_sysconfig & 0x03; - - /* sanity checks */ - if (beginrow < cliprect.min_y) - beginrow = cliprect.min_y; - if (endrow > cliprect.max_y) - endrow = cliprect.max_y; - if (endrow < beginrow) - return; - - vram = &m_ram_ptr[(m_page2 ? 0x4000 : 0x2000)]; - - vram_row[0] = 0; - vram_row[41] = 0; - - for (row = beginrow; row <= endrow; row++) - { - for (col = 0; col < 40; col++) - { - offset = ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)) | ((row & 7) << 10); - vram_row[1+col] = vram[offset]; - } - - p = &bitmap.pix16(row); - - for (col = 0; col < 40; col++) - { - w = (((UINT32) vram_row[col+0] & 0x7f) << 0) - | (((UINT32) vram_row[col+1] & 0x7f) << 7) - | (((UINT32) vram_row[col+2] & 0x7f) << 14); - - switch (mon_type) - { - case 0: - // verified on h/w: setting dhires w/o 80col emulates a rev. 0 Apple ][ with no orange/blue - if (m_dhires) - { - artifact_map_ptr = m_hires_artifact_map; - } - else - { - artifact_map_ptr = &m_hires_artifact_map[((vram_row[col + 1] & 0x80) >> 7) * 16]; - } - for (b = 0; b < 7; b++) - { - v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; - *(p++) = v; - *(p++) = v; - } - break; - - case 1: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; - *(p++) = v ? GREEN : BLACK; - } - break; - - case 3: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; - *(p++) = v ? ORANGE : BLACK; - } - break; - } - } - } -} - -// similar to regular A2 except page 2 is at $A000 -void a2_video_device::hgr_update_tk2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - const UINT8 *vram; - int row, col, b; - int offset; - UINT8 vram_row[42]; - UINT16 v; - UINT16 *p; - UINT32 w; - UINT16 *artifact_map_ptr; - int mon_type = m_sysconfig & 0x03; - - /* sanity checks */ - if (beginrow < cliprect.min_y) - beginrow = cliprect.min_y; - if (endrow > cliprect.max_y) - endrow = cliprect.max_y; - if (endrow < beginrow) - return; - - vram = &m_ram_ptr[(m_page2 ? 0xa000 : 0x2000)]; - - vram_row[0] = 0; - vram_row[41] = 0; - - for (row = beginrow; row <= endrow; row++) - { - for (col = 0; col < 40; col++) - { - offset = ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)) | ((row & 7) << 10); - vram_row[1+col] = vram[offset]; - } - - p = &bitmap.pix16(row); - - for (col = 0; col < 40; col++) - { - w = (((UINT32) vram_row[col+0] & 0x7f) << 0) - | (((UINT32) vram_row[col+1] & 0x7f) << 7) - | (((UINT32) vram_row[col+2] & 0x7f) << 14); - - switch (mon_type) - { - case 0: - artifact_map_ptr = &m_hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; - for (b = 0; b < 7; b++) - { - v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; - *(p++) = v; - *(p++) = v; - } - break; - - case 1: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; - *(p++) = v ? GREEN : BLACK; - } - break; - - case 3: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; - *(p++) = v ? ORANGE : BLACK; - } - break; - } - } - } -} - -void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) -{ - const UINT8 *vram, *vaux; - int row, col, b; - int offset; - UINT8 vram_row[82]; - UINT16 v; - UINT16 *p; - UINT32 w; - int page = m_page2 ? 0x4000 : 0x2000; - int mon_type = m_sysconfig & 0x03; - - /* sanity checks */ - if (beginrow < cliprect.min_y) - beginrow = cliprect.min_y; - if (endrow > cliprect.max_y) - endrow = cliprect.max_y; - if (endrow < beginrow) - return; - - vram = &m_ram_ptr[page]; - if (m_aux_ptr) - { - vaux = m_aux_ptr; - } - else - { - vaux = vram; - } - vaux += page; - - vram_row[0] = 0; - vram_row[81] = 0; - - for (row = beginrow; row <= endrow; row++) - { - for (col = 0; col < 40; col++) - { - offset = ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col)) | ((row & 7) << 10); - vram_row[1+(col*2)+0] = vaux[offset]; - vram_row[1+(col*2)+1] = vram[offset]; - } - - p = &bitmap.pix16(row); - - for (col = 0; col < 80; col++) - { - w = (((UINT32) vram_row[col+0] & 0x7f) << 0) - | (((UINT32) vram_row[col+1] & 0x7f) << 7) - | (((UINT32) vram_row[col+2] & 0x7f) << 14); - - switch (mon_type) - { - case 0: - for (b = 0; b < 7; b++) - { - v = m_dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; - *(p++) = v; - } - break; - - case 1: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; - } - break; - - case 3: - w >>= 7; - for (b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; - } - break; - } - } - } -} - -/* according to Steve Nickolas (author of Dapple), our original palette would - * have been more appropriate for an Apple IIgs. So we've substituted in the - * Robert Munafo palette instead, which is more accurate on 8-bit Apples - */ -static const rgb_t apple2_palette[] = -{ - rgb_t::black, - rgb_t(0xE3, 0x1E, 0x60), /* Dark Red */ - rgb_t(0x60, 0x4E, 0xBD), /* Dark Blue */ - rgb_t(0xFF, 0x44, 0xFD), /* Purple */ - rgb_t(0x00, 0xA3, 0x60), /* Dark Green */ - rgb_t(0x9C, 0x9C, 0x9C), /* Dark Gray */ - rgb_t(0x14, 0xCF, 0xFD), /* Medium Blue */ - rgb_t(0xD0, 0xC3, 0xFF), /* Light Blue */ - rgb_t(0x60, 0x72, 0x03), /* Brown */ - rgb_t(0xFF, 0x6A, 0x3C), /* Orange */ - rgb_t(0x9C, 0x9C, 0x9C), /* Light Grey */ - rgb_t(0xFF, 0xA0, 0xD0), /* Pink */ - rgb_t(0x14, 0xF5, 0x3C), /* Light Green */ - rgb_t(0xD0, 0xDD, 0x8D), /* Yellow */ - rgb_t(0x72, 0xFF, 0xD0), /* Aquamarine */ - rgb_t(0xFF, 0xFF, 0xFF) /* White */ -}; - -/* Initialize the palette */ -PALETTE_INIT_MEMBER(a2_video_device, apple2) -{ - palette.set_pen_colors(0, apple2_palette, ARRAY_LENGTH(apple2_palette)); -} diff --git a/src/mess/video/apple2.h b/src/mess/video/apple2.h deleted file mode 100644 index 6f5f76e4cbf..00000000000 --- a/src/mess/video/apple2.h +++ /dev/null @@ -1,61 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/********************************************************************* - - video/apple2.h - Video handling for 8-bit Apple IIs - -*********************************************************************/ - -#ifndef __A2_VIDEO__ -#define __A2_VIDEO__ - -#include "emu.h" - -class a2_video_device : - public device_t -{ -public: - // construction/destruction - a2_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_PALETTE_INIT(apple2); - - bool m_page2; - bool m_flash; - bool m_mix; - bool m_graphics; - bool m_hires; - bool m_dhires; - bool m_80col; - bool m_altcharset; - UINT16 *m_hires_artifact_map; - UINT16 *m_dhires_artifact_map; - - UINT8 *m_ram_ptr, *m_aux_ptr, *m_char_ptr; - int m_char_size; - - int m_sysconfig; - - void text_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void text_update_ultr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void text_update_orig(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void lores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void dlores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void hgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void hgr_update_tk2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - void dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); - -protected: - virtual void device_reset(); - virtual void device_start(); - -private: - void plot_text_character(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg); - void plot_text_character_ultr(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg); - void plot_text_character_orig(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, UINT32 code, const UINT8 *textgfx_data, UINT32 textgfx_datalen, int fg, int bg); -}; - -// device type definition -extern const device_type APPLE2_VIDEO; - -#endif diff --git a/src/mess/video/apple2gs.c b/src/mess/video/apple2gs.c deleted file mode 100644 index fb00047c30a..00000000000 --- a/src/mess/video/apple2gs.c +++ /dev/null @@ -1,168 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods,R. Belmont -/********************************************************************* - - video/apple2gs.c - - Apple IIgs video code - -*********************************************************************/ - - -#include "emu.h" -#include "includes/apple2.h" -#include "includes/apple2gs.h" - - - -VIDEO_START_MEMBER(apple2gs_state,apple2gs) -{ - m_bordercolor = 0; - apple2_video_start(m_slowmem, m_slowmem+0x10000, 0, 8); - m_legacy_gfx = auto_bitmap_ind16_alloc(machine(), 560, 192); - - save_item(m_bordercolor, "BORDERCLR"); - save_item(NAME(m_fgcolor)); - save_item(NAME(m_bgcolor)); -} - - - -UINT32 apple2gs_state::screen_update_apple2gs(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - const UINT8 *vram; - UINT32 *scanline; - UINT8 scb, b; - int col, palette; - UINT32 last_pixel = 0, pixel; - int beamy; - UINT16 *a2pixel; - - beamy = cliprect.min_y; - - if (m_newvideo & 0x80) - { - // in top or bottom border? - if ((beamy < BORDER_TOP) || (beamy >= 200+BORDER_TOP)) - { - // don't draw past the bottom border - if (beamy >= 231+BORDER_TOP) - { - return 0; - } - - scanline = &bitmap.pix32(beamy); - for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++) - { - scanline[col] = m_a2_palette[m_bordercolor]; - } - } - else // regular screen area - { - int shrline = beamy - BORDER_TOP; - - scb = m_slowmem[0x19D00 + shrline]; - palette = ((scb & 0x0f) << 4); - - vram = &m_slowmem[0x12000 + (shrline * 160)]; - scanline = &bitmap.pix32(beamy); - - // draw left and right borders - for (col = 0; col < BORDER_LEFT; col++) - { - scanline[col] = m_a2_palette[m_bordercolor]; - scanline[col+BORDER_LEFT+640] = m_a2_palette[m_bordercolor]; - } - - if (scb & 0x80) // 640 mode - { - for (col = 0; col < 160; col++) - { - b = vram[col]; - scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[palette + 0 + ((b >> 6) & 0x03)]; - scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[palette + 4 + ((b >> 4) & 0x03)]; - scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[palette + 8 + ((b >> 2) & 0x03)]; - scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[palette + 12 + ((b >> 0) & 0x03)]; - } - } - else // 320 mode - { - for (col = 0; col < 160; col++) - { - b = vram[col]; - pixel = (b >> 4) & 0x0f; - - if ((scb & 0x20) && !pixel) - pixel = last_pixel; - else - last_pixel = pixel; - pixel += palette; - scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[pixel]; - scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[pixel]; - - b = vram[col]; - pixel = (b >> 0) & 0x0f; - - if ((scb & 0x20) && !pixel) - pixel = last_pixel; - else - last_pixel = pixel; - pixel += palette; - scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[pixel]; - scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[pixel]; - } - } - } - } - else - { - /* call legacy Apple II video rendering at scanline 0 to draw into the off-screen buffer */ - if (beamy == 0) - { - // check if DHR should be monochrome 560x192 - if (m_newvideo & 0x20) - { - m_monochrome_dhr = true; - } - else - { - m_monochrome_dhr = false; - } - - rectangle new_cliprect(0, 559, 0, 191); - screen_update_apple2(screen, *m_legacy_gfx, new_cliprect); - } - - if ((beamy < (BORDER_TOP+4)) || (beamy >= (192+4+BORDER_TOP))) - { - if (beamy >= (231+BORDER_TOP)) - { - return 0; - } - - scanline = &bitmap.pix32(beamy); - for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++) - { - scanline[col] = m_a2_palette[m_bordercolor]; - } - } - else - { - scanline = &bitmap.pix32(beamy); - - // draw left and right borders - for (col = 0; col < BORDER_LEFT + 40; col++) - { - scanline[col] = m_a2_palette[m_bordercolor]; - scanline[col+BORDER_LEFT+600] = m_a2_palette[m_bordercolor]; - } - - a2pixel = &m_legacy_gfx->pix16(beamy-(BORDER_TOP+4)); - for (int x = 0; x < 560; x++) - { - scanline[40 + BORDER_LEFT + x] = m_a2_palette[*a2pixel++]; - } - } - } - return 0; -} diff --git a/src/mess/video/apple3.c b/src/mess/video/apple3.c deleted file mode 100644 index e733199bd87..00000000000 --- a/src/mess/video/apple3.c +++ /dev/null @@ -1,518 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods,R. Belmont -/*************************************************************************** - - video/apple3.c - - Apple /// - -***************************************************************************/ - - -#include "emu.h" -#include "includes/apple3.h" -#include "machine/ram.h" - -#define BLACK 0 -#define DKRED 1 -#define DKBLUE 2 -#define PURPLE 3 -#define DKGREEN 4 -#define DKGRAY 5 -#define BLUE 6 -#define LTBLUE 7 -#define BROWN 8 -#define ORANGE 9 -#define GRAY 10 -#define PINK 11 -#define GREEN 12 -#define YELLOW 13 -#define AQUA 14 -#define WHITE 15 - -// derived from the IIgs palette then adjusted to match Sara -static const unsigned char apple3_palette[] = -{ - // text colors, which don't match the Apple II palette - 0x0, 0x0, 0x0, /* Black $0 */ - 0x5, 0x0, 0x5, /* Magenta $1 */ - 0x0, 0x0, 0x9, /* Dark Blue $2 */ - 0xD, 0x2, 0xD, /* Purple $3 */ - 0x0, 0x7, 0x2, /* Dark Green $4 */ - 0xa, 0xa, 0xa, /* Light Gray $5 */ - 0x2, 0x2, 0xF, /* Medium Blue $6 */ - 0x6, 0xA, 0xF, /* Light Blue $7 */ - 0x8, 0x5, 0x0, /* Brown $8 */ - 0xF, 0x6, 0x0, /* Orange $9 */ - 0x5, 0x5, 0x5, /* Dark Gray $A */ - 0xF, 0x9, 0xF, /* Pink $B */ - 0x1, 0xD, 0x0, /* Light Green $C */ - 0xe, 0xe, 0x0, /* Yellow $D */ - 0x4, 0xe, 0xd, /* Cyan $E */ - 0xF, 0xF, 0xF, /* White $F */ - // graphics colors, which *are* Apple II order - 0x0, 0x0, 0x0, /* Black $0 */ - 0xD, 0x0, 0x3, /* Deep Red $1 */ - 0x0, 0x0, 0x9, /* Dark Blue $2 */ - 0xD, 0x2, 0xD, /* Purple $3 */ - 0x0, 0x7, 0x2, /* Dark Green $4 */ - 0x5, 0x5, 0x5, /* Dark Gray $5 */ - 0x2, 0x2, 0xF, /* Medium Blue $6 */ - 0x6, 0xA, 0xF, /* Light Blue $7 */ - 0x8, 0x5, 0x0, /* Brown $8 */ - 0xF, 0x6, 0x0, /* Orange $9 */ - 0xA, 0xA, 0xA, /* Light Gray $A */ - 0xF, 0x9, 0x8, /* Pink $B */ - 0x1, 0xD, 0x0, /* Light Green $C */ - 0xF, 0xF, 0x0, /* Yellow $D */ - 0x4, 0xF, 0x9, /* Aquamarine $E */ - 0xF, 0xF, 0xF /* White $F */ - -}; - -static const UINT32 text_map[] = -{ - 0x400, 0x480, 0x500, 0x580, 0x600, 0x680, 0x700, 0x780, - 0x428, 0x4a8, 0x528, 0x5a8, 0x628, 0x6a8, 0x728, 0x7a8, - 0x450, 0x4d0, 0x550, 0x5d0, 0x650, 0x6d0, 0x750, 0x7d0 -}; - - -PALETTE_INIT_MEMBER(apple3_state, apple3) -{ - int i; - - for (i = 0; i < 32; i++) - { - m_palette->set_pen_color(i, - apple3_palette[(3*i)]*17, - apple3_palette[(3*i)+1]*17, - apple3_palette[(3*i)+2]*17); - } -} - -void apple3_state::apple3_write_charmem() -{ - address_space& space = m_maincpu->space(AS_PROGRAM); - static const UINT32 screen_hole_map[] = - { - 0x478, 0x4f8, 0x578, 0x5f8, 0x678, 0x6f8, 0x778, 0x7f8 - }; - int i, j, addr; - UINT8 val; - - for (i = 0; i < 8; i++) - { - for (j = 0; j < 4; j++) - { - addr = 0x7f & space.read_byte(screen_hole_map[i] + 0x400 + j + 0); - val = space.read_byte(screen_hole_map[i] + j + 0); - m_char_mem[((addr * 8) + ((i & 3) * 2) + 0) & 0x3ff] = val; - - addr = 0x7f & space.read_byte(screen_hole_map[i] + 0x400 + j + 4); - val = space.read_byte(screen_hole_map[i] + j + 4); - m_char_mem[((addr * 8) + ((i & 3) * 2) + 1) & 0x3ff] = val; - } - } -} - - - -VIDEO_START_MEMBER(apple3_state,apple3) -{ - int i, j; - UINT32 v; - - memset(m_char_mem, 0, 0x800); - - m_hgr_map = auto_alloc_array(machine(), UINT32, 192); - for (i = 0; i < 24; i++) - { - v = text_map[i] - 0x0400; - for (j = 0; j < 8; j++) - { - m_hgr_map[(i * 8) + j] = 0x2000 + v + (j * 0x400); - } - } -} - - - -void apple3_state::apple3_video_text40(bitmap_ind16 &bitmap) -{ - int x, y, col, row, lc; - offs_t offset; - UINT8 ch; - const UINT8 *char_data; - pen_t fg, bg, temp; - UINT16 *dest; - UINT8 *ram = m_ram->pointer(); - UINT32 ram_size = m_ram->size(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 24; y++) - { - for (x = 0; x < 40; x++) - { - offset = ram_size - 0x8000 + text_map[y] + x + (m_flags & VAR_VM2 ? 0x0400 : 0x0000); - ch = ram[offset]; - - // no color text in emulation mode - if ((m_flags & VAR_VM0) && (m_via_1_a & 0x40)) - { - /* color text */ - offset = ram_size - 0x8000 + text_map[y] + x + (m_flags & VAR_VM2 ? 0x0000 : 0x0400); - bg = (ram[offset] >> 0) & 0x0F; - fg = (ram[offset] >> 4) & 0x0F; - } - else - { - /* monochrome - on a real /// with an RGB monitor, text is white */ - bg = BLACK; - fg = WHITE; - } - - /* inverse? */ - if (!(ch & 0x80)) - { - temp = fg; - fg = bg; - bg = temp; - } - - char_data = &m_char_mem[(ch & 0x7F) * 8]; - - for (row = 0; row < 8; row++) - { - for (col = 0; col < 7; col++) - { - if (m_smoothscr) - { - // get the offset into the group of 8 lines - lc = (col + smooth) & 7; - } - else - { - lc = col; - } - - dest = &bitmap.pix16(y * 8 + row, x * 14 + lc * 2); - dest[0] = (char_data[row] & (1 << col)) ? fg : bg; - dest[1] = (char_data[row] & (1 << col)) ? fg : bg; - } - } - } - } -} - - - -void apple3_state::apple3_video_text80(bitmap_ind16 &bitmap) -{ - int x, y, col, row, lc; - offs_t offset; - UINT8 ch; - const UINT8 *char_data; - pen_t fg, bg; - UINT16 *dest; - UINT8 *ram = m_ram->pointer(); - UINT32 ram_size = m_ram->size(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 24; y++) - { - for (x = 0; x < 40; x++) - { - offset = ram_size - 0x8000 + text_map[y] + x; - - /* first character */ - ch = ram[offset + 0x0000]; - char_data = &m_char_mem[(ch & 0x7F) * 8]; - fg = (ch & 0x80) ? GREEN : BLACK; - bg = (ch & 0x80) ? BLACK : GREEN; - - for (row = 0; row < 8; row++) - { - for (col = 0; col < 7; col++) - { - if (m_smoothscr) - { - // get the offset into the group of 8 lines - lc = (col + smooth) & 7; - } - else - { - lc = col; - } - - dest = &bitmap.pix16(y * 8 + row, x * 14 + lc + 0); - *dest = (char_data[row] & (1 << col)) ? fg : bg; - } - } - - /* second character */ - ch = ram[offset + 0x0400]; - char_data = &m_char_mem[(ch & 0x7F) * 8]; - fg = (ch & 0x80) ? GREEN : BLACK; - bg = (ch & 0x80) ? BLACK : GREEN; - - for (row = 0; row < 8; row++) - { - for (col = 0; col < 7; col++) - { - dest = &bitmap.pix16(y * 8 + row, x * 14 + col + 7); - *dest = (char_data[row] & (1 << col)) ? fg : bg; - } - } - } - } -} - - - -void apple3_state::apple3_video_graphics_hgr(bitmap_ind16 &bitmap) -{ - /* hi-res mode: 280x192x2 */ - int y, i, x, ly, lyb; - const UINT8 *pix_info; - UINT16 *ptr; - UINT8 b; - UINT8 *ram = m_ram->pointer(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 192; y++) - { - ly = y; - if (m_smoothscr) - { - // get our base Y position - ly = y & ~7; - // get the offset into the group of 8 lines - lyb = ((y % 8) + smooth) & 7; - // add to the base - ly += lyb; - } - - if (m_flags & VAR_VM2) - pix_info = &ram[m_hgr_map[ly]]; - else - pix_info = &ram[m_hgr_map[ly] - 0x2000]; - ptr = &bitmap.pix16(y); - - for (i = 0; i < 40; i++) - { - b = *(pix_info++); - - for (x = 0; x < 7; x++) - { - ptr[0] = ptr[1] = (b & 0x01) ? WHITE : BLACK; - ptr += 2; - b >>= 1; - } - } - } -} - -void apple3_state::apple3_video_graphics_chgr(bitmap_ind16 &bitmap) -{ - /* color hi-res mode: 280x192x16 */ - int y, i, x, ly, lyb; - const UINT8 *pix_info; - const UINT8 *col_info; - UINT16 *ptr; - UINT8 b; - UINT16 fgcolor, bgcolor; - UINT8 *ram = m_ram->pointer(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 192; y++) - { - ly = y; - if (m_smoothscr) - { - // get our base Y position - ly = y & ~7; - // get the offset into the group of 8 lines - lyb = ((y % 8) + smooth) & 7; - // add to the base - ly += lyb; - } - - if (m_flags & VAR_VM2) - { - pix_info = &ram[m_hgr_map[ly] + 0x2000]; - col_info = &ram[m_hgr_map[ly] + 0x4000]; - } - else - { - pix_info = &ram[m_hgr_map[ly] - 0x2000]; - col_info = &ram[m_hgr_map[ly]]; - } - ptr = &bitmap.pix16(y); - - for (i = 0; i < 40; i++) - { - bgcolor = ((*col_info >> 0) & 0x0F) + 16; - fgcolor = ((*col_info >> 4) & 0x0F) + 16; - - b = *pix_info; - - for (x = 0; x < 7; x++) - { - ptr[0] = ptr[1] = (b & 1) ? fgcolor : bgcolor; - ptr += 2; - b >>= 1; - } - pix_info++; - col_info++; - } - } -} - - - -void apple3_state::apple3_video_graphics_shgr(bitmap_ind16 &bitmap) -{ - /* super hi-res mode: 560x192x2 */ - int y, i, x, ly, lyb; - const UINT8 *pix_info1; - const UINT8 *pix_info2; - UINT16 *ptr; - UINT8 b1, b2; - UINT8 *ram = m_ram->pointer(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 192; y++) - { - ly = y; - if (m_smoothscr) - { - // get our base Y position - ly = y & ~7; - // get the offset into the group of 8 lines - lyb = ((y % 8) + smooth) & 7; - // add to the base - ly += lyb; - } - - if (m_flags & VAR_VM2) - { - pix_info1 = &ram[m_hgr_map[ly] + 0x2000]; - pix_info2 = &ram[m_hgr_map[ly] + 0x4000]; - } - else - { - pix_info1 = &ram[m_hgr_map[ly] - 0x2000]; - pix_info2 = &ram[m_hgr_map[ly]]; - } - ptr = &bitmap.pix16(y); - - for (i = 0; i < 40; i++) - { - b1 = *(pix_info1++); - b2 = *(pix_info2++); - - for (x = 0; x < 7; x++) - { - *(ptr++) = (b1 & 0x01) ? WHITE : BLACK; - b1 >>= 1; - } - - for (x = 0; x < 7; x++) - { - *(ptr++) = (b2 & 0x01) ? WHITE : BLACK; - b2 >>= 1; - } - } - } -} - - - -void apple3_state::apple3_video_graphics_chires(bitmap_ind16 &bitmap) -{ - UINT16 *pen; - UINT8 p1, p2, p3, p4; - int y, i, ly, lyb; - UINT8 *ram = m_ram->pointer(); - int smooth = m_va | (m_vb << 1) | (m_vc << 2); - - for (y = 0; y < 192; y++) - { - ly = y; - if (m_smoothscr) - { - // get our base Y position - ly = y & ~7; - // get the offset into the group of 8 lines - lyb = ((y % 8) + smooth) & 7; - // add to the base - ly += lyb; - } - - pen = &bitmap.pix16(y); - for (i = 0; i < 20; i++) - { - if (m_flags & VAR_VM2) - { - p1 = ram[m_hgr_map[ly] + 0x2000 + (i * 2) + 0]; - p2 = ram[m_hgr_map[ly] + 0x4000 + (i * 2) + 0]; - p3 = ram[m_hgr_map[ly] + 0x2000 + (i * 2) + 1]; - p4 = ram[m_hgr_map[ly] + 0x4000 + (i * 2) + 1]; - } - else - { - p1 = ram[m_hgr_map[ly] - 0x2000 + (i * 2) + 0]; - p2 = ram[m_hgr_map[ly] - 0x0000 + (i * 2) + 0]; - p3 = ram[m_hgr_map[ly] - 0x2000 + (i * 2) + 1]; - p4 = ram[m_hgr_map[ly] - 0x0000 + (i * 2) + 1]; - } - - pen[ 0] = pen[ 1] = pen[ 2] = pen[ 3] = (p1 & 0x0f); - pen[ 4] = pen[ 5] = pen[ 6] = pen[ 7] = ((p1 >> 4) & 0x07) | ((p2 & 1) << 3); - pen[ 8] = pen[ 9] = pen[10] = pen[11] = ((p2 >> 1) & 0x0F); - pen[12] = pen[13] = pen[14] = pen[15] = ((p2 >> 5) & 0x03) | ((p3 & 3) << 2); - pen[16] = pen[17] = pen[18] = pen[19] = ((p3 >> 2) & 0x0F); - pen[20] = pen[21] = pen[22] = pen[23] = ((p3 >> 6) & 0x01) | ((p4 << 1) & 0xe); - pen[24] = pen[25] = pen[26] = pen[27] = ((p4 >> 3) & 0x0F); - pen += 28; - } - } -} - - - -UINT32 apple3_state::screen_update_apple3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ -// printf("gfx mode %x\n", m_flags & (VAR_VM3|VAR_VM1|VAR_VM0)); - - switch(m_flags & (VAR_VM3|VAR_VM1|VAR_VM0)) - { - case 0: - case VAR_VM0: - apple3_video_text40(bitmap); - break; - - case VAR_VM1: - case VAR_VM1|VAR_VM0: - apple3_video_text80(bitmap); - break; - - case VAR_VM3: - apple3_video_graphics_hgr(bitmap); /* hgr mode */ - break; - - case VAR_VM3|VAR_VM0: - apple3_video_graphics_chgr(bitmap); - break; - - case VAR_VM3|VAR_VM1: - apple3_video_graphics_shgr(bitmap); - break; - - case VAR_VM3|VAR_VM1|VAR_VM0: - apple3_video_graphics_chires(bitmap); - break; - } - return 0; -} diff --git a/src/mess/video/aquarius.c b/src/mess/video/aquarius.c deleted file mode 100644 index 3d644bfd8b2..00000000000 --- a/src/mess/video/aquarius.c +++ /dev/null @@ -1,80 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/*************************************************************************** - - aquarius.c - - Functions to emulate the video hardware of the aquarius. - -***************************************************************************/ - -#include "emu.h" -#include "includes/aquarius.h" - - -static const unsigned short aquarius_palette[] = -{ - 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,10, 0,11, 0,12, 0,13, 0,14, 0,15, 0, - 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1,10, 1,11, 1,12, 1,13, 1,14, 1,15, 1, - 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2,10, 2,11, 2,12, 2,13, 2,14, 2,15, 2, - 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3,10, 3,11, 3,12, 3,13, 3,14, 3,15, 3, - 0, 4, 1, 4, 2, 4, 3, 4, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4,10, 4,11, 4,12, 4,13, 4,14, 4,15, 4, - 0, 5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5,10, 5,11, 5,12, 5,13, 5,14, 5,15, 5, - 0, 6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 6, 7, 6, 8, 6, 9, 6,10, 6,11, 6,12, 6,13, 6,14, 6,15, 6, - 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8, 7, 9, 7,10, 7,11, 7,12, 7,13, 7,14, 7,15, 7, - 0, 8, 1, 8, 2, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 8, 9, 8,10, 8,11, 8,12, 8,13, 8,14, 8,15, 8, - 0, 9, 1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9, 9, 9,10, 9,11, 9,12, 9,13, 9,14, 9,15, 9, - 0,10, 1,10, 2,10, 3,10, 4,10, 5,10, 6,10, 7,10, 8,10, 9,10,10,10,11,10,12,10,13,10,14,10,15,10, - 0,11, 1,11, 2,11, 3,11, 4,11, 5,11, 6,11, 7,11, 8,11, 9,11,10,11,11,11,12,11,13,11,14,11,15,11, - 0,12, 1,12, 2,12, 3,12, 4,12, 5,12, 6,12, 7,12, 8,12, 9,12,10,12,11,12,12,12,13,12,14,12,15,12, - 0,13, 1,13, 2,13, 3,13, 4,13, 5,13, 6,13, 7,13, 8,13, 9,13,10,13,11,13,12,13,13,13,14,13,15,13, - 0,14, 1,14, 2,14, 3,14, 4,14, 5,14, 6,14, 7,14, 8,14, 9,14,10,14,11,14,12,14,13,14,14,14,15,14, - 0,15, 1,15, 2,15, 3,15, 4,15, 5,15, 6,15, 7,15, 8,15, 9,15,10,15,11,15,12,15,13,15,14,15,15,15, -}; - -PALETTE_INIT_MEMBER(aquarius_state, aquarius) -{ - int i; - - for (i = 0; i < 16; i++) - m_palette->set_indirect_color(i, m_tea1002->color(i)); - - for (i = 0; i < 512; i++) - m_palette->set_pen_indirect(i, aquarius_palette[i]); -} - -WRITE8_MEMBER(aquarius_state::aquarius_videoram_w) -{ - UINT8 *videoram = m_videoram; - videoram[offset] = data; - m_tilemap->mark_tile_dirty(offset); -} - -WRITE8_MEMBER(aquarius_state::aquarius_colorram_w) -{ - m_colorram[offset] = data; - m_tilemap->mark_tile_dirty(offset); -} - -TILE_GET_INFO_MEMBER(aquarius_state::aquarius_gettileinfo) -{ - UINT8 *videoram = m_videoram; - int bank = 0; - int code = videoram[tile_index]; - int color = m_colorram[tile_index]; - int flags = 0; - - SET_TILE_INFO_MEMBER(bank, code, color, flags); -} - -void aquarius_state::video_start() -{ - m_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarius_state::aquarius_gettileinfo),this), TILEMAP_SCAN_ROWS, 8, 8, 40, 25); -} - -UINT32 aquarius_state::screen_update_aquarius(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - return 0; -} diff --git a/src/mess/video/arcadia.c b/src/mess/video/arcadia.c deleted file mode 100644 index 869439aef10..00000000000 --- a/src/mess/video/arcadia.c +++ /dev/null @@ -1,676 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/****************************************************************************** -Consolidation and enhancment of documentation by Manfred Schneider based on previous work from - PeT mess@utanet.at and Paul Robson (autismuk@aol.com) - - Schematics, manuals and anything you can desire for at http://amigan.1emu.net/ - - TODO: find a dump of the charactyer ROM - convert the drawing code to tilemap - - emulation of signetics 2637 video/audio device - -General -The UVI is capable of controlling 512 Bytes of RAM. It also generates a select signal -for a 128 byte wide area. -This whole addres space maps in the arcadia and compatible machines from $1800 - $1AFF. - -1. Video Memory - -The screen table is at 1800-CF and 1A00-CF. Each page has 13 lines of the -screen (16 bytes per line,26 lines in total, 208 scan lines). The 2 most -significant bits of each byte are colour data, the 6 least significant -are character data. The resolution of the Arcadia is 128 x 208 pixels. - -It is possible to halve the screen resolution so 1A00..1ACF can -be used for code. This is controlled by bit 6 of $19F8. - -The byte at location $18FF is the current Character Line address, lower -4 bits only. The start line goes from 1800 to 18C0 then from 1900 to 19C0. -The 4 least significant bits of this count 0123456789ABC0123456789ABC, -going to D when in vertical blank. The 4 most significant bits are always -'1'. Some games do use this for scrolling effects - a good example of this -is the routine at $010F in Alien Invaders which scrolls the various bits of -the screen about using the memory locations $18FF and $18FE. - -The screen can be scrolled upto 7 pixels to the left using the high 3 bits -of $18FE. This is used in Alien Invaders. - -A line beginning with $C0 contains block graphics. Each square contains -3 wide x 2 high pixels, coloured as normal. The 3 least significant bits -are the top, the next 3 bits are the bottom. Alien Invaders uses this for -shields. The graphics are returned to normal for the next line. - -The VBlank signal (maybe VSYNC) is connected to the SENSE input. This is -logic '1' when the system is in VBLANK. - -The Flag line does.... something graphical - it might make the sprites -half width/double height perhaps. Breakaway sets this when the bats are -double size in vertical mode. - - -2. Character codes - -Character codes 00..37 to be in a ROM somewhere in the Emerson. These -are known, others may be discovered by comparing the screen snapshots -against the character tables. If the emulator displays an exclamation -mark you've found one. Get a snapshot to see what it looks like -normally and let me know. Codes 38..3F are taken from RAM. - -00 (space) -01..0F Graphic Characters -10..19 0..9 -1A..33 A..Z -34 Decimal Point -35 comma -36 + -37 $ -38..3F User Defined Characters (8 off, from 1980..19FF) - -Character data is stored 8 bits per character , as a single plane graphic -The 2nd and 3rd bits of palette data come from the screen tables, so there -are two colours per character and 4 possible palette selections for the -background. - - -3. Sound - -fixed frequency sound and random Noise generator. -18FD pitch (lower 7 bits) -18FE volume ( bits 0 - 2) -18fe bit 3 set means sound on -18fe bit 4 set means random noise on - -Calculation of sound frequency is done as follows - 1/Freq = 2 (pitch +1) * (horizontal line period) - - -4. Sprites - -Sprite pointers are at 18F0..18F7 (there are four of them). The graphics -used are the ones in the 1980..19BF UDG table (the first four). - -Sprite addresses (x,y) are converted to offsets in the 128 x 208 as follows: - -1) 1's complement the y coordinate -2) subtract 16 from the y coordinate -3) subtract 43 from the x coordinate - -5. Palette - -The Palette is encoded between 19F8-19FB. This section describes the method -by which colours are allocated. There are 8 colours, information is coded -3 bits per colour (usually 2 colours per byte) - - Colour Code Name - ------ ----- ------- - 7 111 Black - 6 110 Blue - 5 101 Red - 4 100 Magenta - 3 011 Green - 2 010 Cyan - 1 001 Yellow - 0 000 White - -Bits 0..2 of $19F9 are the screen colour -Bits 3..5 of $19F9 are the colours of characters -Bit 6 of $19f9 is for poti axis -Bit 7 of $19f9 is for character size (1 = 8x8; 0 = 8x16) -Bits 0..5 of $19FA are the colours of Sprites 2 & 3 (sprite 3 is low bits) -Bit 6 of $19FA is for size of sprite 3 (0 = 8x16; 1 = 8x8) -Bit 7 of $19FA is for size of sprite 2 (0 = 8x16; 1 = 8x8) -Bits 0..5 of $19FB are the colours of Sprites 0 & 1 (sprite 1 is low bits) -Bit 6 of $19FB is for size of sprite 1 (0 = 8x16; 1 = 8x8) -Bit 7 of $19FB is for size of sprite 0 (0 = 8x16; 1 = 8x8) - - -6. Collision Detection - -Bits are set to zero on a collision - I think they are reset at the -frame start. There are two locations : one is for sprite/background -collisions, one is for sprite/sprite collisions. - -19FC bits 0..3 are collision between sprites 0..3 and the background. - -19FD bit 0 is sprite 0 / 1 collision - bit 1 is sprite 0 / 2 collision - bit 2 is sprite 0 / 3 collision - bit 3 is sprite 1 / 2 collision - bit 4 is sprite 1 / 3 collision (guess) - bit 5 is sprite 2 / 3 collision (guess) - - -7. Graphic Mode -19f8 bit 7 graphics mode on (lower 6 bits descripe rectangles) -0xc0 in line switches to graphics mode in this line -0x40 in line switches to char mode in this line - 22211100 - 22211100 - 22211100 - 22211100 - 55544433 - 55544433 - 55544433 - 55544433 - - 8. Memory Map - The offsets in the following memory Map are from the view of the UVI. - In the arcadia and compatibles the base offset is $1800 thats how the CPU sees the UVI - - 0000 - 00FF external RAM - 0000 - 00CF upper screen character/graphics codes organised as 16 char x 13 rows - 00D0 - 00EF RAM (not used by UVI, can be used by CPU) - 00F0 vertical offset object 0 - 00F1 horizontal offset object 0 - 00F2 vertical offset object 1 - 00F3 horizontal offset object 1 - 00F4 vertical offset object 2 - 00F5 horizontal offset object 2 - 00F6 vertical offset object 3 - 00F7 horizontal offset object 3 - 00F8 - 00FB RAM (not used by UVI, can be used by CPU) - 00FC complement number of rows from the trailing edge of VRST - to the start of character display - 00FD bit0 - 6 sound frequeny, bit 7 color mode - 00FE bit0 - 2 loudness, bit 3 sound enable when set, bit 4 random noise enable when set - bit 5 - 7 delay for row of characters - 00FF bit 0 - 3 DMA number, bit 4 - 7 unused -0100 - 017F CE area. In arcadia used for keypad. -0180 - 01FF internal UVI registers - 0180 - 0187 image of object 0 or UDC-code $38 - 0188 - 018F image of object 1 or UDC-code $39 - 0190 - 0197 image of object 2 or UDC-code $3A - 0198 - 019F image of object 3 or UDC-code $3B - 01A0 - 01A7 image of UDC-code $3C - 01A8 - 01AF image of UDC-code $3D - 01B0 - 01B7 image of UDC-code $3E - 01B8 - 01BF image of UDC-code $3F - 01C0 - 01F7 unused - 01F8 bit 0 - 2 alternate screen color, bit 3 - 5 alternate character color - bit 6 Refresh mode when set entire character field will be display twice - bit 7 Grahics mode - 01F9 bit 0 - 2 screen color, bit 3 - 5 character color - bit 6 poti mux control - bit 7 character size when set size=8x8 else size=8x16 - 01FA bit 0 - 2 color of object 3, bit 3 - 5 color of object 2 - bit 6 size of object 3 when set size=8x8 else size=8x16 - bit 7 size of object 2 when set size=8x8 else size=8x16 - 01FB bit 0 - 2 color of object 1, bit 3 - 5 color of object 0 - bit 6 size of object 1 when set size=8x8 else size=8x16 - bit 7 size of object 0 when set size=8x8 else size=8x16 - 01FC object - character collision bits - bit 0 when low object 0 collided with character - bit 1 when low object 1 collided with character - bit 2 when low object 2 collided with character - bit 3 when low object 3 collided with character - bit 4 - 7 unused set to high - 01FD inter object collision - bit 0 - when low object 1 and 2 collide - bit 1 - when low object 1 and 3 collide - bit 2 - when low object 1 and 4 collide - bit 3 - when low object 2 and 3 collide - bit 4 - when low object 2 and 4 collide - bit 5 - when low object 3 and 4 collide - bit 6 - 7 unused set to high - 01FE digital value of POT1 or POT3 input. Valid only during VRST - 01FF digital value of POT2 or POT4 input. Valid only furing VRST -0200 - 02FF 2nd external RAM - 0200 - 02CF lower screen character/graphics codes organised as 16 char x 13 rows - 02D0 - 02FF RAM (not used by UVI, can be used by CPU) -*/ - - -#include "includes/arcadia.h" - -static const UINT8 chars[0x40][8]={ - // read from the screen generated from a palladium - { 0,0,0,0,0,0,0,0 }, // 00 (space) - { 1,2,4,8,16,32,64,128 }, // 01 (\) - { 128,64,32,16,8,4,2,1 }, // 02 (/) - { 255,255,255,255,255,255,255,255 }, // 03 (solid block) - { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 },// 04 (?) - { 3,3,3,3,3,3,3,3 }, // 05 (half square right on) - { 0,0,0,0,0,0,255,255 }, // 06 (horz lower line) - { 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },// 07 (half square left on) - { 0xff,0xff,3,3,3,3,3,3 }, // 08 (?) - { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },// 09 (?) - { 192,192,192,192,192,192,255,255 }, // 0A (!_) - { 3,3,3,3,3,3,255,255 }, // 0B (_!) - { 1,3,7,15,31,63,127,255 }, // 0C (diagonal block) - { 128,192,224,240,248,252,254,255 }, // 0D (diagonal block) - { 255,254,252,248,240,224,192,128 }, // 0E (diagonal block) - { 255,127,63,31,15,7,3,1 }, // 0F (diagonal block) - { 0x00,0x1c,0x22,0x26,0x2a,0x32,0x22,0x1c },// 10 0 - { 0x00,0x08,0x18,0x08,0x08,0x08,0x08,0x1c },// 11 1 - { 0x00,0x1c,0x22,0x02,0x0c,0x10,0x20,0x3e },// 12 2 - { 0x00,0x3e,0x02,0x04,0x0c,0x02,0x22,0x1c },// 13 3 - { 0x00,0x04,0x0c,0x14,0x24,0x3e,0x04,0x04 },// 14 4 - { 0x00,0x3e,0x20,0x3c,0x02,0x02,0x22,0x1c },// 15 5 - { 0x00,0x0c,0x10,0x20,0x3c,0x22,0x22,0x1c },// 16 6 - { 0x00,0x7c,0x02,0x04,0x08,0x10,0x10,0x10 },// 17 7 - { 0x00,0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c },// 18 8 - { 0x00,0x1c,0x22,0x22,0x3e,0x02,0x04,0x18 },// 19 9 - { 0x00,0x08,0x14,0x22,0x22,0x3e,0x22,0x22 },// 1A A - { 0x00,0x3c,0x22,0x22,0x3c,0x22,0x22,0x3c },// 1B B - { 0x00,0x1c,0x22,0x20,0x20,0x20,0x22,0x1c },// 1C C - { 0x00,0x3c,0x22,0x22,0x22,0x22,0x22,0x3c },// 1D D - { 0x00,0x3e,0x20,0x20,0x3c,0x20,0x20,0x3e },// 1E E - { 0x00,0x3e,0x20,0x20,0x3c,0x20,0x20,0x20 },// 1F F - { 0x00,0x1e,0x20,0x20,0x20,0x26,0x22,0x1e },// 20 G - { 0x00,0x22,0x22,0x22,0x3e,0x22,0x22,0x22 },// 21 H - { 0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x1c },// 22 I - { 0x00,0x02,0x02,0x02,0x02,0x02,0x22,0x1c },// 23 J - { 0x00,0x22,0x24,0x28,0x30,0x28,0x24,0x22 },// 24 K - { 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x3e },// 25 L - { 0x00,0x22,0x36,0x2a,0x2a,0x22,0x22,0x22 },// 26 M - { 0x00,0x22,0x22,0x32,0x2a,0x26,0x22,0x22 },// 27 N - { 0x00,0x1c,0x22,0x22,0x22,0x22,0x22,0x1c },// 28 O - { 0x00,0x3c,0x22,0x22,0x3c,0x20,0x20,0x20 },// 29 P - { 0x00,0x1c,0x22,0x22,0x22,0x2a,0x24,0x1a },// 2A Q - { 0x00,0x3c,0x22,0x22,0x3c,0x28,0x24,0x22 },// 2B R - { 0x00,0x1c,0x22,0x20,0x1c,0x02,0x22,0x1c },// 2C S - { 0x00,0x3e,0x08,0x08,0x08,0x08,0x08,0x08 },// 2D T - { 0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x1c },// 2E U - { 0x00,0x22,0x22,0x22,0x22,0x22,0x14,0x08 },// 2F V - { 0x00,0x22,0x22,0x22,0x2a,0x2a,0x36,0x22 },// 30 W - { 0x00,0x22,0x22,0x14,0x08,0x14,0x22,0x22 },// 31 X - { 0x00,0x22,0x22,0x14,0x08,0x08,0x08,0x08 },// 32 Y - { 0x00,0x3e,0x02,0x04,0x08,0x10,0x20,0x3e },// 33 Z - { 0,0,0,0,0,0,0,8 }, // 34 . - { 0,0,0,0,0,8,8,0x10 }, // 35 , - { 0,0,8,8,0x3e,8,8,0 }, // 36 + - { 0,8,0x1e,0x28,0x1c,0xa,0x3c,8 }, // 37 $ - // 8x user defined -}; - -void arcadia_state::video_start() -{ - int i; - memcpy(&m_chars, chars, sizeof(chars)); - for (i=0; i<0x40; i++) - { - m_rectangle[i][0]=0; - m_rectangle[i][4]=0; - if (i&1) m_rectangle[i][0]|=3; - if (i&2) m_rectangle[i][0]|=0x1c; - if (i&4) m_rectangle[i][0]|=0xe0; - if (i&8) m_rectangle[i][4]|=3; - if (i&0x10) m_rectangle[i][4]|=0x1c; - if (i&0x20) m_rectangle[i][4]|=0xe0; - m_rectangle[i][1]=m_rectangle[i][2]=m_rectangle[i][3]=m_rectangle[i][0]; - m_rectangle[i][5]=m_rectangle[i][6]=m_rectangle[i][7]=m_rectangle[i][4]; - } - - { - int width = m_screen->width(); - int height = m_screen->height(); - m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); - } -} - -READ8_MEMBER( arcadia_state::video_r ) -{ - UINT8 data=0; - switch (offset) - { - case 0xff: data = m_charline|0xf0;break; - case 0x100: data = m_controller1_col1->read();break; - case 0x101: data = m_controller1_col2->read();break; - case 0x102: data = m_controller1_col3->read();break; - case 0x103: data = m_controller1_extra->read();break; - case 0x104: data = m_controller2_col1->read();break; - case 0x105: data = m_controller2_col2->read();break; - case 0x106: data = m_controller2_col3->read();break; - case 0x107: data = m_controller2_extra->read();break; - case 0x108: data = m_panel->read();break; -#if 0 - case 0x1fe: - if (m_ad_select) - data=ioport("controller1_joy_y")->read()<<3; - else - data=ioport("controller1_joy_x")->read()<<3; - break; - case 0x1ff: - if (m_ad_select) - data=ioport("controller2_joy_y")->read()<<3; - else - data=ioport("controller2_joy_x")->read()<<3; - break; -#else - case 0x1fe: - data = 0x80; - if (m_ad_select) - { - if (m_joysticks->read()&0x10) data=0; - if (m_joysticks->read()&0x20) data=0xff; - } - else - { - if (m_joysticks->read()&0x40) data=0xff; - if (m_joysticks->read()&0x80) data=0; - } - break; - case 0x1ff: - data = 0x6f; // 0x7f too big for alien invaders (move right) - if (m_ad_select) - { - if (m_joysticks->read()&0x1) data=0; - if (m_joysticks->read()&0x2) data=0xff; - } - else - { - if (m_joysticks->read()&0x4) data=0xff; - if (m_joysticks->read()&0x8) data=0; - } - break; -#endif - default: - data = m_reg.data[offset]; - } - return data; -} - -WRITE8_MEMBER( arcadia_state::video_w ) -{ - m_reg.data[offset]=data; - switch (offset) - { - case 0xfc: - m_ypos=255-data+YPOS; - break; - case 0xfd: - m_custom->write(space, offset&3, data); - m_multicolor = data & 0x80; - break; - case 0xfe: - m_custom->write(space, offset&3, data); - m_shift = (data>>5); - break; - case 0xf0: - case 0xf2: - case 0xf4: - case 0xf6: - m_pos[(offset>>1)&3].y = (data^0xff)+1; - break; - case 0xf1: - case 0xf3: - case 0xf5: - case 0xf7: - m_pos[(offset>>1)&3].x = data-43; - break; - case 0x180: case 0x181: case 0x182: case 0x183: case 0x184: case 0x185: case 0x186: case 0x187: - case 0x188: case 0x189: case 0x18a: case 0x18b: case 0x18c: case 0x18d: case 0x18e: case 0x18f: - case 0x190: case 0x191: case 0x192: case 0x193: case 0x194: case 0x195: case 0x196: case 0x197: - case 0x198: case 0x199: case 0x19a: case 0x19b: case 0x19c: case 0x19d: case 0x19e: case 0x19f: - case 0x1a0: case 0x1a1: case 0x1a2: case 0x1a3: case 0x1a4: case 0x1a5: case 0x1a6: case 0x1a7: - case 0x1a8: case 0x1a9: case 0x1aa: case 0x1ab: case 0x1ac: case 0x1ad: case 0x1ae: case 0x1af: - case 0x1b0: case 0x1b1: case 0x1b2: case 0x1b3: case 0x1b4: case 0x1b5: case 0x1b6: case 0x1b7: - case 0x1b8: case 0x1b9: case 0x1ba: case 0x1bb: case 0x1bc: case 0x1bd: case 0x1be: case 0x1bf: - m_chars[0x38|((offset>>3)&7)][offset&7] = data; - break; - case 0x1f8: - m_lines26 = data & 0x40; - m_graphics = data & 0x80; - break; - case 0x1f9: - m_doublescan =! (data&0x80); - m_ad_delay = 10; - break; - } -} - -void arcadia_state::draw_char(UINT8 *ch, int charcode, int y, int x) -{ - int k,b,cc,sc, colour; - if (m_multicolor) - { - if (charcode&0x40) - cc=((m_reg.d.pal[1]>>3)&7); - else - cc=((m_reg.d.pal[0]>>3)&7); - - if (charcode&0x80) - sc=(m_reg.d.pal[1]&7); - else - sc=(m_reg.d.pal[0]&7); - } - else - { - cc=((m_reg.d.pal[1]>>3)&1)|((charcode>>5)&6); - sc=(m_reg.d.pal[1]&7); - } - colour = (((sc << 3) | cc) + 4); - - if (m_doublescan) - { - for (k=0; (k<8)&&(yheight()); k++, y+=2) - { - b=ch[k]; - m_bg[y][x>>3]|=b>>(x&7); - m_bg[y][(x>>3)+1]|=b<<(8-(x&7)); - - if (y+1height()) - { - m_bg[y+1][x>>3]|=b>>(x&7); - m_bg[y+1][(x>>3)+1]|=b<<(8-(x&7)); - m_gfxdecode->gfx(0)->opaque(*m_bitmap,m_bitmap->cliprect(), b,colour, 0,0,x,y); - m_gfxdecode->gfx(0)->opaque(*m_bitmap,m_bitmap->cliprect(), b,colour, 0,0,x,y+1); - } - } - } - else - { - for (k=0; (k<8)&&(yheight()); k++, y++) - { - b=ch[k]; - m_bg[y][x>>3]|=b>>(x&7); - m_bg[y][(x>>3)+1]|=b<<(8-(x&7)); - - m_gfxdecode->gfx(0)->opaque(*m_bitmap,m_bitmap->cliprect(), b,colour, 0,0,x,y); - } - } -} - - -void arcadia_state::vh_draw_line(int y, UINT8 chars1[16]) -{ - int x, ch, j, h; - int graphics = m_graphics; - h = m_doublescan ? 16 : 8 ; - - if (m_bitmap->height() - m_line < h) - h = m_bitmap->height() - m_line; - - m_bitmap->plot_box(0, y, m_bitmap->width(), h, (m_reg.d.pal[1]&7)); - memset(m_bg[y], 0, sizeof(m_bg[0])*h); - - for (x=XPOS+m_shift, j=0; j<16;j++,x+=8) - { - ch=chars1[j]; -// hangman switches with 0x40 -// alien invaders shield lines start with 0xc0 - if ((ch&0x3f)==0) - { - switch (ch) - { - case 0xc0: graphics=TRUE;break; - case 0x40: graphics=FALSE;break; -// case 0x80: -// alien invaders shields are empty 0x80 -// popmessage(5, "graphics code 0x80 used"); - } - } - if (graphics) - draw_char(m_rectangle[ch&0x3f], ch, y, x); - else - draw_char(m_chars[ch&0x3f], ch, y, x); - } -} - - -int arcadia_state::sprite_collision(int n1, int n2) -{ - int k, b1, b2, x; - if (m_pos[n1].x+8<=m_pos[n2].x) - return FALSE; - if (m_pos[n1].x>=m_pos[n2].x+8) - return FALSE; - - for (k=0; k<8; k++) - { - if (m_pos[n1].y+k=m_pos[n2].y+8) - break; - x=m_pos[n1].x-m_pos[n2].x; - b1=m_reg.d.chars[n1][k]; - b2=m_reg.d.chars[n2][m_pos[n1].y+k-m_pos[n2].y]; - if (x<0) - b2>>=-x; - if (x>0) - b1>>=x; - if (b1&b2) - return TRUE; - } - return FALSE; -} - - -void arcadia_state::draw_sprites() -{ - int i, k, x, y, color=0; - UINT8 b; - - m_reg.d.collision_bg|=0xf; - m_reg.d.collision_sprite|=0x3f; - for (i=0; i<4; i++) - { - int doublescan = FALSE; - if (m_pos[i].y<=-YPOS) continue; - if (m_pos[i].y>=m_bitmap->height()-YPOS-8) continue; - if (m_pos[i].x<=-XPOS) continue; - if (m_pos[i].x>=128+XPOS-8) continue; - - switch (i) - { - case 0: - color=(m_reg.d.pal[3]>>3)&7; - doublescan=m_reg.d.pal[3]&0x80?FALSE:TRUE; - break; - case 1: - color=m_reg.d.pal[3]&7; - doublescan=m_reg.d.pal[3]&0x40?FALSE:TRUE; - break; - case 2: - color=(m_reg.d.pal[2]>>3)&7; - doublescan=m_reg.d.pal[2]&0x80?FALSE:TRUE; - break; - case 3: - color=m_reg.d.pal[2]&7; - doublescan=m_reg.d.pal[2]&0x40?FALSE:TRUE; - break; - } - for (k=0; k<8; k++) - { - int j, m; - b=m_reg.d.chars[i][k]; - x=m_pos[i].x+XPOS; - if (!doublescan) - { - y=m_pos[i].y+YPOS+k; - for (j=0,m=0x80; j<8; j++, m>>=1) - { - if (b & m) - m_bitmap->pix16(y, x + j) = color; - } - } - else - { - y=m_pos[i].y+YPOS+k*2; - for (j=0,m=0x80; j<8; j++, m>>=1) - { - if (b & m) - { - m_bitmap->pix16(y, x + j) = color; - m_bitmap->pix16(y+1, x + j) = color; - } - } - } - if (m_reg.d.collision_bg&(1<>3]<<8) | m_bg[y][(x>>3)+1]) ) - m_reg.d.collision_bg&=~(1<width(); - - if (m_ad_delay<=0) - m_ad_select=m_reg.d.pal[1]&0x40; - else m_ad_delay--; - - m_line++; - m_line%=262; - // unbelievable, reflects only charline, but alien invaders uses it for - // alien scrolling - - if (m_lineplot_box(0, m_line, width, 1, (m_reg.d.pal[1])&7); - memset(m_bg[m_line], 0, sizeof(m_bg[0])); - } - else - { - int h=m_doublescan?16:8; - - m_charline=(m_line-m_ypos)/h; - - if (m_charline<13) - { - if (((m_line-m_ypos)&(h-1))==0) - { - vh_draw_line(m_charline*h+m_ypos, m_reg.d.chars1[m_charline]); - } - } - else - if (m_lines26 && (m_charline<26)) - { - if (((m_line-m_ypos)&(h-1))==0) - { - vh_draw_line(m_charline*h+m_ypos, m_reg.d.chars2[m_charline-13]); - } - m_charline-=13; - } - else - { - m_charline=0xd; - m_bitmap->plot_box(0, m_line, width, 1, (m_reg.d.pal[1])&7); - memset(m_bg[m_line], 0, sizeof(m_bg[0])); - } - } - if (m_line==261) - draw_sprites(); -} - -READ8_MEMBER( arcadia_state::vsync_r ) -{ - return m_line>=216 ? 0x80 : 0 ; -} - -UINT32 arcadia_state::screen_update_arcadia(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/atarist.c b/src/mess/video/atarist.c deleted file mode 100644 index 2c80d6beb9a..00000000000 --- a/src/mess/video/atarist.c +++ /dev/null @@ -1,1131 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder, Olivier Galibert -/* - - TODO: - - - rewrite shifter - - STe pixelofs - - blitter hog - - high resolution - -*/ - -#include "emu.h" -#include "cpu/m68000/m68000.h" -#include "machine/ram.h" -#include "video/atarist.h" -#include "includes/atarist.h" - - - -//************************************************************************** -// CONSTANTS / MACROS -//************************************************************************** - -#define LOG 0 - -static const int BLITTER_NOPS[16][4] = -{ - { 1, 1, 1, 1 }, - { 2, 2, 3, 3 }, - { 2, 2, 3, 3 }, - { 1, 1, 2, 2 }, - { 2, 2, 3, 3 }, - { 2, 2, 2, 2 }, - { 2, 2, 3, 3 }, - { 2, 2, 3, 3 }, - { 2, 2, 3, 3 }, - { 2, 2, 3, 3 }, - { 2, 2, 2, 2 }, - { 2, 2, 3, 3 }, - { 1, 1, 2, 2 }, - { 2, 2, 3, 3 }, - { 2, 2, 3, 3 }, - { 1, 1, 1, 1 } -}; - - -//************************************************************************** -// SHIFTER -//************************************************************************** - -//------------------------------------------------- -// shift_mode_0 - -//------------------------------------------------- - -inline pen_t st_state::shift_mode_0() -{ - int color = (BIT(m_shifter_rr[3], 15) << 3) | (BIT(m_shifter_rr[2], 15) << 2) | (BIT(m_shifter_rr[1], 15) << 1) | BIT(m_shifter_rr[0], 15); - - m_shifter_rr[0] <<= 1; - m_shifter_rr[1] <<= 1; - m_shifter_rr[2] <<= 1; - m_shifter_rr[3] <<= 1; - - return m_palette->pen(color); -} - - -//------------------------------------------------- -// shift_mode_1 - -//------------------------------------------------- - -inline pen_t st_state::shift_mode_1() -{ - int color = (BIT(m_shifter_rr[1], 15) << 1) | BIT(m_shifter_rr[0], 15); - - m_shifter_rr[0] <<= 1; - m_shifter_rr[1] <<= 1; - m_shifter_shift++; - - if (m_shifter_shift == 16) - { - m_shifter_rr[0] = m_shifter_rr[2]; - m_shifter_rr[1] = m_shifter_rr[3]; - m_shifter_rr[2] = m_shifter_rr[3] = 0; - m_shifter_shift = 0; - } - - return m_palette->pen(color); -} - - -//------------------------------------------------- -// shift_mode_2 - -//------------------------------------------------- - -inline pen_t st_state::shift_mode_2() -{ - int color = BIT(m_shifter_rr[0], 15); - - m_shifter_rr[0] <<= 1; - m_shifter_shift++; - - switch (m_shifter_shift) - { - case 16: - m_shifter_rr[0] = m_shifter_rr[1]; - m_shifter_rr[1] = m_shifter_rr[2]; - m_shifter_rr[2] = m_shifter_rr[3]; - m_shifter_rr[3] = 0; - break; - - case 32: - m_shifter_rr[0] = m_shifter_rr[1]; - m_shifter_rr[1] = m_shifter_rr[2]; - m_shifter_rr[2] = 0; - break; - - case 48: - m_shifter_rr[0] = m_shifter_rr[1]; - m_shifter_rr[1] = 0; - m_shifter_shift = 0; - break; - } - - return m_palette->pen(color); -} - - -//------------------------------------------------- -// shifter_tick - -//------------------------------------------------- - -void st_state::shifter_tick() -{ - int y = machine().first_screen()->vpos(); - int x = machine().first_screen()->hpos(); - - pen_t pen; - - switch (m_shifter_mode) - { - case 0: - pen = shift_mode_0(); - break; - - case 1: - pen = shift_mode_1(); - break; - - case 2: - pen = shift_mode_2(); - break; - - default: - pen = m_palette->black_pen(); - break; - } - - m_bitmap.pix32(y, x) = pen; -} - - -//------------------------------------------------- -// shifter_load - -//------------------------------------------------- - -inline void st_state::shifter_load() -{ - address_space &program = m_maincpu->space(AS_PROGRAM); - UINT16 data = program.read_word(m_shifter_ofs); - - m_shifter_ir[m_shifter_bitplane] = data; - m_shifter_bitplane++; - m_shifter_ofs += 2; - - if (m_shifter_bitplane == 4) - { - m_shifter_bitplane = 0; - - m_shifter_rr[0] = m_shifter_ir[0]; - m_shifter_rr[1] = m_shifter_ir[1]; - m_shifter_rr[2] = m_shifter_ir[2]; - m_shifter_rr[3] = m_shifter_ir[3]; - } -} - - -//------------------------------------------------- -// glue_tick - -//------------------------------------------------- - -void st_state::glue_tick() -{ - int y = machine().first_screen()->vpos(); - int x = machine().first_screen()->hpos(); - - int v = (y >= m_shifter_y_start) && (y < m_shifter_y_end); - int h = (x >= m_shifter_x_start) && (x < m_shifter_x_end); - - if(m_shifter_mode == 1) { - int dt = 8; - h = (x >= m_shifter_x_start-dt) && (x < m_shifter_x_end-dt); - } - int de = h && v; - - if(!x) { - m_shifter_bitplane = 0; - m_shifter_shift = 0; - } - - if (de != m_shifter_de) - { - m_mfp->tbi_w(de); - m_shifter_de = de; - } - - if (de) - { - shifter_load(); - } - - if ((y == m_shifter_vblank_start) && (x == 0)) - { - m_maincpu->set_input_line(M68K_IRQ_4, HOLD_LINE); - m_shifter_ofs = m_shifter_base; - } - - if (x == m_shifter_hblank_start) - { - m_maincpu->set_input_line(M68K_IRQ_2, HOLD_LINE); -// m_shifter_ofs += (m_shifter_lineofs * 2); // STe - } - - pen_t pen; - - switch (m_shifter_mode) - { - case 0: - pen = shift_mode_0(); - m_bitmap.pix32(y, x) = pen; - m_bitmap.pix32(y, x+1) = pen; - pen = shift_mode_0(); - m_bitmap.pix32(y, x+2) = pen; - m_bitmap.pix32(y, x+3) = pen; - pen = shift_mode_0(); - m_bitmap.pix32(y, x+4) = pen; - m_bitmap.pix32(y, x+5) = pen; - pen = shift_mode_0(); - m_bitmap.pix32(y, x+6) = pen; - m_bitmap.pix32(y, x+7) = pen; - break; - - case 1: - pen = shift_mode_1(); - m_bitmap.pix32(y, x) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+1) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+2) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+3) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+4) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+5) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+6) = pen; - pen = shift_mode_1(); - m_bitmap.pix32(y, x+7) = pen; - break; - - case 2: - pen = shift_mode_2(); - break; - - default: - pen = m_palette->black_pen(); - break; - } -} - - -//------------------------------------------------- -// set_screen_parameters - -//------------------------------------------------- - -void st_state::set_screen_parameters() -{ - if (m_shifter_sync & 0x02) - { - m_shifter_x_start = ATARIST_HBDEND_PAL*2; - m_shifter_x_end = ATARIST_HBDSTART_PAL*2; - m_shifter_y_start = ATARIST_VBDEND_PAL; - m_shifter_y_end = ATARIST_VBDSTART_PAL; - m_shifter_hblank_start = ATARIST_HBSTART_PAL*2; - m_shifter_vblank_start = ATARIST_VBSTART_PAL; - } - else - { - m_shifter_x_start = ATARIST_HBDEND_NTSC*2; - m_shifter_x_end = ATARIST_HBDSTART_NTSC*2; - m_shifter_y_start = ATARIST_VBDEND_NTSC; - m_shifter_y_end = ATARIST_VBDSTART_NTSC; - m_shifter_hblank_start = ATARIST_HBSTART_NTSC*2; - m_shifter_vblank_start = ATARIST_VBSTART_NTSC; - } -} - - -//------------------------------------------------- -// shifter_base_r - -//------------------------------------------------- - -READ8_MEMBER( st_state::shifter_base_r ) -{ - UINT8 data = 0; - - switch (offset) - { - case 0x00: - data = (m_shifter_base >> 16) & 0x3f; - break; - - case 0x01: - data = (m_shifter_base >> 8) & 0xff; - break; - } - - return data; -} - - -//------------------------------------------------- -// shifter_base_w - -//------------------------------------------------- - -WRITE8_MEMBER( st_state::shifter_base_w ) -{ - switch (offset) - { - case 0x00: - m_shifter_base = (m_shifter_base & 0x00ff00) | (data & 0x3f) << 16; - logerror("SHIFTER Video Base Address %06x\n", m_shifter_base); - break; - - case 0x01: - m_shifter_base = (m_shifter_base & 0x3f0000) | (data << 8); - logerror("SHIFTER Video Base Address %06x\n", m_shifter_base); - break; - } -} - - -//------------------------------------------------- -// shifter_counter_r - -//------------------------------------------------- - -READ8_MEMBER( st_state::shifter_counter_r ) -{ - UINT8 data = 0; - - switch (offset) - { - case 0x00: - data = (m_shifter_ofs >> 16) & 0x3f; - break; - - case 0x01: - data = (m_shifter_ofs >> 8) & 0xff; - break; - - case 0x02: - data = m_shifter_ofs & 0xff; - break; - } - - return data; -} - - -//------------------------------------------------- -// shifter_sync_r - -//------------------------------------------------- - -READ8_MEMBER( st_state::shifter_sync_r ) -{ - return m_shifter_sync; -} - - -//------------------------------------------------- -// shifter_sync_w - -//------------------------------------------------- - -WRITE8_MEMBER( st_state::shifter_sync_w ) -{ - m_shifter_sync = data; - logerror("SHIFTER Sync %x\n", m_shifter_sync); - set_screen_parameters(); -} - - -//------------------------------------------------- -// shifter_mode_r - -//------------------------------------------------- - -READ8_MEMBER( st_state::shifter_mode_r ) -{ - return m_shifter_mode; -} - - -//------------------------------------------------- -// shifter_mode_w - -//------------------------------------------------- - -WRITE8_MEMBER( st_state::shifter_mode_w ) -{ - m_shifter_mode = data; - logerror("SHIFTER Mode %x\n", m_shifter_mode); -} - - -//------------------------------------------------- -// shifter_palette_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::shifter_palette_r ) -{ - return m_shifter_palette[offset] | 0xf888; -} - - -//------------------------------------------------- -// shifter_palette_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::shifter_palette_w ) -{ - m_shifter_palette[offset] = data; - // logerror("SHIFTER Palette[%x] = %x\n", offset, data); - - m_palette->set_pen_color(offset, pal3bit(data >> 8), pal3bit(data >> 4), pal3bit(data)); -} - - - -//************************************************************************** -// STE SHIFTER -//************************************************************************** - -//------------------------------------------------- -// shifter_base_low_r - -//------------------------------------------------- - -READ8_MEMBER( ste_state::shifter_base_low_r ) -{ - return m_shifter_base & 0xfe; -} - - -//------------------------------------------------- -// shifter_base_low_w - -//------------------------------------------------- - -WRITE8_MEMBER( ste_state::shifter_base_low_w ) -{ - m_shifter_base = (m_shifter_base & 0x3fff00) | (data & 0xfe); - logerror("SHIFTER Video Base Address %06x\n", m_shifter_base); -} - - -//------------------------------------------------- -// shifter_counter_r - -//------------------------------------------------- - -READ8_MEMBER( ste_state::shifter_counter_r ) -{ - UINT8 data = 0; - - switch (offset) - { - case 0x00: - data = (m_shifter_ofs >> 16) & 0x3f; - break; - - case 0x01: - data = (m_shifter_ofs >> 8) & 0xff; - break; - - case 0x02: - data = m_shifter_ofs & 0xfe; - break; - } - - return data; -} - - -//------------------------------------------------- -// shifter_counter_w - -//------------------------------------------------- - -WRITE8_MEMBER( ste_state::shifter_counter_w ) -{ - switch (offset) - { - case 0x00: - m_shifter_ofs = (m_shifter_ofs & 0x00fffe) | (data & 0x3f) << 16; - logerror("SHIFTER Video Address Counter %06x\n", m_shifter_ofs); - break; - - case 0x01: - m_shifter_ofs = (m_shifter_ofs & 0x3f00fe) | (data << 8); - logerror("SHIFTER Video Address Counter %06x\n", m_shifter_ofs); - break; - - case 0x02: - m_shifter_ofs = (m_shifter_ofs & 0x3fff00) | (data & 0xfe); - logerror("SHIFTER Video Address Counter %06x\n", m_shifter_ofs); - break; - } -} - - -//------------------------------------------------- -// shifter_palette_w - -//------------------------------------------------- - -WRITE16_MEMBER( ste_state::shifter_palette_w ) -{ - int r = ((data >> 7) & 0x0e) | BIT(data, 11); - int g = ((data >> 3) & 0x0e) | BIT(data, 7); - int b = ((data << 1) & 0x0e) | BIT(data, 3); - - m_shifter_palette[offset] = data; - logerror("SHIFTER palette %x = %x\n", offset, data); - - m_palette->set_pen_color(offset, r, g, b); -} - - -//------------------------------------------------- -// shifter_lineofs_r - -//------------------------------------------------- - -READ8_MEMBER( ste_state::shifter_lineofs_r ) -{ - return m_shifter_lineofs; -} - - -//------------------------------------------------- -// shifter_lineofs_w - -//------------------------------------------------- - -WRITE8_MEMBER( ste_state::shifter_lineofs_w ) -{ - m_shifter_lineofs = data; - logerror("SHIFTER Line Offset %x\n", m_shifter_lineofs); -} - - -//------------------------------------------------- -// shifter_pixelofs_r - -//------------------------------------------------- - -READ8_MEMBER( ste_state::shifter_pixelofs_r ) -{ - return m_shifter_pixelofs; -} - - -//------------------------------------------------- -// shifter_pixelofs_w - -//------------------------------------------------- - -WRITE8_MEMBER( ste_state::shifter_pixelofs_w ) -{ - m_shifter_pixelofs = data & 0x0f; - logerror("SHIFTER Pixel Offset %x\n", m_shifter_pixelofs); -} - - - -//************************************************************************** -// BLITTER -//************************************************************************** - -//------------------------------------------------- -// blitter_source - -//------------------------------------------------- - -void st_state::blitter_source() -{ - address_space &program = m_maincpu->space(AS_PROGRAM); - UINT16 data = program.read_word(m_blitter_src); - - if (m_blitter_src_inc_x < 0) - { - m_blitter_srcbuf = (data << 16) | (m_blitter_srcbuf >> 16); - } - else - { - m_blitter_srcbuf = (m_blitter_srcbuf << 16) | data; - } -} - - -//------------------------------------------------- -// blitter_hop - -//------------------------------------------------- - -UINT16 st_state::blitter_hop() -{ - UINT16 source = m_blitter_srcbuf >> (m_blitter_skew & 0x0f); - UINT16 halftone = m_blitter_halftone[m_blitter_ctrl & 0x0f]; - - if (m_blitter_ctrl & ATARIST_BLITTER_CTRL_SMUDGE) - { - halftone = m_blitter_halftone[source & 0x0f]; - } - - switch (m_blitter_hop) - { - case 0: - return 0xffff; - case 1: - return halftone; - case 2: - return source; - case 3: - return source & halftone; - } - - return 0; -} - - -//------------------------------------------------- -// blitter_op - -//------------------------------------------------- - -void st_state::blitter_op(UINT16 s, UINT32 dstaddr, UINT16 mask) -{ - address_space &program = m_maincpu->space(AS_PROGRAM); - - UINT16 d = program.read_word(dstaddr); - UINT16 result = 0; - - if (m_blitter_op & 0x08) result = (~s & ~d); - if (m_blitter_op & 0x04) result |= (~s & d); - if (m_blitter_op & 0x02) result |= (s & ~d); - if (m_blitter_op & 0x01) result |= (s & d); - - program.write_word(dstaddr, result); -} - - -//------------------------------------------------- -// blitter_tick - -//------------------------------------------------- - -void st_state::blitter_tick() -{ - do - { - if (m_blitter_skew & ATARIST_BLITTER_SKEW_FXSR) - { - blitter_source(); - m_blitter_src += m_blitter_src_inc_x; - } - - blitter_source(); - blitter_op(blitter_hop(), m_blitter_dst, m_blitter_endmask1); - m_blitter_xcount--; - - while (m_blitter_xcount > 0) - { - m_blitter_src += m_blitter_src_inc_x; - m_blitter_dst += m_blitter_dst_inc_x; - - if (m_blitter_xcount == 1) - { - if (!(m_blitter_skew & ATARIST_BLITTER_SKEW_NFSR)) - { - blitter_source(); - } - - blitter_op(blitter_hop(), m_blitter_dst, m_blitter_endmask3); - } - else - { - blitter_source(); - blitter_op(blitter_hop(), m_blitter_dst, m_blitter_endmask2); - } - - m_blitter_xcount--; - } - - m_blitter_src += m_blitter_src_inc_y; - m_blitter_dst += m_blitter_dst_inc_y; - - if (m_blitter_dst_inc_y < 0) - { - m_blitter_ctrl = (m_blitter_ctrl & 0xf0) | (((m_blitter_ctrl & 0x0f) - 1) & 0x0f); - } - else - { - m_blitter_ctrl = (m_blitter_ctrl & 0xf0) | (((m_blitter_ctrl & 0x0f) + 1) & 0x0f); - } - - m_blitter_xcount = m_blitter_xcountl; - m_blitter_ycount--; - } - while (m_blitter_ycount > 0); - - m_blitter_ctrl &= 0x7f; - - m_mfp->i3_w(0); -} - - -//------------------------------------------------- -// blitter_halftone_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_halftone_r ) -{ - return m_blitter_halftone[offset]; -} - - -//------------------------------------------------- -// blitter_src_inc_x_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_src_inc_x_r ) -{ - return m_blitter_src_inc_x; -} - - -//------------------------------------------------- -// blitter_src_inc_y_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_src_inc_y_r ) -{ - return m_blitter_src_inc_y; -} - - -//------------------------------------------------- -// blitter_src_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_src_r ) -{ - switch (offset) - { - case 0: - return (m_blitter_src >> 16) & 0xff; - case 1: - return m_blitter_src & 0xfffe; - } - - return 0; -} - - -//------------------------------------------------- -// blitter_end_mask_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_end_mask_r ) -{ - switch (offset) - { - case 0: - return m_blitter_endmask1; - case 1: - return m_blitter_endmask2; - case 2: - return m_blitter_endmask3; - } - - return 0; -} - - -//------------------------------------------------- -// blitter_dst_inc_x_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_dst_inc_x_r ) -{ - return m_blitter_dst_inc_x; -} - - -//------------------------------------------------- -// blitter_dst_inc_y_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_dst_inc_y_r ) -{ - return m_blitter_dst_inc_y; -} - - -//------------------------------------------------- -// blitter_dst_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_dst_r ) -{ - switch (offset) - { - case 0: - return (m_blitter_dst >> 16) & 0xff; - case 1: - return m_blitter_dst & 0xfffe; - } - - return 0; -} - - -//------------------------------------------------- -// blitter_count_x_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_count_x_r ) -{ - return m_blitter_xcount; -} - - -//------------------------------------------------- -// blitter_count_y_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_count_y_r ) -{ - return m_blitter_ycount; -} - - -//------------------------------------------------- -// blitter_op_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_op_r ) -{ - if (ACCESSING_BITS_0_7) - { - return m_blitter_hop; - } - else - { - return m_blitter_op; - } -} - - -//------------------------------------------------- -// blitter_ctrl_r - -//------------------------------------------------- - -READ16_MEMBER( st_state::blitter_ctrl_r ) -{ - if (ACCESSING_BITS_0_7) - { - return m_blitter_ctrl; - } - else - { - return m_blitter_skew; - } -} - - -//------------------------------------------------- -// blitter_halftone_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_halftone_w ) -{ - m_blitter_halftone[offset] = data; -} - - -//------------------------------------------------- -// blitter_src_inc_x_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_src_inc_x_w ) -{ - m_blitter_src_inc_x = data & 0xfffe; -} - - -//------------------------------------------------- -// blitter_src_inc_y_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_src_inc_y_w ) -{ - m_blitter_src_inc_y = data & 0xfffe; -} - - -//------------------------------------------------- -// blitter_src_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_src_w ) -{ - switch (offset) - { - case 0: - m_blitter_src = (data & 0xff) | (m_blitter_src & 0xfffe); - break; - - case 1: - m_blitter_src = (m_blitter_src & 0xff0000) | (data & 0xfffe); - break; - } -} - - -//------------------------------------------------- -// blitter_end_mask_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_end_mask_w ) -{ - switch (offset) - { - case 0: - m_blitter_endmask1 = data; - break; - - case 1: - m_blitter_endmask2 = data; - break; - - case 2: - m_blitter_endmask3 = data; - break; - } -} - - -//------------------------------------------------- -// blitter_dst_inc_x_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_dst_inc_x_w ) -{ - m_blitter_dst_inc_x = data & 0xfffe; -} - - -//------------------------------------------------- -// blitter_dst_inc_y_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_dst_inc_y_w ) -{ - m_blitter_dst_inc_y = data & 0xfffe; -} - - -//------------------------------------------------- -// blitter_dst_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_dst_w ) -{ - switch (offset) - { - case 0: - m_blitter_dst = (data & 0xff) | (m_blitter_dst & 0xfffe); - break; - - case 1: - m_blitter_dst = (m_blitter_dst & 0xff0000) | (data & 0xfffe); - break; - } -} - - -//------------------------------------------------- -// blitter_count_x_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_count_x_w ) -{ - m_blitter_xcount = data; -} - - -//------------------------------------------------- -// blitter_count_y_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_count_y_w ) -{ - m_blitter_ycount = data; -} - - -//------------------------------------------------- -// blitter_op_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_op_w ) -{ - if (ACCESSING_BITS_0_7) - { - m_blitter_hop = (data >> 8) & 0x03; - } - else - { - m_blitter_op = data & 0x0f; - } -} - - -//------------------------------------------------- -// blitter_ctrl_w - -//------------------------------------------------- - -WRITE16_MEMBER( st_state::blitter_ctrl_w ) -{ - if (ACCESSING_BITS_0_7) - { - m_blitter_ctrl = (data >> 8) & 0xef; - - if (!(m_blitter_ctrl & ATARIST_BLITTER_CTRL_BUSY)) - { - if ((data >> 8) & ATARIST_BLITTER_CTRL_BUSY) - { - m_mfp->i3_w(1); - - int nops = BLITTER_NOPS[m_blitter_op][m_blitter_hop]; // each NOP takes 4 cycles - timer_set(attotime::from_hz((Y2/4)/(4*nops)), TIMER_BLITTER_TICK); - } - } - } - else - { - m_blitter_skew = data & 0xcf; - } -} - - - -//************************************************************************** -// VIDEO -//************************************************************************** - -void st_state::video_start() -{ - m_shifter_timer = timer_alloc(TIMER_SHIFTER_TICK); - m_glue_timer = timer_alloc(TIMER_GLUE_TICK); - -// m_shifter_timer->adjust(machine().first_screen()->time_until_pos(0), 0, attotime::from_hz(Y2/4)); // 125 ns - m_glue_timer->adjust(machine().first_screen()->time_until_pos(0), 0, attotime::from_hz(Y2/16)); // 500 ns - - machine().first_screen()->register_screen_bitmap(m_bitmap); - - /* register for state saving */ - save_item(NAME(m_shifter_base)); - save_item(NAME(m_shifter_ofs)); - save_item(NAME(m_shifter_sync)); - save_item(NAME(m_shifter_mode)); - save_item(NAME(m_shifter_palette)); - save_item(NAME(m_shifter_rr)); - save_item(NAME(m_shifter_ir)); - save_item(NAME(m_shifter_bitplane)); - save_item(NAME(m_shifter_shift)); - save_item(NAME(m_shifter_h)); - save_item(NAME(m_shifter_v)); - save_item(NAME(m_shifter_de)); - - save_item(NAME(m_blitter_halftone)); - save_item(NAME(m_blitter_src_inc_x)); - save_item(NAME(m_blitter_src_inc_y)); - save_item(NAME(m_blitter_dst_inc_x)); - save_item(NAME(m_blitter_dst_inc_y)); - save_item(NAME(m_blitter_src)); - save_item(NAME(m_blitter_dst)); - save_item(NAME(m_blitter_endmask1)); - save_item(NAME(m_blitter_endmask2)); - save_item(NAME(m_blitter_endmask3)); - save_item(NAME(m_blitter_xcount)); - save_item(NAME(m_blitter_ycount)); - save_item(NAME(m_blitter_xcountl)); - save_item(NAME(m_blitter_hop)); - save_item(NAME(m_blitter_op)); - save_item(NAME(m_blitter_ctrl)); - save_item(NAME(m_blitter_skew)); - - set_screen_parameters(); -} - - -void ste_state::video_start() -{ - st_state::video_start(); - - // register for state saving - save_item(NAME(m_shifter_lineofs)); - save_item(NAME(m_shifter_pixelofs)); -} - -void stbook_state::video_start() -{ -} - - -UINT32 st_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/atarist.h b/src/mess/video/atarist.h deleted file mode 100644 index da66ff3a17e..00000000000 --- a/src/mess/video/atarist.h +++ /dev/null @@ -1,41 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder, Olivier Galibert -#ifndef _VIDEO_ATARIST_H_ -#define _VIDEO_ATARIST_H_ - -// 32028400 also exists -#define Y2 32084988.0 -#define Y2_NTSC 32042400.0 - -#define ATARIST_HBSTART_PAL 128*4 -#define ATARIST_HBEND_PAL 0 -#define ATARIST_HBSTART_NTSC 127*4 -#define ATARIST_HBEND_NTSC 0 -#define ATARIST_HTOT_PAL 129*4 -#define ATARIST_HTOT_NTSC 128*4 - -#define ATARIST_HBDEND_PAL 14*4 -#define ATARIST_HBDSTART_PAL 94*4 -#define ATARIST_HBDEND_NTSC 13*4 -#define ATARIST_HBDSTART_NTSC 93*4 - -#define ATARIST_VBEND_PAL 0 -#define ATARIST_VBEND_NTSC 0 -#define ATARIST_VBSTART_PAL 312 -#define ATARIST_VBSTART_NTSC 262 -#define ATARIST_VTOT_PAL 313 -#define ATARIST_VTOT_NTSC 263 - -#define ATARIST_VBDEND_PAL 63 -#define ATARIST_VBDSTART_PAL 263 -#define ATARIST_VBDEND_NTSC 34 -#define ATARIST_VBDSTART_NTSC 234 - -#define ATARIST_BLITTER_SKEW_NFSR 0x40 -#define ATARIST_BLITTER_SKEW_FXSR 0x80 - -#define ATARIST_BLITTER_CTRL_SMUDGE 0x20 -#define ATARIST_BLITTER_CTRL_HOG 0x40 -#define ATARIST_BLITTER_CTRL_BUSY 0x80 - -#endif diff --git a/src/mess/video/aussiebyte.c b/src/mess/video/aussiebyte.c deleted file mode 100644 index f3f758fe4f6..00000000000 --- a/src/mess/video/aussiebyte.c +++ /dev/null @@ -1,196 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert -/*********************************************************** - - Video - Graphics not working properly. - Mode 0 - lores (wide, chunky) - Mode 1 - external, *should* be ok - Mode 2 - thin graphics, not explained well enough to code - Mode 3 - alphanumeric, works - - - -************************************************************/ -#include "includes/aussiebyte.h" -/*********************************************************** - - I/O Ports - -************************************************************/ - -// dummy read port, forces requested action to happen -READ8_MEMBER( aussiebyte_state::port33_r ) -{ - return 0xff; -} - -/* -Video control - needs to be fully understood -d0, d1, d2, d3 - can replace RA0-3 in graphics mode -d4 - GS - unknown -d5 - /SRRD - controls write of data to either vram or aram (1=vram, 0=aram) -d6 - /VWR - 0 = enable write vdata to vram, read from aram to vdata ; 1 = enable write to aram from vdata -d7 - OE on port 35 -*/ -WRITE8_MEMBER( aussiebyte_state::port34_w ) -{ - m_port34 = data; -} - -WRITE8_MEMBER( aussiebyte_state::port35_w ) -{ - m_port35 = data; -} - -READ8_MEMBER( aussiebyte_state::port36_r ) -{ - if BIT(m_port34, 5) - { - if BIT(m_p_attribram[m_alpha_address & 0x7ff], 7) - return m_p_videoram[m_alpha_address]; - else - return m_p_videoram[m_graph_address]; - } - else - return m_p_attribram[m_alpha_address & 0x7ff]; -} - -READ8_MEMBER( aussiebyte_state::port37_r ) -{ - return m_crtc->de_r() ? 0xff : 0xfe; -} - - -/*********************************************************** - - Video - -************************************************************/ -MC6845_ON_UPDATE_ADDR_CHANGED( aussiebyte_state::crtc_update_addr ) -{ -/* not sure what goes in here - parameters passed are device, address, strobe */ -// m_video_address = address;// & 0x7ff; -} - -WRITE8_MEMBER( aussiebyte_state::address_w ) -{ - m_crtc->address_w( space, 0, data ); - - m_video_index = data & 0x1f; - - if (m_video_index == 31) - { - m_alpha_address++; - m_alpha_address &= 0x3fff; - m_graph_address = (m_alpha_address << 4) | (m_port34 & 15); - - if BIT(m_port34, 5) - { - if BIT(m_p_attribram[m_alpha_address & 0x7ff], 7) - m_p_videoram[m_alpha_address] = m_port35; - else - m_p_videoram[m_graph_address] = m_port35; - } - else - m_p_attribram[m_alpha_address & 0x7ff] = m_port35; - } -} - -WRITE8_MEMBER( aussiebyte_state::register_w ) -{ - m_crtc->register_w( space, 0, data ); - UINT16 temp = m_alpha_address; - - // Get transparent address - if (m_video_index == 18) - m_alpha_address = (data << 8 ) | (temp & 0xff); - else - if (m_video_index == 19) - m_alpha_address = data | (temp & 0xff00); -} - -UINT8 aussiebyte_state::crt8002(UINT8 ac_ra, UINT8 ac_chr, UINT8 ac_attr, UINT16 ac_cnt, bool ac_curs) -{ - UINT8 gfx = 0; - switch (ac_attr & 3) - { - case 0: // lores gfx - switch (ac_ra) - { - case 0: - case 1: - case 2: - gfx = (BIT(ac_chr, 7) ? 0xf8 : 0) | (BIT(ac_chr, 3) ? 7 : 0); - break; - case 3: - case 4: - case 5: - gfx = (BIT(ac_chr, 6) ? 0xf8 : 0) | (BIT(ac_chr, 2) ? 7 : 0); - break; - case 6: - case 7: - case 8: - gfx = (BIT(ac_chr, 5) ? 0xf8 : 0) | (BIT(ac_chr, 1) ? 7 : 0); - break; - default: - gfx = (BIT(ac_chr, 4) ? 0xf8 : 0) | (BIT(ac_chr, 0) ? 7 : 0); - break; - } - break; - case 1: // external mode - gfx = BITSWAP8(ac_chr, 0,1,2,3,4,5,6,7); - break; - case 2: // thin gfx - break; - case 3: // alpha - gfx = m_p_chargen[((ac_chr & 0x7f)<<4) | ac_ra]; - break; - } - - if (BIT(ac_attr, 3) & (ac_ra == 11)) // underline - gfx = 0xff; - if (BIT(ac_attr, 2) & ((ac_ra == 5) | (ac_ra == 6))) // strike-through - gfx = 0xff; - if (BIT(ac_attr, 6) & BIT(ac_cnt, 13)) // flash - gfx = 0; - if BIT(ac_attr, 5) // blank - gfx = 0; - if (ac_curs & BIT(ac_cnt, 14)) // cursor - gfx ^= 0xff; - if BIT(ac_attr, 4) // reverse video - gfx ^= 0xff; - return gfx; -} - -MC6845_UPDATE_ROW( aussiebyte_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT8 chr,gfx,attr; - UINT16 mem,x; - UINT32 *p = &bitmap.pix32(y); - ra &= 15; - m_cnt++; - - for (x = 0; x < x_count; x++) - { - mem = ma + x; - attr = m_p_attribram[mem & 0x7ff]; - if BIT(attr, 7) - chr = m_p_videoram[mem & 0x3fff]; // alpha - else - chr = m_p_videoram[(mem << 4) | ra]; // gfx - - gfx = crt8002(ra, chr, attr, m_cnt, (x==cursor_x)); - - /* Display a scanline of a character (8 pixels) */ - *p++ = palette[BIT(gfx, 7)]; - *p++ = palette[BIT(gfx, 6)]; - *p++ = palette[BIT(gfx, 5)]; - *p++ = palette[BIT(gfx, 4)]; - *p++ = palette[BIT(gfx, 3)]; - *p++ = palette[BIT(gfx, 2)]; - *p++ = palette[BIT(gfx, 1)]; - *p++ = palette[BIT(gfx, 0)]; - } -} diff --git a/src/mess/video/avigo.c b/src/mess/video/avigo.c deleted file mode 100644 index 0177023fe9f..00000000000 --- a/src/mess/video/avigo.c +++ /dev/null @@ -1,118 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker,Sandro Ronco -/*************************************************************************** - - avigo.c - - Functions to emulate the video hardware of the TI Avigo 10 PDA - -***************************************************************************/ - -#include "emu.h" -#include "includes/avigo.h" - -/*************************************************************************** - Start the video hardware emulation. -***************************************************************************/ - -/* mem size = 0x017c0 */ - - -/* current column to read/write */ - -#define AVIGO_VIDEO_DEBUG 0 -#define LOG(x) do { if (AVIGO_VIDEO_DEBUG) logerror x; } while (0) - - -READ8_MEMBER(avigo_state::vid_memory_r) -{ - if (!offset) - return m_screen_column; - - if ((offset<0x0100) || (offset>=0x01f0) || (m_screen_column >= (AVIGO_SCREEN_WIDTH>>3))) - { - LOG(("vid mem read: %04x\n", offset)); - return 0; - } - - /* 0x0100-0x01f0 contains data for selected column */ - return m_video_memory[m_screen_column + ((offset&0xff)*(AVIGO_SCREEN_WIDTH>>3))]; -} - -WRITE8_MEMBER(avigo_state::vid_memory_w) -{ - if (!offset) - { - /* select column to read/write */ - m_screen_column = data; - - LOG(("vid mem column write: %02x\n",data)); - - if (data>=(AVIGO_SCREEN_WIDTH>>3)) - { - LOG(("error: vid mem column write: %02x\n",data)); - } - return; - } - - if ((offset<0x0100) || (offset>=0x01f0) || (m_screen_column >= (AVIGO_SCREEN_WIDTH>>3))) - { - LOG(("vid mem write: %04x %02x\n", offset, data)); - return; - } - - /* 0x0100-0x01f0 contains data for selected column */ - m_video_memory[m_screen_column + ((offset&0xff)*(AVIGO_SCREEN_WIDTH>>3))] = data; -} - -void avigo_state::video_start() -{ - /* current selected column to read/write */ - m_screen_column = 0; - - /* allocate video memory */ - m_video_memory = machine().memory().region_alloc( "videoram", (AVIGO_SCREEN_WIDTH>>3) * AVIGO_SCREEN_HEIGHT + 1, 1, ENDIANNESS_LITTLE )->base(); - memset(m_video_memory, 0, (AVIGO_SCREEN_WIDTH>>3) * AVIGO_SCREEN_HEIGHT + 1); - - save_pointer(NAME(m_video_memory), (AVIGO_SCREEN_WIDTH>>3) * AVIGO_SCREEN_HEIGHT + 1); -} - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(avigo_state, avigo) -{ - m_palette->set_pen_color(0,rgb_t(0xff,0xff,0xff)); /* white */ - m_palette->set_pen_color(1,rgb_t(0x00,0x00,0x00)); /* black */ -} - -UINT32 avigo_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y; - int b; - int x; - - /* draw avigo display */ - for (y=0; y>3)); - - x = 0; - for (by=((AVIGO_SCREEN_WIDTH>>3)-1); by>=0; by--) - { - int px; - UINT8 byte = line_ptr[0]; - - px = x; - for (b=7; b>=0; b--) - { - bitmap.pix16(y, px) = ((byte>>7) & 0x01); - px++; - byte = byte<<1; - } - - x = px; - line_ptr = line_ptr+1; - } - } - return 0; -} diff --git a/src/mess/video/b2m.c b/src/mess/video/b2m.c deleted file mode 100644 index 9cd59b2ec42..00000000000 --- a/src/mess/video/b2m.c +++ /dev/null @@ -1,60 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Bashkiria-2M video driver by Miodrag Milanovic - - 28/03/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/b2m.h" -#include "machine/ram.h" - -void b2m_state::video_start() -{ -} - -UINT32 b2m_state::screen_update_b2m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code1; - UINT8 code2; - UINT8 col; - int y, x, b; - UINT8 *ram = m_ram->pointer(); - - for (x = 0; x < 48; x++) - { - for (y = 0; y < 256; y++) - { - if (m_b2m_video_page==0) { - code1 = ram[0x11000 + x*256 + ((y + m_b2m_video_scroll) & 0xff)]; - code2 = ram[0x15000 + x*256 + ((y + m_b2m_video_scroll) & 0xff)]; - } else { - code1 = ram[0x19000 + x*256 + ((y + m_b2m_video_scroll) & 0xff)]; - code2 = ram[0x1d000 + x*256 + ((y + m_b2m_video_scroll) & 0xff)]; - } - for (b = 7; b >= 0; b--) - { - col = (((code2 >> b) & 0x01)<<1) + ((code1 >> b) & 0x01); - bitmap.pix16(y, x*8+b) = col; - } - } - } - - return 0; -} - -static const rgb_t b2m_palette[4] = { - rgb_t(0x00, 0x00, 0x00), // 0 - rgb_t(0x00, 0x00, 0x00), // 1 - rgb_t(0x00, 0x00, 0x00), // 2 - rgb_t(0x00, 0x00, 0x00), // 3 -}; - -PALETTE_INIT_MEMBER(b2m_state, b2m) -{ - palette.set_pen_colors(0, b2m_palette, ARRAY_LENGTH(b2m_palette)); -} diff --git a/src/mess/video/bbc.c b/src/mess/video/bbc.c deleted file mode 100644 index 5e059647705..00000000000 --- a/src/mess/video/bbc.c +++ /dev/null @@ -1,306 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Gordon Jefferyes, Nigel Barnes -/****************************************************************************** - BBC Model B - - MESS Driver By: - - Gordon Jefferyes - mess_bbc@romvault.com - - This is the first go around at converting the BBC code over to using - mames built in mc6845, there are a number of features now incorrect - or missing in this build: - - BBC split modes no longer work (Like is used in Elite.) - -******************************************************************************/ - -#include "emu.h" -#include "includes/bbc.h" -#include "video/saa5050.h" -#include "video/mc6845.h" - -/************************************************************************ - * C0 and C1 along with MA12 output from the 6845 drive 4 NAND gates in ICs 27,36 and 40 - * the outputs from these NAND gates (B1 to B4) along with MA8 to MA11 from the 6845 (A1 to B4) are added together - * in IC39 74LS283 4 bit adder to form (S1 to S4) the logic is used to loop the screen memory for hardware scrolling. - * when MA13 from the 6845 is low the latches IC8 and IC9 are enabled - * they control the memory addressing for the Hi-Res modes. - * when MA13 from the 6845 is high the latches IC10 and IC11 are enabled - * they control the memory addressing for the Teletext mode. - * IC 8 or IC10 drives the row select in the memory (the lower 7 bits in the memory address) and - * IC 9 or IC11 drives the column select in the memory (the next 7 bits in the memory address) this - * gives control of the bottom 14 bits of the memory, in a 32K model B 15 bits are needed to access - * all the RAM, so S4 for the adder drives the CAS0 and CAS1 to access the top bit, in a 16K model A - * the output of S4 is linked out to a 0v supply by link S25 to just access the 16K memory area. - ************************************************************************/ - -unsigned int bbc_state::calculate_video_address(int ma,int ra) -{ - // ma = output from IC2 6845 MA address - - int c0=m_b4_video0; // output from IC32 74LS259 bits 4 and 5 - int c1=m_b5_video1; - - /* the 4 bit input port b on IC39 are produced by 4 NAND gates. - these NAND gates take their - inputs from c0 and c1 (from IC32) and ma12 (from the 6845) */ - - /* get bit m12 from the 6845 */ - int ma12=(ma>>12)&1; - - // 4 bit input B on IC39 74LS283 (4 bit adder) - /* 3 input NAND part of IC 36 */ - int b1=(~(c1 & c0 & ma12)) & 1; - /* 2 input NAND part of IC40 (b3 is calculated before b2 and b4 because b3 feed back into b2 and b4) */ - int b3=(~(c0 & ma12)) & 1; - /* 3 input NAND part of IC 36 */ - int b2=(~(c1 & b3 & ma12)) & 1; - /* 2 input NAND part of IC 27 */ - int b4=(~(b3 & ma12)) & 1; - - /* inputs port b to IC39 are taken from the NAND gates b1 to b4 */ - int b=(b1<<0)|(b2<<1)|(b3<<2)|(b4<<3); - - /* inputs port a to IC39 are MA8 to MA11 from the 6845 */ - int a=(ma>>8)&0xf; - - /* IC39 performs the 4 bit add with the carry input set high */ - int s=(a+b+1)&0xf; - - /* if MA13 (TTXVDU) is low then IC8 and IC9 are used to calculate - the memory location required for the hi res video. - if MA13 is hight then IC10 and IC11 are used to calculate the memory location for the teletext chip*/ - unsigned int m; - if ((ma>>13)&1) - { - // IC 10 and IC 11 - m=((ma&0x3ff)|0x3c00)|((s&0x8)<<11); - } else { - // IC 8 and IC 9 - m=((ma&0xff)<<3)|(s<<11)|(ra&0x7); - } - if (m_memorySize==16) - return m & 0x3fff; - - return m; -} - -/************************************************************************ - * VideoULA - ************************************************************************/ - -static const int pixels_per_byte_set[8]={ 2,4,8,16,1,2,4,8 }; - -static const int width_of_cursor_set[8]={ 0,0,1,2,1,0,2,4 }; - -/* this is a quick lookup array that puts bits 0,2,4,6 into bits 0,1,2,3 - this is used by the palette lookup in the video ULA */ -void bbc_state::set_pixel_lookup() -{ - for (int i=0; i<256; i++) - { - m_pixel_bits[i] = (((i>>7)&1)<<3) | (((i>>5)&1)<<2) | (((i>>3)&1)<<1) | (((i>>1)&1)<<0); - } -} - - -WRITE8_MEMBER(bbc_state::bbc_videoULA_w) -{ - // Make sure vpos is never <0 2008-10-11 PHS. - int vpos=machine().first_screen()->vpos(); - if(vpos==0) - machine().first_screen()->update_partial(vpos); - else - machine().first_screen()->update_partial(vpos -1 ); - - logerror("setting videoULA %.4x to:%.4x at :%d \n",data,offset,machine().first_screen()->vpos() ); - - - switch (offset&0x01) - { - // Set the control register in the Video ULA - case 0: - { - m_videoULA_Reg=data; - m_videoULA_master_cursor_size= (m_videoULA_Reg>>7)&0x01; - m_videoULA_width_of_cursor= (m_videoULA_Reg>>5)&0x03; - m_videoULA_6845_clock_rate= (m_videoULA_Reg>>4)&0x01; - m_videoULA_characters_per_line= (m_videoULA_Reg>>2)&0x03; - m_videoULA_teletext_normal_select=(m_videoULA_Reg>>1)&0x01; - m_videoULA_flash_colour_select= m_videoULA_Reg &0x01; - - m_videoULA_pallet_lookup=m_videoULA_flash_colour_select?m_videoULA_pallet0:m_videoULA_pallet1; - - m_emulation_cursor_size=width_of_cursor_set[m_videoULA_width_of_cursor|(m_videoULA_master_cursor_size<<2)]; - - // this is the number of BBC pixels held in each byte - if (m_videoULA_teletext_normal_select) - { - m_pixels_per_byte=6; - } else { - m_pixels_per_byte=pixels_per_byte_set[m_videoULA_characters_per_line|(m_videoULA_6845_clock_rate<<2)]; - } - m_mc6845->set_hpixels_per_column(m_pixels_per_byte); - if (m_videoULA_6845_clock_rate) - m_mc6845->set_clock(2000000); - else - m_mc6845->set_clock(1000000); - } - break; - // Set a pallet register in the Video ULA - case 1: - int tpal=(data>>4)&0x0f; - int tcol=data&0x0f; - m_videoULA_pallet0[tpal]=tcol; - m_videoULA_pallet1[tpal]=tcol<8?tcol:tcol^7; - break; - } -} - -/************************************************************************ - * BBC circuits controlled by 6845 Outputs - ************************************************************************/ - -MC6845_UPDATE_ROW( bbc_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - - if (m_videoULA_teletext_normal_select) - { - m_trom->lose_w(1); - m_trom->lose_w(0); - - for(int x_pos=0; x_pos>13)&1)==0) - { - m_Teletext_Latch=0; - } - else - { - m_Teletext_Latch=(m_BBC_Video_RAM[calculate_video_address(ma+x_pos,ra)]); - } - - m_trom->write((m_Teletext_Latch&0x3f)|(m_Teletext_Latch&0x40)); - - m_trom->f1_w(1); - m_trom->f1_w(0); - - for(int pixelno=0;pixelno<6;pixelno++) - { - m_trom->tr6_w(1); - m_trom->tr6_w(0); - - int col=m_trom->get_rgb() ^ ((x_pos==cursor_x) ? 7 : 0); - - int r = BIT(col, 0) * 0xff; - int g = BIT(col, 1) * 0xff; - int b = BIT(col, 2) * 0xff; - - rgb_t rgb = rgb_t(r, g, b); - - bitmap.pix32(y, (x_pos*m_pixels_per_byte)+pixelno) = rgb; - } - } - - if (ra == 18) - { - m_trom->lose_w(1); - m_trom->lose_w(0); - } - } - else - { - // this is IC38 and IC41 takes 6845 DisplayEnabled and 6845 RA3 - int DE= !(ra>=8); - - if (DE) - { - for(int x_pos=0; x_posdew_w(state); -} - - -/**** BBC B+ Shadow Ram change ****/ - -void bbc_state::bbcbp_setvideoshadow(int vdusel) -{ - if (vdusel) - { - m_BBC_Video_RAM= m_region_maincpu->base()+0x8000; - } else { - m_BBC_Video_RAM= m_region_maincpu->base(); - } -} - -/************************************************************************ - * bbc_vh_start - * Initialize the BBC video emulation - ************************************************************************/ - -void bbc_state::common_init(int memorySize) -{ - m_emulation_cursor_size = 1; - - m_VideoULA_CR = 7; - m_VideoULA_CR_counter = 0; - - set_pixel_lookup(); - - m_BBC_Video_RAM = m_region_maincpu->base(); - m_memorySize=memorySize; - -} - -VIDEO_START_MEMBER(bbc_state,bbca) -{ - common_init(m_ram->size()/1024); -} - -VIDEO_START_MEMBER(bbc_state,bbcb) -{ - common_init(32); -} - -VIDEO_START_MEMBER(bbc_state,bbcbp) -{ - common_init(32); -} - -VIDEO_START_MEMBER(bbc_state,bbcm) -{ - common_init(32); -} diff --git a/src/mess/video/bk.c b/src/mess/video/bk.c deleted file mode 100644 index 103c78779bd..00000000000 --- a/src/mess/video/bk.c +++ /dev/null @@ -1,40 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - BK video driver by Miodrag Milanovic - - 10/03/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/bk.h" - - -void bk_state::video_start() -{ -} - -UINT32 bk_state::screen_update_bk0010(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT16 code; - int y, x, b; - int nOfs; - - nOfs = (m_scrool - 728) % 256; - - for (y = 0; y < 256; y++) - { - for (x = 0; x < 32; x++) - { - code = m_bk0010_video_ram[((y+nOfs) %256)*32 + x]; - for (b = 0; b < 16; b++) - { - bitmap.pix16(y, x*16 + b) = (code >> b) & 0x01; - } - } - } - return 0; -} diff --git a/src/mess/video/busicom.c b/src/mess/video/busicom.c deleted file mode 100644 index 0c97258a002..00000000000 --- a/src/mess/video/busicom.c +++ /dev/null @@ -1,1860 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Busicom 141-PF - - 04/08/2009 Initial driver by Miodrag Milanovic - -****************************************************************************/ -#include "emu.h" -#include "includes/busicom.h" - -// Printer font 34x44 as provided by MIT Media Lab - - -static const UINT8 printer_font[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,0,0,0,0,0,0,4,7,7,7,4,0,0,0, -0,1,7,7,7,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,7,7,3,0,0,0, -0,1,7,7,7,7,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,7,7,3,0,0,0, -0,1,6,7,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,7,7,3,0,0,0, -0,0,6,7,7,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,7,7,2,0,0,0, -0,0,5,7,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,7,7,7,0,0,0,0, -0,0,4,7,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,5,0,0,0,0, -0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - -void busicom_state::video_start() -{ -} - -UINT32 busicom_state::screen_update_busicom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y, x, b, j; - //34x44 - for (y = 0; y < 11; y++) - { - UINT8 col = 8 * m_printer_line_color[y]; - for (x = 0; x < 17; x++) - { - UINT8 chr = m_printer_line[y][x]; - for (j = 0; j < 44; j++) { - for (b = 0; b < 34; b++) - { - bitmap.pix16((y*44)+j, x*40+b) = printer_font[44*34 * chr + j*34 + b] + col ; - } - for (b = 34; b < 40; b++) - { - bitmap.pix16((y*44)+j, x*40+b) = 0; - } - - } - } - } - return 0; -} -static const UINT8 color[] = { 0xFF,0xDB,0xB7,0x92,0x6E,0x49,0x25,0x00 }; - -static const UINT8 color_red[] = { 0xb0,0xb5,0xc0,0xc5,0xd0,0xd5,0xdf }; - -PALETTE_INIT_MEMBER(busicom_state, busicom) -{ - int i; - for(i=0;i<8;i++) { - m_palette->set_pen_color( i, rgb_t(color[i],color[i],color[i]) ); - } - m_palette->set_pen_color( 8, rgb_t(0xff,0xff,0xff) ); - for(i=0;i<7;i++) { - m_palette->set_pen_color( i+9, rgb_t(color_red[i],0x00,0x00) ); - } -} diff --git a/src/mess/video/cgc7900.c b/src/mess/video/cgc7900.c deleted file mode 100644 index 0eb1cda1dd6..00000000000 --- a/src/mess/video/cgc7900.c +++ /dev/null @@ -1,237 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "emu.h" -#include "includes/cgc7900.h" - -/*************************************************************************** - PARAMETERS -***************************************************************************/ - -#define OVERLAY_CUR BIT(cell, 31) /* places a cursor in the cell if SET */ -#define OVERLAY_BLK BIT(cell, 30) /* blinks the foreground character in the cell if SET */ -#define OVERLAY_VF BIT(cell, 28) /* makes the foreground visible if SET (else transparent) */ -#define OVERLAY_VB BIT(cell, 27) /* makes the background visible if SET (else transparent) */ -#define OVERLAY_PL BIT(cell, 24) /* uses bits 0-7 as PLOT DOT descriptor if SET (else ASCII) */ -#define OVERLAY_BR BIT(cell, 18) /* turns on Red in background if SET */ -#define OVERLAY_BG BIT(cell, 17) /* turns on Green in background if SET */ -#define OVERLAY_BB BIT(cell, 16) /* turns on Blue in background if SET */ -#define OVERLAY_FR BIT(cell, 10) /* turns on Red in foreground if SET */ -#define OVERLAY_FG BIT(cell, 9) /* turns on Green in foreground if SET */ -#define OVERLAY_FB BIT(cell, 8) /* turns on Blue in background if SET */ -#define OVERLAY_DATA (cell & 0xff) /* ASCII or Plot Dot character */ - -#define IMAGE_SELECT BIT(m_roll_overlay[0], 13) -#define OVERLAY_CURSOR_BLINK BIT(m_roll_overlay[0], 12) -#define OVERLAY_CHARACTER_BLINK BIT(m_roll_overlay[0], 11) - -PALETTE_INIT_MEMBER(cgc7900_state, cgc7900) -{ - palette.set_pen_color(0, rgb_t::black); - palette.set_pen_color(1, rgb_t(0x00, 0x00, 0xff)); - palette.set_pen_color(2, rgb_t(0x00, 0xff, 0x00)); - palette.set_pen_color(3, rgb_t(0x00, 0xff, 0xff)); - palette.set_pen_color(4, rgb_t(0xff, 0x00, 0x00)); - palette.set_pen_color(5, rgb_t(0xff, 0x00, 0xff)); - palette.set_pen_color(6, rgb_t(0xff, 0xff, 0x00)); - palette.set_pen_color(7, rgb_t::white); -} - -/*************************************************************************** - READ/WRITE HANDLERS -***************************************************************************/ - -/*------------------------------------------------- - cgc7900_z_mode_r - Z mode read --------------------------------------------------*/ - -READ16_MEMBER( cgc7900_state::z_mode_r ) -{ - return 0; -} - -/*------------------------------------------------- - cgc7900_z_mode_w - Z mode write --------------------------------------------------*/ - -WRITE16_MEMBER( cgc7900_state::z_mode_w ) -{ -} - -/*------------------------------------------------- - cgc7900_color_status_w - color status write --------------------------------------------------*/ - -WRITE16_MEMBER( cgc7900_state::color_status_w ) -{ -} - -/*------------------------------------------------- - cgc7900_sync_r - sync information read --------------------------------------------------*/ - -READ16_MEMBER( cgc7900_state::sync_r ) -{ - /* - - bit signal description - - 0 _VERT vertical retrace (0=vblank) - 1 interlace (1=first field, 0=second field) - 2 _HG horizontal retrace (0=hblank) - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 - 13 1 - 14 1 - 15 1 - - */ - - return 0xffff; -} - -/*************************************************************************** - VIDEO -***************************************************************************/ - -/*------------------------------------------------- - update_clut - update color lookup table --------------------------------------------------*/ - -void cgc7900_state::update_clut() -{ - for (int i = 0; i < 256; i++) - { - UINT16 addr = i * 2; - UINT32 data = (m_clut_ram[addr + 1] << 16) | m_clut_ram[addr]; - UINT8 b = data & 0xff; - UINT8 g = (data >> 8) & 0xff; - UINT8 r = (data >> 16) & 0xff; - - m_clut[i] = rgb_t(r, g, b); - } -} - -/*------------------------------------------------- - draw_bitmap - draw bitmap image --------------------------------------------------*/ - -void cgc7900_state::draw_bitmap(screen_device *screen, bitmap_rgb32 &bitmap) -{ -} - -/*------------------------------------------------- - draw_overlay - draw text overlay --------------------------------------------------*/ - -void cgc7900_state::draw_overlay(screen_device *screen, bitmap_rgb32 &bitmap) -{ - const pen_t *pen = m_palette->pens(); - for (int y = 0; y < 768; y++) - { - int sy = y / 8; - int line = y % 8; - - for (int sx = 0; sx < 85; sx++) - { - UINT16 addr = (sy * 170) + (sx * 2); - UINT32 cell = (m_overlay_ram[addr] << 16) | m_overlay_ram[addr + 1]; - UINT8 data = m_char_rom->base()[(OVERLAY_DATA << 3) | line]; - int fg = (cell >> 8) & 0x07; - int bg = (cell >> 16) & 0x07; - - for (int x = 0; x < 8; x++) - { - if (OVERLAY_CUR) - { - if (!OVERLAY_CURSOR_BLINK || m_blink) - { - bitmap.pix32(y, (sx * 8) + x) = pen[7]; - } - } - else - { - if (BIT(data, x) && (!OVERLAY_CHARACTER_BLINK || m_blink)) - { - if (OVERLAY_VF) bitmap.pix32(y, (sx * 8) + x) = pen[fg]; - } - else - { - if (OVERLAY_VB) bitmap.pix32(y, (sx * 8) + x) = pen[bg]; - } - } - } - } - } -} - -/*------------------------------------------------- - TIMER_DEVICE_CALLBACK_MEMBER( blink_tick ) --------------------------------------------------*/ - -TIMER_DEVICE_CALLBACK_MEMBER(cgc7900_state::blink_tick) -{ - m_blink = !m_blink; -} - -UINT32 cgc7900_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - update_clut(); - draw_bitmap(&screen, bitmap); - draw_overlay(&screen, bitmap); - - return 0; -} - -/*------------------------------------------------- - gfx_layout cgc7900_charlayout --------------------------------------------------*/ - -static const gfx_layout cgc7900_charlayout = -{ - 8,8, - RGN_FRAC(1,1), - 1, - { RGN_FRAC(0,1) }, - { STEP8(7,-1) }, - { STEP8(0,8) }, - 8*8 -}; - -/*------------------------------------------------- - GFXDECODE( cgc7900 ) --------------------------------------------------*/ - -static GFXDECODE_START( cgc7900 ) - GFXDECODE_ENTRY( "gfx1", 0x0000, cgc7900_charlayout, 0, 1 ) -GFXDECODE_END - -/*************************************************************************** - MACHINE DRIVERS -***************************************************************************/ - -/*------------------------------------------------- - MACHINE_DRIVER( cgc7900_video ) --------------------------------------------------*/ - -MACHINE_CONFIG_FRAGMENT( cgc7900_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ - MCFG_SCREEN_UPDATE_DRIVER(cgc7900_state, screen_update) - MCFG_SCREEN_SIZE(1024, 768) - MCFG_SCREEN_VISIBLE_AREA(0, 1024-1, 0, 768-1) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", cgc7900) - MCFG_PALETTE_ADD("palette", 8) - MCFG_PALETTE_INIT_OWNER(cgc7900_state, cgc7900) - - MCFG_TIMER_DRIVER_ADD_PERIODIC("blink", cgc7900_state, blink_tick, attotime::from_hz(XTAL_28_48MHz/7500000)) -MACHINE_CONFIG_END diff --git a/src/mess/video/channelf.c b/src/mess/video/channelf.c deleted file mode 100644 index 03a5310e934..00000000000 --- a/src/mess/video/channelf.c +++ /dev/null @@ -1,71 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller, Frank Palazzolo, Sean Riddle -#include "includes/channelf.h" - -static const rgb_t channelf_palette[] = -{ - rgb_t(0x10, 0x10, 0x10), /* black */ - rgb_t(0xfd, 0xfd, 0xfd), /* white */ - rgb_t(0xff, 0x31, 0x53), /* red */ - rgb_t(0x02, 0xcc, 0x5d), /* green */ - rgb_t(0x4b, 0x3f, 0xf3), /* blue */ - rgb_t(0xe0, 0xe0, 0xe0), /* ltgray */ - rgb_t(0x91, 0xff, 0xa6), /* ltgreen */ - rgb_t(0xce, 0xd0, 0xff) /* ltblue */ -}; - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define LTGRAY 5 -#define LTGREEN 6 -#define LTBLUE 7 - -static const UINT16 colormap[] = { - BLACK, WHITE, WHITE, WHITE, - LTBLUE, BLUE, RED, GREEN, - LTGRAY, BLUE, RED, GREEN, - LTGREEN, BLUE, RED, GREEN, -}; - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(channelf_state, channelf) -{ - palette.set_pen_colors(0, channelf_palette, ARRAY_LENGTH(channelf_palette)); -} - -void channelf_state::video_start() -{ - m_p_videoram = memregion("vram")->base(); -} - -int channelf_state::recalc_palette_offset(int reg1, int reg2) -{ - /* Note: This is based on the decoding they used to */ - /* determine which palette this line is using */ - - return ((reg2&0x2)|(reg1>>1)) << 2; -} - -UINT32 channelf_state::screen_update_channelf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,col; - UINT16 ma=0,x; - int palette_offset; - - for(y = 0; y < 64; y++ ) - { - UINT16 *p = &bitmap.pix16(y); - palette_offset = recalc_palette_offset(m_p_videoram[y*128+125]&3, m_p_videoram[y*128+126]&3); - - for (x = ma; x < ma + 128; x++) - { - col = palette_offset+(m_p_videoram[x|(y<<7)]&3); - *p++ = colormap[col]; - } - ma+=128; - } - return 0; -} diff --git a/src/mess/video/comquest.c b/src/mess/video/comquest.c deleted file mode 100644 index cbfb1014fe7..00000000000 --- a/src/mess/video/comquest.c +++ /dev/null @@ -1,24 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#include "emu.h" - -#include "includes/comquest.h" - -void comquest_state::video_start() -{ -} - -UINT32 comquest_state::screen_update_comquest(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y, j; - - for (y=0; y<128;y++) { - for (x=0, j=0; j<8;j++,x+=8*4) { -#if 0 - m_gfxdecode->gfx(0)->opaque(bitmap,0, state->m_data[y][j],0, - 0,0,x,y); -#endif - } - } - return 0; -} diff --git a/src/mess/video/comx35.c b/src/mess/video/comx35.c deleted file mode 100644 index 4c214006776..00000000000 --- a/src/mess/video/comx35.c +++ /dev/null @@ -1,126 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "emu.h" -#include "rendlay.h" -#include "includes/comx35.h" -#include "cpu/cosmac/cosmac.h" -#include "sound/cdp1869.h" -#include "sound/wave.h" -#include "video/mc6845.h" - -WRITE8_MEMBER( comx35_state::cdp1869_w ) -{ - UINT16 ma = m_maincpu->get_memory_address(); - - switch (offset) - { - case 3: - m_vis->out3_w(space, ma, data); - break; - - case 4: - m_vis->out4_w(space, ma, data); - break; - - case 5: - m_vis->out5_w(space, ma, data); - break; - - case 6: - m_vis->out6_w(space, ma, data); - break; - - case 7: - m_vis->out7_w(space, ma, data); - break; - } -} - -/* CDP1869 */ - -static ADDRESS_MAP_START( cdp1869_page_ram, AS_0, 8, driver_device ) - AM_RANGE(0x000, 0x7ff) AM_RAM -ADDRESS_MAP_END - -CDP1869_CHAR_RAM_READ_MEMBER( comx35_state::comx35_charram_r ) -{ - UINT8 column = pmd & 0x7f; - UINT16 charaddr = (column << 4) | cma; - - return m_char_ram[charaddr]; -} - -CDP1869_CHAR_RAM_WRITE_MEMBER( comx35_state::comx35_charram_w ) -{ - UINT8 column = pmd & 0x7f; - UINT16 charaddr = (column << 4) | cma; - - m_char_ram[charaddr] = data; -} - -CDP1869_PCB_READ_MEMBER( comx35_state::comx35_pcb_r ) -{ - return BIT(pmd, 7); -} - -WRITE_LINE_MEMBER( comx35_state::prd_w ) -{ - if ((m_prd == CLEAR_LINE) && (state == ASSERT_LINE)) - { - m_cr1 = m_iden ? CLEAR_LINE : ASSERT_LINE; - check_interrupt(); - } - - m_prd = state; - - m_maincpu->set_input_line(COSMAC_INPUT_LINE_EF1, state); -} - - -void comx35_state::video_start() -{ - // allocate memory - m_char_ram.allocate(COMX35_CHARRAM_SIZE); -} - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( comx35_pal_video ) - MCFG_CDP1869_SCREEN_PAL_ADD(CDP1869_TAG, SCREEN_TAG, CDP1869_DOT_CLK_PAL) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, cdp1869_page_ram) - MCFG_CDP1869_COLOR_CLOCK(CDP1869_COLOR_CLK_PAL) - MCFG_CDP1869_CHAR_PCB_READ_OWNER(comx35_state, comx35_pcb_r) - MCFG_CDP1869_CHAR_RAM_READ_OWNER(comx35_state, comx35_charram_r) - MCFG_CDP1869_CHAR_RAM_WRITE_OWNER(comx35_state, comx35_charram_w) - MCFG_CDP1869_PAL_NTSC_CALLBACK(VCC) - MCFG_CDP1869_PRD_CALLBACK(WRITELINE(comx35_state, prd_w)) - MCFG_CDP1869_SET_SCREEN(SCREEN_TAG) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) - - MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette") - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( comx35_ntsc_video ) - MCFG_CDP1869_SCREEN_NTSC_ADD(CDP1869_TAG, SCREEN_TAG, CDP1869_DOT_CLK_NTSC) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_NTSC, cdp1869_page_ram) - MCFG_CDP1869_COLOR_CLOCK(CDP1869_COLOR_CLK_NTSC) - MCFG_CDP1869_CHAR_PCB_READ_OWNER(comx35_state, comx35_pcb_r) - MCFG_CDP1869_CHAR_RAM_READ_OWNER(comx35_state, comx35_charram_r) - MCFG_CDP1869_CHAR_RAM_WRITE_OWNER(comx35_state, comx35_charram_w) - MCFG_CDP1869_PAL_NTSC_CALLBACK(GND) - MCFG_CDP1869_PRD_CALLBACK(WRITELINE(comx35_state, prd_w)) - MCFG_CDP1869_SET_SCREEN(SCREEN_TAG) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) - - MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette") - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END diff --git a/src/mess/video/crt.c b/src/mess/video/crt.c deleted file mode 100644 index d075600baf7..00000000000 --- a/src/mess/video/crt.c +++ /dev/null @@ -1,184 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - video/crt.c - - CRT video emulation for TX-0 and PDP-1. - - -Theory of operation: - - What makes such CRT devices so odd is that there is no video processor, no - scan logic, no refresh logic. The beam position and intensity is - controlled by the program completely: in order to draw an object, the - program must direct the beam to each point of the object, and in order to - refresh it, the program must redraw the object periodically. - - Since the refresh rates are highly variable (completely controlled by the - program), I need to simulate CRT remanence: the intensity of each pixel on - display decreases regularly. In order to keep this efficient, I keep a - list of non-black pixels, and only process these pixels on each refresh. - In order to improve efficiency further, I keep a distinct list for each - line of the display: I have found that it improves drawing speed slightly - (probably because it improves the cache hit rate). - - - Raphael Nabet 2002-2004 - Based on earlier work by Chris Salomon -*/ - -#include "emu.h" -#include "video/crt.h" - - -// special value that tells that the node is not in list -enum -{ - intensity_pixel_not_in_list = -1 -}; - - -// device type definition -const device_type CRT = &device_creator; - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// crt_device - constructor -//------------------------------------------------- - -crt_device::crt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, CRT, "CRT Video", tag, owner, clock, "crt", __FILE__), - m_list(NULL), - m_list_head(NULL), - m_decay_counter(0), - m_num_intensity_levels(0), - m_window_offset_x(0), - m_window_offset_y(0), - m_window_width(0), - m_window_height(0) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void crt_device::device_start() -{ - /* alloc the arrays */ - m_list = auto_alloc_array(machine(), crt_point, m_window_width * m_window_height); - m_list_head = auto_alloc_array(machine(), int, m_window_height); - - /* fill with black and set up list as empty */ - for (int i = 0; i < (m_window_width * m_window_height); i++) - m_list[i].intensity = intensity_pixel_not_in_list; - - for (int i = 0; i < m_window_height; i++) - m_list_head[i] = -1; - - m_decay_counter = 0; -} - - -// -// crt_plot -// -// schedule a pixel to be plotted -// -void crt_device::plot(int x, int y) -{ - crt_point *node; - int list_index; - - /* compute pixel coordinates */ - if (x<0) x=0; - if (y<0) y=0; - if ((x>(m_window_width-1)) || ((y>m_window_height-1))) - return; - y = (m_window_height-1) - y; - - /* find entry in list */ - list_index = x + y*m_window_width; - - node = &m_list[list_index]; - - if (node->intensity == intensity_pixel_not_in_list) - { /* insert node in list if it is not in it */ - node->next = m_list_head[y]; - m_list_head[y] = list_index; - } - /* set intensity */ - node->intensity = m_num_intensity_levels; -} - - -// -// crt_eof -// -// keep track of time -// -void crt_device::eof() -{ - m_decay_counter++; -} - - -// -// crt_update -// -// update the bitmap -// -void crt_device::update(bitmap_ind16 &bitmap) -{ - int i, p_i; - int y; - - //if (m_decay_counter) - { - /* some time has elapsed: let's update the screen */ - for (y=0; yintensity == m_num_intensity_levels) - /* new pixel: set to max intensity */ - node->intensity = m_num_intensity_levels-1; - else - { - /* otherwise, apply intensity decay */ - node->intensity -= m_decay_counter; - if (node->intensity < 0) - node->intensity = 0; - } - - /* draw pixel on screen */ - //plot_pixel(bitmap, x, y+m_window_offset_y, node->intensity); - line[x] = node->intensity; - - if (node->intensity != 0) - p_i = i; /* current node will be next iteration's previous node */ - else - { /* delete current node */ - node->intensity = intensity_pixel_not_in_list; - if (p_i != -1) - m_list[p_i].next = node->next; - else - m_list_head[y] = node->next; - } - } - } - - m_decay_counter = 0; - } -} diff --git a/src/mess/video/crt.h b/src/mess/video/crt.h deleted file mode 100644 index cb0767ad0d9..00000000000 --- a/src/mess/video/crt.h +++ /dev/null @@ -1,93 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/************************************************************************* - - video/crt.h - - CRT video emulation for TX-0 and PDP-1 - -*************************************************************************/ - -#ifndef __CRT_H__ -#define __CRT_H__ - - -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_CRT_NUM_LEVELS(_lev) \ - crt_device::set_num_levels(*device, _lev); - -#define MCFG_CRT_OFFSETS(_xoffs, _yoffs) \ - crt_device::set_offsets(*device, _xoffs, _yoffs); - -#define MCFG_CRT_SIZE(_width, _height) \ - crt_device::set_size(*device, _width, _height); - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -struct crt_point -{ - crt_point() : - intensity(0), - next(0) {} - - int intensity; /* current intensity of the pixel */ - /* a node is not in the list when (intensity == -1) */ - int next; /* index of next pixel in list */ -}; - -// ======================> crt_device - -class crt_device : public device_t -{ -public: - crt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~crt_device() { } - - static void set_num_levels(device_t &device, int levels) { downcast(device).m_num_intensity_levels = levels; } - static void set_offsets(device_t &device, int x_offset, int y_offset) - { - crt_device &dev = downcast(device); - dev.m_window_offset_x = x_offset; - dev.m_window_offset_y = y_offset; - } - static void set_size(device_t &device, int width, int height) - { - crt_device &dev = downcast(device); - dev.m_window_width = width; - dev.m_window_height = height; - } - - void plot(int x, int y); - void eof(); - void update(bitmap_ind16 &bitmap); - -protected: - // device-level overrides - virtual void device_start(); - -private: - crt_point *m_list; /* array of (crt_window_width*crt_window_height) point */ - int *m_list_head; /* head of the list of lit pixels (index in the array) */ - /* keep a separate list for each display line (makes the video code slightly faster) */ - - int m_decay_counter; /* incremented each frame (tells for how many frames the CRT has decayed between two screen refresh) */ - - /* CRT window */ - int m_num_intensity_levels; - int m_window_offset_x; - int m_window_offset_y; - int m_window_width; - int m_window_height; -}; - -extern const device_type CRT; - - - -#endif /* CRT_H_ */ diff --git a/src/mess/video/dai.c b/src/mess/video/dai.c deleted file mode 100644 index a0d36a8097c..00000000000 --- a/src/mess/video/dai.c +++ /dev/null @@ -1,764 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha, Nathan Woods -/*************************************************************************** - - dai.c - - Functions to emulate the video hardware of DAI. - - Krzysztof Strzecha - - All video modes are emulated but not fully tested yet. - dai_state::screen_update_dai() function needs strong cleanup and optimalisation. - - -***************************************************************************/ - -#include "emu.h" -#include "includes/dai.h" - -#define DEBUG_DAI_VIDEO 0 - -#define LOG_DAI_VIDEO_LINE(_mode, _unit, _resolution, _repeat, _scan) do { if (DEBUG_DAI_VIDEO) logerror ("Mode: %02x, Unit: %02x, Resolution: %02x, Repeat: %d, Current line: %d\n", _mode, _unit, _resolution, _repeat, _scan); } while (0) - -const unsigned char dai_palette[16*3] = -{ - 0x00, 0x00, 0x00, /* 0 Black */ - 0x00, 0x00, 0x8b, /* 1 Dark Blue */ - 0xb1, 0x00, 0x95, /* 2 Purple Red */ - 0xff, 0x00, 0x00, /* 3 Red */ - 0x75, 0x2e, 0x50, /* 4 Purple Brown */ - 0x00, 0xb2, 0x38, /* 5 Emerald Green */ - 0x98, 0x62, 0x00, /* 6 Kakhi Brown */ - 0xae, 0x7a, 0x00, /* 7 Mustard Brown */ - 0x89, 0x89, 0x89, /* 8 Grey */ - 0xa1, 0x6f, 0xff, /* 9 Middle Blue */ - 0xff, 0xa5, 0x00, /* 10 Orange */ - 0xff, 0x99, 0xff, /* 11 Pink */ - 0x9e, 0xf4, 0xff, /* 12 Light Blue */ - 0xb3, 0xff, 0xbb, /* 13 Light Green */ - 0xff, 0xff, 0x28, /* 14 Light Yellow */ - 0xff, 0xff, 0xff, /* 15 White */ -}; - - -PALETTE_INIT_MEMBER(dai_state, dai) -{ - int i; - - for ( i = 0; i < sizeof(dai_palette) / 3; i++ ) - { - m_palette->set_pen_color(i, dai_palette[i * 3], dai_palette[i * 3 + 1], dai_palette[i * 3 + 2]); - } -} - - -void dai_state::video_start() -{ -} - -UINT32 dai_state::screen_update_dai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - int i, j, k, l; - - UINT8* char_rom = memregion("gfx1")->base(); - - UINT16 dai_video_memory_start = 0xbfff; - UINT16 dai_scan_lines = 604; /* scan lines of PAL tv */ - - UINT16 current_scan_line = 0; - UINT16 current_video_memory_address = dai_video_memory_start; - - UINT8 mode; /* mode byte of line - bits 0-3 - line repeat count - bits 4-5 - resolution control - bits 6-7 - display mode control */ - UINT8 colour; /* colour byte of line - bits 0-3 - one of 16 colours - bits 4-5 - colour register for update - bit 6 - if unset force 'unit colour mode' - bit 7 - enable coulor change - if unset bits 0-5 are ignored */ - UINT8 line_repeat_count; /* number of horizontalraster scans - for which same data will be displayed - 0000 - 2 lines - each additional repeat adds 2 scans */ - UINT8 horizontal_resolution; /* number of blobs per line - 00 - 88 (low resolution graphics) - 01 - 176 (medium resolution graphics) - 10 - 352 (high resolution graphics) - 11 - 528 (text with 66 chars per line) */ - UINT8 display_mode; /* determine how data will be used - to generate the picture - 00 - four colour graphics - 01 - four colour characters - 10 - sixteen colour graphics - 11 - sixteen colour characters */ - UINT8 unit_mode; - - UINT8 current_data_1, current_data_2; - - UINT8 current_colour; - - while (current_scan_line < dai_scan_lines) - { - mode = space.read_byte(current_video_memory_address--); - colour = space.read_byte(current_video_memory_address--); - line_repeat_count = mode & 0x0f; - horizontal_resolution = (mode & 0x30) >> 4; - display_mode = (mode & 0xc0) >> 6; - unit_mode = (colour & 0x40) >> 6; - - if (colour & 0x80) - m_4_colours_palette[(colour & 0x30) >> 4] = colour & 0x0f; - - switch (display_mode) - { - case 0x00: /* 4 colour grahics modes */ - switch (horizontal_resolution) - { - case 0x00: /* 88 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - - for (i=0; i<11; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<11; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - break; - } - break; - - case 0x01: /* 176 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<22; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<22; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - break; - } - break; - - case 0x02: /* 352 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<44; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<44; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - } - break; - - case 0x03: /* 528 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<66; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<66; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - } - break; - } - break; - - case 0x01: /* 4 colour characters */ - switch (horizontal_resolution) - { - case 0x00: /* 11 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (i=0; i<11; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<11; i++) - { - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - } - break; - case 0x01: /* 22 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (i=0; i<22; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<22; i++) - { - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - } - break; - case 0x02: /* 44 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (i=0; i<44; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<44; i++) - { - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - } - break; - case 0x03: /* 66 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (i=0; i<66; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<66; i++) - { - current_data_1 = space.read_byte(current_video_memory_address); - current_data_2 = space.read_byte(current_video_memory_address-1); - current_video_memory_address-=2; - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = m_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - } - break; - } - break; - case 0x02: /* 16 colour graphics */ - switch (horizontal_resolution) - { - case 0x00: /* 88 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - - for (i=0; i<11; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<11; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - break; - } - break; - - case 0x01: /* 176 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<22; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<22; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - break; - } - break; - - case 0x02: /* 352 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<44; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<44; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - } - break; - - case 0x03: /* 528 pixels */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<66; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<66; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((current_data_1>>(7-k)) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - } - break; - } - break; - case 0x03: /* 16 colour characters */ - switch (horizontal_resolution) - { - case 0x00: /* 11 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<11; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<11; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<12; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - } - break; - case 0x01: /* 22 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<22; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - case 1: - for (i=0; i<22; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<6; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; - } - } - } - current_video_memory_address-=2; - break; - } - break; - case 0x02: /* 44 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<44; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<44; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<3; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; - } - } - } - break; - } - break; - case 0x03: /* 66 chars */ - switch (unit_mode) - { - case 0: - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (i=0; i<66; i++) - { - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - case 1: - for (i=0; i<66; i++) - { - current_data_1 = space.read_byte(current_video_memory_address--); - current_data_2 = space.read_byte(current_video_memory_address--); - for (j=0; j<=line_repeat_count; j++) - { - for (k=0; k<8; k++) - { - current_colour = ((char_rom[current_data_1*16+j]>>k) & 0x01) ? (current_data_2>>4)&0x0f : current_data_2&0x0f; - for (l=0; l<2; l++) - bitmap.pix16(current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; - } - } - } - break; - } - break; - } - break; - } - current_scan_line += line_repeat_count*2+2; - LOG_DAI_VIDEO_LINE(display_mode, unit_mode, horizontal_resolution, line_repeat_count, current_scan_line); - } - return 0; -} diff --git a/src/mess/video/dgn_beta.c b/src/mess/video/dgn_beta.c deleted file mode 100644 index 41cb1fde657..00000000000 --- a/src/mess/video/dgn_beta.c +++ /dev/null @@ -1,286 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/* - video/dgn_beta.c - -The Dragon Beta uses a 68B45 for it's display generation, this is used in the -conventional wat with a character generator ROM in the two text modes, which are -standard 40x25 and 80x25. In adition to the 6845 there is some TTL logic which -provides colour and attributes. In text modes the video ram is organised as pairs -of character and attribute, in alternate bytes. - -The attributes decode as follows :- - - 7-6-5-4-3-2-1-0 - f-u-F-F-F-B-B-B - - f=flash - u=underline - - FFF = foreground colour - BBB = bakcground colour - - 000 black - 001 red - 010 green - 011 yellow - 100 blue - 101 magenta - 110 cyan - 111 white - - If flash is true, foreground and background colours will be exchanged. - -It is interesting to note that the 6845 uses 16 bit wide access to the ram, in contrast -to the 8 bit accesses from the CPUs, this allows each increment of the MA lines to move -2 bytes at a time, and therefore feed both the character rom and the attribute decode -circuit simultaniously. - -The RAM addresses are made up of two parts, the MA0..13 from the 6845, plus two output -lines from the 6821 PIA, I28, the lines are BP6 and PB7, with PB7 being the most -significant. This effectivly allows the 6845 access to the first 128K of memory, as there -are 16 address lines, accessing a 16 bit wide memory. - -The relationship between how the cpu sees the RAM, and the way the 6845 sees it is simply -CPU addr=2x6845 addr. So for the default video address of $1F000, the CPU sees this as -being at $1F000 (after DAT trasnlation). The 6845 is programmed to start it's MA lines -counting at $3800, plus A14 and A15 being supplied by PB6 and PB7 from I28, gives an address -of $F800, which is the same as $1F000 / 2. - -I am currently at this time not sure of how any of the graphics modes, work, this will need -further investigation. - -However the modes supported are :- - -Text Modes - width height colours - 40 25 8 - 80 25 8 -Graphics modes - 320 256 4 - 320 256 16 - 640 512 4 - 640 256 4** - 640 512 2 - -Looking at the parts of the circuit sheet that I have seen it looks like the graphics modes -are driven using a combination of the 6845 MA and RA lines to address more than 64K or memory -which is needed for some of the modes above (specifically, 640x512x4, which needs 80K). - -2006-11-30, Text mode is almost completely implemented, in both 40 and 80 column modes. -I have made a start on implementing the graphics modes of the beta, drawing from technical -documents, from the project, this is still a work in progress. I have however managed to get -it to display a distorted graphical image, so I know I am going in the correct direction ! - -** 2006-12-05, this mode is not documented in any of the printed documentation, however it -is supported and displayed by the graphics test rom, it is basically the 640x512x4 mode with -half the number of vertical lines, and in non-interlaced mode. - -It seems that the 640x512 modes operate the 6845 in interlaced mode, just how this affects -the access to the video memory is unclear to me at the moment. - -*/ - -#include "emu.h" -#include "includes/dgn_beta.h" - -/* GCtrl bitmasks, infered from bits of Beta schematic */ -#define GCtrlWI 0x01 -#define GCtrlSWChar 0x02 /* Character set select */ -#define GCtrlHiLo 0x04 /* Hi/Lo res graphics, Hi=1, Lo=0 */ -#define GCtrlChrGfx 0x08 /* Character=1 / Graphics=0 */ -#define GCtrlControl 0x10 /* Control bit, sets direct drive mode */ -#define GCtrlFS 0x20 /* labeled F/S, not yet sure of function Fast or Slow scan ? */ -#define GCtrlAddrLines 0xC0 /* Top two address lines for text mode */ - -#define IsTextMode (m_GCtrl & GCtrlChrGfx) ? 1 : 0 // Is this text mode ? -#define IsGfx16 ((~m_GCtrl & GCtrlChrGfx) && (~m_GCtrl & GCtrlControl)) ? 1 : 0 // is this 320x256x16bpp mode -#define IsGfx2 ((m_GCtrl & GCtrlHiLo) && (~m_GCtrl & GCtrlFS)) ? 1 : 0 // Is this a 2 colour mode -#define SWChar (m_GCtrl & GCtrlSWChar)>>1 // Swchar bit - -MC6845_UPDATE_ROW( dgn_beta_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT8 *videoram = m_videoram; - UINT32 *p = &bitmap.pix32(y); - int i; - if(IsTextMode) - { - UINT8 *chr_gen = memregion("gfx1")->base(); - for ( i = 0; i < x_count; i++ ) - { - UINT32 offset = ( ( ma + i ) | ((m_GCtrl & GCtrlAddrLines)<<8)) << 1; - UINT8 chr = videoram[ offset ]; - UINT8 attr = videoram[ offset +1 ]; - - /* Extract non-colour attributes, in character set 1, undeline is used */ - /* We will extract the colours below, when we have decoded inverse */ - /* to indicate a double height character */ - int UnderLine=(attr & 0x40) >> 6; // Underline active - int FlashChar=(attr & 0x80) >> 7; // Flashing char - - // underline is active for character set 0, on character row 9 - int ULActive=(UnderLine && (ra==9) && ~SWChar); - - /* Invert forground and background if flashing char and flash acive */ - int Invert=(FlashChar & m_FlashBit); - - /* Underline inverts flash */ - if (ULActive) - Invert=~Invert; - - /* Cursor on also inverts */ - if (i == cursor_x) - Invert=~Invert; - - UINT16 fg = 0; - UINT16 bg = 0; - - /* Invert colours if invert is true */ - if(!Invert) - { - fg = (attr & 0x38) >> 3; - bg = (attr & 0x07); - } - else - { - bg = (attr & 0x38) >> 3; - fg = (attr & 0x07); - } - - - - UINT8 data = chr_gen[ chr * 16 + ra ]; - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - } - - } - else - { - for ( i = 0; i < x_count; i++ ) - { - UINT32 offset = ((((ma + i ) & 0x1FFF) << 3) | (ra & 0x07)) << 1; - - UINT8 Lo = videoram[ offset ]; - UINT8 Hi = videoram[ offset +1 ]; - UINT16 Word = (Hi<<8) | Lo; - int Red; - int Green; - int Blue; - int Intense; - int Colour; - int Dot; - - /* If contol is low then we are plotting 4 bit per pixel, 16 colour mode */ - /* This directly drives the colour output lines, from the pixel value */ - /* If Control is high, then we lookup the colour from the LS670 4x4 bit */ - /* palate register */ - if (IsGfx16) - { - Intense =(Lo & 0x0F); - Red =(Lo & 0xF0)>>4; - Green =(Hi & 0x0F); - Blue =(Hi & 0xF0)>>4; - Colour=((Intense&0x08) | (Red&0x08)>>1) | ((Green&0x08)>>2) | ((Blue&0x08)>>3); - - for (Dot=0;Dot<4;Dot++) - { - *p = palette[Colour]; p++; - *p = palette[Colour]; p++; - *p = palette[Colour]; p++; - *p = palette[Colour]; p++; - - Intense =Intense<<1; - Red =Red<<1; - Green =Green<<1; - Blue =Blue<<1; - } - } - else if (IsGfx2) - { - for (Dot=0;Dot<16;Dot=Dot+1) - { - Colour=m_ColourRAM[((Word&0x8000)>>15)]; - - *p = palette[Colour]; p++; - - Hi=(Word&0x8000) >> 15; - Word=((Word<<1)&0xFFFE) | Hi; - } - } - else - { - for (Dot=0;Dot<8;Dot++) - { - Colour=m_ColourRAM[((Word&0x8000)>>14) | ((Word&0x80)>>7)]; - *p = palette[Colour]; p++; - *p = palette[Colour]; p++; - - Hi=(Word&0x8000) >> 15; - Word=((Word<<1)&0xFFFE) | Hi; - } - } - } - } - -} - -WRITE_LINE_MEMBER(dgn_beta_state::dgnbeta_vsync_changed) -{ - m_beta_VSync=state; - if (!m_beta_VSync) - { - m_FlashCount++; - if(m_FlashCount==10) - { - m_FlashCount=0; // Reset counter - m_FlashBit=(!m_FlashBit) & 0x01; // Invert flash bit. - } - } - - dgn_beta_frame_interrupt(state); -} - - -/* Set video control register from I28 port B, the control register is laid out as */ -/* follows :- */ -/* bit function */ -/* 0 WI, unknown */ -/* 1 Character set select, drives A12 of character rom in text mode */ -/* 2 High (1) or Low(0) resolution if in graphics mode. */ -/* 3 Text (1) or Graphics(0) mode */ -/* 4 Control bit, Selects between colour palate and drirect drive */ -/* 5 F/S bit, 1=80 bytes/line, 0=40bytes/line */ -/* 6 Effective A14, to ram, in text mode */ -/* 7 Effective A15, to ram, in text mode */ -/* the top two address lines for the video ram, are supplied by the BB6 and PB7 on */ -/* 6821-I28, this allows the 6845 to access the full 64K address range, however */ -/* since the ram data is addressed as a 16bit wide unit, this allows the 6845 */ -/* access to the first 128K or ram. */ -void dgn_beta_state::dgnbeta_vid_set_gctrl(int data) -{ - m_GCtrl=data; -} - - -/* Write handler for colour, pallate ram */ -WRITE8_MEMBER(dgn_beta_state::dgnbeta_colour_ram_w) -{ - m_ColourRAM[offset]=data&0x0f; /* Colour ram 4 bit and write only to CPU */ -} diff --git a/src/mess/video/electron.c b/src/mess/video/electron.c deleted file mode 100644 index e77904ef8e6..00000000000 --- a/src/mess/video/electron.c +++ /dev/null @@ -1,273 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/****************************************************************************** - Acorn Electron driver - - MESS Driver By: - - Wilbert Pol - -******************************************************************************/ - -#include "emu.h" -#include "includes/electron.h" - -/* - From the ElectrEm site: - -Timing is somewhat of a thorny issue on the Electron. It is almost certain the Electron could have been a much faster machine if BBC Micro OS level compatibility had not been not a design requirement. - -When accessing the ROM regions, the CPU always runs at 2MHz. When accessing the FC (1 MHz bus) or FD (JIM) pages, the CPU always runs at 1MHz. - -The timing for RAM accesses varies depending on the graphics mode, and how many bytes are required to be read by the video circuits per scanline. When accessing RAM in modes 4-6, the CPU is simply moved to a 1MHz clock. This occurs for any RAM access at any point during the frame. - -In modes 0-3, if the CPU tries to access RAM at any time during which the video circuits are fetching bytes, it is halted by means of receiving a stopped clock until the video circuits next stop fetching bytes. - -Each scanline is drawn in exactly 64us, and of that the video circuits fetch bytes for 40us. In modes 0, 1 and 2, 256 scanlines have pixels on, whereas in mode 3 only 250 scanlines are affected as mode 3 is a 'spaced' mode. - -As opposed to one clock generator which changes pace, the 1MHz and 2MHz clocks are always available, so the ULA acts to simply change which clock is piped to the CPU. This means in half of all cases, a further 2MHz cycle is lost waiting for the 2MHz and 1MHz clocks to synchronise during a 2MHz to 1MHz step. - -The video circuits run from a constant 2MHz clock, and generate 312 scanlines a frame, one scanline every 128 cycles. This actually gives means the Electron is running at 50.08 frames a second. - -Creating a scanline numbering scheme where the first scanline with pixels is scanline 0, in all modes the end of display interrupt is generated at the end of scanline 255, and the RTC interrupt is generated upon the end of scanline 99. - -From investigating some code for vertical split modes printed in Electron User volume 7, issue 7 it seems that the exact timing of the end of display interrupt is somewhere between 24 and 40 cycles after the end of pixels. This may coincide with HSYNC. I have no similarly accurate timing for the real time clock interrupt at this time. - -Mode changes are 'immediate', so any change in RAM access timing occurs exactly after the write cycle of the changing instruction. Similarly palette changes take effect immediately. VSYNC is not signalled in any way. - -*/ - - - - -void electron_state::video_start() -{ - int i; - for( i = 0; i < 256; i++ ) { - m_map4[i] = ( ( i & 0x10 ) >> 3 ) | ( i & 0x01 ); - m_map16[i] = ( ( i & 0x40 ) >> 3 ) | ( ( i & 0x10 ) >> 2 ) | ( ( i & 0x04 ) >> 1 ) | ( i & 0x01 ); - } - m_scanline_timer = timer_alloc(TIMER_SCANLINE_INTERRUPT); - m_scanline_timer->adjust( machine().first_screen()->time_until_pos(0), 0, machine().first_screen()->scan_period() ); -} - -inline UINT8 electron_state::read_vram( UINT16 addr ) -{ - return m_ula.vram[ addr % m_ula.screen_size ]; -} - -inline void electron_state::electron_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -UINT32 electron_state::screen_update_electron(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int i; - int x = 0; - int pal[16]; - int scanline = screen.vpos(); - rectangle r = cliprect; - r.min_y = r.max_y = scanline; - - /* set up palette */ - switch( m_ula.screen_mode ) - { - case 0: case 3: case 4: case 6: case 7: /* 2 colour mode */ - pal[0] = m_ula.current_pal[0]; - pal[1] = m_ula.current_pal[8]; - break; - case 1: case 5: /* 4 colour mode */ - pal[0] = m_ula.current_pal[0]; - pal[1] = m_ula.current_pal[2]; - pal[2] = m_ula.current_pal[8]; - pal[3] = m_ula.current_pal[10]; - break; - case 2: /* 16 colour mode */ - for( i = 0; i < 16; i++ ) - pal[i] = m_ula.current_pal[i]; - } - - /* draw line */ - switch( m_ula.screen_mode ) - { - case 0: - for( i = 0; i < 80; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + (i << 3) ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)& 1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)& 1] ); - } - m_ula.screen_addr++; - if ( ( scanline & 0x07 ) == 7 ) - m_ula.screen_addr += 0x278; - break; - - case 1: - for( i = 0; i < 80; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - } - m_ula.screen_addr++; - if ( ( scanline & 0x07 ) == 7 ) - m_ula.screen_addr += 0x278; - break; - - case 2: - for( i = 0; i < 80; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map16[pattern>>0]] ); - } - m_ula.screen_addr++; - if ( ( scanline & 0x07 ) == 7 ) - m_ula.screen_addr += 0x278; - break; - - case 3: - if ( ( scanline > 249 ) || ( scanline % 10 >= 8 ) ) - bitmap.fill(7, r ); - else - { - for( i = 0; i < 80; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); - } - m_ula.screen_addr++; - } - if ( scanline % 10 == 9 ) - m_ula.screen_addr += 0x278; - break; - - case 4: - case 7: - for( i = 0; i < 40; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); - } - m_ula.screen_addr++; - if ( ( scanline & 0x07 ) == 7 ) - m_ula.screen_addr += 0x138; - break; - - case 5: - for( i = 0; i < 40; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>3]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>2]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>1]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - electron_plot_pixel( bitmap, x++, scanline, pal[m_map4[pattern>>0]] ); - } - m_ula.screen_addr++; - if ( ( scanline & 0x07 ) == 7 ) - m_ula.screen_addr += 0x138; - break; - - case 6: - if ( ( scanline > 249 ) || ( scanline % 10 >= 8 ) ) - bitmap.fill(7, r ); - else - { - for( i = 0; i < 40; i++ ) - { - UINT8 pattern = read_vram( m_ula.screen_addr + i * 8 ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>4)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>3)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>2)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); - electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); - } - m_ula.screen_addr++; - if ( ( scanline % 10 ) == 7 ) - m_ula.screen_addr += 0x138; - } - break; - } - - return 0; -} - -TIMER_CALLBACK_MEMBER(electron_state::electron_scanline_interrupt) -{ - switch (machine().first_screen()->vpos()) - { - case 43: - electron_interrupt_handler( INT_SET, INT_RTC ); - break; - case 199: - electron_interrupt_handler( INT_SET, INT_DISPLAY_END ); - break; - case 0: - m_ula.screen_addr = m_ula.screen_start - m_ula.screen_base; - break; - } -} diff --git a/src/mess/video/fm7.c b/src/mess/video/fm7.c deleted file mode 100644 index 298e98c9262..00000000000 --- a/src/mess/video/fm7.c +++ /dev/null @@ -1,1493 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Barry Rodewald -/* - * - * Fujitsu Micro 7 Video functions - * - */ - -#include "emu.h" -#include "cpu/m6809/m6809.h" -#include "includes/fm7.h" - - -/* - * Main CPU: Sub-CPU interface (port 0xfd05) - * - * Read: - * bit 7: Sub-CPU busy (or halted) - * bit 0: EXTDET (?) - * Write: - * bit 7: Sub-CPU halt - * bit 6: Sub-CPU cancel IRQ - */ - -READ8_MEMBER(fm7_state::fm7_subintf_r) -{ - UINT8 ret = 0x00; - - if(m_video.sub_busy != 0 || m_video.sub_halt != 0) - ret |= 0x80; - - ret |= 0x7e; - //ret |= 0x01; // EXTDET (not implemented yet) - - return ret; -} - -WRITE8_MEMBER(fm7_state::fm7_subintf_w) -{ - m_video.sub_halt = data & 0x80; - if(data & 0x80) - m_video.sub_busy = data & 0x80; - - m_sub->set_input_line(INPUT_LINE_HALT,(data & 0x80) ? ASSERT_LINE : CLEAR_LINE); - if(data & 0x40) - m_sub->set_input_line(M6809_IRQ_LINE,ASSERT_LINE); - //popmessage("Sub CPU Interface write: %02x\n",data); -} - -READ8_MEMBER(fm7_state::fm7_sub_busyflag_r) -{ - if(m_video.sub_halt == 0) - m_video.sub_busy = 0x00; - return 0x00; -} - -WRITE8_MEMBER(fm7_state::fm7_sub_busyflag_w) -{ - m_video.sub_busy = 0x80; -} - -/* - * Sub-CPU port 0xd402 - * Read-only: Acknowledge Cancel IRQ - */ -READ8_MEMBER(fm7_state::fm7_cancel_ack) -{ - m_sub->set_input_line(M6809_IRQ_LINE,CLEAR_LINE); - return 0x00; -} - -/* - * Reading from 0xd404 (sub-CPU) causes an "Attention" FIRQ on the main CPU - */ -READ8_MEMBER(fm7_state::fm7_attn_irq_r) -{ - m_video.attn_irq = 1; - m_maincpu->set_input_line(M6809_FIRQ_LINE,ASSERT_LINE); - return 0xff; -} - -/* - * Sub CPU: I/O port 0xd409 - * - * On read, enables VRAM access - * On write, disables VRAM access - */ -READ8_MEMBER(fm7_state::fm7_vram_access_r) -{ - m_video.vram_access = 1; - return 0xff; -} - -WRITE8_MEMBER(fm7_state::fm7_vram_access_w) -{ - m_video.vram_access = 0; -} - -TIMER_CALLBACK_MEMBER(fm7_state::fm77av_alu_task_end) -{ - m_alu.busy = 0; -} - -void fm7_state::fm7_alu_mask_write(UINT32 offset, int bank, UINT8 dat) -{ - UINT8 temp; - int page = 0; - - if(offset >= 0xc000) - page = 1; - - if((m_alu.command & 0x40) == 0) - { // "always" write mode - m_video_ram[(offset & 0x3fff) + (bank * 0x4000) + (page * 0xc000)] = dat; - return; - } - - temp = m_video_ram[(offset & 0x3fff) + (bank * 0x4000) + (page * 0xc000)]; - if(m_alu.command & 0x20) - { // "not equal" write mode - temp &= m_alu.compare_data; - dat &= ~m_alu.compare_data; - } - else - { // "equal" write mode - temp &= ~m_alu.compare_data; - dat &= m_alu.compare_data; - } - - m_video_ram[(offset & 0x3fff) + (bank * 0x4000) + (page * 0xc000)] = temp | dat; -} - -void fm7_state::fm7_alu_function_compare(UINT32 offset) -{ - // COMPARE - compares which colors match those in the compare registers - // can be used on its own, or when bit 6 of the command register is high. - - UINT8 red,green,blue; - UINT8 dat = 0; - UINT8 colour; - UINT8 banks; - int x,y; - int match; - int page = 0; - UINT8 bit = 0x80; - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - blue = m_video_ram[(offset & 0x3fff) + (page * 0xc000)]; - red = m_video_ram[(offset & 0x3fff) + 0x4000 + (page * 0xc000)]; - green = m_video_ram[(offset & 0x3fff) + 0x8000 + (page * 0xc000)]; - - banks = (~m_alu.bank_disable) & 0x07; - - for(x=0;x<8;x++) // loop through each pixel - { - colour = 0; - if(blue & bit) - colour |= 1; - if(red & bit) - colour |= 2; - if(green & bit) - colour |= 4; - - match = 0; - for(y=0;y<8;y++) // loop through each compare register - { - if(!(m_alu.compare[y] & 0x80)) // don't compare if register is masked - { - if((m_alu.compare[y] & banks) == (colour & banks)) - match = 1; - } - } - if(match != 0) - dat |= bit; - - bit >>= 1; - } - m_alu.compare_data = dat; -} - -void fm7_state::fm7_alu_function_pset(UINT32 offset) -{ - // PSET - simply sets the pixels to the selected logical colour - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - if(m_alu.lcolour & (1 << x)) - dat = 0xff; - else - dat = 0; - - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]) & m_alu.mask; - dat &= ~m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_or(UINT32 offset) -{ - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - if(m_alu.lcolour & (1 << x)) - dat = 0xff; - else - dat = 0; - - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); - dat |= mask; - - mask &= m_alu.mask; - dat &= ~m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_and(UINT32 offset) -{ - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - if(m_alu.lcolour & (1 << x)) - dat = 0xff; - else - dat = 0; - - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); - dat &= mask; - - mask &= m_alu.mask; - dat &= ~m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_xor(UINT32 offset) -{ - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - if(m_alu.lcolour & (1 << x)) - dat = 0xff; - else - dat = 0; - - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); - dat ^= mask; - - mask &= m_alu.mask; - dat &= ~m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_not(UINT32 offset) -{ - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - if(m_alu.lcolour & (1 << x)) - dat = 0xff; - else - dat = 0; - - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); - dat = ~mask; - - mask &= m_alu.mask; - dat &= ~m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_invalid(UINT32 offset) -{ - // Invalid function, still does something though (used by Laydock) - int x; - UINT8 dat; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); - - dat = mask & m_alu.mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function_tilepaint(UINT32 offset) -{ - // TILEPAINT - writes to VRAM based on the tilepaint colour registers - int x; - UINT8 dat = 0; - int page = 0; - UINT8 mask; - - if(m_alu.command & 0x40) - fm7_alu_function_compare(offset); - - if(offset >= 0xc000) - { - page = 1; - offset += m_video.vram_offset2; - } - else - offset += m_video.vram_offset; - - for(x=0;x<3;x++) // cycle through banks - { - if(!(m_alu.bank_disable & (1 << x))) - { - switch(x) - { - case 0: - dat = m_alu.tilepaint_b; - break; - case 1: - dat = m_alu.tilepaint_r; - break; - case 2: - dat = m_alu.tilepaint_g; - break; - } - dat &= ~m_alu.mask; - mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]) & m_alu.mask; - dat |= mask; - - fm7_alu_mask_write(offset,x,dat); - } - } -} - -void fm7_state::fm7_alu_function(UINT32 offset) -{ - switch(m_alu.command & 0x07) - { - case 0x00: // PSET - fm7_alu_function_pset(offset); - break; - case 0x02: // OR - fm7_alu_function_or(offset); - break; - case 0x03: // AND - fm7_alu_function_and(offset); - break; - case 0x04: // XOR - fm7_alu_function_xor(offset); - break; - case 0x05: // NOT - fm7_alu_function_not(offset); - break; - case 0x06: // TILEPAINT - fm7_alu_function_tilepaint(offset); - break; - case 0x07: // COMPARE - fm7_alu_function_compare(offset); - break; - case 0x01: - default: - fm7_alu_function_invalid(offset); - } -} - -UINT32 fm7_state::fm7_line_set_pixel(int x, int y) -{ - UINT32 addr; - static const UINT8 pixel_mask[8] = {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe }; - - - if(m_video.modestatus & 0x40) // 320 pixels wide - { - addr = (x >> 3) + (y * 40); - } - else // 640 pixels wide - { - addr = (x >> 3) + (y * 80); - } - addr += (m_alu.addr_offset << 1); - addr &= 0x3fff; - if(m_video.active_video_page != 0) - addr += 0xc000; - - if(m_alu.command & 0x80) // ALU must be active - { - m_alu.mask = pixel_mask[x & 0x07]; - fm7_alu_function(addr); - } - - return addr; -} - -void fm7_state::fm77av_line_draw() -{ - int x1 = m_alu.x0; - int x2 = m_alu.x1; - int y1 = m_alu.y0; - int y2 = m_alu.y1; - - int dx = abs(x2 - x1); - int dy = abs(y2 - y1); - int stepx, stepy; - int err,err2; - int byte_count = 0; - - if(x1 < x2) - stepx = 1; - else - stepx = -1; - if(y1 < y2) - stepy = 1; - else - stepy = -1; - - err = dx - dy; - - for(;;) - { - fm7_line_set_pixel(x1, y1); - byte_count++; - - if(x1 == x2 && y1 == y2) - break; - - err2 = 2*err; - if(err2 > -dy) - { - err -= dy; - x1 += stepx; - } - if(err2 < dx) - { - err += dx; - y1 += stepy; - } - } - - // set timer to disable busy flag - // 1/16 us for each byte changed - timer_set(attotime::from_usec(byte_count/16), TIMER_FM77AV_ALU_TASK_END); -} - -READ8_MEMBER(fm7_state::fm7_vram_r) -{ - int offs; - UINT16 page = 0x0000; - - if(m_video.active_video_page != 0) - page = 0xc000; - - if(offset < 0x4000 && (m_video.multi_page & 0x01)) - return 0xff; - if((offset < 0x8000 && offset >=0x4000) && (m_video.multi_page & 0x02)) - return 0xff; - if((offset < 0xc000 && offset >=0x8000) && (m_video.multi_page & 0x04)) - return 0xff; - - if(m_alu.command & 0x80) // ALU active, writes to VRAM even when reading it (go figure) - { - fm7_alu_function(offset+page); - } - - if(m_video.modestatus & 0x40) - { - if(m_video.active_video_page != 0) - offs = (offset & 0xe000) | ((offset + m_video.vram_offset2) & 0x1fff); - else - offs = (offset & 0xe000) | ((offset + m_video.vram_offset) & 0x1fff); - } - else - { - if(m_video.active_video_page != 0) - offs = (offset & 0xc000) | ((offset + m_video.vram_offset2) & 0x3fff); - else - offs = (offset & 0xc000) | ((offset + m_video.vram_offset) & 0x3fff); - } - return m_video_ram[offs + page]; -} - -WRITE8_MEMBER(fm7_state::fm7_vram_w) -{ - int offs; - UINT16 page = 0x0000; - - if(m_video.active_video_page != 0) - page = 0xc000; - - if(offset < 0x4000 && (m_video.multi_page & 0x01)) - return; - if((offset < 0x8000 && offset >=0x4000) && (m_video.multi_page & 0x02)) - return; - if((offset < 0xc000 && offset >=0x8000) && (m_video.multi_page & 0x04)) - return; - - if(m_alu.command & 0x80) // ALU active - { - fm7_alu_function(offset+page); - return; - } - - if(m_video.modestatus & 0x40) - { - if(m_video.active_video_page != 0) - offs = (offset & 0xe000) | ((offset + m_video.vram_offset2) & 0x1fff); - else - offs = (offset & 0xe000) | ((offset + m_video.vram_offset) & 0x1fff); - } - else - { - if(m_video.active_video_page != 0) - offs = (offset & 0xc000) | ((offset + m_video.vram_offset2) & 0x3fff); - else - offs = (offset & 0xc000) | ((offset + m_video.vram_offset) & 0x3fff); - } -// if(m_video.vram_access != 0) - m_video_ram[offs+page] = data; -} - -// not pretty, but it should work. -WRITE8_MEMBER(fm7_state::fm7_vram_banked_w) -{ - int offs; - UINT16 page = 0x0000; - - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return; - - if(m_video.active_video_page != 0) - page = 0xc000; - - if(offset < 0x4000 && (m_video.multi_page & 0x01)) - return; - if((offset < 0x8000 && offset >=0x4000) && (m_video.multi_page & 0x02)) - return; - if((offset < 0xc000 && offset >=0x8000) && (m_video.multi_page & 0x04)) - return; - - if(m_alu.command & 0x80) // ALU active - { - fm7_alu_function(offset+page); - return; - } - - if(m_video.modestatus & 0x40) - { - if(m_video.active_video_page != 0) - offs = (offset & 0xe000) | ((offset + m_video.vram_offset2) & 0x1fff); - else - offs = (offset & 0xe000) | ((offset + m_video.vram_offset) & 0x1fff); - } - else - { - if(m_video.active_video_page != 0) - offs = (offset & 0xc000) | ((offset + m_video.vram_offset2) & 0x3fff); - else - offs = (offset & 0xc000) | ((offset + m_video.vram_offset) & 0x3fff); - } - m_video_ram[offs+page] = data; -} - -READ8_MEMBER(fm7_state::fm7_vram0_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset); -} - -READ8_MEMBER(fm7_state::fm7_vram1_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x1000); -} - -READ8_MEMBER(fm7_state::fm7_vram2_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x2000); -} - -READ8_MEMBER(fm7_state::fm7_vram3_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x3000); -} - -READ8_MEMBER(fm7_state::fm7_vram4_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x4000); -} - -READ8_MEMBER(fm7_state::fm7_vram5_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x5000); -} - -READ8_MEMBER(fm7_state::fm7_vram6_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x6000); -} - -READ8_MEMBER(fm7_state::fm7_vram7_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x7000); -} - -READ8_MEMBER(fm7_state::fm7_vram8_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x8000); -} - -READ8_MEMBER(fm7_state::fm7_vram9_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0x9000); -} - -READ8_MEMBER(fm7_state::fm7_vramA_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0xa000); -} - -READ8_MEMBER(fm7_state::fm7_vramB_r) -{ - if(!m_video.sub_halt) // no access if sub CPU is not halted. - return 0xff; - return fm7_vram_r(space,offset+0xb000); -} - -WRITE8_MEMBER(fm7_state::fm7_vram0_w) -{ - fm7_vram_banked_w(space,offset,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram1_w) -{ - fm7_vram_banked_w(space,offset+0x1000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram2_w) -{ - fm7_vram_banked_w(space,offset+0x2000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram3_w) -{ - fm7_vram_banked_w(space,offset+0x3000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram4_w) -{ - fm7_vram_banked_w(space,offset+0x4000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram5_w) -{ - fm7_vram_banked_w(space,offset+0x5000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram6_w) -{ - fm7_vram_banked_w(space,offset+0x6000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram7_w) -{ - fm7_vram_banked_w(space,offset+0x7000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram8_w) -{ - fm7_vram_banked_w(space,offset+0x8000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vram9_w) -{ - fm7_vram_banked_w(space,offset+0x9000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vramA_w) -{ - fm7_vram_banked_w(space,offset+0xa000,data); -} - -WRITE8_MEMBER(fm7_state::fm7_vramB_w) -{ - fm7_vram_banked_w(space,offset+0xb000,data); -} - -/* - * Sub CPU: I/O port 0xd408 - * - * On read, enables the CRT display - * On write, disables the CRT display - */ -READ8_MEMBER(fm7_state::fm7_crt_r) -{ - m_video.crt_enable = 1; - return 0xff; -} - -WRITE8_MEMBER(fm7_state::fm7_crt_w) -{ - m_video.crt_enable = 0; -} - -/* - * Sub CPU: I/O ports 0xd40e - 0xd40f - * - * 0xd40e: bits 0-6 - offset in bytes (high byte) (bit 6 is used for 400 line video only) - * 0xd40f: bits 0-7 - offset in bytes (low byte) - */ -WRITE8_MEMBER(fm7_state::fm7_vram_offset_w) -{ - UINT16 new_offset = 0; - - switch(offset) - { - case 0: - if(m_video.active_video_page != 0) - new_offset = ((data & 0x3f) << 8) | (m_video.vram_offset2 & 0x00ff); - else - new_offset = ((data & 0x3f) << 8) | (m_video.vram_offset & 0x00ff); - break; - case 1: // low 5 bits are used on FM-77AV and later only - if(m_type == SYS_FM7) - new_offset = (m_video.vram_offset & 0xff00) | (data & 0xe0); - else - { - if(m_video.active_video_page != 0) - { - if(m_video.fine_offset != 0) - new_offset = (m_video.vram_offset2 & 0xff00) | (data & 0xff); - else - new_offset = (m_video.vram_offset2 & 0xff00) | (data & 0xe0); - } - else - { - if(m_video.fine_offset != 0) - new_offset = (m_video.vram_offset & 0xff00) | (data & 0xff); - else - new_offset = (m_video.vram_offset & 0xff00) | (data & 0xe0); - } - } - break; - } - if(m_video.active_video_page != 0) - m_video.vram_offset2 = new_offset; - else - m_video.vram_offset = new_offset; -} - -/* - * Main CPU: port 0xfd37 - * Multipage - * Port is write-only - * - * bits 6-4: VRAM planes to display (G,R,B) (1=disable) - * bits 2-0: VRAM CPU access (G,R,B) (1=disable) - */ -WRITE8_MEMBER(fm7_state::fm7_multipage_w) -{ - m_video.multi_page = data & 0x77; -} - -/* - * Main CPU: I/O ports 0xfd38-0xfd3f - * Colour palette. - * Each port represents one of eight colours. Palette is 3-bit. - * bit 2 = Green - * bit 1 = Red - * bit 0 = Blue - */ -READ8_MEMBER(fm7_state::fm7_palette_r) -{ - return m_video.fm7_pal[offset]; -} - -WRITE8_MEMBER(fm7_state::fm7_palette_w) -{ - m_palette->set_pen_color(offset, rgb_t(pal1bit(data >> 1), pal1bit(data >> 2), pal1bit(data >> 0))); - m_video.fm7_pal[offset] = data & 0x07; -} - -/* - * Main CPU: 0xfd30 - 0xfd34 - * Analog colour palette (FM-77AV and later only) - * All ports are write-only. - * - * fd30: colour select(?) high 4 bits (LC11-LC8) - * fd31: colour select(?) low 8 bits (LC7-LC0) - * fd32: blue level (4 bits) - * fd33: red level (4 bits) - * fd34: green level (4 bits) - */ -WRITE8_MEMBER(fm7_state::fm77av_analog_palette_w) -{ - int val; - - switch(offset) - { - case 0: - val = ((data & 0x0f) << 8) | (m_video.fm77av_pal_selected & 0x00ff); - m_video.fm77av_pal_selected = val; - break; - case 1: - val = data | (m_video.fm77av_pal_selected & 0x0f00); - m_video.fm77av_pal_selected = val; - break; - case 2: - m_av_palette->set_pen_blue_level(m_video.fm77av_pal_selected, data << 4); - break; - case 3: - m_av_palette->set_pen_red_level(m_video.fm77av_pal_selected, data << 4); - break; - case 4: - m_av_palette->set_pen_green_level(m_video.fm77av_pal_selected, data << 4); - break; - } -} - - -/* - * Sub CPU: 0xd430 - BUSY/NMI/Bank register (FM77AV series only) - * - * On read: bit 7 - 0 if in VBlank - * bit 4 - ALU busy(0)/ready(1) - * bit 2 - VSync status (1 if active?) - * bit 0 - RESET - * - * On write: bits 1-0 - CGROM select (maps to 0xd800) - * bit 2 - fine offset enable (enables OA4-OA0 bits in VRAM offset) - * bit 5 - active VRAM page - * bit 6 - display VRAM page - * bit 7 - NMI mask register (1=mask) - */ -READ8_MEMBER(fm7_state::fm77av_video_flags_r) -{ - UINT8 ret = 0xff; - - if(machine().first_screen()->vblank()) - ret &= ~0x80; - - if(m_alu.busy != 0) - ret &= ~0x10; - - if(m_video.vsync_flag == 0) - ret &= ~0x04; - - if(!m_video.sub_reset) - ret &= ~0x01; - - return ret; -} - -WRITE8_MEMBER(fm7_state::fm77av_video_flags_w) -{ - UINT8* RAM = memregion("subsyscg")->base(); - - m_video.cgrom = data & 0x03; - membank("bank20")->set_base(RAM+(m_video.cgrom*0x800)); - m_video.fine_offset = data & 0x04; - m_video.active_video_page = data & 0x20; - m_video.display_video_page = data & 0x40; - m_video.nmi_mask = data & 0x80; -} - -/* - * Main CPU: port 0xfd12 - * Sub mode status register (FM-77AV or later) - * bit 6 (R/W) - Video mode width(?) 0=640 (default) 1=320. - * bit 1 (R/O) - DISPTMG status (0=blank) - * bit 0 (R/O) - VSync status (1=sync?) - */ -READ8_MEMBER(fm7_state::fm77av_sub_modestatus_r) -{ - UINT8 ret = 0x00; - - ret |= 0xbc; - ret |= (m_video.modestatus & 0x40); - - if(!machine().first_screen()->vblank()) - ret |= 0x02; - - if(m_video.vsync_flag != 0) - ret |= 0x01; - - return ret; -} - -WRITE8_MEMBER(fm7_state::fm77av_sub_modestatus_w) -{ - m_video.modestatus = data & 0x40; - if(data & 0x40) - { - rectangle rect(0, 320-1, 0, 200-1); - machine().first_screen()->configure(320,200,rect,HZ_TO_ATTOSECONDS(60)); - } - else - { - rectangle rect(0, 640-1, 0, 200-1); - machine().first_screen()->configure(640,200,rect,HZ_TO_ATTOSECONDS(60)); - } -} - -/* - * Main CPU: port 0xfd13 - * Sub Bank select register - * - * bits 1 and 0 select which subsys ROM to be banked into sub CPU space - * on the FM-77AV40 and later, bit 2 can also selected to bank in sub monitor RAM. - */ -WRITE8_MEMBER(fm7_state::fm77av_sub_bank_w) -{ -// UINT8* RAM = memregion("sub")->base(); - UINT8* ROM; - - if((data & 0x03) == (m_sb_prev & 0x03)) - return; - - m_video.subrom = data & 0x03; - switch (data & 0x03) - { - case 0x00: // Type C, 640x200 (as used on the FM-7) - ROM = memregion("subsys_c")->base(); - // membank(20)->set_base(ROM); - membank("bank21")->set_base(ROM+0x800); - logerror("VID: Sub ROM Type C selected\n"); - break; - case 0x01: // Type A, 640x200 - ROM = memregion("subsys_a")->base(); - // membank(20)->set_base(RAM+0xd800); - membank("bank21")->set_base(ROM); - logerror("VID: Sub ROM Type A selected\n"); - break; - case 0x02: // Type B, 320x200 - ROM = memregion("subsys_b")->base(); - // membank(20)->set_base(RAM+0xd800); - membank("bank21")->set_base(ROM); - logerror("VID: Sub ROM Type B selected\n"); - break; - case 0x03: // CG Font? - ROM = memregion("subsyscg")->base(); - // membank(20)->set_base(RAM+0xd800); - membank("bank21")->set_base(ROM); - logerror("VID: Sub ROM CG selected\n"); - break; - } - // reset sub CPU, set busy flag, set reset flag - m_sub->set_input_line(INPUT_LINE_RESET,PULSE_LINE); - m_video.sub_busy = 0x80; - m_video.sub_halt = 0; - m_video.sub_reset = 1; - m_sb_prev = data; -} - -/* - * Sub CPU: ports 0xd410-0xd42b (FM-77AV and later only) - * Video operations - * - * 0xd410 (R/W): Command register - * bit 7: 0=DIS 1=Start - * bits 6-5: MBIT1, MBIT2 - * bits 2-0: Draw mode - * 0 0 0 - PSET - * 0 1 0 - OR - * 0 1 1 - AND - * 1 0 0 - XOR - * 1 0 1 - NOT - * 1 1 0 - TILEPAINT - * 1 1 1 - COMPARE - * 0xd411 (R/W): Logical colour (bits 2-0, G-R-B) - * 0xd412 (R/W): Mask register - * 0xd413 (R) : Compare data (?) - * 0xd413-1a(W): Compare registers (bits 2-0, G-R-B, 1=mask (bit 7)) - * 0xd41b (R/W): Bank disable register (bits 2-0, G-R-B, 1=disable, bit 3 must always be 1) - * 0xd41c-1e(W): Tilepaint registers (B-R-G) - * 0xd420-21(W): Line Address offset register (High-Low, A13-A1) - * 0xd422-23(W): Line style pattern register (High-Low, P15-P0) - * 0xd424-25(W): Line X0 (High-Low, X9-X0) - * 0xd426-27(W): Line Y0 (High-Low, Y8-Y0) - * 0xd428-29(W): Line X1 (High-Low, X9-X0) - * 0xd42a-2b(W): Line Y1 (High-Low, Y8-Y0) - */ -READ8_MEMBER(fm7_state::fm77av_alu_r) -{ - switch(offset) - { - case 0x00: - logerror("ALU: read from command register (%02x)\n",m_alu.command); - return m_alu.command; - case 0x01: - logerror("ALU: read from logical colour\n"); - return m_alu.lcolour; - case 0x02: - logerror("ALU: read from mask register\n"); - return m_alu.mask; - case 0x03: - logerror("ALU: read from compare data register (%02x)\n",m_alu.compare_data); - return m_alu.compare_data; - case 0x0b: - logerror("ALU: read from bank disable register\n"); - return 0xf7 | m_alu.bank_disable; - default: - logerror("ALU: read from invalid register 0x%02x\n",offset); - return 0xff; - } -} - -WRITE8_MEMBER(fm7_state::fm77av_alu_w) -{ - UINT16 dat; - - switch(offset) - { - case 0x00: - m_alu.command = data; - logerror("ALU: write to command register - %02x\n",data); - break; - case 0x01: - m_alu.lcolour = data & 0x07; - logerror("ALU: write to logical colour - %02x\n",data); - break; - case 0x02: - m_alu.mask = data; - logerror("ALU: write to mask register - %02x\n",data); - break; - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0a: - m_alu.compare[offset-3] = data; - logerror("ALU: write to compare register %i - %02x\n",offset-3,data); - break; - case 0x0b: - m_alu.bank_disable = data & 0x03; -// logerror("ALU: write to bank disable register - %02x\n",data); - break; - case 0x0c: - m_alu.tilepaint_b = data; -// logerror("ALU: write to tilepaint (blue) register - %02x\n",data); - break; - case 0x0d: - m_alu.tilepaint_r = data; -// logerror("ALU: write to tilepaint (red) register - %02x\n",data); - break; - case 0x0e: - m_alu.tilepaint_g = data; -// logerror("ALU: write to tilepaint (green) register - %02x\n",data); - break; - case 0x10: - dat = ((data & 0x1f) << 8) | (m_alu.addr_offset & 0x00ff); - m_alu.addr_offset = dat; -// logerror("ALU: write to address offset (high) register - %02x (%04x)\n",data,m_alu.addr_offset); - break; - case 0x11: - dat = (m_alu.addr_offset & 0xff00) | data; - m_alu.addr_offset = dat; -// logerror("ALU: write to address offset (low) register - %02x (%04x)\n",data,m_alu.addr_offset); - break; - case 0x12: - dat = (data << 8) | (m_alu.line_style & 0x00ff); - m_alu.line_style = dat; -// logerror("ALU: write to line style (high) register - %02x (%04x)\n",data,m_alu.line_style); - break; - case 0x13: - dat = (m_alu.line_style & 0xff00) | data; - m_alu.line_style = dat; -// logerror("ALU: write to line style (low) register - %02x (%04x)\n",data,m_alu.line_style); - break; - case 0x14: - dat = ((data & 0x03) << 8) | (m_alu.x0 & 0x00ff); - m_alu.x0 = dat; -// logerror("ALU: write to X0 (high) register - %02x (%04x)\n",data,m_alu.x0); - break; - case 0x15: - dat = (m_alu.x0 & 0xff00) | data; - m_alu.x0 = dat; -// logerror("ALU: write to X0 (low) register - %02x (%04x)\n",data,m_alu.x0); - break; - case 0x16: - dat = ((data & 0x01) << 8) | (m_alu.y0 & 0x00ff); - m_alu.y0 = dat; -// logerror("ALU: write to Y0 (high) register - %02x (%04x)\n",data,m_alu.y0); - break; - case 0x17: - dat = (m_alu.y0 & 0xff00) | data; - m_alu.y0 = dat; -// logerror("ALU: write to Y0 (low) register - %02x (%04x)\n",data,m_alu.y0); - break; - case 0x18: - dat = ((data & 0x03) << 8) | (m_alu.x1 & 0x00ff); - m_alu.x1 = dat; -// logerror("ALU: write to X1 (high) register - %02x (%04x)\n",data,m_alu.x1); - break; - case 0x19: - dat = (m_alu.x1 & 0xff00) | data; - m_alu.x1 = dat; -// logerror("ALU: write to X1 (low) register - %02x (%04x)\n",data,m_alu.x1); - break; - case 0x1a: - dat = ((data & 0x01) << 8) | (m_alu.y1 & 0x00ff); - m_alu.y1 = dat; -// logerror("ALU: write to Y1 (high) register - %02x (%04x)\n",data,m_alu.y1); - break; - case 0x1b: - dat = (m_alu.y1 & 0xff00) | data; - m_alu.y1 = dat; - // draw line - fm77av_line_draw(); -// logerror("ALU: write to Y1 (low) register - %02x (%04x)\n",data,m_alu.y1); - break; - default: - logerror("ALU: write 0x%02x to invalid register 0x%02x\n",data,offset); - } -} - -TIMER_CALLBACK_MEMBER(fm7_state::fm77av_vsync) -{ - if(param == 0) // start of vsync - { - m_video.vsync_flag = 1; - m_fm77av_vsync_timer->adjust(attotime::from_usec(510),1); // VSync length for 200 line modes = 0.51ms - } - else - { - m_video.vsync_flag = 0; - m_fm77av_vsync_timer->adjust(machine().first_screen()->time_until_vblank_end()); - } -} - -// called when banked into main CPU space by the MMR, available only if sub CPU is halted -READ8_MEMBER(fm7_state::fm7_sub_ram_ports_banked_r) -{ - UINT8* RAM = memregion("maincpu")->base(); - UINT8* ROM; - - if(!m_video.sub_halt) - return 0xff; - - if(offset < 0x380) // work RAM - return RAM[0x1d000+offset]; - if(offset >= 0x380 && offset < 0x400) // shared RAM - return m_shared_ram[offset-0x380]; - if(offset >= 0x500 && offset < 0x800) // work RAM - return RAM[0x1d000+offset]; - if(offset > 0x800) // CGROM - { - ROM = memregion("subsyscg")->base(); - return ROM[(m_video.cgrom*0x800)+(offset-0x800)]; - } - - if(offset >= 0x410 && offset <= 0x42b) - return fm77av_alu_r(space,offset-0x410); - - switch(offset) - { - case 0x400: - case 0x401: - return fm7_sub_keyboard_r(space,offset-0x400); - case 0x402: - return fm7_cancel_ack(space,0); - case 0x403: - return fm7_sub_beeper_r(space,0); - case 0x404: - return fm7_attn_irq_r(space,0); - case 0x408: - return fm7_crt_r(space,0); - case 0x409: - return fm7_vram_access_r(space,0); - case 0x40a: - return fm7_sub_busyflag_r(space,0); - case 0x430: - return fm77av_video_flags_r(space,0); - case 0x431: - case 0x432: - return fm77av_key_encoder_r(space,offset-0x431); - default: - logerror("Unmapped read from sub CPU port 0xd%03x via MMR banking\n",offset); - return 0xff; - } -} - -WRITE8_MEMBER(fm7_state::fm7_sub_ram_ports_banked_w) -{ - UINT8* RAM = memregion("maincpu")->base(); - - if(!m_video.sub_halt) - return; - - if(offset < 0x380) // work RAM - { - RAM[0x1d000+offset] = data; - return; - } - if(offset >= 0x380 && offset < 0x400) // shared RAM - { - m_shared_ram[offset-0x380] = data; - return; - } - if(offset >= 0x500 && offset < 0x800) // work RAM - { - RAM[0x1d000+offset] = data; - return; - } - - if(offset >= 0x410 && offset <= 0x42b) - { - fm77av_alu_w(space,offset-0x410,data); - return; - } - - switch(offset) - { - case 0x408: - fm7_crt_w(space,0,data); - break; - case 0x409: - fm7_vram_access_w(space,0,data); - break; - case 0x40a: - fm7_sub_busyflag_w(space,0,data); - break; - case 0x40e: - case 0x40f: - fm7_vram_offset_w(space,offset-0x40e,data); - break; - case 0x430: - fm77av_video_flags_w(space,0,data); - break; - case 0x431: - case 0x432: - fm77av_key_encoder_w(space,offset-0x431,data); - break; - default: - logerror("Unmapped write of 0x%02x to sub CPU port 0xd%03x via MMR banking\n",data,offset); - } -} - -READ8_MEMBER(fm7_state::fm7_console_ram_banked_r) -{ - UINT8* RAM = memregion("maincpu")->base(); - - if(!m_video.sub_halt) - return 0xff; - - return RAM[0x1c000+offset]; -} - -WRITE8_MEMBER(fm7_state::fm7_console_ram_banked_w) -{ - UINT8* RAM = memregion("maincpu")->base(); - - if(!m_video.sub_halt) - return; - - RAM[0x1c000+offset] = data; -} - -void fm7_state::video_start() -{ - m_video.vram_access = 0; - m_video.crt_enable = 0; - m_video.vram_offset = 0x0000; - m_video.vram_offset2 = 0x0000; - m_video.sub_reset = 0; - m_video.multi_page = 0; - m_video.subrom = 0; - m_video.cgrom = 0; - m_video.fine_offset = 0; - m_video.nmi_mask = 0; - m_video.active_video_page = 0; - m_video.display_video_page = 0; - m_video.vsync_flag = 0; -} - -UINT32 fm7_state::screen_update_fm7(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT8 code_r = 0,code_g = 0,code_b = 0; - UINT8 code_r2 = 0,code_g2 = 0,code_b2 = 0; - UINT8 code_r3 = 0,code_g3 = 0,code_b3 = 0; - UINT8 code_r4 = 0,code_g4 = 0,code_b4 = 0; - UINT16 col; - int y, x, b; - UINT16 page = 0x0000; - - if(m_video.display_video_page != 0) - page = 0xc000; - - if(m_video.crt_enable == 0) - return 0; - - if(m_video.modestatus & 0x40) // 320x200 mode - { - for (y = 0; y < 200; y++) - { - for (x = 0; x < 40; x++) - { - if(!(m_video.multi_page & 0x40)) - { - code_r = m_video_ram[0x8000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_r2 = m_video_ram[0xa000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_r3 = m_video_ram[0x14000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - code_r4 = m_video_ram[0x16000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - } - if(!(m_video.multi_page & 0x20)) - { - code_g = m_video_ram[0x4000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_g2 = m_video_ram[0x6000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_g3 = m_video_ram[0x10000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - code_g4 = m_video_ram[0x12000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - } - if(!(m_video.multi_page & 0x10)) - { - code_b = m_video_ram[0x0000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_b2 = m_video_ram[0x2000 + ((y*40 + x + m_video.vram_offset) & 0x1fff)]; - code_b3 = m_video_ram[0xc000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - code_b4 = m_video_ram[0xe000 + ((y*40 + x + m_video.vram_offset2) & 0x1fff)]; - } - for (b = 0; b < 8; b++) - { - col = (((code_b >> b) & 0x01) ? 8 : 0) | (((code_b2 >> b) & 0x01) ? 4 : 0) | (((code_b3 >> b) & 0x01) ? 2 : 0) | (((code_b4 >> b) & 0x01) ? 1 : 0); - col |= (((code_g >> b) & 0x01) ? 128 : 0) | (((code_g2 >> b) & 0x01) ? 64 : 0) | (((code_g3 >> b) & 0x01) ? 32 : 0) | (((code_g4 >> b) & 0x01) ? 16 : 0); - col |= (((code_r >> b) & 0x01) ? 2048 : 0) | (((code_r2 >> b) & 0x01) ? 1024 : 0) | (((code_r3 >> b) & 0x01) ? 512 : 0) | (((code_r4 >> b) & 0x01) ? 256 : 0); - bitmap.pix32(y, x*8+(7-b)) = m_av_palette->pen_color(col); - } - } - } - } - else - { - for (y = 0; y < 200; y++) - { - for (x = 0; x < 80; x++) - { - if(!(m_video.multi_page & 0x40)) - code_r = m_video_ram[page + 0x8000 + ((y*80 + x + m_video.vram_offset) & 0x3fff)]; - if(!(m_video.multi_page & 0x20)) - code_g = m_video_ram[page + 0x4000 + ((y*80 + x + m_video.vram_offset) & 0x3fff)]; - if(!(m_video.multi_page & 0x10)) - code_b = m_video_ram[page + 0x0000 + ((y*80 + x + m_video.vram_offset) & 0x3fff)]; - for (b = 0; b < 8; b++) - { - col = (((code_r >> b) & 0x01) ? 4 : 0) + (((code_g >> b) & 0x01) ? 2 : 0) + (((code_b >> b) & 0x01) ? 1 : 0); - bitmap.pix32(y, x*8+(7-b)) = m_palette->pen_color(col); - } - } - } - } - return 0; -} diff --git a/src/mess/video/fmtowns.c b/src/mess/video/fmtowns.c deleted file mode 100644 index 1790f856bc4..00000000000 --- a/src/mess/video/fmtowns.c +++ /dev/null @@ -1,1729 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Barry Rodewald - -/* - * FM Towns video hardware - * - * Resolution: from 320x200 to 768x512 - * - * Up to two graphics layers - * - * Sprites - * - * CRTC registers (16-bit): - * - * 0: HSync width 1 - * 1: HSync width 2 - * 4: HSync total - * 5: VSync width 1 - * 6: VSync width 2 - * 7: Equalising pulse accountable time (what?) - * 8: VSync total - * - * 9: - * 10: Graphic layer 0 horizontal start/end - * 11: - * 12: Graphic layer 1 horizontal start/end - * - * 13: - * 14: Graphic layer 0 vertical start/end - * 15: - * 16: Graphic layer 1 vertical start/end - * - * 17: Graphic layer 0 initial address? - * 18: Graphic layer 0 horizontal adjust - * 19: Graphic layer 0 field indirect address offset - * 20: Graphic layer 0 line indirect address offset - * - * 21-24: As above, but for Graphic layer 1 - * - * 27: Layer zoom. bit 0 = x2 horizontal zoom layer 0 - * to be confirmed bit 5 = x2 vertical zoom layer 0 - * bit 9 = x2 horizontal zoom layer 1 - * bit 13 = x2 vertical zoom layer 1 - * - * 28: Control register 0 - * VSync enable (bit 15) (blank display?) - * Scroll type (layer 0 = bit 4, layer 1 = bit 5) - * 0 = spherical scroll, 1 = cylindrical scroll - * - * 29: Control register 1 - * Dot clock (bits 1 and 0) - * 0x00 = 28.6363MHz - * 0x01 = 24.5454MHz - * 0x02 = 25.175MHz - * 0x03 = 21.0525MHz (default?) - * - * 30: Dummy register - * - * 31: Control register 2 - * - * Video registers: - * - * 0: Graphic layer(s) type: (others likely exist) - * bit 4 = 2 layers - * bits 2-3 = layer 1 mode - * bits 0-1 = layer 0 mode - * mode: 1 = 16 colours, 2 = 256 colours, 3 = highcolour (16-bit) - * 0 = disabled? - * - * 1: Layer reverse (priority?) (bit 0) - * YM (bit 2) - unknown - * peltype (bits 4 and 5) - * - * - * Sprite registers: - * - * 0,1: Maximum sprite (last one to render?) (10-bit) - * - * 1 (bit 7): Enable sprite display - * - * 2,3: X offset (9-bit) - * - * 4,5: Y offset (9-bit) - * - * 6 (bit 4): VRAM location (0=0x40000,1=0x60000) - * - */ - -#include "emu.h" -#include "machine/pic8259.h" -#include "machine/ram.h" -#include "includes/fmtowns.h" - -//#define CRTC_REG_DISP 1 -//#define SPR_DEBUG 1 - -//static UINT32 pshift; // for debugging - -void towns_state::towns_crtc_refresh_mode() -{ - unsigned int width,height; - - rectangle scr(0, m_video.towns_crtc_reg[4], 0, m_video.towns_crtc_reg[8] / 2); - - // layer 0 - width = m_video.towns_crtc_reg[10] - m_video.towns_crtc_reg[9]; - height = (m_video.towns_crtc_reg[14] - m_video.towns_crtc_reg[13]) / 2; - m_video.towns_crtc_layerscr[0].min_x = scr.xcenter() - (width / 2); - m_video.towns_crtc_layerscr[0].min_y = scr.ycenter() - (height / 2); - m_video.towns_crtc_layerscr[0].max_x = scr.xcenter() + (width / 2); - m_video.towns_crtc_layerscr[0].max_y = scr.ycenter() + (height / 2); - - // layer 1 - width = m_video.towns_crtc_reg[12] - m_video.towns_crtc_reg[11]; - height = (m_video.towns_crtc_reg[16] - m_video.towns_crtc_reg[15]) / 2; - m_video.towns_crtc_layerscr[1].min_x = scr.xcenter() - (width / 2); - m_video.towns_crtc_layerscr[1].min_y = scr.ycenter() - (height / 2); - m_video.towns_crtc_layerscr[1].max_x = scr.xcenter() + (width / 2); - m_video.towns_crtc_layerscr[1].max_y = scr.ycenter() + (height / 2); - - // sanity checks - if(scr.max_x == 0 || scr.max_y == 0) - return; - if(scr.max_x <= scr.min_x || scr.max_y <= scr.min_y) - return; - - machine().first_screen()->configure(scr.max_x+1,scr.max_y+1,scr,HZ_TO_ATTOSECONDS(60)); -} - -READ8_MEMBER( towns_state::towns_gfx_high_r ) -{ - return m_towns_gfxvram[offset]; -} - -WRITE8_MEMBER( towns_state::towns_gfx_high_w ) -{ - m_towns_gfxvram[offset] = data; -} - -READ8_MEMBER( towns_state::towns_gfx_r ) -{ - UINT8 ret = 0; - - if(m_towns_mainmem_enable != 0) - return m_messram->pointer()[offset+0xc0000]; - - offset = offset << 2; - - if(m_video.towns_vram_page_sel != 0) - offset += 0x20000; - - ret = (((m_towns_gfxvram[offset] >> m_video.towns_vram_rplane) << 7) & 0x80) - | (((m_towns_gfxvram[offset] >> m_video.towns_vram_rplane) << 2) & 0x40) - | (((m_towns_gfxvram[offset+1] >> m_video.towns_vram_rplane) << 5) & 0x20) - | (((m_towns_gfxvram[offset+1] >> m_video.towns_vram_rplane)) & 0x10) - | (((m_towns_gfxvram[offset+2] >> m_video.towns_vram_rplane) << 3) & 0x08) - | (((m_towns_gfxvram[offset+2] >> m_video.towns_vram_rplane) >> 2) & 0x04) - | (((m_towns_gfxvram[offset+3] >> m_video.towns_vram_rplane) << 1) & 0x02) - | (((m_towns_gfxvram[offset+3] >> m_video.towns_vram_rplane) >> 4) & 0x01); - - return ret; -} - -WRITE8_MEMBER( towns_state::towns_gfx_w ) -{ - if(m_towns_mainmem_enable != 0) - { - m_messram->pointer()[offset+0xc0000] = data; - return; - } - offset = offset << 2; - if(m_video.towns_vram_page_sel != 0) - offset += 0x20000; - if(m_video.towns_vram_wplane & 0x08) - { - m_towns_gfxvram[offset] &= ~0x88; - m_towns_gfxvram[offset] |= ((data & 0x80) >> 4) | ((data & 0x40) << 1); - m_towns_gfxvram[offset + 1] &= ~0x88; - m_towns_gfxvram[offset + 1] |= ((data & 0x20) >> 2) | ((data & 0x10) << 3); - m_towns_gfxvram[offset + 2] &= ~0x88; - m_towns_gfxvram[offset + 2] |= ((data & 0x08)) | ((data & 0x04) << 5); - m_towns_gfxvram[offset + 3] &= ~0x88; - m_towns_gfxvram[offset + 3] |= ((data & 0x02) << 2) | ((data & 0x01) << 7); - } - if(m_video.towns_vram_wplane & 0x04) - { - m_towns_gfxvram[offset] &= ~0x44; - m_towns_gfxvram[offset] |= ((data & 0x80) >> 5) | ((data & 0x40)); - m_towns_gfxvram[offset + 1] &= ~0x44; - m_towns_gfxvram[offset + 1] |= ((data & 0x20) >> 3) | ((data & 0x10) << 2); - m_towns_gfxvram[offset + 2] &= ~0x44; - m_towns_gfxvram[offset + 2] |= ((data & 0x08) >> 1) | ((data & 0x04) << 4); - m_towns_gfxvram[offset + 3] &= ~0x44; - m_towns_gfxvram[offset + 3] |= ((data & 0x02) << 1) | ((data & 0x01) << 6); - } - if(m_video.towns_vram_wplane & 0x02) - { - m_towns_gfxvram[offset] &= ~0x22; - m_towns_gfxvram[offset] |= ((data & 0x80) >> 6) | ((data & 0x40) >> 1); - m_towns_gfxvram[offset + 1] &= ~0x22; - m_towns_gfxvram[offset + 1] |= ((data & 0x20) >> 4) | ((data & 0x10) << 1); - m_towns_gfxvram[offset + 2] &= ~0x22; - m_towns_gfxvram[offset + 2] |= ((data & 0x08) >> 2) | ((data & 0x04) << 3); - m_towns_gfxvram[offset + 3] &= ~0x22; - m_towns_gfxvram[offset + 3] |= ((data & 0x02)) | ((data & 0x01) << 5); - } - if(m_video.towns_vram_wplane & 0x01) - { - m_towns_gfxvram[offset] &= ~0x11; - m_towns_gfxvram[offset] |= ((data & 0x80) >> 7) | ((data & 0x40) >> 2); - m_towns_gfxvram[offset + 1] &= ~0x11; - m_towns_gfxvram[offset + 1] |= ((data & 0x20) >> 5) | ((data & 0x10)); - m_towns_gfxvram[offset + 2] &= ~0x11; - m_towns_gfxvram[offset + 2] |= ((data & 0x08) >> 3) | ((data & 0x04) << 2); - m_towns_gfxvram[offset + 3] &= ~0x11; - m_towns_gfxvram[offset + 3] |= ((data & 0x02) >> 1) | ((data & 0x01) << 4); - } -} - -void towns_state::towns_update_kanji_offset() -{ - // this is a little over the top... - if(m_video.towns_kanji_code_h < 0x30) - { - m_video.towns_kanji_offset = ((m_video.towns_kanji_code_l & 0x1f) << 4) - | (((m_video.towns_kanji_code_l - 0x20) & 0x20) << 8) - | (((m_video.towns_kanji_code_l - 0x20) & 0x40) << 6) - | ((m_video.towns_kanji_code_h & 0x07) << 9); - } - else if(m_video.towns_kanji_code_h < 0x70) - { - m_video.towns_kanji_offset = ((m_video.towns_kanji_code_l & 0x1f) << 4) - + (((m_video.towns_kanji_code_l - 0x20) & 0x60) << 8) - + ((m_video.towns_kanji_code_h & 0x0f) << 9) - + (((m_video.towns_kanji_code_h - 0x30) & 0x70) * 0xc00) - + 0x8000; - } - else - { - m_video.towns_kanji_offset = ((m_video.towns_kanji_code_l & 0x1f) << 4) - | (((m_video.towns_kanji_code_l - 0x20) & 0x20) << 8) - | (((m_video.towns_kanji_code_l - 0x20) & 0x40) << 6) - | ((m_video.towns_kanji_code_h & 0x07) << 9) - | 0x38000; - } -} - -READ8_MEMBER( towns_state::towns_video_cff80_r ) -{ - UINT8* ROM = m_user->base(); - - switch(offset) - { - case 0x00: // mix register - return m_video.towns_crtc_mix; - case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) - return ((m_video.towns_vram_rplane << 6) & 0xc0) | m_video.towns_vram_wplane; - case 0x02: // display planes (bits 0-2,5), display page select (bit 4) - return m_video.towns_display_plane | m_video.towns_display_page_sel; - case 0x03: // VRAM page select (bit 5) - if(m_video.towns_vram_page_sel != 0) - return 0x10; - else - return 0x00; - case 0x06: - if(m_video.towns_vblank_flag != 0) - return 0x10; - else - return 0x00; - case 0x16: // Kanji character data - return ROM[(m_video.towns_kanji_offset << 1) + 0x180000]; - case 0x17: // Kanji character data - return ROM[(m_video.towns_kanji_offset++ << 1) + 0x180001]; - case 0x19: // ANK CG ROM - if(m_towns_ankcg_enable != 0) - return 0x01; - else - return 0x00; - default: - logerror("VGA: read from invalid or unimplemented memory-mapped port %05x\n",0xcff80+offset*4); - } - - return 0; -} - -WRITE8_MEMBER( towns_state::towns_video_cff80_w ) -{ - switch(offset) - { - case 0x00: // mix register - m_video.towns_crtc_mix = data; - break; - case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) - m_video.towns_vram_wplane = data & 0x0f; - m_video.towns_vram_rplane = (data & 0xc0) >> 6; - towns_update_video_banks(space); - //logerror("VGA: VRAM wplane select = 0x%02x\n",towns_vram_wplane); - break; - case 0x02: // display plane (bits 0-2), display page select (bit 4) - m_video.towns_display_plane = data & 0x27; - m_video.towns_display_page_sel = data & 0x10; - break; - case 0x03: // VRAM page select (bit 4) - m_video.towns_vram_page_sel = data & 0x10; - break; - case 0x14: // Kanji offset (high) - m_video.towns_kanji_code_h = data & 0x7f; - towns_update_kanji_offset(); - //logerror("VID: Kanji code set (high) = %02x %02x\n",towns_kanji_code_h,towns_kanji_code_l); - break; - case 0x15: // Kanji offset (low) - m_video.towns_kanji_code_l = data & 0x7f; - towns_update_kanji_offset(); - //logerror("VID: Kanji code set (low) = %02x %02x\n",towns_kanji_code_h,towns_kanji_code_l); - break; - case 0x19: // ANK CG ROM - m_towns_ankcg_enable = data & 0x01; - towns_update_video_banks(space); - break; - default: - logerror("VGA: write %08x to invalid or unimplemented memory-mapped port %05x\n",data,0xcff80+offset); - } -} - -READ8_MEMBER( towns_state::towns_video_cff80_mem_r ) -{ - if(m_towns_mainmem_enable != 0) - return m_messram->pointer()[offset+0xcff80]; - - return towns_video_cff80_r(space,offset); -} - -WRITE8_MEMBER( towns_state::towns_video_cff80_mem_w ) -{ - if(m_towns_mainmem_enable != 0) - { - m_messram->pointer()[offset+0xcff80] = data; - return; - } - towns_video_cff80_w(space,offset,data); -} - -/* - * port 0x440-0x443 - CRTC - * 0x440 = register select - * 0x442/3 = register data (16-bit) - * 0x448 = shifter register select - * 0x44a = shifter register data (8-bit) - * - */ -READ8_MEMBER(towns_state::towns_video_440_r) -{ - UINT8 ret = 0; - UINT16 xpos,ypos; - - switch(offset) - { - case 0x00: - return m_video.towns_crtc_sel; - case 0x02: -// logerror("CRTC: reading register %i (0x442) [%04x]\n",towns_crtc_sel,towns_crtc_reg[towns_crtc_sel]); - if(m_video.towns_crtc_sel == 30) - return 0x00; - return m_video.towns_crtc_reg[m_video.towns_crtc_sel] & 0x00ff; - case 0x03: -// logerror("CRTC: reading register %i (0x443) [%04x]\n",towns_crtc_sel,towns_crtc_reg[towns_crtc_sel]); - if(m_video.towns_crtc_sel == 30) - { - // check video position - xpos = space.machine().first_screen()->hpos(); - ypos = space.machine().first_screen()->vpos(); - - if(xpos < (m_video.towns_crtc_reg[0] & 0xfe)) - ret |= 0x02; - if(ypos < (m_video.towns_crtc_reg[6] & 0x1f)) - ret |= 0x04; - if(xpos < m_video.towns_crtc_layerscr[0].max_x && xpos > m_video.towns_crtc_layerscr[0].min_x) - ret |= 0x10; - if(xpos < m_video.towns_crtc_layerscr[1].max_x && xpos > m_video.towns_crtc_layerscr[1].min_x) - ret |= 0x20; - if(ypos < m_video.towns_crtc_layerscr[0].max_y && ypos > m_video.towns_crtc_layerscr[0].min_y) - ret |= 0x40; - if(ypos < m_video.towns_crtc_layerscr[1].max_y && ypos > m_video.towns_crtc_layerscr[1].min_y) - ret |= 0x80; - - return ret; - } - return (m_video.towns_crtc_reg[m_video.towns_crtc_sel] & 0xff00) >> 8; - case 0x08: - return m_video.towns_video_sel; - case 0x0a: - logerror("Video: reading register %i (0x44a) [%02x]\n",m_video.towns_video_sel,m_video.towns_video_reg[m_video.towns_video_sel]); - return m_video.towns_video_reg[m_video.towns_video_sel]; - case 0x0c: - if(m_video.towns_dpmd_flag != 0) - { - m_video.towns_dpmd_flag = 0; - ret |= 0x80; - } - ret |= (m_video.towns_sprite_flag ? 0x02 : 0x00); // Sprite drawing flag - ret |= m_video.towns_sprite_page & 0x01; - return ret; - case 0x10: - return m_video.towns_sprite_sel; - case 0x12: - logerror("SPR: reading register %i (0x452) [%02x]\n",m_video.towns_sprite_sel,m_video.towns_sprite_reg[m_video.towns_sprite_sel]); - return m_video.towns_sprite_reg[m_video.towns_sprite_sel]; - //default: - //logerror("VID: read port %04x\n",offset+0x440); - } - return 0x00; -} - -WRITE8_MEMBER(towns_state::towns_video_440_w) -{ - switch(offset) - { - case 0x00: - m_video.towns_crtc_sel = data; - break; - case 0x02: -// logerror("CRTC: writing register %i (0x442) [%02x]\n",towns_crtc_sel,data); - m_video.towns_crtc_reg[m_video.towns_crtc_sel] = - (m_video.towns_crtc_reg[m_video.towns_crtc_sel] & 0xff00) | data; - towns_crtc_refresh_mode(); - break; - case 0x03: -// logerror("CRTC: writing register %i (0x443) [%02x]\n",towns_crtc_sel,data); - m_video.towns_crtc_reg[m_video.towns_crtc_sel] = - (m_video.towns_crtc_reg[m_video.towns_crtc_sel] & 0x00ff) | (data << 8); - towns_crtc_refresh_mode(); - break; - case 0x08: - m_video.towns_video_sel = data & 0x01; - break; - case 0x0a: - logerror("Video: writing register %i (0x44a) [%02x]\n",m_video.towns_video_sel,data); - m_video.towns_video_reg[m_video.towns_video_sel] = data; - break; - case 0x10: - m_video.towns_sprite_sel = data & 0x07; - break; - case 0x12: - logerror("SPR: writing register %i (0x452) [%02x]\n",m_video.towns_sprite_sel,data); - m_video.towns_sprite_reg[m_video.towns_sprite_sel] = data; - break; - default: - logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x440); - } -} - -READ8_MEMBER(towns_state::towns_video_5c8_r) -{ - //logerror("VID: read port %04x\n",offset+0x5c8); - switch(offset) - { - case 0x00: // 0x5c8 - disable TVRAM? - if(m_video.towns_tvram_enable != 0) - { - m_video.towns_tvram_enable = 0; - return 0x80; - } - else - return 0x00; - } - return 0x00; -} - -WRITE8_MEMBER(towns_state::towns_video_5c8_w) -{ - pic8259_device* dev = m_pic_slave; - - switch(offset) - { - case 0x02: // 0x5ca - VSync clear? - dev->ir3_w(0); - if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set low\n"); - //towns_vblank_flag = 0; - break; - } - logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x5c8); -} - -void towns_state::towns_update_palette() -{ - UINT8 entry = m_video.towns_palette_select; - UINT8 r = m_video.towns_palette_r[entry]; - UINT8 g = m_video.towns_palette_g[entry]; - UINT8 b = m_video.towns_palette_b[entry]; - m_palette->set_pen_color(entry, r, g, b); -} - -/* Video/CRTC - * - * 0xfd90 - palette colour select - * 0xfd92/4/6 - BRG value - * 0xfd98-9f - degipal(?) - */ -READ8_MEMBER(towns_state::towns_video_fd90_r) -{ - UINT8 ret = 0; - UINT16 xpos; - -// logerror("VID: read port %04x\n",offset+0xfd90); - switch(offset) - { - case 0x00: - return m_video.towns_palette_select; - case 0x02: - return m_video.towns_palette_b[m_video.towns_palette_select]; - case 0x04: - return m_video.towns_palette_r[m_video.towns_palette_select]; - case 0x06: - return m_video.towns_palette_g[m_video.towns_palette_select]; - case 0x08: - case 0x09: - case 0x0a: - case 0x0b: - case 0x0c: - case 0x0d: - case 0x0e: - case 0x0f: - return m_video.towns_degipal[offset-0x08]; - case 0x10: // "sub status register" - // check video position - xpos = space.machine().first_screen()->hpos(); - - if(xpos < m_video.towns_crtc_layerscr[0].max_x && xpos > m_video.towns_crtc_layerscr[0].min_x) - ret |= 0x02; - if(m_video.towns_vblank_flag) - ret |= 0x01; - return ret; - } - return 0x00; -} - -WRITE8_MEMBER(towns_state::towns_video_fd90_w) -{ - switch(offset) - { - case 0x00: - m_video.towns_palette_select = data; - break; - case 0x02: - m_video.towns_palette_b[m_video.towns_palette_select] = data; - towns_update_palette(); - break; - case 0x04: - m_video.towns_palette_r[m_video.towns_palette_select] = data; - towns_update_palette(); - break; - case 0x06: - m_video.towns_palette_g[m_video.towns_palette_select] = data; - towns_update_palette(); - break; - case 0x08: - case 0x09: - case 0x0a: - case 0x0b: - case 0x0c: - case 0x0d: - case 0x0e: - case 0x0f: - m_video.towns_degipal[offset-0x08] = data; - m_video.towns_dpmd_flag = 1; - break; - case 0x10: - m_video.towns_layer_ctrl = data; - break; - } - logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90); -} - -READ8_MEMBER(towns_state::towns_video_ff81_r) -{ - return ((m_video.towns_vram_rplane << 6) & 0xc0) | m_video.towns_vram_wplane; -} - -WRITE8_MEMBER(towns_state::towns_video_ff81_w) -{ - m_video.towns_vram_wplane = data & 0x0f; - m_video.towns_vram_rplane = (data & 0xc0) >> 6; - towns_update_video_banks(space); - logerror("VGA: VRAM wplane select (I/O) = 0x%02x\n",m_video.towns_vram_wplane); -} - -READ8_MEMBER(towns_state::towns_video_unknown_r) -{ - return 0x00; -} - -/* - * Sprite RAM, low memory - * Writing to 0xc8xxx or 0xcaxxx activates TVRAM - * Writing to I/O port 0x5c8 disables TVRAM - * (bit 7 returns high if TVRAM was previously active) - * - * In TVRAM mode: - * 0xc8000-0xc8fff: ASCII text (2 bytes each: ISO646 code, then attribute) - * 0xca000-0xcafff: JIS code - */ -READ8_MEMBER(towns_state::towns_spriteram_low_r) -{ - UINT8* RAM = m_messram->pointer(); - UINT8* ROM = m_user->base(); - - if(offset < 0x1000) - { // 0xc8000-0xc8fff - if(m_towns_mainmem_enable == 0) - { -// if(towns_tvram_enable == 0) -// return towns_sprram[offset]; -// else - return m_towns_txtvram[offset]; - } - else - return RAM[offset + 0xc8000]; - } - if(offset >= 0x1000 && offset < 0x2000) - { // 0xc9000-0xc9fff - return RAM[offset + 0xc9000]; - } - if(offset >= 0x2000 && offset < 0x3000) - { // 0xca000-0xcafff - if(m_towns_mainmem_enable == 0) - { - if(m_towns_ankcg_enable != 0 && offset < 0x2800) - return ROM[0x180000 + 0x3d000 + (offset-0x2000)]; -// if(towns_tvram_enable == 0) -// return m_towns_sprram[offset]; -// else - return m_towns_txtvram[offset]; - } - else - return RAM[offset + 0xca000]; - } - return 0x00; -} - -WRITE8_MEMBER(towns_state::towns_spriteram_low_w) -{ - UINT8* RAM = m_messram->pointer(); - - if(offset < 0x1000) - { // 0xc8000-0xc8fff - m_video.towns_tvram_enable = 1; - if(m_towns_mainmem_enable == 0) - m_towns_txtvram[offset] = data; - else - RAM[offset + 0xc8000] = data; - } - if(offset >= 0x1000 && offset < 0x2000) - { - RAM[offset + 0xc9000] = data; - } - if(offset >= 0x2000 && offset < 0x3000) - { // 0xca000-0xcafff - m_video.towns_tvram_enable = 1; - if(m_towns_mainmem_enable == 0) - m_towns_txtvram[offset] = data; - else - RAM[offset + 0xca000] = data; - } -} - -READ8_MEMBER( towns_state::towns_spriteram_r ) -{ - return m_towns_txtvram[offset]; -} - -WRITE8_MEMBER( towns_state::towns_spriteram_w ) -{ - m_towns_txtvram[offset] = data; -} - -/* - * Sprites - * - * Max. 1024, 16x16, 16 colours per sprite - * 128kB Sprite RAM (8kB attributes, 120kB pattern/colour data) - * Sprites are rendered directly to VRAM layer 1 (VRAM offset 0x40000 or 0x60000) - * - * Sprite RAM format: - * 4 words per sprite - * +0: X position (10-bit) - * +2: Y position (10-bit) - * +4: Sprite Attribute - * bit 15: enforce offsets (regs 2-5) - * bit 12,13: flip sprite - * bits 10-0: Sprite RAM offset containing sprite pattern - * TODO: other attributes (zoom?) - * +6: Sprite Colour - * bit 15: use colour data in located in sprite RAM offset in bits 11-0 (x32) - */ -void towns_state::render_sprite_4(UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) -{ - UINT16 xpos,ypos; - UINT16 col,pixel; - UINT32 voffset; - UINT16 xstart,xend,ystart,yend; - int xdir,ydir; - int width = (m_video.towns_crtc_reg[12] - m_video.towns_crtc_reg[11]) / (((m_video.towns_crtc_reg[27] & 0x0f00) >> 8)+1); - int height = (m_video.towns_crtc_reg[16] - m_video.towns_crtc_reg[15]) / (((m_video.towns_crtc_reg[27] & 0xf000) >> 12)+2); - - if(xflip) - { - xstart = x+14; - xend = x-2; - xdir = -2; - } - else - { - xstart = x+1; - xend = x+17; - xdir = 2; - } - if(yflip) - { - ystart = y+15; - yend = y-1; - ydir = -1; - } - else - { - ystart = y; - yend = y+16; - ydir = 1; - } - xstart &= 0x1ff; - xend &= 0x1ff; - ystart &= 0x1ff; - yend &= 0x1ff; - poffset &= 0x1ffff; - - for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff) - { - for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff) - { - if(m_video.towns_sprite_page != 0) - voffset = 0x20000; - else - voffset = 0x00000; - pixel = (m_towns_txtvram[poffset] & 0xf0) >> 4; - col = m_towns_txtvram[coffset+(pixel*2)] | (m_towns_txtvram[coffset+(pixel*2)+1] << 8); - voffset += (m_video.towns_crtc_reg[24] * 4) * (ypos & 0x1ff); // scanline size in bytes * y pos - voffset += (xpos & 0x1ff) * 2; - if((m_video.towns_sprite_page != 0 && voffset > 0x1ffff && voffset < 0x40000) - || (m_video.towns_sprite_page == 0 && voffset < 0x20000)) - { - if(xpos < width && ypos < height && pixel != 0) - { - m_towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8; - m_towns_gfxvram[0x40000+voffset] = col & 0x00ff; - } - } - if(xflip) - voffset+=2; - else - voffset-=2; - pixel = m_towns_txtvram[poffset] & 0x0f; - col = m_towns_txtvram[coffset+(pixel*2)] | (m_towns_txtvram[coffset+(pixel*2)+1] << 8); - if((m_video.towns_sprite_page != 0 && voffset > 0x1ffff && voffset < 0x40000) - || (m_video.towns_sprite_page == 0 && voffset < 0x20000)) - { - if(xpos < width && ypos < height && pixel != 0) - { - m_towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8; - m_towns_gfxvram[0x40000+voffset] = col & 0x00ff; - } - } - poffset++; - poffset &= 0x1ffff; - } - } -} - -void towns_state::render_sprite_16(UINT32 poffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) -{ - UINT16 xpos,ypos; - UINT16 col; - UINT32 voffset; - UINT16 xstart,ystart,xend,yend; - int xdir,ydir; - int width = (m_video.towns_crtc_reg[12] - m_video.towns_crtc_reg[11]) / (((m_video.towns_crtc_reg[27] & 0x0f00) >> 8)+1); - int height = (m_video.towns_crtc_reg[16] - m_video.towns_crtc_reg[15]) / (((m_video.towns_crtc_reg[27] & 0xf000) >> 12)+2); - - if(xflip) - { - xstart = x+16; - xend = x; - xdir = -1; - } - else - { - xstart = x+1; - xend = x+17; - xdir = 1; - } - if(yflip) - { - ystart = y+15; - yend = y-1; - ydir = -1; - } - else - { - ystart = y; - yend = y+16; - ydir = 1; - } - xstart &= 0x1ff; - xend &= 0x1ff; - ystart &= 0x1ff; - yend &= 0x1ff; - poffset &= 0x1ffff; - - for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff) - { - for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff) - { - if(m_video.towns_sprite_page != 0) - voffset = 0x20000; - else - voffset = 0x00000; - col = m_towns_txtvram[poffset] | (m_towns_txtvram[poffset+1] << 8); - voffset += (m_video.towns_crtc_reg[24] * 4) * (ypos & 0x1ff); // scanline size in bytes * y pos - voffset += (xpos & 0x1ff) * 2; - if((m_video.towns_sprite_page != 0 && voffset > 0x1ffff && voffset < 0x40000) - || (m_video.towns_sprite_page == 0 && voffset < 0x20000)) - { - if(xpos < width && ypos < height && col < 0x8000) - { - m_towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8; - m_towns_gfxvram[0x40000+voffset] = col & 0x00ff; - } - } - poffset+=2; - poffset &= 0x1ffff; - } - } -} - -void towns_state::draw_sprites(const rectangle* rect) -{ - UINT16 sprite_limit = (m_video.towns_sprite_reg[0] | (m_video.towns_sprite_reg[1] << 8)) & 0x3ff; - int n; - UINT16 x,y,attr,colour; - UINT16 xoff = (m_video.towns_sprite_reg[2] | (m_video.towns_sprite_reg[3] << 8)) & 0x1ff; - UINT16 yoff = (m_video.towns_sprite_reg[4] | (m_video.towns_sprite_reg[5] << 8)) & 0x1ff; - UINT32 poffset,coffset; - - if(!(m_video.towns_sprite_reg[1] & 0x80)) - return; - - // clears VRAM for each frame? - if(m_video.towns_sprite_page == 0) - memset(m_towns_gfxvram+0x40000,0x80,0x20000); - else - memset(m_towns_gfxvram+0x60000,0x80,0x20000); - - for(n=sprite_limit;n<1024;n++) - { - x = m_towns_txtvram[8*n] | (m_towns_txtvram[8*n+1] << 8); - y = m_towns_txtvram[8*n+2] | (m_towns_txtvram[8*n+3] << 8); - attr = m_towns_txtvram[8*n+4] | (m_towns_txtvram[8*n+5] << 8); - colour = m_towns_txtvram[8*n+6] | (m_towns_txtvram[8*n+7] << 8); - if(attr & 0x8000) - { - x += xoff; - y += yoff; - } - x &= 0x1ff; - y &= 0x1ff; - - if(colour & 0x8000) - { - poffset = (attr & 0x3ff) << 7; - coffset = (colour & 0xfff) << 5; -#ifdef SPR_DEBUG - printf("Sprite4 #%i, X %i Y %i Attr %04x Col %04x Poff %08x Coff %08x\n", - n,x,y,attr,colour,poffset,coffset); -#endif - if(!(colour & 0x2000)) - render_sprite_4((poffset)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect); - } - else - { - poffset = (attr & 0x3ff) << 7; -#ifdef SPR_DEBUG - printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %08x", - n,x,y,attr,colour,poffset); -#endif - if(!(colour & 0x2000)) - render_sprite_16((poffset)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect); - } - } - - if(m_video.towns_sprite_page == 0) // flip VRAM page - m_video.towns_sprite_page = 1; - else - m_video.towns_sprite_page = 0; - - m_video.towns_sprite_flag = 1; // we are now drawing - m_video.sprite_timer->adjust(m_maincpu->cycles_to_attotime(128 * (1025-sprite_limit))); -} - -void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const rectangle* rect,int layer,int line,int scanline) -{ - UINT32 off = 0; - int x; - UINT16 colour; - int hzoom = 1; - int linesize; - UINT32 scroll; - - if(layer == 0) - linesize = m_video.towns_crtc_reg[20] * 4; - else - linesize = m_video.towns_crtc_reg[24] * 4; - - if(m_video.towns_display_page_sel != 0) - off = 0x20000; - -// if((layer == 1) && (m_video.towns_sprite_reg[1] & 0x80) && (m_video.towns_sprite_page == 1)) -// off = 0x20000; - - if(layer != 0) - { - if(!(m_video.towns_video_reg[0] & 0x10)) - return; - if(!(m_video.towns_crtc_reg[28] & 0x10)) - off += (m_video.towns_crtc_reg[21]) << 2; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[21] & 0xfc00) << 2) | (((m_video.towns_crtc_reg[21] & 0x3ff) << 2)); - off += scroll; - } - off += (m_video.towns_crtc_reg[11] - m_video.towns_crtc_reg[22]); - hzoom = ((m_video.towns_crtc_reg[27] & 0x0f00) >> 8) + 1; - } - else - { - if(!(m_video.towns_crtc_reg[28] & 0x20)) - off += (m_video.towns_crtc_reg[17]) << 2; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[17] & 0xfc00) << 2) | (((m_video.towns_crtc_reg[17] & 0x3ff) << 2)); - off += scroll; - } - off += (m_video.towns_crtc_reg[9] - m_video.towns_crtc_reg[18]); - hzoom = (m_video.towns_crtc_reg[27] & 0x000f) + 1; - } - - off += line * linesize; - off &= ~0x01; - - if(hzoom == 1) - { - for(x=rect->min_x;xmax_x;x++) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - - colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)]; - if(colour < 0x8000) - { - bitmap.pix32(scanline, x) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - } - off+=2; - } - } - - if(hzoom == 2) - { // x2 horizontal zoom - for(x=rect->min_x;xmax_x;x+=2) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)]; - if(colour < 0x8000) - { - bitmap.pix32(scanline, x) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+1) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - } - off+=2; - } - } - - if(hzoom == 3) - { // x3 horizontal zoom - for(x=rect->min_x;xmax_x;x+=3) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)]; - if(colour < 0x8000) - { - bitmap.pix32(scanline, x) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+1) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+2) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - } - off+=2; - } - } - - if(hzoom == 4) - { // x4 horizontal zoom - for(x=rect->min_x;xmax_x;x+=4) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)]; - if(colour < 0x8000) - { - bitmap.pix32(scanline, x) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+1) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+2) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+3) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - } - off+=2; - } - } - - if(hzoom == 5) - { // x5 horizontal zoom - for(x=rect->min_x;xmax_x;x+=5) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = (m_towns_gfxvram[off+(layer*0x40000)+1] << 8) | m_towns_gfxvram[off+(layer*0x40000)]; - if(colour < 0x8000) - { - bitmap.pix32(scanline, x) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+1) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+2) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+3) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - bitmap.pix32(scanline, x+4) = - ((colour & 0x001f) << 3) - | ((colour & 0x7c00) << 1) - | ((colour & 0x03e0) << 14); - } - off+=2; - } - } -} - -void towns_state::towns_crtc_draw_scan_layer_256(bitmap_rgb32 &bitmap,const rectangle* rect,int layer,int line,int scanline) -{ - int off = 0; - int x; - UINT8 colour; - int hzoom = 1; - int linesize; - UINT32 scroll; - - if(m_video.towns_display_page_sel != 0) - off = 0x20000; - -// if((layer == 1) && (m_video.towns_sprite_reg[1] & 0x80) && (m_video.towns_sprite_page == 1)) -// off = 0x20000; - - if(layer == 0) - linesize = m_video.towns_crtc_reg[20] * 8; - else - linesize = m_video.towns_crtc_reg[24] * 8; - - if(layer != 0) - { - if(!(m_video.towns_video_reg[0] & 0x10)) - return; - if(!(m_video.towns_crtc_reg[28] & 0x10)) - off += m_video.towns_crtc_reg[21] << 3; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[21] & 0xfc00) << 3) | (((m_video.towns_crtc_reg[21] & 0x3ff) << 3)); - off += scroll; - } - off += (m_video.towns_crtc_reg[11] - m_video.towns_crtc_reg[22]); - hzoom = ((m_video.towns_crtc_reg[27] & 0x0f00) >> 8) + 1; - } - else - { - if(!(m_video.towns_crtc_reg[28] & 0x20)) - off += m_video.towns_crtc_reg[17] << 3; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[17] & 0xfc00) << 3) | (((m_video.towns_crtc_reg[17] & 0x3ff) << 3)); - off += scroll; - } - off += (m_video.towns_crtc_reg[9] - m_video.towns_crtc_reg[18]); - hzoom = (m_video.towns_crtc_reg[27] & 0x000f) + 1; - } - - off += line * linesize; - - if(hzoom == 1) - { - for(x=rect->min_x;xmax_x;x++) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)]; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 2) - { // x2 horizontal zoom - for(x=rect->min_x;xmax_x;x+=2) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)+1]; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 3) - { // x3 horizontal zoom - for(x=rect->min_x;xmax_x;x+=3) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)+1]; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 4) - { // x4 horizontal zoom - for(x=rect->min_x;xmax_x;x+=4) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)+1]; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 5) - { // x5 horizontal zoom - for(x=rect->min_x;xmax_x;x+=5) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)+1]; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - bitmap.pix32(scanline, x+4) = m_palette->pen(colour); - } - off++; - } - } -} - -void towns_state::towns_crtc_draw_scan_layer_16(bitmap_rgb32 &bitmap,const rectangle* rect,int layer,int line,int scanline) -{ - int off = 0; - int x; - UINT8 colour; - int hzoom = 1; - int linesize; - UINT32 scroll; - - if(m_video.towns_display_page_sel != 0) - off = 0x20000; - -// if((layer == 1) && (m_video.towns_sprite_reg[1] & 0x80) && (m_video.towns_sprite_page == 1)) -// off = 0x20000; - - if(layer == 0) - linesize = m_video.towns_crtc_reg[20] * 4; - else - linesize = m_video.towns_crtc_reg[24] * 4; - - if(layer != 0) - { - if(!(m_video.towns_video_reg[0] & 0x10)) - return; - if(!(m_video.towns_crtc_reg[28] & 0x10)) - off += m_video.towns_crtc_reg[21]; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[21] & 0xfc00)<<2) | (((m_video.towns_crtc_reg[21] & 0x3ff)<<2)); - off += scroll; - } - off += (m_video.towns_crtc_reg[11] - m_video.towns_crtc_reg[22]); - hzoom = ((m_video.towns_crtc_reg[27] & 0x0f00) >> 8) + 1; - } - else - { - if(!(m_video.towns_crtc_reg[28] & 0x20)) - off += m_video.towns_crtc_reg[17]; // initial offset - else - { - scroll = ((m_video.towns_crtc_reg[17] & 0xfc00)<<2) | (((m_video.towns_crtc_reg[17] & 0x3ff)<<2)); - off += scroll; - } - off += (m_video.towns_crtc_reg[9] - m_video.towns_crtc_reg[18]); - hzoom = (m_video.towns_crtc_reg[27] & 0x000f) + 1; - } - - off += line * linesize; - - if(hzoom == 1) - { - for(x=rect->min_x;xmax_x;x+=2) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4; - if(colour != 0) - { - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - } - colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 2) - { // x2 horizontal zoom - for(x=rect->min_x;xmax_x;x+=4) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4; - if(colour != 0) - { - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - } - colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 3) - { // x3 horizontal zoom - for(x=rect->min_x;xmax_x;x+=6) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4; - if(colour != 0) - { - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - bitmap.pix32(scanline, x+4) = m_palette->pen(colour); - bitmap.pix32(scanline, x+5) = m_palette->pen(colour); - } - colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 4) - { // x4 horizontal zoom - for(x=rect->min_x;xmax_x;x+=8) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4; - if(colour != 0) - { - bitmap.pix32(scanline, x+4) = m_palette->pen(colour); - bitmap.pix32(scanline, x+5) = m_palette->pen(colour); - bitmap.pix32(scanline, x+6) = m_palette->pen(colour); - bitmap.pix32(scanline, x+7) = m_palette->pen(colour); - } - colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - } - off++; - } - } - - if(hzoom == 5) - { // x5 horizontal zoom - for(x=rect->min_x;xmax_x;x+=10) - { - if(m_video.towns_video_reg[0] & 0x10) - off &= 0x3ffff; // 2 layers - else - off &= 0x7ffff; // 1 layer - colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4; - if(colour != 0) - { - bitmap.pix32(scanline, x+5) = m_palette->pen(colour); - bitmap.pix32(scanline, x+6) = m_palette->pen(colour); - bitmap.pix32(scanline, x+7) = m_palette->pen(colour); - bitmap.pix32(scanline, x+8) = m_palette->pen(colour); - bitmap.pix32(scanline, x+9) = m_palette->pen(colour); - } - colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f; - if(colour != 0) - { - bitmap.pix32(scanline, x) = m_palette->pen(colour); - bitmap.pix32(scanline, x+1) = m_palette->pen(colour); - bitmap.pix32(scanline, x+2) = m_palette->pen(colour); - bitmap.pix32(scanline, x+3) = m_palette->pen(colour); - bitmap.pix32(scanline, x+4) = m_palette->pen(colour); - } - off++; - } - } -} - -void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* rect,int layer) -{ - int line; - int scanline; - int height; - - if(layer == 0) - { - scanline = rect->min_y; - height = (rect->max_y - rect->min_y); - if(m_video.towns_crtc_reg[27] & 0x0010) - height /= 2; - switch(m_video.towns_video_reg[0] & 0x03) - { - case 0x01: - for(line=0;linemin_y; - height = (rect->max_y - rect->min_y); - if(m_video.towns_crtc_reg[27] & 0x1000) - height /= 2; - switch(m_video.towns_video_reg[0] & 0x0c) - { - case 0x04: - for(line=0;linebase(); - int a,b; - - // all characters are 16 pixels high - vram_addr = (x * 4) + (y * (linesize * 16)); - - if((attr & 0xc0) == 0) - rom_addr = 0x3d800 + (ascii * 128); - else - { - code_h = (jis & 0xff00) >> 8; - code_l = jis & 0x00ff; - if(code_h < 0x30) - { - rom_addr = ((code_l & 0x1f) << 4) - | (((code_l - 0x20) & 0x20) << 8) - | (((code_l - 0x20) & 0x40) << 6) - | ((code_h & 0x07) << 9); - } - else if(code_h < 0x70) - { - rom_addr = ((code_l & 0x1f) << 4) - + (((code_l - 0x20) & 0x60) << 8) - + ((code_h & 0x0f) << 9) - + (((code_h - 0x30) & 0x70) * 0xc00) - + 0x8000; - } - else - { - rom_addr = ((code_l & 0x1f) << 4) - | (((code_l - 0x20) & 0x20) << 8) - | (((code_l - 0x20) & 0x40) << 6) - | ((code_h & 0x07) << 9) - | 0x38000; - } - } - colour = attr & 0x07; - if(attr & 0x20) - colour |= 0x08; - - for(a=0;a<16;a++) // for each scanline - { - if((attr & 0xc0) == 0) - data = font_rom[0x180000 + rom_addr + a]; - else - { - if((attr & 0xc0) == 0x80) - data = font_rom[0x180000 + rom_addr + (a*2)]; - else - data = font_rom[0x180000 + rom_addr + (a*2) + 1]; - } - - if(attr & 0x08) - data = ~data; // inverse - - // and finally, put the data in VRAM - for(b=0;b<8;b+=2) - { - temp = 0; - if(data & (1<(dev)->ir3_w(0); // IRQ11 = VSync - if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set low\n"); - m_video.towns_vblank_flag = 0; -} - -INTERRUPT_GEN_MEMBER(towns_state::towns_vsync_irq) -{ - pic8259_device* dev = m_pic_slave; - dev->ir3_w(1); // IRQ11 = VSync - if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set high\n"); - m_video.towns_vblank_flag = 1; - machine().scheduler().timer_set(machine().first_screen()->time_until_vblank_end(), timer_expired_delegate(FUNC(towns_state::towns_vblank_end),this), 0, (void*)dev); - if(m_video.towns_tvram_enable) - draw_text_layer(); - if(m_video.towns_sprite_reg[1] & 0x80) - draw_sprites(&m_video.towns_crtc_layerscr[1]); -} - -void towns_state::video_start() -{ - m_video.towns_vram_wplane = 0x00; - m_video.towns_sprite_page = 0; - m_video.sprite_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(towns_state::towns_sprite_done),this)); -} - -UINT32 towns_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(0x00000000, cliprect); - - if(!(m_video.towns_video_reg[1] & 0x01)) - { - if(!machine().input().code_pressed(KEYCODE_Q)) - { - if((m_video.towns_layer_ctrl & 0x03) != 0) - towns_crtc_draw_layer(bitmap,&m_video.towns_crtc_layerscr[1],1); - } - if(!machine().input().code_pressed(KEYCODE_W)) - { - if((m_video.towns_layer_ctrl & 0x0c) != 0) - towns_crtc_draw_layer(bitmap,&m_video.towns_crtc_layerscr[0],0); - } - } - else - { - if(!machine().input().code_pressed(KEYCODE_Q)) - { - if((m_video.towns_layer_ctrl & 0x0c) != 0) - towns_crtc_draw_layer(bitmap,&m_video.towns_crtc_layerscr[0],0); - } - if(!machine().input().code_pressed(KEYCODE_W)) - { - if((m_video.towns_layer_ctrl & 0x03) != 0) - towns_crtc_draw_layer(bitmap,&m_video.towns_crtc_layerscr[1],1); - } - } - -#if 0 -#ifdef SPR_DEBUG - if(machine().input().code_pressed(KEYCODE_O)) - pshift+=0x80; - if(machine().input().code_pressed(KEYCODE_I)) - pshift-=0x80; - popmessage("Pixel shift = %08x",pshift); -#endif -#endif - -#ifdef CRTC_REG_DISP - popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%04x %i %i %i | %04x %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i Spr=%02x\nReg28=%04x", - m_video.towns_crtc_reg[0],m_video.towns_crtc_reg[1],m_video.towns_crtc_reg[2],m_video.towns_crtc_reg[3], - m_video.towns_crtc_reg[4],m_video.towns_crtc_reg[5],m_video.towns_crtc_reg[6],m_video.towns_crtc_reg[7], - m_video.towns_crtc_reg[8], - m_video.towns_crtc_reg[9],m_video.towns_crtc_reg[10],m_video.towns_crtc_reg[11],m_video.towns_crtc_reg[12], - m_video.towns_crtc_reg[13],m_video.towns_crtc_reg[14],m_video.towns_crtc_reg[15],m_video.towns_crtc_reg[16], - m_video.towns_crtc_reg[17],m_video.towns_crtc_reg[18],m_video.towns_crtc_reg[19],m_video.towns_crtc_reg[20], - m_video.towns_crtc_reg[21],m_video.towns_crtc_reg[22],m_video.towns_crtc_reg[23],m_video.towns_crtc_reg[24], - m_video.towns_crtc_reg[27],m_video.towns_video_reg[0],m_video.towns_video_reg[1],m_video.towns_tvram_enable,m_video.towns_sprite_reg[1] & 0x80, - m_video.towns_crtc_reg[28]); -#endif - - return 0; -} diff --git a/src/mess/video/galaxy.c b/src/mess/video/galaxy.c deleted file mode 100644 index 0f8184916f8..00000000000 --- a/src/mess/video/galaxy.c +++ /dev/null @@ -1,134 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha, Miodrag Milanovic -/*************************************************************************** - - galaxy.c - - Functions to emulate the video hardware of the Galaksija. - - 20/05/2008 - Real video implementation by Miodrag Milanovic - 01/03/2008 - Update by Miodrag Milanovic to make Galaksija video work with new SVN code -***************************************************************************/ - -#include "emu.h" -#include "includes/galaxy.h" -#include "cpu/z80/z80.h" - - -TIMER_CALLBACK_MEMBER(galaxy_state::gal_video) -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - int y, x; - if (m_interrupts_enabled == TRUE) - { - UINT8 *gfx = m_region_gfx1->base(); - UINT8 dat = (m_latch_value & 0x3c) >> 2; - if ((m_gal_cnt >= 48 * 2) && (m_gal_cnt < 48 * 210)) // display on screen just m_first 208 lines - { - UINT8 mode = (m_latch_value >> 1) & 1; // bit 2 latch represents mode - UINT16 addr = (m_maincpu->state_int(Z80_I) << 8) | m_maincpu->state_int(Z80_R) | ((m_latch_value & 0x80) ^ 0x80); - if (mode == 0) - { - // Text mode - if (m_first == 0 && (m_maincpu->state_int(Z80_R) & 0x1f) == 0) - { - // Due to a fact that on real processor latch value is set at - // the end of last cycle we need to skip dusplay of double - // m_first char in each row - m_code = 0x00; - m_first = 1; - } - else - { - m_code = space.read_byte(addr) & 0xbf; - m_code += (m_code & 0x80) >> 1; - m_code = gfx[(m_code & 0x7f) +(dat << 7 )] ^ 0xff; - m_first = 0; - } - y = m_gal_cnt / 48 - 2; - x = (m_gal_cnt % 48) * 8; - - m_bitmap.pix16(y, x ) = (m_code >> 0) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 1) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 2) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 3) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 4) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 5) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 6) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 7) & 1; - } - else - { // Graphics mode - if (m_first < 4 && (m_maincpu->state_int(Z80_R) & 0x1f) == 0) - { - // Due to a fact that on real processor latch value is set at - // the end of last cycle we need to skip dusplay of 4 times - // m_first char in each row - m_code = 0x00; - m_first++; - } - else - { - m_code = space.read_byte(addr) ^ 0xff; - m_first = 0; - } - y = m_gal_cnt / 48 - 2; - x = (m_gal_cnt % 48) * 8; - - /* hack - until calc of R is fixed in Z80 */ - if (x == 11 * 8 && y == 0) - { - m_start_addr = addr; - } - if ((x / 8 >= 11) && (x / 8 < 44)) - { - m_code = space.read_byte(m_start_addr + y * 32 + (m_gal_cnt % 48) - 11) ^ 0xff; - } - else - { - m_code = 0x00; - } - /* end of hack */ - - m_bitmap.pix16(y, x ) = (m_code >> 0) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 1) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 2) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 3) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 4) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 5) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 6) & 1; x++; - m_bitmap.pix16(y, x ) = (m_code >> 7) & 1; - } - } - m_gal_cnt++; - } -} - -void galaxy_state::galaxy_set_timer() -{ - m_gal_cnt = 0; - m_gal_video_timer->adjust(attotime::zero, 0, attotime::from_hz(6144000 / 8)); -} - -void galaxy_state::video_start() -{ - m_gal_cnt = 0; - - m_gal_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(galaxy_state::gal_video),this)); - m_gal_video_timer->adjust(attotime::zero, 0, attotime::never); - - machine().first_screen()->register_screen_bitmap(m_bitmap); -} - -UINT32 galaxy_state::screen_update_galaxy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_gal_video_timer->adjust(attotime::zero, 0, attotime::never); - if (m_interrupts_enabled == FALSE) - { - const rectangle black_area(0, 384 - 1, 0, 208 - 1); - m_bitmap.fill(0, black_area); - } - m_interrupts_enabled = FALSE; - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/galeb.c b/src/mess/video/galeb.c deleted file mode 100644 index d7bd7bb7b4a..00000000000 --- a/src/mess/video/galeb.c +++ /dev/null @@ -1,45 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Galeb video driver by Miodrag Milanovic - - 01/03/2008 Updated to work with latest SVN code - 22/02/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/galeb.h" - - -const gfx_layout galeb_charlayout = -{ - 8, 8, /* 8x8 characters */ - 256, /* 256 characters */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {7, 6, 5, 4, 3, 2, 1, 0}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -void galeb_state::video_start() -{ -} - -UINT32 galeb_state::screen_update_galeb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - - for(y = 0; y < 16; y++ ) - { - for(x = 0; x < 48; x++ ) - { - int code = m_video_ram[15 + x + y*64]; - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code , 0, 0,0, x*8,y*8); - } - } - return 0; -} diff --git a/src/mess/video/gamecom.c b/src/mess/video/gamecom.c deleted file mode 100644 index 29bad2d9ce7..00000000000 --- a/src/mess/video/gamecom.c +++ /dev/null @@ -1,71 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol, Robbbert - -#include "includes/gamecom.h" - -#define Y_PIXELS 200 - - -TIMER_CALLBACK_MEMBER(gamecom_state::gamecom_scanline) - { - // draw line - m_base_address = ( m_p_ram[SM8521_LCDC] & 0x40 ) ? 0x2000 : 0x0000; - - if ( ~m_p_ram[SM8521_LCDC] & 0x80 ) - { - rectangle rec(0, Y_PIXELS - 1, m_scanline, m_scanline); - m_bitmap.fill(0, rec ); - return; - } - else - { - UINT8 *line = &m_p_videoram[ m_base_address + 40 * m_scanline ]; - int pal[4]; - int i; - - switch( m_p_ram[SM8521_LCDC] & 0x30 ) - { - case 0x00: - pal[0] = 4; - pal[1] = 3; - pal[2] = 2; - pal[3] = 0; - break; - case 0x10: - pal[0] = 4; - pal[1] = 3; - pal[2] = 1; - pal[3] = 0; - break; - case 0x20: - pal[0] = 4; - pal[1] = 3; - pal[2] = 1; - pal[3] = 0; - break; - case 0x30: - pal[0] = 4; - pal[1] = 2; - pal[2] = 1; - pal[3] = 0; - break; - } - for( i = 0; i < 40; i++ ) - { - UINT8 p = line[i]; - m_bitmap.pix16(i * 4 + 0, m_scanline) = pal[ ( p >> 6 ) & 3 ]; - m_bitmap.pix16(i * 4 + 1, m_scanline) = pal[ ( p >> 4 ) & 3 ]; - m_bitmap.pix16(i * 4 + 2, m_scanline) = pal[ ( p >> 2 ) & 3 ]; - m_bitmap.pix16(i * 4 + 3, m_scanline) = pal[ ( p ) & 3 ]; - } - } - - m_scanline = ( m_scanline + 1 ) % Y_PIXELS; -} - -void gamecom_state::video_start() -{ - m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamecom_state::gamecom_scanline),this)); - m_scanline_timer->adjust( machine().first_screen()->time_until_pos(0 ), 0, machine().first_screen()->scan_period() ); - machine().first_screen()->register_screen_bitmap(m_bitmap); -} diff --git a/src/mess/video/gb_lcd.c b/src/mess/video/gb_lcd.c deleted file mode 100644 index b46aece5a15..00000000000 --- a/src/mess/video/gb_lcd.c +++ /dev/null @@ -1,2852 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/*************************************************************************** - - gb_lcd.c - - Video file to handle emulation of the Nintendo Game Boy. - - Original code Carsten Sorensen 1998 - Mess modifications, bug fixes and speedups Hans de Goede 1998 - Bug fixes, SGB and GBC code Anthony Kruize 2002 - Improvements to match real hardware Wilbert Pol 2006-2008 - - Timing is not accurate enough: - - Mode 3 takes 172 cycles (measuered with logic analyzer by costis) - -***************************************************************************/ - -#include "emu.h" -//#include "cpu/lr35902/lr35902.h" -#include "video/gb_lcd.h" - -/* Interrupts (copied from includes/gb.h)... */ -#define VBL_INT 0 /* V-Blank */ -#define LCD_INT 1 /* LCD Status */ -#define TIM_INT 2 /* Timer */ -#define SIO_INT 3 /* Serial I/O */ -#define EXT_INT 4 /* Joypad */ - - - -#define LCDCONT m_vid_regs[0x00] /* LCD control register */ -#define LCDSTAT m_vid_regs[0x01] /* LCD status register */ -#define SCROLLY m_vid_regs[0x02] /* Starting Y position of the background */ -#define SCROLLX m_vid_regs[0x03] /* Starting X position of the background */ -#define CURLINE m_vid_regs[0x04] /* Current screen line being scanned */ -#define CMPLINE m_vid_regs[0x05] /* Gen. int. when scan reaches this line */ -#define BGRDPAL m_vid_regs[0x07] /* Background palette */ -#define SPR0PAL m_vid_regs[0x08] /* Sprite palette #0 */ -#define SPR1PAL m_vid_regs[0x09] /* Sprite palette #1 */ -#define WNDPOSY m_vid_regs[0x0A] /* Window Y position */ -#define WNDPOSX m_vid_regs[0x0B] /* Window X position */ -#define KEY1 m_vid_regs[0x0D] /* Prepare speed switch */ -#define HDMA1 m_vid_regs[0x11] /* HDMA source high byte */ -#define HDMA2 m_vid_regs[0x12] /* HDMA source low byte */ -#define HDMA3 m_vid_regs[0x13] /* HDMA destination high byte */ -#define HDMA4 m_vid_regs[0x14] /* HDMA destination low byte */ -#define HDMA5 m_vid_regs[0x15] /* HDMA length/mode/start */ -#define GBCBCPS m_vid_regs[0x28] /* Backgound palette spec */ -#define GBCBCPD m_vid_regs[0x29] /* Backgound palette data */ -#define GBCOCPS m_vid_regs[0x2A] /* Object palette spec */ -#define GBCOCPD m_vid_regs[0x2B] /* Object palette data */ - -/* -- Super Game Boy specific -- */ -#define SGB_BORDER_PAL_OFFSET 64 /* Border colours stored from pal 4-7 */ -#define SGB_XOFFSET 48 /* GB screen starts at column 48 */ -#define SGB_YOFFSET 40 /* GB screen starts at row 40 */ - - -enum { - UNLOCKED=0, - LOCKED -}; - - -enum { - GB_LCD_STATE_LYXX_M3=1, - GB_LCD_STATE_LYXX_PRE_M0, - GB_LCD_STATE_LYXX_M0, - GB_LCD_STATE_LYXX_M0_SCX3, - GB_LCD_STATE_LYXX_M0_GBC_PAL, - GB_LCD_STATE_LYXX_M0_PRE_INC, - GB_LCD_STATE_LYXX_M0_INC, - GB_LCD_STATE_LY00_M2, - GB_LCD_STATE_LYXX_M2, - GB_LCD_STATE_LY9X_M1, - GB_LCD_STATE_LY9X_M1_INC, - GB_LCD_STATE_LY00_M1, - GB_LCD_STATE_LY00_M1_1, - GB_LCD_STATE_LY00_M1_2, - GB_LCD_STATE_LY00_M0 -}; - - -/* OAM contents on power up. - - The OAM area seems contain some kind of unit fingerprint. On each boot - the data is almost always the same. Some random bits are flipped between - different boots. It is currently unknown how much these fingerprints - differ between different units. - - OAM fingerprints taken from Wilbert Pol's own unit. - */ - -static const UINT8 dmg_oam_fingerprint[0x100] = { - 0xD8, 0xE6, 0xB3, 0x89, 0xEC, 0xDE, 0x11, 0x62, 0x0B, 0x7E, 0x48, 0x9E, 0x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0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static const UINT8 mgb_oam_fingerprint[0x100] = { - 0xB9, 0xE9, 0x0D, 0x69, 0xBB, 0x7F, 0x00, 0x80, 0xE9, 0x7B, 0x79, 0xA2, 0xFD, 0xCF, 0xD8, 0x0A, - 0x87, 0xEF, 0x44, 0x11, 0xFE, 0x37, 0x10, 0x21, 0xFA, 0xFF, 0x00, 0x17, 0xF6, 0x4F, 0x83, 0x03, - 0x3A, 0xF4, 0x00, 0x24, 0xBB, 0xAE, 0x05, 0x01, 0xFF, 0xF7, 0x12, 0x48, 0xA7, 0x5E, 0xF6, 0x28, - 0x5B, 0xFF, 0x2E, 0x10, 0xFF, 0xB9, 0x50, 0xC8, 0xAF, 0x77, 0x2C, 0x1A, 0x62, 0xD7, 0x81, 0xC2, - 0xFD, 0x5F, 0xA0, 0x94, 0xAF, 0xFF, 0x51, 0x20, 0x36, 0x76, 0x50, 0x0A, 0xFD, 0xF6, 0x20, 0x00, - 0xFE, 0xF7, 0xA0, 0x68, 0xFF, 0xFC, 0x29, 0x51, 0xA3, 0xFA, 0x06, 0xC4, 0x94, 0xFF, 0x39, 0x0A, - 0xFF, 0x6C, 0x20, 0x20, 0xF1, 0xAD, 0x0C, 0x81, 0x56, 0xFB, 0x03, 0x82, 0xFF, 0xFF, 0x08, 0x58, - 0x96, 0x7E, 0x01, 0x4D, 0xFF, 0xE4, 0x82, 0xE3, 0x3D, 0xBB, 0x54, 0x00, 0x3D, 0xF3, 0x04, 0x21, - 0xB7, 0x39, 0xCC, 0x10, 0xF9, 0x5B, 0x80, 0x50, 0x3F, 0x6A, 0x1C, 0x21, 0x1F, 0xFA, 0xA8, 0x52, - 0x5F, 0xB3, 0x44, 0xA1, 0x96, 0x1E, 0x00, 0x27, 0x63, 0x77, 0x30, 0x54, 0x37, 0x6F, 0x60, 0x22, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static const UINT8 cgb_oam_fingerprint[0x100] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x74, 0xFF, 0x09, 0x00, 0x9D, 0x61, 0xA8, 0x28, 0x36, 0x1E, 0x58, 0xAA, 0x75, 0x74, 0xA1, 0x42, - 0x05, 0x96, 0x40, 0x09, 0x41, 0x02, 0x60, 0x00, 0x1F, 0x11, 0x22, 0xBC, 0x31, 0x52, 0x22, 0x54, - 0x22, 0xA9, 0xC4, 0x00, 0x1D, 0xAD, 0x80, 0x0C, 0x5D, 0xFA, 0x51, 0x92, 0x93, 0x98, 0xA4, 0x04, - 0x22, 0xA9, 0xC4, 0x00, 0x1D, 0xAD, 0x80, 0x0C, 0x5D, 0xFA, 0x51, 0x92, 0x93, 0x98, 0xA4, 0x04, - 0x22, 0xA9, 0xC4, 0x00, 0x1D, 0xAD, 0x80, 0x0C, 0x5D, 0xFA, 0x51, 0x92, 0x93, 0x98, 0xA4, 0x04, - 0x22, 0xA9, 0xC4, 0x00, 0x1D, 0xAD, 0x80, 0x0C, 0x5D, 0xFA, 0x51, 0x92, 0x93, 0x98, 0xA4, 0x04 -}; - -/* - For an AGS in CGB mode this data is: */ -#if 0 -static const UINT8 abs_oam_fingerprint[0x100] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -#endif - - -const device_type GB_LCD_DMG = &device_creator; -const device_type GB_LCD_MGB = &device_creator; -const device_type GB_LCD_SGB = &device_creator; -const device_type GB_LCD_CGB = &device_creator; - - - -gb_lcd_device::gb_lcd_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source), - device_video_interface(mconfig, *this), - m_sgb_border_hack(0) -{ -} - -gb_lcd_device::gb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, GB_LCD_DMG, "DMG LCD", tag, owner, clock, "dmg_lcd", __FILE__), - device_video_interface(mconfig, *this), - m_sgb_border_hack(0) -{ -} - -mgb_lcd_device::mgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gb_lcd_device(mconfig, GB_LCD_MGB, "MGB LCD", tag, owner, clock, "mgb_lcd", __FILE__) -{ -} - -sgb_lcd_device::sgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gb_lcd_device(mconfig, GB_LCD_SGB, "SGB LCD", tag, owner, clock, "sgb_lcd", __FILE__) -{ -} - -cgb_lcd_device::cgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gb_lcd_device(mconfig, GB_LCD_CGB, "CGB LCD", tag, owner, clock, "cgb_lcd", __FILE__) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void gb_lcd_device::common_start() -{ - m_screen->register_screen_bitmap(m_bitmap); - save_item(NAME(m_bitmap)); - m_oam = auto_alloc_array_clear(machine(), UINT8, 0x100); - - machine().save().register_postload(save_prepost_delegate(FUNC(gb_lcd_device::videoptr_restore), this)); - - m_maincpu = machine().device("maincpu"); - - save_pointer(NAME(m_oam), 0x100); - save_item(NAME(m_window_lines_drawn)); - save_item(NAME(m_vid_regs)); - save_item(NAME(m_bg_zbuf)); - - save_item(NAME(m_cgb_bpal)); - save_item(NAME(m_cgb_spal)); - - save_item(NAME(m_gb_bpal)); - save_item(NAME(m_gb_spal0)); - save_item(NAME(m_gb_spal1)); - - save_item(NAME(m_current_line)); - save_item(NAME(m_cmp_line)); - save_item(NAME(m_sprCount)); - save_item(NAME(m_sprite)); - save_item(NAME(m_previous_line)); - save_item(NAME(m_start_x)); - save_item(NAME(m_end_x)); - save_item(NAME(m_mode)); - save_item(NAME(m_state)); - save_item(NAME(m_lcd_irq_line)); - save_item(NAME(m_triggering_line_irq)); - save_item(NAME(m_line_irq)); - save_item(NAME(m_triggering_mode_irq)); - save_item(NAME(m_mode_irq)); - save_item(NAME(m_delayed_line_irq)); - save_item(NAME(m_sprite_cycles)); - save_item(NAME(m_scrollx_adjust)); - save_item(NAME(m_oam_locked)); - save_item(NAME(m_vram_locked)); - save_item(NAME(m_pal_locked)); - save_item(NAME(m_hdma_enabled)); - save_item(NAME(m_hdma_possible)); - save_item(NAME(m_gbc_mode)); - save_item(NAME(m_gb_tile_no_mod)); - save_item(NAME(m_vram_bank)); - - save_item(NAME(m_gb_chrgen_offs)); - save_item(NAME(m_gb_bgdtab_offs)); - save_item(NAME(m_gb_wndtab_offs)); - save_item(NAME(m_gbc_chrgen_offs)); - save_item(NAME(m_gbc_bgdtab_offs)); - save_item(NAME(m_gbc_wndtab_offs)); - - save_item(NAME(m_layer[0].enabled)); - save_item(NAME(m_layer[0].xindex)); - save_item(NAME(m_layer[0].xshift)); - save_item(NAME(m_layer[0].xstart)); - save_item(NAME(m_layer[0].xend)); - save_item(NAME(m_layer[0].bgline)); - save_item(NAME(m_layer[1].enabled)); - save_item(NAME(m_layer[1].xindex)); - save_item(NAME(m_layer[1].xshift)); - save_item(NAME(m_layer[1].xstart)); - save_item(NAME(m_layer[1].xend)); - save_item(NAME(m_layer[1].bgline)); -} - - -void gb_lcd_device::videoptr_restore() -{ - m_layer[0].bg_map = m_vram + m_gb_bgdtab_offs; - m_layer[0].bg_tiles = m_vram + m_gb_chrgen_offs; - m_layer[1].bg_map = m_vram + m_gb_wndtab_offs; - m_layer[1].bg_tiles = m_vram + m_gb_chrgen_offs; -} - -void cgb_lcd_device::videoptr_restore() -{ - m_layer[0].bg_map = m_vram + m_gb_bgdtab_offs; - m_layer[0].gbc_map = m_vram + m_gbc_bgdtab_offs; - m_layer[1].bg_map = m_vram + m_gb_wndtab_offs; - m_layer[1].gbc_map = m_vram + m_gbc_wndtab_offs; -} - - -void gb_lcd_device::device_start() -{ - common_start(); - m_lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_lcd_device::lcd_timer_proc),this)); - - m_vram = auto_alloc_array_clear(machine(), UINT8, 0x2000); - save_pointer(NAME(m_vram), 0x2000); - - memcpy(m_oam, dmg_oam_fingerprint, 0x100); -} - -void mgb_lcd_device::device_start() -{ - common_start(); - m_lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mgb_lcd_device::lcd_timer_proc),this)); - - m_vram = auto_alloc_array_clear(machine(), UINT8, 0x2000); - save_pointer(NAME(m_vram), 0x2000); - - memcpy(m_oam, mgb_oam_fingerprint, 0x100); -} - -void sgb_lcd_device::device_start() -{ - common_start(); - m_lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sgb_lcd_device::lcd_timer_proc),this)); - - m_vram = auto_alloc_array_clear(machine(), UINT8, 0x2000); - save_pointer(NAME(m_vram), 0x2000); - - m_sgb_tile_data = auto_alloc_array_clear(machine(), UINT8, 0x2000); - save_pointer(NAME(m_sgb_tile_data), 0x2000); - - memset(m_sgb_tile_map, 0, sizeof(m_sgb_tile_map)); - - /* Some default colours for non-SGB games */ - m_sgb_pal[0] = 32767; - m_sgb_pal[1] = 21140; - m_sgb_pal[2] = 10570; - m_sgb_pal[3] = 0; - /* The rest of the colortable can be black */ - for (int i = 4; i < 8 * 16; i++) - m_sgb_pal[i] = 0; - - save_item(NAME(m_sgb_atf_data)); - save_item(NAME(m_sgb_atf)); - save_item(NAME(m_sgb_pal_data)); - save_item(NAME(m_sgb_pal_map)); - save_item(NAME(m_sgb_pal)); - save_item(NAME(m_sgb_tile_map)); - save_item(NAME(m_sgb_window_mask)); -} - -void cgb_lcd_device::device_start() -{ - common_start(); - m_lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cgb_lcd_device::lcd_timer_proc),this)); - - m_vram = auto_alloc_array_clear(machine(), UINT8, 0x4000); - save_pointer(NAME(m_vram), 0x4000); - - memcpy(m_oam, cgb_oam_fingerprint, 0x100); - - /* Background is initialised as white */ - for (int i = 0; i < 32; i++) - m_cgb_bpal[i] = 32767; - /* Sprites are supposed to be uninitialized, but we'll make them black */ - for (int i = 0; i < 32; i++) - m_cgb_spal[i] = 0; -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void gb_lcd_device::common_reset() -{ - m_window_lines_drawn = 0; - - m_current_line = 0; - m_cmp_line = 0; - m_sprCount = 0; - m_previous_line = 0; - m_start_x = 0; - m_end_x = 0; - m_mode = 0; - m_state = 0; - m_lcd_irq_line = 0; - m_triggering_line_irq = 0; - m_line_irq = 0; - m_triggering_mode_irq = 0; - m_mode_irq = 0; - m_delayed_line_irq = 0; - m_sprite_cycles = 0; - m_scrollx_adjust = 0; - m_oam_locked = 0; - m_vram_locked = 0; - m_pal_locked = 0; - m_gbc_mode = 0; - m_gb_tile_no_mod = 0; - m_vram_bank = 0; - - m_gb_chrgen_offs = 0; - m_gb_bgdtab_offs = 0x1c00; - m_gb_wndtab_offs = 0x1c00; - - memset(&m_vid_regs, 0, sizeof(m_vid_regs)); - memset(&m_bg_zbuf, 0, sizeof(m_bg_zbuf)); - memset(&m_cgb_bpal, 0, sizeof(m_cgb_bpal)); - memset(&m_cgb_spal, 0, sizeof(m_cgb_spal)); - memset(&m_sprite, 0, sizeof(m_sprite)); - memset(&m_layer[0], 0, sizeof(m_layer[0])); - memset(&m_layer[1], 0, sizeof(m_layer[1])); - - // specific reg initialization - m_vid_regs[0x06] = 0xff; - - for (int i = 0x0c; i < _NR_GB_VID_REGS; i++) - m_vid_regs[i] = 0xff; - - LCDSTAT = 0x80; - LCDCONT = 0x00; /* Video hardware is turned off at boot time */ - m_current_line = CURLINE = CMPLINE = 0x00; - SCROLLX = SCROLLY = 0x00; - SPR0PAL = SPR1PAL = 0xFF; - WNDPOSX = WNDPOSY = 0x00; - - // Initialize palette arrays - for (int i = 0; i < 4; i++) - m_gb_bpal[i] = m_gb_spal0[i] = m_gb_spal1[i] = i; - -} - - -void gb_lcd_device::device_reset() -{ - common_reset(); - - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(456)); -} - -void sgb_lcd_device::device_reset() -{ - common_reset(); - - memset(m_sgb_tile_data, 0, 0x2000); - - m_sgb_window_mask = 0; - - memset(m_sgb_pal_map, 0, sizeof(m_sgb_pal_map)); - memset(m_sgb_atf_data, 0, sizeof(m_sgb_atf_data)); -} - -void cgb_lcd_device::device_reset() -{ - common_reset(); - - m_gbc_chrgen_offs = 0x2000; - m_gbc_bgdtab_offs = 0x3c00; - m_gbc_wndtab_offs = 0x3c00; - - /* HDMA disabled */ - m_hdma_enabled = 0; - m_hdma_possible = 0; - - m_gbc_mode = 1; -} - - - -inline void gb_lcd_device::plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -/* - Select which sprites should be drawn for the current scanline and return the - number of sprites selected. - */ -void gb_lcd_device::select_sprites() -{ - int /*yindex,*/ line, height; - UINT8 *oam = m_oam + 39 * 4; - - m_sprCount = 0; - - /* If video hardware is enabled and sprites are enabled */ - if ((LCDCONT & 0x80) && (LCDCONT & 0x02)) - { - /* Check for stretched sprites */ - if (LCDCONT & 0x04) - height = 16; - else - height = 8; - - //yindex = m_current_line; - line = m_current_line + 16; - - for (int i = 39; i >= 0; i--) - { - if (line >= oam[0] && line < (oam[0] + height) && oam[1] && oam[1] < 168) - { - /* We limit the sprite count to max 10 here; - proper games should not exceed this... */ - if (m_sprCount < 10) - { - m_sprite[m_sprCount] = i; - m_sprCount++; - } - } - oam -= 4; - } - } -} - -void gb_lcd_device::update_sprites() -{ - bitmap_ind16 &bitmap = m_bitmap; - UINT8 height, tilemask, line, *oam, *vram; - int yindex; - - if (LCDCONT & 0x04) - { - height = 16; - tilemask = 0xFE; - } - else - { - height = 8; - tilemask = 0xFF; - } - - yindex = m_current_line; - line = m_current_line + 16; - - oam = m_oam + 39 * 4; - vram = m_vram; - for (int i = 39; i >= 0; i--) - { - /* if sprite is on current line && x-coordinate && x-coordinate is < 168 */ - if (line >= oam[0] && line < (oam[0] + height) && oam[1] && oam[1] < 168) - { - UINT16 data; - UINT8 bit, *spal; - int xindex, adr; - - spal = (oam[3] & 0x10) ? m_gb_spal1 : m_gb_spal0; - xindex = oam[1] - 8; - if (oam[3] & 0x40) /* flip y ? */ - { - adr = (oam[2] & tilemask) * 16 + (height - 1 - line + oam[0]) * 2; - } - else - { - adr = (oam[2] & tilemask) * 16 + (line - oam[0]) * 2; - } - data = (vram[adr + 1] << 8) | vram[adr]; - - switch (oam[3] & 0xA0) - { - case 0xA0: /* priority is set (behind bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if (colour && !m_bg_zbuf[xindex] && xindex >= 0 && xindex < 160) - plot_pixel(bitmap, xindex, yindex, spal[colour]); - data >>= 1; - } - break; - case 0x20: /* priority is not set (overlaps bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if (colour && xindex >= 0 && xindex < 160) - plot_pixel(bitmap, xindex, yindex, spal[colour]); - data >>= 1; - } - break; - case 0x80: /* priority is set (behind bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8 && xindex < 160; bit++, xindex++) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if (colour && !m_bg_zbuf[xindex] && xindex >= 0 && xindex < 160) - plot_pixel(bitmap, xindex, yindex, spal[colour]); - data <<= 1; - } - break; - case 0x00: /* priority is not set (overlaps bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8 && xindex < 160; bit++, xindex++) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if (colour && xindex >= 0 && xindex < 160) - plot_pixel(bitmap, xindex, yindex, spal[colour]); - data <<= 1; - } - break; - } - } - oam -= 4; - } -} - -void gb_lcd_device::update_scanline() -{ - bitmap_ind16 &bitmap = m_bitmap; - - g_profiler.start(PROFILER_VIDEO); - - /* Make sure we're in mode 3 */ - if ((LCDSTAT & 0x03) == 0x03) - { - /* Calculate number of pixels to render based on time still left on the timer */ - UINT32 cycles_to_go = m_maincpu->attotime_to_cycles(m_lcd_timer->remaining()); - int l = 0; - - if (m_start_x < 0) - { - /* Window is enabled if the hardware says so AND the current scanline is - * within the window AND the window X coordinate is <=166 */ - m_layer[1].enabled = ((LCDCONT & 0x20) && (m_current_line >= WNDPOSY) && (WNDPOSX <= 166)) ? 1 : 0; - - /* BG is enabled if the hardware says so AND (window_off OR (window_on - * AND window's X position is >=7)) */ - m_layer[0].enabled = ((LCDCONT & 0x01) && ((!m_layer[1].enabled) || (m_layer[1].enabled && (WNDPOSX >= 7)))) ? 1 : 0; - - if (m_layer[0].enabled) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - m_layer[0].bg_map = m_vram + m_gb_bgdtab_offs; - m_layer[0].bg_tiles = m_vram + m_gb_chrgen_offs; - m_layer[0].xindex = SCROLLX >> 3; - m_layer[0].xshift = SCROLLX & 7; - m_layer[0].xstart = 0; - m_layer[0].xend = 160; - } - - if (m_layer[1].enabled) - { - int xpos = WNDPOSX - 7; /* Window is offset by 7 pixels */ - if (xpos < 0) - xpos = 0; - - m_layer[1].bgline = m_window_lines_drawn; - m_layer[1].bg_map = m_vram + m_gb_wndtab_offs; - m_layer[1].bg_tiles = m_vram + m_gb_chrgen_offs; - m_layer[1].xindex = 0; - m_layer[1].xshift = 0; - m_layer[1].xstart = xpos; - m_layer[1].xend = 160; - m_layer[0].xend = xpos; - } - m_start_x = 0; - } - - if (cycles_to_go < 160) - { - m_end_x = MIN(160 - cycles_to_go, 160); - /* Draw empty pixels when the background is disabled */ - if (!(LCDCONT & 0x01)) - { - rectangle r(m_start_x, m_end_x - 1, m_current_line, m_current_line); - bitmap.fill(m_gb_bpal[0], r); - } - while (l < 2) - { - UINT8 xindex, *map, *tiles; - UINT16 data; - int i, tile_index; - - if (!m_layer[l].enabled) - { - l++; - continue; - } - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - tiles = m_layer[l].bg_tiles + ((m_layer[l].bgline & 7) << 1); - xindex = m_start_x; - if (xindex < m_layer[l].xstart) - xindex = m_layer[l].xstart; - i = m_end_x; - if (i > m_layer[l].xend) - i = m_layer[l].xend; - i = i - xindex; - - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index+1] << 8); - data <<= m_layer[l].xshift; - - while (i > 0) - { - while ((m_layer[l].xshift < 8) && i) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - plot_pixel(bitmap, xindex, m_current_line, m_gb_bpal[colour]); - m_bg_zbuf[xindex] = colour; - xindex++; - data <<= 1; - m_layer[l].xshift++; - i--; - } - if (m_layer[l].xshift == 8) - { - /* Take possible changes to SCROLLY into account */ - if (l == 0) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - tiles = m_layer[l].bg_tiles + ((m_layer[l].bgline & 7) << 1); - } - - m_layer[l].xindex = (m_layer[l].xindex + 1) & 31; - m_layer[l].xshift = 0; - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index + 1] << 8); - } - } - l++; - } - if (m_end_x == 160 && LCDCONT & 0x02) - { - update_sprites(); - } - m_start_x = m_end_x; - } - } - else - { - if (!(LCDCONT & 0x80)) - { - /* Draw an empty line when LCD is disabled */ - if (m_previous_line != m_current_line) - { - if (m_current_line < 144) - { - const rectangle &r = m_screen->visible_area(); - rectangle r1(r.min_x, r.max_x, m_current_line, m_current_line); - bitmap.fill(0, r1); - } - m_previous_line = m_current_line; - } - } - } - - g_profiler.stop(); -} - -/* --- Super Game Boy Specific --- */ - -void sgb_lcd_device::update_sprites() -{ - bitmap_ind16 &bitmap = m_bitmap; - UINT8 height, tilemask, line, *oam, *vram, pal; - INT16 yindex; - - if (LCDCONT & 0x04) - { - height = 16; - tilemask = 0xFE; - } - else - { - height = 8; - tilemask = 0xFF; - } - - /* Offset to center of screen */ - yindex = m_current_line + SGB_YOFFSET; - line = m_current_line + 16; - - oam = m_oam + 39 * 4; - vram = m_vram; - for (int i = 39; i >= 0; i--) - { - /* if sprite is on current line && x-coordinate && x-coordinate is < 168 */ - if (line >= oam[0] && line < (oam[0] + height) && oam[1] && oam[1] < 168) - { - UINT16 data; - UINT8 bit, *spal; - INT16 xindex; - int adr; - - spal = (oam[3] & 0x10) ? m_gb_spal1 : m_gb_spal0; - xindex = oam[1] - 8; - if (oam[3] & 0x40) /* flip y ? */ - { - adr = (oam[2] & tilemask) * 16 + (height - 1 - line + oam[0]) * 2; - } - else - { - adr = (oam[2] & tilemask) * 16 + (line - oam[0]) * 2; - } - data = (vram[adr + 1] << 8) | vram[adr]; - - /* Find the palette to use */ - // If sprite started before the start of the line we may need to pick a different pal_map entry? - pal = m_sgb_pal_map[(xindex < 0) ? 0 : (xindex >> 3)][((yindex - SGB_YOFFSET) >> 3)] << 2; - - /* Offset to center of screen */ - xindex += SGB_XOFFSET; - - switch (oam[3] & 0xA0) - { - case 0xA0: /* priority is set (behind bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if ((xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160) && colour && !m_bg_zbuf[xindex - SGB_XOFFSET]) - plot_pixel(bitmap, xindex, yindex, m_sgb_pal[pal + spal[colour]]); - data >>= 1; - } - break; - case 0x20: /* priority is not set (overlaps bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if ((xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160) && colour) - plot_pixel(bitmap, xindex, yindex, m_sgb_pal[pal + spal[colour]]); - data >>= 1; - } - break; - case 0x80: /* priority is set (behind bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if ((xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160) && colour && !m_bg_zbuf[xindex - SGB_XOFFSET]) - plot_pixel(bitmap, xindex, yindex, m_sgb_pal[pal + spal[colour]]); - data <<= 1; - } - break; - case 0x00: /* priority is not set (overlaps bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if ((xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160) && colour) - plot_pixel(bitmap, xindex, yindex, m_sgb_pal[pal + spal[colour]]); - data <<= 1; - } - break; - } - } - oam -= 4; - } -} - - -void sgb_lcd_device::refresh_border() -{ - UINT16 data, data2; - UINT8 *tiles, *tiles2; - - for (UINT16 yidx = 0; yidx < 224; yidx++) - { - UINT8 *map = m_sgb_tile_map + ((yidx >> 3) * 64); - UINT16 xindex = 0; - - for (UINT16 xidx = 0; xidx < 64; xidx += 2) - { - if (map[xidx + 1] & 0x80) /* Vertical flip */ - tiles = m_sgb_tile_data + ((7 - (yidx % 8)) << 1); - else /* No vertical flip */ - tiles = m_sgb_tile_data + ((yidx % 8) << 1); - tiles2 = tiles + 16; - - UINT8 pal = (map[xidx + 1] & 0x1C) >> 2; - if (pal == 0) - pal = 1; - pal <<= 4; - - if (m_sgb_border_hack) - { /* A few games do weird stuff */ - UINT8 tileno = map[xidx]; - if (tileno >= 128) tileno = ((64 + tileno) % 128) + 128; - else tileno = (64 + tileno) % 128; - data = tiles[tileno * 32] | (tiles[(tileno * 32) + 1] << 8); - data2 = tiles2[tileno * 32] | (tiles2[(tileno * 32) + 1] << 8); - } - else - { - data = tiles[map[xidx] * 32] | (tiles[(map[xidx] * 32) + 1] << 8); - data2 = tiles2[map[xidx] * 32] | (tiles2[(map[xidx] * 32) + 1] << 8); - } - - for (int i = 0; i < 8; i++) - { - register UINT8 colour; - if ((map[xidx + 1] & 0x40)) /* Horizontal flip */ - { - colour = ((data & 0x0001) ? 1 : 0) | ((data & 0x0100) ? 2 : 0) | - ((data2 & 0x0001) ? 4 : 0) | ((data2 & 0x0100) ? 8 : 0); - data >>= 1; - data2 >>= 1; - } - else /* No horizontal flip */ - { - colour = ((data & 0x0080) ? 1 : 0) | ((data & 0x8000) ? 2 : 0) | - ((data2 & 0x0080) ? 4 : 0) | ((data2 & 0x8000) ? 8 : 0); - data <<= 1; - data2 <<= 1; - } - /* A slight hack below so we don't draw over the GB screen. - * Drawing there is allowed, but due to the way we draw the - * scanline, it can obscure the screen even when it shouldn't. - */ - if (!((yidx >= SGB_YOFFSET && yidx < SGB_YOFFSET + 144) && - (xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160))) - { - plot_pixel(m_bitmap, xindex, yidx, m_sgb_pal[pal + colour]); - } - xindex++; - } - } - } -} - -void sgb_lcd_device::update_scanline() -{ - bitmap_ind16 &bitmap = m_bitmap; - - g_profiler.start(PROFILER_VIDEO); - - if ((LCDSTAT & 0x03) == 0x03) - { - /* Calcuate number of pixels to render based on time still left on the timer */ - UINT32 cycles_to_go = m_maincpu->attotime_to_cycles(m_lcd_timer->remaining()); - int l = 0; - - if (m_start_x < 0) - { - /* Window is enabled if the hardware says so AND the current scanline is - * within the window AND the window X coordinate is <=166 */ - m_layer[1].enabled = ((LCDCONT & 0x20) && m_current_line >= WNDPOSY && WNDPOSX <= 166) ? 1 : 0; - - /* BG is enabled if the hardware says so AND (window_off OR (window_on - * AND window's X position is >=7 )) */ - m_layer[0].enabled = ((LCDCONT & 0x01) && ((!m_layer[1].enabled) || (m_layer[1].enabled && WNDPOSX >= 7))) ? 1 : 0; - - if (m_layer[0].enabled) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - m_layer[0].bg_map = m_vram + m_gb_bgdtab_offs; - m_layer[0].bg_tiles = m_vram + m_gb_chrgen_offs; - m_layer[0].xindex = SCROLLX >> 3; - m_layer[0].xshift = SCROLLX & 7; - m_layer[0].xstart = 0; - m_layer[0].xend = 160; - } - - if (m_layer[1].enabled) - { - int xpos; - - /* Window X position is offset by 7 so we'll need to adjust */ - xpos = WNDPOSX - 7; - if (xpos < 0) - xpos = 0; - - m_layer[1].bgline = m_window_lines_drawn; - m_layer[1].bg_map = m_vram + m_gb_wndtab_offs; - m_layer[1].bg_tiles = m_vram + m_gb_chrgen_offs; - m_layer[1].xindex = 0; - m_layer[1].xshift = 0; - m_layer[1].xstart = xpos; - m_layer[1].xend = 160; - m_layer[0].xend = xpos; - } - m_start_x = 0; - } - - if (cycles_to_go == 0) - { - /* Does this belong here? or should it be moved to the else block */ - /* Handle SGB mask */ - switch (m_sgb_window_mask) - { - case 1: /* Freeze screen */ - return; - case 2: /* Blank screen (black) */ - { - rectangle r(SGB_XOFFSET, SGB_XOFFSET + 160-1, SGB_YOFFSET, SGB_YOFFSET + 144 - 1); - bitmap.fill(0, r); - } - return; - case 3: /* Blank screen (white - or should it be color 0?) */ - { - rectangle r(SGB_XOFFSET, SGB_XOFFSET + 160 - 1, SGB_YOFFSET, SGB_YOFFSET + 144 - 1); - bitmap.fill(32767, r); - } - return; - } - - /* Draw the "border" if we're on the first line */ - if (m_current_line == 0) - { - refresh_border(); - } - } - if (cycles_to_go < 160) - { - m_end_x = MIN(160 - cycles_to_go,160); - - /* if background or screen disabled clear line */ - if (!(LCDCONT & 0x01)) - { - rectangle r(SGB_XOFFSET, SGB_XOFFSET + 160 - 1, m_current_line + SGB_YOFFSET, m_current_line + SGB_YOFFSET); - bitmap.fill(0, r); - } - while (l < 2) - { - UINT8 xindex, sgb_palette, *map, *tiles; - UINT16 data; - int i, tile_index; - - if (!m_layer[l].enabled) - { - l++; - continue; - } - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - tiles = m_layer[l].bg_tiles + ((m_layer[l].bgline & 7) << 1); - xindex = m_start_x; - if (xindex < m_layer[l].xstart) - xindex = m_layer[l].xstart; - i = m_end_x; - if (i > m_layer[l].xend) - i = m_layer[l].xend; - i = i - xindex; - - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index + 1] << 8); - data <<= m_layer[l].xshift; - - while (i > 0) - { - /* Figure out which palette we're using */ - assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < ARRAY_LENGTH(m_sgb_pal_map)); - sgb_palette = m_sgb_pal_map[(m_end_x - i) >> 3][m_current_line >> 3] << 2; - - while ((m_layer[l].xshift < 8) && i) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - plot_pixel(bitmap, xindex + SGB_XOFFSET, m_current_line + SGB_YOFFSET, m_sgb_pal[sgb_palette + m_gb_bpal[colour]]); - m_bg_zbuf[xindex] = colour; - xindex++; - data <<= 1; - m_layer[l].xshift++; - i--; - } - if (m_layer[l].xshift == 8) - { - /* Take possible changes to SCROLLY into account */ - if (l == 0) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - tiles = m_layer[l].bg_tiles + ((m_layer[l].bgline & 7) << 1); - } - - m_layer[l].xindex = (m_layer[l].xindex + 1) & 31; - m_layer[l].xshift = 0; - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index + 1] << 8); - } - } - l++; - } - if ((m_end_x == 160) && (LCDCONT & 0x02)) - { - update_sprites(); - } - m_start_x = m_end_x; - } - } - else - { - if (!(LCDCONT * 0x80)) - { - /* if screen disabled clear line */ - if (m_previous_line != m_current_line) - { - /* Also refresh border here??? */ - if (m_current_line < 144) - { - rectangle r(SGB_XOFFSET, SGB_XOFFSET + 160 - 1, m_current_line + SGB_YOFFSET, m_current_line + SGB_YOFFSET); - bitmap.fill(0, r); - } - m_previous_line = m_current_line; - } - } - } - - g_profiler.stop(); -} - -/* --- Game Boy Color Specific --- */ - -void cgb_lcd_device::update_sprites() -{ - bitmap_ind16 &bitmap = m_bitmap; - UINT8 height, tilemask, line, *oam; - int xindex, yindex; - - if (LCDCONT & 0x04) - { - height = 16; - tilemask = 0xFE; - } - else - { - height = 8; - tilemask = 0xFF; - } - - yindex = m_current_line; - line = m_current_line + 16; - - oam = m_oam + 39 * 4; - for (int i = 39; i >= 0; i--) - { - /* if sprite is on current line && x-coordinate && x-coordinate is < 168 */ - if (line >= oam[0] && line < (oam[0] + height) && oam[1] && oam[1] < 168) - { - UINT16 data; - UINT8 bit, pal; - - /* Handle mono mode for GB games */ - if (!m_gbc_mode) - pal = (oam[3] & 0x10) ? 4 : 0; - else - pal = ((oam[3] & 0x7) * 4); - - xindex = oam[1] - 8; - if (oam[3] & 0x40) /* flip y ? */ - { - data = *((UINT16 *) &m_vram[((oam[3] & 0x8)<<10) + (oam[2] & tilemask) * 16 + (height - 1 - line + oam[0]) * 2]); - } - else - { - data = *((UINT16 *) &m_vram[((oam[3] & 0x8)<<10) + (oam[2] & tilemask) * 16 + (line - oam[0]) * 2]); - } - - data = LITTLE_ENDIANIZE_INT16(data); - - switch (oam[3] & 0xA0) - { - case 0xA0: /* priority is set (behind bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if (colour && !m_bg_zbuf[xindex] && xindex >= 0 && xindex < 160) - { - if (!m_gbc_mode) - colour = pal ? m_gb_spal1[colour] : m_gb_spal0[colour]; - plot_pixel(bitmap, xindex, yindex, m_cgb_spal[pal + colour]); - } - data >>= 1; - } - break; - case 0x20: /* priority is not set (overlaps bgnd & wnd, flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - if ((m_bg_zbuf[xindex] & 0x80) && (m_bg_zbuf[xindex] & 0x7f) && (LCDCONT & 0x1)) - colour = 0; - if (colour && xindex >= 0 && xindex < 160) - { - if (!m_gbc_mode) - colour = pal ? m_gb_spal1[colour] : m_gb_spal0[colour]; - plot_pixel(bitmap, xindex, yindex, m_cgb_spal[pal + colour]); - } - data >>= 1; - } - break; - case 0x80: /* priority is set (behind bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if (colour && !m_bg_zbuf[xindex] && xindex >= 0 && xindex < 160) - { - if (!m_gbc_mode) - colour = pal ? m_gb_spal1[colour] : m_gb_spal0[colour]; - plot_pixel(bitmap, xindex, yindex, m_cgb_spal[pal + colour]); - } - data <<= 1; - } - break; - case 0x00: /* priority is not set (overlaps bgnd & wnd, don't flip x) */ - for (bit = 0; bit < 8; bit++, xindex++) - { - if (xindex >= 0 && xindex < 160) - { - register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - if ((m_bg_zbuf[xindex] & 0x80) && (m_bg_zbuf[xindex] & 0x7f) && (LCDCONT & 0x1)) - colour = 0; - if (colour) - { - if (!m_gbc_mode) - colour = pal ? m_gb_spal1[colour] : m_gb_spal0[colour]; - plot_pixel(bitmap, xindex, yindex, m_cgb_spal[pal + colour]); - } - } - data <<= 1; - } - break; - } - } - oam -= 4; - } -} - -void cgb_lcd_device::update_scanline() -{ - bitmap_ind16 &bitmap = m_bitmap; - - g_profiler.start(PROFILER_VIDEO); - - if ((LCDSTAT & 0x03) == 0x03) - { - /* Calcuate number of pixels to render based on time still left on the timer */ - UINT32 cycles_to_go = m_maincpu->attotime_to_cycles(m_lcd_timer->remaining()); - int l = 0; - - if (m_start_x < 0) - { - /* Window is enabled if the hardware says so AND the current scanline is - * within the window AND the window X coordinate is <=166 */ - m_layer[1].enabled = ((LCDCONT & 0x20) && (m_current_line >= WNDPOSY) && (WNDPOSX <= 166)) ? 1 : 0; - - /* BG is enabled if the hardware says so AND (window_off OR (window_on - * AND window's X position is >=7 )) */ - m_layer[0].enabled = ((LCDCONT & 0x01) && ((!m_layer[1].enabled) || (m_layer[1].enabled && (WNDPOSX >= 7)))) ? 1 : 0; - - if (m_layer[0].enabled) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - m_layer[0].bg_map = m_vram + m_gb_bgdtab_offs; - m_layer[0].gbc_map = m_vram + m_gbc_bgdtab_offs; - m_layer[0].xindex = SCROLLX >> 3; - m_layer[0].xshift = SCROLLX & 7; - m_layer[0].xstart = 0; - m_layer[0].xend = 160; - } - - if (m_layer[1].enabled) - { - int xpos; - - /* Window X position is offset by 7 so we'll need to adust */ - xpos = WNDPOSX - 7; - if (xpos < 0) - xpos = 0; - - m_layer[1].bgline = m_window_lines_drawn; - m_layer[1].bg_map = m_vram + m_gb_wndtab_offs; - m_layer[1].gbc_map = m_vram + m_gbc_wndtab_offs; - m_layer[1].xindex = 0; - m_layer[1].xshift = 0; - m_layer[1].xstart = xpos; - m_layer[1].xend = 160; - m_layer[0].xend = xpos; - } - m_start_x = 0; - } - - if (cycles_to_go < 160) - { - m_end_x = MIN(160 - cycles_to_go, 160); - /* Draw empty line when the background is disabled */ - if (!(LCDCONT & 0x01)) - { - rectangle r(m_start_x, m_end_x - 1, m_current_line, m_current_line); - bitmap.fill((!m_gbc_mode) ? 0 : 32767, r); - } - while (l < 2) - { - UINT8 xindex, *map, *tiles, *gbcmap; - UINT16 data; - int i, tile_index; - - if (!m_layer[l].enabled) - { - l++; - continue; - } - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - gbcmap = m_layer[l].gbc_map + ((m_layer[l].bgline << 2) & 0x3E0); - tiles = (gbcmap[m_layer[l].xindex] & 0x08) ? (m_vram + m_gbc_chrgen_offs) : (m_vram + m_gb_chrgen_offs); - - /* Check for vertical flip */ - if (gbcmap[m_layer[l].xindex] & 0x40) - { - tiles += ((7 - (m_layer[l].bgline & 0x07)) << 1); - } - else - { - tiles += ((m_layer[l].bgline & 0x07) << 1); - } - xindex = m_start_x; - if (xindex < m_layer[l].xstart) - xindex = m_layer[l].xstart; - i = m_end_x; - if (i > m_layer[l].xend) - i = m_layer[l].xend; - i = i - xindex; - - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index + 1] << 8); - /* Check for horinzontal flip */ - if (gbcmap[m_layer[l].xindex] & 0x20) - { - data >>= m_layer[l].xshift; - } - else - { - data <<= m_layer[l].xshift; - } - - while (i > 0) - { - while ((m_layer[l].xshift < 8) && i) - { - int colour; - /* Check for horinzontal flip */ - if (gbcmap[m_layer[l].xindex] & 0x20) - { - colour = ((data & 0x0100) ? 2 : 0) | ((data & 0x0001) ? 1 : 0); - data >>= 1; - } - else - { - colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0); - data <<= 1; - } - plot_pixel(bitmap, xindex, m_current_line, m_cgb_bpal[(!m_gbc_mode) ? m_gb_bpal[colour] : (((gbcmap[m_layer[l].xindex] & 0x07) * 4) + colour)]); - m_bg_zbuf[xindex] = colour + (gbcmap[m_layer[l].xindex] & 0x80); - xindex++; - m_layer[l].xshift++; - i--; - } - if (m_layer[l].xshift == 8) - { - /* Take possible changes to SCROLLY into account */ - if (l == 0) - { - m_layer[0].bgline = (SCROLLY + m_current_line) & 0xFF; - map = m_layer[l].bg_map + ((m_layer[l].bgline << 2) & 0x3E0); - gbcmap = m_layer[l].gbc_map + ((m_layer[l].bgline << 2) & 0x3E0); - } - - m_layer[l].xindex = (m_layer[l].xindex + 1) & 31; - m_layer[l].xshift = 0; - tiles = (gbcmap[m_layer[l].xindex] & 0x08) ? (m_vram + m_gbc_chrgen_offs) : (m_vram + m_gb_chrgen_offs); - - /* Check for vertical flip */ - if (gbcmap[m_layer[l].xindex] & 0x40) - { - tiles += ((7 - (m_layer[l].bgline & 0x07)) << 1); - } - else - { - tiles += ((m_layer[l].bgline & 0x07) << 1); - } - tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16; - data = tiles[tile_index] | (tiles[tile_index + 1] << 8); - } - } - l++; - } - if (m_end_x == 160 && (LCDCONT & 0x02)) - { - update_sprites(); - } - m_start_x = m_end_x; - } - } - else - { - if (!(LCDCONT & 0x80)) - { - /* Draw an empty line when LCD is disabled */ - if (m_previous_line != m_current_line) - { - if (m_current_line < 144) - { - const rectangle &r1 = m_screen->visible_area(); - rectangle r(r1.min_x, r1.max_x, m_current_line, m_current_line); - bitmap.fill((!m_gbc_mode) ? 0 : 32767 , r); - } - m_previous_line = m_current_line; - } - } - } - - g_profiler.stop(); -} - - -TIMER_CALLBACK_MEMBER(gb_lcd_device::video_init_vbl) -{ - m_maincpu->set_input_line(VBL_INT, ASSERT_LINE); -} - -UINT32 gb_lcd_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} - - -void gb_lcd_device::increment_scanline() -{ - m_current_line = (m_current_line + 1) % 154; - if (LCDCONT & 0x80) - { - CURLINE = m_current_line; - } - if (m_current_line == 0) - { - m_window_lines_drawn = 0; - } -} - -TIMER_CALLBACK_MEMBER(gb_lcd_device::lcd_timer_proc) -{ - static const int gb_sprite_cycles[] = { 0, 8, 20, 32, 44, 52, 64, 76, 88, 96, 108 }; - - m_state = param; - - if (LCDCONT & 0x80) - { - switch (m_state) - { - case GB_LCD_STATE_LYXX_PRE_M0: /* Just before switching to mode 0 */ - m_mode = 0; - if (LCDSTAT & 0x08) - { - if (!m_mode_irq) - { - if (!m_line_irq && !m_delayed_line_irq) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - else - { - m_mode_irq = 0; - } - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); - break; - case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ - /* update current scanline */ - update_scanline(); - /* Increment the number of window lines drawn if enabled */ - if (m_layer[1].enabled) - { - m_window_lines_drawn++; - } - m_previous_line = m_current_line; - /* Set Mode 0 lcdstate */ - m_mode = 0; - LCDSTAT &= 0xFC; - m_oam_locked = UNLOCKED; - m_vram_locked = UNLOCKED; - /* - There seems to a kind of feature in the Game Boy hardware when the lowest bits of the - SCROLLX register equals 3 or 7, then the delayed M0 irq is triggered 4 cycles later - than usual. - The SGB probably has the same bug. - */ - if ((SCROLLX & 0x03) == 0x03) - { - m_scrollx_adjust += 4; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); - break; - } - case GB_LCD_STATE_LYXX_M0_SCX3: - /* Generate lcd interrupt if requested */ - if (!m_mode_irq && (LCDSTAT & 0x08) && - ((!m_line_irq && m_delayed_line_irq) || !(LCDSTAT & 0x40))) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(196 - m_scrollx_adjust - m_sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); - break; - case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ - if (CURLINE < 143) - { - m_mode = 2; - m_triggering_mode_irq = (LCDSTAT & 0x20) ? 1 : 0; - if (m_triggering_mode_irq) - { - if (!m_mode_irq) - { - if (!m_line_irq && !m_delayed_line_irq) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - else - { - m_mode_irq = 0; - } - } - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); - break; - case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ - increment_scanline(); - m_delayed_line_irq = m_line_irq; - m_triggering_line_irq = ((CMPLINE == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - if (!m_mode_irq && !m_delayed_line_irq && m_triggering_line_irq && !m_triggering_mode_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* Reset LY==LYC STAT bit */ - LCDSTAT &= 0xFB; - /* Check if we're going into VBlank next */ - if (CURLINE == 144) - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); - } - else - { - /* Internally switch to mode 2 */ - m_mode = 2; - /* Generate lcd interrupt if requested */ - if (!m_mode_irq && m_triggering_mode_irq && - ((!m_triggering_line_irq && !m_delayed_line_irq) || !(LCDSTAT & 0x40))) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); - } - break; - case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ - /* Set Mode 2 lcdstate */ - m_mode = 2; - LCDSTAT = (LCDSTAT & 0xFC) | 0x02; - m_oam_locked = LOCKED; - /* Generate lcd interrupt if requested */ - if ((LCDSTAT & 0x20) && !m_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* Check for regular compensation of x-scroll register */ - m_scrollx_adjust = (SCROLLX & 0x04) ? 4 : 0; - /* Mode 2 lasts approximately 80 clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); - break; - case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ - /* Update STAT register to the correct state */ - LCDSTAT = (LCDSTAT & 0xFC) | 0x02; - m_oam_locked = LOCKED; - /* Generate lcd interrupt if requested */ - if ((m_delayed_line_irq && m_triggering_line_irq && !(LCDSTAT & 0x20)) || - (!m_mode_irq && !m_line_irq && !m_delayed_line_irq && m_triggering_mode_irq)) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_line_irq = m_triggering_line_irq; - m_triggering_mode_irq = 0; - /* Check if LY==LYC STAT bit should be set */ - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - /* Check for regular compensation of x-scroll register */ - m_scrollx_adjust = (SCROLLX & 0x04) ? 4 : 0; - /* Mode 2 last for approximately 80 clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); - break; - case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ - select_sprites(); - m_sprite_cycles = gb_sprite_cycles[m_sprCount]; - /* Set Mode 3 lcdstate */ - m_mode = 3; - LCDSTAT = (LCDSTAT & 0xFC) | 0x03; - m_vram_locked = LOCKED; - /* Check for compensations of x-scroll register */ - /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(168 + m_scrollx_adjust + m_sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); - m_start_x = -1; - break; - case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ - if (CURLINE == 144) - { - /* Trigger VBlank interrupt */ - m_maincpu->set_input_line(VBL_INT, ASSERT_LINE); - /* Set VBlank lcdstate */ - m_mode = 1; - LCDSTAT = (LCDSTAT & 0xFC) | 0x01; - /* Trigger LCD interrupt if requested */ - if (LCDSTAT & 0x10) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - /* Check if LY==LYC STAT bit should be set */ - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - if (m_delayed_line_irq && m_triggering_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); - break; - case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ - increment_scanline(); - m_delayed_line_irq = m_line_irq; - m_triggering_line_irq = ((CMPLINE == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - if (!m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* Reset LY==LYC STAT bit */ - LCDSTAT &= 0xFB; - if (m_current_line == 153) - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); - } - else - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); - } - break; - case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ - /* Check LY=LYC for line #153 */ - if (m_delayed_line_irq) - { - if (m_triggering_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - m_delayed_line_irq = m_delayed_line_irq | m_line_irq; - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - increment_scanline(); - m_triggering_line_irq = ((CMPLINE == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - LCDSTAT &= 0xFB; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1); - break; - case GB_LCD_STATE_LY00_M1_1: - if (!m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); - break; - case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ - if (m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); - break; - case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ - /* Set Mode 0 lcdstat */ - m_mode = 0; - LCDSTAT = (LCDSTAT & 0xFC); - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); - break; - } - } - else - { - increment_scanline(); - if (m_current_line < 144) - { - update_scanline(); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(456)); - } -} - - -// CGB specific code - -void cgb_lcd_device::hdma_trans(UINT16 length) -{ - UINT16 src, dst; - address_space &space = m_maincpu->space(AS_PROGRAM); - - src = ((UINT16)HDMA1 << 8) | (HDMA2 & 0xF0); - dst = ((UINT16)(HDMA3 & 0x1F) << 8) | (HDMA4 & 0xF0); - dst |= 0x8000; - while (length > 0) - { - space.write_byte(dst++, space.read_byte(src++)); - length--; - } - HDMA1 = src >> 8; - HDMA2 = src & 0xF0; - HDMA3 = 0x1f & (dst >> 8); - HDMA4 = dst & 0xF0; - HDMA5--; - if ((HDMA5 & 0x7f) == 0x7f) - { - HDMA5 = 0xff; - m_hdma_enabled = 0; - } -} - - -TIMER_CALLBACK_MEMBER(cgb_lcd_device::lcd_timer_proc) -{ - static const int cgb_sprite_cycles[] = { 0, 8, 20, 32, 44, 52, 64, 76, 88, 96, 108 }; - - m_state = param; - - if (LCDCONT & 0x80) - { - switch (m_state) - { - case GB_LCD_STATE_LYXX_PRE_M0: /* Just before switching to mode 0 */ - m_mode = 0; - if (LCDSTAT & 0x08) - { - if (!m_mode_irq) - { - if (!m_line_irq && !m_delayed_line_irq) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - else - { - m_mode_irq = 0; - } - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); - break; - case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ - /* update current scanline */ - update_scanline(); - /* Increment the number of window lines drawn if enabled */ - if (m_layer[1].enabled) - { - m_window_lines_drawn++; - } - m_previous_line = m_current_line; - /* Set Mode 0 lcdstate */ - m_mode = 0; - LCDSTAT &= 0xFC; - m_oam_locked = UNLOCKED; - m_vram_locked = UNLOCKED; - /* - There seems to a kind of feature in the Game Boy hardware when the lowest bits of the - SCROLLX register equals 3 or 7, then the delayed M0 irq is triggered 4 cycles later - than usual. - The SGB probably has the same bug. - */ - m_triggering_mode_irq = (LCDSTAT & 0x08) ? 1 : 0; - if ((SCROLLX & 0x03) == 0x03) - { - m_scrollx_adjust += 4; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); - break; - } - case GB_LCD_STATE_LYXX_M0_SCX3: - /* Generate lcd interrupt if requested */ - if (!m_mode_irq && m_triggering_mode_irq && - ((!m_line_irq && m_delayed_line_irq) || !(LCDSTAT & 0x40))) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - m_triggering_mode_irq = 0; - } - if ((SCROLLX & 0x03) == 0x03) - { - m_pal_locked = UNLOCKED; - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL); - break; - case GB_LCD_STATE_LYXX_M0_GBC_PAL: - m_pal_locked = UNLOCKED; - /* Check for HBLANK DMA */ - if (m_hdma_enabled) - { - hdma_trans(0x10); -// cpunum_set_reg(0, LR35902_DMA_CYCLES, 36); - } - else - { - m_hdma_possible = 1; - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(192 - m_scrollx_adjust - m_sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); - break; - case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ - m_cmp_line = CMPLINE; - if (CURLINE < 143) - { - m_mode = 2; - if (LCDSTAT & 0x20) - { - if (!m_mode_irq) - { - if (!m_line_irq && !m_delayed_line_irq) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - else - { - m_mode_irq = 0; - } - } - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); - break; - case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ - increment_scanline(); - m_delayed_line_irq = m_line_irq; - m_triggering_line_irq = ((m_cmp_line == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - if (!m_mode_irq && !m_delayed_line_irq && m_triggering_line_irq && !(LCDSTAT & 0x20)) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_hdma_possible = 0; - /* Check if we're going into VBlank next */ - if (CURLINE == 144) - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); - } - else - { - /* Internally switch to mode 2 */ - m_mode = 2; - /* Generate lcd interrupt if requested */ - if (!m_mode_irq && (LCDSTAT & 0x20) && - ((!m_triggering_line_irq && !m_delayed_line_irq) || !(LCDSTAT & 0x40))) - { - m_mode_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); - } - break; - case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ - /* Set Mode 2 lcdstate */ - m_mode = 2; - LCDSTAT = (LCDSTAT & 0xFC) | 0x02; - m_oam_locked = LOCKED; - /* Generate lcd interrupt if requested */ - if ((LCDSTAT & 0x20) && !m_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* Check for regular compensation of x-scroll register */ - m_scrollx_adjust = (SCROLLX & 0x04) ? 4 : 0; - /* Mode 2 lasts approximately 80 clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); - break; - case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ - /* Update STAT register to the correct state */ - LCDSTAT = (LCDSTAT & 0xFC) | 0x02; - m_oam_locked = LOCKED; - /* Generate lcd interrupt if requested */ - if ((m_delayed_line_irq && m_triggering_line_irq && !(LCDSTAT & 0x20)) || - (!m_mode_irq && !m_line_irq && !m_delayed_line_irq && (LCDSTAT & 0x20))) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_line_irq = m_triggering_line_irq; - /* Check if LY==LYC STAT bit should be set */ - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - else - { - LCDSTAT &= ~0x04; - } - /* Check for regular compensation of x-scroll register */ - m_scrollx_adjust = (SCROLLX & 0x04) ? 4 : 0; - /* Mode 2 last for approximately 80 clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); - break; - case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ - select_sprites(); - m_sprite_cycles = cgb_sprite_cycles[m_sprCount]; - /* Set Mode 3 lcdstate */ - m_mode = 3; - LCDSTAT = (LCDSTAT & 0xFC) | 0x03; - m_vram_locked = LOCKED; - m_pal_locked = LOCKED; - /* Check for compensations of x-scroll register */ - /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(168 + m_scrollx_adjust + m_sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); - m_start_x = -1; - break; - case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ - if (CURLINE == 144) - { - /* Trigger VBlank interrupt */ - m_maincpu->set_input_line(VBL_INT, ASSERT_LINE); - /* Set VBlank lcdstate */ - m_mode = 1; - LCDSTAT = (LCDSTAT & 0xFC) | 0x01; - /* Trigger LCD interrupt if requested */ - if (LCDSTAT & 0x10) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - /* Check if LY==LYC STAT bit should be set */ - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - else - { - LCDSTAT &= ~0x04; - } - if (m_delayed_line_irq && m_triggering_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); - break; - case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ - increment_scanline(); - m_delayed_line_irq = m_line_irq; - m_triggering_line_irq = ((CMPLINE == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - if (!m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - if (m_current_line == 153) - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); - } - else - { - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); - } - break; - case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ - /* Check LY=LYC for line #153 */ - if (m_delayed_line_irq) - { - if (m_triggering_line_irq) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - m_delayed_line_irq = m_delayed_line_irq | m_line_irq; - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - else - { - LCDSTAT &= ~0x04; - } - increment_scanline(); - m_triggering_line_irq = ((CMPLINE == CURLINE) && (LCDSTAT & 0x40)) ? 1 : 0; - m_line_irq = 0; - LCDSTAT &= 0xFB; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1); - break; - case GB_LCD_STATE_LY00_M1_1: - if (!m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); - break; - case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ - if (m_delayed_line_irq && m_triggering_line_irq) - { - m_line_irq = m_triggering_line_irq; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - } - else - { - LCDSTAT &= ~0x04; - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); - break; - case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ - /* Set Mode 0 lcdstat */ - m_mode = 0; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); - break; - } - } - else - { - increment_scanline(); - if (m_current_line < 144) - { - update_scanline(); - } - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(456)); - } -} - - -void gb_lcd_device::lcd_switch_on() -{ - m_current_line = 0; - m_previous_line = 153; - m_window_lines_drawn = 0; - m_line_irq = 0; - m_delayed_line_irq = 0; - m_mode = 0; - m_oam_locked = LOCKED; /* TODO: Investigate whether this OAM locking is correct. */ - /* Check for LY=LYC coincidence */ - if (CURLINE == CMPLINE) - { - LCDSTAT |= 0x04; - /* Generate lcd interrupt if requested */ - if (LCDSTAT & 0x40) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - m_state = GB_LCD_STATE_LY00_M2; - m_lcd_timer->adjust(m_maincpu->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); -} - - - - -READ8_MEMBER(gb_lcd_device::vram_r) -{ - return (m_vram_locked == LOCKED) ? 0xff : m_vram[offset + (m_vram_bank * 0x2000)]; -} - -WRITE8_MEMBER(gb_lcd_device::vram_w) -{ - if (m_vram_locked == LOCKED) - return; - - m_vram[offset + (m_vram_bank * 0x2000)] = data; -} - -READ8_MEMBER(gb_lcd_device::oam_r) -{ - return (m_oam_locked == LOCKED) ? 0xff : m_oam[offset]; -} - -WRITE8_MEMBER(gb_lcd_device::oam_w) -{ - if (m_oam_locked == LOCKED || offset >= 0xa0) - return; - - m_oam[offset] = data; -} - - - -READ8_MEMBER(gb_lcd_device::video_r) -{ - return m_vid_regs[offset]; -} - -WRITE8_MEMBER(gb_lcd_device::video_w) -{ - switch (offset) - { - case 0x00: /* LCDC - LCD Control */ - m_gb_chrgen_offs = (data & 0x10) ? 0x0000 : 0x0800; - m_gb_tile_no_mod = (data & 0x10) ? 0x00 : 0x80; - m_gb_bgdtab_offs = (data & 0x08) ? 0x1c00 : 0x1800; - m_gb_wndtab_offs = (data & 0x40) ? 0x1c00 : 0x1800; - /* if LCD controller is switched off, set STAT and LY to 00 */ - if (!(data & 0x80)) - { - LCDSTAT &= ~0x03; - CURLINE = 0; - m_oam_locked = UNLOCKED; - m_vram_locked = UNLOCKED; - } - /* If LCD is being switched on */ - if (!(LCDCONT & 0x80) && (data & 0x80)) - { - lcd_switch_on(); - } - break; - case 0x01: /* STAT - LCD Status */ - data = 0x80 | (data & 0x78) | (LCDSTAT & 0x07); - /* - Check for the STAT bug: - Writing to STAT when the LCD controller is active causes a STAT - interrupt to be triggered. - */ - if (LCDCONT & 0x80) - { - /* Triggers seen so far: - - 0x40 -> 0x00 - trigger - - 0x00 -> 0x08 - trigger - - 0x08 -> 0x00 - don't trigger - - 0x00 -> 0x20 (mode 3) - trigger - - 0x00 -> 0x60 (mode 2) - don't trigger - - 0x20 -> 0x60 (mode 3) - trigger - - 0x20 -> 0x40 (mode 3) - trigger - - 0x40 -> 0x20 (mode 2) - don't trigger - - 0x40 -> 0x08 (mode 0) - don't trigger - - 0x00 -> 0x40 - trigger only if LY==LYC - - 0x20 -> 0x00/0x08/0x10/0x20/0x40 (mode 2, after m2int) - don't trigger - - 0x20 -> 0x00/0x08/0x10/0x20/0x40 (mode 3, after m2int) - don't trigger - */ - if (!m_mode_irq && ((m_mode == 1) || - ((LCDSTAT & 0x40) && !(data & 0x68)) || - (!(LCDSTAT & 0x40) && (data & 0x40) && (LCDSTAT & 0x04)) || - (!(LCDSTAT & 0x48) && (data & 0x08)) || - ((LCDSTAT & 0x60) == 0x00 && (data & 0x60) == 0x20) || - ((LCDSTAT & 0x60) == 0x20 && (data & 0x40)) - )) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* - - 0x20 -> 0x08/0x18/0x28/0x48 (mode 0, after m2int) - trigger - - 0x20 -> 0x00/0x10/0x20/0x40 (mode 0, after m2int) - trigger (stat bug) - - 0x00 -> 0xXX (mode 0) - trigger stat bug - */ - if (m_mode_irq && m_mode == 0) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - break; - case 0x04: /* LY - LCD Y-coordinate */ - return; - case 0x05: /* LYC */ - if (CMPLINE != data) - { - if (CURLINE == data) - { - if (m_state != GB_LCD_STATE_LYXX_M0_INC && m_state != GB_LCD_STATE_LY9X_M1_INC) - { - LCDSTAT |= 0x04; - /* Generate lcd interrupt if requested */ - if (LCDSTAT & 0x40) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - } - else - { - LCDSTAT &= 0xFB; - m_triggering_line_irq = 0; - } - } - break; - case 0x06: /* DMA - DMA Transfer and Start Address */ - { - UINT8 *P = m_oam; - offset = (UINT16) data << 8; - for (data = 0; data < 0xA0; data++) - *P++ = space.read_byte(offset++); - } - return; - case 0x07: /* BGP - Background Palette */ - update_scanline(); - m_gb_bpal[0] = data & 0x3; - m_gb_bpal[1] = (data & 0xC) >> 2; - m_gb_bpal[2] = (data & 0x30) >> 4; - m_gb_bpal[3] = (data & 0xC0) >> 6; - break; - case 0x08: /* OBP0 - Object Palette 0 */ -// update_scanline(); - m_gb_spal0[0] = data & 0x3; - m_gb_spal0[1] = (data & 0xC) >> 2; - m_gb_spal0[2] = (data & 0x30) >> 4; - m_gb_spal0[3] = (data & 0xC0) >> 6; - break; - case 0x09: /* OBP1 - Object Palette 1 */ -// update_scanline(); - m_gb_spal1[0] = data & 0x3; - m_gb_spal1[1] = (data & 0xC) >> 2; - m_gb_spal1[2] = (data & 0x30) >> 4; - m_gb_spal1[3] = (data & 0xC0) >> 6; - break; - case 0x02: /* SCY - Scroll Y */ - case 0x03: /* SCX - Scroll X */ - update_scanline(); - break; - case 0x0A: /* WY - Window Y position */ - case 0x0B: /* WX - Window X position */ - break; - default: /* Unknown register, no change */ - return; - } - m_vid_regs[offset] = data; -} - -READ8_MEMBER(cgb_lcd_device::video_r) -{ - switch (offset) - { - case 0x11: /* FF51 */ - case 0x12: /* FF52 */ - case 0x13: /* FF53 */ - case 0x14: /* FF54 */ - return 0xFF; - case 0x29: /* FF69 */ - case 0x2B: /* FF6B */ - if (m_pal_locked == LOCKED) - { - return 0xFF; - } - break; - } - return m_vid_regs[offset]; -} - -WRITE8_MEMBER(cgb_lcd_device::video_w) -{ - switch (offset) - { - case 0x00: /* LCDC - LCD Control */ - m_gb_chrgen_offs = (data & 0x10) ? 0x0000 : 0x0800; - m_gbc_chrgen_offs = (data & 0x10) ? 0x2000 : 0x2800; - m_gb_tile_no_mod = (data & 0x10) ? 0x00 : 0x80; - m_gb_bgdtab_offs = (data & 0x08) ? 0x1c00 : 0x1800; - m_gbc_bgdtab_offs = (data & 0x08) ? 0x3c00 : 0x3800; - m_gb_wndtab_offs = (data & 0x40) ? 0x1c00 : 0x1800; - m_gbc_wndtab_offs = (data & 0x40) ? 0x3c00 : 0x3800; - /* if LCD controller is switched off, set STAT to 00 */ - if (!(data & 0x80)) - { - LCDSTAT &= ~0x03; - CURLINE = 0; - m_oam_locked = UNLOCKED; - m_vram_locked = UNLOCKED; - m_pal_locked = UNLOCKED; - } - /* If LCD is being switched on */ - if (!(LCDCONT & 0x80) && (data & 0x80)) - { - lcd_switch_on(); - } - break; - case 0x01: /* STAT - LCD Status */ - data = 0x80 | (data & 0x78) | (LCDSTAT & 0x07); - if (LCDCONT & 0x80) - { - /* - - 0x20 -> 0x08/0x18/0x28/0x48 (mode 0, after m2int) - trigger - */ - if (m_mode_irq && m_mode == 0 && (LCDSTAT & 0x28) == 0x20 && (data & 0x08)) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - /* Check if line irqs are being disabled */ - if (!(data & 0x40)) - { - m_delayed_line_irq = 0; - } - /* Check if line irqs are being enabled */ - if (!(LCDSTAT & 0x40) && (data & 0x40)) - { - if (CMPLINE == CURLINE) - { - m_line_irq = 1; - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - } - break; - case 0x05: /* LYC */ - if (CMPLINE != data) - { - if ((m_state != GB_LCD_STATE_LYXX_M0_PRE_INC && CURLINE == data) || - (m_state == GB_LCD_STATE_LYXX_M0_INC && m_triggering_line_irq)) - { - LCDSTAT |= 0x04; - /* Generate lcd interrupt if requested */ - if (LCDSTAT & 0x40) - { - m_maincpu->set_input_line(LCD_INT, ASSERT_LINE); - } - } - else - { - LCDSTAT &= 0xFB; - m_triggering_line_irq = 0; - m_cmp_line = data; - } - } - break; - case 0x07: /* BGP - GB background palette */ - update_scanline(); - m_gb_bpal[0] = data & 0x3; - m_gb_bpal[1] = (data & 0xC) >> 2; - m_gb_bpal[2] = (data & 0x30) >> 4; - m_gb_bpal[3] = (data & 0xC0) >> 6; - break; - case 0x08: /* OBP0 - GB Object 0 palette */ - m_gb_spal0[0] = data & 0x3; - m_gb_spal0[1] = (data & 0xC) >> 2; - m_gb_spal0[2] = (data & 0x30) >> 4; - m_gb_spal0[3] = (data & 0xC0) >> 6; - break; - case 0x09: /* OBP1 - GB Object 1 palette */ - m_gb_spal1[0] = data & 0x3; - m_gb_spal1[1] = (data & 0xC) >> 2; - m_gb_spal1[2] = (data & 0x30) >> 4; - m_gb_spal1[3] = (data & 0xC0) >> 6; - break; - case 0x0c: /* Undocumented register involved in selecting gb/gbc mode */ - logerror("Write to undocumented register: %X = %X\n", offset, data); - break; - case 0x0F: /* VBK - VRAM bank select */ - m_vram_bank = data & 0x01; - data |= 0xFE; - break; - case 0x11: /* HDMA1 - HBL General DMA - Source High */ - break; - case 0x12: /* HDMA2 - HBL General DMA - Source Low */ - data &= 0xF0; - break; - case 0x13: /* HDMA3 - HBL General DMA - Destination High */ - data &= 0x1F; - break; - case 0x14: /* HDMA4 - HBL General DMA - Destination Low */ - data &= 0xF0; - break; - case 0x15: /* HDMA5 - HBL General DMA - Mode, Length */ - if (!(data & 0x80)) - { - if (m_hdma_enabled) - { - m_hdma_enabled = 0; - data = HDMA5 & 0x80; - } - else - { - /* General DMA */ - hdma_trans(((data & 0x7F) + 1) * 0x10); -// cpunum_set_reg(0, LR35902_DMA_CYCLES, 4 + (((data & 0x7F) + 1) * 32)); - data = 0xff; - } - } - else - { - /* H-Blank DMA */ - m_hdma_enabled = 1; - data &= 0x7f; - m_vid_regs[offset] = data; - /* Check if HDMA should be immediately performed */ - if (m_hdma_possible) - { - hdma_trans(0x10); -// cpunum_set_reg(0, LR35902_DMA_CYCLES, 36); - m_hdma_possible = 0; - } - } - break; - case 0x28: /* BCPS - Background palette specification */ - GBCBCPS = data; - if (data & 0x01) - GBCBCPD = m_cgb_bpal[(data >> 1) & 0x1F] >> 8; - else - GBCBCPD = m_cgb_bpal[(data >> 1) & 0x1F] & 0xFF; - break; - case 0x29: /* BCPD - background palette data */ - if (m_pal_locked == LOCKED) - { - return; - } - GBCBCPD = data; - if (GBCBCPS & 0x01) - m_cgb_bpal[(GBCBCPS >> 1) & 0x1F] = ((data << 8) | (m_cgb_bpal[(GBCBCPS >> 1) & 0x1F] & 0xFF)) & 0x7FFF; - else - m_cgb_bpal[(GBCBCPS >> 1) & 0x1F] = ((m_cgb_bpal[(GBCBCPS >> 1) & 0x1F] & 0xFF00) | data) & 0x7FFF; - if (GBCBCPS & 0x80) - { - GBCBCPS++; - GBCBCPS &= 0xBF; - } - break; - case 0x2A: /* OCPS - Object palette specification */ - GBCOCPS = data; - if (data & 0x01) - GBCOCPD = m_cgb_spal[(data >> 1) & 0x1F] >> 8; - else - GBCOCPD = m_cgb_spal[(data >> 1) & 0x1F] & 0xFF; - break; - case 0x2B: /* OCPD - Object palette data */ - if (m_pal_locked == LOCKED) - { - return; - } - GBCOCPD = data; - if (GBCOCPS & 0x01) - m_cgb_spal[(GBCOCPS >> 1) & 0x1F] = ((data << 8) | (m_cgb_spal[(GBCOCPS >> 1) & 0x1F] & 0xFF)) & 0x7FFF; - else - m_cgb_spal[(GBCOCPS >> 1) & 0x1F] = ((m_cgb_spal[(GBCOCPS >> 1) & 0x1F] & 0xFF00) | data) & 0x7FFF; - if (GBCOCPS & 0x80) - { - GBCOCPS++; - GBCOCPS &= 0xBF; - } - break; - /* Undocumented registers */ - case 0x2C: - /* bit 0 can be read/written */ - logerror("Write to undocumented register: %X = %X\n", offset, data); - data = 0xFE | (data & 0x01); - if (data & 0x01) - { - m_gbc_mode = 0; - } - break; - case 0x32: - case 0x33: - case 0x34: - /* whole byte can be read/written */ - logerror("Write to undocumented register: %X = %X\n", offset, data); - break; - case 0x35: - /* bit 4-6 can be read/written */ - logerror("Write to undocumented register: %X = %X\n", offset, data); - data = 0x8F | (data & 0x70); - break; - case 0x36: - case 0x37: - logerror("Write to undocumented register: %X = %X\n", offset, data); - return; - default: - /* we didn't handle the write, so pass it to the GB handler */ - gb_lcd_device::video_w(space, offset, data); - return; - } - - m_vid_regs[offset] = data; -} - -// Super Game Boy - -void sgb_lcd_device::sgb_io_write_pal(int offs, UINT8 *data) -{ - switch (offs) - { - case 0x00: /* PAL01 */ - m_sgb_pal[0 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[0 * 4 + 1] = data[3] | (data[4] << 8); - m_sgb_pal[0 * 4 + 2] = data[5] | (data[6] << 8); - m_sgb_pal[0 * 4 + 3] = data[7] | (data[8] << 8); - m_sgb_pal[1 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[1 * 4 + 1] = data[9] | (data[10] << 8); - m_sgb_pal[1 * 4 + 2] = data[11] | (data[12] << 8); - m_sgb_pal[1 * 4 + 3] = data[13] | (data[14] << 8); - break; - case 0x01: /* PAL23 */ - m_sgb_pal[2 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[2 * 4 + 1] = data[3] | (data[4] << 8); - m_sgb_pal[2 * 4 + 2] = data[5] | (data[6] << 8); - m_sgb_pal[2 * 4 + 3] = data[7] | (data[8] << 8); - m_sgb_pal[3 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[3 * 4 + 1] = data[9] | (data[10] << 8); - m_sgb_pal[3 * 4 + 2] = data[11] | (data[12] << 8); - m_sgb_pal[3 * 4 + 3] = data[13] | (data[14] << 8); - break; - case 0x02: /* PAL03 */ - m_sgb_pal[0 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[0 * 4 + 1] = data[3] | (data[4] << 8); - m_sgb_pal[0 * 4 + 2] = data[5] | (data[6] << 8); - m_sgb_pal[0 * 4 + 3] = data[7] | (data[8] << 8); - m_sgb_pal[3 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[3 * 4 + 1] = data[9] | (data[10] << 8); - m_sgb_pal[3 * 4 + 2] = data[11] | (data[12] << 8); - m_sgb_pal[3 * 4 + 3] = data[13] | (data[14] << 8); - break; - case 0x03: /* PAL12 */ - m_sgb_pal[1 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[1 * 4 + 1] = data[3] | (data[4] << 8); - m_sgb_pal[1 * 4 + 2] = data[5] | (data[6] << 8); - m_sgb_pal[1 * 4 + 3] = data[7] | (data[8] << 8); - m_sgb_pal[2 * 4 + 0] = data[1] | (data[2] << 8); - m_sgb_pal[2 * 4 + 1] = data[9] | (data[10] << 8); - m_sgb_pal[2 * 4 + 2] = data[11] | (data[12] << 8); - m_sgb_pal[2 * 4 + 3] = data[13] | (data[14] << 8); - break; - case 0x04: /* ATTR_BLK */ - { - UINT8 I, J, K, o; - for( K = 0; K < data[1]; K++ ) - { - o = K * 6; - if( data[o + 2] & 0x1 ) - { - for( I = data[ o + 4]; I <= data[o + 6]; I++ ) - { - for( J = data[o + 5]; J <= data[o + 7]; J++ ) - { - m_sgb_pal_map[I][J] = data[o + 3] & 0x3; - } - } - } - } - } - break; - case 0x05: /* ATTR_LIN */ - { - UINT8 J, K; - if( data[1] > 15 ) - data[1] = 15; - for( K = 0; K < data[1]; K++ ) - { - if( data[K + 1] & 0x80 ) - { - for( J = 0; J < 20; J++ ) - { - m_sgb_pal_map[J][data[K + 1] & 0x1f] = (data[K + 1] & 0x60) >> 5; - } - } - else - { - for( J = 0; J < 18; J++ ) - { - m_sgb_pal_map[data[K + 1] & 0x1f][J] = (data[K + 1] & 0x60) >> 5; - } - } - } - } - break; - case 0x06: /* ATTR_DIV */ - { - UINT8 I, J; - if( data[1] & 0x40 ) /* Vertical */ - { - for( I = 0; I < data[2]; I++ ) - { - for( J = 0; J < 20; J++ ) - { - m_sgb_pal_map[J][I] = (data[1] & 0xC) >> 2; - } - } - for( J = 0; J < 20; J++ ) - { - m_sgb_pal_map[J][data[2]] = (data[1] & 0x30) >> 4; - } - for( I = data[2] + 1; I < 18; I++ ) - { - for( J = 0; J < 20; J++ ) - { - m_sgb_pal_map[J][I] = data[1] & 0x3; - } - } - } - else /* Horizontal */ - { - for( I = 0; I < data[2]; I++ ) - { - for( J = 0; J < 18; J++ ) - { - m_sgb_pal_map[I][J] = (data[1] & 0xC) >> 2; - } - } - for( J = 0; J < 18; J++ ) - { - m_sgb_pal_map[data[2]][J] = (data[1] & 0x30) >> 4; - } - for( I = data[2] + 1; I < 20; I++ ) - { - for( J = 0; J < 18; J++ ) - { - m_sgb_pal_map[I][J] = data[1] & 0x3; - } - } - } - } - break; - case 0x07: /* ATTR_CHR */ - { - UINT16 I, sets; - UINT8 x, y; - sets = (data[3] | (data[4] << 8) ); - if( sets > 360 ) - sets = 360; - sets >>= 2; - sets += 6; - x = data[1]; - y = data[2]; - if( data[5] ) /* Vertical */ - { - for( I = 6; I < sets; I++ ) - { - m_sgb_pal_map[x][y++] = (data[I] & 0xC0) >> 6; - if( y > 17 ) - { - y = 0; - x++; - if( x > 19 ) - x = 0; - } - - m_sgb_pal_map[x][y++] = (data[I] & 0x30) >> 4; - if( y > 17 ) - { - y = 0; - x++; - if( x > 19 ) - x = 0; - } - - m_sgb_pal_map[x][y++] = (data[I] & 0xC) >> 2; - if( y > 17 ) - { - y = 0; - x++; - if( x > 19 ) - x = 0; - } - - m_sgb_pal_map[x][y++] = data[I] & 0x3; - if( y > 17 ) - { - y = 0; - x++; - if( x > 19 ) - x = 0; - } - } - } - else /* horizontal */ - { - for( I = 6; I < sets; I++ ) - { - m_sgb_pal_map[x++][y] = (data[I] & 0xC0) >> 6; - if( x > 19 ) - { - x = 0; - y++; - if( y > 17 ) - y = 0; - } - - m_sgb_pal_map[x++][y] = (data[I] & 0x30) >> 4; - if( x > 19 ) - { - x = 0; - y++; - if( y > 17 ) - y = 0; - } - - m_sgb_pal_map[x++][y] = (data[I] & 0xC) >> 2; - if( x > 19 ) - { - x = 0; - y++; - if( y > 17 ) - y = 0; - } - - m_sgb_pal_map[x++][y] = data[I] & 0x3; - if( x > 19 ) - { - x = 0; - y++; - if( y > 17 ) - y = 0; - } - } - } - } - break; - case 0x08: /* SOUND */ - /* This command enables internal sound effects */ - /* Not Implemented */ - break; - case 0x09: /* SOU_TRN */ - /* This command sends data to the SNES sound processor. - We'll need to emulate that for this to be used */ - /* Not Implemented */ - break; - case 0x0A: /* PAL_SET */ - { - UINT16 index_; - - /* Palette 0 */ - index_ = (UINT16)(data[1] | (data[2] << 8)) * 4; - m_sgb_pal[0] = m_sgb_pal_data[index_]; - m_sgb_pal[1] = m_sgb_pal_data[index_ + 1]; - m_sgb_pal[2] = m_sgb_pal_data[index_ + 2]; - m_sgb_pal[3] = m_sgb_pal_data[index_ + 3]; - /* Palette 1 */ - index_ = (UINT16)(data[3] | (data[4] << 8)) * 4; - m_sgb_pal[4] = m_sgb_pal_data[index_]; - m_sgb_pal[5] = m_sgb_pal_data[index_ + 1]; - m_sgb_pal[6] = m_sgb_pal_data[index_ + 2]; - m_sgb_pal[7] = m_sgb_pal_data[index_ + 3]; - /* Palette 2 */ - index_ = (UINT16)(data[5] | (data[6] << 8)) * 4; - m_sgb_pal[8] = m_sgb_pal_data[index_]; - m_sgb_pal[9] = m_sgb_pal_data[index_ + 1]; - m_sgb_pal[10] = m_sgb_pal_data[index_ + 2]; - m_sgb_pal[11] = m_sgb_pal_data[index_ + 3]; - /* Palette 3 */ - index_ = (UINT16)(data[7] | (data[8] << 8)) * 4; - m_sgb_pal[12] = m_sgb_pal_data[index_]; - m_sgb_pal[13] = m_sgb_pal_data[index_ + 1]; - m_sgb_pal[14] = m_sgb_pal_data[index_ + 2]; - m_sgb_pal[15] = m_sgb_pal_data[index_ + 3]; - /* Attribute File */ - if (data[9] & 0x40) - m_sgb_window_mask = 0; - m_sgb_atf = (data[9] & 0x3f) * (18 * 5); - if (data[9] & 0x80) - { - for (int j = 0; j < 18; j++ ) - { - for (int i = 0; i < 5; i++ ) - { - m_sgb_pal_map[i * 4][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0xC0) >> 6; - m_sgb_pal_map[(i * 4) + 1][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0x30) >> 4; - m_sgb_pal_map[(i * 4) + 2][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0xC) >> 2; - m_sgb_pal_map[(i * 4) + 3][j] = m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0x3; - } - } - } - } - break; - case 0x0B: /* PAL_TRN */ - { - UINT16 col; - - for (int i = 0; i < 2048; i++ ) - { - col = (m_vram[0x0800 + (i * 2) + 1] << 8) | m_vram[0x0800 + (i * 2)]; - m_sgb_pal_data[i] = col; - } - } - break; - case 0x0C: /* ATRC_EN */ - /* Not Implemented */ - break; - case 0x0D: /* TEST_EN */ - /* Not Implemented */ - break; - case 0x0E: /* ICON_EN */ - /* Not Implemented */ - break; - case 0x0F: /* DATA_SND */ - /* Not Implemented */ - break; - case 0x10: /* DATA_TRN */ - /* Not Implemented */ - break; - case 0x12: /* JUMP */ - /* Not Implemented */ - break; - case 0x13: /* CHR_TRN */ - if (data[1] & 0x1) - memcpy(m_sgb_tile_data + 4096, m_vram + 0x0800, 4096); - else - memcpy(m_sgb_tile_data, m_vram + 0x0800, 4096); - break; - case 0x14: /* PCT_TRN */ - { - UINT16 col; - if (m_sgb_border_hack) - { - memcpy(m_sgb_tile_map, m_vram + 0x1000, 2048); - for (int i = 0; i < 64; i++) - { - col = (m_vram[0x0800 + (i * 2) + 1 ] << 8) | m_vram[0x0800 + (i * 2)]; - m_sgb_pal[SGB_BORDER_PAL_OFFSET + i] = col; - } - } - else /* Do things normally */ - { - memcpy(m_sgb_tile_map, m_vram + 0x0800, 2048); - for (int i = 0; i < 64; i++) - { - col = (m_vram[0x1000 + (i * 2) + 1] << 8) | m_vram[0x1000 + (i * 2)]; - m_sgb_pal[SGB_BORDER_PAL_OFFSET + i] = col; - } - } - } - break; - case 0x15: /* ATTR_TRN */ - memcpy(m_sgb_atf_data, m_vram + 0x0800, 4050); - break; - case 0x16: /* ATTR_SET */ - { - /* Attribute File */ - if (data[1] & 0x40) - m_sgb_window_mask = 0; - m_sgb_atf = (data[1] & 0x3f) * (18 * 5); - for (int j = 0; j < 18; j++) - { - for (int i = 0; i < 5; i++) - { - m_sgb_pal_map[i * 4][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0xC0) >> 6; - m_sgb_pal_map[(i * 4) + 1][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0x30) >> 4; - m_sgb_pal_map[(i * 4) + 2][j] = (m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0xC) >> 2; - m_sgb_pal_map[(i * 4) + 3][j] = m_sgb_atf_data[(j * 5) + m_sgb_atf + i] & 0x3; - } - } - } - break; - case 0x17: /* MASK_EN */ - m_sgb_window_mask = data[1]; - break; - case 0x18: /* OBJ_TRN */ - /* Not Implemnted */ - break; - case 0x19: /* ? */ - /* Called by: dkl,dkl2,dkl3,zeldadx - But I don't know what it is for. */ - /* Not Implemented */ - break; - case 0x1E: /* Used by bootrom to transfer the gb cart header */ - break; - case 0x1F: /* Used by bootrom to transfer the gb cart header */ - break; - default: - logerror( "SGB: Unknown Command 0x%02x!\n", data[0] >> 3 ); - } - -} diff --git a/src/mess/video/gb_lcd.h b/src/mess/video/gb_lcd.h deleted file mode 100644 index 31bd0c30403..00000000000 --- a/src/mess/video/gb_lcd.h +++ /dev/null @@ -1,215 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/***************************************************************************** - * - * video/gb_lcd.h - * - ****************************************************************************/ - -#ifndef __GB_LCD_H__ -#define __GB_LCD_H__ - -#include "emu.h" - - -#define _NR_GB_VID_REGS 0x40 - - -struct layer_struct { - UINT8 enabled; - UINT8 *bg_tiles; - UINT8 *bg_map; - UINT8 xindex; - UINT8 xshift; - UINT8 xstart; - UINT8 xend; - /* GBC specific */ - UINT8 *gbc_map; - INT16 bgline; -}; - - -class gb_lcd_device : public device_t, - public device_video_interface -{ -public: - gb_lcd_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - gb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - - DECLARE_READ8_MEMBER(vram_r); - DECLARE_WRITE8_MEMBER(vram_w); - DECLARE_READ8_MEMBER(oam_r); - DECLARE_WRITE8_MEMBER(oam_w); - virtual DECLARE_READ8_MEMBER(video_r); - virtual DECLARE_WRITE8_MEMBER(video_w); - - // FIXME: remove it when proper sgb support is added - void set_sgb_hack(bool val) { m_sgb_border_hack = val ? 1 : 0; } - -protected: - inline void plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color); - - void select_sprites(); - virtual void update_sprites(); - virtual void update_scanline(); - - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - void common_start(); - void common_reset(); - - // pointer to the main system - cpu_device *m_maincpu; - - // state variables - bitmap_ind16 m_bitmap; - - UINT8 m_sgb_atf_data[4050]; /* (SGB) Attributes files */ - UINT32 m_sgb_atf; - UINT16 m_sgb_pal_data[4096]; - UINT8 m_sgb_pal_map[20][18]; - UINT16 m_sgb_pal[128]; - UINT8 *m_sgb_tile_data; - UINT8 m_sgb_tile_map[2048]; - UINT8 m_sgb_window_mask; - - // this is temporarily needed for a bunch of games which draw the border differently... - int m_sgb_border_hack; - - int m_window_lines_drawn; - - UINT8 m_vid_regs[_NR_GB_VID_REGS]; - UINT8 m_bg_zbuf[160]; - - UINT16 m_cgb_bpal[32]; /* CGB current background palette table */ - UINT16 m_cgb_spal[32]; /* CGB current sprite palette table */ - - UINT8 m_gb_bpal[4]; /* Background palette */ - UINT8 m_gb_spal0[4]; /* Sprite 0 palette */ - UINT8 m_gb_spal1[4]; /* Sprite 1 palette */ - - /* Things used to render current line */ - int m_current_line; /* Current line */ - int m_cmp_line; /* Compare line */ - int m_sprCount; /* Number of sprites on current line */ - int m_sprite[10]; /* References to sprites to draw on current line */ - int m_previous_line; /* Previous line we've drawn in */ - int m_start_x; /* Pixel to start drawing from (inclusive) */ - int m_end_x; /* Pixel to end drawing (exclusive) */ - int m_mode; /* Keep track of internal STAT mode */ - int m_state; /* Current state of the video state machine */ - int m_lcd_irq_line; - int m_triggering_line_irq; - int m_line_irq; - int m_triggering_mode_irq; - int m_mode_irq; - int m_delayed_line_irq; - int m_sprite_cycles; - int m_scrollx_adjust; - int m_oam_locked; - int m_vram_locked; - int m_pal_locked; - int m_hdma_enabled; - int m_hdma_possible; - struct layer_struct m_layer[2]; - emu_timer *m_lcd_timer; - int m_gbc_mode; - - UINT8 *m_vram; // Pointer to VRAM - UINT8 *m_oam; // Pointer to OAM memory - UINT8 m_gb_tile_no_mod; - UINT32 m_gb_chrgen_offs; // GB Character generator - UINT32 m_gb_bgdtab_offs; // GB Background character table - UINT32 m_gb_wndtab_offs; // GB Window character table - UINT32 m_gbc_chrgen_offs; // CGB Character generator - UINT32 m_gbc_bgdtab_offs; // CGB Background character table - UINT32 m_gbc_wndtab_offs; // CGB Window character table - int m_vram_bank; - - TIMER_CALLBACK_MEMBER(video_init_vbl); - virtual TIMER_CALLBACK_MEMBER(lcd_timer_proc); - virtual void videoptr_restore(); - void save_gb_video(); - void increment_scanline(); - void lcd_switch_on(); -}; - - -class mgb_lcd_device : public gb_lcd_device -{ -public: - mgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - -protected: - - // device-level overrides - virtual void device_start(); -}; - - -class sgb_lcd_device : public gb_lcd_device -{ -public: - sgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - void sgb_io_write_pal(int offs, UINT8 *data); - -protected: - - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - - virtual void update_sprites(); - virtual void update_scanline(); - void refresh_border(); -}; - - -class cgb_lcd_device : public gb_lcd_device -{ -public: - cgb_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - virtual DECLARE_READ8_MEMBER(video_r); - virtual DECLARE_WRITE8_MEMBER(video_w); - -protected: - - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - - virtual void update_sprites(); - virtual void update_scanline(); - - virtual TIMER_CALLBACK_MEMBER(lcd_timer_proc); - virtual void videoptr_restore(); - void hdma_trans(UINT16 length); -}; - - -extern const device_type GB_LCD_DMG; -extern const device_type GB_LCD_MGB; -extern const device_type GB_LCD_SGB; -extern const device_type GB_LCD_CGB; - - -#define MCFG_GB_LCD_DMG_ADD(_tag ) \ - MCFG_DEVICE_ADD( _tag, GB_LCD_DMG, 0 ) - -#define MCFG_GB_LCD_MGB_ADD(_tag ) \ - MCFG_DEVICE_ADD( _tag, GB_LCD_MGB, 0 ) - -#define MCFG_GB_LCD_SGB_ADD(_tag ) \ - MCFG_DEVICE_ADD( _tag, GB_LCD_SGB, 0 ) - -#define MCFG_GB_LCD_CGB_ADD(_tag ) \ - MCFG_DEVICE_ADD( _tag, GB_LCD_CGB, 0 ) - - -#endif /* GB_LCD_H_ */ diff --git a/src/mess/video/gba.c b/src/mess/video/gba.c deleted file mode 100644 index 0699f047c98..00000000000 --- a/src/mess/video/gba.c +++ /dev/null @@ -1,1901 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont,Ryan Holtz -/*************************************************************************** - - gba.c - - File to handle emulation of the video hardware of the Game Boy Advance - - By R. Belmont, MooglyGuy - -***************************************************************************/ - -#include "emu.h" -#include "includes/gba.h" - -#define VERBOSE_LEVEL (0) - -INLINE void ATTR_PRINTF(3,4) verboselog(running_machine &machine, int n_level, const char *s_fmt, ...) -{ - if( VERBOSE_LEVEL >= n_level ) - { - va_list v; - char buf[ 32768 ]; - va_start( v, s_fmt ); - vsprintf( buf, s_fmt, v ); - va_end( v ); - logerror( "%08x: %s", machine.driver_data()->m_maincpu->pc(), buf ); - } -} - -static const int coeff[32] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 -}; - -/* Utility functions */ -INLINE UINT32 alpha_blend_pixel(UINT32 color0, UINT32 color1, int ca, int cb); -INLINE UINT32 increase_brightness(UINT32 color, int coeff_); -INLINE UINT32 decrease_brightness(UINT32 color, int coeff_); - -#define GBA_MODE0 0 -#define GBA_MODE1 1 -#define GBA_MODE2 2 -#define GBA_MODE345 3 - -#define GBA_SUBMODE0 0 -#define GBA_SUBMODE1 1 -#define GBA_SUBMODE2 2 - -inline void gba_state::update_mask(UINT8* mask, int mode, int submode, UINT32* obj_win, UINT8 inwin0, UINT8 inwin1, UINT8 in0_mask, UINT8 in1_mask, UINT8 out_mask) -{ - UINT8 mode_mask = 0; - if (submode == GBA_SUBMODE2) - { - for (int x = 0; x < 240; x++) - { - mask[x] = out_mask; - - if ((obj_win[x] & 0x80000000) == 0) - mask[x] = m_WINOUT >> 8; - - if (inwin1) - { - if (is_in_window(x, 1)) - mask[x] = in1_mask; - } - - if (inwin0) - { - if (is_in_window(x, 0)) - mask[x] = in0_mask; - } - } - } - - if (mode == GBA_MODE1) - { - // disable line3 - mode_mask = ~0x08; - } - else if (mode == GBA_MODE2) - { - // disable line0 & line1 - mode_mask = ~0x03; - } - else if (mode == GBA_MODE345) - { - // disable line0, line1 & line3 - mode_mask = ~0x0b; - } - - - if (mode_mask) - { - for (int x = 0; x < 240; x++) - mask[x] &= mode_mask; - } -} - -void gba_state::draw_modes(int mode, int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) -{ - UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; - int inWindow0 = 0; - int inWindow1 = 0; - UINT8 inWin0Mask = m_WININ & 0x00ff; - UINT8 inWin1Mask = m_WININ >> 8; - UINT8 outMask = m_WINOUT & 0x00ff; - UINT8 masks[240]; // this puts together WinMasks with the fact that some modes/submodes skip specific layers! - - if (submode == GBA_SUBMODE2) - { - if (m_DISPCNT & DISPCNT_WIN0_EN) - { - UINT8 v0 = m_WIN0V >> 8; - UINT8 v1 = m_WIN0V & 0x00ff; - inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; - if (v1 >= v0) - inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; - else - inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; - } - - if (m_DISPCNT & DISPCNT_WIN1_EN) - { - UINT8 v0 = m_WIN1V >> 8; - UINT8 v1 = m_WIN1V & 0x00ff; - inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; - if (v1 >= v0) - inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; - else - inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; - } - } - - // Draw BG - switch (mode) - { - case 0: - draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); - draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); - draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS); - draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS); - break; - case 1: - draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); - draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); - draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); - break; - case 2: - draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); - draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed); - break; - case 3: - case 4: - case 5: - draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp); - break; - } - - // Draw OAM - draw_gba_oam(lineOBJ, y); - if (submode == GBA_SUBMODE2) - draw_gba_oam_window(lineOBJWin, y); - - memset(masks, 0xff, sizeof(masks)); - update_mask(&masks[0], mode, submode, lineOBJWin, inWindow0, inWindow1, inWin0Mask, inWin1Mask, outMask); - - for (int x = 0; x < 240; x++) - { - UINT32 color = backdrop; - UINT8 top = 0x20; - - if ((UINT8)(line0[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x01) - { - color = line0[x]; - top = 0x01; - } - - if ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x02) - { - color = line1[x]; - top = 0x02; - } - - if ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x04) - { - color = line2[x]; - top = 0x04; - } - - if ((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x08) - { - color = line3[x]; - top = 0x08; - } - - if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x10) - { - color = lineOBJ[x]; - top = 0x10; - } - - if (color & 0x00010000) - { - if (submode != GBA_SUBMODE0 || top == 0x10) - { - UINT32 back = backdrop; - UINT8 top2 = 0x20; - - if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x01) - { - back = line0[x]; - top2 = 0x01; - } - - if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x02) - { - back = line1[x]; - top2 = 0x02; - } - - if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x04) - { - back = line2[x]; - top2 = 0x04; - } - - if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x08) - { - back = line3[x]; - top2 = 0x08; - } - - if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) - color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); - else - { - if (top & m_BLDCNT) - { - switch(m_BLDCNT & BLDCNT_SFX) - { - case BLDCNT_SFX_LIGHTEN: - color = increase_brightness(color, coeff[m_BLDY & 0x1f]); - break; - case BLDCNT_SFX_DARKEN: - color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); - break; - } - } - } - } - } - else if (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && masks[x] & 0x20)) - { - if (top & m_BLDCNT) - { - switch(m_BLDCNT & BLDCNT_SFX) - { - case BLDCNT_SFX_NONE: - break; - case BLDCNT_SFX_ALPHA: - { - UINT32 back = backdrop; - UINT8 top2 = 0x20; - - if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x01) - { - if (top != 0x01) - { - back = line0[x]; - top2 = 0x01; - } - } - - if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x02) - { - if (top != 0x02) - { - back = line1[x]; - top2 = 0x02; - } - } - - if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x04) - { - if (top != 0x04) - { - back = line2[x]; - top2 = 0x04; - } - } - - if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x08) - { - if (top != 0x08) - { - back = line3[x]; - top2 = 0x08; - } - } - - if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x10) - { - if (top != 0x10) - { - back = lineOBJ[x]; - top2 = 0x10; - } - } - - if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) - color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); - } - break; - case BLDCNT_SFX_LIGHTEN: - color = increase_brightness(color, coeff[m_BLDY & 0x1f]); - break; - case BLDCNT_SFX_DARKEN: - color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); - break; - } - } - } - lineMix[x] = color; - } - if (mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) - m_gfxBG2Changed = 0; - if (mode == GBA_MODE2) - m_gfxBG3Changed = 0; -} - -void gba_state::draw_roz_bitmap_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth) -{ - UINT8 *src8 = (UINT8 *)m_gba_vram.target(); - UINT16 *src16 = (UINT16 *)m_gba_vram.target(); - UINT16 *palette = (UINT16 *)m_gba_pram.target(); - INT32 sx = (depth == 4) ? 160 : 240; - INT32 sy = (depth == 4) ? 128 : 160; - UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; - INT32 cx, cy, pixx, pixy, x; - - if ((depth == 8) && (m_DISPCNT & DISPCNT_FRAMESEL)) - src8 += 0xa000; - - if ((depth == 4) && (m_DISPCNT & DISPCNT_FRAMESEL)) - src16 += 0xa000/2; - - // sign extend roz parameters - if (X & 0x08000000) X |= 0xf0000000; - if (Y & 0x08000000) Y |= 0xf0000000; - if (PA & 0x8000) PA |= 0xffff0000; - if (PB & 0x8000) PB |= 0xffff0000; - if (PC & 0x8000) PC |= 0xffff0000; - if (PD & 0x8000) PD |= 0xffff0000; - - if(ypos == 0) - changed = 3; - - if(changed & 1) - *currentx = X; - else - *currentx += PB; - - if(changed & 2) - *currenty = Y; - else - *currenty += PD; - - cx = *currentx; - cy = *currenty; - - if(ctrl & BGCNT_MOSAIC) - { - INT32 mosaic_line = ((m_MOSAIC & 0xf0) >> 4) + 1; - INT32 tempy = (ypos / mosaic_line) * mosaic_line; - cx = X + tempy*PB; - cy = Y + tempy*PD; - } - - pixx = cx >> 8; - pixy = cy >> 8; - - for(x = 0; x < 240; x++) - { - if(pixx < 0 || pixy < 0 || pixx >= sx || pixy >= sy) - { - scanline[x] = 0x80000000; - } - else - { - if (depth == 8) - { - UINT8 color = src8[pixy*sx + pixx]; - scanline[x] = color ? (palette[color] | prio) : 0x80000000; - } - else - { - scanline[x] = src16[pixy*sx + pixx] | prio; - } - } - - cx += PA; - cy += PC; - - pixx = cx >> 8; - pixy = cy >> 8; - } - - if(ctrl & BGCNT_MOSAIC) - { - INT32 mosaicx = (m_MOSAIC & 0x0f) + 1; - if(mosaicx > 1) - { - INT32 m = 1; - for(x = 0; x < 239; x++) - { - scanline[x+1] = scanline[x]; - m++; - if(m == mosaicx) - { - m = 1; - x++; - } - } - } - } -} - -void gba_state::draw_roz_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed) -{ - UINT32 base, mapbase, size; - static const INT32 sizes[4] = { 128, 256, 512, 1024 }; - INT32 cx, cy, pixx, pixy; - UINT8 *mgba_vram = (UINT8 *)m_gba_vram.target(); - UINT32 tile; - UINT16 *pgba_pram = (UINT16 *)m_gba_pram.target(); - UINT16 pixel; - UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; - int x = 0; - - for (x = 0; x < 240; x++) - scanline[x] = 0x80000000; - - if (m_DISPCNT & enablemask) - { - base = ((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000; // VRAM base of tiles - mapbase = ((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800; // VRAM base of map - size = (ctrl & BGCNT_SCREENSIZE) >> BGCNT_SCREENSIZE_SHIFT; // size of map in submaps - - // sign extend roz parameters - if (X & 0x08000000) X |= 0xf0000000; - if (Y & 0x08000000) Y |= 0xf0000000; - if (PA & 0x8000) PA |= 0xffff0000; - if (PB & 0x8000) PB |= 0xffff0000; - if (PC & 0x8000) PC |= 0xffff0000; - if (PD & 0x8000) PD |= 0xffff0000; - - if(ypos == 0) - changed = 3; - - if(changed & 1) - *currentx = X; - else - *currentx += PB; - - if(changed & 2) - *currenty = Y; - else - *currenty += PD; - - cx = *currentx; - cy = *currenty; - - if(ctrl & BGCNT_MOSAIC) - { - int mosaic_line = ((m_MOSAIC & 0xf0) >> 4) + 1; - int y = ypos % mosaic_line; - cx -= y*PB; - cy -= y*PD; - } - - pixx = cx >> 8; - pixy = cy >> 8; - - if(ctrl & BGCNT_PALETTESET_WRAP) - { - pixx %= sizes[size]; - pixy %= sizes[size]; - if(pixx < 0) - { - pixx += sizes[size]; - } - if(pixy < 0) - { - pixy += sizes[size]; - } - } - - for(x = 0; x < 240; x++) - { - if(pixx < 0 || pixy < 0 || pixx >= sizes[size] || pixy >= sizes[size]) - { - scanline[x] = 0x80000000; - } - else - { - int tilex = pixx & 7; - int tiley = pixy & 7; - - // shall we shift for (ctrl & BGCNT_PALETTE256)?? or is not effective for ROZ? - tile = mgba_vram[mapbase + (pixx >> 3) + (pixy >> 3) * (sizes[size] >> 3)]; - pixel = mgba_vram[base + (tile << 6) + (tiley << 3) + tilex]; - - // plot it - scanline[x] = pixel ? (pgba_pram[pixel] | prio) : 0x80000000; - } - - cx += PA; - cy += PC; - - pixx = cx >> 8; - pixy = cy >> 8; - - if(ctrl & BGCNT_PALETTESET_WRAP) - { - pixx %= sizes[size]; - pixy %= sizes[size]; - if(pixx < 0) - { - pixx += sizes[size]; - } - if(pixy < 0) - { - pixy += sizes[size]; - } - } - } - - if(ctrl & BGCNT_MOSAIC) - { - int mosaicx = (m_MOSAIC & 0x0f) + 1; - if(mosaicx > 1) - { - int m = 1; - for(x = 0; x < 239; x++) - { - scanline[x+1] = scanline[x]; - m++; - if(m == mosaicx) - { - m = 1; - x++; - } - } - } - } - } -} - -void gba_state::draw_bg_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs) -{ - UINT8 *vram = (UINT8*)m_gba_vram.target(); - UINT16 *palette = (UINT16*)m_gba_pram.target(); - UINT8 *chardata = &vram[((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000]; - UINT16 *screendata = (UINT16*)&vram[((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800]; - UINT32 priority = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; - INT32 width = 256; - INT32 height = 256; - INT32 maskx, masky, pixx, pixy; - UINT8 use_mosaic = (ctrl & BGCNT_MOSAIC) ? 1 : 0; - INT32 mosaicx = (m_MOSAIC & 0x000f) + 1; - INT32 mosaicy = ((m_MOSAIC & 0x00f0) >> 4) + 1; - INT32 stride; - int x = 0; - - for (x = 0; x < 240; x++) - scanline[x] = 0x80000000; - - if(m_DISPCNT & enablemask) - { - switch((ctrl & BGCNT_SCREENSIZE) >> BGCNT_SCREENSIZE_SHIFT) - { - case 1: - width = 512; - break; - case 2: - height = 512; - break; - case 3: - width = 512; - height = 512; - break; - } - - maskx = width - 1; - masky = height - 1; - - pixx = hofs & maskx; - pixy = (vofs + ypos) & masky; - - if(use_mosaic) - { - if((ypos % mosaicy) != 0) - { - mosaicy = (ypos / mosaicy) * mosaicy; - pixy = (vofs + mosaicy) & masky; - } - } - - if(pixy > 255 && height > 256) - { - pixy &= 0x000000ff; - screendata += 0x400; - if(width > 256) - { - screendata += 0x400; - } - } - - stride = (pixy >> 3) << 5; - - UINT16 *src = screendata + 0x400 * (pixx >> 8) + ((pixx & 255) >> 3) + stride; - for(x = 0; x < 240; x++) - { - UINT16 data = *src; - INT32 tile = data & TILEOBJ_TILE; - INT32 tilex = pixx & 7; - INT32 tiley = pixy & 7; - UINT8 color; - UINT8 palindex; - - if(data & TILEOBJ_HFLIP) - { - tilex = 7 - tilex; - } - if(data & TILEOBJ_VFLIP) - { - tiley = 7 - tiley; - } - - if (ctrl & BGCNT_PALETTE256) - { - color = chardata[(tile << 6) + (tiley << 3) + tilex]; - palindex = 0; - } - else - { - color = chardata[(tile << 5) + (tiley << 2) + (tilex >> 1)]; - - if (tilex & 1) - color >>= 4; - else - color &= 0x0f; - palindex = (data >> 8) & 0x00f0; - } - - if (color) - scanline[x] = palette[palindex + color] | priority; - else - scanline[x] = 0x80000000; - - if (data & TILEOBJ_HFLIP) - { - if (tilex == 0) - { - src++; - } - } - else if (tilex == 7) - { - src++; - } - - pixx++; - if(pixx == 256) - { - if(width > 256) - { - src = screendata + 0x400 + stride; - } - else - { - src = screendata + stride; - pixx = 0; - } - } - else if(pixx >= width) - { - pixx = 0; - src = screendata + stride; - } - } - - if(use_mosaic) - { - if(mosaicx > 1) - { - INT32 m = 1; - for(x = 0; x < 239; x++) - { - scanline[x+1] = scanline[x]; - m++; - if(m == mosaicx) - { - m = 1; - x++; - } - } - } - } - - } -} - -void gba_state::draw_gba_oam_window(UINT32 *scanline, int y) -{ - INT16 gba_oamindex; - UINT32 tilebytebase, tileindex, tiledrawindex; - UINT32 width, height; - UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target(); - UINT8 *src = (UINT8*)m_gba_vram.target(); - int x = 0; - - for (x = 0; x < 240; x++) - scanline[x] = 0x80000000; - - if (m_DISPCNT & DISPCNT_OBJWIN_EN) - { - for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- ) - { - INT32 sx, sy; - UINT16 attr0, attr1, attr2; - INT32 cury; - - attr0 = pgba_oam[(4*gba_oamindex)+0]; - attr1 = pgba_oam[(4*gba_oamindex)+1]; - attr2 = pgba_oam[(4*gba_oamindex)+2]; - - sx = (attr1 & OBJ_X_COORD); - sy = (attr0 & OBJ_Y_COORD); - - if(sy > 160) - { - sy -= 256; - } - - if ((attr0 & OBJ_MODE) != OBJ_MODE_WINDOW) - { - continue; - } - else - { - width = 0; - height = 0; - switch (attr0 & OBJ_SHAPE ) - { - case OBJ_SHAPE_SQR: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 1; - height = 1; - break; - case OBJ_SIZE_16: - width = 2; - height = 2; - break; - case OBJ_SIZE_32: - width = 4; - height = 4; - break; - case OBJ_SIZE_64: - width = 8; - height = 8; - break; - } - break; - case OBJ_SHAPE_HORIZ: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 2; - height = 1; - break; - case OBJ_SIZE_16: - width = 4; - height = 1; - break; - case OBJ_SIZE_32: - width = 4; - height = 2; - break; - case OBJ_SIZE_64: - width = 8; - height = 4; - break; - } - break; - case OBJ_SHAPE_VERT: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 1; - height = 2; - break; - case OBJ_SIZE_16: - width = 1; - height = 4; - break; - case OBJ_SIZE_32: - width = 2; - height = 4; - break; - case OBJ_SIZE_64: - width = 4; - height = 8; - break; - } - break; - default: - width = 0; - height = 0; - verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" ); - break; - } - - tiledrawindex = tileindex = (attr2 & OBJ_TILENUM); - tilebytebase = 0x10000; // the index doesn't change in the higher modes, we just ignore sprites that are out of range - - if (attr0 & OBJ_ROZMODE_ROZ) - { - INT32 fx, fy, ax, ay, rx, ry; - INT16 dx, dy, dmx, dmy; - UINT8 color; - - width *= 8; - height *= 8; - - if ((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DISABLE) - { - continue; - } - - fx = width; - fy = height; - - if((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DBLROZ) - { - fx *= 2; - fy *= 2; - } - - cury = y - sy; - - if(cury >= 0 && cury < fy) - { - if(sx < 240 || ((sx + fx) & 0x1ff) < 240) - { - int rot = (attr1 & OBJ_SCALE_PARAM) >> OBJ_SCALE_PARAM_SHIFT; - dx = (INT16)pgba_oam[(rot << 4)+3]; - dmx = (INT16)pgba_oam[(rot << 4)+7]; - dy = (INT16)pgba_oam[(rot << 4)+11]; - dmy = (INT16)pgba_oam[(rot << 4)+15]; - - rx = (width << 7) - (fx >> 1)*dx - (fy >> 1)*dmx + cury * dmx; - ry = (height << 7) - (fx >> 1)*dy - (fy >> 1)*dmy + cury * dmy; - - if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256) - { - int inc = 32; - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = sx >> 2; - } - else - { - tiledrawindex &= 0x3fe; - } - for(x = 0; x < fx; x++) - { - ax = rx >> 8; - ay = ry >> 8; - - if(ax < 0 || ax >= sx || ay < 0 || ay >= sy) - { - } - else - { - color = src[tilebytebase + ((((tiledrawindex + (ay >> 3) * inc) << 5) + ((ay & 0x07) << 3) + ((ax >> 3) << 6) + (ax & 0x07)) & 0x7fff)]; - - if(color) - { - scanline[sx] = 1; - } - } - - sx = (sx + 1) & 0x1ff; - - rx += dx; - ry += dy; - } - } - else - { - int inc = 32; - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = sx >> 3; - } - for(x = 0; x < fx; x++) - { - ax = rx >> 8; - ay = ry >> 8; - - if(ax < 0 || ax >= sx || ay < 0 || ay >= sy) - { - } - else - { - color = src[tilebytebase + ((((tiledrawindex + (ay >> 3) * inc) << 5) + ((ay & 0x07) << 2) + ((ax >> 3) << 5) + ((ax & 0x07) >> 1)) & 0x7fff)]; - - if(ax & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color) - { - scanline[sx] = 1; - } - } - - sx = (sx + 1) & 0x1ff; - - rx += dx; - ry += dy; - } - } - } - } - } - else - { - INT32 ax; - int cury_ = y - sy; - - width *= 8; - height *= 8; - - if(cury_ >= 0 && cury_ < height) - { - if( ( (sx < 240) || ( ( (sx + width) & 0x1ff ) < 240 ) ) && (attr0 & OBJ_ROZMODE_DISABLE) == 0) - { - if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256) - { - int inc = 32; - int address = 0; - if(attr1 & OBJ_VFLIP) - { - cury_ = height - cury_ - 1; - } - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 2; - } - else - { - tiledrawindex &= 0x3fe; - } - - ax = 0; - if(attr1 & OBJ_HFLIP) - { - ax = width - 1; - } - - address = 0x10000 + ((((tiledrawindex + (cury_ >> 3) * inc) << 5) + ((cury_ & 7) << 3) + ((ax >> 3) << 6) + (ax & 7)) & 0x7fff); - - if(attr1 & OBJ_HFLIP) - { - ax = 7; - } - - for(x = 0; x < width; x++) - { - if(sx < 240) - { - UINT8 color = src[address]; - - if(color) - { - scanline[sx] = 1; - } - } - - sx = (sx + 1) & 0x1ff; - - if(attr1 & OBJ_HFLIP) - { - ax--; - address--; - if(ax == -1) - { - address -= 56; - ax = 7; - } - if(address < 0x10000) - { - address += 0x8000; - } - } - else - { - ax++; - address++; - if(ax == 8) - { - address += 56; - ax = 0; - } - if(address > 0x17fff) - { - address -= 0x8000; - } - } - } - } - else - { - int inc = 32; - UINT32 address; - if(attr1 & OBJ_VFLIP) - { - cury_ = height - cury_ - 1; - } - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 3; - } - - ax = 0; - if(attr1 & OBJ_HFLIP) - { - ax = width - 1; - } - - address = 0x10000 + ((((tiledrawindex + (cury_ >> 3) * inc) << 5) + ((cury_ & 0x07) << 2) + ((ax >> 3) << 5) + ((ax & 0x07) >> 1)) & 0x7fff); - if(attr1 & OBJ_HFLIP) - { - ax = 7; - for(x = width - 1; x >= 0; x--) - { - if(sx < 240) - { - UINT8 color = src[address]; - if(x & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color) - { - scanline[sx] = 1; - } - } - - sx = (sx + 1) & 0x1ff; - ax--; - if((x & 1) == 0) - { - address--; - } - if(ax == -1) - { - ax = 7; - address -= 28; - } - if(address < 0x10000) - { - address += 0x8000; - } - } - } - else - { - for(x = 0; x < width; x++) - { - if(sx < 240) - { - UINT8 color = src[address]; - - if(x & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color) - { - scanline[sx] = 1; - } - } - - sx = (sx + 1) & 0x1ff; - ax++; - if(x & 1) - { - address++; - } - if(ax == 8) - { - address += 28; - ax = 0; - } - if(address > 0x17fff) - { - address -= 0x8000; - } - } - } - } - } - } - } - } - } - } -} - -void gba_state::draw_gba_oam(UINT32 *scanline, int y) -{ - INT16 gba_oamindex; - INT32 mosaiccnt = 0; - INT32 mosaicy = ((m_MOSAIC & 0xf000) >> 12) + 1; - INT32 mosaicx = ((m_MOSAIC & 0x0f00) >> 8) + 1; - UINT32 tileindex, tiledrawindex; //, tilebytebase - UINT8 width, height; - UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target(); - UINT8 *src = (UINT8 *)m_gba_vram.target(); - UINT16 *palette = (UINT16*)m_gba_pram.target(); - int x = 0; - - for (x = 0; x < 240; x++) - scanline[x] = 0x80000000; - - if( m_DISPCNT & DISPCNT_OBJ_EN ) - { - for( gba_oamindex = 0; gba_oamindex < 128; gba_oamindex++ ) - { - UINT16 attr0, attr1, attr2; - INT32 cury; - UINT32 prio; - UINT32 priority; - - attr0 = pgba_oam[(4*gba_oamindex)+0]; - attr1 = pgba_oam[(4*gba_oamindex)+1]; - attr2 = pgba_oam[(4*gba_oamindex)+2]; - priority = (attr2 & OBJ_PRIORITY) >> OBJ_PRIORITY_SHIFT; - prio = (priority << 25) | ((attr0 & OBJ_MODE) << 6); - - if ((attr0 & OBJ_MODE) != OBJ_MODE_WINDOW) - { - width = 0; - height = 0; - switch (attr0 & OBJ_SHAPE) - { - case OBJ_SHAPE_SQR: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 1; - height = 1; - break; - case OBJ_SIZE_16: - width = 2; - height = 2; - break; - case OBJ_SIZE_32: - width = 4; - height = 4; - break; - case OBJ_SIZE_64: - width = 8; - height = 8; - break; - } - break; - case OBJ_SHAPE_HORIZ: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 2; - height = 1; - break; - case OBJ_SIZE_16: - width = 4; - height = 1; - break; - case OBJ_SIZE_32: - width = 4; - height = 2; - break; - case OBJ_SIZE_64: - width = 8; - height = 4; - break; - } - break; - case OBJ_SHAPE_VERT: - switch(attr1 & OBJ_SIZE ) - { - case OBJ_SIZE_8: - width = 1; - height = 2; - break; - case OBJ_SIZE_16: - width = 1; - height = 4; - break; - case OBJ_SIZE_32: - width = 2; - height = 4; - break; - case OBJ_SIZE_64: - width = 4; - height = 8; - break; - } - break; - default: - width = 0; - height = 0; - verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" ); - break; - } - - tiledrawindex = tileindex = (attr2 & OBJ_TILENUM); -// tilebytebase = 0x10000; // the index doesn't change in the higher modes, we just ignore sprites that are out of range - - if (attr0 & OBJ_ROZMODE_ROZ) - { - INT32 sx, sy; - INT32 fx, fy, rx, ry; - INT16 dx, dy, dmx, dmy; - - width *= 8; - height *= 8; - - if ((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DISABLE) - { - continue; - } - - sx = (attr1 & OBJ_X_COORD); - sy = (attr0 & OBJ_Y_COORD); - - if(sy > 160) - { - sy -= 256; - } - - fx = width; - fy = height; - - if((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DBLROZ) - { - fx *= 2; - fy *= 2; - } - - cury = y - sy; - - if(cury >= 0 && cury < fy) - { - if(sx < 240 || ((sx + fx) & 0x1ff) < 240) - { - INT32 oamparam = (attr1 & OBJ_SCALE_PARAM) >> OBJ_SCALE_PARAM_SHIFT; - - dx = (INT16)pgba_oam[(oamparam << 4)+3]; - dmx = (INT16)pgba_oam[(oamparam << 4)+7]; - dy = (INT16)pgba_oam[(oamparam << 4)+11]; - dmy = (INT16)pgba_oam[(oamparam << 4)+15]; - - if(attr0 & OBJ_MOSAIC) - { - cury -= (cury % mosaicy); - } - - rx = (width << 7) - (fx >> 1)*dx - (fy >> 1)*dmx + cury*dmx; - ry = (height << 7) - (fx >> 1)*dy - (fy >> 1)*dmy + cury*dmy; - - if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256) - { - INT32 inc = 32; - - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 2; - } - else - { - tiledrawindex &= 0x3fe; - } - - for(x = 0; x < fx; x++) - { - INT32 pixx = rx >> 8; - INT32 pixy = ry >> 8; - - if(!(pixx < 0 || pixx >= width || pixy < 0 || pixy >= height || sx >= 240)) - { - UINT8 color = src[0x10000 + ((((tiledrawindex + (pixy >> 3) * inc) << 5) + ((pixy & 7) << 3) + ((pixx >> 3) << 6) + (pixx & 7)) & 0x7fff)]; - if(color == 0 && priority < ((scanline[sx] >> 25) & 3)) - { - scanline[sx] = (scanline[sx] & 0xf9ffffff) | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - else if(color != 0 && prio < (scanline[sx] & 0xff000000)) - { - scanline[sx] = palette[256 + color] | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - - if(attr0 & OBJ_MOSAIC) - { - mosaiccnt++; - if(mosaiccnt == mosaicx) - { - mosaiccnt = 0; - } - } - } - - sx++; - sx &= 0x1ff; - - rx += dx; - ry += dy; - } - } - else - { - INT32 inc = 32; - INT32 palentry = (attr2 >> 8) & 0xf0; - - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 3; - } - - for(x = 0; x < fx; x++) - { - INT32 pixx = rx >> 8; - INT32 pixy = ry >> 8; - - if(!(pixx < 0 || pixx >= width || pixy < 0 || pixy >= height || sx >= 240)) - { - UINT8 color = src[0x10000 + ((((tiledrawindex + (pixy >> 3) * inc) << 5) + ((pixy & 7) << 2) + ((pixx >> 3) << 5) + ((pixx & 7) >> 1)) & 0x7fff)]; - - if(pixx & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color == 0 && priority < ((scanline[sx] >> 25) & 3)) - { - scanline[sx] = (scanline[sx] & 0xf9ffffff) | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - else if(color != 0 && prio < (scanline[sx] & 0xff000000)) - { - scanline[sx] = palette[256 + palentry + color] | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - } - - if(attr0 & OBJ_MOSAIC) - { - mosaiccnt++; - if(mosaiccnt == mosaicx) - { - mosaiccnt = 0; - } - } - - sx++; - - sx &= 0x1ff; - - rx += dx; - ry += dy; - } - } - } - } - } - else - { - INT32 sx, sy; - INT32 vflip = (attr1 & OBJ_VFLIP) ? 1 : 0; - INT32 hflip = (attr1 & OBJ_HFLIP) ? 1 : 0; - - width *= 8; - height *= 8; - - if ((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DISABLE) - { - continue; - } - - sx = (attr1 & OBJ_X_COORD); - sy = (attr0 & OBJ_Y_COORD); - - if(sy > 160) - { - sy -= 256; - } - - cury = y - sy; - if(cury >= 0 && cury < height) - { - if(sx < 240 || ((sx + width) & 0x1ff) < 240) - { - if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256) - { - INT32 pixx; - INT32 inc = 32; - INT32 address = 0; - - if(vflip) - { - cury = height - cury - 1; - } - - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 2; - } - else - { - tiledrawindex &= 0x3fe; - } - - pixx = 0; - if(hflip) - { - pixx = width - 1; - } - - if(attr0 & OBJ_MOSAIC) - { - cury -= (cury % mosaicy); - } - - address = 0x10000 + ((((tiledrawindex + (cury >> 3) * inc) << 5) + ((cury & 7) << 3) + ((pixx >> 3) << 6) + (pixx & 7)) & 0x7fff); - - if(hflip) - { - pixx = 7; - } - - for(x = 0; x < width; x++) - { - if(sx < 240) - { - UINT8 color = src[address]; - if(color == 0 && priority < ((scanline[sx] >> 25) & 3)) - { - scanline[sx] = (scanline[sx] & 0xf9ffffff) | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - else if(color != 0 && prio < (scanline[sx] & 0xff000000)) - { - scanline[sx] = palette[256 + color] | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - } - - if(attr0 & OBJ_MOSAIC) - { - mosaiccnt++; - if(mosaiccnt == mosaicx) - { - mosaiccnt = 0; - } - } - - sx++; - sx &= 0x1ff; - - if(hflip) - { - pixx--; - address--; - if(pixx == -1) - { - address -= 56; - pixx = 7; - } - if(address < 0x10000) - { - address += 0x8000; - } - } - else - { - pixx++; - address++; - if(pixx == 8) - { - address += 56; - pixx = 0; - } - if(address > 0x17fff) - { - address -= 0x8000; - } - } - } - } - else - { - INT32 pixx; - INT32 inc = 32; - UINT32 address = 0; - - if(vflip) - { - cury = height - cury - 1; - } - - if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) - { - continue; - } - - if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) - { - inc = width >> 3; - } - - pixx = 0; - if(hflip) - { - pixx = width - 1; - } - - if(attr0 & OBJ_MOSAIC) - { - cury -= (cury % mosaicy); - } - - address = 0x10000 + ((((tiledrawindex + (cury >> 3) * inc) << 5) + ((cury & 7) << 2) + ((pixx >> 3) << 5) + ((pixx & 7) >> 1)) & 0x7fff); - - if(hflip) - { - pixx = 7; - for(x = width - 1; x >= 0; x--) - { - if(sx < 240) - { - UINT8 color = src[address]; - UINT8 palentry = (attr2 >> 8) & 0xf0; - - if(x & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color == 0 && priority < ((scanline[sx] >> 25) & 3)) - { - scanline[sx] = (scanline[sx] & 0xf9ffffff) | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - else if(color != 0 && prio < (scanline[sx] & 0xff000000)) - { - scanline[sx] = palette[256 + palentry + color] | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - } - - sx++; - sx &= 0x1ff; - - pixx--; - if(!(x & 1)) - { - address--; - } - if(pixx == -1) - { - address -= 28; - pixx = 7; - } - if(address < 0x10000) - { - address += 0x8000; - } - } - } - else - { - for(x = 0; x < width; x++) - { - if(sx < 240) - { - UINT8 color = src[address]; - UINT8 palentry = (attr2 >> 8) & 0xf0; - - if(x & 1) - { - color >>= 4; - } - else - { - color &= 0x0f; - } - - if(color == 0 && priority < ((scanline[sx] >> 25) & 3)) - { - scanline[sx] = (scanline[sx] & 0xf9ffffff) | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - else if(color != 0 && prio < (scanline[sx] & 0xff000000)) - { - scanline[sx] = palette[256 + palentry + color] | prio; - if((attr0 & OBJ_MOSAIC) != 0 && mosaiccnt != 0) - { - scanline[sx] = (scanline[sx - 1] & 0xf9ffffff) | prio; - } - } - } - - if(attr0 & OBJ_MOSAIC) - { - mosaiccnt++; - if(mosaiccnt == mosaicx) - { - mosaiccnt = 0; - } - } - - sx++; - sx &= 0x1ff; - - pixx++; - if(x & 1) - { - address++; - } - if(pixx == 8) - { - address += 28; - pixx = 0; - } - if(address > 0x17fff) - { - address -= 0x8000; - } - } - } - } - } - } - } - } - } - } -} - -inline int gba_state::is_in_window(int x, int window) -{ - int x0 = m_WIN0H >> 8; - int x1 = m_WIN0H & 0x00ff; - - if(window == 1) - { - x0 = m_WIN1H >> 8; - x1 = m_WIN1H & 0x00ff; - } - - if(x0 <= x1) - { - if(x >= x0 && x < x1) - { - return 1; - } - } - else - { - if(x >= x0 || x < x1) - { - return 1; - } - } - - return 0; -} - -INLINE UINT32 alpha_blend_pixel(UINT32 color0, UINT32 color1, int ca, int cb) -{ - if(color0 < 0x80000000) - { - int r0 = (color0 >> 0) & 0x1f; - int g0 = (color0 >> 5) & 0x1f; - int b0 = (color0 >> 10) & 0x1f; - int r1 = (color1 >> 0) & 0x1f; - int g1 = (color1 >> 5) & 0x1f; - int b1 = (color1 >> 10) & 0x1f; - int r = ((r0 * ca) >> 4) + ((r1 * cb) >> 4); - int g = ((g0 * ca) >> 4) + ((g1 * cb) >> 4); - int b = ((b0 * ca) >> 4) + ((b1 * cb) >> 4); - - if(r > 0x1f) r = 0x1f; - if(g > 0x1f) g = 0x1f; - if(b > 0x1f) b = 0x1f; - - return (color0 & 0xffff0000) | (b << 10) | (g << 5) | r; - } - return color0; -} - -INLINE UINT32 increase_brightness(UINT32 color, int coeff_) -{ - int r = (color >> 0) & 0x1f; - int g = (color >> 5) & 0x1f; - int b = (color >> 10) & 0x1f; - - r += ((0x1f - r) * coeff_) >> 4; - g += ((0x1f - g) * coeff_) >> 4; - b += ((0x1f - b) * coeff_) >> 4; - - if(r > 0x1f) r = 0x1f; - if(g > 0x1f) g = 0x1f; - if(b > 0x1f) b = 0x1f; - - return (color & 0xffff0000) | (b << 10) | (g << 5) | r; -} - -INLINE UINT32 decrease_brightness(UINT32 color, int coeff_) -{ - int r = (color >> 0) & 0x1f; - int g = (color >> 5) & 0x1f; - int b = (color >> 10) & 0x1f; - - r -= (r * coeff_) >> 4; - g -= (g * coeff_) >> 4; - b -= (b * coeff_) >> 4; - - if(r < 0) r = 0; - if(g < 0) g = 0; - if(b < 0) b = 0; - - return (color & 0xffff0000) | (b << 10) | (g << 5) | r; -} - -void gba_state::draw_scanline(int y) -{ - bitmap_ind16 &bitmap = m_bitmap; - UINT16 *scanline = &bitmap.pix16(y); - UINT8 submode = 0; - int depth = 0; - - // forced blank - if (m_DISPCNT & DISPCNT_BLANK) - { - // forced blank is white - for (int x = 0; x < 240; x++) - scanline[x] = 0x7fff; - return; - } - - if(!m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN)) - submode = GBA_SUBMODE0; - else if(m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN)) - submode = GBA_SUBMODE1; - else - submode = GBA_SUBMODE2; - - if ((m_DISPCNT & 7) == 3) - depth = 16; - else if ((m_DISPCNT & 7) == 4) - depth = 8; - else if ((m_DISPCNT & 7) == 5) - depth = 4; - - //printf("mode = %d, %d\n", m_DISPCNT & 7, submode); - - switch(m_DISPCNT & 7) - { - case 0: - case 1: - case 2: - draw_modes(m_DISPCNT & 7, submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], depth); - break; - case 3: - case 4: - case 5: - draw_modes(GBA_MODE345, submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], depth); - break; - default: - fatalerror("Invalid screen mode (6 or 7)!\n"); - } - - for (int x = 0; x < 240; x++) - { - scanline[x] = m_xferscan[6][1024 + x] & 0x7fff; - } - - return; -} - -void gba_state::video_start() -{ - machine().first_screen()->register_screen_bitmap(m_bitmap); -} - -UINT32 gba_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/gime.c b/src/mess/video/gime.c deleted file mode 100644 index 83b78e92b25..00000000000 --- a/src/mess/video/gime.c +++ /dev/null @@ -1,2077 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/********************************************************************* - - gime.c - - Implementation of CoCo GIME (Graphics Interrupt Memory Enhancement) - video chip. - - Mid frame raster effects (source John Kowalski) - - Here are the things that get changed mid-frame: - - - Palette registers ($FFB0-$FFBF) - - Horizontal resolution (switches between 256 and 320 pixels, $FF99) - - Horizontal scroll position (bits 0-6 $FF9F) - - Horizontal virtual screen (bit 7 $FF9F) - - Pixel height (bits 0-2 $FF98) - - Border color ($FF9A) - - On the positive side, you don't have to worry about registers - $FF9D/$FF9E being changed mid-frame. Even if they are changed - mid-frame, they have no effect on the displayed image. The video - address only gets latched at the top of the frame. - - - TIMING - - We divide a single frame into five regions - - Region Scanlines (on 192) Field Sync (before right border) - ------ ------------------ -------------------------------- - Top Border 25 1 - Body 192 1 - Bottom Border 26 1 - Vertical Retrace 6 0 - Vertical Blanking 13 (or 13.5) 1 - - Horizontal sync appears to be low only during retrace/blanking but - field sync switches as soon as the last body pixel is displayed - - Note that the GIME trailing edges field sync after the bottom - border; this is different than the MC6847 - -********************************************************************** - - SOFTWARE FOR TIMING TESTING - - Various CoCo 3 programs can "stress test" timing in various ways - - COLOR3: This program was in Rainbow January 1987. It will synchronize - with field sync by polling bit 7 of $FF03 (PIA0) (specifically, it polls - until the rising edge of writes to PIA0 CB1). This causes the loop to - be broken out at the top of vblank. COLOR3 also synchronizes on - horizontal sync through PIA0; it counts 70 hsyncs to get to a point 32 - scanlines into the body. - - DEMO: This SockMaster demo has a main loop that adjusts GIME registers - and shuffles some graphics bytes. From a timing perspective, the - critical piece is a SYNC with PIA field sync (specifically, it SYNCs - with the trailing edge of writes to PIA0 CB1). DEMO does not attempt - to synchronize on horizontal sync; it relies on CPU timing. - - MOON: SockMaster demo. Uses GIME interrupts; FIRQ gets TMR interrupts - and IRQ gets VBORD interrupts. Since it does not use the PIA field - sync, it can be used to demonstrate how the GIME's VBORD interrupt - is distinct. - - BOINK: SockMaster demo. Like DEMO, it SYNCs on the trailing edge - of PIA field sync. Also uses non standard $FF99 LPF mode. If - BOINK "wobbles vertically", it suggests that the main loop is not - executing within a single field sync. BOINK also makes extensive - use of $FF9F scrolling with bit 7 cleared. - - CRYSTAL CITY: Jeremy Spiller game. The intro uses an attribute-less - GIME text mode - -**********************************************************************/ - - -#include "emu.h" -#include "video/gime.h" -#include "machine/6883sam.h" -#include "bus/coco/cococart.h" -#include "machine/ram.h" - - - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -#define USE_HORIZONTAL_CLIP false -#define GIME_TYPE_1987 0 -#define NO_ATTRIBUTE 0x80 - -#define LOG_INT_MASKING 0 -#define LOG_GIME 0 -#define LOG_TIMER 0 - - - -//************************************************************************** -// DEVICE SETUP -//************************************************************************** - -//------------------------------------------------- -// ctor -//------------------------------------------------- - -gime_base_device::gime_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const UINT8 *fontdata, const char *shortname, const char *source) - : mc6847_friend_device(mconfig, type, name, tag, owner, clock, fontdata, true, 263, 25+192+26+3, false, shortname, source), - m_write_irq(*this), - m_write_firq(*this), - m_read_floating_bus(*this), - m_maincpu_tag(NULL), - m_ram_tag(NULL), - m_ext_tag(NULL) -{ -} - - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void gime_base_device::device_start(void) -{ - // find the RAM device - make sure that it is started - m_ram = machine().device(m_ram_tag); - if (!m_ram->started()) - throw device_missing_dependencies(); - - // find the CART device - make sure that it is started - m_cart_device = machine().device(m_ext_tag); - if (!m_cart_device->started()) - throw device_missing_dependencies(); - - // find the CPU device - make sure that it is started - m_cpu = machine().device(m_maincpu_tag); - if (!m_cpu->started()) - throw device_missing_dependencies(); - - // inherited device_start - need to do this after checking dependencies - super::device_start(); - - // initialize variables - memset(m_scanlines, 0, sizeof(m_scanlines)); - m_interrupt_value = 0x00; - m_irq = 0x00; - m_firq = 0x00; - - // allocate timer - m_gime_clock_timer = timer_alloc(TIMER_GIME_CLOCK); - - // setup banks - assert(ARRAY_LENGTH(m_read_banks) == ARRAY_LENGTH(m_write_banks)); - for (int i = 0; i < ARRAY_LENGTH(m_read_banks); i++) - { - char buffer[8]; - snprintf(buffer, ARRAY_LENGTH(buffer), "rbank%d", i); - m_read_banks[i] = machine().root_device().membank(buffer); - snprintf(buffer, ARRAY_LENGTH(buffer), "wbank%d", i); - m_write_banks[i] = machine().root_device().membank(buffer); - } - - // resolve callbacks - m_write_irq.resolve_safe(); - m_write_firq.resolve_safe(); - m_read_floating_bus.resolve_safe(0); - - // set up ROM/RAM pointers - m_rom = machine().root_device().memregion(m_maincpu_tag)->base(); - m_cart_rom = m_cart_device->get_cart_base(); - - // populate palettes - for (int color = 0; color < 64; color++) - { - m_composite_palette[color] = get_composite_color(color); - m_composite_bw_palette[color] = black_and_white(m_composite_palette[color]); - m_rgb_palette[color] = get_rgb_color(color); - } - - // set up save states - save_pointer(NAME(m_gime_registers), ARRAY_LENGTH(m_gime_registers)); - save_pointer(NAME(m_mmu), ARRAY_LENGTH(m_mmu)); - save_item(NAME(m_sam_state)); - save_item(NAME(m_ff22_value)); - save_item(NAME(m_interrupt_value)); - save_item(NAME(m_irq)); - save_item(NAME(m_firq)); - save_item(NAME(m_timer_value)); - save_item(NAME(m_is_blinking)); - save_pointer(NAME(m_palette_rotated[0]), 16); -} - - - -//------------------------------------------------- -// get_composite_color -//------------------------------------------------- - -inline gime_base_device::pixel_t gime_base_device::get_composite_color(int color) -{ - /* CMP colors - * - * These colors are of the format IICCCC, where II is the intensity and - * CCCC is the base color. There is some weirdness because intensity - * is often different for each base color. - * - * The code below is based on an algorithm specified in the following - * CoCo BASIC program was used to approximate composite colors. - * (Program by SockMaster): - * - * 10 POKE65497,0:DIMR(63),G(63),B(63):WIDTH80:PALETTE0,0:PALETTE8,54:CLS1 - * 20 SAT=92:CON=70:BRI=-50:L(0)=0:L(1)=47:L(2)=120:L(3)=255 - * 30 W=.4195456981879*1.01:A=W*9.2:S=A+W*5:D=S+W*5:P=0:FORH=0TO3:P=P+1 - * 40 BRI=BRI+CON:FORG=1TO15:R(P)=COS(A)*SAT+BRI - * 50 G(P)=(COS(S)*SAT)*1+BRI:B(P)=(COS(D)*SAT)*1+BRI:P=P+1 - * 55 A=A+W:S=S+W:D=D+W:NEXT:R(P-16)=L(H):G(P-16)=L(H):B(P-16)=L(H) - * 60 NEXT:R(63)=R(48):G(63)=G(48):B(63)=B(48) - * 70 FORH=0TO63STEP1:R=INT(R(H)):G=INT(G(H)):B=INT(B(H)):IFR<0THENR=0 - * 80 IFG<0THENG=0 - * 90 IFB<0THENB=0 - * 91 IFR>255THENR=255 - * 92 IFG>255THENG=255 - * 93 IFB>255THENB=255 - * 100 PRINTRIGHT$(STR$(H),2);" $";:R=R+256:G=G+256:B=B+256 - * 110 PRINTRIGHT$(HEX$(R),2);",$";RIGHT$(HEX$(G),2);",$";RIGHT$(HEX$(B),2) - * 115 IF(H AND15)=15 THENIFINKEY$=""THEN115ELSEPRINT - * 120 NEXT - * - * At one point, we used a different SockMaster program, but the colors - * produced were too dark for people's taste - * - * 10 POKE65497,0:DIMR(63),G(63),B(63):WIDTH80:PALETTE0,0:PALETTE8,54:CLS1 - * 20 SAT=92:CON=53:BRI=-16:L(0)=0:L(1)=47:L(2)=120:L(3)=255 - * 30 W=.4195456981879*1.01:A=W*9.2:S=A+W*5:D=S+W*5:P=0:FORH=0TO3:P=P+1 - * 40 BRI=BRI+CON:FORG=1TO15:R(P)=COS(A)*SAT+BRI - * 50 G(P)=(COS(S)*SAT)*.50+BRI:B(P)=(COS(D)*SAT)*1.9+BRI:P=P+1 - * 55 A=A+W:S=S+W:D=D+W:NEXT:R(P-16)=L(H):G(P-16)=L(H):B(P-16)=L(H) - * 60 NEXT:R(63)=R(48):G(63)=G(48):B(63)=B(48) - * 70 FORH=0TO63STEP1:R=INT(R(H)):G=INT(G(H)):B=INT(B(H)):IFR<0THENR=0 - * 80 IFG<0THENG=0 - * 90 IFB<0THENB=0 - * 91 IFR>255THENR=255 - * 92 IFG>255THENG=255 - * 93 IFB>255THENB=255 - * 100 PRINTRIGHT$(STR$(H),2);" $";:R=R+256:G=G+256:B=B+256 - * 110 PRINTRIGHT$(HEX$(R),2);",$";RIGHT$(HEX$(G),2);",$";RIGHT$(HEX$(B),2) - * 115 IF(H AND15)=15 THENIFINKEY$=""THEN115ELSEPRINT - * 120 NEXT - */ - - double saturation, brightness, contrast; - int offset; - double w; - int r, g, b; - - switch(color) - { - case 0: - r = g = b = 0; - break; - - case 16: - r = g = b = 47; - break; - - case 32: - r = g = b = 120; - break; - - case 48: - case 63: - r = g = b = 255; - break; - - default: - w = .4195456981879*1.01; - contrast = 70; - saturation = 92; - brightness = -50; - brightness += ((color / 16) + 1) * contrast; - offset = (color % 16) - 1 + (color / 16)*15; - r = cos(w*(offset + 9.2)) * saturation + brightness; - g = cos(w*(offset + 14.2)) * saturation + brightness; - b = cos(w*(offset + 19.2)) * saturation + brightness; - - if (r < 0) - r = 0; - else if (r > 255) - r = 255; - - if (g < 0) - g = 0; - else if (g > 255) - g = 255; - - if (b < 0) - b = 0; - else if (b > 255) - b = 255; - break; - } - return (pixel_t) ((r << 16) | (g << 8) | (b << 0)); -} - - - -//------------------------------------------------- -// get_rgb_color -//------------------------------------------------- - -inline gime_base_device::pixel_t gime_base_device::get_rgb_color(int color) -{ - return (((color >> 4) & 2) | ((color >> 2) & 1)) * 0x550000 - | (((color >> 3) & 2) | ((color >> 1) & 1)) * 0x005500 - | (((color >> 2) & 2) | ((color >> 0) & 1)) * 0x000055; -} - - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void gime_base_device::device_reset(void) -{ - /* Tepolt verifies that the GIME registers are all cleared on initialization */ - memset(m_gime_registers, 0, sizeof(m_gime_registers)); - - /* initialize MMU */ - for (int i = 0; i < 8; i++) - m_mmu[i] = m_mmu[i + 8] = 56 + i; - - /* initialize palette */ - memset(m_palette_rotated, 0, sizeof(m_palette_rotated)); - m_palette_rotated_position = 0; - m_palette_rotated_position_used = false; - - /* clear SAM state */ - m_sam_state = 0x0000; - - /* clear interrupts */ - m_interrupt_value = 0x00; - m_irq = 0x00; - m_firq = 0x00; - m_is_blinking = false; - - m_legacy_video = false; - - m_displayed_rgb = false; - - update_memory(); - reset_timer(); -} - - - -//------------------------------------------------- -// device_timer - handle timer callbacks -//------------------------------------------------- - -void gime_base_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch(id) - { - case TIMER_GIME_CLOCK: - timer_elapsed(); - break; - - default: - super::device_timer(timer, id, param, ptr); - break; - } -} - - - -//------------------------------------------------- -// device_pre_save - device-specific pre save -//------------------------------------------------- - -void gime_base_device::device_pre_save() -{ - super::device_pre_save(); - - // copy to palette rotation position zero - for (offs_t i = 0; i < 16; i++) - m_palette_rotated[0][i] = m_palette_rotated[m_palette_rotated_position][i]; -} - - -//------------------------------------------------- -// device_post_load - device-specific post load -//------------------------------------------------- - -void gime_base_device::device_post_load() -{ - super::device_post_load(); - update_memory(); - update_cpu_clock(); - - // we update to position zero - m_palette_rotated_position = 0; - m_palette_rotated_position_used = false; -} - - - -//------------------------------------------------- -// device_input_ports -//------------------------------------------------- - -ioport_constructor gime_base_device::device_input_ports() const -{ - return INPUT_PORTS_NAME(mc6847_artifacting); -} - - - -//************************************************************************** -// TIMER -// -// The CoCo 3 had a timer that had would activate when first written to, and -// would decrement over and over again until zero was reached, and at that -// point, would flag an interrupt. At this point, the timer starts back up -// again. -// -// I am deducing that the timer interrupt line was asserted if the timer was -// zero and unasserted if the timer was non-zero. Since we never truly track -// the timer, we just use timer callback (coco3_timer_callback() asserts the -// line) -// -// Most CoCo 3 docs, including the specs that Tandy released, say that the -// high speed timer is 70ns (half of the speed of the main clock crystal). -// However, it seems that this is in error, and the GIME timer is really a -// 280ns timer (one eighth the speed of the main clock crystal. Gault's -// FAQ agrees with this -// -//************************************************************************** - -//------------------------------------------------- -// timer_type -//------------------------------------------------- - -gime_base_device::timer_type_t gime_base_device::timer_type(void) -{ - // wraps the GIME register access and returns an enumeration - return (m_gime_registers[0x01] & 0x20) ? GIME_TIMER_CLOCK : GIME_TIMER_HBORD; -} - - - -//------------------------------------------------- -// timer_type_string -//------------------------------------------------- - -const char *gime_base_device::timer_type_string(void) -{ - const char *result; - switch(timer_type()) - { - case GIME_TIMER_CLOCK: - result = "CLOCK"; - break; - case GIME_TIMER_HBORD: - result = "HBORD"; - break; - default: - fatalerror("Should not get here\n"); - } - return result; -} - - - -//------------------------------------------------- -// timer_elapsed -//------------------------------------------------- - -void gime_base_device::timer_elapsed(void) -{ - /* reset the timer; give her another run! */ - reset_timer(); - - /* change the blinking value - note that we don't have to use update_value() */ - m_is_blinking = !m_is_blinking; - - /* twiddle the timer interrupt */ - set_interrupt_value(INTERRUPT_TMR, true); - set_interrupt_value(INTERRUPT_TMR, false); -} - - - -//------------------------------------------------- -// reset_timer -//------------------------------------------------- - -void gime_base_device::reset_timer(void) -{ - /* value is from 0-4095 */ - m_timer_value = ((m_gime_registers[0x04] & 0x0F) * 0x100) | m_gime_registers[0x05]; - - /* depending on the GIME type, cannonicalize the value */ - if (m_timer_value > 0) - { - if (GIME_TYPE_1987) - m_timer_value += 1; /* the 1987 GIME reset to the value plus one */ - else - m_timer_value += 2; /* the 1986 GIME reset to the value plus two */ - } - - attotime duration; - if ((timer_type() == GIME_TIMER_CLOCK) && (m_timer_value > 0)) - { - /* we're starting a countdown on the GIME clock timer */ - attotime current_time = machine().time(); - UINT64 current_tick = current_time.as_ticks(m_clock); - duration = attotime::from_ticks(current_tick + m_timer_value, m_clock) - current_time; - } - else - { - /* either the timer is off, or were not using the GIME clock timer */ - duration = attotime::never; - } - m_gime_clock_timer->adjust(duration); - - if (LOG_TIMER) - logerror("%s: reset_timer(): timer_type=%s value=%d\n", describe_context(), timer_type_string(), m_timer_value); -} - - - -//************************************************************************** -// MEMORY AND REGISTERS -//************************************************************************** - -//------------------------------------------------- -// update_memory -//------------------------------------------------- - -inline void gime_base_device::update_memory(void) -{ - for (int bank = 0; bank <= 8; bank++) - { - update_memory(bank); - } -} - - - -//------------------------------------------------- -// update_memory -//------------------------------------------------- - -void gime_base_device::update_memory(int bank) -{ - // choose bank - assert((bank >= 0) && (bank < ARRAY_LENGTH(m_read_banks)) && (bank < ARRAY_LENGTH(m_write_banks))); - memory_bank *read_bank = m_read_banks[bank]; - memory_bank *write_bank = m_write_banks[bank]; - - // bank 8 is really $FE00-$FEFF; it is weird so adjust for it - offs_t offset; - bool force_ram; - bool enable_mmu = (m_gime_registers[0] & 0x40) ? true : false; - if (bank == 8) - { - bank = 7; - offset = 0x1E00; - force_ram = true; - enable_mmu = enable_mmu && !(m_gime_registers[0] & 0x08); - } - else - { - offset = 0x0000; - force_ram = false; - } - - // is the MMU enabled at $FF90? - int block; - if (enable_mmu) - { - // check TR register at $FF91 - bank += (m_gime_registers[1] & 0x01) ? 8 : 0; - - // perform the MMU lookup - block = m_mmu[bank]; - - // also check $FF9B - relevant for the 2-8 MB upgrade - block |= ((UINT32) ((m_gime_registers[11] >> 4) & 0x03)) << 8; - } - else - { - // the MMU is not enabled - block = bank + 56; - } - - // are we actually in ROM? - UINT8 *memory; - bool is_read_only; - if (((block & 0x3F) >= 0x3C) && !(m_sam_state & SAM_STATE_TY) && !force_ram) - { - // we're in ROM - static const UINT8 rom_map[4][4] = - { - { 0, 1, 6, 7 }, - { 0, 1, 6, 7 }, - { 0, 1, 2, 3 }, - { 4, 5, 6, 7 } - }; - - // look up the block in the ROM map - block = rom_map[m_gime_registers[0] & 3][(block & 0x3F) - 0x3C]; - - // are we in onboard ROM or cart ROM? - UINT8 *rom_ptr = (block & 4) ? m_cart_rom : m_rom; - // TODO: make this unmapped - if (rom_ptr==NULL) rom_ptr = m_rom; - // perform the look up - memory = &rom_ptr[(block & 3) * 0x2000]; - is_read_only = true; - } - else - { - // we're in RAM - memory = memory_pointer(block * 0x2000); - is_read_only = false; - } - - // compensate for offset - memory += offset; - - // set the banks - read_bank->set_base(memory); - write_bank->set_base(is_read_only ? m_dummy_bank : memory); -} - - - -//------------------------------------------------- -// memory_pointer -//------------------------------------------------- - -UINT8 *gime_base_device::memory_pointer(UINT32 address) -{ - return &m_ram->pointer()[address % m_ram->size()]; -} - - - -//------------------------------------------------- -// update_cart_rom -//------------------------------------------------- - -void gime_base_device::update_cart_rom(void) -{ - m_cart_rom = m_cart_device->get_cart_base(); - update_memory(); -} - - - -//------------------------------------------------- -// read -//------------------------------------------------- - -UINT8 gime_base_device::read(offs_t offset) -{ - UINT8 data = 0x00; - - switch(offset & 0xF0) - { - case 0x00: - data = read_gime_register(offset); - break; - - case 0x10: - data = read_mmu_register(offset); - break; - - case 0x20: - data = read_palette_register(offset); - break; - - default: - data = read_floating_bus(); - break; - } - - return data; -} - - - -//------------------------------------------------- -// read_gime_register -//------------------------------------------------- - -inline UINT8 gime_base_device::read_gime_register(offs_t offset) -{ - offset &= 0x0F; - - UINT8 result; - switch(offset) - { - case 2: // read pending IRQs - result = m_irq; - if (result != 0x00) - { - m_irq = 0x00; - recalculate_irq(); - } - break; - - case 3: // read pending FIRQs - result = m_firq; - if (result != 0x00) - { - m_firq = 0x00; - recalculate_firq(); - } - break; - - case 14: - case 15: - // these (I guess) are readable (Mametesters bug #05135) - result = m_gime_registers[offset]; - break; - - default: - // the others are not readable; read floating bus (Mametesters bug #05135) - result = read_floating_bus(); - break; - } - return result; -} - - - -//------------------------------------------------- -// read_mmu_register -//------------------------------------------------- - -inline UINT8 gime_base_device::read_mmu_register(offs_t offset) -{ - return (m_mmu[offset & 0x0F] & 0x3F) | (read_floating_bus() & 0xC0); -} - - - -//------------------------------------------------- -// read_palette_register -//------------------------------------------------- - -inline UINT8 gime_base_device::read_palette_register(offs_t offset) -{ - // Bits 7/6 are floating, and behave oddly. On a real CoCo 3 - // - // POKE&HFFB1,255:PRINTPEEK(&HFFB1) returns 127. - // POKE&HFFB1,0:PRINTPEEK(&HFFB1) returns 64 - // - // This is because of the floating bus - return m_palette_rotated[m_palette_rotated_position][offset & 0x0F] - | (read_floating_bus() & 0xC0); -} - - - -//------------------------------------------------- -// read_floating_bus -//------------------------------------------------- - -inline UINT8 gime_base_device::read_floating_bus(void) -{ - return m_read_floating_bus(0); -} - - - -//------------------------------------------------- -// write -//------------------------------------------------- - -void gime_base_device::write(offs_t offset, UINT8 data) -{ - switch(offset & 0xF0) - { - case 0x00: - write_gime_register(offset & 0x0F, data); - break; - - case 0x10: - write_mmu_register(offset & 0x0F, data); - break; - - case 0x20: - write_palette_register(offset & 0x0F, data & 0x3F); - break; - - case 0x30: - case 0x40: - write_sam_register(offset - 0x30); - break; - } -} - - - -//------------------------------------------------- -// write_gime_register -//------------------------------------------------- - -inline void gime_base_device::write_gime_register(offs_t offset, UINT8 data) -{ - // this is needed for writes to FF95 - bool timer_was_off = (m_gime_registers[0x04] == 0x00) && (m_gime_registers[0x05] == 0x00); - - // sanity check input - offset &= 0x0F; - - // perform logging - if (LOG_GIME) - logerror("%s: CoCo3 GIME: $%04x <== $%02x\n", describe_context(), offset + 0xff90, data); - - // make the change, and track the difference - UINT8 xorval = m_gime_registers[offset] ^ data; - m_gime_registers[offset] = data; - - switch(offset) - { - case 0x00: - // $FF90 Initialization register 0 - // Bit 7 COCO 1=CoCo compatible mode - // Bit 6 MMUEN 1=MMU enabled - // Bit 5 IEN 1 = GIME chip IRQ enabled - // Bit 4 FEN 1 = GIME chip FIRQ enabled - // Bit 3 MC3 1 = RAM at FEXX is constant - // Bit 2 MC2 1 = standard SCS (Spare Chip Select) - // Bit 1 MC1 ROM map control - // Bit 0 MC0 ROM map control - if (xorval & 0x4B) - update_memory(); - break; - - case 0x01: - // $FF91 Initialization register 1 - // Bit 7 Unused - // Bit 6 Unused - // Bit 5 TINS Timer input select; 1 = 280 nsec, 0 = 63.5 usec - // Bit 4 Unused - // Bit 3 Unused - // Bit 2 Unused - // Bit 1 Unused - // Bit 0 TR Task register select - if (xorval & 0x01) - update_memory(); - - // I'm not sure about this one; as written this code will reset the timer - // with the _original_ value. This is probably not correct. - if (xorval & 0x20) - reset_timer(); - break; - - case 0x02: - // $FF92 Interrupt request enable register - // Bit 7 Unused - // Bit 6 Unused - // Bit 5 TMR Timer interrupt - // Bit 4 HBORD Horizontal border interrupt - // Bit 3 VBORD Vertical border interrupt - // ! Bit 2 EI2 Serial data interrupt - // Bit 1 EI1 Keyboard interrupt - // Bit 0 EI0 Cartridge interrupt - if (LOG_INT_MASKING) - { - logerror("%s: GIME IRQ: Interrupts { %s%s%s%s%s%s} enabled\n", - describe_context(), - (data & 0x20) ? "TMR " : "", - (data & 0x10) ? "HBORD " : "", - (data & 0x08) ? "VBORD " : "", - (data & 0x04) ? "EI2 " : "", - (data & 0x02) ? "EI1 " : "", - (data & 0x01) ? "EI0 " : ""); - } - break; - - case 0x03: - // $FF93 Fast interrupt request enable register - // Bit 7 Unused - // Bit 6 Unused - // Bit 5 TMR Timer interrupt - // Bit 4 HBORD Horizontal border interrupt - // Bit 3 VBORD Vertical border interrupt - // ! Bit 2 EI2 Serial data interrupt - // Bit 1 EI1 Keyboard interrupt - // Bit 0 EI0 Cartridge interrupt - if (LOG_INT_MASKING) - { - logerror("%s: GIME FIRQ: Interrupts { %s%s%s%s%s%s} enabled\n", - describe_context(), - (data & 0x20) ? "TMR " : "", - (data & 0x10) ? "HBORD " : "", - (data & 0x08) ? "VBORD " : "", - (data & 0x04) ? "EI2 " : "", - (data & 0x02) ? "EI1 " : "", - (data & 0x01) ? "EI0 " : ""); - } - break; - - case 0x04: - // $FF94 Timer register MSB - // Bits 4-7 Unused - // Bits 0-3 High order four bits of the timer - reset_timer(); - break; - - case 0x05: - // $FF95 Timer register LSB - // Bits 0-7 Low order eight bits of the timer - if (timer_was_off && (m_gime_registers[0x05] != 0x00)) - { - // Writes to $FF95 do not cause the timer to reset, but MESS - // will invoke coco3_timer_reset() if $FF94/5 was previously - // $0000. The reason for this is because the timer is not - // actually off when $FF94/5 are loaded with $0000; rather it - // is continuously reloading the GIME's internal countdown - // register, even if it isn't causing interrupts to be raised. - // - // Failure to do this was the cause of bug #1065. Special - // thanks to John Kowalski for pointing me in the right - // direction - reset_timer(); - } - break; - - case 0x08: - // $FF98 Video Mode Register - // Bit 7 BP 0 = Text modes, 1 = Graphics modes - // Bit 6 Unused - // ! Bit 5 BPI Burst Phase Invert (Color Set) - // Bit 4 MOCH 1 = Monochrome on Composite - // ! Bit 3 H50 1 = 50 Hz power, 0 = 60 Hz power - // Bits 0-2 LPR Lines per row - break; - - case 0x09: - // $FF99 Video Resolution Register - // Bit 7 Undefined - // Bits 5-6 LPF Lines per Field (Number of Rows) - // Bits 2-4 HRES Horizontal Resolution - // 000=16 bytes per row - // 001=20 bytes per row - // 010=32 bytes per row - // 011=40 bytes per row - // 100=64 bytes per row - // 101=80 bytes per row - // 110=128 bytes per row - // 111=160 bytes per row - // Bits 0-1 CRES Color Resolution - if (xorval & 0x60) - update_geometry(); - break; - - case 0x0A: - // $FF9A Border Register - // Bits 6,7 Unused - // Bits 0-5 BRDR Border color - break; - - case 0x0C: - // $FF9C Vertical Scroll Register - // Bits 4-7 Reserved - // Bits 0-3 VSC Vertical Scroll bits - break; - - case 0x0B: - // $FF9B Two/Eight Megabyte Upgrade register - // - // This variable is weird; it affects both the video position, but - // it also affects normal memory mapping. However, changing $FF9B - // alone won't affect the MMU; writes to $FFAx are required to "latch" - // in the $FF9B value. - // - // The reason that $FF9B is not mentioned in offical documentation - // is because it is only meaningful in CoCo 3's with the 2MB upgrade - break; - - case 0x0D: - case 0x0E: - // $FF9B,$FF9D,$FF9E Vertical Offset Registers - // - // According to JK, if an odd value is placed in $FF9E on the 1986 - // GIME, the GIME crashes - break; - - case 0x0F: - // $FF9F Horizontal Offset Register - // Bit 7 HVEN Horizontal Virtual Enable - // Bits 0-6 X0-X6 Horizontal Offset Address - // - // Unline $FF9D-E, this value can be modified mid frame - // - // Note that the FF9F offset is shifted by one bit (e.g. - $FF9F=$03 will - // be a six byte offset). Also note that scanlines wrap at 256 byte boundaries - // without regard to bit 7. - break; - } -} - - - -//------------------------------------------------- -// write_mmu_register -//------------------------------------------------- - -inline void gime_base_device::write_mmu_register(offs_t offset, UINT8 data) -{ - offset &= 0x0F; - - // Check to see if the MMU register has changed. If we have more than 512k of RAM - // then we have to always update because this is the point at which the MMU makes - // decisions based off of $FF9B - if ((m_mmu[offset] != data) || (m_ram->size() > 512*1024)) - { - m_mmu[offset] = data; - update_memory(offset & 0x07); - } -} - - - -//------------------------------------------------- -// write_palette_register -//------------------------------------------------- - -inline void gime_base_device::write_palette_register(offs_t offset, UINT8 data) -{ - offset &= 0x0F; - - /* has this entry changed? */ - if (m_palette_rotated[m_palette_rotated_position][offset] != data) - { - /* do we need to rotate the palette? */ - if (m_palette_rotated_position_used) - { - /* identify the new position */ - UINT16 new_palette_rotated_position = (m_palette_rotated_position + 1) % ARRAY_LENGTH(m_palette_rotated); - - /* copy the palette */ - for (int i = 0; i < ARRAY_LENGTH(m_palette_rotated[0]); i++) - m_palette_rotated[new_palette_rotated_position][i] = m_palette_rotated[m_palette_rotated_position][i]; - - /* and advance */ - m_palette_rotated_position = new_palette_rotated_position; - m_palette_rotated_position_used = false; - } - - /* record the change */; - m_palette_rotated[m_palette_rotated_position][offset] = data; - } -} - - - -//------------------------------------------------- -// write_sam_register -//------------------------------------------------- - -inline void gime_base_device::write_sam_register(offs_t offset) -{ - /* change the SAM state */ - UINT16 xorval = alter_sam_state(offset); - - /* $FFDE-F can trigger a memory update */ - if (xorval & SAM_STATE_TY) - update_memory(); - - if (xorval & (SAM_STATE_R1|SAM_STATE_R0)) - update_cpu_clock(); -} - - - -//------------------------------------------------- -// interrupt_rising_edge -//------------------------------------------------- - -void gime_base_device::interrupt_rising_edge(UINT8 interrupt) -{ - /* evaluate IRQ */ - if ((m_gime_registers[0x00] & 0x20) && (m_gime_registers[0x02] & interrupt)) - { - m_irq |= interrupt; - recalculate_irq(); - } - - /* evaluate FIRQ */ - if ((m_gime_registers[0x00] & 0x10) && (m_gime_registers[0x03] & interrupt)) - { - m_firq |= interrupt; - recalculate_firq(); - } -} - - - -//------------------------------------------------- -// recalculate_irq -//------------------------------------------------- - -void gime_base_device::recalculate_irq(void) -{ - m_write_irq(irq_r()); -} - - - -//------------------------------------------------- -// recalculate_firq -//------------------------------------------------- - -void gime_base_device::recalculate_firq(void) -{ - m_write_firq(firq_r()); -} - - - -//************************************************************************** -// VIDEO STATE -//************************************************************************** - -//------------------------------------------------- -// get_video_base -// -// The purpose of the ff9d_mask and ff9e_mask is to mask out bits that are -// ignored in lo-res mode. Specifically, $FF9D is masked with $E0, and -// $FF9E is masked with $3F -// -// John Kowalski confirms this behavior -//------------------------------------------------- - -inline offs_t gime_base_device::get_video_base(void) -{ - offs_t result; - UINT8 ff9d_mask, ff9e_mask; - - if (m_legacy_video) - { - /* legacy video gets the base address from the SAM addresses, and masks out GIME variables */ - result = display_offset(); - ff9d_mask = 0xE0; - ff9e_mask = 0x3F; - } - else - { - /* GIME video ignores the SAM addresses, relying on the GIME variables exclusively */ - result = 0; - ff9d_mask = 0xFF; - ff9e_mask = 0xFF; - } - - result += ((offs_t) (m_gime_registers[0x0E] & ff9e_mask) * 0x00008) - | ((offs_t) (m_gime_registers[0x0D] & ff9d_mask) * 0x00800) - | ((offs_t) (m_gime_registers[0x0B] & 0x0F) * 0x80000); - return result; -} - - - -//------------------------------------------------- -// new_frame -//------------------------------------------------- - -void gime_base_device::new_frame(void) -{ - /* call inherited function */ - super::new_frame(); - - /* latch in legacy video value */ - bool legacy_video_changed = update_value(&m_legacy_video, m_gime_registers[0] & 0x80 ? true : false); - - /* latch in the video position */ - m_video_position = get_video_base(); - m_line_in_row = m_gime_registers[0x0C] & 0x0F; - - /* update the geometry, as appropriate */ - if (legacy_video_changed) - update_geometry(); -} - - - -//------------------------------------------------- -// horizontal_sync_changed -//------------------------------------------------- - -void gime_base_device::horizontal_sync_changed(bool line) -{ - set_interrupt_value(INTERRUPT_HBORD, line); - - /* decrement timer if appropriate */ - if ((timer_type() == GIME_TIMER_HBORD) && (m_timer_value > 0) && line) - { - if (--m_timer_value == 0) - timer_elapsed(); - } - -} - - - -//------------------------------------------------- -// enter_bottom_border -//------------------------------------------------- - -void gime_base_device::enter_bottom_border(void) -{ - set_interrupt_value(INTERRUPT_VBORD, true); - set_interrupt_value(INTERRUPT_VBORD, false); -} - - - -//------------------------------------------------- -// update_border -//------------------------------------------------- - -void gime_base_device::update_border(UINT16 physical_scanline) -{ - UINT8 border; - if (m_legacy_video) - { - /* legacy video */ - switch(border_value(m_ff22_value, true)) - { - case BORDER_COLOR_GREEN: - border = 0x12; /* green */ - break; - case BORDER_COLOR_WHITE: - border = 0x3F; /* white */ - break; - case BORDER_COLOR_BLACK: - border = 0x00; /* black */ - break; - case BORDER_COLOR_ORANGE: - border = 0x26; /* orange */ - break; - default: - fatalerror("Should not get here\n"); - } - } - else - { - /* get the border value from $FF9A */ - border = m_gime_registers[0x0A] & 0x3F; - } - update_value(&m_scanlines[physical_scanline].m_border, border); -} - - - -//------------------------------------------------- -// record_border_scanline -//------------------------------------------------- - -void gime_base_device::record_border_scanline(UINT16 physical_scanline) -{ - m_line_in_row = 0; - update_border(physical_scanline); - update_value(&m_scanlines[physical_scanline].m_line_in_row, (UINT8) ~0); -} - - - -//------------------------------------------------- -// get_lines_per_row -//------------------------------------------------- - -inline UINT16 gime_base_device::get_lines_per_row(void) -{ - UINT16 lines_per_row; - if (m_legacy_video) - { - switch(m_ff22_value & (MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0)) - { - case 0: - case MODE_GM0: - case MODE_GM1: - case MODE_GM1|MODE_GM0: - case MODE_GM2: - case MODE_GM2|MODE_GM0: - case MODE_GM2|MODE_GM1: - case MODE_GM2|MODE_GM1|MODE_GM0: - lines_per_row = 12; - break; - - case MODE_AG: - case MODE_AG|MODE_GM0: - case MODE_AG|MODE_GM1: - lines_per_row = 3; - break; - - case MODE_AG|MODE_GM1|MODE_GM0: - case MODE_AG|MODE_GM2: - lines_per_row = 2; - break; - - case MODE_AG|MODE_GM2|MODE_GM0: - case MODE_AG|MODE_GM2|MODE_GM1: - case MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0: - lines_per_row = 1; - break; - - default: - fatalerror("Should not get here\n"); - } - } - else - { - switch(m_gime_registers[0x08] & 0x07) - { - case 0x00: - case 0x01: - lines_per_row = 1; - break; - case 0x02: - lines_per_row = 2; - break; - case 0x03: - lines_per_row = 8; - break; - case 0x04: - lines_per_row = 9; - break; - case 0x05: - lines_per_row = 10; - break; - case 0x06: - lines_per_row = 11; - break; - case 0x07: - lines_per_row = 0xFFFF; - break; - default: - fatalerror("Should not get here\n"); - } - } - return lines_per_row; -} - - - -//------------------------------------------------- -// record_scanline_res -//------------------------------------------------- - -template -inline UINT32 gime_base_device::record_scanline_res(int scanline) -{ - int column; - UINT32 base_offset = m_legacy_video ? 0 : (m_gime_registers[0x0F] & 0x7F) * 2; - UINT32 offset = 0; - - /* main loop */ - for (column = 0; column < xres; column++) - { - /* input data */ - UINT8 data, mode; - offset += ((*this).*(get_data))(m_video_position + ((base_offset + offset) & 0xFF), &data, &mode); - - /* and record the pertinent values */ - if (record_mode) - update_value(&m_scanlines[scanline].m_mode[column], mode); - update_value(&m_scanlines[scanline].m_data[column], data); - update_value(&m_scanlines[scanline].m_palette[column], m_palette_rotated_position); - } - - return offset; -} - - - -//------------------------------------------------- -// get_data_mc6847 - used for retrieving data/mode -// in legacy video modes -//------------------------------------------------- - -UINT32 gime_base_device::get_data_mc6847(UINT32 video_position, UINT8 *data, UINT8 *mode) -{ - *data = *memory_pointer(video_position); - *mode = (m_ff22_value & (MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0|MODE_CSS)) - | ((*data & 0x80) == 0x80 ? MODE_AS : 0) - | ((*data & 0xC0) == 0x40 ? MODE_INV : 0); - - // postprocess the mode to remove unnecessary flags - *mode = mc6847_friend_device::simplify_mode(*data, *mode); - return 1; -} - - - -//------------------------------------------------- -// get_data_without_attributes - used for -// retrieving data/mode in GIME graphics or GIME -// text modes without attributes -//------------------------------------------------- - -UINT32 gime_base_device::get_data_without_attributes(UINT32 video_position, UINT8 *data, UINT8 *mode) -{ - *data = *memory_pointer(video_position); - *mode = NO_ATTRIBUTE; - return 1; -} - - - -//------------------------------------------------- -// get_data_with_attributes - used for retrieving -// data/mode in GIME text modes with attributes -//------------------------------------------------- - -UINT32 gime_base_device::get_data_with_attributes(UINT32 video_position, UINT8 *data, UINT8 *mode) -{ - *data = *memory_pointer(video_position + 0); - *mode = *memory_pointer(video_position + 1); - - /* is the blink attribute specified? */ - if (UNEXPECTED(*mode & 0x80)) - { - /* if so - and we're blinking - then clear the character */ - if (m_is_blinking) - { - *data = 0x20; - *mode &= ~0x40; - } - - /* clear the blink bit */ - *mode &= ~0x80; - } - return 2; -} - - - -//------------------------------------------------- -// record_body_scanline -//------------------------------------------------- - -void gime_base_device::record_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline) -{ - /* update the border first */ - update_border(physical_scanline); - - /* set the line in row */ - update_value(&m_scanlines[physical_scanline].m_line_in_row, m_line_in_row); - - /* we're using this palette rotation */ - m_palette_rotated_position_used = true; - - UINT32 pitch = 0; - if (m_legacy_video) - { - /* legacy video */ - update_value(&m_scanlines[physical_scanline].m_ff22_value, m_ff22_value); - - switch(m_ff22_value & (MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0)) - { - case MODE_AG: - case MODE_AG|MODE_GM0: - case MODE_AG|MODE_GM1|MODE_GM0: - case MODE_AG|MODE_GM2|MODE_GM0: - pitch = record_scanline_res<16, &gime_base_device::get_data_mc6847, true>(physical_scanline); - break; - - case 0: - case MODE_GM0: - case MODE_GM1: - case MODE_GM1|MODE_GM0: - case MODE_GM2: - case MODE_GM2|MODE_GM0: - case MODE_GM2|MODE_GM1: - case MODE_GM2|MODE_GM1|MODE_GM0: - case MODE_AG|MODE_GM1: - case MODE_AG|MODE_GM2: - case MODE_AG|MODE_GM2|MODE_GM1: - case MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0: - pitch = record_scanline_res<32, &gime_base_device::get_data_mc6847, true>(physical_scanline); - break; - - default: - /* should not get here */ - fatalerror("Should not get here\n"); - } - } - else - { - /* CoCo 3 video */ - update_value(&m_scanlines[physical_scanline].m_ff98_value, m_gime_registers[0x08]); - update_value(&m_scanlines[physical_scanline].m_ff99_value, m_gime_registers[0x09]); - - /* is this graphics or text? */ - if (m_gime_registers[0x08] & 0x80) - { - /* graphics */ - switch(m_gime_registers[0x09] & 0x1C) - { - case 0x00: pitch = record_scanline_res< 16, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x04: pitch = record_scanline_res< 20, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x08: pitch = record_scanline_res< 32, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x0C: pitch = record_scanline_res< 40, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x10: pitch = record_scanline_res< 64, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x14: pitch = record_scanline_res< 80, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x18: pitch = record_scanline_res<128, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - case 0x1C: pitch = record_scanline_res<160, &gime_base_device::get_data_without_attributes, false>(physical_scanline); break; - default: - fatalerror("Should not get here\n"); - } - } - else - { - /* text */ - switch(m_gime_registers[0x09] & 0x15) - { - case 0x00: pitch = record_scanline_res< 32, &gime_base_device::get_data_without_attributes, true>(physical_scanline); break; - case 0x01: pitch = record_scanline_res< 32, &gime_base_device::get_data_with_attributes, true>(physical_scanline); break; - case 0x04: pitch = record_scanline_res< 40, &gime_base_device::get_data_without_attributes, true>(physical_scanline); break; - case 0x05: pitch = record_scanline_res< 40, &gime_base_device::get_data_with_attributes, true>(physical_scanline); break; - case 0x10: pitch = record_scanline_res< 64, &gime_base_device::get_data_without_attributes, true>(physical_scanline); break; - case 0x11: pitch = record_scanline_res< 64, &gime_base_device::get_data_with_attributes, true>(physical_scanline); break; - case 0x14: pitch = record_scanline_res< 80, &gime_base_device::get_data_without_attributes, true>(physical_scanline); break; - case 0x15: pitch = record_scanline_res< 80, &gime_base_device::get_data_with_attributes, true>(physical_scanline); break; - default: - fatalerror("Should not get here\n"); - } - } - - /* is the GIME hoizontal virtual screen enabled? */ - if (m_gime_registers[0x0F] & 0x80) - { - pitch = 256; - } - } - - /* sanity checks */ - assert(pitch > 0); - - /* are we moving on to the next line? */ - if (++m_line_in_row >= get_lines_per_row()) - { - /* next row */ - m_line_in_row = 0; - m_video_position += pitch; - } -} - - - -//------------------------------------------------- -// record_partial_body_scanline -//------------------------------------------------- - -void gime_base_device::record_partial_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline, INT32 start_clock, INT32 end_clock) -{ - fatalerror("NYI"); -} - - - -//------------------------------------------------- -// update_geometry -//------------------------------------------------- - -void gime_base_device::update_geometry(void) -{ - UINT16 top_border_scanlines, body_scanlines; - - switch(m_legacy_video ? 0x00 : (m_gime_registers[9] & 0x60)) - { - case 0x00: - // 192 lines (and legacy video) - top_border_scanlines = 25; - body_scanlines = 192; - break; - - case 0x20: - // 200 lines - top_border_scanlines = 23; - body_scanlines = 200; - break; - - case 0x40: - // zero/infinite lines - // - // If specified within the border, the border will go forever. If specified within the body, the body will go forever. This - // suggests that there is a counter that counts scanlines, and we switch border <=> body when we hit some maximum count - top_border_scanlines = ~0; - body_scanlines = ~0; - break; - - case 0x60: - // 225 lines - top_border_scanlines = 8; - body_scanlines = 225; - break; - - default: - fatalerror("Should not get here\n"); - } - - // bit 3 of $FF99 controls "wideness" - bool wide = !m_legacy_video && (m_gime_registers[9] & 0x08); - - // set the geometry - set_geometry(top_border_scanlines, body_scanlines, wide); -} - - - -//************************************************************************** -// VIDEO BLITTING -//************************************************************************** - -//------------------------------------------------- -// emit_dummy_samples -//------------------------------------------------- - -UINT32 gime_base_device::emit_dummy_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette) -{ - fatalerror("Should not get here\n"); -} - -//------------------------------------------------- -// emit_mc6847_samples -//------------------------------------------------- - -inline UINT32 gime_base_device::emit_mc6847_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette) -{ - return super::emit_mc6847_samples<2>( - scanline->m_mode[sample_start], - &scanline->m_data[sample_start], - sample_count, - pixels, - palette, - super::m_charrom_cb, - sample_start, - scanline->m_line_in_row); -} - - - -//------------------------------------------------- -// emit_gime_graphics_samples -//------------------------------------------------- - -template -inline UINT32 gime_base_device::emit_gime_graphics_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette) -{ - const UINT8 *data = &scanline->m_data[sample_start]; - mc6847_friend_device::emit_graphics(data, sample_count, pixels, 0, palette); - return sample_count * (8 / bits_per_pixel) * xscale; -} - - - -//------------------------------------------------- -// emit_gime_text_samples -//------------------------------------------------- - -template -inline UINT32 gime_base_device::emit_gime_text_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette) -{ - UINT8 attribute = scanline->m_mode[sample_start]; - const UINT8 *data = &scanline->m_data[sample_start]; - - /* determine the background/foreground colors */ - UINT8 bg = (attribute == NO_ATTRIBUTE) ? 0 : ((attribute >> 0) & 0x07) + 0x00; - UINT8 fg = (attribute == NO_ATTRIBUTE) ? 1 : ((attribute >> 3) & 0x07) + 0x08; - - /* underline attribute */ - int underline_line = -1; - if ((attribute != NO_ATTRIBUTE) && (attribute & 0x40)) - { - /* to quote SockMaster: - * - * The underline attribute will light up the bottom scan line of the character - * if the lines are set to 8 or 9. Not appear at all when less, or appear on - * the 2nd to bottom scan line if set higher than 9. Further exception being - * the $x7 setting where the whole screen is filled with only one line of data - * - but it's glitched - the line repeats over and over again every 16 scan - * lines.. Nobody will use this mode, but that's what happens if you want to - * make things really authentic :) - */ - switch(scanline->m_ff98_value & 0x07) - { - case 0x03: - underline_line = 7; - break; - case 0x04: - case 0x05: - underline_line = 8; - break; - case 0x06: - underline_line = 9; - break; - } - } - - for (int i = 0; i < sample_count; i++) - { - for (int j = 0; j < 8; j++) - { - for (int k = 0; k < xscale; k++) - { - UINT8 font_byte = hires_font[data[i] & 0x7F][scanline->m_line_in_row]; - bool bit = (scanline->m_line_in_row == underline_line) || ((font_byte >> (7 - j)) & 0x01); - pixels[(i * 8 + j) * xscale + k] = bit ? palette[fg] : palette[bg]; - } - } - } - return sample_count * 8 * xscale; -} - - - -//------------------------------------------------- -// render_scanline -//------------------------------------------------- - -template -inline void gime_base_device::render_scanline(const scanline_record *scanline, pixel_t *pixels, int min_x, int max_x, palette_resolver *resolver) -{ - int left_border, right_border; - int x, x2, pixel_position; - pixel_t border_color = resolver->lookup(scanline->m_border); - const pixel_t *resolved_palette = NULL; - - /* is this a wide video mode? */ - bool wide = !m_legacy_video && (scanline->m_ff99_value & 0x04); - - /* size up the borders */ - if (sample_count > 0) - { - left_border = wide ? 0 : 64; - right_border = wide ? 640 : 512; - } - else - { - left_border = 640; - right_border = 640; - } - - /* left border */ - for (x = min_x; x < left_border; x++) - { - pixels[x] = border_color; - } - - /* right border */ - for (x = right_border; x <= max_x; x++) - { - pixels[x] = border_color; - } - - /* offset the pixel counts depending on wide */ - pixels += wide ? 0 : 64; - - /* body */ - x = 0; - pixel_position = 0; - while(x < sample_count) - { - /* determine how many bytes exist for which the mode is identical */ - for (x2 = x + 1; (x2 < sample_count) && (scanline->m_mode[x] == scanline->m_mode[x2]) && (scanline->m_palette[x] == scanline->m_palette[x2]); x2++) - ; - - /* resolve the palette */ - resolved_palette = resolver->get_palette(scanline->m_palette[x]); - - /* emit the samples, with a (hopefully) aggressively inlined function */ - pixel_position += ((*this).*(emit_samples))(scanline, x, x2 - x, &pixels[pixel_position], resolved_palette); - - /* update x */ - x = x2; - } - - /* artifacting */ - if (m_legacy_video && (sample_count > 0)) - { - m_artifacter.process_artifacts<2>(pixels, scanline->m_mode[0], resolved_palette); - } -} - - - -//------------------------------------------------- -// update_screen -//------------------------------------------------- - -bool gime_base_device::update_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect, const pixel_t *RESTRICT palette) -{ - int base_x = 64; - int min_x = USE_HORIZONTAL_CLIP ? cliprect.min_x : 0; - int max_x = USE_HORIZONTAL_CLIP ? cliprect.max_x : (base_x * 2 + 512 - 1); - int min_y = cliprect.min_y; - int max_y = cliprect.max_y; - palette_resolver resolver(this, palette); - - /* if the video didn't change, indicate as much */ - if (!has_video_changed()) - return UPDATE_HAS_NOT_CHANGED; - - for (int y = min_y; y <= max_y; y++) - { - const scanline_record *scanline = &m_scanlines[y]; - pixel_t *RESTRICT pixels = bitmap_addr(bitmap, y, 0); - - /* render the scanline */ - if (m_scanlines[y].m_line_in_row == (UINT8) ~0) - { - /* this is a border scanline */ - render_scanline<0, &gime_base_device::emit_dummy_samples>(scanline, pixels, min_x, max_x, &resolver); - } - else if (m_legacy_video) - { - /* this is a legacy body scanline */ - switch(scanline->m_ff22_value & (MODE_AG|MODE_GM2|MODE_GM1|MODE_GM0)) - { - case MODE_AG: - case MODE_AG|MODE_GM0: - case MODE_AG|MODE_GM1|MODE_GM0: - case MODE_AG|MODE_GM2|MODE_GM0: - render_scanline<16, &gime_base_device::emit_mc6847_samples>(scanline, pixels, min_x, max_x, &resolver); - break; - - default: - render_scanline<32, &gime_base_device::emit_mc6847_samples>(scanline, pixels, min_x, max_x, &resolver); - break; - } - } - else if (scanline->m_ff98_value & 0x80) - { - /* GIME graphics */ - switch(scanline->m_ff99_value & 0x1F) - { - case 0x00: render_scanline< 16, &gime_base_device::emit_gime_graphics_samples< 4, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x01: render_scanline< 16, &gime_base_device::emit_gime_graphics_samples< 8, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x02: - case 0x03: render_scanline< 16, &gime_base_device::emit_gime_graphics_samples<16, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x04: render_scanline< 20, &gime_base_device::emit_gime_graphics_samples< 4, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x05: render_scanline< 20, &gime_base_device::emit_gime_graphics_samples< 8, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x06: - case 0x07: render_scanline< 20, &gime_base_device::emit_gime_graphics_samples<16, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x08: render_scanline< 32, &gime_base_device::emit_gime_graphics_samples< 2, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x09: render_scanline< 32, &gime_base_device::emit_gime_graphics_samples< 4, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x0A: - case 0x0B: render_scanline< 32, &gime_base_device::emit_gime_graphics_samples< 8, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x0C: render_scanline< 40, &gime_base_device::emit_gime_graphics_samples< 2, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x0D: render_scanline< 40, &gime_base_device::emit_gime_graphics_samples< 4, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x0E: - case 0x0F: render_scanline< 40, &gime_base_device::emit_gime_graphics_samples< 8, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x10: render_scanline< 64, &gime_base_device::emit_gime_graphics_samples< 1, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x11: render_scanline< 64, &gime_base_device::emit_gime_graphics_samples< 2, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x12: - case 0x13: render_scanline< 64, &gime_base_device::emit_gime_graphics_samples< 4, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x14: render_scanline< 80, &gime_base_device::emit_gime_graphics_samples< 1, 1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x15: render_scanline< 80, &gime_base_device::emit_gime_graphics_samples< 2, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x16: - case 0x17: render_scanline< 80, &gime_base_device::emit_gime_graphics_samples< 4, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x18: - case 0x19: render_scanline<128, &gime_base_device::emit_gime_graphics_samples< 1, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x1A: - case 0x1B: render_scanline<128, &gime_base_device::emit_gime_graphics_samples< 2, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x1C: - case 0x1D: render_scanline<160, &gime_base_device::emit_gime_graphics_samples< 1, 2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x1E: - case 0x1F: render_scanline<160, &gime_base_device::emit_gime_graphics_samples< 2, 4> >(scanline, pixels, min_x, max_x, &resolver); break; - } - } - else - { - /* GIME text */ - switch(scanline->m_ff99_value & 0x14) - { - case 0x00: render_scanline<32, &gime_base_device::emit_gime_text_samples<2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x04: render_scanline<40, &gime_base_device::emit_gime_text_samples<2> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x10: render_scanline<64, &gime_base_device::emit_gime_text_samples<1> >(scanline, pixels, min_x, max_x, &resolver); break; - case 0x14: render_scanline<80, &gime_base_device::emit_gime_text_samples<1> >(scanline, pixels, min_x, max_x, &resolver); break; - } - } - } - return 0; -} - - - -//------------------------------------------------- -// update_composite -//------------------------------------------------- - -bool gime_base_device::update_composite(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - update_value(&m_displayed_rgb, false); - const pixel_t *palette = (m_gime_registers[0x08] & 0x10) - ? m_composite_bw_palette - : m_composite_palette; - return update_screen(bitmap, cliprect, palette); -} - - - -//------------------------------------------------- -// update_rgb -//------------------------------------------------- - -bool gime_base_device::update_rgb(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - update_value(&m_displayed_rgb, true); - return update_screen(bitmap, cliprect, m_rgb_palette); -} - - - -//************************************************************************** -// PALETTE RESOLVER MEMBER CLASS -//************************************************************************** - -//------------------------------------------------- -// palette_resolver::palette_resolver -//------------------------------------------------- - -inline gime_base_device::palette_resolver::palette_resolver(gime_base_device *gime, const pixel_t *palette) -{ - m_gime = gime; - m_palette = palette; - memset(m_resolved_palette, 0, sizeof(m_resolved_palette)); - m_current_resolved_palette = -1; -} - - - -//------------------------------------------------- -// palette_resolver::get_palette -//------------------------------------------------- - -inline const gime_base_device::pixel_t *gime_base_device::palette_resolver::get_palette(UINT16 palette_rotation) -{ - if (UNEXPECTED(m_current_resolved_palette != palette_rotation)) - { - for (int i = 0; i < 16; i++) - m_resolved_palette[i] = lookup(m_gime->m_palette_rotated[palette_rotation][i]); - m_current_resolved_palette = palette_rotation; - } - return m_resolved_palette; -} - - - -//------------------------------------------------- -// palette_resolver::lookup -//------------------------------------------------- - -inline gime_base_device::pixel_t gime_base_device::palette_resolver::lookup(UINT8 color) -{ - assert(color <= 63); - return m_palette[color]; -} - - - -//------------------------------------------------- -// hires_font -//------------------------------------------------- - -const UINT8 gime_base_device::hires_font[128][12] = -{ - { 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x10}, { 0x44, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00}, - { 0x08, 0x10, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00}, { 0x10, 0x28, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00}, - { 0x28, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00}, { 0x20, 0x10, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00}, - { 0x10, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00}, { 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x10}, - { 0x10, 0x28, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00}, { 0x28, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00}, - { 0x20, 0x10, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00}, { 0x28, 0x00, 0x30, 0x10, 0x10, 0x10, 0x38, 0x00}, - { 0x10, 0x28, 0x00, 0x30, 0x10, 0x10, 0x38, 0x00}, { 0x00, 0x18, 0x24, 0x38, 0x24, 0x24, 0x38, 0x40}, - { 0x44, 0x10, 0x28, 0x44, 0x7C, 0x44, 0x44, 0x00}, { 0x10, 0x10, 0x28, 0x44, 0x7C, 0x44, 0x44, 0x00}, - { 0x08, 0x10, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, { 0x00, 0x00, 0x68, 0x14, 0x3C, 0x50, 0x3C, 0x00}, - { 0x3C, 0x50, 0x50, 0x78, 0x50, 0x50, 0x5C, 0x00}, { 0x10, 0x28, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, - { 0x28, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, { 0x00, 0x00, 0x38, 0x4C, 0x54, 0x64, 0x38, 0x00}, - { 0x10, 0x28, 0x00, 0x44, 0x44, 0x4C, 0x34, 0x00}, { 0x20, 0x10, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00}, - { 0x38, 0x4C, 0x54, 0x54, 0x54, 0x64, 0x38, 0x00}, { 0x44, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00}, - { 0x28, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00}, { 0x38, 0x40, 0x38, 0x44, 0x38, 0x04, 0x38, 0x00}, - { 0x08, 0x14, 0x10, 0x38, 0x10, 0x50, 0x3C, 0x00}, { 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x7C, 0x00}, - { 0x10, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}, { 0x08, 0x14, 0x10, 0x38, 0x10, 0x10, 0x20, 0x40}, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, { 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00}, - { 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00}, { 0x28, 0x28, 0x7C, 0x28, 0x7C, 0x28, 0x28, 0x00}, - { 0x10, 0x3C, 0x50, 0x38, 0x14, 0x78, 0x10, 0x00}, { 0x60, 0x64, 0x08, 0x10, 0x20, 0x4C, 0x0C, 0x00}, - { 0x20, 0x50, 0x50, 0x20, 0x54, 0x48, 0x34, 0x00}, { 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}, - { 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00}, { 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00}, - { 0x00, 0x10, 0x54, 0x38, 0x38, 0x54, 0x10, 0x00}, { 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00}, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x20}, { 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00}, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00}, { 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}, - { 0x38, 0x44, 0x4C, 0x54, 0x64, 0x44, 0x38, 0x00}, { 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00}, - { 0x38, 0x44, 0x04, 0x38, 0x40, 0x40, 0x7C, 0x00}, { 0x38, 0x44, 0x04, 0x08, 0x04, 0x44, 0x38, 0x00}, - { 0x08, 0x18, 0x28, 0x48, 0x7C, 0x08, 0x08, 0x00}, { 0x7C, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00}, - { 0x38, 0x40, 0x40, 0x78, 0x44, 0x44, 0x38, 0x00}, { 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x00}, - { 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00}, { 0x38, 0x44, 0x44, 0x38, 0x04, 0x04, 0x38, 0x00}, - { 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00}, { 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x20}, - { 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00}, { 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x00, 0x00}, - { 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00}, { 0x38, 0x44, 0x04, 0x08, 0x10, 0x00, 0x10, 0x00}, - { 0x38, 0x44, 0x04, 0x34, 0x4C, 0x4C, 0x38, 0x00}, { 0x10, 0x28, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x00}, - { 0x78, 0x24, 0x24, 0x38, 0x24, 0x24, 0x78, 0x00}, { 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00}, - { 0x78, 0x24, 0x24, 0x24, 0x24, 0x24, 0x78, 0x00}, { 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x7C, 0x00}, - { 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x40, 0x00}, { 0x38, 0x44, 0x40, 0x40, 0x4C, 0x44, 0x38, 0x00}, - { 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00}, { 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00}, - { 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00}, { 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00}, - { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C, 0x00}, { 0x44, 0x6C, 0x54, 0x54, 0x44, 0x44, 0x44, 0x00}, - { 0x44, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x44, 0x00}, { 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00}, - { 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00}, { 0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x00}, - { 0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x00}, { 0x38, 0x44, 0x40, 0x38, 0x04, 0x44, 0x38, 0x00}, - { 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}, { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00}, - { 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00}, { 0x44, 0x44, 0x44, 0x44, 0x54, 0x6C, 0x44, 0x00}, - { 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x00}, { 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00}, - { 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7C, 0x00}, { 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00}, - { 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00}, { 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00}, - { 0x10, 0x38, 0x54, 0x10, 0x10, 0x10, 0x10, 0x00}, { 0x00, 0x10, 0x20, 0x7C, 0x20, 0x10, 0x00, 0x00}, - { 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, { 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00}, - { 0x40, 0x40, 0x58, 0x64, 0x44, 0x64, 0x58, 0x00}, { 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00}, - { 0x04, 0x04, 0x34, 0x4C, 0x44, 0x4C, 0x34, 0x00}, { 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00}, - { 0x08, 0x14, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00}, { 0x00, 0x00, 0x34, 0x4C, 0x4C, 0x34, 0x04, 0x38}, - { 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00}, { 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x38, 0x00}, - { 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x44, 0x38}, { 0x40, 0x40, 0x48, 0x50, 0x60, 0x50, 0x48, 0x00}, - { 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00}, { 0x00, 0x00, 0x68, 0x54, 0x54, 0x54, 0x54, 0x00}, - { 0x00, 0x00, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00}, { 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, - { 0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40}, { 0x00, 0x00, 0x3C, 0x44, 0x44, 0x3C, 0x04, 0x04}, - { 0x00, 0x00, 0x58, 0x64, 0x40, 0x40, 0x40, 0x00}, { 0x00, 0x00, 0x3C, 0x40, 0x38, 0x04, 0x78, 0x00}, - { 0x20, 0x20, 0x70, 0x20, 0x20, 0x24, 0x18, 0x00}, { 0x00, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00}, - { 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00}, { 0x00, 0x00, 0x44, 0x54, 0x54, 0x28, 0x28, 0x00}, - { 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00}, { 0x00, 0x00, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x38}, - { 0x00, 0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00}, { 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00}, - { 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00}, { 0x20, 0x10, 0x10, 0x08, 0x10, 0x10, 0x20, 0x00}, - { 0x20, 0x54, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00}, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00} -}; - - - -//************************************************************************** -// VARIATIONS -//************************************************************************** - -const device_type GIME_NTSC = &device_creator; -const device_type GIME_PAL = &device_creator; - - - -//------------------------------------------------- -// gime_ntsc_device -//------------------------------------------------- - -gime_ntsc_device::gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gime_base_device(mconfig, GIME_NTSC, "GIME_NTSC", tag, owner, clock, ntsc_round_fontdata8x12, "gime_ntsc", __FILE__) -{ -} - - - -//------------------------------------------------- -// gime_pal_device -//------------------------------------------------- - -gime_pal_device::gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : gime_base_device(mconfig, GIME_PAL, "GIME_PAL", tag, owner, clock, pal_round_fontdata8x12, "gime_pal", __FILE__) -{ -} diff --git a/src/mess/video/gime.h b/src/mess/video/gime.h deleted file mode 100644 index 862dfeec3b0..00000000000 --- a/src/mess/video/gime.h +++ /dev/null @@ -1,311 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/********************************************************************* - - gime.h - - Implementation of CoCo GIME (Graphics Interrupt Memory Enhancement) - video chip. - -***************************************************************************/ - -#pragma once - -#ifndef __GIME__ -#define __GIME__ - -#include "video/mc6847.h" -#include "machine/6883sam.h" -#include "machine/ram.h" - - -//************************************************************************** -// GIME CONFIG/INTERFACE -//************************************************************************** - -#define MCFG_GIME_HSYNC_CALLBACK MCFG_MC6847_HSYNC_CALLBACK - -#define MCFG_GIME_FSYNC_CALLBACK MCFG_MC6847_FSYNC_CALLBACK - -#define MCFG_GIME_IRQ_CALLBACK(_write) \ - devcb = &gime_base_device::set_irq_wr_callback(*device, DEVCB_##_write); - -#define MCFG_GIME_FIRQ_CALLBACK(_write) \ - devcb = &gime_base_device::set_firq_wr_callback(*device, DEVCB_##_write); - -#define MCFG_GIME_FLOATING_BUS_CALLBACK(_read) \ - devcb = &gime_base_device::set_floating_bus_rd_callback(*device, DEVCB_##_read); - -#define MCFG_GIME_MAINCPU(_tag) \ - gime_base_device::set_maincpu_tag(*device, _tag); - -#define MCFG_GIME_RAM(_tag) \ - gime_base_device::set_ram_tag(*device, _tag); - -#define MCFG_GIME_EXT(_tag) \ - gime_base_device::set_ext_tag(*device, _tag); - - -//************************************************************************** -// GIME CORE -//************************************************************************** - -class cococart_slot_device; - -class gime_base_device : public mc6847_friend_device, public sam6883_friend_device -{ -public: - template static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_irq.set_callback(object); } - template static devcb_base &set_firq_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_firq.set_callback(object); } - template static devcb_base &set_floating_bus_rd_callback(device_t &device, _Object object) { return downcast(device).m_read_floating_bus.set_callback(object); } - static void set_maincpu_tag(device_t &device, const char *tag) { downcast(device).m_maincpu_tag = tag; } - static void set_ram_tag(device_t &device, const char *tag) { downcast(device).m_ram_tag = tag; } - static void set_ext_tag(device_t &device, const char *tag) { downcast(device).m_ext_tag = tag; } - - // read/write - DECLARE_READ8_MEMBER( read ) { return read(offset); } - DECLARE_WRITE8_MEMBER( write ) { write(offset, data); } - - // used to turn on/off reading/writing to $FF40-$FF5F - bool spare_chip_select_enabled(void) { return m_gime_registers[0] & 0x04 ? true : false; } - - // the GIME seems to intercept writes to $FF22 (not precisely sure how) - void ff22_write(UINT8 data) { m_ff22_value = data; } - - // updates the cart ROM - void update_cart_rom(void); - - /* updates the screen -- this will call begin_update(), - followed by update_row() reapeatedly and after all row - updating is complete, end_update() */ - bool update_composite(bitmap_rgb32 &bitmap, const rectangle &cliprect); - bool update_rgb(bitmap_rgb32 &bitmap, const rectangle &cliprect); - - // interrupt outputs - bool firq_r(void) { return m_firq != 0x00; } - bool irq_r(void) { return m_irq != 0x00; } - - // interrupt inputs - void set_il0(bool value) { set_interrupt_value(INTERRUPT_EI0, value); } - void set_il1(bool value) { set_interrupt_value(INTERRUPT_EI1, value); } - void set_il2(bool value) { set_interrupt_value(INTERRUPT_EI2, value); } - -protected: - gime_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const UINT8 *fontdata, const char *shortname, const char *source); - - // device-level overrides - virtual void device_start(void); - virtual void device_reset(void); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual void device_pre_save(void); - virtual void device_post_load(void); - virtual ioport_constructor device_input_ports() const; - - // other overrides - virtual void new_frame(void); - virtual void horizontal_sync_changed(bool line); - virtual void enter_bottom_border(void); - virtual void record_border_scanline(UINT16 physical_scanline); - virtual void record_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline); - virtual void record_partial_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline, INT32 start_clock, INT32 end_clock); - -private: - typedef mc6847_friend_device super; - - struct scanline_record - { - UINT8 m_border; - UINT8 m_line_in_row; - UINT8 m_ff22_value; - UINT8 m_ff98_value; - UINT8 m_ff99_value; - UINT8 m_mode[160]; - UINT8 m_data[160]; - UINT16 m_palette[160]; - }; - - typedef UINT32 (gime_base_device::*get_data_func)(UINT32, UINT8 *, UINT8 *); - - class palette_resolver - { - public: - palette_resolver(gime_base_device *gime, const pixel_t *palette); - const pixel_t *get_palette(UINT16 palette_rotation); - pixel_t lookup(UINT8 color); - - private: - gime_base_device *m_gime; - const pixel_t *m_palette; - pixel_t m_resolved_palette[16]; - int m_current_resolved_palette; - }; - - enum - { - INTERRUPT_TMR = 0x20, - INTERRUPT_HBORD = 0x10, - INTERRUPT_VBORD = 0x08, - INTERRUPT_EI2 = 0x04, - INTERRUPT_EI1 = 0x02, - INTERRUPT_EI0 = 0x01 - }; - - enum timer_type_t - { - GIME_TIMER_HBORD, - GIME_TIMER_CLOCK - }; - - // timer constants - static const device_timer_id TIMER_GIME_CLOCK = 4; - - // statics - static const UINT8 hires_font[128][12]; - - // callbacks - devcb_write_line m_write_irq; - devcb_write_line m_write_firq; - devcb_read8 m_read_floating_bus; - - // device state - UINT8 m_gime_registers[16]; - UINT8 m_mmu[16]; - UINT8 m_ff22_value; - UINT8 m_interrupt_value; - UINT8 m_irq; - UINT8 m_firq; - UINT16 m_timer_value; - bool m_is_blinking; - - // video state - bool m_legacy_video; - UINT32 m_video_position; - UINT8 m_line_in_row; - scanline_record m_scanlines[25+192+26]; - bool m_displayed_rgb; - - // palette state - UINT8 m_palette_rotated[1024][16]; - UINT16 m_palette_rotated_position; - bool m_palette_rotated_position_used; - - // incidentals - ram_device * m_ram; - emu_timer * m_gime_clock_timer; - cococart_slot_device * m_cart_device; - memory_bank * m_read_banks[9]; - memory_bank * m_write_banks[9]; - UINT8 * m_rom; - UINT8 * m_cart_rom; - pixel_t m_composite_palette[64]; - pixel_t m_composite_bw_palette[64]; - pixel_t m_rgb_palette[64]; - UINT8 m_dummy_bank[0x2000]; - - const char *m_maincpu_tag; /* tag of main CPU */ - const char *m_ram_tag; /* tag of RAM device */ - const char *m_ext_tag; /* tag of expansion device */ - - // timer constants - static const device_timer_id TIMER_FRAME = 0; - static const device_timer_id TIMER_HSYNC_OFF = 1; - static const device_timer_id TIMER_HSYNC_ON = 2; - static const device_timer_id TIMER_FSYNC_OFF = 3; - static const device_timer_id TIMER_FSYNC_ON = 4; - - // read/write - UINT8 read(offs_t offset); - UINT8 read_gime_register(offs_t offset); - UINT8 read_mmu_register(offs_t offset); - UINT8 read_palette_register(offs_t offset); - UINT8 read_floating_bus(void); - void write(offs_t offset, UINT8 data); - void write_gime_register(offs_t offset, UINT8 data); - void write_mmu_register(offs_t offset, UINT8 data); - void write_palette_register(offs_t offset, UINT8 data); - void write_sam_register(offs_t offset); - - // memory - void update_memory(void); - void update_memory(int bank); - UINT8 *memory_pointer(UINT32 address); - - // interrupts - void interrupt_rising_edge(UINT8 interrupt); - void recalculate_irq(void); - void recalculate_firq(void); - - ATTR_FORCE_INLINE void set_interrupt_value(UINT8 interrupt, bool value) - { - /* save the old interrupt value */ - UINT8 old_interrupt_value = m_interrupt_value; - - /* update the interrupt value */ - if (value) - m_interrupt_value |= interrupt; - else - m_interrupt_value &= ~interrupt; - - /* was this a rising edge? */ - if (value && ((old_interrupt_value & interrupt) == 0)) - { - interrupt_rising_edge(interrupt); - } - } - - // timer - timer_type_t timer_type(void); - const char *timer_type_string(void); - void reset_timer(void); - void timer_elapsed(void); - - // video - bool update_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect, const pixel_t *palette); - void update_geometry(void); - void update_border(UINT16 physical_scanline); - pixel_t get_composite_color(int color); - pixel_t get_rgb_color(int color); - offs_t get_video_base(void); - UINT16 get_lines_per_row(void); - UINT32 get_data_mc6847(UINT32 video_position, UINT8 *data, UINT8 *mode); - UINT32 get_data_without_attributes(UINT32 video_position, UINT8 *data, UINT8 *mode); - UINT32 get_data_with_attributes(UINT32 video_position, UINT8 *data, UINT8 *mode); - bool is_blinking(void); - - // template function for doing video update collection - template - UINT32 record_scanline_res(int scanline); - - // rendering sampled graphics - typedef UINT32 (gime_base_device::*emit_samples_proc)(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette); - UINT32 emit_dummy_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette); - UINT32 emit_mc6847_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette); - template - UINT32 emit_gime_text_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette); - template - UINT32 emit_gime_graphics_samples(const scanline_record *scanline, int sample_start, int sample_count, pixel_t *pixels, const pixel_t *palette); - template - void render_scanline(const scanline_record *scanline, pixel_t *pixels, int min_x, int max_x, palette_resolver *resolver); -}; - - -//************************************************************************** -// VARIATIONS -//************************************************************************** - -class gime_ntsc_device : public gime_base_device -{ -public: - gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); -}; - -class gime_pal_device : public gime_base_device -{ -public: - gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); -}; - -extern const device_type GIME_NTSC; -extern const device_type GIME_PAL; - -#endif /* __GIME__ */ diff --git a/src/mess/video/hec2video.c b/src/mess/video/hec2video.c deleted file mode 100644 index f16f23b8363..00000000000 --- a/src/mess/video/hec2video.c +++ /dev/null @@ -1,141 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:JJ Stacino -///////////////////////////////////////////////////////////////////////////////// -///// Hector video -///////////////////////////////////////////////////////////////////////////////// -/* Hector 2HR+ - Victor - Hector 2HR - Hector HRX - Hector MX40c - Hector MX80c - Hector 1 - Interact - - 12/05/2009 Skeleton driver - Micko : mmicko@gmail.com - 31/06/2009 Video - Robbbert - - 29/10/2009 Update skeleton to functional machine - by yo_fr (jj.stac @ aliceadsl.fr) - - => add Keyboard, - => add color, - => add cassette, - => add sn76477 sound and 1bit sound, - => add joysticks (stick, pot, fire) - => add BR/HR switching - => add bank switch for HRX - => add device MX80c and bank switching for the ROM - Importante note : the keyboard function add been piked from - DChector project : http://dchector.free.fr/ made by DanielCoulom - (thank's Daniel) - TODO : Add the cartridge function, - Adjust the one shot and A/D timing (sn76477) -*/ - -#include "emu.h" - -#include "includes/hec2hrp.h" - - -void hec2hrp_state::Init_Hector_Palette() -{ - UINT8 *hector_color = m_hector_color; - // basic colors ! - hector_color[0] = 0; // fond (noir) - hector_color[1] = 1; // HECTOR HRX (rouge) - hector_color[2] = 7; // Point interrogation (Blanc) - hector_color[3] = 3; // Ecriture de choix (jaune) - - // Color initialisation : full lightning - m_palette->set_pen_color( 0,rgb_t(000,000,000));//Noir - m_palette->set_pen_color( 1,rgb_t(255,000,000));//Rouge - m_palette->set_pen_color( 2,rgb_t(000,255,000));//Vert - m_palette->set_pen_color( 3,rgb_t(255,255,000));//Jaune - m_palette->set_pen_color( 4,rgb_t(000,000,255));//Bleu - m_palette->set_pen_color( 5,rgb_t(255,000,255));//Magneta - m_palette->set_pen_color( 6,rgb_t(000,255,255));//Cyan - m_palette->set_pen_color( 7,rgb_t(255,255,255));//Blanc - // 1/2 lightning - - m_palette->set_pen_color( 8,rgb_t(000,000,000));//Noir - m_palette->set_pen_color( 9,rgb_t(128,000,000));//Rouge - m_palette->set_pen_color( 10,rgb_t(000,128,000));//Vert - m_palette->set_pen_color( 11,rgb_t(128,128,000));//Jaune - m_palette->set_pen_color( 12,rgb_t(000,000,128));//Bleu - m_palette->set_pen_color( 13,rgb_t(128,000,128));//Magneta - m_palette->set_pen_color( 14,rgb_t(000,128,128));//Cyan - m_palette->set_pen_color( 15,rgb_t(128,128,128));//Blanc -} - -void hec2hrp_state::hector_hr(bitmap_ind16 &bitmap, UINT8 *page, int ymax, int yram) -{ - UINT8 *hector_color = m_hector_color; - UINT8 gfx,y; - UINT16 sy=0,ma=0,x; - for (y = 0; y <= ymax; y++) { //224 - UINT16 *p = &bitmap.pix16(sy++); - for (x = ma; x < ma + yram; x++) { // 64 - gfx = *(page+x); - /* Display a scanline of a character (4 pixels !) */ - *p++ = hector_color[(gfx >> 0) & 0x03]; - *p++ = hector_color[(gfx >> 2) & 0x03]; - *p++ = hector_color[(gfx >> 4) & 0x03]; - *p++ = hector_color[(gfx >> 6) & 0x03]; - } - ma+=yram; - } -} - -void hec2hrp_state::hector_80c(bitmap_ind16 &bitmap, UINT8 *page, int ymax, int yram) -{ - UINT8 gfx,y; - UINT16 sy=0,ma=0,x; - for (y = 0; y <= ymax; y++) { //224 - UINT16 *p = &bitmap.pix16(sy++); - for (x = ma; x < ma + yram; x++) { // 64 - gfx = *(page+x); - /* Display a scanline of a character (8 pixels !) */ - *p++ = (gfx & 0x01) ? 7 : 0; - *p++ = (gfx & 0x02) ? 7 : 0; - *p++ = (gfx & 0x04) ? 7 : 0; - *p++ = (gfx & 0x08) ? 7 : 0; - *p++ = (gfx & 0x10) ? 7 : 0; - *p++ = (gfx & 0x20) ? 7 : 0; - *p++ = (gfx & 0x40) ? 7 : 0; - *p++ = (gfx & 0x80) ? 7 : 0; - } - ma+=yram; - } -} - - -VIDEO_START_MEMBER(hec2hrp_state,hec2hrp) -{ - Init_Hector_Palette(); -} - -UINT32 hec2hrp_state::screen_update_hec2hrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - UINT8 *videoram_HR = m_hector_videoram; - if (m_hector_flag_hr==1) - { - if (m_hector_flag_80c==0) - { - screen.set_visible_area(0, 243, 0, 227); - hector_hr(bitmap , &videoram_HR[0], 227, 64); - } - else - { - screen.set_visible_area(0, 243*2, 0, 227); - hector_80c(bitmap , &videoram_HR[0], 227, 64); - } - } - else - { - screen.set_visible_area(0, 113, 0, 75); - hector_hr(bitmap, videoram, 77, 32); - } - return 0; -} diff --git a/src/mess/video/hp48.c b/src/mess/video/hp48.c deleted file mode 100644 index 03883f17100..00000000000 --- a/src/mess/video/hp48.c +++ /dev/null @@ -1,203 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Antoine Mine -/********************************************************************** - - Copyright (C) Antoine Mine' 2008 - - Hewlett Packard HP48 S/SX & G/GX/G+ - -**********************************************************************/ - -#include "emu.h" -#include "includes/hp48.h" - -/*************************************************************************** - DEBUGGING -***************************************************************************/ - - -#define VERBOSE 0 - -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - - - -/*************************************************************************** - GLOBAL VARIABLES & CONSTANTS -***************************************************************************/ - -/* base colors */ -static const int hp48_bg_color[3] = { 136, 147, 109 }; /* yellow */ -static const int hp48_fg_color[3] = { 0, 0, 64 }; /* dark blue */ - -/* color mixing */ -#define mix(c1,c2,x) (c1)*(1-(x))+(c2)*(x) -#define mix2(i,x) mix(hp48_bg_color[i],hp48_fg_color[i],x) - - - - -/*************************************************************************** - FUNCTIONS -***************************************************************************/ - -PALETTE_INIT_MEMBER(hp48_state, hp48) -{ - int i; - for ( i = 0; i < 255; i++ ) - { - float c = i/255.; - m_palette->set_pen_color( i, rgb_t( 0, mix2(0,c), mix2(1,c), mix2(2,c) ) ); - } -} - - - -/* The screen is organised as follows: - - - - announciators - - ---------------------- ^ ^ - | | | | - | | | | - | | | | - | | M lines | - | main screen | | | - | | | | - | | | 64 lines - | | | | - | | | | - |----------------------| - | - | | | | - | menu | m lines | - | | | | - ---------------------- v v - - <----- 131 columns ----> - - - - The LCD is 131x64 pixels and has two components: - - a main screen - - a menu screen - - The main height (M) and the menu height (m) can be changed with the constraints: - - m+M=64 - - M>=2 - - Pixels are 1-bit, packed in memory. - - The start address of both screens can be changed independently - (this allows smooth, pixel-precise vertical scrooling of both parts). - They must be even addresses (in nibbles). - - The stride (offset in nibbles between two scanlines) can be changed for the main screen. - It must be even. - It is fixed to 34 for the menu screen. - - The bit offset for the first column of the main screen can be changed - (this allows smooth, pixel-precise horizontal scrooling). - It is always 0 for the menu screen. - - Above the LCD, there are 6 annonciators that can be independently turned - on and off (and independetly from the LCD). - They are not handled here, but through output_set_value. - */ - - -/* - In theory, the LCD is monorchrome, with a global adjustable contrast (32 levels). - However, by switching between screens at each refresh (64 Hz), one can achieve the - illusion of grayscale, with moderate flickering. - This technique was very widespread. - We emulate it by simply averaging between the last few (HP48_NB_SCREENS) frames. - - HP48_NB_SCREENS should be a multiple of the period of screen flips to avoid - flickering in the emulation. - */ - - -#define draw_pixel \ - m_screens[ m_cur_screen ][ y ][ xp + 8 ] = (data & 1) ? fg : 0; \ - xp++; \ - data >>= 1 - -#define draw_quart \ - UINT8 data = space.read_byte( addr ); \ - draw_pixel; draw_pixel; draw_pixel; draw_pixel; - - -UINT32 hp48_state::screen_update_hp48(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - int x, y, xp, i, addr; - int display = HP48_IO_4(0) >> 3; /* 1=on, 0=off */ - int left_margin = HP48_IO_4(0) & 7; /* 0..7 pixels for main bitmap */ - int contrast = HP48_IO_8(1) & 0x1f; /* 0..31 */ - int refresh = HP48_IO_4(3) >> 3; /* vertical refresh */ - int bitmap_start = HP48_IO_20(0x20) & ~1; /* main bitmap address */ - int right_margin = HP48_IO_12(0x25) & ~1; /* -2048..2046 nibbles for main bitmap */ - int last_line = HP48_IO_8(0x28) & 0x3f; /* 2..63 lines of main bitmap before menu */ - int menu_start = HP48_IO_20(0x30) & ~1; /* menu bitmap address */ - int fg = contrast + 2; - - LOG(( "%f hp48 video_update called: ", machine().time().as_double())); - - if ( !display || refresh ) - { - LOG(( "display off\n" )); - bitmap.fill(0 ); - return 0; - } - - /* correcting factors */ - if ( right_margin & 0x800 ) right_margin -= 0x1000; - if ( last_line <= 1 ) last_line = 0x3f; - - LOG(( "on=%i lmargin=%i rmargin=%i contrast=%i start=%05x lline=%i menu=%05x\n", - display, left_margin, right_margin, contrast, bitmap_start, last_line, menu_start )); - - /* draw main bitmap */ - addr = bitmap_start; - for ( y = 0; y <= last_line; y++ ) - { - xp = -left_margin; - for ( x = 0; x < 34; x++, addr++ ) - { - draw_quart; - } - addr += (right_margin + (left_margin / 4) + 1) & ~1; - } - - /* draw menu bitmap */ - addr = menu_start; - for ( ; y <= 0x3f; y++ ) - { - xp = 0; - for ( x = 0; x < 34; x++, addr++ ) - { - draw_quart; - } - } - - /* draw averaged frames */ - for ( y = 0; y < 64; y++ ) - { - for ( x = 0; x < 131; x++ ) - { - int acc = 0; - for ( i = 0; i < HP48_NB_SCREENS; i++ ) - { - acc += m_screens[ i ][ y ][ x+8 ]; - } - acc = (acc * 255) / (33 * HP48_NB_SCREENS); - bitmap.pix16(y, x ) = acc; - } - } - - m_cur_screen = (m_cur_screen + 1) % HP48_NB_SCREENS; - - return 0; -} diff --git a/src/mess/video/intv.c b/src/mess/video/intv.c deleted file mode 100644 index 42c12b743a8..00000000000 --- a/src/mess/video/intv.c +++ /dev/null @@ -1,137 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods,Frank Palazzolo -#include "emu.h" -#include "includes/intv.h" - -void intv_state::video_start() -{ - m_tms9927_num_rows = 25; -} - - -/* very rudimentary support for the tms9927 character generator IC */ - - -READ8_MEMBER( intv_state::intvkbd_tms9927_r ) -{ - UINT8 rv; - switch (offset) - { - case 8: - rv = m_tms9927_cursor_row; - break; - case 9: - /* note: this is 1-based */ - rv = m_tms9927_cursor_col; - break; - case 11: - m_tms9927_last_row = (m_tms9927_last_row + 1) % m_tms9927_num_rows; - rv = m_tms9927_last_row; - break; - default: - rv = 0; - } - return rv; -} - -WRITE8_MEMBER( intv_state::intvkbd_tms9927_w ) -{ - switch (offset) - { - case 3: - m_tms9927_num_rows = (data & 0x3f) + 1; - break; - case 6: - m_tms9927_last_row = data; - break; - case 11: - m_tms9927_last_row = (m_tms9927_last_row + 1) % m_tms9927_num_rows; - break; - case 12: - /* note: this is 1-based */ - m_tms9927_cursor_col = data; - break; - case 13: - m_tms9927_cursor_row = data; - break; - } -} - - -UINT32 intv_state::screen_update_intv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_stic->screen_update(screen, bitmap, cliprect); - return 0; -} - - -UINT32 intv_state::screen_update_intvkbd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - int x,y,offs; - int current_row; -// char c; - - /* Draw the underlying INTV screen first */ - m_stic->screen_update(screen, bitmap, cliprect); - - /* if the intvkbd text is not blanked, overlay it */ - if (!m_intvkbd_text_blanked) - { - current_row = (m_tms9927_last_row + 1) % m_tms9927_num_rows; - for(y=0;y<24;y++) - { - for(x=0;x<40;x++) - { - offs = current_row*64+x; - - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - videoram[offs], - 7, /* white */ - 0,0, - x<<3,y<<3, 0); - } - if (current_row == m_tms9927_cursor_row) - { - /* draw the cursor as a solid white block */ - /* (should use a filled rect here!) */ - - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - 191, /* a block */ - 7, /* white */ - 0,0, - (m_tms9927_cursor_col-1)<<3,y<<3, 0); - } - current_row = (current_row + 1) % m_tms9927_num_rows; - } - } - -#if 0 - // debugging - c = tape_motor_mode_desc[m_tape_motor_mode][0]; - m_gfxdecode->gfx(0)->transpen(bitmap,&machine().screen[0].visarea, - c, - 1, - 0,0, - 0*8,0*8, 0); - for(y=0;y<5;y++) - { - m_gfxdecode->gfx(0)->transpen(bitmap,&machine().screen[0].visarea, - m_tape_unknown_write[y]+'0', - 1, - 0,0, - 0*8,(y+2)*8, 0); - } - m_gfxdecode->gfx(0)->transpen(bitmap,&machine().screen[0].visarea, - m_tape_unknown_write[5]+'0', - 1, - 0,0, - 0*8,8*8, 0); - m_gfxdecode->gfx(0)->transpen(bitmap,&machine().screen[0].visarea, - m_tape_interrupts_enabled+'0', - 1, - 0,0, - 0*8,10*8, 0); -#endif - return 0; -} diff --git a/src/mess/video/k1ge.c b/src/mess/video/k1ge.c deleted file mode 100644 index 94e0398fd1a..00000000000 --- a/src/mess/video/k1ge.c +++ /dev/null @@ -1,918 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/****************************************************************************** - - K1GE/K2GE graphics emulation - - The K1GE graphics were used in the Neogeo pocket mono; the K2GE graphics were - used in the Neogeo pocket color. - -******************************************************************************/ - -#include "emu.h" -#include "k1ge.h" - - -PALETTE_INIT_MEMBER(k1ge_device, k1ge) -{ - int i; - - for ( i = 0; i < 8; i++ ) - { - int j = ( i << 5 ) | ( i << 2 ) | ( i >> 1 ); - - palette.set_pen_color( 7-i, j, j, j ); - } -} - - -PALETTE_INIT_MEMBER(k2ge_device, k2ge) -{ - int r,g,b; - - for ( b = 0; b < 16; b++ ) - { - for ( g = 0; g < 16; g++ ) - { - for ( r = 0; r < 16; r++ ) - { - palette.set_pen_color( ( b << 8 ) | ( g << 4 ) | r, ( r << 4 ) | r, ( g << 4 ) | g, ( b << 4 ) | b ); - } - } - } -} - - -READ8_MEMBER( k1ge_device::read ) -{ - assert(offset < 0x4000); - - UINT8 data = m_vram[offset]; - - switch( offset ) - { - case 0x008: /* RAS.H */ - data = m_screen->hpos() >> 2; - break; - case 0x009: /* RAS.V */ - data = m_screen->vpos(); - break; - } - return data; -} - - -WRITE8_MEMBER( k1ge_device::write ) -{ - assert(offset < 0x4000); - - switch( offset ) - { - case 0x000: - m_vblank_pin_w( ( data & 0x80 ) ? ( ( m_vram[0x010] & 0x40 ) ? 1 : 0 ) : 0 ); - break; - case 0x030: - data &= 0x80; - break; - case 0x101: case 0x102: case 0x103: - case 0x105: case 0x106: case 0x107: - case 0x109: case 0x10a: case 0x10b: - case 0x10d: case 0x10e: case 0x10f: - case 0x111: case 0x112: case 0x113: - case 0x115: case 0x116: case 0x117: - data &= 0x07; - break; - case 0x7e2: - if ( m_vram[0x7f0] != 0xaa ) - return; - data &= 0x80; - break; - } - - /* Only the lower 4 bits of the palette entry high bytes can be written */ - if ( offset >= 0x0200 && offset < 0x0400 && ( offset & 1 ) ) - { - data &= 0x0f; - } - - m_vram[offset] = data; -} - - -void k1ge_device::draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, int pal_base ) -{ - int i; - int offset_x = ( scroll_x >> 3 ) * 2; - int px = scroll_x & 0x07; - UINT16 map_data; - UINT16 hflip; - UINT16 pcode; - UINT16 tile_addr; - UINT16 tile_data; - - base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); - - /* setup */ - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = pal_base + ( ( map_data & 0x2000 ) ? 4 : 0 ); - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - if ( hflip ) - tile_data >>= 2 * ( scroll_x & 0x07 ); - else - tile_data <<= 2 * ( scroll_x & 0x07 ); - - /* draw pixels */ - for ( i = 0; i < 160; i++ ) - { - UINT16 col; - - if ( hflip ) - { - col = tile_data & 0x0003; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( col ) - { - p[ i ] = m_vram[ pcode + col ]; - } - - px++; - if ( px >= 8 ) - { - offset_x = ( offset_x + 2 ) & 0x3f; - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = pal_base + ( ( map_data & 0x2000 ) ? 4 : 0 ); - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - px = 0; - } - } -} - - -void k1ge_device::draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) -{ - struct { - UINT16 spr_data; - UINT8 x; - UINT8 y; - } spr[64]; - int num_sprites = 0; - UINT8 spr_y = 0; - UINT8 spr_x = 0; - int i; - - priority <<= 11; - - /* Select sprites */ - for ( i = 0; i < 256; i += 4 ) - { - UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); - UINT8 x = m_vram[ 0x802 + i ]; - UINT8 y = m_vram[ 0x803 + i ]; - - spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); - spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); - - if ( ( spr_data & 0x1800 ) == priority ) - { - if ( ( line >= spr_y || spr_y > 0xf8 ) && line < ( ( spr_y + 8 ) & 0xff ) ) - { - spr[num_sprites].spr_data = spr_data; - spr[num_sprites].y = spr_y; - spr[num_sprites].x = spr_x; - num_sprites++; - } - } - } - - /* Draw sprites */ - for ( i = num_sprites-1; i >= 0; i-- ) - { - int j; - UINT16 tile_addr; - UINT16 tile_data; - UINT16 pcode = 0x100 + ( ( spr[i].spr_data & 0x2000 ) ? 4 : 0 ); - - tile_addr = 0x2000 + ( ( spr[i].spr_data & 0x1ff ) * 16 ); - if ( spr[i].spr_data & 0x4000 ) - tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; - else - tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - - for ( j = 0; j < 8; j++ ) - { - UINT16 col; - - spr_x = spr[i].x + j; - - if ( spr[i].spr_data & 0x8000 ) - { - col = tile_data & 0x03; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( spr_x < 160 && col ) - { - p[ spr_x ] = m_vram[ pcode + col ]; - } - } - } -} - - -void k1ge_device::draw( int line ) -{ - UINT16 *p = &m_bitmap->pix16(line); - UINT16 oowcol = m_vram[0x012] & 0x07; - int i; - - if ( line < m_wba_v || line >= m_wba_v + m_wsi_v ) - { - for( i = 0; i < 160; i++ ) - { - p[i] = oowcol; - } - } - else - { - UINT16 col = ( ( m_vram[0x118] & 0xc0 ) == 0x80 ) ? m_vram[0x118] & 0x07 : 0; - - for ( i = 0; i < 160; i++ ) - p[i] = col; - - if ( m_vram[0x030] & 0x80 ) - { - /* Draw sprites with 01 priority */ - draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108 ); - - /* Draw sprites with 10 priority */ - draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110 ); - - /* Draw sprites with 11 priority */ - draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - else - { - /* Draw sprites with 01 priority */ - draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110 ); - - /* Draw sprites with 10 priority */ - draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108 ); - - /* Draw sprites with 11 priority */ - draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - - for( i = 0; i < m_wba_h; i++ ) - { - p[i] = oowcol; - } - - for( i = m_wba_h + m_wsi_h; i < 160; i++ ) - { - p[i] = oowcol; - } - } -} - - -void k2ge_device::draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_base ) -{ - int i; - int offset_x = ( scroll_x >> 3 ) * 2; - int px = scroll_x & 0x07; - UINT16 map_data; - UINT16 hflip; - UINT16 pcode; - UINT16 tile_addr; - UINT16 tile_data; - - base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); - - /* setup */ - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = pal_base + ( ( map_data & 0x1e00 ) >> 6 ); - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - if ( hflip ) - tile_data >>= 2 * ( scroll_x & 0x07 ); - else - tile_data <<= 2 * ( scroll_x & 0x07 ); - - /* draw pixels */ - for ( i = 0; i < 160; i++ ) - { - UINT16 col; - - if ( hflip ) - { - col = tile_data & 0x0003; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( col ) - { - p[ i ] = m_vram[ pcode + col * 2 ] | ( m_vram[ pcode + col * 2 + 1 ] << 8 ); - } - - px++; - if ( px >= 8 ) - { - offset_x = ( offset_x + 2 ) & 0x3f; - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = pal_base + ( ( map_data & 0x1e00 ) >> 6 ); - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - px = 0; - } - } -} - - -void k2ge_device::draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) -{ - struct { - UINT16 spr_data; - UINT8 x; - UINT8 y; - UINT8 index; - } spr[64]; - int num_sprites = 0; - UINT8 spr_y = 0; - UINT8 spr_x = 0; - int i; - - priority <<= 11; - - /* Select sprites */ - for ( i = 0; i < 256; i += 4 ) - { - UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); - UINT8 x = m_vram[ 0x802 + i ]; - UINT8 y = m_vram[ 0x803 + i ]; - - spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); - spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); - - if ( ( spr_data & 0x1800 ) == priority ) - { - if ( ( line >= spr_y || spr_y > 0xf8 ) && line < ( ( spr_y + 8 ) & 0xff ) ) - { - spr[num_sprites].spr_data = spr_data; - spr[num_sprites].y = spr_y; - spr[num_sprites].x = spr_x; - spr[num_sprites].index = i >> 2; - num_sprites++; - } - } - } - - /* Draw sprites */ - for ( i = num_sprites-1; i >= 0; i-- ) - { - int j; - UINT16 tile_addr; - UINT16 tile_data; - UINT16 pcode = 0x0200 + ( ( m_vram[0x0c00 + spr[i].index ] & 0x0f ) << 3 ); - - tile_addr = 0x2000 + ( ( spr[i].spr_data & 0x1ff ) * 16 ); - if ( spr[i].spr_data & 0x4000 ) - tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; - else - tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - - for ( j = 0; j < 8; j++ ) - { - UINT16 col; - - spr_x = spr[i].x + j; - - if ( spr[i].spr_data & 0x8000 ) - { - col = tile_data & 0x03; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( spr_x < 160 && col ) - { - p[ spr_x ] = m_vram[ pcode + col * 2 ] | ( m_vram[ pcode + col * 2 + 1 ] << 8 ); - } - } - } -} - - -void k2ge_device::k1ge_draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_lut_base, UINT16 k2ge_lut_base ) -{ - int i; - int offset_x = ( scroll_x >> 3 ) * 2; - int px = scroll_x & 0x07; - UINT16 map_data; - UINT16 hflip; - UINT16 pcode; - UINT16 tile_addr; - UINT16 tile_data; - - base += ( ( ( ( scroll_y + line ) >> 3 ) * 0x0040 ) & 0x7ff ); - - /* setup */ - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = ( map_data & 0x2000 ) ? 1 : 0; - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - if ( hflip ) - tile_data >>= 2 * ( scroll_x & 0x07 ); - else - tile_data <<= 2 * ( scroll_x & 0x07 ); - - /* draw pixels */ - for ( i = 0; i < 160; i++ ) - { - UINT16 col; - - if ( hflip ) - { - col = tile_data & 0x0003; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( col ) - { - UINT16 col2 = 16 * pcode + ( m_vram[ pal_lut_base + 4 * pcode + col ] * 2 ); - p[ i ] = m_vram[ k2ge_lut_base + col2 ] | ( m_vram[ k2ge_lut_base + col2 + 1 ] << 8 ); - } - - px++; - if ( px >= 8 ) - { - offset_x = ( offset_x + 2 ) & 0x3f; - map_data = m_vram[ base + offset_x ] | ( m_vram[ base + offset_x + 1 ] << 8 ); - hflip = map_data & 0x8000; - pcode = ( map_data & 0x2000 ) ? 1 : 0; - tile_addr = 0x2000 + ( ( map_data & 0x1ff ) * 16 ); - if ( map_data & 0x4000 ) - tile_addr += ( 7 - ( ( scroll_y + line ) & 0x07 ) ) * 2; - else - tile_addr += ( ( scroll_y + line ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - px = 0; - } - } -} - - -void k2ge_device::k1ge_draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ) -{ - struct { - UINT16 spr_data; - UINT8 x; - UINT8 y; - } spr[64]; - int num_sprites = 0; - UINT8 spr_y = 0; - UINT8 spr_x = 0; - int i; - - priority <<= 11; - - /* Select sprites */ - for ( i = 0; i < 256; i += 4 ) - { - UINT16 spr_data = m_vram[ 0x800 + i ] | ( m_vram[ 0x801 + i ] << 8 ); - UINT8 x = m_vram[ 0x802 + i ]; - UINT8 y = m_vram[ 0x803 + i ]; - - spr_x = ( spr_data & 0x0400 ) ? ( spr_x + x ) : ( scroll_x + x ); - spr_y = ( spr_data & 0x0200 ) ? ( spr_y + y ) : ( scroll_y + y ); - - if ( ( spr_data & 0x1800 ) == priority ) - { - if ( ( line >= spr_y || spr_y > 0xf8 ) && line < ( ( spr_y + 8 ) & 0xff ) ) - { - spr[num_sprites].spr_data = spr_data; - spr[num_sprites].y = spr_y; - spr[num_sprites].x = spr_x; - num_sprites++; - } - } - } - - /* Draw sprites */ - for ( i = num_sprites-1; i >= 0; i-- ) - { - int j; - UINT16 tile_addr; - UINT16 tile_data; - UINT16 pcode = ( spr[i].spr_data & 0x2000 ) ? 1 : 0; - - tile_addr = 0x2000 + ( ( spr[i].spr_data & 0x1ff ) * 16 ); - if ( spr[i].spr_data & 0x4000 ) - tile_addr += ( 7 - ( ( line - spr[i].y ) & 0x07 ) ) * 2; - else - tile_addr += ( ( line - spr[i].y ) & 0x07 ) * 2; - tile_data = m_vram[ tile_addr ] | ( m_vram[ tile_addr + 1 ] << 8 ); - - for ( j = 0; j < 8; j++ ) - { - UINT16 col; - - spr_x = spr[i].x + j; - - if ( spr[i].spr_data & 0x8000 ) - { - col = tile_data & 0x03; - tile_data >>= 2; - } - else - { - col = tile_data >> 14; - tile_data <<= 2; - } - - if ( spr_x < 160 && col ) - { - UINT16 col2 = 16 * pcode + m_vram[ 0x100 + 4 * pcode + col ] * 2; - p[ spr_x ] = m_vram[ 0x380 + col2 ] | ( m_vram[ 0x381 + col2 ] << 8 ); - } - } - } -} - - -void k2ge_device::draw( int line ) -{ - UINT16 *p = &m_bitmap->pix16(line); - UINT16 col = 0; - UINT16 oowcol; - int i; - - oowcol = ( m_vram[0x012] & 0x07 ) * 2; - oowcol = m_vram[0x3f0 + oowcol ] | ( m_vram[0x3f1 + oowcol ] << 8 ); - - if ( line < m_wba_v || line >= m_wba_v + m_wsi_v ) - { - for( i = 0; i < 160; i++ ) - { - p[i] = oowcol; - } - } - else - { - /* Determine the background color */ - if ( ( m_vram[0x118] & 0xc0 ) == 0x80 ) - { - col = ( m_vram[0x118] & 0x07 ) * 2; - } - col = m_vram[0x3e0 + col ] | ( m_vram[0x3e1 + col ] << 8 ); - - /* Set the bacground color */ - for ( i = 0; i < 160; i++ ) - { - p[i] = col; - } - - if ( m_vram[0x7e2] & 0x80 ) - { - /* K1GE compatibility mode */ - if ( m_vram[0x030] & 0x80 ) - { - /* Draw sprites with 01 priority */ - k1ge_draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - k1ge_draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108, 0x3a0 ); - - /* Draw sprites with 10 priority */ - k1ge_draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - k1ge_draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110, 0x3c0 ); - - /* Draw sprites with 11 priority */ - k1ge_draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - else - { - /* Draw sprites with 01 priority */ - k1ge_draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - k1ge_draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x110, 0x3c0 ); - - /* Draw sprites with 10 priority */ - k1ge_draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - k1ge_draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x108, 0x3a0 ); - - /* Draw sprites with 11 priority */ - k1ge_draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - } - else - { - /* K2GE mode */ - if ( m_vram[0x030] & 0x80 ) - { - /* Draw sprites with 01 priority */ - draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x280 ); - - /* Draw sprites with 10 priority */ - draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x300 ); - - /* Draw sprites with 11 priority */ - draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - else - { - /* Draw sprites with 01 priority */ - draw_sprite_plane( p, 1, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF2 */ - draw_scroll_plane( p, 0x1800, line, m_vram[0x034], m_vram[0x035], 0x300 ); - - /* Draw sprites with 10 priority */ - draw_sprite_plane( p, 2, line, m_vram[0x020], m_vram[0x021] ); - - /* Draw PF1 */ - draw_scroll_plane( p, 0x1000, line, m_vram[0x032], m_vram[0x033], 0x280 ); - - /* Draw sprites with 11 priority */ - draw_sprite_plane( p, 3, line, m_vram[0x020], m_vram[0x021] ); - } - } - - for ( i = 0; i < m_wba_h; i++ ) - { - p[i] = oowcol; - } - - for ( i = m_wba_h + m_wsi_h; i < 160; i++ ) - { - p[i] = oowcol; - } - } -} - - -TIMER_CALLBACK_MEMBER( k1ge_device::hblank_on_timer_callback ) -{ - m_hblank_pin_w(0); -} - - -TIMER_CALLBACK_MEMBER( k1ge_device::timer_callback ) -{ - int y = m_screen->vpos(); - - /* Check for start of VBlank */ - if ( y >= 152 ) - { - m_vram[0x010] |= 0x40; - if (m_vram[0x000] & 0x80) - { - m_vblank_pin_w(1); - } - } - - /* Check for end of VBlank */ - if ( y == 0 ) - { - m_wba_h = m_vram[0x002]; - m_wba_v = m_vram[0x003]; - m_wsi_h = m_vram[0x004]; - m_wsi_v = m_vram[0x005]; - m_vram[0x010] &= ~ 0x40; - if (m_vram[0x000] & 0x80) - { - m_vblank_pin_w(0); - } - } - - /* Check if Hint should be triggered */ - if ( y == K1GE_SCREEN_HEIGHT - 1 || y < 151 ) - { - if (!m_hblank_pin_w.isnull()) - { - if (m_vram[0x000] & 0x40) - { - m_hblank_pin_w(1); - } - m_hblank_on_timer->adjust( m_screen->time_until_pos(y, 480 ) ); - } - } - - /* Draw a line when inside visible area */ - if ( y && y < 153 ) - { - draw( y - 1 ); - } - - m_timer->adjust( m_screen->time_until_pos(( y + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); -} - - -void k1ge_device::update( bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - copybitmap( bitmap, *m_bitmap, 0, 0, 0, 0, cliprect ); -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void k1ge_device::device_start() -{ - m_vblank_pin_w.resolve(); - m_hblank_pin_w.resolve(); - - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k1ge_device::timer_callback), this)); - m_hblank_on_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k1ge_device::hblank_on_timer_callback), this)); - m_vram = auto_alloc_array_clear(machine(), UINT8, 0x4000); - m_bitmap = auto_bitmap_ind16_alloc( machine(), m_screen->width(), m_screen->height() ); - - save_pointer(NAME(m_vram), 0x4000); - save_item(NAME(m_wba_h)); - save_item(NAME(m_wba_v)); - save_item(NAME(m_wsi_h)); - save_item(NAME(m_wsi_v)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void k1ge_device::device_reset() -{ - m_vram[0x000] = 0x00; /* Interrupt enable */ - m_vram[0x002] = 0x00; /* WBA.H */ - m_vram[0x003] = 0x00; /* WVA.V */ - m_vram[0x004] = 0xFF; /* WSI.H */ - m_vram[0x005] = 0xFF; /* WSI.V */ - m_vram[0x007] = 0xc6; /* REF */ - m_vram[0x012] = 0x00; /* 2D control */ - m_vram[0x020] = 0x00; /* PO.H */ - m_vram[0x021] = 0x00; /* PO.V */ - m_vram[0x030] = 0x00; /* PF */ - m_vram[0x032] = 0x00; /* S1SO.H */ - m_vram[0x033] = 0x00; /* S1SO.V */ - m_vram[0x034] = 0x00; /* S2SO.H */ - m_vram[0x035] = 0x00; /* S2SO.V */ - m_vram[0x101] = 0x07; /* SPPLT01 */ - m_vram[0x102] = 0x07; /* SPPLT02 */ - m_vram[0x103] = 0x07; /* SPPLT03 */ - m_vram[0x105] = 0x07; /* SPPLT11 */ - m_vram[0x106] = 0x07; /* SPPLT12 */ - m_vram[0x107] = 0x07; /* SPPLT13 */ - m_vram[0x109] = 0x07; /* SC1PLT01 */ - m_vram[0x10a] = 0x07; /* SC1PLT02 */ - m_vram[0x10b] = 0x07; /* SC1PLT03 */ - m_vram[0x10d] = 0x07; /* SC1PLT11 */ - m_vram[0x10e] = 0x07; /* SC1PLT12 */ - m_vram[0x10f] = 0x07; /* SC1PLT13 */ - m_vram[0x111] = 0x07; /* SC2PLT01 */ - m_vram[0x112] = 0x07; /* SC2PLT02 */ - m_vram[0x113] = 0x07; /* SC2PLT03 */ - m_vram[0x115] = 0x07; /* SC2PLT11 */ - m_vram[0x116] = 0x07; /* SC2PLT12 */ - m_vram[0x117] = 0x07; /* SC2PLT13 */ - m_vram[0x118] = 0x07; /* BG */ - m_vram[0x400] = 0xFF; /* LED control */ - m_vram[0x402] = 0x80; /* LEDFREG */ - m_vram[0x7e0] = 0x52; /* RESET */ - m_vram[0x7e2] = 0x00; /* MODE */ - - m_timer->adjust( m_screen->time_until_pos(( m_screen->vpos() + 1 ) % K1GE_SCREEN_HEIGHT, 0 ) ); -} - - -const device_type K1GE = &device_creator; - -k1ge_device::k1ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, K1GE, "K1GE Monochrome Graphics + LCD", tag, owner, clock, "k1ge", __FILE__) - , device_video_interface(mconfig, *this) - , m_vblank_pin_w(*this) - , m_hblank_pin_w(*this) -{ -} - -k1ge_device::k1ge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source) - , device_video_interface(mconfig, *this) - , m_vblank_pin_w(*this) - , m_hblank_pin_w(*this) -{ -} - -static MACHINE_CONFIG_FRAGMENT( k1ge ) - MCFG_PALETTE_ADD("palette", 8 ) - MCFG_PALETTE_INIT_OWNER(k1ge_device, k1ge) -MACHINE_CONFIG_END - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor k1ge_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( k1ge ); -} - - -const device_type K2GE = &device_creator; - -k2ge_device::k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : k1ge_device(mconfig, K2GE, "K2GE Color Graphics + LCD", tag, owner, clock, "k2ge", __FILE__) -{ -} - -static MACHINE_CONFIG_FRAGMENT( k2ge ) - MCFG_PALETTE_ADD("palette", 4096 ) - MCFG_PALETTE_INIT_OWNER(k2ge_device, k2ge) -MACHINE_CONFIG_END - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor k2ge_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( k2ge ); -} diff --git a/src/mess/video/k1ge.h b/src/mess/video/k1ge.h deleted file mode 100644 index 6ecb2e771bc..00000000000 --- a/src/mess/video/k1ge.h +++ /dev/null @@ -1,92 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/****************************************************************************** - - K1GE/K2GE graphics emulation - -******************************************************************************/ - -#ifndef __K2GE_H_ -#define __K2GE_H_ - - -#define MCFG_K1GE_ADD(_tag, _clock, _screen, _vblank, _hblank ) \ - MCFG_DEVICE_ADD( _tag, K1GE, _clock ) \ - MCFG_VIDEO_SET_SCREEN( _screen ) \ - devcb = &k1ge_device::static_set_vblank_callback( *device, DEVCB_##_vblank ); \ - devcb = &k1ge_device::static_set_hblank_callback( *device, DEVCB_##_hblank ); - -#define MCFG_K2GE_ADD(_tag, _clock, _screen, _vblank, _hblank ) \ - MCFG_DEVICE_ADD( _tag, K2GE, _clock ) \ - MCFG_VIDEO_SET_SCREEN( _screen ) \ - devcb = &k1ge_device::static_set_vblank_callback( *device, DEVCB_##_vblank ); \ - devcb = &k1ge_device::static_set_hblank_callback( *device, DEVCB_##_hblank ); - - -class k1ge_device : public device_t, - public device_video_interface -{ -public: - k1ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - k1ge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - - DECLARE_PALETTE_INIT(k1ge); - - void update( bitmap_ind16 &bitmap, const rectangle &cliprect ); - - // Static methods - template static devcb_base &static_set_vblank_callback(device_t &device, _Object object) { return downcast(device).m_vblank_pin_w.set_callback(object); } - template static devcb_base &static_set_hblank_callback(device_t &device, _Object object) { return downcast(device).m_hblank_pin_w.set_callback(object); } - - static const int K1GE_SCREEN_HEIGHT = 199; -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual machine_config_constructor device_mconfig_additions() const; - - devcb_write_line m_vblank_pin_w; - devcb_write_line m_hblank_pin_w; - UINT8 *m_vram; - UINT8 m_wba_h, m_wba_v, m_wsi_h, m_wsi_v; - - emu_timer *m_timer; - emu_timer *m_hblank_on_timer; - bitmap_ind16 *m_bitmap; - - virtual void draw(int line); - - void draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, int pal_base ); - void draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ); - TIMER_CALLBACK_MEMBER( hblank_on_timer_callback ); - TIMER_CALLBACK_MEMBER( timer_callback ); - -}; - - -class k2ge_device : public k1ge_device -{ -public: - k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_PALETTE_INIT(k2ge); -protected: - virtual machine_config_constructor device_mconfig_additions() const; - - virtual void draw(int line); - - void draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_base ); - void draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ); - void k1ge_draw_scroll_plane( UINT16 *p, UINT16 base, int line, int scroll_x, int scroll_y, UINT16 pal_lut_base, UINT16 k2ge_lut_base ); - void k1ge_draw_sprite_plane( UINT16 *p, UINT16 priority, int line, int scroll_x, int scroll_y ); - -}; - -extern const device_type K1GE; -extern const device_type K2GE; - - -#endif diff --git a/src/mess/video/kaypro.c b/src/mess/video/kaypro.c deleted file mode 100644 index d9e6d10340b..00000000000 --- a/src/mess/video/kaypro.c +++ /dev/null @@ -1,312 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert - -#include "includes/kaypro.h" - - - -/*********************************************************** - - Video - -************************************************************/ - -PALETTE_INIT_MEMBER(kaypro_state,kaypro) -{ - palette.set_pen_color(0, rgb_t::black); /* black */ - palette.set_pen_color(1, rgb_t(0, 220, 0)); /* green */ - palette.set_pen_color(2, rgb_t(0, 110, 0)); /* low intensity green */ -} - -UINT32 kaypro_state::screen_update_kayproii(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ -/* The display consists of 80 columns and 24 rows. Each row is allocated 128 bytes of ram, - but only the first 80 are used. The total video ram therefore is 0x0c00 bytes. - There is one video attribute: bit 7 causes blinking. The first half of the - character generator is blank, with the visible characters in the 2nd half. - During the "off" period of blanking, the first half is used. Only 5 pixels are - connected from the rom to the shift register, the remaining pixels are held high. */ - - UINT8 y,ra,chr,gfx; - UINT16 sy=0,ma=0,x; - - m_framecnt++; - - for (y = 0; y < 24; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 80; x++) - { - gfx = 0; - - if (ra < 8) - { - chr = m_p_videoram[x]^0x80; - - /* Take care of flashing characters */ - if ((chr < 0x80) && (m_framecnt & 0x08)) - chr |= 0x80; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<3) | ra ]; - } - - /* Display a scanline of a character (7 pixels) */ - *p++ = 0; - *p++ = BIT( gfx, 4 ); - *p++ = BIT( gfx, 3 ); - *p++ = BIT( gfx, 2 ); - *p++ = BIT( gfx, 1 ); - *p++ = BIT( gfx, 0 ); - *p++ = 0; - } - } - ma+=128; - } - return 0; -} - -UINT32 kaypro_state::screen_update_omni2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx; - UINT16 sy=0,ma=0,x; - - m_framecnt++; - - for (y = 0; y < 24; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 80; x++) - { - gfx = 0; - - if (ra < 8) - { - chr = m_p_videoram[x]; - - /* Take care of flashing characters */ - if ((chr > 0x7f) && (m_framecnt & 0x08)) - chr |= 0x80; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<3) | ra ]; - } - - /* Display a scanline of a character (7 pixels) */ - *p++ = BIT( gfx, 6 ); - *p++ = BIT( gfx, 5 ); - *p++ = BIT( gfx, 4 ); - *p++ = BIT( gfx, 3 ); - *p++ = BIT( gfx, 2 ); - *p++ = BIT( gfx, 1 ); - *p++ = BIT( gfx, 0 ); - } - } - ma+=128; - } - return 0; -} - -UINT32 kaypro_state::screen_update_kaypro2x(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - m_framecnt++; - m_crtc->screen_update(screen, bitmap, cliprect); - return 0; -} - -/* bit 6 of kaypro2x_system_port selects alternate characters (A12 on character generator rom). - The diagram specifies a 2732 with 28 pins, and more address pins. Possibly a 2764 or 27128. - Since our dump only goes up to A11, the alternate character set doesn't exist. - - 0000-07FF of videoram is memory-mapped characters; 0800-0FFF is equivalent attribute bytes. - d3 Underline - d2 blinking (at unknown rate) - d1 low intensity - d0 reverse video - - Not sure how the attributes interact, for example does an underline blink? */ - - -MC6845_UPDATE_ROW( kaypro_state::kaypro2x_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT16 x; - UINT8 gfx,fg,bg; - - for (x = 0; x < x_count; x++) // for each character - { - UINT8 inv=0; - // if (x == cursor_x) inv=0xff; /* uncomment when mame fixed */ - UINT16 mem = (ma + x) & 0x7ff; - UINT8 chr = m_p_videoram[mem]; - UINT8 attr = m_p_videoram[mem | 0x800]; - - if ((attr & 3) == 3) - { - fg = 0; - bg = 2; - } - else - if ((attr & 3) == 2) - { - fg = 2; - bg = 0; - } - else - if ((attr & 3) == 1) - { - fg = 0; - bg = 1; - } - else - { - fg = 1; - bg = 0; - } - - /* Take care of flashing characters */ - if ( (BIT(attr, 2)) & (BIT(m_framecnt, 3)) ) - fg = bg; - - /* process cursor */ - if (x == cursor_x) - inv ^= m_mc6845_cursor[ra]; - - /* get pattern of pixels for that character scanline */ - if ( (ra == 15) & (BIT(attr, 3)) ) /* underline */ - gfx = 0xff; - else - gfx = m_p_chargen[(chr<<4) | ra ] ^ inv; - - /* Display a scanline of a character (8 pixels) */ - *p++ = palette[BIT( gfx, 7 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 6 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 5 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 4 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 3 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 2 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 1 ) ? fg : bg]; - *p++ = palette[BIT( gfx, 0 ) ? fg : bg]; - } -} - -/************************************* MC6845 SUPPORT ROUTINES ***************************************/ - -/* The 6845 can produce a variety of cursor shapes - all are emulated here - remove when mame fixed */ -void kaypro_state::mc6845_cursor_configure() -{ - UINT8 i,curs_type=0,r9,r10,r11; - - /* curs_type holds the general cursor shape to be created - 0 = no cursor - 1 = partial cursor (only shows on a block of scan lines) - 2 = full cursor - 3 = two-part cursor (has a part at the top and bottom with the middle blank) */ - - for ( i = 0; i < ARRAY_LENGTH(m_mc6845_cursor); i++) m_mc6845_cursor[i] = 0; // prepare cursor by erasing old one - - r9 = m_mc6845_reg[9]; // number of scan lines - 1 - r10 = m_mc6845_reg[10] & 0x1f; // cursor start line = last 5 bits - r11 = m_mc6845_reg[11]+1; // cursor end line incremented to suit for-loops below - - /* decide the curs_type by examining the registers */ - if (r10 < r11) curs_type=1; // start less than end, show start to end - else - if (r10 == r11) curs_type=2; // if equal, show full cursor - else curs_type=3; // if start greater than end, it's a two-part cursor - - if ((r11 - 1) > r9) curs_type=2; // if end greater than scan-lines, show full cursor - if (r10 > r9) curs_type=0; // if start greater than scan-lines, then no cursor - if (r11 > 16) r11=16; // truncate 5-bit register to fit our 4-bit hardware - - /* create the new cursor */ - if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(m_mc6845_cursor);i++) m_mc6845_cursor[i]=0xff; // turn on full cursor - - if (curs_type == 1) for (i = r10;i < r11;i++) m_mc6845_cursor[i]=0xff; // for each line that should show, turn on that scan line - - if (curs_type == 3) for (i = r11; i < r10;i++) m_mc6845_cursor[i]=0; // now take a bite out of the middle -} - -/* Resize the screen within the limits of the hardware. Expand the image to fill the screen area. - Standard screen is 640 x 400 = 0x7d0 bytes. */ - -void kaypro_state::mc6845_screen_configure() -{ - UINT16 width = m_mc6845_reg[1]*8-1; // width in pixels - UINT16 height = m_mc6845_reg[6]*(m_mc6845_reg[9]+1)-1; // height in pixels - UINT16 bytes = m_mc6845_reg[1]*m_mc6845_reg[6]-1; // video ram needed -1 - - /* Resize the screen */ - if ((width < 640) && (height < 400) && (bytes < 0x800)) /* bounds checking to prevent an assert or violation */ - machine().first_screen()->set_visible_area(0, width, 0, height); -} - - -/**************************** I/O PORTS *****************************************************************/ - -READ8_MEMBER( kaypro_state::kaypro2x_status_r ) -{ -/* Need bit 7 high or computer hangs */ - - return 0x80 | m_crtc->register_r(space, 0); -} - -WRITE8_MEMBER( kaypro_state::kaypro2x_index_w ) -{ - m_mc6845_ind = data & 0x1f; - m_crtc->address_w( space, 0, data ); -} - -WRITE8_MEMBER( kaypro_state::kaypro2x_register_w ) -{ - static const UINT8 mcmask[32]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0}; - - if (m_mc6845_ind < 16) - m_mc6845_reg[m_mc6845_ind] = data & mcmask[m_mc6845_ind]; /* save data in register */ - else - m_mc6845_reg[m_mc6845_ind] = data; - - m_crtc->register_w( space, 0, data ); - - if ((m_mc6845_ind == 1) || (m_mc6845_ind == 6) || (m_mc6845_ind == 9)) - mc6845_screen_configure(); /* adjust screen size */ - - if ((m_mc6845_ind > 8) && (m_mc6845_ind < 12)) - mc6845_cursor_configure(); /* adjust cursor shape - remove when mame fixed */ - - if ((m_mc6845_ind > 17) && (m_mc6845_ind < 20)) - m_mc6845_video_address = m_mc6845_reg[19] | ((m_mc6845_reg[18] & 0x3f) << 8); /* internal ULA address */ -} - -READ8_MEMBER( kaypro_state::kaypro_videoram_r ) -{ - return m_p_videoram[offset]; -} - -WRITE8_MEMBER( kaypro_state::kaypro_videoram_w ) -{ - m_p_videoram[offset] = data; -} - -READ8_MEMBER( kaypro_state::kaypro2x_videoram_r ) -{ - return m_p_videoram[m_mc6845_video_address]; -} - -WRITE8_MEMBER( kaypro_state::kaypro2x_videoram_w ) -{ - m_p_videoram[m_mc6845_video_address] = data; -} - -VIDEO_START_MEMBER(kaypro_state,kaypro) -{ - m_p_chargen = memregion("chargen")->base(); - m_p_videoram = memregion("roms")->base()+0x3000; -} diff --git a/src/mess/video/kc.c b/src/mess/video/kc.c deleted file mode 100644 index 9a9dcbce29b..00000000000 --- a/src/mess/video/kc.c +++ /dev/null @@ -1,240 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker,Sandro Ronco -/*************************************************************************** - - kc.c - - Functions to emulate the video hardware of the kc85/4,kc85/3 - -***************************************************************************/ - -#include "emu.h" -#include "includes/kc.h" - -// 3 bit colour value. bit 2->green, bit 1->red, bit 0->blue -static const UINT8 kc85_palette[KC85_PALETTE_SIZE * 3] = -{ - // foreground colours, "full" of each component - 0x00, 0x00, 0x00, // black - 0x00, 0x00, 0xd0, // blue - 0xd0, 0x00, 0x00, // red - 0xd0, 0x00, 0xd0, // magenta - 0x00, 0xd0, 0x00, // green - 0x00, 0xd0, 0xd0, // cyan - 0xd0, 0xd0, 0x00, // yellow - 0xd0, 0xd0, 0xd0, // white - - // full of each component + half of another component - 0x00, 0x00, 0x00, // black - 0x60, 0x00, 0xa0, // violet - 0xa0, 0x60, 0x00, // brown - 0xa0, 0x00, 0x60, // red/purple - 0x00, 0xa0, 0x60, // pastel green - 0x00, 0x60, 0xa0, // sky blue - 0xa0, 0xa0, 0x60, // yellow/green - 0xd0, 0xd0, 0xd0, // white - - // background colours are slightly darker than foreground colours - 0x00, 0x00, 0x00, // black - 0x00, 0x00, 0xa0, // dark blue - 0xa0, 0x00, 0x00, // dark red - 0xa0, 0x00, 0xa0, // dark magenta - 0x00, 0xa0, 0x00, // dark green - 0x00, 0xa0, 0xa0, // dark cyan - 0xa0, 0xa0, 0x00, // dark yellow - 0xa0, 0xa0, 0xa0 // dark white (grey) -}; - - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(kc_state,kc85) -{ - for (int i = 0; i < sizeof(kc85_palette) / 3; i++ ) - palette.set_pen_color(i, kc85_palette[i*3], kc85_palette[i*3+1], kc85_palette[i*3+2]); -} - -/* set new blink state */ -WRITE_LINE_MEMBER( kc_state::video_toggle_blink_state ) -{ - if (state) - { - machine().first_screen()->update_partial(machine().first_screen()->vpos()); - - m_kc85_blink_state = !m_kc85_blink_state; - } -} - - -/* draw 8 pixels */ -void kc_state::video_draw_8_pixels(bitmap_ind16 &bitmap, int x, int y, UINT8 colour_byte, UINT8 gfx_byte) -{ - int pens[4]; - int px; - - if (m_high_resolution) - { - /* High resolution: 4 colors for block */ - - pens[0] = 0; // black - pens[1] = 2; // red - pens[2] = 5; // cyan - pens[3] = 7; // white - - px = x; - - for (int a=0; a<8; a++) - { - int pen = pens[((gfx_byte>>7) & 0x07) | ((colour_byte>>6) & 0x02)]; - - if ((px >= 0) && (px < bitmap.width()) && (y >= 0) && (y < bitmap.height())) - { - bitmap.pix16(y, px) = pen; - } - - px++; - colour_byte <<= 1; - gfx_byte <<= 1; - } - } - else - { - /* Low resolution: 2 colors for block */ - /* 16 foreground colours, 8 background colours */ - - /* bit 7 = 1: flash between foreground and background colour 0: no flash */ - /* bit 6: adjusts foreground colours by adding half of another component */ - /* bit 5,4,3 = foreground colour */ - /* bit 5: background colour -> Green */ - /* bit 4: background colour -> Red */ - /* bit 3: background colour -> Blue */ - /* bit 2,1,0 = background colour */ - /* bit 2: background colour -> Green */ - /* bit 1: background colour -> Red */ - /* bit 0: background colour -> Blue */ - - int background_pen = (colour_byte&7) + 16; - int foreground_pen = ((colour_byte>>3) & 0x0f); - - if ((colour_byte & 0x80) && m_kc85_blink_state && (m_pio_data[1] & 0x80)) - { - foreground_pen = background_pen; - } - - pens[0] = background_pen; - pens[1] = foreground_pen; - - px = x; - - for (int a=0; a<8; a++) - { - int pen = pens[(gfx_byte>>7) & 0x01]; - - if ((px >= 0) && (px < bitmap.width()) && (y >= 0) && (y < bitmap.height())) - { - bitmap.pix16(y, px) = pen; - } - px++; - gfx_byte = gfx_byte<<1; - } - } -} - - -/*************************************************************************** - KC85/4 video hardware -***************************************************************************/ - -void kc85_4_state::video_start() -{ - m_video_ram = machine().memory().region_alloc("videoram", (KC85_4_SCREEN_COLOUR_RAM_SIZE*2) + (KC85_4_SCREEN_PIXEL_RAM_SIZE*2), 1, ENDIANNESS_LITTLE)->base(); - memset(m_video_ram, 0, (KC85_4_SCREEN_COLOUR_RAM_SIZE*2) + (KC85_4_SCREEN_PIXEL_RAM_SIZE*2)); - m_display_video_ram = m_video_ram; - - m_kc85_blink_state = 0; -} - -void kc85_4_state::video_control_w(int data) -{ - /* calculate address of video ram to display */ - if (data & 1) - m_display_video_ram = m_video_ram + (KC85_4_SCREEN_PIXEL_RAM_SIZE + KC85_4_SCREEN_COLOUR_RAM_SIZE); - else - m_display_video_ram = m_video_ram; - - m_high_resolution = (data & 0x08) ? 0 : 1; -} - - -UINT32 kc85_4_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *pixel_ram = m_display_video_ram; - UINT8 *colour_ram = pixel_ram + 0x04000; - - for (int y=cliprect.min_y; y<=cliprect.max_y; y++) - { - for (int x=0; x<(KC85_SCREEN_WIDTH>>3); x++) - { - UINT16 offset = y | (x<<8); - - UINT8 colour_byte = colour_ram[offset]; - UINT8 gfx_byte = pixel_ram[offset]; - - video_draw_8_pixels(bitmap, (x<<3), y, colour_byte, gfx_byte); - } - } - - return 0; -} - -/*************************************************************************** - KC85/3 video -***************************************************************************/ - -void kc_state::video_start() -{ - m_video_ram = machine().memory().region_alloc("videoram", 0x4000, 1, ENDIANNESS_LITTLE)->base(); - memset(m_video_ram, 0, 0x4000); - - m_kc85_blink_state = 0; -} - -UINT32 kc_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - /* colour ram takes up 0x02800 bytes */ - UINT8 *pixel_ram = m_video_ram; - UINT8 *colour_ram = m_video_ram + 0x02800; - - for (int y=cliprect.min_y; y<=cliprect.max_y; y++) - { - for (int x=0; x<(KC85_SCREEN_WIDTH>>3); x++) - { - int pixel_offset,colour_offset; - - if ((x & 0x020)==0) - { - pixel_offset = (x & 0x01f) | (((y>>2) & 0x03)<<5) | - ((y & 0x03)<<7) | (((y>>4) & 0x0f)<<9); - - colour_offset = (x & 0x01f) | (((y>>2) & 0x03f)<<5); - } - else - { - /* 1 0 1 0 0 V7 V6 V1 V0 V3 V2 V5 V4 H2 H1 H0 */ - /* 1 0 1 1 0 0 0 V7 V6 V3 V2 V5 V4 H2 H1 H0 */ - - pixel_offset = 0x02000+((x & 0x07) | (((y>>4) & 0x03)<<3) | - (((y>>2) & 0x03)<<5) | ((y & 0x03)<<7) | ((y>>6) & 0x03)<<9); - - colour_offset = 0x0800+((x & 0x07) | (((y>>4) & 0x03)<<3) | - (((y>>2) & 0x03)<<5) | ((y>>6) & 0x03)<<7); - } - - UINT8 colour_byte = colour_ram[colour_offset]; - UINT8 gfx_byte = pixel_ram[pixel_offset]; - - video_draw_8_pixels(bitmap,(x<<3),y, colour_byte, gfx_byte); - } - } - - return 0; -} diff --git a/src/mess/video/kramermc.c b/src/mess/video/kramermc.c deleted file mode 100644 index a5609e8259f..00000000000 --- a/src/mess/video/kramermc.c +++ /dev/null @@ -1,46 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Kramer MC video driver by Miodrag Milanovic - - 13/09/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/kramermc.h" - -#define KRAMERMC_VIDEO_MEMORY 0xFC00 - -const gfx_layout kramermc_charlayout = -{ - 8, 8, /* 8x8 characters */ - 256, /* 256 characters */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {0, 1, 2, 3, 4, 5, 6, 7}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -void kramermc_state::video_start() -{ -} - -UINT32 kramermc_state::screen_update_kramermc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - address_space &space = m_maincpu->space(AS_PROGRAM); - - for(y = 0; y < 16; y++ ) - { - for(x = 0; x < 64; x++ ) - { - int code = space.read_byte(KRAMERMC_VIDEO_MEMORY + x + y*64); - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code , 0, 0,0, x*8,y*8); - } - } - return 0; -} diff --git a/src/mess/video/kyocera.c b/src/mess/video/kyocera.c deleted file mode 100644 index 34c3d60f95d..00000000000 --- a/src/mess/video/kyocera.c +++ /dev/null @@ -1,89 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/kyocera.h" - -PALETTE_INIT_MEMBER(kc85_state,kc85) -{ - palette.set_pen_color(0, rgb_t(138, 146, 148)); - palette.set_pen_color(1, rgb_t(92, 83, 88)); -} - -PALETTE_INIT_MEMBER(tandy200_state,tandy200) -{ - palette.set_pen_color(0, rgb_t(138, 146, 148)); - palette.set_pen_color(1, rgb_t(92, 83, 88)); -} - -UINT32 kc85_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_lcdc0->screen_update(screen, bitmap, cliprect); - m_lcdc1->screen_update(screen, bitmap, cliprect); - m_lcdc2->screen_update(screen, bitmap, cliprect); - m_lcdc3->screen_update(screen, bitmap, cliprect); - m_lcdc4->screen_update(screen, bitmap, cliprect); - m_lcdc5->screen_update(screen, bitmap, cliprect); - m_lcdc6->screen_update(screen, bitmap, cliprect); - m_lcdc7->screen_update(screen, bitmap, cliprect); - m_lcdc8->screen_update(screen, bitmap, cliprect); - m_lcdc9->screen_update(screen, bitmap, cliprect); - - return 0; -} - -UINT32 tandy200_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_lcdc->screen_update(screen, bitmap, cliprect); - - return 0; -} - -static ADDRESS_MAP_START( tandy200_lcdc, AS_0, 8, tandy200_state ) - ADDRESS_MAP_GLOBAL_MASK(0x1fff) - AM_RANGE(0x0000, 0x1fff) AM_RAM -ADDRESS_MAP_END - -MACHINE_CONFIG_FRAGMENT( kc85_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, LCD) - MCFG_SCREEN_REFRESH_RATE(44) - MCFG_SCREEN_UPDATE_DRIVER(kc85_state, screen_update) - MCFG_SCREEN_SIZE(240, 64) - MCFG_SCREEN_VISIBLE_AREA(0, 240-1, 0, 64-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_DEFAULT_LAYOUT(layout_lcd) - - MCFG_PALETTE_ADD("palette", 2) - MCFG_PALETTE_INIT_OWNER(kc85_state,kc85) - - MCFG_HD44102_ADD(HD44102_0_TAG, SCREEN_TAG, 0, 0) - MCFG_HD44102_ADD(HD44102_1_TAG, SCREEN_TAG, 50, 0) - MCFG_HD44102_ADD(HD44102_2_TAG, SCREEN_TAG, 100, 0) - MCFG_HD44102_ADD(HD44102_3_TAG, SCREEN_TAG, 150, 0) - MCFG_HD44102_ADD(HD44102_4_TAG, SCREEN_TAG, 200, 0) - MCFG_HD44102_ADD(HD44102_5_TAG, SCREEN_TAG, 0, 32) - MCFG_HD44102_ADD(HD44102_6_TAG, SCREEN_TAG, 50, 32) - MCFG_HD44102_ADD(HD44102_7_TAG, SCREEN_TAG, 100, 32) - MCFG_HD44102_ADD(HD44102_8_TAG, SCREEN_TAG, 150, 32) - MCFG_HD44102_ADD(HD44102_9_TAG, SCREEN_TAG, 200, 32) - -// MCFG_HD44103_MASTER_ADD("m11", SCREEN_TAG, CAP_P(18), RES_K(100), HD44103_FS_HIGH, HD44103_DUTY_1_32) -// MCFG_HD44103_SLAVE_ADD( "m12", "m11", SCREEN_TAG, HD44103_FS_HIGH, HD44103_DUTY_1_32) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( tandy200_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, LCD) - MCFG_SCREEN_REFRESH_RATE(80) - MCFG_SCREEN_UPDATE_DRIVER(tandy200_state, screen_update) - MCFG_SCREEN_SIZE(240, 128) - MCFG_SCREEN_VISIBLE_AREA(0, 240-1, 0, 128-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_DEFAULT_LAYOUT(layout_lcd) - - MCFG_PALETTE_ADD("palette", 2) - MCFG_PALETTE_INIT_OWNER(tandy200_state,tandy200) - - MCFG_DEVICE_ADD(HD61830_TAG, HD61830, XTAL_4_9152MHz/2/2) - MCFG_DEVICE_ADDRESS_MAP(AS_0, tandy200_lcdc) - MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) -MACHINE_CONFIG_END diff --git a/src/mess/video/llc.c b/src/mess/video/llc.c deleted file mode 100644 index dd9ba725500..00000000000 --- a/src/mess/video/llc.c +++ /dev/null @@ -1,96 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic, Robbbert -/*************************************************************************** - - LLC driver by Miodrag Milanovic - - 17/04/2009 Preliminary driver. - -****************************************************************************/ - - -#include "includes/llc.h" - - -void llc_state::video_start() -{ - m_p_chargen = memregion("chargen")->base(); -} - -UINT32 llc_state::screen_update_llc1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx,inv; - UINT16 sy=0,ma=0,x; - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 8; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x++) - { - inv = (m_p_videoram[x] & 0x80) ? 0xff : 0; - chr = m_p_videoram[x] & 0x7f; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[ chr | (ra << 7) ] ^ inv; - - /* Display a scanline of a character (8 pixels) */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=64; - } - return 0; -} - -UINT32 llc_state::screen_update_llc2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx,inv, inv1=m_rv ? 0xff : 0; - UINT16 sy=0,ma=0,x; - - for (y = 0; y < 32; y++) - { - for (ra = 0; ra < 8; ra++) - { - inv = 0; - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x++) - { - chr = m_p_videoram[x]; - if (chr==0x11) // inverse on - { - inv=0xff; - chr=0x0f; // must not show - } - else - if (chr==0x10) // inverse off - inv=0; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[ (chr << 3) | ra ] ^ inv ^ inv1; - - /* Display a scanline of a character (8 pixels) */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=64; - } - return 0; -} diff --git a/src/mess/video/lviv.c b/src/mess/video/lviv.c deleted file mode 100644 index affc58516f0..00000000000 --- a/src/mess/video/lviv.c +++ /dev/null @@ -1,91 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha -/*************************************************************************** - - lviv.c - - Functions to emulate the video hardware of PK-01 Lviv. - - Krzysztof Strzecha - -***************************************************************************/ - -#include "emu.h" -#include "includes/lviv.h" - -const unsigned char lviv_palette[8*3] = -{ - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xa4, - 0x00, 0xa4, 0x00, - 0x00, 0xa4, 0xa4, - 0xa4, 0x00, 0x00, - 0xa4, 0x00, 0xa4, - 0xa4, 0xa4, 0x00, - 0xa4, 0xa4, 0xa4 -}; - - -PALETTE_INIT_MEMBER(lviv_state, lviv) -{ - int i; - - for ( i = 0; i < sizeof(lviv_palette) / 3; i++ ) { - m_palette->set_pen_color(i, lviv_palette[i*3], lviv_palette[i*3+1], lviv_palette[i*3+2]); - } -} - - -void lviv_state::lviv_update_palette(UINT8 pal) -{ - m_colortable[0][0] = 0; - m_colortable[0][1] = 0; - m_colortable[0][2] = 0; - m_colortable[0][3] = 0; - - m_colortable[0][0] |= (((pal>>3)&0x01) == ((pal>>4)&0x01)) ? 0x04 : 0x00; - m_colortable[0][0] |= ((pal>>5)&0x01) ? 0x02 : 0x00; - m_colortable[0][0] |= (((pal>>2)&0x01) == ((pal>>6)&0x01)) ? 0x01 : 0x00; - - m_colortable[0][1] |= ((pal&0x01) == ((pal>>4)&0x01)) ? 0x04 : 0x00; - m_colortable[0][1] |= ((pal>>5)&0x01) ? 0x02 : 0x00; - m_colortable[0][1] |= ((pal>>6)&0x01) ? 0x00 : 0x01; - - m_colortable[0][2] |= ((pal>>4)&0x01) ? 0x04 : 0x00; - m_colortable[0][2] |= ((pal>>5)&0x01) ? 0x00 : 0x02; - m_colortable[0][2] |= ((pal>>6)&0x01) ? 0x01 : 0x00; - - m_colortable[0][3] |= ((pal>>4)&0x01) ? 0x00 : 0x04; - m_colortable[0][3] |= (((pal>>1)&0x01) == ((pal>>5)&0x01)) ? 0x02 : 0x00; - m_colortable[0][3] |= ((pal>>6)&0x01) ? 0x01 : 0x00; -} - -void lviv_state::video_start() -{ -} - -UINT32 lviv_state::screen_update_lviv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - int pen; - UINT8 data; - - for (y=0; y<256; y++) - for (x=0; x<256; x+=4) - { - data = m_video_ram[y*64+x/4]; - - pen = m_colortable[0][((data & 0x08) >> 3) | ((data & 0x80) >> (3+3))]; - bitmap.pix16(y, x + 0) = pen; - - pen = m_colortable[0][((data & 0x04) >> 2) | ((data & 0x40) >> (2+3))]; - bitmap.pix16(y, x + 1) = pen; - - pen = m_colortable[0][((data & 0x02) >> 1) | ((data & 0x20) >> (1+3))]; - bitmap.pix16(y, x + 2) = pen; - - pen = m_colortable[0][((data & 0x01) >> 0) | ((data & 0x10) >> (0+3))]; - bitmap.pix16(y, x + 3) = pen; - } - return 0; -} diff --git a/src/mess/video/mac.c b/src/mess/video/mac.c deleted file mode 100644 index 289c62feb57..00000000000 --- a/src/mess/video/mac.c +++ /dev/null @@ -1,1257 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont -/*************************************************************************** - - video/mac.c - - Macintosh video hardware - - Emulates the video hardware for compact Macintosh series (original - Macintosh (128k, 512k, 512ke), Macintosh Plus, Macintosh SE, Macintosh - Classic) - - Also emulates on-board video for systems with the - RBV, V8, Eagle, Sonora, and DAFB chips. - - ---------------------------------------------------------------------- - Monitor sense codes - - Apple assigns 3 pins for monitor IDs. These allow 8 possible codes: - - 000 - color 2-Page Display (21") - 001 - monochrome Full Page display (15") - 010 - color 512x384 (12") - 011 - monochrome 2 Page display (21") - 100 - NTSC - 101 - color Full Page display (15") - 110 - High-Resolution Color (13" 640x480) or use "type 6" extended codes - 111 - No monitor connected or use "type 7" extended codes - - For extended codes, you drive one of the 3 pins at a time and read the 2 - undriven pins. See http://support.apple.com/kb/TA21618?viewlocale=en_US - for details. - -Extended codes: - - Sense 2 Low Sense 1 Low Sense 0 Low - 1 & 0 2 & 0 2 & 1 - -Multiple Scan 14" 00 00 11 -Multiple Scan 16" 00 10 11 -Multiple Scan 21" 10 00 11 -PAL Encoder 00 00 00 -NTSC Encoder 01 01 00 -VGA/Super VGA 01 01 11 -RGB 16" 10 11 01 -PAL Monitor 11 00 00 -RGB 19" 11 10 10 -Radius color TPD 11 00 01 (TPD = Two Page Display) -Radius mono TPD 11 01 00 -Apple TPD 11 01 01 -Apple color FPD 01 11 10 (FPD = Full Page Display) - -***************************************************************************/ - - -#include "emu.h" -#include "sound/asc.h" -#include "includes/mac.h" -#include "machine/ram.h" - -PALETTE_INIT_MEMBER(mac_state,mac) -{ - palette.set_pen_color(0, 0xff, 0xff, 0xff); - palette.set_pen_color(1, 0x00, 0x00, 0x00); -} - -// 4-level grayscale -PALETTE_INIT_MEMBER(mac_state,macgsc) -{ - palette.set_pen_color(0, 0xff, 0xff, 0xff); - palette.set_pen_color(1, 0x7f, 0x7f, 0x7f); - palette.set_pen_color(2, 0x3f, 0x3f, 0x3f); - palette.set_pen_color(3, 0x00, 0x00, 0x00); -} - -VIDEO_START_MEMBER(mac_state,mac) -{ -} - -#define MAC_MAIN_SCREEN_BUF_OFFSET 0x5900 -#define MAC_ALT_SCREEN_BUF_OFFSET 0xD900 - -UINT32 mac_state::screen_update_mac(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT32 video_base; - const UINT16 *video_ram; - UINT16 word; - UINT16 *line; - int y, x, b; - - video_base = m_ram->size() - (m_screen_buffer ? MAC_MAIN_SCREEN_BUF_OFFSET : MAC_ALT_SCREEN_BUF_OFFSET); - video_ram = (const UINT16 *) (m_ram->pointer() + video_base); - - for (y = 0; y < MAC_V_VIS; y++) - { - line = &bitmap.pix16(y); - - for (x = 0; x < MAC_H_VIS; x += 16) - { - word = *(video_ram++); - for (b = 0; b < 16; b++) - { - line[x + b] = (word >> (15 - b)) & 0x0001; - } - } - } - return 0; -} - -UINT32 mac_state::screen_update_macse30(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT32 video_base; - const UINT16 *video_ram; - UINT16 word; - UINT16 *line; - int y, x, b; - - video_base = m_screen_buffer ? 0x8000 : 0; - video_base += (MAC_H_VIS/8); - video_ram = (const UINT16 *) &m_vram[video_base/4]; - - for (y = 0; y < MAC_V_VIS; y++) - { - line = &bitmap.pix16(y); - - for (x = 0; x < MAC_H_VIS; x += 16) - { - word = video_ram[((y * MAC_H_VIS)/16) + ((x/16)^1)]; - for (b = 0; b < 16; b++) - { - line[x + b] = (word >> (15 - b)) & 0x0001; - } - } - } - return 0; -} - -UINT32 mac_state::screen_update_macprtb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - const UINT16 *video_ram; - UINT16 word; - UINT16 *line; - int y, x, b; - - video_ram = (const UINT16 *) m_vram16.target(); - - for (y = 0; y < 400; y++) - { - line = &bitmap.pix16(y); - - for (x = 0; x < 640; x += 16) - { - word = video_ram[((y * 640)/16) + ((x/16))]; - for (b = 0; b < 16; b++) - { - line[x + b] = (word >> (15 - b)) & 0x0001; - } - } - } - return 0; -} - -UINT32 mac_state::screen_update_macpb140(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - const UINT16 *video_ram; - UINT16 word; - UINT16 *line; - int y, x, b; - - video_ram = (const UINT16 *) m_vram.target(); - - for (y = 0; y < 400; y++) - { - line = &bitmap.pix16(y); - - for (x = 0; x < 640; x += 16) - { - word = video_ram[((y * 640)/16) + ((x/16)^1)]; - for (b = 0; b < 16; b++) - { - line[x + b] = (word >> (15 - b)) & 0x0001; - } - } - } - return 0; -} - -UINT32 mac_state::screen_update_macpb160(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT16 *line; - int y, x; - UINT8 pixels; - UINT8 *vram8 = (UINT8 *)m_vram.target(); - - for (y = 0; y < 400; y++) - { - line = &bitmap.pix16(y); - - for (x = 0; x < 640/4; x++) - { - pixels = vram8[(y * 160) + (BYTE4_XOR_BE(x))]; - - *line++ = ((pixels>>6)&3); - *line++ = ((pixels>>4)&3); - *line++ = ((pixels>>2)&3); - *line++ = (pixels&3); - - } - } - return 0; -} - -// IIci/IIsi RAM-Based Video (RBV) and children: V8, Eagle, Spice, VASP, Sonora - -VIDEO_START_MEMBER(mac_state,macrbv) -{ -} - -VIDEO_RESET_MEMBER(mac_state,maceagle) -{ - m_rbv_montype = 32; - m_rbv_palette[0xfe] = 0xffffff; - m_rbv_palette[0xff] = 0; -} - -VIDEO_RESET_MEMBER(mac_state,macrbv) -{ - rectangle visarea; - int htotal, vtotal; - double framerate; - int view; - - memset(m_rbv_regs, 0, sizeof(m_rbv_regs)); - - m_rbv_count = 0; - m_rbv_clutoffs = 0; - m_rbv_immed10wr = 0; - - m_rbv_regs[2] = 0x7f; - m_rbv_regs[3] = 0; - - m_rbv_type = RBV_TYPE_RBV; - - visarea.min_x = 0; - visarea.min_y = 0; - view = 0; - if (m_montype) - { - m_rbv_montype = m_montype->read(); - } - else - { - m_rbv_montype = 2; - } - switch (m_rbv_montype) - { - case 1: // 15" portrait display - visarea.max_x = 640-1; - visarea.max_y = 870-1; - htotal = 832; - vtotal = 918; - framerate = 75.0; - view = 1; - break; - - case 2: // 12" RGB - visarea.max_x = 512-1; - visarea.max_y = 384-1; - htotal = 640; - vtotal = 407; - framerate = 60.15; - break; - - case 6: // 13" RGB - default: - visarea.max_x = 640-1; - visarea.max_y = 480-1; - htotal = 800; - vtotal = 525; - framerate = 59.94; - break; - } - -// printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); - machine().first_screen()->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(framerate)); - render_target *target = machine().render().first_target(); - target->set_view(view); -} - -VIDEO_RESET_MEMBER(mac_state,macsonora) -{ - rectangle visarea; - int htotal, vtotal; - double framerate; - int view = 0; - - memset(m_rbv_regs, 0, sizeof(m_rbv_regs)); - - m_rbv_count = 0; - m_rbv_clutoffs = 0; - m_rbv_immed10wr = 0; - - m_rbv_regs[2] = 0x7f; - m_rbv_regs[3] = 0; - - m_rbv_type = RBV_TYPE_SONORA; - - visarea.min_x = 0; - visarea.min_y = 0; - - m_rbv_montype = m_montype ? m_montype->read() : 2; - switch (m_rbv_montype) - { - case 1: // 15" portrait display - visarea.max_x = 640-1; - visarea.max_y = 870-1; - htotal = 832; - vtotal = 918; - framerate = 75.0; - view = 1; - break; - - case 2: // 12" RGB - visarea.max_x = 512-1; - visarea.max_y = 384-1; - htotal = 640; - vtotal = 407; - framerate = 60.15; - break; - - case 6: // 13" RGB - default: - visarea.max_x = 640-1; - visarea.max_y = 480-1; - htotal = 800; - vtotal = 525; - framerate = 59.94; - break; - } - -// printf("Sonora reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate); - machine().first_screen()->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(framerate)); - render_target *target = machine().render().first_target(); - target->set_view(view); -} - -VIDEO_START_MEMBER(mac_state,macsonora) -{ - memset(m_rbv_regs, 0, sizeof(m_rbv_regs)); - - m_rbv_count = 0; - m_rbv_clutoffs = 0; - m_rbv_immed10wr = 0; - - m_rbv_regs[2] = 0x7f; - m_rbv_regs[3] = 0; - m_rbv_regs[4] = 0x6; - m_rbv_regs[5] = 0x3; - - m_sonora_vctl[0] = 0x9f; - m_sonora_vctl[1] = 0; - m_sonora_vctl[2] = 0; - - m_rbv_type = RBV_TYPE_SONORA; -} - -VIDEO_START_MEMBER(mac_state,macv8) -{ - memset(m_rbv_regs, 0, sizeof(m_rbv_regs)); - - m_rbv_count = 0; - m_rbv_clutoffs = 0; - m_rbv_immed10wr = 0; - - m_rbv_regs[0] = 0x4f; - m_rbv_regs[1] = 0x06; - m_rbv_regs[2] = 0x7f; - - m_rbv_type = RBV_TYPE_V8; -} - -UINT32 mac_state::screen_update_macrbv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT32 *scanline; - int x, y, hres, vres; - UINT8 *vram8 = (UINT8 *)m_ram->pointer(); - - switch (m_rbv_montype) - { - case 32: // classic II built-in display - hres = MAC_H_VIS; - vres = MAC_V_VIS; - vram8 += 0x1f9a80; // Classic II apparently doesn't use VRAM? - break; - - case 1: // 15" portrait display - hres = 640; - vres = 870; - break; - - case 2: // 12" RGB - hres = 512; - vres = 384; - break; - - case 6: // 13" RGB - default: - hres = 640; - vres = 480; - break; - } - - switch (m_rbv_regs[0x10] & 7) - { - case 0: // 1bpp - { - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres; x+=8) - { - pixels = vram8[(y * (hres/8)) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[0xfe|(pixels>>7)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>6)&1)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>5)&1)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>4)&1)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>3)&1)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>2)&1)]; - *scanline++ = m_rbv_palette[0xfe|((pixels>>1)&1)]; - *scanline++ = m_rbv_palette[0xfe|(pixels&1)]; - } - } - } - break; - - case 1: // 2bpp - { - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres/4; x++) - { - pixels = vram8[(y * (hres/4)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0xfc|((pixels>>6)&3)]; - *scanline++ = m_rbv_palette[0xfc|((pixels>>4)&3)]; - *scanline++ = m_rbv_palette[0xfc|((pixels>>2)&3)]; - *scanline++ = m_rbv_palette[0xfc|(pixels&3)]; - } - } - } - break; - - case 2: // 4bpp - { - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres/2; x++) - { - pixels = vram8[(y * (hres/2)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0xf0|(pixels>>4)]; - *scanline++ = m_rbv_palette[0xf0|(pixels&0xf)]; - } - } - } - break; - - case 3: // 8bpp - { - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres; x++) - { - pixels = vram8[(y * hres) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - } - - return 0; -} - -UINT32 mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT32 *scanline; - int x, y, hres, vres; - - switch (m_rbv_montype) - { - case 1: // 15" portrait display - hres = 640; - vres = 870; - break; - - case 2: // 12" RGB - hres = 512; - vres = 384; - break; - - case 6: // 13" RGB - default: - hres = 640; - vres = 480; - break; - } - - switch (m_rbv_regs[0x10] & 7) - { - case 0: // 1bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres; x+=8) - { - pixels = vram8[(y * 0x400) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; - } - } - } - break; - - case 1: // 2bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres/4; x++) - { - pixels = vram8[(y * (hres/4)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0xfc|((pixels>>6)&3)]; - *scanline++ = m_rbv_palette[0xfc|((pixels>>4)&3)]; - *scanline++ = m_rbv_palette[0xfc|((pixels>>2)&3)]; - *scanline++ = m_rbv_palette[0xfc|(pixels&3)]; - } - } - } - break; - - case 2: // 4bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres/2; x++) - { - pixels = vram8[(y * (hres/2)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0xf0|(pixels>>4)]; - *scanline++ = m_rbv_palette[0xf0|(pixels&0xf)]; - } - } - } - break; - - case 3: // 8bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres; x++) - { - pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - } - - return 0; -} - -UINT32 mac_state::screen_update_macv8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT32 *scanline; - int x, y, hres, vres; - - switch (m_rbv_montype) - { - case 1: // 15" portrait display - hres = 640; - vres = 870; - break; - - case 2: // 12" RGB - hres = 512; - vres = 384; - break; - - case 6: // 13" RGB - default: - hres = 640; - vres = 480; - break; - } - - switch (m_rbv_regs[0x10] & 7) - { - case 0: // 1bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres; x+=8) - { - pixels = vram8[(y * 1024) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; - } - } - } - break; - - case 1: // 2bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres/4; x++) - { - pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0x3f|(pixels&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<2)&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<4)&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<6)&0xc0)]; - } - } - } - break; - - case 2: // 4bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres/2; x++) - { - pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[(pixels&0xf0) | 0xf]; - *scanline++ = m_rbv_palette[((pixels&0x0f)<<4) | 0xf]; - } - } - } - break; - - case 3: // 8bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres; x++) - { - pixels = vram8[(y * 1024) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - break; - } - - return 0; -} - -UINT32 mac_state::screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT32 *scanline; - int x, y, hres, vres, stride; - - switch (m_rbv_montype) - { - case 1: // 15" portrait display - stride = hres = 640; - vres = 870; - break; - - case 2: // 12" RGB - stride = hres = 512; - vres = 384; - break; - - case 6: // 13" RGB - default: - stride = hres = 640; - vres = 480; - break; - } - - // forced blank? - if (m_sonora_vctl[0] & 0x80) - { - return 0; - } - - switch (m_sonora_vctl[1] & 7) - { - case 0: // 1bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres; x+=8) - { - pixels = vram8[(y * (stride/8)) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[0x7f|(pixels&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<2)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<3)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<4)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<5)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<6)&0x80)]; - *scanline++ = m_rbv_palette[0x7f|((pixels<<7)&0x80)]; - } - } - } - break; - - case 1: // 2bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < hres/4; x++) - { - pixels = vram8[(y * (stride/4)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[0x3f|(pixels&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<2)&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<4)&0xc0)]; - *scanline++ = m_rbv_palette[0x3f|((pixels<<6)&0xc0)]; - } - } - } - break; - - case 2: // 4bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres/2; x++) - { - pixels = vram8[(y * (stride/2)) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[(pixels&0xf0) | 0xf]; - *scanline++ = m_rbv_palette[((pixels&0x0f)<<4) | 0xf]; - } - } - } - break; - - case 3: // 8bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres; x++) - { - pixels = vram8[(y * stride) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - break; - - case 4: // 16bpp - { - UINT16 *vram16 = (UINT16 *)m_vram.target(); - UINT16 pixels; - - for (y = 0; y < vres; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < hres; x++) - { - pixels = vram16[(y * stride) + (x^1)]; - *scanline++ = rgb_t(((pixels>>10) & 0x1f)<<3, ((pixels>>5) & 0x1f)<<3, (pixels & 0x1f)<<3); - } - } - } - break; - } - - return 0; -} - -// DAFB: video for Quadra 700/900 - -void mac_state::dafb_recalc_ints() -{ - if (m_dafb_int_status != 0) - { - nubus_slot_interrupt(0xf, ASSERT_LINE); - } - else - { - nubus_slot_interrupt(0xf, CLEAR_LINE); - } -} - -TIMER_CALLBACK_MEMBER(mac_state::dafb_vbl_tick) -{ - m_dafb_int_status |= 1; - dafb_recalc_ints(); - - m_vbl_timer->adjust(m_screen->time_until_pos(480, 0), 0); -} - -TIMER_CALLBACK_MEMBER(mac_state::dafb_cursor_tick) -{ - m_dafb_int_status |= 4; - dafb_recalc_ints(); - - m_cursor_timer->adjust(m_screen->time_until_pos(m_cursor_line, 0), 0); -} - -VIDEO_START_MEMBER(mac_state,macdafb) -{ - m_vbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::dafb_vbl_tick),this)); - m_cursor_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::dafb_cursor_tick),this)); - - m_vbl_timer->adjust(attotime::never); - m_cursor_timer->adjust(attotime::never); -} - -VIDEO_RESET_MEMBER(mac_state,macdafb) -{ - m_rbv_count = 0; - m_rbv_clutoffs = 0; - m_rbv_montype = 6; - m_rbv_vbltime = 0; - m_dafb_int_status = 0; - m_rbv_type = RBV_TYPE_DAFB; - m_dafb_mode = 0; - m_dafb_base = 0x1000; - m_dafb_stride = 256*4; - - memset(m_rbv_palette, 0, sizeof(m_rbv_palette)); -} - -READ32_MEMBER(mac_state::dafb_r) -{ -// if (offset != 0x108/4) printf("DAFB: Read @ %x (mask %x PC=%x)\n", offset*4, mem_mask, m_maincpu->pc()); - - switch (offset<<2) - { - case 0x1c: // inverse of monitor sense - return 7; // 21" color 2-page - - case 0x24: // SCSI 539x #1 status - return m_dafb_scsi1_drq<<9; - - case 0x28: // SCSI 539x #2 status - return m_dafb_scsi2_drq<<9; - - case 0x108: // IRQ/VBL status - return m_dafb_int_status; - - case 0x10c: // clear cursor scanline int - m_dafb_int_status &= ~4; - dafb_recalc_ints(); - break; - - case 0x114: // clear VBL int - m_dafb_int_status &= ~1; - dafb_recalc_ints(); - break; - } - return 0; -} - -WRITE32_MEMBER(mac_state::dafb_w) -{ -// if (offset != 0x10c/4) printf("DAFB: Write %08x @ %x (mask %x PC=%x)\n", data, offset*4, mem_mask, m_maincpu->pc()); - - switch (offset<<2) - { - case 0: // bits 20-9 of base - m_dafb_base &= 0x1ff; - m_dafb_base |= (data & 0xffff) << 9; -// printf("DAFB baseH: %x\n", m_dafb_base); - break; - - case 4: // bits 8-5 of base - m_dafb_base &= ~0x1ff; - m_dafb_base |= (data & 0xf) << 5; -// printf("DAFB baseL: %x\n", m_dafb_base); - break; - - case 8: - m_dafb_stride = data<<2; // stride in DWORDs -// printf("DAFB stride: %x %x\n", m_dafb_stride, data); - break; - - case 0x104: - if (data & 1) // VBL enable - { - m_vbl_timer->adjust(m_screen->time_until_pos(480, 0), 0); - } - else - { - m_vbl_timer->adjust(attotime::never); - m_dafb_int_status &= ~1; - dafb_recalc_ints(); - } - - if (data & 2) // aux scanline interrupt enable - { - fatalerror("DAFB: Aux scanline interrupt enable not supported!\n"); - } - - if (data & 4) // cursor scanline interrupt enable - { - m_cursor_timer->adjust(m_screen->time_until_pos(m_cursor_line, 0), 0); - } - else - { - m_cursor_timer->adjust(attotime::never); - m_dafb_int_status &= ~4; - dafb_recalc_ints(); - } - break; - - case 0x10c: // clear cursor scanline int - m_dafb_int_status &= ~4; - dafb_recalc_ints(); - break; - - case 0x114: // clear VBL int - m_dafb_int_status &= ~1; - dafb_recalc_ints(); - break; - } -} - -READ32_MEMBER(mac_state::dafb_dac_r) -{ -// printf("DAFB: Read DAC @ %x (mask %x PC=%x)\n", offset*4, mem_mask, m_maincpu->pc()); - - return 0; -} - -WRITE32_MEMBER(mac_state::dafb_dac_w) -{ -// if ((offset > 0) && (offset != 0x10/4)) printf("DAFB: Write %08x to DAC @ %x (mask %x PC=%x)\n", data, offset*4, mem_mask, m_maincpu->pc()); - - switch (offset<<2) - { - case 0: - m_rbv_clutoffs = data & 0xff; - m_rbv_count = 0; - break; - - case 0x10: - m_rbv_colors[m_rbv_count++] = data&0xff; - - if (m_rbv_count == 3) - { - m_palette->set_pen_color(m_rbv_clutoffs, rgb_t(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2])); - m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]); - m_rbv_clutoffs++; - m_rbv_count = 0; - } - break; - - case 0x20: - printf("%x to DAFB mode\n", data); - switch (data & 0x9f) - { - case 0x80: - m_dafb_mode = 0; // 1bpp - break; - - case 0x88: - m_dafb_mode = 1; // 2bpp - break; - - case 0x90: - m_dafb_mode = 2; // 4bpp - break; - - case 0x98: - m_dafb_mode = 3; // 8bpp - break; - - case 0x9c: - m_dafb_mode = 4; // 24bpp - break; - } - break; - } -} - -UINT32 mac_state::screen_update_macdafb(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT32 *scanline; - int x, y; - - switch (m_dafb_mode) - { - case 0: // 1bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - vram8 += m_dafb_base; - - for (y = 0; y < 870; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < 1152; x+=8) - { - pixels = vram8[(y * m_dafb_stride) + ((x/8)^3)]; - - *scanline++ = m_rbv_palette[(pixels>>7)&1]; - *scanline++ = m_rbv_palette[(pixels>>6)&1]; - *scanline++ = m_rbv_palette[(pixels>>5)&1]; - *scanline++ = m_rbv_palette[(pixels>>4)&1]; - *scanline++ = m_rbv_palette[(pixels>>3)&1]; - *scanline++ = m_rbv_palette[(pixels>>2)&1]; - *scanline++ = m_rbv_palette[(pixels>>1)&1]; - *scanline++ = m_rbv_palette[(pixels&1)]; - } - } - } - break; - - case 1: // 2bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - vram8 += m_dafb_base; - - for (y = 0; y < 870; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < 1152/4; x++) - { - pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[((pixels>>6)&3)]; - *scanline++ = m_rbv_palette[((pixels>>4)&3)]; - *scanline++ = m_rbv_palette[((pixels>>2)&3)]; - *scanline++ = m_rbv_palette[(pixels&3)]; - } - } - } - break; - - case 2: // 4bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - vram8 += m_dafb_base; - - for (y = 0; y < 870; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < 1152/2; x++) - { - pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))]; - - *scanline++ = m_rbv_palette[(pixels>>4)]; - *scanline++ = m_rbv_palette[(pixels&0xf)]; - } - } - } - break; - - case 3: // 8bpp - { - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - vram8 += m_dafb_base; - - for (y = 0; y < 870; y++) - { - scanline = &bitmap.pix32(y); - - for (x = 0; x < 1152; x++) - { - pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - } - break; - - case 4: // 24 bpp - for (y = 0; y < 480; y++) - { - UINT32 *base; - - scanline = &bitmap.pix32(y); - base = (UINT32 *)&m_vram[(y * (m_dafb_stride/4)) + (m_dafb_base/4)]; - for (x = 0; x < 640; x++) - { - *scanline++ = *base++; - } - } - break; - } - - return 0; -} - -UINT32 mac_state::screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)/* Color PowerBooks using an off-the-shelf WD video chipset */ -{ - UINT32 *scanline; - int x, y; - UINT8 *vram8 = (UINT8 *)m_vram.target(); - UINT8 pixels; - -// vram8 += 0x40000; - - for (y = 0; y < 480; y++) - { - scanline = &bitmap.pix32(y); - for (x = 0; x < 640; x++) - { - pixels = vram8[(y * 640) + (BYTE4_XOR_BE(x))]; - *scanline++ = m_rbv_palette[pixels]; - } - } - - return 0; -} - -READ32_MEMBER(mac_state::macwd_r) -{ - switch (offset) - { - case 0xf6: - if (m_screen->vblank()) - { - return 0xffffffff; - } - else - { - return 0; - } - - default: -// printf("macwd_r: @ %x, mask %08x (PC=%x)\n", offset, mem_mask, m_maincpu->pc()); - break; - } - return 0; -} - -WRITE32_MEMBER(mac_state::macwd_w) -{ - switch (offset) - { - case 0xf2: - if (mem_mask == 0xff000000) // DAC control - { - m_rbv_clutoffs = data>>24; - m_rbv_count = 0; - } - else if (mem_mask == 0x00ff0000) // DAC data - { - m_rbv_colors[m_rbv_count++] = (data>>16)&0xff; - if (m_rbv_count == 3) - { -// printf("RAMDAC: color %d = %02x %02x %02x\n", m_rbv_clutoffs, m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]); - m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]); - m_rbv_clutoffs++; - m_rbv_count = 0; - } - } - else - { - printf("macwd: Unknown DAC write, data %08x, mask %08x\n", data, mem_mask); - } - break; - - default: -// printf("macwd_w: %x @ %x, mask %08x (PC=%x)\n", data, offset, mem_mask, m_maincpu->pc()); - break; - } -} diff --git a/src/mess/video/maria.c b/src/mess/video/maria.c deleted file mode 100644 index b2514770e82..00000000000 --- a/src/mess/video/maria.c +++ /dev/null @@ -1,484 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Dan Boris, Fabio Priuli, Mike Saarna, Robert Tuccitto -/*************************************************************************** - - Atari MARIA video emulation - - - - some history: - 2014-12-01 Mike Saarna, Robert Tuccitto Implemented "colorburst kill" bit - of the MARIA CTRL register. - 2014-10-05 Mike Saarna, Robert Tuccitto Last Line DMA value corrected - to 6. GCC and Atari docs both show a difference between - Other Line and Last Line as +6 at the lowest part of the - range. - Blank scanlines are drawn when DMA is off, like real - hardware. - If MARIA hits the DMA limit, the CPU doesn't run until - the next scanline. - - 2014-09-03 Mike Saarna, Robert Tuccitto reorganized DMA penalties to - support new rendering timeout code. - - 2014-08-29 Mike Saarna Timeout rendering added. - - 2014-08-26 Fabio Priuli Converted to device - - 2014-05-06 Mike Saarna Added interrupts to DMA cycle eating. Updates to - LL, OL, and spin accounting for HALT behavior. - - 2014-03-24 Mike Saarna Fixed DMA regarding startup, shutdown and - cycle stealing. - - 2013-05-08 huygens rewrite to emulate line ram buffers (mostly fixes Kung-Fu Master - Started DMA cycle stealing implementation - - 2003-06-23 ericball Kangaroo mode & 320 mode & other stuff - - 2002-05-14 kubecj vblank dma stop fix - - 2002-05-13 kubecj fixed 320C mode (displayed 2 pixels instead of one!) - noticed that Jinks uses 0x02-320D mode - implemented the mode - completely unsure if good! - implemented some Maria CTRL variables - - 2002-05-12 kubecj added cases for 0x01-160A, 0x05-160B as stated by docs - -***************************************************************************/ - -#include "emu.h" -#include "maria.h" - - -#define TRIGGER_HSYNC 64717 - -#define READ_MEM(x) space.read_byte(x) - -const device_type ATARI_MARIA = &device_creator; - - - -atari_maria_device::atari_maria_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ATARI_MARIA, "Atari MARIA", tag, owner, clock, "atari_maria", __FILE__) -{ -} - - -void atari_maria_device::device_start() -{ - m_cpu = machine().device(m_cpu_tag); - m_screen = machine().first_screen(); - m_screen->register_screen_bitmap(m_bitmap); - - save_item(NAME(m_maria_palette)); - save_item(NAME(m_line_ram)); - save_item(NAME(m_active_buffer)); - save_item(NAME(m_write_mode)); - save_item(NAME(m_dll)); - save_item(NAME(m_dl)); - save_item(NAME(m_holey)); - save_item(NAME(m_offset)); - save_item(NAME(m_vblank)); - save_item(NAME(m_dmaon)); - save_item(NAME(m_dpp)); - save_item(NAME(m_wsync)); - save_item(NAME(m_color_kill)); - save_item(NAME(m_cwidth)); - save_item(NAME(m_bcntl)); - save_item(NAME(m_kangaroo)); - save_item(NAME(m_rm)); - save_item(NAME(m_nmi)); - save_item(NAME(m_charbase)); -} - -void atari_maria_device::device_reset() -{ - for (int i = 0; i < 32; i++) - m_maria_palette[i] = 0; - - for (int i = 0; i < 2; i++) - for (int j = 0; j < 160; j++) - m_line_ram[i][j] = 0; - - m_active_buffer = 0; - - m_write_mode = 0; - m_dmaon = 0; - m_vblank = 0x80; - m_dll = 0; - m_wsync = 0; - - m_color_kill = 0; - m_cwidth = 0; - m_bcntl = 0; - m_kangaroo = 0; - m_rm = 0; - - m_dl = 0; - m_holey = 0; - m_offset = 0; - m_dpp = 0; - m_nmi = 0; - m_charbase = 0; -} - -/*************************************************************************** - - Stop the video hardware emulation. - -***************************************************************************/ - -int atari_maria_device::is_holey(unsigned int addr) -{ - if (((m_holey & 0x02) && ((addr & 0x9000) == 0x9000)) || ( (m_holey & 0x01) && ((addr & 0x8800) == 0x8800))) - return 1; - else - return 0; -} - -int atari_maria_device::write_line_ram(int addr, UINT8 offset, int pal) -{ - address_space& space = m_cpu->space(AS_PROGRAM); - int c; - - int data = READ_MEM(addr); - pal <<= 2; - - if (m_write_mode) - { - c = (pal & 0x10) | (data & 0x0c) | (data >> 6); // P2 D3 D2 D7 D6 - if (((c & 3) || m_kangaroo) && (offset < 160)) - m_line_ram[m_active_buffer][offset] = c; - offset++; - - c = (pal & 0x10) | ((data & 0x03) << 2) | ((data & 0x30) >> 4); // P2 D1 D0 D5 D4 - if (((c & 3) || m_kangaroo) && (offset < 160)) - m_line_ram[m_active_buffer][offset] = c; - } - else - { - for (int i = 0; i < 4; i++, offset++) - { - c = pal | ((data >> (6 - 2 * i)) & 0x03); - if (((c & 3) || m_kangaroo) && (offset < 160)) - m_line_ram[m_active_buffer][offset] = c; - } - } - return m_write_mode ? 2 : 4; -} - - -void atari_maria_device::draw_scanline() -{ - address_space& space = m_cpu->space(AS_PROGRAM); - UINT16 graph_adr, data_addr; - int width, pal, ind; - UINT8 hpos; - UINT16 dl; - int d, c, pixel_cell, cells; - int maria_cycles; - - cells = 0; - - if(m_dmaon) - { - // All lines in a zone have the same initial DMA startup time. We'll adjust - // cycles for the special last zone line later, as those penalties happen after - // MARIA is done rendering, or after its hit the maximum rendering time. - maria_cycles = 16; - - - /* Process this DLL entry */ - dl = m_dl; - - /* DMA */ - /* Step through DL's while we're within maximum rendering time. */ - /* max render time = ( scanline length - DMA start ) */ - /* 426 = ( 454 - 28 ) */ - - while (((READ_MEM(dl + 1) & 0x5f) != 0) && (maria_cycles<426)) - { - /* Extended header */ - if (!(READ_MEM(dl + 1) & 0x1f)) - { - graph_adr = (READ_MEM(dl + 2) << 8) | READ_MEM(dl); - width = ((READ_MEM(dl + 3) ^ 0xff) & 0x1f) + 1; - hpos = READ_MEM(dl + 4); - pal = READ_MEM(dl + 3) >> 5; - m_write_mode = (READ_MEM(dl + 1) & 0x80) >> 5; - ind = READ_MEM(dl + 1) & 0x20; - dl += 5; - maria_cycles += 10; - } - /* Normal header */ - else - { - graph_adr = (READ_MEM(dl + 2) << 8) | READ_MEM(dl); - width = ((READ_MEM(dl + 1) ^ 0xff) & 0x1f) + 1; - hpos = READ_MEM(dl + 3); - pal = READ_MEM(dl + 1) >> 5; - ind = 0x00; - dl += 4; - maria_cycles += 8; - } - - /*logerror("%x DL: ADR=%x width=%x hpos=%x pal=%x mode=%x ind=%x\n", m_screen->vpos(), graph_adr, width, hpos, pal, m_write_mode, ind);*/ - - for (int x = 0; x < width; x++) - { - if (maria_cycles >= 426) // ensure we haven't overrun the maximum render time - break; - - /* Do indirect mode */ - if (ind) - { - c = READ_MEM(graph_adr + x) & 0xff; - data_addr = (m_charbase | c) + (m_offset << 8); - if (is_holey(data_addr)) - continue; - - maria_cycles += 3; - if (m_cwidth) // two data bytes per map byte - { - cells = write_line_ram(data_addr, hpos, pal); - hpos += cells; - cells = write_line_ram(data_addr+1, hpos, pal); - hpos += cells; - maria_cycles += 6; - } - else - { - cells = write_line_ram(data_addr, hpos, pal); - hpos += cells; - maria_cycles += 3; - } - } - else // direct mode - { - data_addr = graph_adr + x + (m_offset << 8); - if (is_holey(data_addr)) - continue; - cells = write_line_ram(data_addr, hpos, pal); - hpos += cells; - maria_cycles += 3; - } - } - } - - // Last Line post-render DMA cycle penalties... - if (m_offset == 0) - { - maria_cycles += 6; // extra shutdown time - if (READ_MEM(m_dll + 3) & 0x80) - maria_cycles += 17; // interrupt overhead - } - - // If MARIA used up all of the DMA time then the CPU can't run until next line... - if (maria_cycles>=426) - { - m_cpu->spin_until_trigger(TRIGGER_HSYNC); - m_wsync = 1; - } - - // Spin the CPU for Maria DMA, if it's not already spinning for WSYNC. - // MARIA generates the 6502 clock by dividing its own clock by 4. It needs to HALT and unHALT - // the 6502 on ths same clock phase, so MARIA will wait until its clock divides evenly by 4. - // To spin until an even divisor, we just round-up any would-be truncations by adding 3. - if (!m_wsync) - m_cpu->spin_until_time(m_cpu->cycles_to_attotime((maria_cycles+3)/4)); - } - - // draw line buffer to screen - m_active_buffer = !m_active_buffer; // switch buffers - UINT16 *scanline; - scanline = &m_bitmap.pix16(m_screen->vpos()); - - - for (int i = 0; i < 160; i++) - { - switch (m_rm) - { - case 0x00: /* 160A, 160B */ - case 0x01: /* 160A, 160B */ - pixel_cell = m_line_ram[m_active_buffer][i]; - scanline[2 * i] = m_maria_palette[pixel_cell]; - scanline[2 * i + 1] = m_maria_palette[pixel_cell]; - break; - - case 0x02: /* 320B, 320D */ - pixel_cell = m_line_ram[m_active_buffer][i]; - d = (pixel_cell & 0x10) | (pixel_cell & 0x02) | ((pixel_cell >> 3) & 1); // b4 0 0 b1 b3 - scanline[2 * i] = m_maria_palette[d]; - d = (pixel_cell & 0x10) | ((pixel_cell << 1) & 0x02) | ((pixel_cell >> 2) & 1); // b4 0 0 b0 b2 - scanline[2 * i + 1] = m_maria_palette[d]; - break; - - case 0x03: /* 320A, 320C */ - pixel_cell = m_line_ram[m_active_buffer][i]; - d = (pixel_cell & 0x1c) | (pixel_cell & 0x02); // b4 b3 b2 b1 0 - scanline[2 * i] = m_maria_palette[d]; - d = (pixel_cell & 0x1c) | ((pixel_cell << 1) & 0x02); // b4 b3 b2 b0 0 - scanline[2 * i + 1] = m_maria_palette[d]; - break; - } - - if(m_color_kill) //remove color if there's no colorburst signal - { - scanline[2 * i] &= 0x0f; - scanline[2 * i + 1] &= 0x0f; - } - } - - for (int i = 0; i < 160; i++) // buffer automaticaly cleared once displayed - m_line_ram[m_active_buffer][i] = 0; -} - - -void atari_maria_device::interrupt(int lines) -{ - if (m_wsync) - { - machine().scheduler().trigger(TRIGGER_HSYNC); - m_wsync = 0; - } - - int frame_scanline = m_screen->vpos() % (lines + 1); - if (frame_scanline == 16) - m_vblank = 0x00; - - if (frame_scanline == (lines - 5)) - m_vblank = 0x80; -} - - -void atari_maria_device::startdma(int lines) -{ - address_space& space = m_cpu->space(AS_PROGRAM); - int maria_scanline = m_screen->vpos(); - int frame_scanline = maria_scanline % (lines + 1); - - if ((frame_scanline == 16) && m_dmaon) - { - /* end of vblank */ - m_dll = m_dpp; // currently only handle changes to dll during vblank - m_dl = (READ_MEM(m_dll + 1) << 8) | READ_MEM(m_dll+2); - m_offset = READ_MEM(m_dll) & 0x0f; - m_holey = (READ_MEM(m_dll) & 0x60) >> 5; - m_nmi = READ_MEM(m_dll) & 0x80; - /* logerror("DLL=%x\n",m_dll); */ - } - - if ((frame_scanline > 15) && (frame_scanline < (lines - 5))) - draw_scanline(); - - if ((frame_scanline > 16) && (frame_scanline < (lines - 5)) && m_dmaon) - { - if (m_offset == 0) - { - m_dll += 3; - m_dl = (READ_MEM(m_dll + 1) << 8) | READ_MEM(m_dll + 2); - m_offset = READ_MEM(m_dll) & 0x0f; - m_holey = (READ_MEM(m_dll) & 0x60) >> 5; - if (READ_MEM(m_dll & 0x10)) - logerror("dll bit 5 set!\n"); - m_nmi = READ_MEM(m_dll) & 0x80; - } - else - { - m_offset--; - } - } - - if (m_nmi) - { - m_cpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); - m_nmi = 0; - } -} - -/*************************************************************************** - - Refresh the video screen - -***************************************************************************/ - -/* This routine is called at the start of vblank to refresh the screen */ -UINT32 atari_maria_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} - - -READ8_MEMBER(atari_maria_device::read) -{ - switch (offset) - { - case 0x08: - return m_vblank; - - default: - logerror("undefined MARIA read %x\n",offset); - return 0x00; // don't know if this should be 0x00 or 0xff - } -} - -WRITE8_MEMBER(atari_maria_device::write) -{ - if ((offset & 3) != 0) - m_maria_palette[offset] = data; - - switch (offset) - { - case 0x00: - // all color ram addresses with 00 for their least significant bits point to the background color - for (int i = 0; i < 8; i++) - m_maria_palette[4 * i] = data; - break; - case 0x04: - m_cpu->spin_until_trigger(TRIGGER_HSYNC); - m_wsync = 1; - break; - case 0x0C: // DPPH - m_dpp = (m_dpp & 0x00ff) | (data << 8); - break; - case 0x10: // DPPL - m_dpp = (m_dpp & 0xff00) | data; - break; - case 0x14: - m_charbase = (data << 8); - break; - case 0x1C: - /*logerror("MARIA CTRL=%x\n",data);*/ - m_color_kill = data & 0x80; - switch ((data >> 5) & 3) - { - case 0x00: - case 01: - logerror("dma test mode, do not use.\n"); - break; - - case 0x02: - m_dmaon = 1; - break; - - case 0x03: - m_dmaon = 0; - break; - } - m_cwidth = data & 0x10; - m_bcntl = data & 0x08; // Currently unimplemented as we don't display the border - m_kangaroo = data & 0x04; - m_rm = data & 0x03; - - /*logerror( "MARIA CTRL: CK:%d DMA:%d CW:%d BC:%d KM:%d RM:%d\n", - m_color_kill ? 1 : 0, - (data & 0x60) >> 5, - m_cwidth ? 1 : 0, - m_bcntl ? 1 : 0, - m_kangaroo ? 1 : 0, - m_rm );*/ - - break; - } -} diff --git a/src/mess/video/maria.h b/src/mess/video/maria.h deleted file mode 100644 index 8e91354cb06..00000000000 --- a/src/mess/video/maria.h +++ /dev/null @@ -1,72 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Dan Boris -#ifndef __ATARI_MARIA__ -#define __ATARI_MARIA__ - -#include "emu.h" - -// ======================> atari_maria_device - -class atari_maria_device : public device_t -{ -public: - // construction/destruction - atari_maria_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - static void set_cpu_tag(device_t &device, const char *tag) { downcast(device).m_cpu_tag = tag; } - - void interrupt(int lines); - void startdma(int lines); - - DECLARE_READ8_MEMBER(read); - DECLARE_WRITE8_MEMBER(write); - - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - -private: - - int m_maria_palette[32]; - int m_line_ram[2][160]; - int m_active_buffer; - int m_write_mode; - unsigned int m_dll; - unsigned int m_dl; - int m_holey; - int m_offset; - int m_vblank; - int m_dmaon; - int m_dpp; - int m_wsync; - int m_color_kill; - int m_cwidth; - int m_bcntl; - int m_kangaroo; - int m_rm; - int m_nmi; - unsigned int m_charbase; - bitmap_ind16 m_bitmap; - - void draw_scanline(); - int is_holey(unsigned int addr); - int write_line_ram(int addr, UINT8 offset, int pal); - - const char *m_cpu_tag; - cpu_device *m_cpu; // CPU whose space(AS_PROGRAM) serves as DMA source - screen_device *m_screen; -}; - - -// device type definition -extern const device_type ATARI_MARIA; - - -#define MCFG_MARIA_DMACPU(_tag) \ - atari_maria_device::set_cpu_tag(*device, _tag); - - -#endif diff --git a/src/mess/video/mbc55x.c b/src/mess/video/mbc55x.c deleted file mode 100644 index d7fdc80d41c..00000000000 --- a/src/mess/video/mbc55x.c +++ /dev/null @@ -1,186 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Phill Harvey-Smith -/* - video/mbc55x.c - - Machine driver for the Sanyo MBC-550 and MBC-555. - - Phill Harvey-Smith - 2011-01-29. - -Taken from : http://www.seasip.info/VintagePC/sanyo.html - -Video Controller - -To a programmer, the MBC's video hardware appears as a 6845 chip and three bitmapped graphics planes. -The 6845 appears at I/O ports 30h (register select) and 32h (data). At system boot, it is programmed -for 25 lines x 72 columns. The RAM BIOS then reprograms it for 25 x 80. The ROM also provides timings -for what appears to be a different 80-column mode; it decides which to use by reading port 1Ch. -If bit 7 of the result is 1, the 72-column mode is used; otherwise, the 80-column mode is. - -Here are the values written to the 6845 in each case, plus (for comparison) the values used by a real CGA: - - 6845 Register | IO.SYS | ROM 80 | ROM 72 | Real CGA -=============================+========+========+========+========== - Horizontal total | 112 | 101 | 112 | 83 - Horizontal display end | 80 | 80 | 72 | 80 - Horizontal sync pos | 89 | 83 | 85 | 81 - Horizontal sync width | 72 | 72 | 74 | 1 - Vertical total | 65 | 105 | 65 | 26 - Vertical total adjust | 0 | 2 | 0 | 0 - Vertical displayed | 50 | 100 | 50 | 26 - Vertical sync position | 56 | 100 | 56 | 25 - Interlace | 0 | 0 | 0 | 2 - Max scan address | 3 | 3 | 3 | 7 - Cursor start | 0 | 0 | 0 | 6 - Cursor end | 0 | 0 | 0 | 7 -=============================+========+========+========+========== - -The important thing to note here is that from the 6845's point of view, a character is 4 lines high. -This explains why the framebuffer memory is mapped as it is. - -The framebuffers - -The MBC video RAM is composed of three planes - green, red and blue. The green plane occupies main memory, -and its position varies; writes to port 10h set its address: - -Value | Address -======+======== - 4 | 0C000h - 5 | 1C000h (other values have not been tested) - 6 | 2C000h - 7 | 3C000h -======+======== - -The red and blue planes appear to have fixed locations of F0000h and F4000h respectively. - -When output goes to a composite monitor, the green plane is usually used by itself. -The red plane becomes "blink", causing pixels in it to blink; and the blue plane becomes "bright". - -Within each plane, memory is organised as 50 rows of 320 bytes (288 bytes in 72-column mode). -This corresponds to a rectangle, 640 (576) pixels wide and four pixels high. The first four bytes -give the leftmost column of the rectangle, the next four give the next column, and so on: - -[--byte 0--] [--byte 4--] [--byte 8--] [--byte 12--] ... -[--byte 1--] [--byte 5--] [--byte 9--] [--byte 13--] ... -[--byte 2--] [--byte 6--] [--byte 10--] [--byte 14--] ... -[--byte 3--] [--byte 7--] [--byte 11--] [--byte 15--] ... - -*************************************************************************************************************/ - -#include "includes/mbc55x.h" - -#define DEBUG_LINES 1 -#define DEBUG_VSYNC 2 - -#define DEBUG_SET(flags) ((m_debug_video & (flags))==(flags)) - -static void video_debug(running_machine &machine, int ref, int params, const char *param[]) -{ - mbc55x_state *mstate = machine.driver_data(); - if(params>0) - { - int temp; - sscanf(param[0],"%d",&temp); mstate->m_debug_video = temp;; - } - else - { - debug_console_printf(machine,"Error usage : mbc55x_vid_debug \n"); - debug_console_printf(machine,"Current debuglevel=%02X\n",mstate->m_debug_video); - } -} - -MC6845_UPDATE_ROW( mbc55x_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - - UINT8 *ram = &m_ram->pointer()[0]; - UINT8 *red = &m_video_mem[RED_PLANE_OFFSET]; - UINT8 *blue = &m_video_mem[BLUE_PLANE_OFFSET]; - UINT8 *green; - int offset; - UINT8 rpx,gpx,bpx; - UINT8 rb,gb,bb; - - int x_pos; - int pixelno; - UINT8 bitno; - UINT8 shifts; - UINT8 colour; - - switch(m_vram_page) - { - case 4 : green=&ram[0x08000]; break; - case 5 : green=&ram[0x1C000]; break; - case 6 : green=&ram[0x2C000]; break; - case 7 : green=&ram[0x3C000]; break; - default : - green=&ram[0x0C000]; - } - - if(DEBUG_SET(DEBUG_LINES)) - logerror("MC6845_UPDATE_ROW: ma=%d, ra=%d, y=%d, x_count=%d\n",ma,ra,y,x_count); - - offset=((ma*4) + ra) % COLOUR_PLANE_SIZE; - - if(DEBUG_SET(DEBUG_LINES)) - logerror("offset=%05X\n",offset); - - for(x_pos=0; x_pos> shifts; - gb=(gpx & bitno) >> shifts; - bb=(bpx & bitno) >> shifts; - - colour=(rb<<2) | (gb<<1) | (bb<<0); - - bitmap.pix32(y, (x_pos*8)+pixelno)=palette[colour]; - //logerror("set pixel (%d,%d)=%d\n",y, ((x_pos*8)+pixelno),colour); - bitno=bitno>>1; - shifts--; - } - } -} - -WRITE_LINE_MEMBER( mbc55x_state::vid_hsync_changed ) -{ -} - -WRITE_LINE_MEMBER( mbc55x_state::vid_vsync_changed ) -{ -} - -void mbc55x_state::video_start() -{ - m_debug_video=0; - - logerror("video_start\n"); - - if (machine().debug_flags & DEBUG_FLAG_ENABLED) - { - debug_console_register_command(machine(), "mbc55x_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug); - } -} - -void mbc55x_state::video_reset() -{ - // When we reset clear the video registers and video memory. - memset(&m_video_mem,0,sizeof(m_video_mem)); - - logerror("Video reset\n"); -} - -void mbc55x_state::screen_eof_mbc55x(screen_device &screen, bool state) -{ -// logerror("screen_eof_mbc55x\n"); -} diff --git a/src/mess/video/mbee.c b/src/mess/video/mbee.c deleted file mode 100644 index ce55969f6a3..00000000000 --- a/src/mess/video/mbee.c +++ /dev/null @@ -1,495 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert -/*************************************************************************** - microbee.c - - video hardware - Originally written by Juergen Buchmueller, Dec 1999 - - Rewritten by Robbbert (see notes in driver file). - - Operation of old keyboard: - The design is taken from the SY6545 Application Note AN3. As the CRTC - renders the picture, the MA lines also scan the keyboard. When a keydown - is detected, the lightpen pin is activated, which sets bit 6 of the status - register. The CPU continuously monitors this register. Once bit 6 is set, - the CPU needs to determine which key is pressed. It firstly clears bit 6, - then sets port 0B to 1. This prevents the CRTC from scanning the keyboard - and causing interference. Next, the CPU writes an address to regs 18,19 and - then instigates the transparent access. This checks one keyboard row, which - if the pressed key is found, will once again set bit 6. If not found, the - next row will be checked. Once found, the CPU clears bit 6 and port 0B, then - works out the ascii key code of the pressed key. - - Tests of old keyboard. Start mbeeic. - 1. Load ASTEROIDS PLUS, stay in attract mode, hold down spacebar, - it should only fire bullets. If it sometimes starts turning, - thrusting or using the shield, then there is a problem. - - 2. Load SCAVENGER and make sure it doesn't go to the next level - until you find the Exit. - - 3. At the Basic prompt, type in EDASM press enter. At the memory size - prompt press enter. Now, make sure the keyboard works properly. - - Old keyboard ToDo: - - Occasional characters dropped while typing - - Lots of characters dropped when pasting - - On mbee128p, Simply Write doesn't accept any input - - New keyboard ToDo: - - On mbeett, various problems caused by phantom characters. - -****************************************************************************/ - - -#include "includes/mbee.h" - -WRITE_LINE_MEMBER( mbee_state::crtc_vs ) -{ - m_b7_vs = state; - if ((m_io_config->read() & 0xc0) == 0) // VS selected in config menu - m_pio->port_b_write(pio_port_b_r(generic_space(),0,0xff)); -} - -/*********************************************************** - - The 6845 can produce a variety of cursor shapes - all - are emulated here. - - Need to find out if the 6545 works the same way. - -************************************************************/ - -void mbee_state::sy6545_cursor_configure() -{ - UINT8 i,curs_type=0,r9,r10,r11; - - /* curs_type holds the general cursor shape to be created - 0 = no cursor - 1 = partial cursor (only shows on a block of scan lines) - 2 = full cursor - 3 = two-part cursor (has a part at the top and bottom with the middle blank) */ - - for ( i = 0; i < ARRAY_LENGTH(m_sy6545_cursor); i++) m_sy6545_cursor[i] = 0; // prepare cursor by erasing old one - - r9 = m_sy6545_reg[9]; // number of scan lines - 1 - r10 = m_sy6545_reg[10] & 0x1f; // cursor start line = last 5 bits - r11 = m_sy6545_reg[11]+1; // cursor end line incremented to suit for-loops below - - /* decide the curs_type by examining the registers */ - if (r10 < r11) curs_type=1; // start less than end, show start to end - else - if (r10 == r11) curs_type=2; // if equal, show full cursor - else curs_type=3; // if start greater than end, it's a two-part cursor - - if ((r11 - 1) > r9) curs_type=2; // if end greater than scan-lines, show full cursor - if (r10 > r9) curs_type=0; // if start greater than scan-lines, then no cursor - if (r11 > 16) r11=16; // truncate 5-bit register to fit our 4-bit hardware - - /* create the new cursor */ - if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(m_sy6545_cursor);i++) m_sy6545_cursor[i]=0xff; // turn on full cursor - - if (curs_type == 1) for (i = r10;i < r11;i++) m_sy6545_cursor[i]=0xff; // for each line that should show, turn on that scan line - - if (curs_type == 3) for (i = r11; i < r10;i++) m_sy6545_cursor[i]=0; // now take a bite out of the middle -} - - -/*********************************************************** - - Handlers of video, colour, and attribute RAM - -************************************************************/ - - -READ8_MEMBER( mbee_state::video_low_r ) -{ - if (m_is_premium && ((m_1c & 0x9f) == 0x90)) - return m_p_attribram[offset]; - else - if (m_0b) - return m_p_gfxram[offset]; - else - return m_p_videoram[offset]; -} - -WRITE8_MEMBER( mbee_state::video_low_w ) -{ - if BIT(m_1c, 4) - { - // non-premium attribute writes are discarded - if (m_is_premium && BIT(m_1c, 7)) - m_p_attribram[offset] = data; - } - else - m_p_videoram[offset] = data; -} - -READ8_MEMBER( mbee_state::video_high_r ) -{ - if BIT(m_08, 6) - return m_p_colorram[offset]; - else - return m_p_gfxram[(((m_1c & 15) + 1) << 11) | offset]; -} - -WRITE8_MEMBER( mbee_state::video_high_w ) -{ - if (BIT(m_08, 6) && (~m_0b & 1)) - m_p_colorram[offset] = data; - else - m_p_gfxram[(((m_1c & 15) + 1) << 11) | offset] = data; -} - -WRITE8_MEMBER( mbee_state::port0b_w ) -{ - m_0b = data & 1; -} - -READ8_MEMBER( mbee_state::port08_r ) -{ - return m_08; -} - -WRITE8_MEMBER( mbee_state::port08_w ) -{ - m_08 = data & 0x4e; -} - -READ8_MEMBER( mbee_state::port1c_r ) -{ - return m_1c; -} - -WRITE8_MEMBER( mbee_state::port1c_w ) -{ -/* d7 extended graphics (1=allow attributes and pcg banks) - d5 bankswitch basic rom - d4 select attribute ram - d3..d0 select m_videoram bank */ - - if (m_is_premium && BIT(data, 7)) - m_1c = data; - else - m_1c = data & 0x30; - - if (m_basic) - m_basic->set_entry(BIT(data, 5)); -} - - -/*********************************************************** - - CRTC-driven keyboard - -************************************************************/ - - -void mbee_state::oldkb_matrix_r(UINT16 offs) -{ - if (m_has_oldkb) - { - UINT8 port = (offs >> 7) & 7; - UINT8 bit = (offs >> 4) & 7; - UINT8 extra = 0; - UINT8 data = m_io_oldkb[port]->read(); - bool keydown = BIT(data, bit); - - // This adds premium-style cursor keys to the old keyboard. - // They are used by the pc85 menu. Premium keyboards already - // have these keys fitted. - if (!keydown && !m_is_premium) - { - if ((port == 0) || (port == 2) || (port == 3)) - extra = m_io_x7->read(); - else - if (port == 7) - extra = data; - - if (extra) - { - if BIT(extra, 0) // cursor up - { - if( port == 7 && bit == 1 ) keydown = 1; - if( port == 0 && bit == 5 ) keydown = 1; // control E - } - else - if BIT(extra, 2) // cursor down - { - if( port == 7 && bit == 1 ) keydown = 1; - if( port == 3 && bit == 0 ) keydown = 1; // control X - } - else - if BIT(extra, 3) // cursor left - { - if( port == 7 && bit == 1 ) keydown = 1; - if( port == 2 && bit == 3 ) keydown = 1; // control S - } - else - if BIT(extra, 6) // cursor right - { - if( port == 7 && bit == 1 ) keydown = 1; - if( port == 0 && bit == 4 ) keydown = 1; // control D - } - } - } - - if( keydown ) - m_crtc->assert_light_pen_input(); //lpen_strobe - } -} - - -void mbee_state::oldkb_scan( UINT16 param ) -{ - if (m_0b) return; // IC5 (pins 11,12,13) - if (param & 15) return; // only scan once per row instead of 16 times - oldkb_matrix_r(param); -} - - -/*********************************************************** - - CRTC registers - -************************************************************/ - -WRITE8_MEMBER ( mbee_state::m6545_index_w ) -{ - data &= 0x1f; - m_sy6545_ind = data; - m_crtc->address_w( space, 0, data ); -} - -WRITE8_MEMBER ( mbee_state::m6545_data_w ) -{ - static const UINT8 sy6545_mask[32]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0,0x3f,0xff}; - - switch( m_sy6545_ind ) - { - case 12: - data &= 0x3f; // select alternate character set - if( m_sy6545_reg[12] != data ) - memcpy(m_p_gfxram, memregion("gfx")->base() + (((data & 0x30) == 0x20) << 11), 0x800); - break; - } - m_sy6545_reg[m_sy6545_ind] = data & sy6545_mask[m_sy6545_ind]; /* save data in register */ - m_crtc->register_w( space, 0, data ); - if ((m_sy6545_ind > 8) && (m_sy6545_ind < 12)) sy6545_cursor_configure(); /* adjust cursor shape - remove when mame fixed */ -} - - - - -/*********************************************************** - - Video - -************************************************************/ - -VIDEO_START_MEMBER( mbee_state, mono ) -{ - m_p_videoram = memregion("videoram")->base(); - m_p_gfxram = memregion("gfx")->base()+0x1000; - m_p_colorram = 0; - m_p_attribram = 0; - m_is_premium = 0; -} - -VIDEO_START_MEMBER( mbee_state, standard ) -{ - m_p_videoram = memregion("videoram")->base(); - m_p_gfxram = memregion("gfx")->base()+0x1000; - m_p_colorram = memregion("colorram")->base(); - m_p_attribram = 0; - m_is_premium = 0; -} - -VIDEO_START_MEMBER( mbee_state, premium ) -{ - m_p_videoram = memregion("videoram")->base(); - m_p_colorram = memregion("colorram")->base(); - m_p_gfxram = memregion("gfx")->base()+0x1000; - m_p_attribram = memregion("attrib")->base(); - m_is_premium = 1; -} - -UINT32 mbee_state::screen_update_mbee(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - m_framecnt++; - m_crtc->screen_update(screen, bitmap, cliprect); - return 0; -} - - -MC6845_ON_UPDATE_ADDR_CHANGED( mbee_state::crtc_update_addr ) -{ -// parameters passed are device, address, strobe(always 0) -// not used on 256TC - - oldkb_matrix_r(address); -} - - -MC6845_UPDATE_ROW( mbee_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - - // colours - UINT8 colourm = (m_08 & 0x0e) >> 1; - UINT8 monopal = (m_io_config->read() & 0x30) >> 4; - // if colour chosen on mono bee, default to amber - if (!monopal && !m_p_colorram) - monopal = 2; - - UINT32 *p = &bitmap.pix32(y); - UINT8 inv, attr=0, gfx, fg=96+monopal, bg=96, col=0; - UINT16 mem, x, chr; - - for (x = 0; x < x_count; x++) // for each character - { - inv = 0; - mem = (ma + x) & 0x7ff; - chr = m_p_videoram[mem]; - - if BIT(m_1c, 7) // premium graphics enabled? - { - attr = m_p_attribram[mem]; - - if BIT(chr, 7) - chr += ((attr & 15) << 7); // bump chr to its particular pcg definition - - if BIT(attr, 6) - inv ^= 0xff; // inverse attribute - - if (BIT(attr, 7) & BIT(m_framecnt, 4)) // flashing attribute - chr = 0x20; - } - - oldkb_scan(x+ma); - - /* process cursor */ - if (x == cursor_x) - inv ^= m_sy6545_cursor[ra]; // cursor scan row - - /* get pattern of pixels for that character scanline */ - gfx = m_p_gfxram[(chr<<4) | ra] ^ inv; - - // get colours - if (!monopal) - { - col = m_p_colorram[mem]; // read a byte of colour - - if (m_is_premium) - { - fg = col & 15; - bg = col >> 4; - } - else - { - fg = (col & 0x1f) | 64; - bg = ((col & 0xe0) >> 2) | colourm; - } - } - - /* Display a scanline of a character (8 pixels) */ - *p++ = palette[BIT(gfx, 7) ? fg : bg]; - *p++ = palette[BIT(gfx, 6) ? fg : bg]; - *p++ = palette[BIT(gfx, 5) ? fg : bg]; - *p++ = palette[BIT(gfx, 4) ? fg : bg]; - *p++ = palette[BIT(gfx, 3) ? fg : bg]; - *p++ = palette[BIT(gfx, 2) ? fg : bg]; - *p++ = palette[BIT(gfx, 1) ? fg : bg]; - *p++ = palette[BIT(gfx, 0) ? fg : bg]; - } -} - - -/***************************************************************************************************** - - Palette - - Standard Palette: The 8 bits from the colour RAM are divided into 5 bits for foreground, and 3 - bits for background. The 5 foreground bits pass through a PAL, which has 6 outputs. A write to - port 8 produces 3 more background lines, giving 6 in total. These 12 lines travel to a pair of - 74LS157 switching chips, where the foreground or background lines are selected by the absence or - or presence of a pixel. The 6 chosen lines pass through a 7407 then are merged to the final 3 RGB - lines. Each pair is merged like this: - VCC --- 330 ohm --- primary colour line + out to monitor ---- 120 ohm --- secondary colour line - -*****************************************************************************************************/ - -PALETTE_INIT_MEMBER( mbee_state, standard ) -{ - const UINT8 *color_prom = memregion("proms")->base(); - UINT8 i=0, r, b, g, k, r1, g1, b1; - UINT8 bglevel[] = { 0, 0x54, 0xa0, 0xff }; - UINT8 fglevel[] = { 0, 0xa0, 0xff, 0xff }; - - // set up background colours (00-63) - for (b1 = 0; b1 < 4; b1++) - { - b = bglevel[b1]; - for (g1 = 0; g1 < 4; g1++) - { - g = bglevel[g1]; - for (r1 = 0; r1 < 4; r1++) - { - r = bglevel[r1]; - k = BITSWAP8(i, 7, 6, 5, 3, 1, 4, 2, 0); - palette.set_pen_color(k, rgb_t(r, g, b)); - i++; - } - } - } - - // set up foreground palette (64-95) by reading the prom - for (i = 0; i < 32; i++) - { - k = color_prom[i]; - r = fglevel[(BIT(k, 2))|(BIT(k, 5)<<1)]; - g = fglevel[(BIT(k, 1))|(BIT(k, 4)<<1)]; - b = fglevel[(BIT(k, 0))|(BIT(k, 3)<<1)]; - palette.set_pen_color(i|64, rgb_t(r, g, b)); - } - - // monochrome palette - palette.set_pen_color(96, rgb_t(0x00, 0x00, 0x00)); // black - palette.set_pen_color(97, rgb_t(0x00, 0xff, 0x00)); // green - palette.set_pen_color(98, rgb_t(0xf7, 0xaa, 0x00)); // amber - palette.set_pen_color(99, rgb_t(0xff, 0xff, 0xff)); // white -} - - -PALETTE_INIT_MEMBER( mbee_state, premium ) -{ - UINT8 i, r, b, g; - - /* set up 8 low intensity colours */ - for (i = 0; i < 7; i++) - { - r = BIT(i, 0) ? 0xc0 : 0; - g = BIT(i, 1) ? 0xc0 : 0; - b = BIT(i, 2) ? 0xc0 : 0; - palette.set_pen_color(i, rgb_t(r, g, b)); - } - - // colour 8 is dark grey, rather than black - palette.set_pen_color(8, rgb_t(96, 96, 96)); - - /* set up 8 high intensity colours */ - for (i = 9; i < 16; i++) - { - r = BIT(i, 0) ? 0xff : 0; - g = BIT(i, 1) ? 0xff : 0; - b = BIT(i, 2) ? 0xff : 0; - palette.set_pen_color(i, rgb_t(r, g, b)); - } - - // monochrome palette - palette.set_pen_color(96, rgb_t(0x00, 0x00, 0x00)); // black - palette.set_pen_color(97, rgb_t(0x00, 0xff, 0x00)); // green - palette.set_pen_color(98, rgb_t(0xf7, 0xaa, 0x00)); // amber - palette.set_pen_color(99, rgb_t(0xff, 0xff, 0xff)); // white -} diff --git a/src/mess/video/mc80.c b/src/mess/video/mc80.c deleted file mode 100644 index 66f05dd8576..00000000000 --- a/src/mess/video/mc80.c +++ /dev/null @@ -1,173 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - MC-80.xx video by Miodrag Milanovic - - 15/05/2009 Initial implementation - 12/05/2009 Skeleton driver. - -****************************************************************************/ - -#include "includes/mc80.h" - -// This is not a content of U402 510 -// but order is fine - -static const UINT8 prom[] = { - 0x0c,0x11,0x13,0x15,0x17,0x10,0x0e,0x00, // @ - 0x04,0x0a,0x11,0x11,0x1f,0x11,0x11,0x00, // A - 0x1e,0x11,0x11,0x1e,0x11,0x11,0x1e,0x00, // B - 0x0e,0x11,0x10,0x10,0x10,0x11,0x0e,0x00, // C - 0x1e,0x09,0x09,0x09,0x09,0x09,0x1e,0x00, // D - 0x1f,0x10,0x10,0x1e,0x10,0x10,0x1f,0x00, // E - 0x1f,0x10,0x10,0x1e,0x10,0x10,0x10,0x00, // F - 0x0e,0x11,0x10,0x10,0x13,0x11,0x0f,0x00, // G - - 0x11,0x11,0x11,0x1f,0x11,0x11,0x11,0x00, // H - 0x0e,0x04,0x04,0x04,0x04,0x04,0x0e,0x00, // I - 0x01,0x01,0x01,0x01,0x11,0x11,0x0e,0x00, // J - 0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00, // K - 0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0x00, // L - 0x11,0x1b,0x15,0x15,0x11,0x11,0x11,0x00, // M - 0x11,0x11,0x19,0x15,0x13,0x11,0x11,0x00, // N - 0x0e,0x11,0x11,0x11,0x11,0x11,0x0e,0x00, // O - - 0x1e,0x11,0x11,0x1e,0x10,0x10,0x10,0x00, // P - 0x0e,0x11,0x11,0x11,0x15,0x12,0x0d,0x00, // Q - 0x1e,0x11,0x11,0x1e,0x14,0x12,0x11,0x00, // R - 0x0e,0x11,0x10,0x0e,0x01,0x11,0x0e,0x00, // S - 0x1f,0x04,0x04,0x04,0x04,0x04,0x04,0x00, // T - 0x11,0x11,0x11,0x11,0x11,0x11,0x0e,0x00, // U - 0x11,0x11,0x11,0x0a,0x0a,0x04,0x04,0x00, // V - 0x11,0x11,0x11,0x15,0x15,0x15,0x0a,0x00, // W - - 0x11,0x11,0x0a,0x04,0x0a,0x11,0x11,0x00, // X - 0x11,0x11,0x0a,0x04,0x04,0x04,0x04,0x00, // Y - 0x1f,0x01,0x02,0x04,0x08,0x10,0x1f,0x00, // Z - 0x1c,0x10,0x10,0x10,0x10,0x10,0x1c,0x00, // [ - 0x00,0x10,0x08,0x04,0x02,0x01,0x00,0x00, // backslash - 0x07,0x01,0x01,0x01,0x01,0x01,0x07,0x00, // ] - 0x0e,0x11,0x00,0x00,0x00,0x00,0x00,0x00, // ^ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00, // _ - - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // - 0x04,0x04,0x04,0x04,0x04,0x00,0x04,0x00, // ! - 0x0a,0x0a,0x0a,0x00,0x00,0x00,0x00,0x00, // " - 0x0a,0x0a,0x1f,0x0a,0x1f,0x0a,0x0a,0x00, // # - 0x00,0x11,0x0e,0x0a,0x0e,0x11,0x00,0x00, // [] - 0x18,0x19,0x02,0x04,0x08,0x13,0x03,0x00, // % - 0x04,0x0a,0x0a,0x0c,0x15,0x12,0x0d,0x00, // & - 0x04,0x04,0x08,0x00,0x00,0x00,0x00,0x00, // ' - - 0x02,0x04,0x08,0x08,0x08,0x04,0x02,0x00, // ( - 0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00, // ) - 0x00,0x04,0x15,0x0e,0x15,0x04,0x00,0x00, // * - 0x00,0x04,0x04,0x1f,0x04,0x04,0x00,0x00, // + - 0x00,0x00,0x00,0x00,0x08,0x08,0x10,0x00, // , - 0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x00, // - - 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, // . - 0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00, // / - - 0x0e,0x11,0x13,0x15,0x19,0x11,0x0e,0x00, // 0 - 0x04,0x0c,0x04,0x04,0x04,0x04,0x0e,0x00, // 1 - 0x0e,0x11,0x01,0x06,0x08,0x10,0x1f,0x00, // 2 - 0x1f,0x01,0x02,0x06,0x01,0x11,0x0e,0x00, // 3 - 0x02,0x06,0x0a,0x12,0x1f,0x02,0x02,0x00, // 4 - 0x1f,0x10,0x1e,0x01,0x01,0x11,0x0e,0x00, // 5 - 0x07,0x08,0x10,0x1e,0x11,0x11,0x0e,0x00, // 6 - 0x1f,0x01,0x02,0x04,0x08,0x08,0x08,0x00, // 7 - - 0x0e,0x11,0x11,0x0e,0x11,0x11,0x0e,0x00, // 8 - 0x0e,0x11,0x11,0x0f,0x01,0x02,0x1c,0x00, // 9 - 0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00, // : - 0x00,0x00,0x04,0x00,0x04,0x04,0x08,0x00, // ; - 0x02,0x04,0x08,0x10,0x08,0x04,0x02,0x00, // < - 0x00,0x00,0x1f,0x00,0x1f,0x00,0x00,0x00, // = - 0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x00, // > - 0x0e,0x11,0x01,0x02,0x04,0x00,0x04,0x00 // ? -}; - -/*****************************************************************************/ -/* Implementation for MC80.2x */ -/*****************************************************************************/ - - - -VIDEO_START_MEMBER(mc80_state,mc8020) -{ -} - -UINT32 mc80_state::screen_update_mc8020(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx; - UINT16 sy=0,ma=0,x; - - for(y = 0; y < 8; y++ ) - { - for (ra = 0; ra < 16; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 32; x++) - { - if (ra > 3 && ra < 12) - { - chr = m_p_videoram[x]; - gfx = prom[(chr<<3) | (ra-4)]; - } - else - gfx = 0; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=32; - } - return 0; -} - -/*****************************************************************************/ -/* Implementation for MC80.3x */ -/*****************************************************************************/ - - -VIDEO_START_MEMBER(mc80_state,mc8030) -{ - m_p_videoram.set_target(memregion("vram")->base(),m_p_videoram.bytes()); -} - -UINT32 mc80_state::screen_update_mc8030(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 gfx; - UINT16 y=0,ma=0,x; - - for(y = 0; y < 256; y++ ) - { - UINT16 *p = &bitmap.pix16(y); - { - for (x = ma; x < ma + 64; x++) - { - gfx = m_p_videoram[x^0x3fff]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=64; - } - return 0; -} diff --git a/src/mess/video/microtan.c b/src/mess/video/microtan.c deleted file mode 100644 index b6973e40fac..00000000000 --- a/src/mess/video/microtan.c +++ /dev/null @@ -1,57 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller -/*************************************************************************** - * Microtan 65 - * - * video hardware - * - * Juergen Buchmueller , Jul 2000 - * - * Thanks go to Geoff Macdonald - * for his site http:://www.geo255.redhotant.com - * and to Fabrice Frances - * for his site http://www.ifrance.com/oric/microtan.html - * - ***************************************************************************/ - -#include "emu.h" -#include "includes/microtan.h" - - - - -WRITE8_MEMBER(microtan_state::microtan_videoram_w) -{ - UINT8 *videoram = m_videoram; - if ((videoram[offset] != data) || (m_chunky_buffer[offset] != m_chunky_graphics)) - { - videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); - m_chunky_buffer[offset] = m_chunky_graphics; - } -} - -TILE_GET_INFO_MEMBER(microtan_state::get_bg_tile_info) -{ - UINT8 *videoram = m_videoram; - int gfxn = m_chunky_buffer[tile_index]; - int code = videoram[tile_index]; - - SET_TILE_INFO_MEMBER(gfxn, code, 0, 0); -} - -void microtan_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(microtan_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, - 8, 16, 32, 16); - - m_chunky_buffer = auto_alloc_array(machine(), UINT8, 0x200); - memset(m_chunky_buffer, 0, 0x200); - m_chunky_graphics = 0; -} - -UINT32 microtan_state::screen_update_microtan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - return 0; -} diff --git a/src/mess/video/mikro80.c b/src/mess/video/mikro80.c deleted file mode 100644 index edab6f8cd06..00000000000 --- a/src/mess/video/mikro80.c +++ /dev/null @@ -1,40 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Mikro-80 video driver by Miodrag Milanovic - - 10/03/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/mikro80.h" - - -void mikro80_state::video_start() -{ -} - -UINT32 mikro80_state::screen_update_mikro80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *gfx = m_region_gfx1->base(); - int x,y,b; - - for(y = 0; y < 32*8; y++ ) - { - for(x = 0; x < 64; x++ ) - { - int addr = x + (y / 8)*64; - UINT8 code = gfx[m_video_ram [addr]*8+ (y % 8)]; - UINT8 attr = m_cursor_ram[addr+1] & 0x80 ? 1 : 0; - for (b = 7; b >= 0; b--) - { - UINT8 col = (code >> b) & 0x01; - bitmap.pix16(y, x*8+(7-b)) = attr ? col ^ 1 : col; - } - } - } - return 0; -} diff --git a/src/mess/video/mikromik.c b/src/mess/video/mikromik.c deleted file mode 100644 index e107a3c4421..00000000000 --- a/src/mess/video/mikromik.c +++ /dev/null @@ -1,126 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/mikromik.h" - - - -//------------------------------------------------- -// i8275 crtc display pixels -//------------------------------------------------- - -I8275_DRAW_CHARACTER_MEMBER( mm1_state::crtc_display_pixels ) -{ - UINT8 romdata = m_char_rom->base()[(charcode << 4) | linecount]; - - int d0 = BIT(romdata, 0); - int d7 = BIT(romdata, 7); - int gpa0 = BIT(gpa, 0); - int llen = m_llen; - int i; - - UINT8 data = (romdata << 1) | (d7 & d0); - - for (i = 0; i < 8; i++) - { - int qh = BIT(data, i); - int video_in = ((((d7 & llen) | !vsp) & !gpa0) & qh) | lten; - int compl_in = rvv; - int hlt_in = hlgt; - - int color = hlt_in ? 2 : (video_in ^ compl_in); - - bitmap.pix32(y, x + i) = m_palette->pen(color); - } -} - - -//------------------------------------------------- -// ADDRESS_MAP( mm1_upd7220_map ) -//------------------------------------------------- - -static ADDRESS_MAP_START( mm1_upd7220_map, AS_0, 16, mm1_state ) - ADDRESS_MAP_GLOBAL_MASK(0x7fff) - AM_RANGE(0x0000, 0x7fff) AM_RAM AM_SHARE("video_ram") -ADDRESS_MAP_END - - -//------------------------------------------------- -// UPD7220_INTERFACE( hgdc_intf ) -//------------------------------------------------- - -UPD7220_DISPLAY_PIXELS_MEMBER( mm1_state::hgdc_display_pixels ) -{ - UINT16 data = m_video_ram[address >> 1]; - - for (int i = 0; i < 16; i++) - { - if (BIT(data, i)) bitmap.pix32(y, x + i) = m_palette->pen(1); - } -} - - -UINT32 mm1_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - /* text */ - m_crtc->screen_update(screen, bitmap, cliprect); - - /* graphics */ - m_hgdc->screen_update(screen, bitmap, cliprect); - - return 0; -} - - -//------------------------------------------------- -// gfx_layout charlayout -//------------------------------------------------- - -static const gfx_layout charlayout = -{ - 8, 16, - RGN_FRAC(1,1), - 1, - { 0 }, - { 7, 6, 5, 4, 3, 2, 1, 0 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - 8*16 -}; - - -//------------------------------------------------- -// GFXDECODE( mm1 ) -//------------------------------------------------- - -static GFXDECODE_START( mm1 ) - GFXDECODE_ENTRY( "chargen", 0, charlayout, 0, 1 ) -GFXDECODE_END - - -//------------------------------------------------- -// MACHINE_CONFIG_FRAGMENT( mm1m6_video ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( mm1m6_video ) - MCFG_SCREEN_ADD( SCREEN_TAG, RASTER ) - MCFG_SCREEN_REFRESH_RATE( 50 ) - MCFG_SCREEN_UPDATE_DRIVER(mm1_state, screen_update) - MCFG_SCREEN_SIZE( 800, 400 ) - MCFG_SCREEN_VISIBLE_AREA( 0, 800-1, 0, 400-1 ) - //MCFG_SCREEN_RAW_PARAMS(XTAL_18_720MHz, ...) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", mm1) - MCFG_PALETTE_ADD_MONOCHROME_GREEN_HIGHLIGHT("palette") - - MCFG_DEVICE_ADD(I8275_TAG, I8275, XTAL_18_720MHz/8) - MCFG_I8275_CHARACTER_WIDTH(8) - MCFG_I8275_DRAW_CHARACTER_CALLBACK_OWNER(mm1_state, crtc_display_pixels) - MCFG_I8275_DRQ_CALLBACK(DEVWRITELINE(I8237_TAG, am9517a_device, dreq0_w)) - MCFG_I8275_VRTC_CALLBACK(DEVWRITELINE(UPD7220_TAG, upd7220_device, ext_sync_w)) - MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) - - MCFG_DEVICE_ADD(UPD7220_TAG, UPD7220, XTAL_18_720MHz/8) - MCFG_DEVICE_ADDRESS_MAP(AS_0, mm1_upd7220_map) - MCFG_UPD7220_DISPLAY_PIXELS_CALLBACK_OWNER(mm1_state, hgdc_display_pixels) - MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) -MACHINE_CONFIG_END diff --git a/src/mess/video/mz700.c b/src/mess/video/mz700.c deleted file mode 100644 index b3f08dad1a3..00000000000 --- a/src/mess/video/mz700.c +++ /dev/null @@ -1,128 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller, Dirk Best -/*************************************************************************** - * Sharp MZ700 - * - * video hardware - * - * Juergen Buchmueller , Jul 2000 - * - * Reference: http://sharpmz.computingmuseum.com - * - ***************************************************************************/ - -#include "emu.h" -#include "includes/mz700.h" - - -#ifndef VERBOSE -#define VERBOSE 1 -#endif - -#define LOG(N,M,A) \ - do { \ - if(VERBOSE>=N) \ - { \ - if( M ) \ - logerror("%11.6f: %-24s",machine.time().as_double(),(char*)M ); \ - logerror A; \ - } \ - } while (0) - - -PALETTE_INIT_MEMBER(mz_state, mz) -{ - int i; - - for (i = 0; i < 8; i++) - m_palette->set_indirect_color(i, rgb_t((i & 2) ? 0xff : 0x00, (i & 4) ? 0xff : 0x00, (i & 1) ? 0xff : 0x00)); - - for (i = 0; i < 256; i++) - { - m_palette->set_pen_indirect(i*2, i & 7); - m_palette->set_pen_indirect(i*2+1, (i >> 4) & 7); - } -} - - -UINT32 mz_state::screen_update_mz700(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - int offs; - - bitmap.fill(m_palette->black_pen(), cliprect); - - for(offs = 0; offs < 40*25; offs++) - { - int sx, sy, code, color; - - sy = (offs / 40) * 8; - sx = (offs % 40) * 8; - - color = m_colorram[offs]; - code = videoram[offs] | (color & 0x80) << 1; - - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code, color, 0, 0, sx, sy); - } - - return 0; -} - - -/*************************************************************************** - MZ-800 -***************************************************************************/ - -VIDEO_START_MEMBER(mz_state,mz800) -{ - m_gfxdecode->gfx(0)->set_source(m_cgram); -} - -UINT32 mz_state::screen_update_mz800(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - - bitmap.fill(m_palette->black_pen(), cliprect); - - if (m_mz700_mode) - return screen_update_mz700(screen, bitmap, cliprect); - else - { - if (m_hires_mode) - { - } - else - { - int x, y; - UINT8 *start_addr = videoram; - - for (x = 0; x < 40; x++) - { - for (y = 0; y < 200; y++) - { - bitmap.pix16(y, x * 8 + 0) = BIT(start_addr[x * 8 + y], 0); - bitmap.pix16(y, x * 8 + 1) = BIT(start_addr[x * 8 + y], 1); - bitmap.pix16(y, x * 8 + 2) = BIT(start_addr[x * 8 + y], 2); - bitmap.pix16(y, x * 8 + 3) = BIT(start_addr[x * 8 + y], 3); - bitmap.pix16(y, x * 8 + 4) = BIT(start_addr[x * 8 + y], 4); - bitmap.pix16(y, x * 8 + 5) = BIT(start_addr[x * 8 + y], 5); - bitmap.pix16(y, x * 8 + 6) = BIT(start_addr[x * 8 + y], 6); - bitmap.pix16(y, x * 8 + 7) = BIT(start_addr[x * 8 + y], 7); - } - } - } - - return 0; - } -} - -/*************************************************************************** - CGRAM -***************************************************************************/ - -WRITE8_MEMBER(mz_state::mz800_cgram_w) -{ - m_cgram[offset] = data; - - m_gfxdecode->gfx(0)->mark_dirty(offset/8); -} diff --git a/src/mess/video/mz80.c b/src/mess/video/mz80.c deleted file mode 100644 index d6bfa015c9c..00000000000 --- a/src/mess/video/mz80.c +++ /dev/null @@ -1,143 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - MZ80 driver by Miodrag Milanovic - - 22/11/2008 Preliminary driver. - -****************************************************************************/ - -#include "includes/mz80.h" - -const gfx_layout mz80k_charlayout = -{ - 8, 8, /* 8x8 characters */ - 256, /* 256 characters */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {0, 1, 2, 3, 4, 5, 6, 7}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -const gfx_layout mz80kj_charlayout = -{ - 8, 8, /* 8x8 characters */ - 256, /* 256 characters + 256 blanks */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {7, 6, 5, 4, 3, 2, 1, 0}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -/* Video hardware */ -void mz80_state::video_start() -{ - m_p_chargen = memregion("chargen")->base(); -} - -UINT32 mz80_state::screen_update_mz80k(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_mz80k_vertical ^= 1; - m_mz80k_cursor_cnt++; - UINT8 y,ra,chr,gfx; - UINT16 x,sy=0,ma=0; - - for(y = 0; y < 25; y++ ) - { - for (ra = 0; ra < 8; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 40; x++) - { - chr = m_p_videoram[x]; - gfx = m_p_chargen[(chr<<3) | ra]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=40; - } - return 0; -} - -// same as above except bits are in reverse order -UINT32 mz80_state::screen_update_mz80kj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_mz80k_vertical ^= 1; - m_mz80k_cursor_cnt++; - UINT8 y,ra,chr,gfx; - UINT16 x,sy=0,ma=0; - - for(y = 0; y < 25; y++ ) - { - for (ra = 0; ra < 8; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 40; x++) - { - chr = m_p_videoram[x]; - gfx = m_p_chargen[(chr<<3) | ra]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 0); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 7); - } - } - ma+=40; - } - return 0; -} - -// has twice as much video ram and uses a scroll register -UINT32 mz80_state::screen_update_mz80a(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_mz80k_vertical ^= 1; - m_mz80k_cursor_cnt++; - UINT8 y,ra,chr,gfx; - UINT16 x,sy=0, ma=m_p_ram[0x17d] | (m_p_ram[0x17e] << 8); - - for(y = 0; y < 25; y++ ) - { - for (ra = 0; ra < 8; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 40; x++) - { - chr = m_p_videoram[x&0x7ff]; - gfx = m_p_chargen[(chr<<3) | ra]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=40; - } - return 0; -} diff --git a/src/mess/video/nc.c b/src/mess/video/nc.c deleted file mode 100644 index 934bfbfd3a3..00000000000 --- a/src/mess/video/nc.c +++ /dev/null @@ -1,120 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Wilbert Pol, Kevin Thacker -/*************************************************************************** - - nc.c - - Functions to emulate the video hardware of the Amstrad PCW. - -***************************************************************************/ - -#include "emu.h" -#include "includes/nc.h" -#include "machine/ram.h" - -/*************************************************************************** - Start the video hardware emulation. -***************************************************************************/ - -void nc_state::video_start() -{ -} - -#if 0 -/* two colours */ -static const unsigned short nc_colour_table[NC_NUM_COLOURS] = -{ - 0, 1,2,3 -}; -#endif - -/* black/white */ -static const rgb_t nc_palette[NC_NUM_COLOURS] = -{ - rgb_t(0x060, 0x060, 0x060), - rgb_t(0x000, 0x000, 0x000), - rgb_t(0x080, 0x0a0, 0x060), - rgb_t(0x000, 0x000, 0x000) -}; - - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(nc_state, nc) -{ - palette.set_pen_colors(0, nc_palette, ARRAY_LENGTH(nc_palette)); -} - - -void nc_state::nc200_video_set_backlight(int state) -{ - m_nc200_backlight = state; -} - - -/*************************************************************************** - Draw the game screen in the given bitmap_ind16. - Do NOT call osd_update_display() from this function, - it will be called by the main emulation engine. -***************************************************************************/ -UINT32 nc_state::screen_update_nc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y; - int b; - int x; - int height, width; - int pens[2]; - - if (m_type==NC_TYPE_200) - { - height = NC200_SCREEN_HEIGHT; - width = NC200_SCREEN_WIDTH; - - if (m_nc200_backlight) - { - pens[0] = 2; - pens[1] = 3; - } - else - { - pens[0] = 0; - pens[1] = 1; - } - } - else - { - height = NC_SCREEN_HEIGHT; - width = NC_SCREEN_WIDTH; - pens[0] = 2; - pens[1] = 3; - } - - - for (y=0; ypointer()) + m_display_memory_start + (y<<6); - - x = 0; - for (by=0; by>3; by++) - { - int px; - unsigned char byte; - - byte = line_ptr[0]; - - px = x; - for (b=0; b<8; b++) - { - bitmap.pix16(y, px) = pens[(byte>>7) & 0x01]; - byte = byte<<1; - px++; - } - - x = px; - - line_ptr = line_ptr+1; - } - } - return 0; -} diff --git a/src/mess/video/nes.c b/src/mess/video/nes.c deleted file mode 100644 index 077f4efe3a2..00000000000 --- a/src/mess/video/nes.c +++ /dev/null @@ -1,62 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Brad Oliver,Fabio Priuli -/*************************************************************************** - - video/nes.c - - Routines to control the unique NES video hardware/PPU. - -***************************************************************************/ - -#include "emu.h" -#include "includes/nes.h" - -void nes_state::video_reset() -{ - m_ppu->set_vidaccess_callback(ppu2c0x_vidaccess_delegate(FUNC(nes_state::nes_ppu_vidaccess),this)); -} - -void nes_state::video_start() -{ - m_last_frame_flip = 0; -} - -PALETTE_INIT_MEMBER(nes_state, nes) -{ - m_ppu->init_palette(palette, 0); -} - - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -UINT32 nes_state::screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - // render the ppu - m_ppu->render(bitmap, 0, 0, 0, 0); - - // if this is a disk system game, check for the flip-disk key - if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS)) // first scenario = disksys in m_cartslot (= famicom) - || m_disk) // second scenario = disk via fixed internal disk option (fds & famitwin) - { - if (m_io_disksel) - { - // latch this input so it doesn't go at warp speed - if ((m_io_disksel->read() & 0x01) && (!m_last_frame_flip)) - { - if (m_disk) - m_disk->disk_flip_side(); - else - m_cartslot->disk_flip_side(); - m_last_frame_flip = 1; - } - - if (!(m_io_disksel->read() & 0x01)) - m_last_frame_flip = 0; - } - } - return 0; -} diff --git a/src/mess/video/newbrain.c b/src/mess/video/newbrain.c deleted file mode 100644 index ae010c0b15c..00000000000 --- a/src/mess/video/newbrain.c +++ /dev/null @@ -1,130 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/newbrain.h" -#include "newbrain.lh" - -void newbrain_state::video_start() -{ - /* register for state saving */ - save_item(NAME(m_tvcnsl)); - save_item(NAME(m_tvctl)); - save_item(NAME(m_tvram)); - save_item(NAME(m_segment_data)); -} - -void newbrain_state::screen_update(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - address_space &program = m_maincpu->space(AS_PROGRAM); - - int y, sx; - int columns = (m_tvctl & NEWBRAIN_VIDEO_80L) ? 80 : 40; - int excess = (m_tvctl & NEWBRAIN_VIDEO_32_40) ? 24 : 4; - int ucr = (m_tvctl & NEWBRAIN_VIDEO_UCR) ? 1 : 0; - int fs = (m_tvctl & NEWBRAIN_VIDEO_FS) ? 1 : 0; - int rv = (m_tvctl & NEWBRAIN_VIDEO_RV) ? 1 : 0; - int gr = 0; - - UINT16 videoram_addr = m_tvram; - UINT8 rc = 0; - - for (y = 0; y < 250; y++) - { - int x = 0; - - for (sx = 0; sx < columns; sx++) - { - int bit; - - UINT8 videoram_data = program.read_byte(videoram_addr + sx); - UINT8 charrom_data; - - if (gr) - { - /* render video ram data */ - charrom_data = videoram_data; - } - else - { - /* render character rom data */ - UINT16 charrom_addr = (rc << 8) | ((BIT(videoram_data, 7) & fs) << 7) | (videoram_data & 0x7f); - charrom_data = m_char_rom->base()[charrom_addr & 0xfff]; - - if ((videoram_data & 0x80) && !fs) - { - /* invert character */ - charrom_data ^= 0xff; - } - - if ((videoram_data & 0x60) && !ucr) - { - /* strip bit D0 */ - charrom_data &= 0xfe; - } - } - - for (bit = 0; bit < 8; bit++) - { - int color = BIT(charrom_data, 7) ^ rv; - - bitmap.pix32(y, x++) = m_palette->pen(color); - - if (columns == 40) - { - bitmap.pix32(y, x++) = m_palette->pen(color); - } - - charrom_data <<= 1; - } - } - - if (gr) - { - /* get new data for each line */ - videoram_addr += columns; - videoram_addr += excess; - } - else - { - /* increase row counter */ - rc++; - - if (rc == (ucr ? 8 : 10)) - { - /* reset row counter */ - rc = 0; - - videoram_addr += columns; - videoram_addr += excess; - } - } - } -} - -UINT32 newbrain_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - if (m_enrg1 & NEWBRAIN_ENRG1_TVP) - { - screen_update(bitmap, cliprect); - } - else - { - bitmap.fill(rgb_t::black, cliprect); - } - - return 0; -} - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( newbrain_video ) - MCFG_DEFAULT_LAYOUT(layout_newbrain) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(newbrain_state, screen_update) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ - MCFG_SCREEN_SIZE(640, 250) - MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 249) - - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") -MACHINE_CONFIG_END diff --git a/src/mess/video/newport.c b/src/mess/video/newport.c deleted file mode 100644 index 8d331fbb60f..00000000000 --- a/src/mess/video/newport.c +++ /dev/null @@ -1,1667 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz -/* - SGI "Newport" graphics board used in the Indy and some Indigo2s - - Newport is modular, consisting of the following custom chips: - - REX3: Raster Engine, which is basically a blitter which can also draw antialiased lines. - REX also acts as the interface to the rest of the system - all the other chips on - a Newport board are accessed through it. - - RB2: Frame buffer input controller - - RO1: Frame buffer output controller - - XMAP9: Final display generator - - CMAP: Palette mapper - - VC2: Video timing controller / CRTC - - Taken from the Linux Newport driver, slave addresses for Newport devices are: - VC2 0 - Both CMAPs 1 - CMAP 0 2 - CMAP 1 3 - Both XMAPs 4 - XMAP 0 5 - XMAP 1 6 - RAMDAC 7 - VIDEO (CC1) 8 - VIDEO (AB1) 9 -*/ - -#include "emu.h" -#include "video/newport.h" - -#define VERBOSE_LEVEL ( 0 ) - -#if 0 -INLINE void ATTR_PRINTF(3,4) verboselog(running_machine &machine, int n_level, const char *s_fmt, ... ) -{ - if( VERBOSE_LEVEL >= n_level ) - { - va_list v; - char buf[ 32768 ]; - va_start( v, s_fmt ); - vsprintf( buf, s_fmt, v ); - va_end( v ); - logerror( "%08x: %s", machine.device("maincpu")->safe_pc(), buf ); - } -} -#endif - -#define VC2_VIDENTRY m_VC2.nRegister[0x00] -#define VC2_CURENTRY m_VC2.nRegister[0x01] -#define VC2_CURSORX m_VC2.nRegister[0x02] -#define VC2_CURSORY m_VC2.nRegister[0x03] -#define VC2_CURCURSORX m_VC2.nRegister[0x04] -#define VC2_DIDENTRY m_VC2.nRegister[0x05] -#define VC2_SCANLINELEN m_VC2.nRegister[0x06] -#define VC2_RAMADDR m_VC2.nRegister[0x07] -#define VC2_VTFRAMEPTR m_VC2.nRegister[0x08] -#define VC2_VTLINEPTR m_VC2.nRegister[0x09] -#define VC2_VTLINERUN m_VC2.nRegister[0x0a] -#define VC2_VLINECNT m_VC2.nRegister[0x0b] -#define VC2_CURTABLEPTR m_VC2.nRegister[0x0c] -#define VC2_WORKCURSORY m_VC2.nRegister[0x0d] -#define VC2_DIDFRAMEPTR m_VC2.nRegister[0x0e] -#define VC2_DIDLINEPTR m_VC2.nRegister[0x0f] -#define VC2_DISPLAYCTRL m_VC2.nRegister[0x10] -#define VC2_CONFIG m_VC2.nRegister[0x1f] - -#define XMAP0_CONFIG m_XMAP0.nRegister[0x00] -#define XMAP0_REVISION m_XMAP0.nRegister[0x01] -#define XMAP0_ENTRIES m_XMAP0.nRegister[0x02] -#define XMAP0_CURCMAP m_XMAP0.nRegister[0x03] -#define XMAP0_POPUPCMAP m_XMAP0.nRegister[0x04] -#define XMAP0_MODETBLIDX m_XMAP0.nRegister[0x07] - -#define XMAP1_CONFIG m_XMAP1.nRegister[0x00] -#define XMAP1_REVISION m_XMAP1.nRegister[0x01] -#define XMAP1_ENTRIES m_XMAP1.nRegister[0x02] -#define XMAP1_CURCMAP m_XMAP1.nRegister[0x03] -#define XMAP1_POPUPCMAP m_XMAP1.nRegister[0x04] -#define XMAP1_MODETBLIDX m_XMAP1.nRegister[0x07] - - -const device_type NEWPORT_VIDEO = &device_creator; - - -newport_video_device::newport_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, NEWPORT_VIDEO, "SGI Newport graphics board", tag, owner, clock, "newport_video", __FILE__) -{ -} - - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void newport_video_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void newport_video_device::device_start() -{ - m_base = auto_alloc_array_clear(machine(), UINT32, (1280+64) * (1024+64)); - - save_pointer(NAME(m_base), (1280+64) * (1024+64)); - save_item(NAME(m_VC2.nRegister)); - save_item(NAME(m_VC2.nRAM)); - save_item(NAME(m_VC2.nRegIdx)); - save_item(NAME(m_VC2.nRegData)); - - save_item(NAME(m_XMAP0.nRegister)); - save_item(NAME(m_XMAP0.nModeTable)); - save_item(NAME(m_XMAP1.nRegister)); - save_item(NAME(m_XMAP1.nModeTable)); - - save_item(NAME(m_REX3.nDrawMode1)); - save_item(NAME(m_REX3.nDrawMode0)); - save_item(NAME(m_REX3.nLSMode)); - save_item(NAME(m_REX3.nLSPattern)); - save_item(NAME(m_REX3.nLSPatSave)); - save_item(NAME(m_REX3.nZPattern)); - save_item(NAME(m_REX3.nColorBack)); - save_item(NAME(m_REX3.nColorVRAM)); - save_item(NAME(m_REX3.nAlphaRef)); - save_item(NAME(m_REX3.nSMask0X)); - save_item(NAME(m_REX3.nSMask0Y)); - save_item(NAME(m_REX3.nSetup)); - save_item(NAME(m_REX3.nStepZ)); - save_item(NAME(m_REX3.nXStart)); - save_item(NAME(m_REX3.nYStart)); - save_item(NAME(m_REX3.nXEnd)); - save_item(NAME(m_REX3.nYEnd)); - - save_item(NAME(m_REX3.nXSave)); - save_item(NAME(m_REX3.nXYMove)); - save_item(NAME(m_REX3.nBresD)); - save_item(NAME(m_REX3.nBresS1)); - save_item(NAME(m_REX3.nBresOctInc1)); - save_item(NAME(m_REX3.nBresRndInc2)); - save_item(NAME(m_REX3.nBresE1)); - save_item(NAME(m_REX3.nBresS2)); - save_item(NAME(m_REX3.nAWeight0)); - save_item(NAME(m_REX3.nAWeight1)); - save_item(NAME(m_REX3.nXStartF)); - save_item(NAME(m_REX3.nYStartF)); - save_item(NAME(m_REX3.nXEndF)); - save_item(NAME(m_REX3.nYEndF)); - save_item(NAME(m_REX3.nXStartI)); - save_item(NAME(m_REX3.nXYStartI)); - save_item(NAME(m_REX3.nXYEndI)); - save_item(NAME(m_REX3.nXStartEndI)); - save_item(NAME(m_REX3.nColorRed)); - save_item(NAME(m_REX3.nColorAlpha)); - save_item(NAME(m_REX3.nColorGreen)); - save_item(NAME(m_REX3.nColorBlue)); - save_item(NAME(m_REX3.nSlopeRed)); - save_item(NAME(m_REX3.nSlopeAlpha)); - save_item(NAME(m_REX3.nSlopeGreen)); - save_item(NAME(m_REX3.nSlopeBlue)); - save_item(NAME(m_REX3.nWriteMask)); - save_item(NAME(m_REX3.nZeroFract)); - save_item(NAME(m_REX3.nZeroOverflow)); - save_item(NAME(m_REX3.nHostDataPortMSW)); - save_item(NAME(m_REX3.nHostDataPortLSW)); - save_item(NAME(m_REX3.nDCBMode)); - save_item(NAME(m_REX3.nDCBRegSelect)); - save_item(NAME(m_REX3.nDCBSlvSelect)); - save_item(NAME(m_REX3.nDCBDataMSW)); - save_item(NAME(m_REX3.nDCBDataLSW)); - save_item(NAME(m_REX3.nSMask1X)); - save_item(NAME(m_REX3.nSMask1Y)); - save_item(NAME(m_REX3.nSMask2X)); - save_item(NAME(m_REX3.nSMask2Y)); - save_item(NAME(m_REX3.nSMask3X)); - save_item(NAME(m_REX3.nSMask3Y)); - save_item(NAME(m_REX3.nSMask4X)); - save_item(NAME(m_REX3.nSMask4Y)); - save_item(NAME(m_REX3.nTopScanline)); - save_item(NAME(m_REX3.nXYWin)); - save_item(NAME(m_REX3.nClipMode)); - save_item(NAME(m_REX3.nConfig)); - save_item(NAME(m_REX3.nStatus)); - save_item(NAME(m_REX3.nXFerWidth)); -#if 0 - save_item(NAME(m_REX3.nCurrentX)); - save_item(NAME(m_REX3.nCurrentY)); -#endif - save_item(NAME(m_REX3.nKludge_SkipLine)); - - save_item(NAME(m_nDrawGreen)); - save_item(NAME(m_CMAP0.nPaletteIndex)); - save_item(NAME(m_CMAP0.nPalette)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void newport_video_device::device_reset() -{ - m_nDrawGreen = 0; - m_REX3.nDrawMode0 = 0x00000000; - m_REX3.nDrawMode1 = 0x3002f001; - m_REX3.nDCBMode = 0x00000780; - m_REX3.nKludge_SkipLine = 0; -} - - -UINT32 newport_video_device::screen_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - /* loop over rows and copy to the destination */ - for (int y = cliprect.min_y; y <= cliprect.max_y; y++) - { - UINT32 *src = &m_base[1344 * y]; - UINT32 *dest = &bitmap.pix32(y, cliprect.min_x); - - /* loop over columns */ - for (int x = cliprect.min_x; x < cliprect.max_x; x++) - { - *dest++ = (*src++) & 0x00f8f8f8; - } - } - return 0; -} - - -WRITE32_MEMBER( newport_video_device::cmap0_w ) -{ - switch (m_REX3.nDCBRegSelect) - { - case 0x00: - //verboselog(machine(), 2, "CMAP0 Palette Index Write: %04x\n", data & 0x0000ffff ); - m_CMAP0.nPaletteIndex = data & 0x0000ffff; - break; - case 0x02: - //verboselog(machine(), 2, "CMAP0 Palette Entry %04x Write: %08x\n", m_CMAP0.nPaletteIndex, ( data >> 8 ) & 0x00ffffff ); - m_CMAP0.nPalette[m_CMAP0.nPaletteIndex] = ( data >> 8 ) & 0x00ffffff; - break; - default: - //verboselog(machine(), 2, "Unknown CMAP0 Register %d Write: %08x\n", m_REX3.nDCBRegSelect, data ); - break; - } -} - -READ32_MEMBER( newport_video_device::cmap0_r ) -{ - switch (m_REX3.nDCBRegSelect) - { - case 0x04: - //verboselog(machine(), 2, "CMAP0 Status Read: %08x\n", 0x00000008 ); - return 0x00000008; - case 0x06: /* Revision */ - //verboselog(machine(), 2, "CMAP0 Revision Read: CMAP Rev 1, Board Rev 2, 8bpp\n" ); - return 0x000000a1; - default: - //verboselog(machine(), 2, "Unknown CMAP0 Register %d Read\n", m_REX3.nDCBRegSelect ); - return 0x00000000; - } -} - -READ32_MEMBER( newport_video_device::cmap1_r ) -{ - switch (m_REX3.nDCBRegSelect) - { - case 0x04: - //verboselog(machine(), 2, "CMAP1 Status Read: %08x\n", 0x00000008 ); - return 0x00000008; - case 0x06: /* Revision */ - //verboselog(machine(), 2, "CMAP1 Revision Read: CMAP Rev 1, Board Rev 2, 8bpp\n" ); - return 0x000000a1; - default: - //verboselog(machine(), 2, "Unknown CMAP0 Register %d Read\n", m_REX3.nDCBRegSelect ); - return 0x00000000; - } -} - -READ32_MEMBER( newport_video_device::xmap0_r ) -{ - UINT8 nModeIdx; - - switch (m_REX3.nDCBRegSelect) - { - case 0: - //verboselog(machine(), 2, "XMAP0 Config Read: %08x\n", XMAP0_CONFIG ); - return XMAP0_CONFIG; - case 1: - //verboselog(machine(), 2, "XMAP0 Revision Read: %08x\n", 0x00 ); - return 0x00000000; - case 2: - //verboselog(machine(), 2, "XMAP0 FIFO Availability Read: %08x\n", 0x02 ); - return 0x00000002; - case 3: - //verboselog(machine(), 2, "XMAP0 Cursor CMAP MSB Read: %08x\n", XMAP0_CURCMAP ); - return XMAP0_CURCMAP; - case 4: - //verboselog(machine(), 2, "XMAP0 Pop Up CMAP MSB Read: %08x\n", XMAP0_POPUPCMAP ); - return XMAP0_POPUPCMAP; - case 5: - nModeIdx = ( XMAP0_MODETBLIDX & 0x0000007c ) >> 2; - switch (XMAP0_MODETBLIDX & 0x00000003) - { - case 0: - //verboselog(machine(), 2, "XMAP0 Mode Register Read: %02x (Byte 0): %08x\n", nModeIdx, ( m_XMAP0.nModeTable[ nModeIdx ] & 0x00ff0000 ) >> 16 ); - return ( m_XMAP0.nModeTable[ nModeIdx ] & 0x00ff0000 ) >> 16; - case 1: - //verboselog(machine(), 2, "XMAP0 Mode Register Read: %02x (Byte 1): %08x\n", nModeIdx, ( m_XMAP0.nModeTable[ nModeIdx ] & 0x0000ff00 ) >> 8 ); - return ( m_XMAP0.nModeTable[ nModeIdx ] & 0x0000ff00 ) >> 8; - case 2: - //verboselog(machine(), 2, "XMAP0 Mode Register Read: %02x (Byte 2): %08x\n", nModeIdx, ( m_XMAP0.nModeTable[ nModeIdx ] & 0x000000ff ) ); - return ( m_XMAP0.nModeTable[ nModeIdx ] & 0x000000ff ); - } - break; - case 6: - //verboselog(machine(), 2, "XMAP0 Unused Read: %08x\n", 0x00000000 ); - return 0x00000000; - case 7: - //verboselog(machine(), 2, "XMAP0 Mode Table Address Read: %08x\n", XMAP0_MODETBLIDX ); - return XMAP0_MODETBLIDX; - } - - //verboselog(machine(), 2, "XMAP0 Unknown m_REX3.nDCBRegSelect Value: %02x, returning 0\n", m_REX3.nDCBRegSelect ); - return 0x00000000; -} - -WRITE32_MEMBER( newport_video_device::xmap0_w ) -{ - UINT8 n8BitVal = data & 0x000000ff; - - switch (m_REX3.nDCBRegSelect) - { - case 0: - //verboselog(machine(), 2, "XMAP0 Config Write: %02x\n", n8BitVal ); - XMAP0_CONFIG = n8BitVal; - break; - case 1: - //verboselog(machine(), 2, "XMAP0 Revision Write (Ignored): %02x\n", n8BitVal ); - break; - case 2: - //verboselog(machine(), 2, "XMAP0 FIFO Availability Write (Ignored): %02x\n", n8BitVal ); - break; - case 3: - //verboselog(machine(), 2, "XMAP0 Cursor CMAP MSB Write: %02x\n", n8BitVal ); - XMAP0_CURCMAP = n8BitVal; - break; - case 4: - //verboselog(machine(), 2, "XMAP0 Pop Up CMAP MSB Write: %02x\n", n8BitVal ); - XMAP0_POPUPCMAP = n8BitVal; - break; - case 5: - //verboselog(machine(), 2, "XMAP0 Mode Register Write: %02x = %06x\n", ( data & 0xff000000 ) >> 24, data & 0x00ffffff ); - m_XMAP0.nModeTable[ ( data & 0xff000000 ) >> 24 ] = data & 0x00ffffff; - break; - case 6: - //verboselog(machine(), 2, "XMAP0 Unused Write (Ignored): %08x\n", data ); - break; - case 7: - //verboselog(machine(), 2, "XMAP0 Mode Table Address Write: %02x\n", n8BitVal ); - XMAP0_MODETBLIDX = n8BitVal; - break; - } -} - -READ32_MEMBER( newport_video_device::xmap1_r ) -{ - UINT8 nModeIdx; - - switch (m_REX3.nDCBRegSelect) - { - case 0: - //verboselog(machine(), 2, "XMAP1 Config Read: %08x\n", XMAP1_CONFIG ); - return XMAP1_CONFIG; - case 1: - //verboselog(machine(), 2, "XMAP1 Revision Read: %08x\n", 0x00 ); - return 0x00000000; - case 2: - //verboselog(machine(), 2, "XMAP1 FIFO Availability Read: %08x\n", 0x02 ); - return 0x00000002; - case 3: - //verboselog(machine(), 2, "XMAP1 Cursor CMAP MSB Read: %08x\n", XMAP1_CURCMAP ); - return XMAP1_CURCMAP; - case 4: - //verboselog(machine(), 2, "XMAP1 Pop Up CMAP MSB Read: %08x\n", XMAP1_POPUPCMAP ); - return XMAP1_POPUPCMAP; - case 5: - nModeIdx = ( XMAP1_MODETBLIDX & 0x0000007c ) >> 2; - switch (XMAP1_MODETBLIDX & 0x00000003) - { - case 0: - //verboselog(machine(), 2, "XMAP1 Mode Register Read: %02x (Byte 0): %08x\n", nModeIdx, ( m_XMAP1.nModeTable[ nModeIdx ] & 0x00ff0000 ) >> 16 ); - return ( m_XMAP1.nModeTable[ nModeIdx ] & 0x00ff0000 ) >> 16; - case 1: - //verboselog(machine(), 2, "XMAP1 Mode Register Read: %02x (Byte 1): %08x\n", nModeIdx, ( m_XMAP1.nModeTable[ nModeIdx ] & 0x0000ff00 ) >> 8 ); - return ( m_XMAP1.nModeTable[ nModeIdx ] & 0x0000ff00 ) >> 8; - case 2: - //verboselog(machine(), 2, "XMAP1 Mode Register Read: %02x (Byte 2): %08x\n", nModeIdx, ( m_XMAP1.nModeTable[ nModeIdx ] & 0x000000ff ) ); - return ( m_XMAP1.nModeTable[ nModeIdx ] & 0x000000ff ); - } - break; - case 6: - //verboselog(machine(), 2, "XMAP1 Unused Read: %08x\n", 0x00000000 ); - return 0x00000000; - case 7: - //verboselog(machine(), 2, "XMAP1 Mode Table Address Read: %08x\n", XMAP0_MODETBLIDX ); - return XMAP1_MODETBLIDX; - } - - //verboselog(machine(), 2, "XMAP1 Unknown m_REX3.nDCBRegSelect Value: %02x, returning 0\n", m_REX3.nDCBRegSelect ); - return 0x00000000; -} - -WRITE32_MEMBER( newport_video_device::xmap1_w ) -{ - UINT8 n8BitVal = data & 0x000000ff; - - switch (m_REX3.nDCBRegSelect) - { - case 0: - //verboselog(machine(), 2, "XMAP1 Config Write: %02x\n", n8BitVal ); - XMAP1_CONFIG = n8BitVal; - break; - case 1: - //verboselog(machine(), 2, "XMAP1 Revision Write (Ignored): %02x\n", n8BitVal ); - break; - case 2: - //verboselog(machine(), 2, "XMAP1 FIFO Availability Write (Ignored): %02x\n", n8BitVal ); - break; - case 3: - //verboselog(machine(), 2, "XMAP1 Cursor CMAP MSB Write: %02x\n", n8BitVal ); - XMAP1_CURCMAP = n8BitVal; - break; - case 4: - //verboselog(machine(), 2, "XMAP1 Pop Up CMAP MSB Write: %02x\n", n8BitVal ); - XMAP1_POPUPCMAP = n8BitVal; - break; - case 5: - //verboselog(machine(), 2, "XMAP1 Mode Register Write: %02x = %06x\n", ( data & 0xff000000 ) >> 24, data & 0x00ffffff ); - m_XMAP1.nModeTable[ ( data & 0xff000000 ) >> 24 ] = data & 0x00ffffff; - break; - case 6: - //verboselog(machine(), 2, "XMAP1 Unused Write (Ignored): %08x\n", data ); - break; - case 7: - //verboselog(machine(), 2, "XMAP1 Mode Table Address Write: %02x\n", n8BitVal ); - XMAP1_MODETBLIDX = n8BitVal; - break; - } -} - -READ32_MEMBER( newport_video_device::vc2_r ) -{ - UINT16 ret16; - - switch (m_REX3.nDCBRegSelect) - { - case 0x01: /* Register Read */ - //verboselog(machine(), 2, "VC2 Register Read: %02x, %08x\n", m_VC2.nRegIdx, m_VC2.nRegister[m_VC2.nRegIdx] ); - return m_VC2.nRegister[m_VC2.nRegIdx]; - case 0x03: /* RAM Read */ - //verboselog(machine(), 2, "VC2 RAM Read: %04x = %08x\n", VC2_RAMADDR, m_VC2.nRAM[VC2_RAMADDR] ); - ret16 = m_VC2.nRAM[VC2_RAMADDR]; - VC2_RAMADDR++; - if( VC2_RAMADDR == 0x8000 ) - { - VC2_RAMADDR = 0x0000; - } - return ret16; - default: - //verboselog(machine(), 2, "Unknown VC2 Register Read: %02x\n", m_REX3.nDCBRegSelect ); - return 0; - } -} - -WRITE32_MEMBER( newport_video_device::vc2_w ) -{ - switch (m_REX3.nXFerWidth) - { - case 0x01: /* Register Select */ - switch (m_REX3.nDCBRegSelect) - { - case 0x00: - m_VC2.nRegIdx = ( data & 0x000000ff ) >> 0; - //verboselog(machine(), 2, "VC2 Register Select: %02x\n", m_VC2.nRegIdx ); - break; - default: - //verboselog(machine(), 2, "Unknown VC2 Register Select: DCB Register %02x, data = 0x%08x\n", m_REX3.nDCBRegSelect, data ); - break; - } - break; - case 0x02: /* RAM Write */ - switch (m_REX3.nDCBRegSelect) - { - case 0x03: - //verboselog(machine(), 2, "VC2 RAM Write: %04x = %08x\n", VC2_RAMADDR, data & 0x0000ffff ); - m_VC2.nRAM[VC2_RAMADDR] = data & 0x0000ffff; - VC2_RAMADDR++; - if( VC2_RAMADDR == 0x8000 ) - { - VC2_RAMADDR = 0x0000; - } - break; - default: - //verboselog(machine(), 2, "Unknown 2-byte Write: DCB Register %02x, data = 0x%08x\n", m_REX3.nDCBRegSelect, data ); - break; - } - break; - case 0x03: /* Register Write */ - switch (m_REX3.nDCBRegSelect) - { - case 0x00: - //verboselog(machine(), 2, "VC2 Register Setup:\n" ); - m_VC2.nRegIdx = ( data & 0xff000000 ) >> 24; - m_VC2.nRegData = ( data & 0x00ffff00 ) >> 8; - switch( m_VC2.nRegIdx ) - { - case 0x00: - //verboselog(machine(), 2, " Video Entry Pointer: %04x\n", m_VC2.nRegData ); - break; - case 0x01: - //verboselog(machine(), 2, " Cursor Entry Pointer: %04x\n", m_VC2.nRegData ); - break; - case 0x02: - //verboselog(machine(), 2, " Cursor X Location: %04x\n", m_VC2.nRegData ); - break; - case 0x03: - //verboselog(machine(), 2, " Cursor Y Location: %04x\n", m_VC2.nRegData ); - break; - case 0x04: - //verboselog(machine(), 2, " Current Cursor X: %04x\n", m_VC2.nRegData ); - break; - case 0x05: - //verboselog(machine(), 2, " DID Entry Pointer: %04x\n", m_VC2.nRegData ); - break; - case 0x06: - //verboselog(machine(), 2, " Scanline Length: %04x\n", m_VC2.nRegData ); - break; - case 0x07: - //verboselog(machine(), 2, " RAM Address: %04x\n", m_VC2.nRegData ); - break; - case 0x08: - //verboselog(machine(), 2, " VT Frame Table Ptr: %04x\n", m_VC2.nRegData ); - break; - case 0x09: - //verboselog(machine(), 2, " VT Line Sequence Ptr: %04x\n", m_VC2.nRegData ); - break; - case 0x0a: - //verboselog(machine(), 2, " VT Lines in Run: %04x\n", m_VC2.nRegData ); - break; - case 0x0b: - //verboselog(machine(), 2, " Vertical Line Count: %04x\n", m_VC2.nRegData ); - break; - case 0x0c: - //verboselog(machine(), 2, " Cursor Table Ptr: %04x\n", m_VC2.nRegData ); - break; - case 0x0d: - //verboselog(machine(), 2, " Working Cursor Y: %04x\n", m_VC2.nRegData ); - break; - case 0x0e: - //verboselog(machine(), 2, " DID Frame Table Ptr: %04x\n", m_VC2.nRegData ); - break; - case 0x0f: - //verboselog(machine(), 2, " DID Line Table Ptr: %04x\n", m_VC2.nRegData ); - break; - case 0x10: - //verboselog(machine(), 2, " Display Control: %04x\n", m_VC2.nRegData ); - break; - case 0x1f: - //verboselog(machine(), 2, " Configuration: %04x\n", m_VC2.nRegData ); - m_VC2.nRegister[0x20] = m_VC2.nRegData; - break; - default: - //verboselog(machine(), 2, " Unknown VC2 Register: %04x\n", m_VC2.nRegData ); - break; - } - m_VC2.nRegister[m_VC2.nRegIdx] = m_VC2.nRegData; - break; - default: - //verboselog(machine(), 2, "Unknown VC2 Register Write: %02x = %08x\n", m_REX3.nDCBRegSelect, data ); - break; - } - break; - default: - //verboselog(machine(), 2, "Unknown VC2 XFer Width: Width %02x, DCB Register %02x, Value 0x%08x\n", m_REX3.nXFerWidth, m_REX3.nDCBRegSelect, data ); - break; - } -} - -READ32_MEMBER( newport_video_device::rex3_r ) -{ -// UINT32 nTemp; - -// if( offset >= ( 0x0800 / 4 ) ) -// { -// //verboselog(machine(), 2, "%08x:\n", 0xbf0f0000 + ( offset << 2 ) ); -// } - switch (offset) - { - case 0x0000/4: - case 0x0800/4: - //verboselog(machine(), 2, "REX3 Draw Mode 1 Read: %08x\n", m_REX3.nDrawMode1 ); - return m_REX3.nDrawMode1; - case 0x0004/4: - case 0x0804/4: - //verboselog(machine(), 2, "REX3 Draw Mode 0 Read: %08x\n", m_REX3.nDrawMode0 ); - return m_REX3.nDrawMode0; - case 0x0008/4: - case 0x0808/4: - //verboselog(machine(), 2, "REX3 Line Stipple Mode Read: %08x\n", m_REX3.nLSMode ); - return m_REX3.nLSMode; - case 0x000c/4: - case 0x080c/4: - //verboselog(machine(), 2, "REX3 Line Stipple Pattern Read: %08x\n", m_REX3.nLSPattern ); - return m_REX3.nLSPattern; - case 0x0010/4: - case 0x0810/4: - //verboselog(machine(), 2, "REX3 Line Stipple Pattern (Save) Read: %08x\n", m_REX3.nLSPatSave ); - return m_REX3.nLSPatSave; - case 0x0014/4: - case 0x0814/4: - //verboselog(machine(), 2, "REX3 Pattern Register Read: %08x\n", m_REX3.nZPattern ); - return m_REX3.nZPattern; - case 0x0018/4: - case 0x0818/4: - //verboselog(machine(), 2, "REX3 Opaque Pattern / Blendfunc Dest Color Read: %08x\n", m_REX3.nColorBack ); - return m_REX3.nColorBack; - case 0x001c/4: - case 0x081c/4: - //verboselog(machine(), 2, "REX3 VRAM Fastclear Color Read: %08x\n", m_REX3.nColorVRAM ); - return m_REX3.nColorVRAM; - case 0x0020/4: - case 0x0820/4: - //verboselog(machine(), 2, "REX3 AFUNCTION Reference Alpha Read: %08x\n", m_REX3.nAlphaRef ); - return m_REX3.nAlphaRef; - case 0x0028/4: - case 0x0828/4: - //verboselog(machine(), 2, "REX3 Screenmask 0 X Min/Max Read: %08x\n", m_REX3.nSMask0X ); - return m_REX3.nSMask0X; - case 0x002c/4: - case 0x082c/4: - //verboselog(machine(), 2, "REX3 Screenmask 0 Y Min/Max Read: %08x\n", m_REX3.nSMask0Y ); - return m_REX3.nSMask0Y; - case 0x0030/4: - case 0x0830/4: - //verboselog(machine(), 2, "REX3 Line/Span Setup Read: %08x\n", m_REX3.nSetup ); - return m_REX3.nSetup; - case 0x0034/4: - case 0x0834/4: - //verboselog(machine(), 2, "REX3 ZPattern Enable Read: %08x\n", m_REX3.nStepZ ); - return m_REX3.nStepZ; - case 0x0100/4: - case 0x0900/4: - //verboselog(machine(), 2, "REX3 X Start Read: %08x\n", m_REX3.nXStart ); - return m_REX3.nXStart; - case 0x0104/4: - case 0x0904/4: - //verboselog(machine(), 2, "REX3 YStart Read: %08x\n", m_REX3.nYStart ); - return m_REX3.nYStart; - case 0x0108/4: - case 0x0908/4: - //verboselog(machine(), 2, "REX3 XEnd Read: %08x\n", m_REX3.nXEnd ); - return m_REX3.nXEnd; - case 0x010c/4: - case 0x090c/4: - //verboselog(machine(), 2, "REX3 YEnd Read: %08x\n", m_REX3.nYEnd ); - return m_REX3.nYEnd; - case 0x0110/4: - case 0x0910/4: - //verboselog(machine(), 2, "REX3 XSave Read: %08x\n", m_REX3.nXSave ); - return m_REX3.nXSave; - case 0x0114/4: - case 0x0914/4: - //verboselog(machine(), 2, "REX3 XYMove Read: %08x\n", m_REX3.nXYMove ); - return m_REX3.nXYMove; - case 0x0118/4: - case 0x0918/4: - //verboselog(machine(), 2, "REX3 Bresenham D Read: %08x\n", m_REX3.nBresD ); - return m_REX3.nBresD; - case 0x011c/4: - case 0x091c/4: - //verboselog(machine(), 2, "REX3 Bresenham S1 Read: %08x\n", m_REX3.nBresS1 ); - return m_REX3.nBresS1; - case 0x0120/4: - case 0x0920/4: - //verboselog(machine(), 2, "REX3 Bresenham Octant & Incr1 Read: %08x\n", m_REX3.nBresOctInc1 ); - return m_REX3.nBresOctInc1; - case 0x0124/4: - case 0x0924/4: - //verboselog(machine(), 2, "REX3 Bresenham Octant Rounding Mode & Incr2 Read: %08x\n", m_REX3.nBresRndInc2 ); - return m_REX3.nBresRndInc2; - case 0x0128/4: - case 0x0928/4: - //verboselog(machine(), 2, "REX3 Bresenham E1 Read: %08x\n", m_REX3.nBresE1 ); - return m_REX3.nBresE1; - case 0x012c/4: - case 0x092c/4: - //verboselog(machine(), 2, "REX3 Bresenham S2 Read: %08x\n", m_REX3.nBresS2 ); - return m_REX3.nBresS2; - case 0x0130/4: - case 0x0930/4: - //verboselog(machine(), 2, "REX3 AA Line Weight Table 1/2 Read: %08x\n", m_REX3.nAWeight0 ); - return m_REX3.nAWeight0; - case 0x0134/4: - case 0x0934/4: - //verboselog(machine(), 2, "REX3 AA Line Weight Table 2/2 Read: %08x\n", m_REX3.nAWeight1 ); - return m_REX3.nAWeight1; - case 0x0138/4: - case 0x0938/4: - //verboselog(machine(), 2, "REX3 GL XStart Read: %08x\n", m_REX3.nXStartF ); - return m_REX3.nXStartF; - case 0x013c/4: - case 0x093c/4: - //verboselog(machine(), 2, "REX3 GL YStart Read: %08x\n", m_REX3.nYStartF ); - return m_REX3.nYStartF; - case 0x0140/4: - case 0x0940/4: - //verboselog(machine(), 2, "REX3 GL XEnd Read: %08x\n", m_REX3.nXEndF ); - return m_REX3.nXEndF; - case 0x0144/4: - case 0x0944/4: - //verboselog(machine(), 2, "REX3 GL YEnd Read: %08x\n", m_REX3.nYEndF ); - return m_REX3.nYEndF; - case 0x0148/4: - case 0x0948/4: - //verboselog(machine(), 2, "REX3 XStart (integer) Read: %08x\n", m_REX3.nXStartI ); - return m_REX3.nXStartI; - case 0x014c/4: - case 0x094c/4: - //verboselog(machine(), 2, "REX3 GL XEnd (copy) Read: %08x\n", m_REX3.nXEndF ); - return m_REX3.nXEndF; - case 0x0150/4: - case 0x0950/4: - //verboselog(machine(), 2, "REX3 XYStart (integer) Read: %08x\n", m_REX3.nXYStartI ); - return m_REX3.nXYStartI; - case 0x0154/4: - case 0x0954/4: - //verboselog(machine(), 2, "REX3 XYEnd (integer) Read: %08x\n", m_REX3.nXYEndI ); - return m_REX3.nXYEndI; - case 0x0158/4: - case 0x0958/4: - //verboselog(machine(), 2, "REX3 XStartEnd (integer) Read: %08x\n", m_REX3.nXStartEndI ); - return m_REX3.nXStartEndI; - case 0x0200/4: - case 0x0a00/4: - //verboselog(machine(), 2, "REX3 Red/CI Full State Read: %08x\n", m_REX3.nColorRed ); - return m_REX3.nColorRed; - case 0x0204/4: - case 0x0a04/4: - //verboselog(machine(), 2, "REX3 Alpha Full State Read: %08x\n", m_REX3.nColorAlpha ); - return m_REX3.nColorAlpha; - case 0x0208/4: - case 0x0a08/4: - //verboselog(machine(), 2, "REX3 Green Full State Read: %08x\n", m_REX3.nColorGreen ); - return m_REX3.nColorGreen; - case 0x020c/4: - case 0x0a0c/4: - //verboselog(machine(), 2, "REX3 Blue Full State Read: %08x\n", m_REX3.nColorBlue ); - return m_REX3.nColorBlue; - case 0x0210/4: - case 0x0a10/4: - //verboselog(machine(), 2, "REX3 Red/CI Slope Read: %08x\n", m_REX3.nSlopeRed ); - return m_REX3.nSlopeRed; - case 0x0214/4: - case 0x0a14/4: - //verboselog(machine(), 2, "REX3 Alpha Slope Read: %08x\n", m_REX3.nSlopeAlpha ); - return m_REX3.nSlopeAlpha; - case 0x0218/4: - case 0x0a18/4: - //verboselog(machine(), 2, "REX3 Green Slope Read: %08x\n", m_REX3.nSlopeGreen ); - return m_REX3.nSlopeGreen; - case 0x021c/4: - case 0x0a1c/4: - //verboselog(machine(), 2, "REX3 Blue Slope Read: %08x\n", m_REX3.nSlopeBlue ); - return m_REX3.nSlopeBlue; - case 0x0220/4: - case 0x0a20/4: - //verboselog(machine(), 2, "REX3 Write Mask Read: %08x\n", m_REX3.nWriteMask ); - return m_REX3.nWriteMask; - case 0x0224/4: - case 0x0a24/4: - //verboselog(machine(), 2, "REX3 Packed Color Fractions Read: %08x\n", m_REX3.nZeroFract ); - return m_REX3.nZeroFract; - case 0x0228/4: - case 0x0a28/4: - //verboselog(machine(), 2, "REX3 Color Index Zeros Overflow Read: %08x\n", m_REX3.nZeroOverflow ); - return m_REX3.nZeroOverflow; - case 0x022c/4: - case 0x0a2c/4: - //verboselog(machine(), 2, "REX3 Red/CI Slope (copy) Read: %08x\n", m_REX3.nSlopeRed ); - return m_REX3.nSlopeRed; - case 0x0230/4: - case 0x0a30/4: - //verboselog(machine(), 2, "REX3 Host Data Port MSW Read: %08x\n", m_REX3.nHostDataPortMSW ); - return m_REX3.nHostDataPortMSW; - case 0x0234/4: - case 0x0a34/4: - //verboselog(machine(), 2, "REX3 Host Data Port LSW Read: %08x\n", m_REX3.nHostDataPortLSW ); - return m_REX3.nHostDataPortLSW; - case 0x0238/4: - case 0x0a38/4: - //verboselog(machine(), 2, "REX3 Display Control Bus Mode Read: %08x\n", m_REX3.nDCBMode ); - return m_REX3.nDCBMode; - case 0x0240/4: - case 0x0a40/4: - switch (m_REX3.nDCBSlvSelect) - { - case 0x00: - return vc2_r(space, 0, mem_mask); - case 0x02: - return cmap0_r(space, 0, mem_mask); - case 0x03: - return cmap1_r(space, 0, mem_mask); - case 0x05: - return xmap0_r(space, 0, mem_mask); - case 0x06: - return xmap1_r(space, 0, mem_mask); - default: - //verboselog(machine(), 2, "REX3 Display Control Bus Data MSW Read: %08x\n", m_REX3.nDCBDataMSW ); - break; - } - return m_REX3.nDCBDataMSW; - case 0x0244/4: - case 0x0a44/4: - //verboselog(machine(), 2, "REX3 Display Control Bus Data LSW Read: %08x\n", m_REX3.nDCBDataLSW ); - return m_REX3.nDCBDataLSW; - case 0x1300/4: - //verboselog(machine(), 2, "REX3 Screenmask 1 X Min/Max Read: %08x\n", m_REX3.nSMask1X ); - return m_REX3.nSMask1X; - case 0x1304/4: - //verboselog(machine(), 2, "REX3 Screenmask 1 Y Min/Max Read: %08x\n", m_REX3.nSMask1Y ); - return m_REX3.nSMask1Y; - case 0x1308/4: - //verboselog(machine(), 2, "REX3 Screenmask 2 X Min/Max Read: %08x\n", m_REX3.nSMask2X ); - return m_REX3.nSMask2X; - case 0x130c/4: - //verboselog(machine(), 2, "REX3 Screenmask 2 Y Min/Max Read: %08x\n", m_REX3.nSMask2Y ); - return m_REX3.nSMask2Y; - case 0x1310/4: - //verboselog(machine(), 2, "REX3 Screenmask 3 X Min/Max Read: %08x\n", m_REX3.nSMask3X ); - return m_REX3.nSMask3X; - case 0x1314/4: - //verboselog(machine(), 2, "REX3 Screenmask 3 Y Min/Max Read: %08x\n", m_REX3.nSMask3Y ); - return m_REX3.nSMask3Y; - case 0x1318/4: - //verboselog(machine(), 2, "REX3 Screenmask 4 X Min/Max Read: %08x\n", m_REX3.nSMask4X ); - return m_REX3.nSMask4X; - case 0x131c/4: - //verboselog(machine(), 2, "REX3 Screenmask 4 Y Min/Max Read: %08x\n", m_REX3.nSMask4Y ); - return m_REX3.nSMask4Y; - case 0x1320/4: - //verboselog(machine(), 2, "REX3 Top of Screen Scanline Read: %08x\n", m_REX3.nTopScanline ); - return m_REX3.nTopScanline; - case 0x1324/4: - //verboselog(machine(), 2, "REX3 Clipping Mode Read: %08x\n", m_REX3.nXYWin ); - return m_REX3.nXYWin; - case 0x1328/4: - //verboselog(machine(), 2, "REX3 Clipping Mode Read: %08x\n", m_REX3.nClipMode ); - return m_REX3.nClipMode; - case 0x1330/4: - //verboselog(machine(), 2, "REX3 Config Read: %08x\n", m_REX3.nConfig ); - return m_REX3.nConfig; - case 0x1338/4: - //verboselog(machine(), 2, "REX3 Status Read: %08x\n", 0x00000001 ); -// nTemp = m_REX3.nStatus; - m_REX3.nStatus = 0; - return 0x00000001; - case 0x133c/4: - //verboselog(machine(), 2, "REX3 User Status Read: %08x\n", 0x00000001 ); - return 0x00000001; - default: - //verboselog(machine(), 2, "Unknown REX3 Read: %08x (%08x)\n", 0x1f0f0000 + ( offset << 2 ), mem_mask ); - return 0; - } -} - -void newport_video_device::DoREX3Command() -{ - UINT32 nCommand = ( ( m_REX3.nDrawMode0 & ( 1 << 15 ) ) >> 15 ) | - ( ( m_REX3.nDrawMode0 & ( 1 << 5 ) ) >> 4 ) | - ( ( m_REX3.nDrawMode0 & ( 1 << 9 ) ) >> 7 ) | - ( ( m_REX3.nDrawMode0 & ( 1 << 8 ) ) >> 5 ) | - ( ( m_REX3.nDrawMode0 & 0x0000001c ) << 2 ) | - ( ( m_REX3.nDrawMode0 & 0x00000003 ) << 7 ); - UINT16 nX, nY; - UINT16 nStartX = ( m_REX3.nXYStartI >> 16 ) & 0x0000ffff; - UINT16 nStartY = ( m_REX3.nXYStartI >> 0 ) & 0x0000ffff; - UINT16 nEndX = ( m_REX3.nXYEndI >> 16 ) & 0x0000ffff; - UINT16 nEndY = ( m_REX3.nXYEndI >> 0 ) & 0x0000ffff; - INT16 nMoveX, nMoveY; - - switch (nCommand) - { - case 0x00000110: - nX = nStartX; - nY = nStartY; - //verboselog(machine(), 3, "Tux Logo Draw: %04x, %04x = %08x\n", nX, nY, m_CMAP0.nPalette[ ( m_REX3.nHostDataPortMSW & 0xff000000 ) >> 24 ] ); -// m_REX3.nKludge_SkipLine = 1; - m_REX3.nBresOctInc1 = 0; - m_base[ nY*(1280+64) + nX ] = m_CMAP0.nPalette[ ( m_REX3.nHostDataPortMSW & 0xff000000 ) >> 24 ]; - nX++; - if( nX > ( ( m_REX3.nXYEndI & 0xffff0000 ) >> 16 ) ) - { - nY++; - nX = m_REX3.nXSave; - } - m_REX3.nXYStartI = ( nX << 16 ) | nY; - m_REX3.nXStartI = nX; - m_REX3.nXStart = 0 | ( ( m_REX3.nXYStartI & 0xffff0000 ) >> 5 ); - m_REX3.nYStart = 0 | ( ( m_REX3.nXYStartI & 0x0000ffff ) << 11 ); - break; - case 0x0000011e: - //verboselog(machine(), 3, "Block draw: %04x, %04x to %04x, %04x = %08x\n", nStartX, nStartY, nEndX, nEndY, m_CMAP0.nPalette[ m_REX3.nZeroFract ] ); - for( nY = nStartY; nY <= nEndY; nY++ ) - { - //verboselog(machine(), 3, "Pixel: %04x, %04x = %08x\n", nStartX, nY, m_CMAP0.nPalette[ m_REX3.nZeroFract ] ); - for( nX = nStartX; nX <= nEndX; nX++ ) - { - m_base[ nY*(1280+64) + nX ] = m_CMAP0.nPalette[ m_REX3.nZeroFract ]; - } - } - break; - case 0x00000119: - if( !m_REX3.nKludge_SkipLine ) - { - //verboselog(machine(), 3, "Pattern Line Draw: %08x at %04x, %04x color %08x\n", m_REX3.nZPattern, m_REX3.nXYStartI >> 16, m_REX3.nXYStartI & 0x0000ffff, m_CMAP0.nPalette[ m_REX3.nZeroFract ] ); - for( nX = nStartX; nX <= nEndX && nX < ( nStartX + 32 ); nX++ ) - { - if( m_REX3.nZPattern & ( 1 << ( 31 - ( nX - nStartX ) ) ) ) - { - m_base[ nStartY*(1280+64) + nX ] = m_CMAP0.nPalette[ m_REX3.nZeroFract ]; - } - } - if( m_REX3.nBresOctInc1 & 0x01000000 ) - { - nStartY--; - } - else - { - nStartY++; - } - m_REX3.nXYStartI = ( nStartX << 16 ) | nStartY; - m_REX3.nYStart = 0 | ( ( m_REX3.nXYStartI & 0x0000ffff ) << 11 ); - } - break; - case 0x0000019e: - nMoveX = (INT16)( ( m_REX3.nXYMove >> 16 ) & 0x0000ffff ); - nMoveY = (INT16)( m_REX3.nXYMove & 0x0000ffff ); - //verboselog(machine(), 1, "FB to FB Copy: %04x, %04x - %04x, %04x to %04x, %04x\n", nStartX, nStartY, nEndX, nEndY, nStartX + nMoveX, nStartY + nMoveY ); - for( nY = nStartY; nY <= nEndY; nY++ ) - { - for( nX = nStartX; nX <= nEndX; nX++ ) - { - m_base[ (nY + nMoveY)*(1280+64) + (nX + nMoveX) ] = m_base[ nY*(1280+64) + nX ]; - } - } - break; - default: - //verboselog(machine(), 1, "Unknown draw command: %08x\n", nCommand ); - break; - } -} - -WRITE32_MEMBER( newport_video_device::rex3_w ) -{ - UINT32 nTemp = 0; - - if( offset & 0x00000200 ) - { - //verboselog(machine(), 2, "Start Cmd\n" ); - } - switch( offset ) - { - case 0x0000/4: - case 0x0800/4: - //verboselog(machine(), 2, "REX3 Draw Mode 1 Write: %08x\n", data ); - switch( data & 0x00000007 ) - { - case 0x00: - //verboselog(machine(), 2, " Planes Enabled: None\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Planes Enabled: R/W RGB/CI\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Planes Enabled: R/W RGBA\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Planes Enabled: R/W OLAY\n" ); - break; - case 0x04: - //verboselog(machine(), 2, " Planes Enabled: R/W PUP\n" ); - break; - case 0x05: - //verboselog(machine(), 2, " Planes Enabled: R/W CID\n" ); - break; - default: - //verboselog(machine(), 2, " Unknown Plane Enable Value\n" ); - break; - } - switch( ( data & 0x00000018 ) >> 3 ) - { - case 0x00: - //verboselog(machine(), 2, " Plane Draw Depth: 4 bits\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Plane Draw Depth: 8 bits\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Plane Draw Depth: 12 bits\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Plane Draw Depth: 32 bits\n" ); - break; - } - //verboselog(machine(), 2, " DBuf Source Buffer: %d\n", ( data & 0x00000020 ) >> 5 ); - //verboselog(machine(), 2, " GL Y Coordinates: %d\n", ( data & 0x00000040 ) >> 6 ); - //verboselog(machine(), 2, " Enable Pxl Packing: %d\n", ( data & 0x00000080 ) >> 7 ); - switch( ( data & 0x00000300 ) >> 8 ) - { - case 0x00: - //verboselog(machine(), 2, " HOSTRW Depth: 4 bits\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " HOSTRW Depth: 8 bits\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " HOSTRW Depth: 12 bits\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " HOSTRW Depth: 32 bits\n" ); - break; - } - //verboselog(machine(), 2, " DWord Transfers: %d\n", ( data & 0x00000400 ) >> 10 ); - //verboselog(machine(), 2, " Swap Endianness: %d\n", ( data & 0x00000800 ) >> 11 ); - //verboselog(machine(), 2, " Compare Src > Dest: %d\n", ( data & 0x00001000 ) >> 12 ); - //verboselog(machine(), 2, " Compare Src = Dest: %d\n", ( data & 0x00002000 ) >> 13 ); - //verboselog(machine(), 2, " Compare Src < Dest: %d\n", ( data & 0x00004000 ) >> 14 ); - //verboselog(machine(), 2, " RGB Mode Select: %d\n", ( data & 0x00008000 ) >> 15 ); - //verboselog(machine(), 2, " Enable Dithering: %d\n", ( data & 0x00010000 ) >> 16 ); - //verboselog(machine(), 2, " Enable Fast Clear: %d\n", ( data & 0x00020000 ) >> 17 ); - //verboselog(machine(), 2, " Enable Blending: %d\n", ( data & 0x00040000 ) >> 18 ); - switch( ( data & 0x00380000 ) >> 19 ) - { - case 0x00: - //verboselog(machine(), 2, " Src Blend Factor: 0\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Src Blend Factor: 1\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Src Blend Factor: Normalized Dest (or COLORBACK)\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Src Blend Factor: 1 - Normalized Dest (or COLORBACK)\n" ); - break; - case 0x04: - //verboselog(machine(), 2, " Src Blend Factor: Normalized Src\n" ); - break; - case 0x05: - //verboselog(machine(), 2, " Src Blend Factor: 1 - Normalized Src\n" ); - break; - default: - //verboselog(machine(), 2, " Unknown Src Blend Factor: %02x\n", ( data & 0x00380000 ) >> 19 ); - break; - } - switch( ( data & 0x01c00000 ) >> 22 ) - { - case 0x00: - //verboselog(machine(), 2, " Dest Blend Factor: 0\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Dest Blend Factor: 1\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Dest Blend Factor: Normalized Dest (or COLORBACK)\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Dest Blend Factor: 1 - Normalized Dest (or COLORBACK)\n" ); - break; - case 0x04: - //verboselog(machine(), 2, " Dest Blend Factor: Normalized Src\n" ); - break; - case 0x05: - //verboselog(machine(), 2, " Dest Blend Factor: 1 - Normalized Src\n" ); - break; - default: - //verboselog(machine(), 2, " Unknown Src Blend Factor: %02x\n", ( data & 0x00380000 ) >> 19 ); - break; - } - //verboselog(machine(), 2, " COLORBACK Dest Blend: %d\n", ( data & 0x02000000 ) >> 25 ); - //verboselog(machine(), 2, " Enable Pxl Prefetch: %d\n", ( data & 0x04000000 ) >> 26 ); - //verboselog(machine(), 2, " SFACTOR Src Alpha: %d\n", ( data & 0x08000000 ) >> 27 ); - switch( ( data & 0xf0000000 ) >> 28 ) - { - case 0x00: - //verboselog(machine(), 2, " Logical Op. Type: 0\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Logical Op. Type: Src & Dst\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Logical Op. Type: Src & ~Dst\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Logical Op. Type: Src\n" ); - break; - case 0x04: - //verboselog(machine(), 2, " Logical Op. Type: ~Src & Dst\n" ); - break; - case 0x05: - //verboselog(machine(), 2, " Logical Op. Type: Dst\n" ); - break; - case 0x06: - //verboselog(machine(), 2, " Logical Op. Type: Src ^ Dst\n" ); - break; - case 0x07: - //verboselog(machine(), 2, " Logical Op. Type: Src | Dst\n" ); - break; - case 0x08: - //verboselog(machine(), 2, " Logical Op. Type: ~(Src | Dst)\n" ); - break; - case 0x09: - //verboselog(machine(), 2, " Logical Op. Type: ~(Src ^ Dst)\n" ); - break; - case 0x0a: - //verboselog(machine(), 2, " Logical Op. Type: ~Dst\n" ); - break; - case 0x0b: - //verboselog(machine(), 2, " Logical Op. Type: Src | ~Dst\n" ); - break; - case 0x0c: - //verboselog(machine(), 2, " Logical Op. Type: ~Src\n" ); - break; - case 0x0d: - //verboselog(machine(), 2, " Logical Op. Type: ~Src | Dst\n" ); - break; - case 0x0e: - //verboselog(machine(), 2, " Logical Op. Type: ~(Src & Dst)\n" ); - break; - case 0x0f: - //verboselog(machine(), 2, " Logical Op. Type: 1\n" ); - break; - } - m_REX3.nDrawMode1 = data; -// if( offset >= ( 0x800 / 4 ) ) -// { -// DoREX3Command(); -// } - break; - case 0x0004/4: - //verboselog(machine(), 2, "REX3 Draw Mode 0 Write: %08x\n", data ); - switch( data & 0x00000003 ) - { - case 0x00: - //verboselog(machine(), 2, " Primitive Function: No Op\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Primitive Function: Read From FB\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Primitive Function: Draw To FB\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Primitive Function: Copy FB To FB\n" ); - break; - } - switch( ( data & 0x0000001c ) >> 2 ) - { - case 0x00: - //verboselog(machine(), 2, " Addressing Mode: Span/Point\n" ); - break; - case 0x01: - //verboselog(machine(), 2, " Addressing Mode: Block\n" ); - break; - case 0x02: - //verboselog(machine(), 2, " Addressing Mode: Bresenham Line, Integer Endpoints\n" ); - break; - case 0x03: - //verboselog(machine(), 2, " Addressing Mode: Bresenham Line, Fractional Endpoints\n" ); - break; - case 0x04: - //verboselog(machine(), 2, " Addressing Mode: AA Bresenham Line\n" ); - break; - default: - //verboselog(machine(), 2, " Unknown Addressing Mode: %02x\n", ( data & 0x0000001c ) >> 2 ); - break; - } - //verboselog(machine(), 2, " Iterator Setup: %d\n", ( data & 0x00000020 ) >> 5 ); - //verboselog(machine(), 2, " RGB/CI Draw Source: %d\n", ( data & 0x00000040 ) >> 6 ); - //verboselog(machine(), 2, " Alpha Draw Source: %d\n", ( data & 0x00000080 ) >> 7 ); - //verboselog(machine(), 2, " Stop On X: %d\n", ( data & 0x00000100 ) >> 8 ); - //verboselog(machine(), 2, " Stop On Y: %d\n", ( data & 0x00000200 ) >> 9 ); - //verboselog(machine(), 2, " Skip Start Point: %d\n", ( data & 0x00000400 ) >> 10 ); - //verboselog(machine(), 2, " Skip End Point: %d\n", ( data & 0x00000800 ) >> 11 ); - //verboselog(machine(), 2, " Enable Patterning: %d\n", ( data & 0x00001000 ) >> 12 ); - //verboselog(machine(), 2, " Enable Stippling: %d\n", ( data & 0x00002000 ) >> 13 ); - //verboselog(machine(), 2, " Stipple Advance: %d\n", ( data & 0x00004000 ) >> 14 ); - //verboselog(machine(), 2, " Limit Draw To 32px: %d\n", ( data & 0x00008000 ) >> 15 ); - //verboselog(machine(), 2, " Z Opaque Stipple %d\n", ( data & 0x00010000 ) >> 16 ); - //verboselog(machine(), 2, " LS Opaque Stipple: %d\n", ( data & 0x00020000 ) >> 17 ); - //verboselog(machine(), 2, " Enable Lin. Shade: %d\n", ( data & 0x00040000 ) >> 18 ); - //verboselog(machine(), 2, " Left-Right Only: %d\n", ( data & 0x00080000 ) >> 19 ); - //verboselog(machine(), 2, " Offset by XYMove: %d\n", ( data & 0x00100000 ) >> 20 ); - //verboselog(machine(), 2, " Enable CI Clamping: %d\n", ( data & 0x00200000 ) >> 21 ); - //verboselog(machine(), 2, " Enable End Filter: %d\n", ( data & 0x00400000 ) >> 22 ); - //verboselog(machine(), 2, " Enable Y+2 Stride: %d\n", ( data & 0x00800000 ) >> 23 ); - m_REX3.nDrawMode0 = data; - break; - case 0x0804/4: - //verboselog(machine(), 2, "REX3 Draw Mode 0 Write: %08x\n", data ); - m_REX3.nDrawMode0 = data; - break; - case 0x0008/4: - case 0x0808/4: - //verboselog(machine(), 2, "REX3 Line Stipple Mode Write: %08x\n", data ); - m_REX3.nLSMode = data & 0x0fffffff; - break; - case 0x000C/4: - case 0x080c/4: - //verboselog(machine(), 2, "REX3 Line Stipple Pattern Write: %08x\n", data ); - m_REX3.nLSPattern = data; - break; - case 0x0010/4: - case 0x0810/4: - //verboselog(machine(), 2, "REX3 Line Stipple Pattern (Save) Write: %08x\n", data ); - m_REX3.nLSPatSave = data; - break; - case 0x0014/4: - case 0x0814/4: - //verboselog(machine(), 2, "REX3 Pattern Register Write: %08x\n", data ); - m_REX3.nZPattern = data; - if (offset & 0x00000200) - { - DoREX3Command(); - } - break; - case 0x0018/4: - case 0x0818/4: - //verboselog(machine(), 2, "REX3 Opaque Pattern / Blendfunc Dest Color Write: %08x\n", data ); - m_REX3.nColorBack = data; - break; - case 0x001c/4: - case 0x081c/4: - //verboselog(machine(), 2, "REX3 VRAM Fastclear Color Write: %08x\n", data ); - m_REX3.nColorVRAM = data; - break; - case 0x0020/4: - case 0x0820/4: - //verboselog(machine(), 2, "REX3 AFUNCTION Reference Alpha Write: %08x\n", data ); - m_REX3.nAlphaRef = data & 0x000000ff; - break; - case 0x0024/4: - case 0x0824/4: - //verboselog(machine(), 2, "REX3 Stall GFIFO Write: %08x\n", data ); - break; - case 0x0028/4: - case 0x0828/4: - //verboselog(machine(), 2, "REX3 Screenmask 0 X Min/Max Write: %08x\n", data ); - m_REX3.nSMask0X = data; - break; - case 0x002c/4: - case 0x082c/4: - //verboselog(machine(), 2, "REX3 Screenmask 0 Y Min/Max Write: %08x\n", data ); - m_REX3.nSMask0Y = data; - break; - case 0x0030/4: - case 0x0830/4: - //verboselog(machine(), 2, "REX3 Line/Span Setup Write: %08x\n", data ); - m_REX3.nSetup = data; - break; - case 0x0034/4: - case 0x0834/4: - //verboselog(machine(), 2, "REX3 ZPattern Enable Write: %08x\n", data ); - m_REX3.nStepZ = data; - break; - case 0x0038/4: - case 0x0838/4: - //verboselog(machine(), 2, "REX3 Update LSPATTERN/LSRCOUNT\n" ); - m_REX3.nLSPattern = m_REX3.nLSPatSave; - break; - case 0x003c/4: - case 0x083c/4: - //verboselog(machine(), 2, "REX3 Update LSPATSAVE/LSRCNTSAVE\n" ); - m_REX3.nLSPatSave = m_REX3.nLSPattern; - break; - case 0x0100/4: - case 0x0900/4: - //verboselog(machine(), 2, "REX3 XStart Write: %08x\n", data ); - m_REX3.nXStart = data & ( 0x0000fffff << 7 ); - break; - case 0x0104/4: - case 0x0904/4: - //verboselog(machine(), 2, "REX3 YStart Write: %08x\n", data ); - m_REX3.nYStart = data & ( 0x0000fffff << 7 ); - break; - case 0x0108/4: - case 0x0908/4: - //verboselog(machine(), 2, "REX3 XEnd Write: %08x\n", data ); - m_REX3.nXEnd = data & ( 0x0000fffff << 7 ); - break; - case 0x010c/4: - case 0x090c/4: - //verboselog(machine(), 2, "REX3 YEnd Write: %08x\n", data ); - m_REX3.nYEnd = data & ( 0x0000fffff << 7 ); - break; - case 0x0110/4: - case 0x0910/4: - //verboselog(machine(), 2, "REX3 XSave Write: %08x\n", data ); - m_REX3.nXSave = data & 0x0000ffff; - m_REX3.nXStartI = m_REX3.nXSave & 0x0000ffff; - break; - case 0x0114/4: - case 0x0914/4: - //verboselog(machine(), 2, "REX3 XYMove Write: %08x\n", data ); - m_REX3.nXYMove = data; - if (offset & 0x00000200) - { - DoREX3Command(); - } - break; - case 0x0118/4: - case 0x0918/4: - //verboselog(machine(), 2, "REX3 Bresenham D Write: %08x\n", data ); - m_REX3.nBresD = data & 0x07ffffff; - break; - case 0x011c/4: - case 0x091c/4: - //verboselog(machine(), 2, "REX3 Bresenham S1 Write: %08x\n", data ); - m_REX3.nBresS1 = data & 0x0001ffff; - break; - case 0x0120/4: - case 0x0920/4: - //verboselog(machine(), 2, "REX3 Bresenham Octant & Incr1 Write: %08x\n", data ); - m_REX3.nBresOctInc1 = data & 0x070fffff; - break; - case 0x0124/4: - case 0x0924/4: - //verboselog(machine(), 2, "REX3 Bresenham Octant Rounding Mode & Incr2 Write: %08x\n", data ); - m_REX3.nBresRndInc2 = data & 0xff1fffff; - break; - case 0x0128/4: - case 0x0928/4: - //verboselog(machine(), 2, "REX3 Bresenham E1 Write: %08x\n", data ); - m_REX3.nBresE1 = data & 0x0000ffff; - break; - case 0x012c/4: - case 0x092c/4: - //verboselog(machine(), 2, "REX3 Bresenham S2 Write: %08x\n", data ); - m_REX3.nBresS2 = data & 0x03ffffff; - break; - case 0x0130/4: - case 0x0930/4: - //verboselog(machine(), 2, "REX3 AA Line Weight Table 1/2 Write: %08x\n", data ); - m_REX3.nAWeight0 = data; - break; - case 0x0134/4: - case 0x0934/4: - //verboselog(machine(), 2, "REX3 AA Line Weight Table 2/2 Write: %08x\n", data ); - m_REX3.nAWeight1 = data; - break; - case 0x0138/4: - case 0x0938/4: - //verboselog(machine(), 2, "REX3 GL XStart Write: %08x\n", data ); - m_REX3.nXStartF = data & ( 0x0000ffff << 7 ); - break; - case 0x013c/4: - case 0x093c/4: - //verboselog(machine(), 2, "REX3 GL YStart Write: %08x\n", data ); - m_REX3.nYStartF = data & ( 0x0000ffff << 7 ); - break; - case 0x0140/4: - case 0x0940/4: - //verboselog(machine(), 2, "REX3 GL XEnd Write: %08x\n", data ); - m_REX3.nXEndF = data & ( 0x0000ffff << 7 ); - break; - case 0x0144/4: - case 0x0944/4: - //verboselog(machine(), 2, "REX3 GL YEnd Write: %08x\n", data ); - m_REX3.nYEndF = data & ( 0x0000ffff << 7 ); - break; - case 0x0148/4: - case 0x0948/4: - //verboselog(machine(), 2, "REX3 XStart (integer) Write: %08x\n", data ); - m_REX3.nXStartI = data & 0x0000ffff; - m_REX3.nXSave = m_REX3.nXStartI; - m_REX3.nXStart = 0 | ( ( m_REX3.nXStartI & 0x0000ffff ) << 11 ); - break; - case 0x014c/4: - case 0x094c/4: - //verboselog(machine(), 2, "REX3 GL XEnd (copy) Write: %08x\n", data ); - m_REX3.nXEndF = data & ( 0x0000ffff << 7 ); - break; - case 0x0150/4: - case 0x0950/4: - //verboselog(machine(), 2, "REX3 XYStart (integer) Write: %08x\n", data ); - m_REX3.nXYStartI = data; - m_REX3.nXStartI = ( data & 0xffff0000 ) >> 16; - m_REX3.nXSave = m_REX3.nXStartI; - m_REX3.nXStart = 0 | ( ( m_REX3.nXYStartI & 0xffff0000 ) >> 5 ); - m_REX3.nYStart = 0 | ( ( m_REX3.nXYStartI & 0x0000ffff ) << 11 ); - break; - case 0x0154/4: - case 0x0954/4: - //verboselog(machine(), 2, "REX3 XYEnd (integer) Write: %08x\n", data ); - m_REX3.nXYEndI = data; - m_REX3.nXEnd = 0 | ( ( m_REX3.nXYEndI & 0xffff0000 ) >> 5 ); - m_REX3.nYEnd = 0 | ( ( m_REX3.nXYEndI & 0x0000ffff ) << 11 ); - if (offset & 0x00000200) - { - DoREX3Command(); - } - break; - case 0x0158/4: - case 0x0958/4: - //verboselog(machine(), 2, "REX3 XStartEnd (integer) Write: %08x\n", data ); - m_REX3.nXStartEndI = data; - m_REX3.nXYEndI = ( m_REX3.nXYEndI & 0x0000ffff ) | ( ( m_REX3.nXStartEndI & 0x0000ffff ) << 16 ); - m_REX3.nXYStartI = ( m_REX3.nXYStartI & 0x0000ffff ) | ( m_REX3.nXStartEndI & 0xffff0000 ); - m_REX3.nXSave = m_REX3.nXStartI; - m_REX3.nXStart = 0 | ( ( m_REX3.nXStartEndI & 0xffff0000 ) >> 5 ); - m_REX3.nXEnd = 0 | ( ( m_REX3.nXStartEndI & 0x0000ffff ) << 11 ); - break; - case 0x0200/4: - case 0x0a00/4: - //verboselog(machine(), 2, "REX3 Red/CI Full State Write: %08x\n", data ); - m_REX3.nColorRed = data & 0x00ffffff; - break; - case 0x0204/4: - case 0x0a04/4: - //verboselog(machine(), 2, "REX3 Alpha Full State Write: %08x\n", data ); - m_REX3.nColorAlpha = data & 0x000fffff; - break; - case 0x0208/4: - case 0x0a08/4: - //verboselog(machine(), 2, "REX3 Green Full State Write: %08x\n", data ); - m_REX3.nColorGreen = data & 0x000fffff; - break; - case 0x020c/4: - case 0x0a0c/4: - //verboselog(machine(), 2, "REX3 Blue Full State Write: %08x\n", data ); - m_REX3.nColorBlue = data & 0x000fffff; - break; - case 0x0210/4: - case 0x0a10/4: - //verboselog(machine(), 2, "REX3 Red/CI Slope Write: %08x\n", data ); - data &= 0x807fffff; - switch( data & 0x80000000 ) - { - case 0x00000000: - nTemp = data & 0x007fffff; - break; - case 0x80000000: - nTemp = 0x00800000 - ( data & 0x007fffff ); - nTemp |= 0x00800000; - break; - } - m_REX3.nSlopeRed = nTemp; - break; - case 0x0214/4: - case 0x0a14/4: - //verboselog(machine(), 2, "REX3 Alpha Slope Write: %08x\n", data ); - data &= 0x8007ffff; - switch( data & 0x80000000 ) - { - case 0x00000000: - nTemp = data & 0x0007ffff; - break; - case 0x80000000: - nTemp = 0x00080000 - ( data & 0x0007ffff ); - nTemp |= 0x00080000; - break; - } - m_REX3.nSlopeAlpha = nTemp; - break; - case 0x0218/4: - case 0x0a18/4: - //verboselog(machine(), 2, "REX3 Green Slope Write: %08x\n", data ); - data &= 0x8007ffff; - switch( data & 0x80000000 ) - { - case 0x00000000: - nTemp = data & 0x0007ffff; - break; - case 0x80000000: - nTemp = 0x00080000 - ( data & 0x0007ffff ); - nTemp |= 0x00080000; - break; - } - m_REX3.nSlopeGreen = nTemp; - break; - case 0x021c/4: - case 0x0a1c/4: - //verboselog(machine(), 2, "REX3 Blue Slope Write: %08x\n", data ); - data &= 0x8007ffff; - switch( data & 0x80000000 ) - { - case 0x00000000: - nTemp = data & 0x0007ffff; - break; - case 0x80000000: - nTemp = 0x00080000 - ( data & 0x0007ffff ); - nTemp |= 0x00080000; - break; - } - m_REX3.nSlopeBlue = nTemp; - break; - case 0x0220/4: - case 0x0a20/4: - //verboselog(machine(), 2, "REX3 Write Mask Write: %08x\n", data ); - m_REX3.nWriteMask = data & 0x00ffffff; - break; - case 0x0224/4: - case 0x0a24/4: - //verboselog(machine(), 2, "REX3 Packed Color Fractions Write: %08x\n", data ); - m_REX3.nZeroFract = data; - break; - case 0x0228/4: - case 0x0a28/4: - //verboselog(machine(), 2, "REX3 Color Index Zeros Overflow Write: %08x\n", data ); - m_REX3.nZeroOverflow = data; - break; - case 0x022c/4: - case 0x0a2c/4: - //verboselog(machine(), 2, "REX3 Red/CI Slope (copy) Write: %08x\n", data ); - m_REX3.nSlopeRed = data; - break; - case 0x0230/4: - case 0x0a30/4: - //verboselog(machine(), 3, "REX3 Host Data Port MSW Write: %08x\n", data ); - m_REX3.nHostDataPortMSW = data; - if (offset & 0x00000200) - { - DoREX3Command(); - } - break; - case 0x0234/4: - case 0x0a34/4: - //verboselog(machine(), 2, "REX3 Host Data Port LSW Write: %08x\n", data ); - m_REX3.nHostDataPortLSW = data; - break; - case 0x0238/4: - case 0x0a38/4: - //verboselog(machine(), 2, "REX3 Display Control Bus Mode Write: %08x\n", data ); - switch( data & 0x00000003 ) - { - case 0x00: - //verboselog(machine(), 2, " Transfer Width: 4 bytes\n" ); - m_REX3.nXFerWidth = 4; - break; - case 0x01: - //verboselog(machine(), 2, " Transfer Width: 1 bytes\n" ); - m_REX3.nXFerWidth = 1; - break; - case 0x02: - //verboselog(machine(), 2, " Transfer Width: 2 bytes\n" ); - m_REX3.nXFerWidth = 2; - break; - case 0x03: - //verboselog(machine(), 2, " Transfer Width: 3 bytes\n" ); - m_REX3.nXFerWidth = 3; - break; - } - //verboselog(machine(), 2, " DCB Reg Select Adr: %d\n", ( data & 0x00000070 ) >> 4 ); - //verboselog(machine(), 2, " DCB Slave Address: %d\n", ( data & 0x00000780 ) >> 7 ); -// //verboselog(machine(), 2, " Use Sync XFer ACK: %d\n", ( data & 0x00000800 ) >> 11 ); -// //verboselog(machine(), 2, " Use Async XFer ACK: %d\n", ( data & 0x00001000 ) >> 12 ); -// //verboselog(machine(), 2, " GIO CLK Cycle Width: %d\n", ( data & 0x0003e000 ) >> 13 ); -// //verboselog(machine(), 2, " GIO CLK Cycle Hold: %d\n", ( data & 0x007c0000 ) >> 18 ); -// //verboselog(machine(), 2, " GIO CLK Cycle Setup: %d\n", ( data & 0x0f800000 ) >> 23 ); -// //verboselog(machine(), 2, " Swap Byte Ordering: %d\n", ( data & 0x10000000 ) >> 28 ); - m_REX3.nDCBRegSelect = ( data & 0x00000070 ) >> 4; - m_REX3.nDCBSlvSelect = ( data & 0x00000780 ) >> 7; - m_REX3.nDCBMode = data & 0x1fffffff; - break; - case 0x0240/4: - case 0x0a40/4: - m_REX3.nDCBDataMSW = data; - switch( m_REX3.nDCBSlvSelect ) - { - case 0x00: - vc2_w(space, 0, data, mem_mask); - break; - case 0x01: - cmap0_w(space, 0, data, mem_mask); - break; - case 0x04: - xmap0_w(space, 0, data, mem_mask); - xmap1_w(space, 0, data, mem_mask); - break; - case 0x05: - xmap0_w(space, 0, data, mem_mask); - break; - case 0x06: - xmap1_w(space, 0, data, mem_mask); - break; - default: - //verboselog(machine(), 2, "REX3 Display Control Bus Data MSW Write: %08x\n", data ); - break; - } - break; - case 0x0244/4: - case 0x0a44/4: - //verboselog(machine(), 2, "REX3 Display Control Bus Data LSW Write: %08x\n", data ); - m_REX3.nDCBDataLSW = data; - break; - case 0x1300/4: - //verboselog(machine(), 2, "REX3 Screenmask 1 X Min/Max Write: %08x\n", data ); - m_REX3.nSMask1X = data; - break; - case 0x1304/4: - //verboselog(machine(), 2, "REX3 Screenmask 1 Y Min/Max Write: %08x\n", data ); - m_REX3.nSMask1Y = data; - break; - case 0x1308/4: - //verboselog(machine(), 2, "REX3 Screenmask 2 X Min/Max Write: %08x\n", data ); - m_REX3.nSMask2X = data; - break; - case 0x130c/4: - //verboselog(machine(), 2, "REX3 Screenmask 2 Y Min/Max Write: %08x\n", data ); - m_REX3.nSMask2Y = data; - break; - case 0x1310/4: - //verboselog(machine(), 2, "REX3 Screenmask 3 X Min/Max Write: %08x\n", data ); - m_REX3.nSMask3X = data; - break; - case 0x1314/4: - //verboselog(machine(), 2, "REX3 Screenmask 3 Y Min/Max Write: %08x\n", data ); - m_REX3.nSMask3Y = data; - break; - case 0x1318/4: - //verboselog(machine(), 2, "REX3 Screenmask 4 X Min/Max Write: %08x\n", data ); - m_REX3.nSMask4X = data; - break; - case 0x131c/4: - //verboselog(machine(), 2, "REX3 Screenmask 4 Y Min/Max Write: %08x\n", data ); - m_REX3.nSMask4Y = data; - break; - case 0x1320/4: - //verboselog(machine(), 2, "REX3 Top of Screen Scanline Write: %08x\n", data ); - m_REX3.nTopScanline = data & 0x000003ff; - break; - case 0x1324/4: - //verboselog(machine(), 2, "REX3 Clipping Mode Write: %08x\n", data ); - m_REX3.nXYWin = data; - break; - case 0x1328/4: - //verboselog(machine(), 2, "REX3 Clipping Mode Write: %08x\n", data ); - m_REX3.nClipMode = data & 0x00001fff; - break; - case 0x132c/4: - //verboselog(machine(), 2, "Request GFIFO Stall\n" ); - break; - case 0x1330/4: - //verboselog(machine(), 2, "REX3 Config Write: %08x\n", data ); - m_REX3.nConfig = data & 0x001fffff; - break; - case 0x1340/4: - //verboselog(machine(), 2, "Reset DCB Bus and Flush BFIFO\n" ); - break; - default: - //verboselog(machine(), 2, "Unknown REX3 Write: %08x (%08x): %08x\n", 0xbf0f0000 + ( offset << 2 ), mem_mask, data ); - break; - } -} diff --git a/src/mess/video/newport.h b/src/mess/video/newport.h deleted file mode 100644 index 16ee86065fb..00000000000 --- a/src/mess/video/newport.h +++ /dev/null @@ -1,163 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz -/* - SGI "Newport" graphics board used in the Indy and some Indigo2s - -*/ - -#ifndef __VIDHRDW_NEWPORT__ -#define __VIDHRDW_NEWPORT__ - -struct VC2_t -{ - UINT16 nRegister[0x21]; - UINT16 nRAM[0x8000]; - UINT8 nRegIdx; - UINT16 nRegData; -}; - - -struct XMAP_t -{ - UINT32 nRegister[0x08]; - UINT32 nModeTable[0x20]; -}; - -struct REX3_t -{ - UINT32 nDrawMode1; - UINT32 nDrawMode0; - UINT32 nLSMode; - UINT32 nLSPattern; - UINT32 nLSPatSave; - UINT32 nZPattern; - UINT32 nColorBack; - UINT32 nColorVRAM; - UINT32 nAlphaRef; - //UINT32 nStall0; - UINT32 nSMask0X; - UINT32 nSMask0Y; - UINT32 nSetup; - UINT32 nStepZ; - UINT32 nXStart; - UINT32 nYStart; - UINT32 nXEnd; - UINT32 nYEnd; - UINT32 nXSave; - UINT32 nXYMove; - UINT32 nBresD; - UINT32 nBresS1; - UINT32 nBresOctInc1; - UINT32 nBresRndInc2; - UINT32 nBresE1; - UINT32 nBresS2; - UINT32 nAWeight0; - UINT32 nAWeight1; - UINT32 nXStartF; - UINT32 nYStartF; - UINT32 nXEndF; - UINT32 nYEndF; - UINT32 nXStartI; - //UINT32 nYEndF1; - UINT32 nXYStartI; - UINT32 nXYEndI; - UINT32 nXStartEndI; - UINT32 nColorRed; - UINT32 nColorAlpha; - UINT32 nColorGreen; - UINT32 nColorBlue; - UINT32 nSlopeRed; - UINT32 nSlopeAlpha; - UINT32 nSlopeGreen; - UINT32 nSlopeBlue; - UINT32 nWriteMask; - UINT32 nZeroFract; - UINT32 nZeroOverflow; - //UINT32 nColorIndex; - UINT32 nHostDataPortMSW; - UINT32 nHostDataPortLSW; - UINT32 nDCBMode; - UINT32 nDCBRegSelect; - UINT32 nDCBSlvSelect; - UINT32 nDCBDataMSW; - UINT32 nDCBDataLSW; - UINT32 nSMask1X; - UINT32 nSMask1Y; - UINT32 nSMask2X; - UINT32 nSMask2Y; - UINT32 nSMask3X; - UINT32 nSMask3Y; - UINT32 nSMask4X; - UINT32 nSMask4Y; - UINT32 nTopScanline; - UINT32 nXYWin; - UINT32 nClipMode; - UINT32 nConfig; - UINT32 nStatus; - UINT8 nXFerWidth; -#if 0 - UINT32 nCurrentX; - UINT32 nCurrentY; -#endif - UINT32 nKludge_SkipLine; -}; - - -struct CMAP_t -{ - UINT16 nPaletteIndex; - UINT32 nPalette[0x10000]; -}; - - -class newport_video_device : public device_t -{ -public: - newport_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~newport_video_device() {} - - - DECLARE_READ32_MEMBER( rex3_r ); - DECLARE_WRITE32_MEMBER( rex3_w ); - - UINT32 screen_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); - -private: - // internal state - - DECLARE_READ32_MEMBER( cmap0_r ); - DECLARE_WRITE32_MEMBER( cmap0_w ); - DECLARE_READ32_MEMBER( cmap1_r ); - DECLARE_READ32_MEMBER( xmap0_r ); - DECLARE_WRITE32_MEMBER( xmap0_w ); - DECLARE_READ32_MEMBER( xmap1_r ); - DECLARE_WRITE32_MEMBER( xmap1_w ); - DECLARE_READ32_MEMBER( vc2_r ); - DECLARE_WRITE32_MEMBER( vc2_w ); - void DoREX3Command(); - - VC2_t m_VC2; - XMAP_t m_XMAP0; - XMAP_t m_XMAP1; - REX3_t m_REX3; - UINT32 *m_base; - UINT8 m_nDrawGreen; - CMAP_t m_CMAP0; -}; - - - -#define MCFG_NEWPORT_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, NEWPORT_VIDEO, 0) - - -extern const device_type NEWPORT_VIDEO; - - -#endif diff --git a/src/mess/video/nick.c b/src/mess/video/nick.c deleted file mode 100644 index afb16ff815b..00000000000 --- a/src/mess/video/nick.c +++ /dev/null @@ -1,1055 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Intelligent Designs NICK emulation - -**********************************************************************/ - -#include "nick.h" - - - -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define LOG 0 - -/* colour mode types */ -#define NICK_2_COLOUR_MODE 0 -#define NICK_4_COLOUR_MODE 1 -#define NICK_16_COLOUR_MODE 2 -#define NICK_256_COLOUR_MODE 3 - -/* Display mode types */ -#define NICK_VSYNC_MODE 0 -#define NICK_PIXEL_MODE 1 -#define NICK_ATTR_MODE 2 -#define NICK_CH256_MODE 3 -#define NICK_CH128_MODE 4 -#define NICK_CH64_MODE 5 -#define NICK_UNUSED_MODE 6 -#define NICK_LPIXEL_MODE 7 - -/* MODEBYTE defines */ -#define NICK_MB_VIRQ (1<<7) -#define NICK_MB_VRES (1<<4) -#define NICK_MB_LPT_RELOAD (1<<0) - -/* Left margin defines */ -#define NICK_LM_MSBALT (1<<7) -#define NICK_LM_LSBALT (1<<6) - -/* Right margin defines */ -#define NICK_RM_ALTIND1 (1<<7) -#define NICK_RM_ALTIND0 (1<<6) - -/* useful macros */ -#define NICK_GET_LEFT_MARGIN(x) (x & 0x03f) -#define NICK_GET_RIGHT_MARGIN(x) (x & 0x03f) -#define NICK_GET_DISPLAY_MODE(x) ((x>>1) & 0x07) -#define NICK_GET_COLOUR_MODE(x) ((x>>5) & 0x03) - -#define NICK_RELOAD_LPT(x) (x & 0x080) -#define NICK_CLOCK_LPT(x) (x & 0x040) - -/* Macros to generate memory address is CHx modes */ -/* x = LD2, y = buf1 */ -#define ADDR_CH256(x,y) (((x & 0x0ff)<<8) | (y & 0x0ff)) -#define ADDR_CH128(x,y) (((x & 0x01ff)<<7) | (y & 0x07f)) -#define ADDR_CH64(x,y) (((x & 0x03ff)<<6) | (y & 0x03f)) - -/* No of highest resolution pixels per "clock" */ -#define NICK_PIXELS_PER_CLOCK 16 - -/* "clocks" per line */ -#define NICK_TOTAL_CLOCKS_PER_LINE 64 - - - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -const device_type NICK = &device_creator; - - -DEVICE_ADDRESS_MAP_START( vram_map, 8, nick_device ) - AM_RANGE(0x0000, 0xffff) AM_READWRITE(vram_r, vram_w) -ADDRESS_MAP_END - -DEVICE_ADDRESS_MAP_START( vio_map, 8, nick_device ) - AM_RANGE(0x00, 0x00) AM_WRITE(fixbias_w) - AM_RANGE(0x01, 0x01) AM_WRITE(border_w) - AM_RANGE(0x02, 0x02) AM_WRITE(lpl_w) - AM_RANGE(0x03, 0x03) AM_WRITE(lph_w) -ADDRESS_MAP_END - - -static ADDRESS_MAP_START( nick_map, AS_0, 8, nick_device ) - AM_RANGE(0x0000, 0xffff) AM_RAM -ADDRESS_MAP_END - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// nick_device - constructor -//------------------------------------------------- - -nick_device::nick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, NICK, "NICK", tag, owner, clock, "nick", __FILE__), - device_memory_interface(mconfig, *this), - device_video_interface(mconfig, *this), - m_space_config("vram", ENDIANNESS_LITTLE, 8, 16, 0, *ADDRESS_MAP_NAME(nick_map)), - m_write_virq(*this), - horizontal_clock(0), - m_scanline_count(0), - m_FIXBIAS(0), - m_BORDER(0), - m_LPL(0), - m_LPH(0), - m_LD1(0), - m_LD2(0), - m_virq(CLEAR_LINE) -{ - memset(&m_LPT, 0x00, sizeof(m_LPT)); -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void nick_device::device_start() -{ - m_screen->register_screen_bitmap(m_bitmap); - calc_visible_clocks(ENTERPRISE_SCREEN_WIDTH); - - // initialize palette - initialize_palette(); - - // resolve callbacks - m_write_virq.resolve_safe(); - - // allocate timers - m_timer_scanline = timer_alloc(); - m_timer_scanline->adjust(m_screen->time_until_pos(0, 0), 0, m_screen->scan_period()); - - // state saving - save_item(NAME(m_scanline_count)); - save_item(NAME(m_FIXBIAS)); - save_item(NAME(m_BORDER)); - save_item(NAME(m_LPL)); - save_item(NAME(m_LPH)); - save_item(NAME(m_LD1)); - save_item(NAME(m_LD2)); - save_item(NAME(m_LPT.SC)); - save_item(NAME(m_LPT.MB)); - save_item(NAME(m_LPT.LM)); - save_item(NAME(m_LPT.RM)); - save_item(NAME(m_LPT.LD1L)); - save_item(NAME(m_LPT.LD1H)); - save_item(NAME(m_LPT.LD2L)); - save_item(NAME(m_LPT.LD2H)); - save_item(NAME(m_LPT.COL)); - save_item(NAME(m_dest_pos)); - save_item(NAME(m_dest_max_pos)); - save_item(NAME(m_reg)); - save_item(NAME(m_first_visible_clock)); - save_item(NAME(m_last_visible_clock)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void nick_device::device_reset() -{ - m_write_virq(CLEAR_LINE); - m_virq = 0; - - m_scanline_count = 0; -} - - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- - -void nick_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - int scanline = m_screen->vpos(); - - if (scanline < ENTERPRISE_SCREEN_HEIGHT) - { - /* set write address for line */ - m_dest = &m_bitmap.pix32(scanline); - m_dest_pos = 0; - m_dest_max_pos = m_bitmap.width(); - - /* write line */ - do_line(); - } -} - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -const address_space_config *nick_device::memory_space_config(address_spacenum spacenum) const -{ - return (spacenum == 0) ? &m_space_config : NULL; -} - - -//------------------------------------------------- -// update_screen - update screen -//------------------------------------------------- - -UINT32 nick_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - - return 0; -} - - -//------------------------------------------------- -// vram_r - video RAM read -//------------------------------------------------- - -READ8_MEMBER( nick_device::vram_r ) -{ - return this->space().read_byte(offset); -} - - -//------------------------------------------------- -// vram_w - video RAM write -//------------------------------------------------- - -WRITE8_MEMBER( nick_device::vram_w ) -{ - this->space().write_byte(offset, data); -} - - -//------------------------------------------------- -// fixbias_w - -//------------------------------------------------- - -WRITE8_MEMBER( nick_device::fixbias_w ) -{ - m_FIXBIAS = data; -} - - -//------------------------------------------------- -// border_w - -//------------------------------------------------- - -WRITE8_MEMBER( nick_device::border_w ) -{ - m_BORDER = data; -} - - -//------------------------------------------------- -// lpl_w - -//------------------------------------------------- - -WRITE8_MEMBER( nick_device::lpl_w ) -{ - m_LPL = m_reg[2] = data; - - update_lpt(); -} - - -//------------------------------------------------- -// lph_w - -//------------------------------------------------- - -WRITE8_MEMBER( nick_device::lph_w ) -{ - m_LPH = m_reg[3] = data; - - update_lpt(); -} - - -//------------------------------------------------- -// initialize_palette - -//------------------------------------------------- - -void nick_device::initialize_palette() -{ - const int resistances_rg[] = { (int) RES_R(470), (int) RES_R(220), (int) RES_R(100) }; - const int resistances_b[] = { (int) RES_R(220), (int) RES_R(82) }; - - double color_weights_rg[3], color_weights_b[2]; - - compute_resistor_weights(0, 0xff, -1.0, - 3, resistances_rg, color_weights_rg, 0, 0, - 2, resistances_b, color_weights_b, 0, 0, - 0, 0, 0, 0, 0); - - for (int i = 0; i < 256; i++) - { - /* - - bit description - - PC0 100R -- RED - PC1 100R -- GREEN - PC2 82R -- BLUE - PC3 220R -- RED - PC4 220R -- GREEN - PC5 220R -- BLUE - PC6 470R -- RED - PC7 470R -- GREEN - - */ - - int ra = BIT(i, 0); - int rb = BIT(i, 3); - int rc = BIT(i, 6); - - int ga = BIT(i, 1); - int gb = BIT(i, 4); - int gc = BIT(i, 7); - - int ba = BIT(i, 2); - int bb = BIT(i, 5); - - UINT8 r = combine_3_weights(color_weights_rg, rc, rb, ra); - UINT8 g = combine_3_weights(color_weights_rg, gc, gb, ga); - UINT8 b = combine_2_weights(color_weights_b, bb, ba); - - m_palette[i] = rgb_t(r, g, b); - } - - for (int i = 0; i < 256; i++) - { - int pen_index; - - pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1); - m_pen_idx_4col[i] = pen_index; - - pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1) | (BIT(i, 5) << 2) | (BIT(i, 1) << 3); - m_pen_idx_16col[i] = pen_index; - } -} - -// MESS specific -/* 8-bit pixel write! */ -void nick_device::write_pixel(int ci) -{ - if (m_dest_pos < m_dest_max_pos) - { - m_dest[m_dest_pos++] = m_palette[ci]; - } -} - -/* we align based on the clocks */ -void nick_device::calc_visible_clocks(int width) -{ - /* number of clocks we can see */ - int no_visible_clocks = width / NICK_PIXELS_PER_CLOCK; - m_first_visible_clock = (NICK_TOTAL_CLOCKS_PER_LINE - no_visible_clocks) >> 1; - m_last_visible_clock = m_first_visible_clock + no_visible_clocks; -} - - -/* write border colour */ -void nick_device::write_border(int clocks) -{ - int col_index = m_BORDER; - - for (int i = 0; i < (clocks << 4); i++) - write_pixel(col_index); -} - - -void nick_device::do_left_margin() -{ - UINT8 left = NICK_GET_LEFT_MARGIN(m_LPT.LM); - - if (left > m_first_visible_clock) - { - /* some of the left margin is visible */ - UINT8 left_visible = left - m_first_visible_clock; - - /* render the border */ - write_border(left_visible); - } -} - -void nick_device::do_right_margin() -{ - UINT8 right = NICK_GET_RIGHT_MARGIN(m_LPT.RM); - - if (right < m_last_visible_clock) - { - /* some of the right margin is visible */ - UINT8 right_visible = m_last_visible_clock - right; - - /* render the border */ - write_border(right_visible); - } -} - -int nick_device::get_color_index(int pen_index) -{ - if (pen_index & 0x08) - return ((m_FIXBIAS & 0x01f) << 3) | (pen_index & 0x07); - else - return m_LPT.COL[pen_index]; -} - -void nick_device::write_pixels2color(UINT8 pen0, UINT8 pen1, UINT8 data_byte) -{ - int col_index[2]; - int pen_index; - UINT8 data = data_byte; - - col_index[0] = get_color_index(pen0); - col_index[1] = get_color_index(pen1); - - for (int i = 0; i < 8; i++) - { - pen_index = col_index[BIT(data, 7)]; - write_pixel(pen_index); - data <<= 1; - } -} - -void nick_device::write_pixels2color_lpixel(UINT8 pen0, UINT8 pen1, UINT8 data_byte) -{ - int col_index[2]; - int pen_index; - UINT8 data = data_byte; - - col_index[0] = get_color_index(pen0); - col_index[1] = get_color_index(pen1); - - for (int i = 0; i < 8; i++) - { - pen_index = col_index[BIT(data, 7)]; - write_pixel(pen_index); - write_pixel(pen_index); - data <<= 1; - } -} - - -void nick_device::write_pixels(UINT8 data_byte, UINT8 char_idx) -{ - /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ - int pen_idx; - /* Col index = EP colour value */ - int pal_idx; - UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); - UINT8 data = data_byte; - - switch (color_mode) - { - case NICK_2_COLOUR_MODE: - { - int pen_offs = 0; - - /* do before displaying byte */ - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - if (data & 0x080) - { - pen_offs |= 2; - } - - data &=~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - if (data & 0x001) - { - pen_offs |= 4; - } - - data &=~0x01; - } - - if (m_LPT.RM & NICK_RM_ALTIND1) - { - if (char_idx & 0x080) - { - pen_offs |= 0x02; - } - } - -#if 0 - if (m_LPT.RM & NICK_RM_ALTIND0) - { - if (data & 0x040) - { - pen_offs |= 0x04; - } - } -#endif - - - write_pixels2color(pen_offs, (pen_offs | 0x01), data); - } - break; - - case NICK_4_COLOUR_MODE: - { - //osd_printf_info("4 colour\r\n"); - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - for (int i = 0; i < 4; i++) - { - pen_idx = m_pen_idx_4col[data]; - pal_idx = m_LPT.COL[pen_idx & 0x03]; - - write_pixel(pal_idx); - write_pixel(pal_idx); - - data <<= 1; - } - } - break; - - case NICK_16_COLOUR_MODE: - { - //osd_printf_info("16 colour\r\n"); - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - for (int i = 0; i < 2; i++) - { - pen_idx = m_pen_idx_16col[data]; - - pal_idx = get_color_index(pen_idx); - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - data <<= 1; - } - } - break; - - case NICK_256_COLOUR_MODE: - { - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - pal_idx = data; - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - - } - break; - } -} - -void nick_device::write_pixels_lpixel(UINT8 data_byte, UINT8 char_idx) -{ - /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ - int pen_idx; - /* Col index = EP colour value */ - int pal_idx; - UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); - UINT8 data = data_byte; - - switch (color_mode) - { - case NICK_2_COLOUR_MODE: - { - int pen_offs = 0; - - /* do before displaying byte */ - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - if (data & 0x080) - { - pen_offs |= 2; - } - - data &=~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - if (data & 0x001) - { - pen_offs |= 4; - } - - data &=~0x01; - } - - if (m_LPT.RM & NICK_RM_ALTIND1) - { - if (char_idx & 0x080) - { - pen_offs |= 0x02; - } - } - -#if 0 - if (m_LPT.RM & NICK_RM_ALTIND0) - { - if (data & 0x040) - { - pen_offs |= 0x04; - } - } -#endif - - - write_pixels2color_lpixel(pen_offs, (pen_offs | 0x01), data); - } - break; - - case NICK_4_COLOUR_MODE: - { - //osd_printf_info("4 colour\r\n"); - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - for (int i = 0; i < 4; i++) - { - pen_idx = m_pen_idx_4col[data]; - pal_idx = m_LPT.COL[pen_idx & 0x03]; - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - data <<= 1; - } - } - break; - - case NICK_16_COLOUR_MODE: - { - //osd_printf_info("16 colour\r\n"); - - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - for (int i = 0; i < 2; i++) - { - pen_idx = m_pen_idx_16col[data]; - pal_idx = get_color_index(pen_idx); - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - data <<= 1; - } - } - break; - - case NICK_256_COLOUR_MODE: - { - /* left margin attributes */ - if (m_LPT.LM & NICK_LM_MSBALT) - { - data &= ~0x080; - } - - if (m_LPT.LM & NICK_LM_LSBALT) - { - data &= ~0x01; - } - - - pal_idx = data; - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - write_pixel(pal_idx); - - - } - break; - } -} - - -void nick_device::do_pixel(int clocks_visible) -{ - UINT8 buf1, buf2; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - - buf2 = space().read_byte(m_LD1); - m_LD1++; - - write_pixels(buf1, buf1); - write_pixels(buf2, buf1); - } -} - - -void nick_device::do_lpixel(int clocks_visible) -{ - UINT8 buf1; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - - write_pixels_lpixel(buf1, buf1); - } -} - -void nick_device::do_attr(int clocks_visible) -{ - UINT8 buf1, buf2; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - - buf2 = space().read_byte(m_LD2); - m_LD2++; - - { - UINT8 bg_color = ((buf1 >> 4) & 0x0f); - UINT8 fg_color = (buf1 & 0x0f); - - write_pixels2color_lpixel(bg_color, fg_color, buf2); - } - } -} - -void nick_device::do_ch256(int clocks_visible) -{ - UINT8 buf1, buf2; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - buf2 = space().read_byte(ADDR_CH256(m_LD2, buf1)); - - write_pixels_lpixel(buf2, buf1); - } -} - -void nick_device::do_ch128(int clocks_visible) -{ - UINT8 buf1, buf2; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - buf2 = space().read_byte(ADDR_CH128(m_LD2, buf1)); - - write_pixels_lpixel(buf2, buf1); - } -} - -void nick_device::do_ch64(int clocks_visible) -{ - UINT8 buf1, buf2; - - for (int i = 0; i < clocks_visible; i++) - { - buf1 = space().read_byte(m_LD1); - m_LD1++; - buf2 = space().read_byte(ADDR_CH64(m_LD2, buf1)); - - write_pixels_lpixel(buf2, buf1); - } -} - - -void nick_device::do_display() -{ - LPT_ENTRY *pLPT = &m_LPT; - UINT8 clocks_visible; - UINT8 right_margin = NICK_GET_RIGHT_MARGIN(pLPT->RM); - UINT8 left_margin = NICK_GET_LEFT_MARGIN(pLPT->LM); - - clocks_visible = right_margin - left_margin; - - if (clocks_visible) - { - /* get display mode */ - UINT8 display_mode = NICK_GET_DISPLAY_MODE(pLPT->MB); - - if (m_scanline_count == 0) // || - //((pLPT->MB & NICK_MB_VRES)==0)) - { - /* doing first line */ - /* reload LD1, and LD2 (if necessary) regardless of display mode */ - m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); - - if ((display_mode != NICK_LPIXEL_MODE) && (display_mode != NICK_PIXEL_MODE)) - { - /* lpixel and pixel modes don't use LD2 */ - m_LD2 = (pLPT->LD2L & 0xff) | ((pLPT->LD2H & 0xff) << 8); - } - } - else - { - /* not first line */ - switch (display_mode) - { - case NICK_ATTR_MODE: - { - /* reload LD1 */ - m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); - } - break; - - case NICK_CH256_MODE: - case NICK_CH128_MODE: - case NICK_CH64_MODE: - { - /* reload LD1 */ - m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); - m_LD2++; - } - break; - - default: - break; - } - } - - switch (display_mode) - { - case NICK_PIXEL_MODE: - { - do_pixel(clocks_visible); - } - break; - - case NICK_ATTR_MODE: - { - //osd_printf_info("attr mode\r\n"); - do_attr(clocks_visible); - } - break; - - case NICK_CH256_MODE: - { - //osd_printf_info("ch256 mode\r\n"); - do_ch256(clocks_visible); - } - break; - - case NICK_CH128_MODE: - { - do_ch128(clocks_visible); - } - break; - - case NICK_CH64_MODE: - { - //osd_printf_info("ch64 mode\r\n"); - do_ch64(clocks_visible); - } - break; - - case NICK_LPIXEL_MODE: - { - do_lpixel(clocks_visible); - } - break; - - default: - break; - } - } -} - -void nick_device::update_lpt() -{ - UINT16 CurLPT = (m_LPL & 0x0ff) | ((m_LPH & 0x0f) << 8); - CurLPT++; - m_LPL = CurLPT & 0x0ff; - m_LPH = (m_LPH & 0x0f0) | ((CurLPT >> 8) & 0x0f); -} - - -void nick_device::reload_lpt() -{ - /* get addr of LPT */ - UINT32 LPT_Addr = ((m_LPL & 0x0ff) << 4) | ((m_LPH & 0x0f) << (8+4)); - - /* update internal LPT state */ - m_LPT.SC = space().read_byte(LPT_Addr); - m_LPT.MB = space().read_byte(LPT_Addr + 1); - m_LPT.LM = space().read_byte(LPT_Addr + 2); - m_LPT.RM = space().read_byte(LPT_Addr + 3); - m_LPT.LD1L = space().read_byte(LPT_Addr + 4); - m_LPT.LD1H = space().read_byte(LPT_Addr + 5); - m_LPT.LD2L = space().read_byte(LPT_Addr + 6); - m_LPT.LD2H = space().read_byte(LPT_Addr + 7); - m_LPT.COL[0] = space().read_byte(LPT_Addr + 8); - m_LPT.COL[1] = space().read_byte(LPT_Addr + 9); - m_LPT.COL[2] = space().read_byte(LPT_Addr + 10); - m_LPT.COL[3] = space().read_byte(LPT_Addr + 11); - m_LPT.COL[4] = space().read_byte(LPT_Addr + 12); - m_LPT.COL[5] = space().read_byte(LPT_Addr + 13); - m_LPT.COL[6] = space().read_byte(LPT_Addr + 14); - m_LPT.COL[7] = space().read_byte(LPT_Addr + 15); -} - -/* call here to render a line of graphics */ -void nick_device::do_line() -{ - UINT8 scanline; - - m_write_virq((m_LPT.MB & NICK_MB_VIRQ) ? ASSERT_LINE : CLEAR_LINE); - - if (m_virq && !(m_LPT.MB & NICK_MB_VIRQ)) - { - m_timer_scanline->adjust(m_screen->time_until_pos(0, 0), 0, m_screen->scan_period()); - } - - m_virq = (m_LPT.MB & NICK_MB_VIRQ) ? 1 : 0; - - if ((m_LPT.MB & NICK_MB_LPT_RELOAD)!=0) - { - /* reload LPT */ - - m_LPL = m_reg[2]; - m_LPH = m_reg[3]; - - reload_lpt(); - } - - /* left border */ - do_left_margin(); - - /* do visible part */ - do_display(); - - /* right border */ - do_right_margin(); - - // 0x0f7 is first! - /* scan line count for this LPT */ - scanline = ((~m_LPT.SC) + 1) & 0x0ff; - - //printf("scanline %02x\r\n", scanline); - - /* update count of scanlines done so far */ - m_scanline_count++; - - if (m_scanline_count == scanline) - { - /* done all scanlines of this Line Parameter Table, get next */ - - m_scanline_count = 0; - - update_lpt(); - reload_lpt(); - } -} diff --git a/src/mess/video/nick.h b/src/mess/video/nick.h deleted file mode 100644 index 738d202e2a7..00000000000 --- a/src/mess/video/nick.h +++ /dev/null @@ -1,178 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Intelligent Designs NICK emulation - -**********************************************************************/ - -#pragma once - -#ifndef __NICK__ -#define __NICK__ - -#include "emu.h" -#include "machine/rescap.h" -#include "video/resnet.h" - - - -///************************************************************************* -// INTERFACE CONFIGURATION MACROS -///************************************************************************* - -#define MCFG_NICK_ADD(_tag, _screen_tag, _clock) \ - MCFG_SCREEN_ADD(_screen_tag, RASTER) \ - MCFG_SCREEN_REFRESH_RATE(50) \ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ - MCFG_SCREEN_SIZE(ENTERPRISE_SCREEN_WIDTH, ENTERPRISE_SCREEN_HEIGHT) \ - MCFG_SCREEN_VISIBLE_AREA(0, ENTERPRISE_SCREEN_WIDTH-1, 0, ENTERPRISE_SCREEN_HEIGHT-1) \ - MCFG_SCREEN_UPDATE_DEVICE(_tag, nick_device, screen_update) \ - MCFG_DEVICE_ADD(_tag, NICK, _clock) \ - MCFG_VIDEO_SET_SCREEN(_screen_tag) - - -#define MCFG_NICK_VIRQ_CALLBACK(_write) \ - devcb = &nick_device::set_virq_wr_callback(*device, DEVCB_##_write); - - -/* there are 64us per line, although in reality - about 50 are visible. */ -#define ENTERPRISE_SCREEN_WIDTH (50*16) - -/* there are 312 lines per screen, although in reality - about 35*8 are visible */ -#define ENTERPRISE_SCREEN_HEIGHT (35*8) - - -///************************************************************************* -// TYPE DEFINITIONS -///************************************************************************* - -/* Nick executes a Display list, in the form of a list of Line Parameter - Tables, this is the form of the data */ -struct LPT_ENTRY -{ - UINT8 SC; /* scanlines in this modeline (two's complement) */ - UINT8 MB; /* the MODEBYTE (defines video display mode) */ - UINT8 LM; /* left margin etc */ - UINT8 RM; /* right margin etc */ - UINT8 LD1L; /* (a7..a0) of line data pointer LD1 */ - UINT8 LD1H; /* (a8..a15) of line data pointer LD1 */ - UINT8 LD2L; /* (a7..a0) of line data pointer LD2 */ - UINT8 LD2H; /* (a8..a15) of line data pointer LD2 */ - UINT8 COL[8]; /* COL0..COL7 */ -}; - - -// ======================> nick_device - -class nick_device : public device_t, - public device_memory_interface, - public device_video_interface -{ -public: - // construction/destruction - nick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - template static devcb_base &set_virq_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_virq.set_callback(object); } - - virtual DECLARE_ADDRESS_MAP(vram_map, 8); - virtual DECLARE_ADDRESS_MAP(vio_map, 8); - - UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - - // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; - - DECLARE_READ8_MEMBER( vram_r ); - DECLARE_WRITE8_MEMBER( vram_w ); - - DECLARE_WRITE8_MEMBER( fixbias_w ); - DECLARE_WRITE8_MEMBER( border_w ); - DECLARE_WRITE8_MEMBER( lpl_w ); - DECLARE_WRITE8_MEMBER( lph_w ); - - address_space_config m_space_config; - -private: - devcb_write_line m_write_virq; - - void initialize_palette(); - - void write_pixel(int ci); - void calc_visible_clocks(int width); - void init(); - void write_border(int clocks); - void do_left_margin(); - void do_right_margin(); - - int get_color_index(int pen_index); - void write_pixels2color(UINT8 pen0, UINT8 pen1, UINT8 data_byte); - void write_pixels2color_lpixel(UINT8 pen0, UINT8 pen1, UINT8 data_byte); - void write_pixels(UINT8 data_byte, UINT8 char_idx); - void write_pixels_lpixel(UINT8 data_byte, UINT8 char_idx); - - void do_pixel(int clocks_visible); - void do_lpixel(int clocks_visible); - void do_attr(int clocks_visible); - void do_ch256(int clocks_visible); - void do_ch128(int clocks_visible); - void do_ch64(int clocks_visible); - void do_display(); - void update_lpt(); - void reload_lpt(); - void do_line(); - - /* horizontal position */ - UINT8 horizontal_clock; - /* current scanline within LPT */ - UINT8 m_scanline_count; - - UINT8 m_FIXBIAS; - UINT8 m_BORDER; - UINT8 m_LPL; - UINT8 m_LPH; - - UINT16 m_LD1; - UINT16 m_LD2; - - LPT_ENTRY m_LPT; - - UINT32 *m_dest; - int m_dest_pos; - int m_dest_max_pos; - - UINT8 m_reg[4]; - - /* first clock visible on left hand side */ - int m_first_visible_clock; - /* first clock visible on right hand side */ - int m_last_visible_clock; - - /* given a bit pattern, this will get the pen index */ - UINT8 m_pen_idx_4col[256]; - /* given a bit pattern, this will get the pen index */ - UINT8 m_pen_idx_16col[256]; - - int m_virq; - - bitmap_rgb32 m_bitmap; - rgb_t m_palette[256]; - - emu_timer *m_timer_scanline; -}; - - -// device type definition -extern const device_type NICK; - - - -#endif diff --git a/src/mess/video/ondra.c b/src/mess/video/ondra.c deleted file mode 100644 index c5112f4729e..00000000000 --- a/src/mess/video/ondra.c +++ /dev/null @@ -1,47 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Ondra driver by Miodrag Milanovic - - 08/09/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/ondra.h" -#include "machine/ram.h" - - - -void ondra_state::video_start() -{ - m_video_enable = 0; -} - -UINT32 ondra_state::screen_update_ondra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code1,code2; - int y, x, b; - int Vaddr = 0x2800; - - if (m_video_enable==1) { - for (x = 0; x < 40; x++) - { - for (y = 127; y >=0; y--) - { - code1 = m_ram->pointer()[0xd700 + Vaddr + 0x80]; - code2 = m_ram->pointer()[0xd700 + Vaddr + 0x00]; - for (b = 0; b < 8; b++) - { - bitmap.pix16(2*y, x*8+b) = ((code1 << b) & 0x80) ? 1 : 0; - bitmap.pix16(2*y+1, x*8+b) = ((code2 << b) & 0x80) ? 1 : 0; - } - Vaddr++; - } - Vaddr = (Vaddr - 128) - 256; - } - } - return 0; -} diff --git a/src/mess/video/orao.c b/src/mess/video/orao.c deleted file mode 100644 index a41f060af8d..00000000000 --- a/src/mess/video/orao.c +++ /dev/null @@ -1,38 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Orao video driver by Miodrag Milanovic - - 01/03/2008 Updated to work with latest SVN code - 22/02/2008 Preliminary driver. - -****************************************************************************/ - -#include "emu.h" -#include "includes/orao.h" - -void orao_state::video_start() -{ -} - -UINT32 orao_state::screen_update_orao(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code; - int y, x, b; - - int addr = 0; - for (y = 0; y < 256; y++) - { - int horpos = 0; - for (x = 0; x < 32; x++) - { - code = m_video_ram[addr++]; - for (b = 0; b < 8; b++) - { - bitmap.pix16(y, horpos++) = (code >> b) & 0x01; - } - } - } - return 0; -} diff --git a/src/mess/video/orion.c b/src/mess/video/orion.c deleted file mode 100644 index 241080684cf..00000000000 --- a/src/mess/video/orion.c +++ /dev/null @@ -1,114 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Orion video driver by Miodrag Milanovic - - 22/04/2008 Orion Pro added - 02/04/2008 Preliminary driver. - -****************************************************************************/ - - -#include "emu.h" -#include "includes/orion.h" - -VIDEO_START_MEMBER(orion_state,orion128) -{ -} - -UINT32 orion_state::screen_update_orion128(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code1,code2,code3,code4,color,val; - int y, x,b; - int orionproshift = (m_orion128_video_mode & 0x10) ? 1 : 0; - int part1addr = (3-((m_orion128_video_page & 3) | orionproshift)) * 0x4000; - int part2addr = part1addr + 0x10000; - int video_mode = m_orion128_video_mode & m_video_mode_mask; - UINT8 *ram = m_ram->pointer(); - - for (x = 0; x < m_orion128_video_width; x++) - { - for (y = 0; y < 256; y++) - { - code1 = ram[part1addr + y + x*256]; - code2 = ram[part2addr + y + x*256]; - code3 = ram[part1addr + y + x*256 + 0x4000]; - code4 = ram[part2addr + y + x*256 + 0x4000]; - if ((video_mode==14) || (video_mode==15)) { - code2 = m_orionpro_pseudo_color; - } - color = 0; - for (b = 7; b >= 0; b--) - { - switch(m_orion128_video_mode & m_video_mode_mask) { - case 0 : color = ((code1 >> b) & 0x01) ? 10 : 0; break; - case 1 : color = ((code1 >> b) & 0x01) ? 17 : 16; break; - case 4 : val = (((code1 >> b) & 0x01) << 1) + ((code2 >> b) & 0x01); - switch(val) { - case 0 : color = 0; break; // black - case 1 : color = 4; break; // red - case 2 : color = 2; break; // green - case 3 : color = 1; break; // blue - } - break; - case 5 : val = (((code1 >> b) & 0x01) << 1) + ((code2 >> b) & 0x01); - switch(val) { - case 0 : color = 7; break; // white - case 1 : color = 4; break; // red - case 2 : color = 2; break; // green - case 3 : color = 1; break; // blue - } - break; - case 6 : - case 7 : - case 14 : - case 15 : - color = ((code1 >> b) & 0x01) ? (code2 & 0x0f) : (code2 >> 4); break; - - default: - switch(m_orion128_video_mode & m_video_mode_mask & 20) { - case 16 : - color = (((code1 >> b) & 0x01) << 2) + (((code3 >> b) & 0x01) << 1) + ((code2 >> b) & 0x01); - break; - case 20 : - color = (((code1 >> b) & 0x01) << 2) + (((code3 >> b) & 0x01) << 1) + ((code2 >> b) & 0x01); - if ((((code4 >> b) & 0x01)==1) && (color!=0)) { - color += 8; - } - break; - } - } - bitmap.pix16(y, x*8+(7-b)) = color; - } - } - } - - return 0; -} - -static const rgb_t orion128_palette[18] = { - rgb_t(0x00, 0x00, 0x00), // 0 - rgb_t(0x00, 0x00, 0xc0), // 1 - rgb_t(0x00, 0xc0, 0x00), // 2 - rgb_t(0x00, 0xc0, 0xc0), // 3 - rgb_t(0xc0, 0x00, 0x00), // 4 - rgb_t(0xc0, 0x00, 0xc0), // 5 - rgb_t(0xc0, 0xc0, 0x00), // 6 - rgb_t(0xc0, 0xc0, 0xc0), // 7 - rgb_t(0x80, 0x80, 0x80), // 8 - rgb_t(0x00, 0x00, 0xff), // 9 - rgb_t(0x00, 0xff, 0x00), // A - rgb_t(0x00, 0xff, 0xff), // B - rgb_t(0xff, 0x00, 0x00), // C - rgb_t(0xff, 0x00, 0xff), // D - rgb_t(0xff, 0xff, 0x00), // E - rgb_t(0xff, 0xff, 0xff), // F - rgb_t(0xc8, 0xb4, 0x28), // 10 - rgb_t(0x32, 0xfa, 0xfa) // 11 -}; - -PALETTE_INIT_MEMBER(orion_state,orion128 ) -{ - palette.set_pen_colors(0, orion128_palette, ARRAY_LENGTH(orion128_palette)); -} diff --git a/src/mess/video/osi.c b/src/mess/video/osi.c deleted file mode 100644 index 94dd155454b..00000000000 --- a/src/mess/video/osi.c +++ /dev/null @@ -1,180 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder, Robbbert, Wilbert Pol -#include "includes/osi.h" - -/* Palette Initialization */ - -PALETTE_INIT_MEMBER(sb2m600_state, osi630) -{ - /* black and white */ - palette.set_pen_color(0, 0x00, 0x00, 0x00); // black - palette.set_pen_color(1, 0xff, 0xff, 0xff); // white - - /* color enabled */ - palette.set_pen_color(2, 0xff, 0xff, 0x00); // yellow - palette.set_pen_color(3, 0xff, 0x00, 0x00); // red - palette.set_pen_color(4, 0x00, 0xff, 0x00); // green - palette.set_pen_color(5, 0x00, 0x80, 0x00); // olive green - palette.set_pen_color(6, 0x00, 0x00, 0xff); // blue - palette.set_pen_color(7, 0xff, 0x00, 0xff); // purple - palette.set_pen_color(8, 0x00, 0x00, 0x80); // sky blue - palette.set_pen_color(9, 0x00, 0x00, 0x00); // black -} - -/* Video Start */ - -void sb2m600_state::video_start() -{ - m_p_chargen = memregion("chargen")->base(); - UINT16 addr; - - /* randomize video memory contents */ - for (addr = 0; addr < OSI600_VIDEORAM_SIZE; addr++) - m_video_ram[addr] = machine().rand() & 0xff; - - /* randomize color memory contents */ - if (m_color_ram) - for (addr = 0; addr < OSI630_COLORRAM_SIZE; addr++) - m_color_ram[addr] = machine().rand() & 0x0f; -} - -/* Video Update */ - -UINT32 sb2m600_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y, bit, sx; - - if (m_32) - { - for (y = 0; y < 256; y++) - { - UINT16 videoram_addr = (y >> 4) * 64; - int line = (y >> 1) & 0x07; - int x = 0; - - for (sx = 0; sx < 64; sx++) - { - UINT8 videoram_data = m_video_ram[videoram_addr]; - UINT16 charrom_addr = ((videoram_data << 3) | line) & 0x7ff; - UINT8 charrom_data = m_p_chargen[charrom_addr]; - - for (bit = 0; bit < 8; bit++) - { - bool color = BIT(charrom_data, 7); - - if (m_coloren) - { - UINT8 colorram_data = m_color_ram[videoram_addr]; - color = (color ^ BIT(colorram_data, 0)) ? (((colorram_data >> 1) & 0x07) + 2) : 0; - } - - bitmap.pix16(y, x++) = color; - - charrom_data <<= 1; - } - - videoram_addr++; - } - } - } - else - { - for (y = 0; y < 256; y++) - { - UINT16 videoram_addr = (y >> 3) * 32; - int line = y & 0x07; - int x = 0; - - for (sx = 0; sx < 32; sx++) - { - UINT8 videoram_data = m_video_ram[videoram_addr]; - UINT16 charrom_addr = ((videoram_data << 3) | line) & 0x7ff; - UINT8 charrom_data = m_p_chargen[charrom_addr]; - - for (bit = 0; bit < 8; bit++) - { - bool color = BIT(charrom_data, 7); - - if (m_coloren) - { - UINT8 colorram_data = m_color_ram[videoram_addr]; - color = (color ^ BIT(colorram_data, 0)) ? (((colorram_data >> 1) & 0x07) + 2) : 0; - } - - bitmap.pix16(y, x++) = color; - bitmap.pix16(y, x++) = color; - - charrom_data <<= 1; - } - - videoram_addr++; - } - } - } - - return 0; -} - -UINT32 uk101_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y, bit, sx; - - for (y = 0; y < 256; y++) - { - UINT16 videoram_addr = (y >> 4) * 64; - int line = (y >> 1) & 0x07; - int x = 0; - - for (sx = 0; sx < 64; sx++) - { - UINT8 videoram_data = m_video_ram[videoram_addr++]; - UINT16 charrom_addr = ((videoram_data << 3) | line) & 0x7ff; - UINT8 charrom_data = m_p_chargen[charrom_addr]; - - for (bit = 0; bit < 8; bit++) - { - bitmap.pix16(y, x) = BIT(charrom_data, 7); - x++; - charrom_data <<= 1; - } - } - } - - return 0; -} - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( osi600_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_REFRESH_RATE(X1/256/256) // 60 Hz - MCFG_SCREEN_UPDATE_DRIVER(sb2m600_state, screen_update) - MCFG_SCREEN_SIZE(64*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0, 32*8-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( uk101_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_UPDATE_DRIVER(uk101_state, screen_update) - MCFG_SCREEN_SIZE(64*8, 16*16) - MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 16*16-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( osi630_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_REFRESH_RATE(X1/256/256) // 60 Hz - MCFG_SCREEN_UPDATE_DRIVER(sb2m600_state, screen_update) - MCFG_SCREEN_SIZE(64*8, 16*16) - MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 16*16-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_PALETTE_ADD("palette", 8+2) - MCFG_PALETTE_INIT_OWNER(sb2m600_state, osi630) -MACHINE_CONFIG_END diff --git a/src/mess/video/p2000m.c b/src/mess/video/p2000m.c deleted file mode 100644 index a75a994fe28..00000000000 --- a/src/mess/video/p2000m.c +++ /dev/null @@ -1,60 +0,0 @@ -// license:??? -// copyright-holders:Paul Daniels -/********************************************************************** - - p2000m.c - - Functions to emulate video hardware of the p2000m - -**********************************************************************/ - -#include "includes/p2000t.h" - - - - -VIDEO_START_MEMBER(p2000t_state,p2000m) -{ - m_frame_count = 0; -} - - -UINT32 p2000t_state::screen_update_p2000m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - int offs, sx, sy, code, loop; - - for (offs = 0; offs < 80 * 24; offs++) - { - sy = (offs / 80) * 20; - sx = (offs % 80) * 12; - - if ((m_frame_count > 25) && (videoram[offs + 2048] & 0x40)) - code = 32; - else - { - code = videoram[offs]; - if ((videoram[offs + 2048] & 0x01) && (code & 0x20)) - { - code += (code & 0x40) ? 64 : 96; - } else { - code &= 0x7f; - } - if (code < 32) code = 32; - } - - m_gfxdecode->gfx(0)->zoom_opaque(bitmap,cliprect, code, - videoram[offs + 2048] & 0x08 ? 0 : 1, 0, 0, sx, sy, 0x20000, 0x20000); - - if (videoram[offs] & 0x80) - { - for (loop = 0; loop < 12; loop++) - { - bitmap.pix16(sy + 18, sx + loop) = 0; /* cursor */ - bitmap.pix16(sy + 19, sx + loop) = 0; /* cursor */ - } - } - } - - return 0; -} diff --git a/src/mess/video/pc1251.c b/src/mess/video/pc1251.c deleted file mode 100644 index c891306600f..00000000000 --- a/src/mess/video/pc1251.c +++ /dev/null @@ -1,163 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#include "emu.h" - -#include "includes/pocketc.h" -#include "includes/pc1251.h" - -static const POCKETC_FIGURE /*busy={ - "11 1 1 11 1 1", - "1 1 1 1 1 1 1", - "11 1 1 1 1 1", - "1 1 1 1 1 1", - "11 1 11 1e" -},*/ def={ - "11 111 111", - "1 1 1 1", - "1 1 111 11", - "1 1 1 1", - "11 111 1e" -}, shift={ - " 11 1 1 1 111 111", - "1 1 1 1 1 1", - " 1 111 1 11 1", - " 1 1 1 1 1 1", - "11 1 1 1 1 1e" -}, /*hyp={ - "1 1 1 1 11", - "1 1 1 1 1 1", - "111 1 1 11", - "1 1 1 1", - "1 1 1 1e" -},*/ de={ - "11 111", - "1 1 1", - "1 1 111", - "1 1 1", - "11 111e" -}, g={ - " 11", - "1", - "1 1", - "1 1", - " 11e" -}, rad={ - "11 1 11", - "1 1 1 1 1 1", - "11 111 1 1", - "1 1 1 1 1 1", - "1 1 1 1 11e" -}, /*braces={ - " 1 1", - "1 1", - "1 1", - "1 1", - " 1 1e" -}, m={ - "1 1", - "11 11", - "1 1 1", - "1 1", - "1 1e" -}, e={ - "111", - "1", - "111", - "1", - "111e" -},*/ run={ - "11 1 1 1 1", - "1 1 1 1 11 1", - "11 1 1 1 11", - "1 1 1 1 1 1", - "1 1 1 1 1e" -}, pro={ - "11 11 1 ", - "1 1 1 1 1 1", - "11 11 1 1", - "1 1 1 1 1", - "1 1 1 1e" -}, /*japan={ - " 1 1 11 1 1 1", - " 1 1 1 1 1 1 1 11 1", - " 1 111 11 111 1 11", - "1 1 1 1 1 1 1 1 1", - " 1 1 1 1 1 1 1 1e" -}, sml={ - " 11 1 1 1", - "1 111 1", - " 1 1 1 1", - " 1 1 1 1", - "11 1 1 111e" -},*/ rsv={ - "11 11 1 1", - "1 1 1 1 1", - "11 1 1 1", - "1 1 1 1 1", - "1 1 11 1e" -}; - -READ8_MEMBER(pc1251_state::pc1251_lcd_read) -{ - UINT8 data = m_reg[offset&0xff]; - logerror("pc1251 read %.3x %.2x\n",offset,data); - return data; -} - -WRITE8_MEMBER(pc1251_state::pc1251_lcd_write) -{ - logerror("pc1251 write %.3x %.2x\n",offset,data); - m_reg[offset&0xff] = data; -} - -#define DOWN 62 -#define RIGHT 68 - -UINT32 pc1251_state::screen_update_pc1251(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y, i, j; - int color[2]; - - bitmap.fill(11, cliprect); - - /* HJB: we cannot initialize array with values from other arrays, thus... */ - color[0] = 7; //pocketc_colortable[PC1251_CONTRAST][0]; - color[1] = 8; //pocketc_colortable[PC1251_CONTRAST][1]; - - for (x=RIGHT,y=DOWN, i=0; i<60; x+=3) - { - for (j=0; j<5; j++, i++, x+=3) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i], - PC1251_CONTRAST,0,0, - x,y); - } - for (i=0x7b; i>=0x40; x+=3) - { - for (j=0; j<5; j++, i--, x+=3) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i], - PC1251_CONTRAST,0,0, - x,y); - } - - pocketc_draw_special(bitmap, RIGHT+134, DOWN-10, de, - m_reg[0x3c] & 0x08 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+142, DOWN-10, g, - m_reg[0x3c] & 0x04 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+146, DOWN-10, rad, - m_reg[0x3d] & 0x04 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+18, DOWN-10, def, - m_reg[0x3c] & 0x01 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT, DOWN-10, shift, - m_reg[0x3d] & 0x02 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+38, DOWN-10, pro, - m_reg[0x3e] & 0x01 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+53, DOWN-10, run, - m_reg[0x3e] & 0x02 ? color[1] : color[0]); - pocketc_draw_special(bitmap, RIGHT+68, DOWN-10, rsv, - m_reg[0x3e] & 0x04 ? color[1] : color[0]); - - /* 0x3c 1 def?, 4 g, 8 de - 0x3d 2 shift, 4 rad, 8 error - 0x3e 1 pro?, 2 run?, 4rsv?*/ - return 0; -} diff --git a/src/mess/video/pc1350.c b/src/mess/video/pc1350.c deleted file mode 100644 index 0804f75ed7c..00000000000 --- a/src/mess/video/pc1350.c +++ /dev/null @@ -1,165 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#include "emu.h" - -#include "includes/pocketc.h" -#include "includes/pc1350.h" - -static const POCKETC_FIGURE /*busy={ - "11 1 1 11 1 1", - "1 1 1 1 1 1 1", - "11 1 1 1 1 1", - "1 1 1 1 1 1", - "11 1 11 1e" -},*/ def={ - "11 111 111", - "1 1 1 1", - "1 1 111 11", - "1 1 1 1", - "11 111 1e" -}, shift={ - " 11 1 1 1 111 111", - "1 1 1 1 1 1", - " 1 111 1 11 1", - " 1 1 1 1 1 1", - "11 1 1 1 1 1e" -}, /*hyp={ - "1 1 1 1 11", - "1 1 1 1 1 1", - "111 1 1 11", - "1 1 1 1", - "1 1 1 1e" -}, de={ - "11 111", - "1 1 1", - "1 1 111", - "1 1 1", - "11 111e" -}, g={ - " 11", - "1", - "1 1", - "1 1", - " 11e" -}, rad={ - "11 1 11", - "1 1 1 1 1 1", - "11 111 1 1", - "1 1 1 1 1 1", - "1 1 1 1 11e" -}, braces={ - " 1 1", - "1 1", - "1 1", - "1 1", - " 1 1e" -}, m={ - "1 1", - "11 11", - "1 1 1", - "1 1", - "1 1e" -}, e={ - "111", - "1", - "111", - "1", - "111e" -},*/ run={ - "11 1 1 1 1", - "1 1 1 1 11 1", - "11 1 1 1 11", - "1 1 1 1 1 1", - "1 1 1 1 1e" -}, pro={ - "11 11 1 ", - "1 1 1 1 1 1", - "11 11 1 1", - "1 1 1 1 1", - "1 1 1 1e" -}, japan={ - " 1 1 11 1 1 1", - " 1 1 1 1 1 1 1 11 1", - " 1 111 11 111 1 11", - "1 1 1 1 1 1 1 1 1", - " 1 1 1 1 1 1 1 1e" -}, sml={ - " 11 1 1 1", - "1 111 1", - " 1 1 1 1", - " 1 1 1 1", - "11 1 1 111e" -}/*, rsv={ - "11 11 1 1", - "1 1 1 1 1", - "11 1 1 1", - "1 1 1 1 1", - "1 1 11 1e" -}*/; - -READ8_MEMBER(pc1350_state::pc1350_lcd_read) -{ - UINT8 data = m_reg[offset&0xfff]; - logerror("pc1350 read %.3x %.2x\n",offset,data); - return data; -} - -WRITE8_MEMBER(pc1350_state::pc1350_lcd_write) -{ - logerror("pc1350 write %.3x %.2x\n",offset,data); - m_reg[offset&0xfff] = data; -} - -READ8_MEMBER(pc1350_state::pc1350_keyboard_line_r) -{ - return m_reg[0xe00]; -} - -/* pc1350 - 24x4 5x8 no space between chars - 7000 .. 701d, 7200..721d, 7400 ..741d, 7600 ..761d, 7800 .. 781d - 7040 .. 705d, 7240..725d, 7440 ..745d, 7640 ..765d, 7840 .. 785d - 701e .. 703b, 721e..723b, 741e ..743b, 761e ..763b, 781e .. 783b - 705e .. 707b, 725e..727b, 745e ..747b, 765e ..767b, 785e .. 787b - 783c: 0 SHIFT 1 DEF 4 RUN 5 PRO 6 JAPAN 7 SML */ -static const int pc1350_addr[4]={ 0, 0x40, 0x1e, 0x5e }; - -#define DOWN 45 -#define RIGHT 76 - -UINT32 pc1350_state::screen_update_pc1350(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y=DOWN, i, j, k=0, b; - int color[4]; - bitmap.fill(11, cliprect); - - /* HJB: we cannot initialize array with values from other arrays, thus... */ - color[0] = pocketc_colortable[PC1350_CONTRAST][0]; - color[1] = pocketc_colortable[PC1350_CONTRAST][1]; - color[2] = 8; - color[3] = 7; - - for (k=0, y=DOWN; k<4; y+=16, k++) - for (x=RIGHT, i=pc1350_addr[k]; i<0xa00; i+=0x200) - for (j=0; j<=0x1d; j++, x+=2) - for (b = 0; b < 8; b++) - bitmap.plot_box(x, y + b * 2, 2, 2, color[(m_reg[j+i] >> b) & 1]); - - - /* 783c: 0 SHIFT 1 DEF 4 RUN 5 PRO 6 JAPAN 7 SML */ - /* I don't know how they really look like in the lcd */ - pocketc_draw_special(bitmap, RIGHT-30, DOWN+45, shift, - m_reg[0x83c] & 0x01 ? color[2] : color[3]); - pocketc_draw_special(bitmap, RIGHT-30, DOWN+55, def, - m_reg[0x83c] & 0x02 ? color[2] : color[3]); - pocketc_draw_special(bitmap, RIGHT-30, DOWN+5, run, - m_reg[0x83c] & 0x10 ? color[2] : color[3]); - pocketc_draw_special(bitmap, RIGHT-30, DOWN+15, pro, - m_reg[0x83c] & 0x20 ? color[2] : color[3]); - pocketc_draw_special(bitmap, RIGHT-30, DOWN+25, japan, - m_reg[0x83c] & 0x40 ? color[2] : color[3]); - pocketc_draw_special(bitmap, RIGHT-30, DOWN+35, sml, - m_reg[0x83c] & 0x80 ? color[2] : color[3]); - - return 0; -} diff --git a/src/mess/video/pc1401.c b/src/mess/video/pc1401.c deleted file mode 100644 index d7663dce91b..00000000000 --- a/src/mess/video/pc1401.c +++ /dev/null @@ -1,213 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#include "emu.h" - -#include "includes/pocketc.h" -#include "includes/pc1401.h" - -/* pc140x - 16 5x7 with space between char - 6000 .. 6027, 6067.. 6040 - 603c: 3 STAT - 603d: 0 BUSY, 1 DEF, 2 SHIFT, 3 HYP, 4 PRO, 5 RUN, 6 CAL - 607c: 0 E, 1 M, 2 (), 3 RAD, 4 G, 5 DE, 6 PRINT */ - -/* pc1421 - 16 5x7 with space between char - 6000 .. 6027, 6067.. 6040 - 603c: 3 RUN - 603d: 0 BUSY, 1 DEF, 2 SHIFT, 3 BGN, 4 STAT, 5 FIN, 6 PRINT - 607c: 0 E, 1 M, 2 BAL, 3 INT, 4 PRN, 5 Sum-Sign, 6 PRO */ - -READ8_MEMBER(pc1401_state::pc1401_lcd_read) -{ - return m_reg[offset & 0xff]; -} - -WRITE8_MEMBER(pc1401_state::pc1401_lcd_write) -{ - m_reg[offset & 0xff]=data; -} - -static const POCKETC_FIGURE line={ /* simple line */ - "11111", - "11111", - "11111e" -}; -static const POCKETC_FIGURE busy={ - "11 1 1 11 1 1", - "1 1 1 1 1 1 1", - "11 1 1 1 1 1", - "1 1 1 1 1 1", - "11 1 11 1e" -}, def={ - "11 111 111", - "1 1 1 1", - "1 1 111 11", - "1 1 1 1", - "11 111 1e" -}, shift={ - " 11 1 1 1 111 111", - "1 1 1 1 1 1", - " 1 111 1 11 1", - " 1 1 1 1 1 1", - "11 1 1 1 1 1e" -}, hyp={ - "1 1 1 1 11", - "1 1 1 1 1 1", - "111 1 1 11", - "1 1 1 1", - "1 1 1 1e" -}, de={ - "11 111", - "1 1 1", - "1 1 111", - "1 1 1", - "11 111e" -}, g={ - " 11", - "1", - "1 1", - "1 1", - " 11e" -}, rad={ - "11 1 11", - "1 1 1 1 1 1", - "11 111 1 1", - "1 1 1 1 1 1", - "1 1 1 1 11e" -}, braces={ - " 1 1", - "1 1", - "1 1", - "1 1", - " 1 1e" -}, m={ - "1 1", - "11 11", - "1 1 1", - "1 1", - "1 1e" -}, e={ - "111", - "1", - "111", - "1", - "111e" -}/*, run={ - "11 1 1 1 1", - "1 1 1 1 11 1", - "11 1 1 1 11", - "1 1 1 1 1 1", - "1 1 1 1 1e" -}, pro={ - "11 11 1 ", - "1 1 1 1 1 1", - "11 11 1 1", - "1 1 1 1 1", - "1 1 1 1e" -}, japan={ - " 1 1 11 1 1 1", - " 1 1 1 1 1 1 1 11 1", - " 1 111 11 111 1 11", - "1 1 1 1 1 1 1 1 1", - " 1 1 1 1 1 1 1 1e" -}, sml={ - " 11 1 1 1", - "1 111 1", - " 1 1 1 1", - " 1 1 1 1", - "11 1 1 111e" -}, rsv={ - "11 11 1 1", - "1 1 1 1 1", - "11 1 1 1", - "1 1 1 1 1", - "1 1 11 1e" -}*/; - -#define DOWN 57 -#define RIGHT 114 - -UINT32 pc1401_state::screen_update_pc1401(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y, i, j; - int color[2]; - - bitmap.fill(11, cliprect); - -#if 0 - /* HJB: we cannot initialize array with values from other arrays, thus... */ - color[0] = pocketc_colortable[CONTRAST][0]; - color[1] = pocketc_colortable[CONTRAST][1]; -#endif - /* Above can be unreadable or misleading at certain contrast settings, this is better */ - color[0] = 7; - color[1] = 8; - - if (m_portc&1) - { - for (x=RIGHT,y=DOWN,i=0; i<0x28;x+=2) - { - for (j=0; j<5;j++,i++,x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0,x,y); - } - for (i=0x67; i>=0x40;x+=2) - { - for (j=0; j<5;j++,i--,x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0,x,y); - } - } - - pocketc_draw_special(bitmap, RIGHT+149, DOWN+24, line, - m_reg[0x3c] & 0x08 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT, DOWN-10, busy, - m_reg[0x3d] & 0x01 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+18, DOWN-10, def, - m_reg[0x3d] & 0x02 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+43, DOWN-10,shift, - m_reg[0x3d] & 0x04 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+63, DOWN-10,hyp, - m_reg[0x3d] & 0x08 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+38, DOWN+24,line, - m_reg[0x3d] & 0x10 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+23, DOWN+24,line, - m_reg[0x3d] & 0x20 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+8, DOWN+24,line, - m_reg[0x3d] & 0x40 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+183, DOWN-10,e, - m_reg[0x7c] & 0x01 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+176, DOWN-10,m, - m_reg[0x7c] & 0x02 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+168, DOWN-10,braces, - m_reg[0x7c] & 0x04 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+138, DOWN-10,rad, - m_reg[0x7c] & 0x08 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+134, DOWN-10,g, - m_reg[0x7c] & 0x10 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+126, DOWN-10,de, - m_reg[0x7c] & 0x20 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, RIGHT+165, DOWN+24,line, - m_reg[0x7c] & 0x40 ? color[1] : color[0]); - -/* - 603c: 3 STAT - 603d: 0 BUSY, 1 DEF, 2 SHIFT, 3 HYP, 4 PRO, 5 RUN, 6 CAL - 607c: 0 E, 1 M, 2 (), 3 RAD, 4 G, 5 DE, 6 PRINT -*/ - return 0; -} diff --git a/src/mess/video/pc1403.c b/src/mess/video/pc1403.c deleted file mode 100644 index 0eb722c0319..00000000000 --- a/src/mess/video/pc1403.c +++ /dev/null @@ -1,246 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/***************************************************************************** - * - * pc1403.c - * portable sharp pc1403 video emulator interface - * (sharp pocket computers) - * - * Copyright (c) 2001 Peter Trauner, all rights reserved. - * - * History of changes: - * 21.07.2001 Several changes listed below were made by Mario Konegger - * (konegger@itp.tu-graz.ac.at) - * Placed the grafical symbols onto the right place and added - * some symbols, so the display is correct rebuit. - * Added a strange behaviour of the display concerning the on/off - * state and the BUSY-symbol, which I found out with experiments - * with my own pc1403. - *****************************************************************************/ - -#include "emu.h" - -#include "includes/pocketc.h" -#include "includes/pc1403.h" - - -void pc1403_state::video_start() -{ - if (strcmp(machine().system().name, "pc1403h") == 0) - { - m_DOWN = 69; - m_RIGHT = 155; - } - else - { - m_DOWN = 67; - m_RIGHT = 152; - } -} - -READ8_MEMBER(pc1403_state::pc1403_lcd_read) -{ - return m_reg[offset]; -} - -WRITE8_MEMBER(pc1403_state::pc1403_lcd_write) -{ - m_reg[offset]=data; -} - -static const POCKETC_FIGURE line={ /* simple line */ - "11111", - "11111", - "11111e" -}; -static const POCKETC_FIGURE busy={ - "11 1 1 11 1 1", - "1 1 1 1 1 1 1", - "11 1 1 1 1 1", - "1 1 1 1 1 1", - "11 1 11 1e" -}, def={ - "11 111 111", - "1 1 1 1", - "1 1 111 11", - "1 1 1 1", - "11 111 1e" -}, shift={ - " 11 1 1 1 111 111", - "1 1 1 1 1 1", - " 1 111 1 11 1", - " 1 1 1 1 1 1", - "11 1 1 1 1 1e" -}, hyp={ - "1 1 1 1 11", - "1 1 1 1 1 1", - "111 1 1 11", - "1 1 1 1", - "1 1 1 1e" -}, de={ - "11 111", - "1 1 1", - "1 1 111", - "1 1 1", - "11 111e" -}, g={ - " 11", - "1", - "1 1", - "1 1", - " 11e" -}, rad={ - "11 1 11", - "1 1 1 1 1 1", - "11 111 1 1", - "1 1 1 1 1 1", - "1 1 1 1 11e" -}, braces={ - " 1 1", - "1 1", - "1 1", - "1 1", - " 1 1e" -}, m={ - "1 1", - "11 11", - "1 1 1", - "1 1", - "1 1e" -}, e={ - "111", - "1", - "111", - "1", - "111e" -}, kana={ // katakana charset - " 1 1 ", - " 11111 111", - " 1 1 1 ", - " 1 1 1 ", - "1 1 1e" -}, shoo={ // minor - " 1 ", - " 1 1 1 ", - "1 1 1", - " 1 ", - " 1e" -}, sml={ - " 11 1 1 1", - "1 111 1", - " 1 1 1 1", - " 1 1 1 1", - "11 1 1 111e" -}; - -UINT32 pc1403_state::screen_update_pc1403(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y, i, j; - int color[3]; - - bitmap.fill(11, cliprect); - - /* HJB: we cannot initialize array with values from other arrays, thus... */ - color[0] = 7; // pocketc_colortable[CONTRAST][0]; - color[2] = 8; // pocketc_colortable[CONTRAST][1]; - color[1] = (m_portc & 1) ? color[2] : color[0]; - - if (m_portc & 1) - { - for (x=m_RIGHT, y=m_DOWN, i=0; i<6*5; x+=2) { - for (j=0; j<5; j++, i++, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - for (i=9*5; i<12*5; x+=2) - { - for (j=0; j<5; j++, i++, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - for (i=6*5; i<9*5; x+=2) - { - for (j=0; j<5; j++, i++, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - for (i=0x7b-3*5; i>0x7b-6*5; x+=2) - { - for (j=0; j<5; j++, i--, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - for (i=0x7b; i>0x7b-3*5; x+=2) - { - for (j=0; j<5; j++, i--, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - for (i=0x7b-6*5; i>0x7b-12*5; x+=2) - { - for (j=0; j<5; j++, i--, x+=2) - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_reg[i],CONTRAST,0,0, - x,y); - } - } - /* if display is off, busy is always visible? it seems to behave like that. */ - /* But if computer is off, busy is hidden. */ - if(!(m_portc&8)) - { - if (m_portc&1) - pocketc_draw_special(bitmap, m_RIGHT, m_DOWN-13, busy, - m_reg[0x3d] & 1 ? color[2] : color[0]); - - else pocketc_draw_special(bitmap, m_RIGHT, m_DOWN-13, busy, color[2]); - } - else - pocketc_draw_special(bitmap, m_RIGHT, m_DOWN-13, busy, color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+18, m_DOWN-13, def, - m_reg[0x3d] & 0x02 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+43, m_DOWN-13, shift, - m_reg[0x3d] & 0x04 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+63, m_DOWN-13, hyp, - m_reg[0x3d] & 0x08 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+155, m_DOWN-13, kana, - m_reg[0x3c] & 0x01 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+167, m_DOWN-13, shoo, - m_reg[0x3c] & 0x02 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+178, m_DOWN-13, sml, - m_reg[0x3c] & 0x04 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+191, m_DOWN-13, de, - m_reg[0x7c] & 0x20 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+199, m_DOWN-13, g, - m_reg[0x7c] & 0x10 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+203, m_DOWN-13, rad, - m_reg[0x7c] & 0x08 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+266, m_DOWN-13, braces, - m_reg[0x7c] & 0x04 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+274, m_DOWN-13, m, - m_reg[0x7c] & 0x02 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+281, m_DOWN-13, e, - m_reg[0x7c] & 0x01 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+10, m_DOWN+27, line /* empty */, - m_reg[0x3c] & 0x40 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+31, m_DOWN+27, line /*calc*/, - m_reg[0x3d] & 0x40 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+52, m_DOWN+27, line/*run*/, - m_reg[0x3d] & 0x20 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+73, m_DOWN+27, line/*prog*/, - m_reg[0x3d] & 0x10 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+94, m_DOWN+27, line /* empty */, - m_reg[0x3c] & 0x20 ? color[1] : color[0]); - - pocketc_draw_special(bitmap, m_RIGHT+232, m_DOWN+27, line/*matrix*/, - m_reg[0x3c] & 0x10 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+253, m_DOWN+27, line/*stat*/, - m_reg[0x3c] & 0x08 ? color[1] : color[0]); - pocketc_draw_special(bitmap, m_RIGHT+274, m_DOWN+27, line/*print*/, - m_reg[0x7c] & 0x40 ? color[1] : color[0]); - - return 0; -} diff --git a/src/mess/video/pc1512.c b/src/mess/video/pc1512.c deleted file mode 100644 index cecfe291d96..00000000000 --- a/src/mess/video/pc1512.c +++ /dev/null @@ -1,606 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/pc1512.h" - - - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -#define LOG 0 - - -static const rgb_t PALETTE_1512[] = -{ - rgb_t::black, - rgb_t(0x00, 0x00, 0xaa), - rgb_t(0x00, 0xaa, 0x00), - rgb_t(0x00, 0xaa, 0xaa), - rgb_t(0xaa, 0x00, 0x00), - rgb_t(0xaa, 0x00, 0xaa), - rgb_t(0xaa, 0x55, 0x00), - rgb_t(0xaa, 0xaa, 0xaa), - rgb_t(0x55, 0x55, 0x55), - rgb_t(0x55, 0x55, 0xff), - rgb_t(0x55, 0xff, 0x55), - rgb_t(0x55, 0xff, 0xff), - rgb_t(0xff, 0x55, 0x55), - rgb_t(0xff, 0x55, 0xff), - rgb_t(0xff, 0xff, 0x55), - rgb_t::white -}; - -static const int PALETTE_0[] = { 0, 3, 5, 7 }; -static const int PALETTE_1[] = { 0, 2, 4, 6 }; -static const int PALETTE_2[] = { 0, 3, 4, 7 }; - - -enum -{ - ALPHA_40 = 0, - ALPHA_80, - GRAPHICS_1, - GRAPHICS_2 -}; - - -#define MODE_ALPHA_80 0x01 -#define MODE_GRAPHICS 0x02 -#define MODE_PALETTE_2 0x04 -#define MODE_ENABLE_VIDEO 0x08 -#define MODE_GRAPHICS_2 0x10 -#define MODE_BLINK 0x20 - - -#define COLOR_INTENSITY 0x10 -#define COLOR_PALETTE_1 0x20 - - -#define VFP_LORES 22 -#define HFP_LORES 16 - - - -//************************************************************************** -// VIDEO RAM ACCESS -//************************************************************************** - -//------------------------------------------------- -// video_ram_r - -//------------------------------------------------- - -READ8_MEMBER( pc1512_state::video_ram_r ) -{ - UINT8 data = 0; - - switch (get_display_mode(m_vdu_mode)) - { - case ALPHA_40: - case ALPHA_80: - data = m_video_ram[offset]; - break; - - case GRAPHICS_1: - data = m_video_ram[(offset << 2) | 3]; - break; - - case GRAPHICS_2: - data = m_video_ram[(offset << 2) | (m_vdu_rdsel ^ 0x03)]; - break; - } - - return data; -} - - -//------------------------------------------------- -// video_ram_w - -//------------------------------------------------- - -WRITE8_MEMBER( pc1512_state::video_ram_w ) -{ - switch (get_display_mode(m_vdu_mode)) - { - case ALPHA_40: - case ALPHA_80: - m_video_ram[offset] = data; - break; - - case GRAPHICS_1: - m_video_ram[(offset << 2) | 3] = data; - m_video_ram[(offset << 2) | 2] = data; - m_video_ram[(offset << 2) | 1] = data; - m_video_ram[(offset << 2) | 0] = data; - break; - - case GRAPHICS_2: - if (BIT(m_vdu_plane, 0)) m_video_ram[(offset << 2) | 3] = data; - if (BIT(m_vdu_plane, 1)) m_video_ram[(offset << 2) | 2] = data; - if (BIT(m_vdu_plane, 2)) m_video_ram[(offset << 2) | 1] = data; - if (BIT(m_vdu_plane, 3)) m_video_ram[(offset << 2) | 0] = data; - break; - } -} - - -//------------------------------------------------- -// vdu_r - -//------------------------------------------------- - -READ8_MEMBER( pc1512_state::vdu_r ) -{ - UINT8 data = 0; - - switch (offset) - { - case 1: case 3: case 5: case 7: - data = m_vdu->register_r(space, 0); - break; - - case 0xa: // VDU Status - /* - - bit description - - 0 Toggle Bit - 1 Light-pen latch select - 2 Light-pen switch off - 3 Frame Flyback Time - 4 - 5 - 6 - 7 - - */ - - // toggle bit - data |= m_toggle; - m_toggle = !m_toggle; - - // light pen latch - data |= m_lpen << 1; - - // light pen switch - data |= 0x04; - - // vertical sync - //data |= m_vdu->vsync_r(); - int flyback = 0; - - if (machine().first_screen()->vpos() < VFP_LORES - 16) flyback = 1; - if (machine().first_screen()->vpos() > VFP_LORES + 200) flyback = 1; - - data |= flyback << 3; - break; - } - - return data; -} - - -//------------------------------------------------- -// vdu_w - -//------------------------------------------------- - -WRITE8_MEMBER( pc1512_state::vdu_w ) -{ - switch (offset) - { - case 0: case 2: case 4: case 6: - m_vdu->address_w(space, 0, data); - break; - - case 1: case 3: case 5: case 7: - m_vdu->register_w(space, 0, data); - break; - - case 8: // VDU Mode Control - /* - - bit description - - 0 Select Alpha 80 Char mode (de-select 40 Char mode) - 1 Select Graphics modes (de-select Alpha modes) - 2 Select Palette 2 (de-select palettes 0,1) - 3 Enable Video Display - 4 Select Graphics Mode 2 (de-select graphics mode 1) - 5 Enable Blinking Chars (disable intensified backgrounds) - 6 - 7 - - */ - - if (LOG) logerror("VDU Mode Control %02x\n", data); - - if ((get_display_mode(m_vdu_mode) != GRAPHICS_2) && (get_display_mode(data) == GRAPHICS_2)) - { - m_vdu_plane = 0x0f; - m_vdu_border = 0; - } - - if (get_display_mode(data) != GRAPHICS_2) - { - m_vdu_rdsel = 0; - } - - if (get_display_mode(m_vdu_mode) != get_display_mode(data)) - { - switch (get_display_mode(data)) - { - case ALPHA_40: - case GRAPHICS_1: - m_vdu->set_hpixels_per_column(8); - m_vdu->set_clock(XTAL_28_63636MHz/32); - break; - - case ALPHA_80: - m_vdu->set_hpixels_per_column(8); - m_vdu->set_clock(XTAL_28_63636MHz/16); - break; - - case GRAPHICS_2: - m_vdu->set_hpixels_per_column(16); - m_vdu->set_clock(XTAL_28_63636MHz/32); - break; - } - } - - m_vdu_mode = data; - break; - - case 9: // VDU Colour Select - /* - - bit description - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("VDU Colour Select %02x\n", data); - - m_vdu_color = data; - break; - - case 0xb: // Clear Light Pen Latch - if (LOG) logerror("VDU Clear Light Pen Latch\n"); - - m_lpen = 0; - break; - - case 0xc: // Set Light Pen Latch - if (LOG) logerror("VDU Set Light Pen Latch\n"); - - if (!m_lpen) - { - m_vdu->assert_light_pen_input(); - } - - m_lpen = 1; - break; - - case 0xd: // VDU Colour Plane Write - /* - - bit description - - 0 Allow CPU write to Blue Plane - 1 Allow CPU write to Green Plane - 2 Allow CPU write to Red Plane - 3 Allow CPU write to Intensity Plane - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("VDU Colour Plane Write %01x\n", data & 0x0f); - - if (get_display_mode(m_vdu_mode) == GRAPHICS_2) - { - m_vdu_plane = data; - } - break; - - case 0xe: // VDU Colour Plane Read - /* - - bit description - - 0 Read Select bit 0 (RDSEL0) - 1 Read Select bit 1 (RDSEL1) - 2 - 3 - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("VDU Colour Plane Read %u\n", data & 0x03); - - if (get_display_mode(m_vdu_mode) == GRAPHICS_2) - { - m_vdu_rdsel = data & 0x03; - } - break; - - case 0xf: // VDU Graphics Mode 2 Border - /* - - bit description - - 0 Border Blue - 1 Border Green - 2 Border Red - 3 Border Intensity - 4 - 5 - 6 - 7 - - */ - - if (LOG) logerror("VDU Graphics Mode 2 Border %u\n", data & 0x0f); - - m_vdu_border = data; - break; - } -} - - -//------------------------------------------------- -// mc6845 -//------------------------------------------------- - -int pc1512_state::get_display_mode(UINT8 mode) -{ - if (mode & MODE_GRAPHICS) - { - if (mode & MODE_GRAPHICS_2) - { - return GRAPHICS_2; - } - else - { - return GRAPHICS_1; - } - } - else - { - if (mode & MODE_ALPHA_80) - { - return ALPHA_80; - } - else - { - return ALPHA_40; - } - } -} - -offs_t pc1512_state::get_char_rom_offset() -{ - return ((m_lk->read() >> 5) & 0x03) << 11; -} - -MC6845_UPDATE_ROW( pc1512_state::draw_alpha ) -{ - offs_t char_rom_offset = get_char_rom_offset(); - UINT32 *p = &bitmap.pix32(y + vbp, hbp); - - if (get_display_mode(m_vdu_mode) == ALPHA_40) - p = &bitmap.pix32(y + vbp, hbp); - - if (y > 199) return; - - for (int column = 0; column < x_count; column++) - { - UINT8 code = m_video_ram[(ma + column) << 1]; - UINT8 attr = m_video_ram[((ma + column) << 1) + 1]; - int fg = attr & 0x0f; - int bg = attr >> 4; - - if (m_vdu_mode & MODE_BLINK) - { - bg &= 0x07; - - if (BIT(attr, 7) && !m_blink) - { - fg = bg; - } - } - - offs_t addr = char_rom_offset | (code << 3) | (ra & 0x07); - UINT8 data = m_char_rom->base()[addr & 0x1fff]; - - if ((column == cursor_x) && m_cursor) - { - data = 0xff; - } - - for (int bit = 0; bit < 8; bit++) - { - int color = BIT(data, 7) ? fg : bg; - - *p = PALETTE_1512[de ? color : 0]; p++; - - data <<= 1; - } - } -} - -int pc1512_state::get_color(UINT8 data) -{ - if (data == 0) return m_vdu_color & 0x0f; - - int color = PALETTE_0[data & 0x03]; - - if (m_vdu_color & COLOR_PALETTE_1) - { - color = PALETTE_1[data & 0x03]; - } - else if (m_vdu_mode & MODE_PALETTE_2) - { - color = PALETTE_2[data & 0x03]; - } - - if (m_vdu_color & COLOR_INTENSITY) - { - color += 8; - } - - return color; -} - -MC6845_UPDATE_ROW( pc1512_state::draw_graphics_1 ) -{ - if (y > 199) return; - - UINT32 *p = &bitmap.pix32(y + vbp, hbp); - - for (int column = 0; column < x_count; column++) - { - offs_t offset = ((ra & 0x01) << 15) | ((ma + column) << 3); - - UINT16 b = (m_video_ram[offset | 3] << 8) | m_video_ram[offset | 7]; - - for (int x = 0; x < 8; x++) - { - *p = PALETTE_1512[de ? get_color((BIT(b, 15) << 1) | BIT(b, 14)) : 0]; p++; - b <<= 2; - } - } -} - -MC6845_UPDATE_ROW( pc1512_state::draw_graphics_2 ) -{ - if (y > 199) return; - - UINT32 *p = &bitmap.pix32(y + vbp, hbp); - - for (int column = 0; column < x_count; column++) - { - offs_t offset = ((ra & 0x01) << 15) | ((ma + column) << 3); - - UINT16 i = BIT(m_vdu_color, 3) ? ((m_video_ram[offset | 0] << 8) | m_video_ram[offset | 4]) : 0; - UINT16 r = BIT(m_vdu_color, 2) ? ((m_video_ram[offset | 1] << 8) | m_video_ram[offset | 5]) : 0; - UINT16 g = BIT(m_vdu_color, 1) ? ((m_video_ram[offset | 2] << 8) | m_video_ram[offset | 6]) : 0; - UINT16 b = BIT(m_vdu_color, 0) ? ((m_video_ram[offset | 3] << 8) | m_video_ram[offset | 7]) : 0; - - for (int x = 0; x < 16; x++) - { - *p = PALETTE_1512[de ? (BIT(i, 15) << 3) | (BIT(r, 15) << 2) | (BIT(g, 15) << 1) | BIT(b, 15) : 0]; p++; - i <<= 1; r <<= 1; g <<= 1; b <<= 1; - } - } -} - -MC6845_UPDATE_ROW( pc1512_state::crtc_update_row ) -{ - switch (get_display_mode(m_vdu_mode)) - { - case ALPHA_40: - case ALPHA_80: - draw_alpha(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - - case GRAPHICS_1: - draw_graphics_1(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - - case GRAPHICS_2: - draw_graphics_2(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - } -} - - -void pc1512_state::video_start() -{ - // allocate memory - m_video_ram.allocate(0x10000); -} - - -UINT32 pc1512_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - if (m_vdu_mode & MODE_ENABLE_VIDEO) - { - m_blink_ctr++; - - if (m_blink_ctr == 0x08) - { - m_cursor = !m_cursor; - } - else if (m_blink_ctr == 0x10) - { - m_cursor = !m_cursor; - m_blink = !m_blink; - m_blink_ctr = 0; - } - - switch (get_display_mode(m_vdu_mode)) - { - case ALPHA_40: - case GRAPHICS_1: - screen.set_visible_area(0, 359, 0, 245); - break; - - case ALPHA_80: - case GRAPHICS_2: - screen.set_visible_area(0, 831, 0, 245); - break; - } - - switch (get_display_mode(m_vdu_mode)) - { - case ALPHA_40: - case ALPHA_80: - case GRAPHICS_1: - bitmap.fill(PALETTE_1512[m_vdu_color & 0x0f], cliprect); - break; - - case GRAPHICS_2: - bitmap.fill(PALETTE_1512[m_vdu_border & 0x0f], cliprect); - break; - } - - m_vdu->screen_update(screen, bitmap, cliprect); - } - else - { - bitmap.fill(rgb_t::black, cliprect); - } - - return 0; -} - - -//------------------------------------------------- -// MACHINE_CONFIG( pc1512 ) -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( pc1512_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(pc1512_state, screen_update) - MCFG_SCREEN_SIZE(80*8, 24*8) - MCFG_SCREEN_VISIBLE_AREA(0, 80*8-1, 0, 24*8-1) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_REFRESH_RATE(50) - - MCFG_MC6845_ADD(AMS40041_TAG, AMS40041, SCREEN_TAG, XTAL_28_63636MHz/32) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(8) - MCFG_MC6845_UPDATE_ROW_CB(pc1512_state, crtc_update_row) -MACHINE_CONFIG_END diff --git a/src/mess/video/pc4.c b/src/mess/video/pc4.c deleted file mode 100644 index ce743569bd2..00000000000 --- a/src/mess/video/pc4.c +++ /dev/null @@ -1,196 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sandro Ronco -/*************************************************************************** - - VTech Laser PC4 LCD controller emulation - -***************************************************************************/ - -#include "emu.h" -#include "includes/pc4.h" - -void pc4_state::set_busy_flag(UINT16 usec) -{ - m_busy_flag = 1; - m_busy_timer->adjust( attotime::from_usec( usec ) ); -} - -UINT32 pc4_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(0, cliprect); - - if (m_display_on) - for (int l=0; l<4; l++) - for (int i=0; i<40; i++) - { - UINT16 char_pos = l*40 + i; - - for (int y=0; y<8; y++) - for (int x=0; x<5; x++) - if (m_ddram[char_pos] <= 0x10) - { - //draw CGRAM characters - bitmap.pix16(l*9 + y, i*6 + x) = BIT(m_cgram[(m_ddram[char_pos]&0x07)*8+y], 4-x); - } - else - { - //draw CGROM characters - bitmap.pix16(l*9 + y, i*6 + x) = BIT(m_region_charset->base()[m_ddram[char_pos]*8+y], 4-x); - - } - - // if is the correct position draw cursor and blink - if (char_pos == m_cursor_pos) - { - //draw the cursor - if (m_cursor_on) - for (int x=0; x<5; x++) - bitmap.pix16(l*9 + 7, i * 6 + x) = 1; - - if (!m_blink && m_blink_on) - for (int y=0; y<7; y++) - for (int x=0; x<5; x++) - bitmap.pix16(l*9 + y, i * 6 + x) = 1; - } - } - - return 0; - -} - -void pc4_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch(id) - { - case BUSY_TIMER: - m_busy_flag = 0; - break; - - case BLINKING_TIMER: - m_blink = !m_blink; - break; - } -} - -WRITE8_MEMBER(pc4_state::lcd_control_w) -{ - if (BIT(data, 7)) - { - m_ac_mode = 0; - m_cursor_pos = m_ac = data & 0x7f; - set_busy_flag(37); - } - else if (BIT(data, 6)) - { - m_ac_mode = 1; - m_ac = data & 0x3f; - set_busy_flag(37); - } - else if (BIT(data, 5)) - { - m_cursor_on = BIT(data, 3); - - set_busy_flag(37); - } - else if (BIT(data, 4)) - { - UINT8 direct = (BIT(data, 2)) ? +1 : -1; - - if (BIT(data, 3)) - m_disp_shift += direct; - else - { - m_ac += direct; - m_cursor_pos += direct; - } - - set_busy_flag(37); - } - else if (BIT(data, 3)) - { - m_display_on = BIT(data, 2); - //m_cursor_on = BIT(data, 1); - m_blink_on = BIT(data, 0); - - set_busy_flag(37); - } - else if (BIT(data, 2)) - { - m_direction = (BIT(data, 1)) ? +1 : -1; - m_shift_on = BIT(data, 0); - set_busy_flag(37); - } - else if (BIT(data, 1)) - { - m_ac = 0; - m_cursor_pos = 0; - m_ac_mode = 0; - m_direction = 1; - m_disp_shift = 0; - set_busy_flag(520); - } - else if (BIT(data, 0)) - { - m_ac = 0; - m_cursor_pos = 0; - m_ac_mode = 0; - m_direction = 1; - m_disp_shift = 0; - memset(m_ddram, 0x20, sizeof(m_ddram)); - set_busy_flag(520); - } -} - - -READ8_MEMBER(pc4_state::lcd_control_r) -{ - return m_busy_flag<<7 || m_ac&0x7f; -} - -void pc4_state::update_ac(void) -{ - int new_ac = m_ac + m_direction; - m_ac = (new_ac < 0) ? 0 : ((new_ac >= 0xa0) ? 0xa0 : new_ac); - - if (m_ac_mode == 0) - { - m_cursor_pos = m_ac; - // display is shifted only after a write - if (m_shift_on && m_data_bus_flag == 1) m_disp_shift += m_direction; - } - - m_data_bus_flag = 0; -} - -WRITE8_MEMBER( pc4_state::lcd_offset_w ) -{ - m_cursor_pos = m_ac = (data%0xa0); -} - - -WRITE8_MEMBER(pc4_state::lcd_data_w) -{ - if (m_ac_mode == 0) - m_ddram[m_ac] = data; - else - m_cgram[m_ac] = data; - - update_ac(); - set_busy_flag(41); -} - -READ8_MEMBER(pc4_state::lcd_data_r) -{ - UINT8 data; - - if (m_ac_mode == 0) - data = m_ddram[m_ac]; - else - data = m_cgram[m_ac]; - - m_data_bus_flag = 2; - update_ac(); - set_busy_flag(41); - - return data; -} diff --git a/src/mess/video/pc8401a.c b/src/mess/video/pc8401a.c deleted file mode 100644 index 1cac970396a..00000000000 --- a/src/mess/video/pc8401a.c +++ /dev/null @@ -1,102 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/pc8401a.h" -#include "pc8500.lh" - -/* PC-8401A */ - -PALETTE_INIT_MEMBER(pc8401a_state,pc8401a) -{ - palette.set_pen_color(0, rgb_t(39, 108, 51)); - palette.set_pen_color(1, rgb_t(16, 37, 84)); -} - -void pc8401a_state::video_start() -{ -} - -/* PC-8500 */ - -void pc8500_state::video_start() -{ -} - -UINT32 pc8500_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ -// m_lcdc->screen_update(screen, bitmap, cliprect); - - /* - if (strcmp(screen.tag(), SCREEN_TAG) == 0) - { - sed1330_update(m_lcdc, &bitmap, cliprect); - } - else - { - m_crtc->update(bitmap, cliprect); - } - */ - - return 0; -} - -/* SED1330 Interface */ - -static ADDRESS_MAP_START( pc8401a_lcdc, AS_0, 8, pc8401a_state ) - ADDRESS_MAP_GLOBAL_MASK(0x1fff) - AM_RANGE(0x0000, 0x1fff) AM_RAM -ADDRESS_MAP_END - -static ADDRESS_MAP_START( pc8500_lcdc, AS_0, 8, pc8401a_state ) - ADDRESS_MAP_GLOBAL_MASK(0x3fff) - AM_RANGE(0x0000, 0x3fff) AM_RAM -ADDRESS_MAP_END - - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( pc8401a_video ) -// MCFG_DEFAULT_LAYOUT(layout_pc8401a) - - MCFG_PALETTE_ADD("palette", 2) - MCFG_PALETTE_INIT_OWNER(pc8401a_state,pc8401a) - - /* LCD */ - MCFG_SCREEN_ADD(SCREEN_TAG, LCD) - MCFG_SCREEN_REFRESH_RATE(44) - MCFG_SCREEN_UPDATE_DEVICE(SED1330_TAG, sed1330_device, screen_update) - MCFG_SCREEN_SIZE(480, 128) - MCFG_SCREEN_VISIBLE_AREA(0, 480-1, 0, 128-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_SED1330_ADD(SED1330_TAG, 0, SCREEN_TAG, pc8401a_lcdc) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( pc8500_video ) - MCFG_DEFAULT_LAYOUT(layout_pc8500) - - MCFG_PALETTE_ADD("palette", 2+8) - MCFG_PALETTE_INIT_OWNER(pc8401a_state,pc8401a) - - /* LCD */ - MCFG_SCREEN_ADD(SCREEN_TAG, LCD) - MCFG_SCREEN_REFRESH_RATE(44) - MCFG_SCREEN_UPDATE_DEVICE(SED1330_TAG, sed1330_device, screen_update) - MCFG_SCREEN_SIZE(480, 208) - MCFG_SCREEN_VISIBLE_AREA(0, 480-1, 0, 200-1) - MCFG_SCREEN_PALETTE("palette") - - MCFG_SED1330_ADD(SED1330_TAG, 0, SCREEN_TAG, pc8500_lcdc) - - /* PC-8441A CRT */ - MCFG_SCREEN_ADD(CRT_SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(pc8500_state, screen_update) - MCFG_SCREEN_SIZE(80*8, 24*8) - MCFG_SCREEN_VISIBLE_AREA(0, 80*8-1, 0, 24*8-1) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_PALETTE("palette") - - MCFG_MC6845_ADD(MC6845_TAG, MC6845, CRT_SCREEN_TAG, 400000) - MCFG_MC6845_SHOW_BORDER_AREA(false) - MCFG_MC6845_CHAR_WIDTH(6) -MACHINE_CONFIG_END diff --git a/src/mess/video/pc_t1t.c b/src/mess/video/pc_t1t.c deleted file mode 100644 index e77c5339bd0..00000000000 --- a/src/mess/video/pc_t1t.c +++ /dev/null @@ -1,1033 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/*************************************************************************** - - IBM PC junior - Tandy 1000 Graphics Adapter (T1T) section - - Note that in the IBM PC Junior world, the term 'vga' is not the 'vga' that - most people think of - -***************************************************************************/ - -#include "emu.h" -#include "pc_t1t.h" -#include "machine/pic8259.h" -#include "machine/ram.h" - -enum -{ - T1000_TEXT_INTEN = 0, - T1000_TEXT_BLINK, - T1000_GFX_1BPP, - T1000_GFX_2BPP, - T1000_GFX_4BPP, - T1000_GFX_2BPP_TGA, - PCJX_TEXT, - PCJR_GFX_2BPP_HIGH -}; - - -const device_type PCVIDEO_T1000 = &device_creator; -const device_type PCVIDEO_PCJR = &device_creator; - -pc_t1t_device::pc_t1t_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source), - device_video_interface(mconfig, *this), - m_mc6845(*this, T1000_MC6845_NAME), - m_mode_control(0), - m_color_select(0), - m_status(0), - m_bank(0), - m_pc_framecnt(0), - m_displayram(NULL), - m_chr_gen(NULL), - m_chr_size(0), - m_ra_offset(0), - m_address_data_ff(0), - m_update_row_type(-1), - m_display_enable(0), - m_vsync(0), - m_palette_base(0), - m_palette(*this,"palette") -{ -} - -pcvideo_t1000_device::pcvideo_t1000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : pc_t1t_device(mconfig, PCVIDEO_T1000, "Tandy 1000 Graphics Adapter", tag, owner, clock, "tandy_1000_graphics_adapter", __FILE__), - m_t1_displayram(NULL) -{ -} - -pcvideo_pcjr_device::pcvideo_pcjr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : pc_t1t_device(mconfig, PCVIDEO_PCJR, "PC Jr Graphics Adapter", tag, owner, clock, "pcjr_graphics_adapter", __FILE__), - m_jxkanji(NULL) -{ -} - - -void pcvideo_t1000_device::device_start() -{ - m_chr_gen = machine().root_device().memregion("gfx1")->base(); - m_bank = 0; - m_chr_size = 1; - m_ra_offset = 256; -} - - -void pcvideo_pcjr_device::device_start() -{ - m_chr_gen = machine().root_device().memregion("gfx1")->base(); - m_bank = 0; - m_mode_control = 0x08; - m_chr_size = 8; - m_ra_offset = 1; - if(!strncmp(machine().system().name, "ibmpcjx", 7)) - m_jxkanji = machine().root_device().memregion("kanji")->base(); - else - m_jxkanji = NULL; -} - - -/*************************************************************************** - - Static declarations - -***************************************************************************/ - -MACHINE_CONFIG_FRAGMENT( pcvideo_t1000 ) - MCFG_SCREEN_ADD(T1000_SCREEN_NAME, RASTER) - MCFG_SCREEN_RAW_PARAMS(XTAL_14_31818MHz,912,0,640,262,0,200) - MCFG_SCREEN_UPDATE_DEVICE( T1000_MC6845_NAME, mc6845_device, screen_update ) - - MCFG_PALETTE_ADD( "palette", 32 ) - MCFG_PALETTE_INIT_OWNER(pc_t1t_device, pcjr) - - MCFG_MC6845_ADD(T1000_MC6845_NAME, MC6845, T1000_SCREEN_NAME, XTAL_14_31818MHz/8) - MCFG_MC6845_SHOW_BORDER_AREA(false) - MCFG_MC6845_CHAR_WIDTH(8) - MCFG_MC6845_UPDATE_ROW_CB(pc_t1t_device, crtc_update_row) - MCFG_MC6845_OUT_DE_CB(WRITELINE(pc_t1t_device, t1000_de_changed)) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(pcvideo_t1000_device, t1000_vsync_changed)) -MACHINE_CONFIG_END - -machine_config_constructor pcvideo_t1000_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( pcvideo_t1000 ); -} - - -MACHINE_CONFIG_FRAGMENT( pcvideo_pcjr ) - MCFG_SCREEN_ADD(T1000_SCREEN_NAME, RASTER) - MCFG_SCREEN_RAW_PARAMS(XTAL_14_31818MHz,912,0,640,262,0,200) - MCFG_SCREEN_UPDATE_DEVICE( T1000_MC6845_NAME, mc6845_device, screen_update ) - - MCFG_PALETTE_ADD( "palette", 32 ) - MCFG_PALETTE_INIT_OWNER(pc_t1t_device, pcjr) - - MCFG_MC6845_ADD(T1000_MC6845_NAME, MC6845, T1000_SCREEN_NAME, XTAL_14_31818MHz/16) - MCFG_MC6845_SHOW_BORDER_AREA(false) - MCFG_MC6845_CHAR_WIDTH(8) - MCFG_MC6845_UPDATE_ROW_CB(pcvideo_pcjr_device, crtc_update_row) - MCFG_MC6845_OUT_DE_CB(WRITELINE(pc_t1t_device, t1000_de_changed)) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(pcvideo_pcjr_device, pcjr_vsync_changed)) -MACHINE_CONFIG_END - -machine_config_constructor pcvideo_pcjr_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( pcvideo_pcjr ); -} - - -/*************************************************************************** - - Methods - -***************************************************************************/ - -/* Initialise the cga palette */ -PALETTE_INIT_MEMBER( pc_t1t_device, pcjr ) -{ - const static unsigned char tga_palette[16][3] = - { - { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0xaa }, { 0x00, 0xaa, 0x00 }, { 0x00, 0xaa, 0xaa }, - { 0xaa, 0x00, 0x00 }, { 0xaa, 0x00, 0xaa }, { 0xaa, 0x55, 0x00 }, { 0xaa, 0xaa, 0xaa }, - { 0x55, 0x55, 0x55 }, { 0x55, 0x55, 0xff }, { 0x55, 0xff, 0x55 }, { 0x55, 0xff, 0xff }, - { 0xff, 0x55, 0x55 }, { 0xff, 0x55, 0xff }, { 0xff, 0xff, 0x55 }, { 0xff, 0xff, 0xff } - }; - int i; - - /* colors */ - for(i = 0; i < 16; i++) - palette.set_pen_color(i, tga_palette[i][0], tga_palette[i][1], tga_palette[i][2]); - - /* b/w mode shades */ - for(i = 0; i < 16; i++) - palette.set_pen_color(16+i, ( i << 4 ) | i, ( i << 4 ) | i, ( i << 4 ) | i ); -} - - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_text_inten_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - int i; - - if ( y == 0 ) logerror("t1000_text_inten_update_row\n"); - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; - UINT8 chr = m_displayram[ offset ]; - UINT8 attr = m_displayram[ offset +1 ]; - UINT8 data = m_chr_gen[ chr * m_chr_size + ra * m_ra_offset ]; - UINT16 fg = m_palette_base + ( attr & 0x0F ); - UINT16 bg = m_palette_base + ( ( attr >> 4 ) & 0x07 ); - - if ( i == cursor_x && ( m_pc_framecnt & 0x08 ) ) - { - data = 0xFF; - } - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - } -} - - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_text_blink_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - int i; - - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; - UINT8 chr = m_displayram[ offset ]; - UINT8 attr = m_displayram[ offset +1 ]; - UINT8 data = m_chr_gen[ chr * m_chr_size + ra * m_ra_offset ]; - UINT16 fg = m_palette_base + ( attr & 0x0F ); - UINT16 bg = m_palette_base + ( ( attr >> 4 ) & 0x07 ); - - if ( i == cursor_x ) - { - if ( m_pc_framecnt & 0x08 ) - { - data = 0xFF; - } - } - else - { - if ( ( attr & 0x80 ) && ( m_pc_framecnt & 0x10 ) ) - { - data = 0x00; - } - } - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - } -} - -MC6845_UPDATE_ROW( pcvideo_pcjr_device::pcjx_text_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - int i; - - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; - UINT8 chr = m_displayram[ offset ]; - UINT8 attr = m_displayram[ offset +1 ]; - UINT16 fg = m_palette_base + ( attr & 0x07 ); - UINT16 bg = m_palette_base + ( ( attr >> 4 ) & 0x07 ); - UINT16 code = chr & 0x1f; - if((attr & 0x88) == 0x88) - { - code = m_displayram[ offset - 2 ] & 0x1f; - code = (code << 8) + chr; - } - else if(attr & 0x80) - code = (code << 8) + m_displayram[ offset + 2 ]; - else - code = chr; - - UINT8 data; - if(ra < 16) - data = m_jxkanji[code * 16 * 2 + (ra * 2) + ((attr & 8)?1:0)]; - else - data = ((i == cursor_x) && (m_pc_framecnt & 8)) ? 0xff: 0; - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - } -} - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_gfx_4bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT8 *vid = m_displayram + ( ra << 13 ); - int i; - - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; - UINT8 data = vid[ offset ]; - - *p = palette[m_palette_base + m_reg.data[0x10 + ( data >> 4 )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data >> 4 )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data & 0x0F )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data & 0x0F )]]; p++; - - data = vid[ offset + 1 ]; - - *p = palette[m_palette_base + m_reg.data[0x10 + ( data >> 4 )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data >> 4 )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data & 0x0F )]]; p++; - *p = palette[m_palette_base + m_reg.data[0x10 + ( data & 0x0F )]]; p++; - } -} - - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_gfx_2bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT8 *vid = m_displayram + ( ra << 13 ); - int i; - - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; - UINT8 data = vid[ offset ]; - - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( data & 0x03 ) ]]; p++; - - data = vid[ offset+1 ]; - - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( data & 0x03 ) ]]; p++; - } -} - - -MC6845_UPDATE_ROW( pcvideo_pcjr_device::pcjr_gfx_2bpp_high_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT8 *vid = m_displayram + ( ra << 13 ); - int i; - - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; - UINT8 data0 = vid[ offset ]; - UINT8 data1 = vid[ offset + 1 ]; - - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x80 ) >> 7 ) | ( ( data1 & 0x80 ) >> 6 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x40 ) >> 6 ) | ( ( data1 & 0x40 ) >> 5 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x20 ) >> 5 ) | ( ( data1 & 0x20 ) >> 4 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x10 ) >> 4 ) | ( ( data1 & 0x10 ) >> 3 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x08 ) >> 3 ) | ( ( data1 & 0x08 ) >> 2 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x04 ) >> 2 ) | ( ( data1 & 0x04 ) >> 1 ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x02 ) >> 1 ) | ( ( data1 & 0x02 ) ) ) ]]; p++; - *p = palette[m_palette_base + m_reg.data[ 0x10 + ( ( ( data0 & 0x01 ) ) | ( ( data1 & 0x01 ) << 1 ) ) ]]; p++; - } -} - - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_gfx_2bpp_tga_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT8 *vid = m_displayram + ( ra << 13 ); - int i; - - if ( y == 0 ) logerror("t1000_gfx_2bpp_tga_update_row\n"); - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; - UINT8 data = vid[ offset ]; - UINT16 data2 = ( vid[ offset + 1 ] ) << 1; - - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x100 ) | ( data & 0x80 ) ) >> 7 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x80 ) | ( data & 0x40 ) ) >> 6 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x40 ) | ( data & 0x20 ) ) >> 5 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x20 ) | ( data & 0x10 ) ) >> 4 ) ]]; p++; - - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x10 ) | ( data & 0x08 ) ) >> 3 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x08 ) | ( data & 0x04 ) ) >> 2 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( ( data2 & 0x04 ) | ( data & 0x02 ) ) >> 1 ) ]]; p++; - *p = palette[m_reg.data[ 0x10 + ( ( data2 & 0x02 ) | ( data & 0x01 ) ) ]]; p++; - } -} - - -MC6845_UPDATE_ROW( pc_t1t_device::t1000_gfx_1bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(y); - UINT8 *vid = m_displayram + ( ra << 13 ); - UINT8 fg = m_palette_base + m_reg.data[0x11]; - UINT8 bg = m_palette_base + m_reg.data[0x10]; - int i; - - if ( y == 0 ) logerror("t1000_gfx_1bpp_update_row\n"); - for ( i = 0; i < x_count; i++ ) - { - UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; - UINT8 data = vid[ offset ]; - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - - data = vid[ offset + 1 ]; - - *p = palette[( data & 0x80 ) ? fg : bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg]; p++; - *p = palette[( data & 0x20 ) ? fg : bg]; p++; - *p = palette[( data & 0x10 ) ? fg : bg]; p++; - *p = palette[( data & 0x08 ) ? fg : bg]; p++; - *p = palette[( data & 0x04 ) ? fg : bg]; p++; - *p = palette[( data & 0x02 ) ? fg : bg]; p++; - *p = palette[( data & 0x01 ) ? fg : bg]; p++; - } -} - -MC6845_UPDATE_ROW( pc_t1t_device::crtc_update_row ) -{ - if (m_update_row_type == -1) - return; - - switch (m_update_row_type) - { - case T1000_TEXT_INTEN: - t1000_text_inten_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case T1000_TEXT_BLINK: - t1000_text_blink_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case T1000_GFX_1BPP: - t1000_gfx_1bpp_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case T1000_GFX_2BPP: - t1000_gfx_2bpp_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case T1000_GFX_2BPP_TGA: - t1000_gfx_2bpp_tga_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case T1000_GFX_4BPP: - t1000_gfx_4bpp_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - } -} - - -MC6845_UPDATE_ROW( pcvideo_pcjr_device::crtc_update_row ) -{ - if (m_update_row_type == -1) - return; - - switch (m_update_row_type) - { - case PCJX_TEXT: - pcjx_text_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - case PCJR_GFX_2BPP_HIGH: - pcjr_gfx_2bpp_high_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - default: - pc_t1t_device::crtc_update_row(bitmap, cliprect, ma, ra, y, x_count, cursor_x, de, hbp, vbp); - break; - } -} - - -READ8_MEMBER( pcvideo_t1000_device::videoram_r ) -{ - UINT8 *videoram = m_t1_displayram; - int data = 0xff; - if( videoram ) - data = videoram[offset]; - return data; -} - -WRITE8_MEMBER( pcvideo_t1000_device::videoram_w ) -{ - UINT8 *videoram = m_t1_displayram; - if( videoram ) - videoram[offset] = data; -} - -void pcvideo_t1000_device::mode_switch( void ) -{ - switch( m_mode_control & 0x3B ) - { - case 0x08: case 0x09: - m_update_row_type = T1000_TEXT_INTEN; - break; - case 0x28: case 0x29: - m_update_row_type = T1000_TEXT_BLINK; - break; - case 0x0A: case 0x0B: case 0x2A: case 0x2B: - switch( m_bank & 0xc0 ) - { - case 0x00: - case 0x40: - //logerror("t1t_gfx_2bpp - 1\n"); - m_update_row_type = T1000_GFX_2BPP; - if ( m_color_select ) - { - m_reg.data[0x10] = 0x00; - m_reg.data[0x11] = 0x0B; - m_reg.data[0x12] = 0x0D; - m_reg.data[0x13] = 0x0F; - } - else - { - m_reg.data[0x10] = 0x00; - m_reg.data[0x11] = 0x0A; - m_reg.data[0x12] = 0x0C; - m_reg.data[0x13] = 0x0E; - } - break; - case 0x80: - case 0xc0: - //logerror("t1t_gfx_4bpp\n"); - m_update_row_type = T1000_GFX_4BPP; - break; - } - break; - case 0x18: case 0x19: case 0x1A: case 0x1B: - case 0x38: case 0x39: case 0x3A: case 0x3B: - switch( m_bank & 0xc0 ) - { - case 0x00: - case 0x40: - //logerror("t1t_gfx_1bpp\n"); - m_update_row_type = T1000_GFX_1BPP; - break; - case 0x80: - case 0xc0: - //logerror("t1t_gfx_2bpp - 2\n"); - m_update_row_type = T1000_GFX_2BPP_TGA; - break; - } - break; - default: - m_update_row_type = -1; - break; - } -} - - -/* mode control 1 ( m_reg.data[0] ) */ -/* bit0 - 0 = low bandwidth, 1 = high bandwidth */ -/* bit1 - 0 = alpha, 1 = graphics */ -/* bit2 - 0 = color, 1 = b/w */ -/* bit3 - 0 = video disable, 1 = video enable */ -/* bit4 - 1 = 16 color graphics */ -/* mode control 2 ( m_reg.data[3] ) */ -/* bit1 - 1 = enable blink */ -/* bit3 - 1 = 2 color graphics */ - -void pcvideo_pcjr_device::pc_pcjr_mode_switch() -{ - switch( m_reg.data[0] & 0x1A ) - { - case 0x08: /* 01x0x */ - if(m_jxkanji) - { - m_update_row_type = PCJX_TEXT; - break; - } - if ( m_reg.data[3] & 0x02 ) - { - m_update_row_type = T1000_TEXT_BLINK; - } - else - { - m_update_row_type = T1000_TEXT_INTEN; - } - break; - case 0x0A: /* 01x1x */ - /* By default use medium resolution mode */ - m_update_row_type = T1000_GFX_2BPP; - - /* Check for high resolution mode */ - if ( ( m_bank & 0xc0 ) == 0xc0 ) - m_update_row_type = PCJR_GFX_2BPP_HIGH; - - /* Check for 640x200 b/w 2 shades mode */ - if ( ( m_reg.data[0] & 0x04 ) && ( m_reg.data[3] & 0x08 ) ) - { - m_update_row_type = T1000_GFX_1BPP; - } - break; - case 0x18: /* 11x0x - invalid?? */ - m_update_row_type = -1; - break; - case 0x1A: /* 11x1x */ - m_update_row_type = T1000_GFX_4BPP; - break; - default: - m_update_row_type = -1; - break; - } - - /* Determine mc6845 input clock */ - if ( m_reg.data[0] & 0x01 ) - { - m_mc6845->set_clock( XTAL_14_31818MHz/8 ); - } - else - { - m_mc6845->set_clock( XTAL_14_31818MHz/16 ); - } - - /* color or b/w? */ - m_palette_base = ( m_reg.data[0] & 0x04 ) ? 16 : 0; -} - - -/* - * 3d8 rW T1T mode control register (see #P138) - */ -void pcvideo_t1000_device::mode_control_w(int data) -{ - m_mode_control = data; - - mode_switch(); -} - -int pc_t1t_device::mode_control_r(void) -{ - int data = m_mode_control; - return data; -} - -/* - * 3d9 ?W color select register on color adapter - */ -void pc_t1t_device::color_select_w(int data) -{ - if (m_color_select == data) - return; - m_color_select = data; -} - -int pc_t1t_device::color_select_r(void) -{ - int data = m_color_select; - return data; -} - -/* Bitfields for T1T status register: - * Bit(s) Description (Table P179) - * 7-6 not used - * 5-4 color EGA, color ET4000: diagnose video display feedback, select - * from color plane enable - * 4 holds current dot being displayed - * 3 in vertical retrace - * 2 (CGA,color EGA) light pen switch is off - * (MCGA,color ET4000) reserved (0) - * 1 (CGA,color EGA) positive edge from light pen has set trigger - * (MCGA,color ET4000) reserved (0) - * 0 display enabled - * =0 do not use memory - * =1 memory access without interfering with display - * (Genoa SuperEGA) horizontal or vertical retrace - */ -int pc_t1t_device::status_r(void) -{ - int data = m_vsync | m_status | m_display_enable; - /* HACK HACK HACK */ - data |= ( m_display_enable ? 0x10 : 0x00 ); - /* end HACK */ - return data; -} - -/* - * 3db -W light pen strobe reset (on any value) - */ -void pc_t1t_device::lightpen_strobe_w(int data) -{ -// pc_port[0x3db] = data; -} - - -/* - * 3da -W (mono EGA/mono VGA) feature control register - * (see PORT 03DAh-W for details; VGA, see PORT 03CAh-R) - */ -void pc_t1t_device::vga_index_w(int data) -{ - m_reg.index = data; -} - -void pcvideo_t1000_device::vga_data_w(int data) -{ - m_reg.data[m_reg.index] = data; - - switch (m_reg.index) - { - case 0x00: /* mode control 1 */ - break; - case 0x01: /* palette mask (bits 3-0) */ - break; - case 0x02: /* border color (bits 3-0) */ - break; - case 0x03: /* mode control 2 */ - break; - case 0x04: /* reset register */ - break; - /* palette array */ - case 0x10: case 0x11: case 0x12: case 0x13: - case 0x14: case 0x15: case 0x16: case 0x17: - case 0x18: case 0x19: case 0x1a: case 0x1b: - case 0x1c: case 0x1d: case 0x1e: case 0x1f: - m_reg.data[m_reg.index] = data & 0x0F; - break; - } -} - - -void pcvideo_pcjr_device::pc_pcjr_vga_data_w(int data) -{ - m_reg.data[m_reg.index] = data; - - switch (m_reg.index) - { - case 0x00: /* mode control 1 */ - /* bit0 - 0 = low bandwidth, 1 = high bandwidth */ - /* bit1 - 0 = alpha, 1 = graphics */ - /* bit2 - 0 = color, 1 = b/w */ - /* bit3 - 0 = video disable, 1 = video enable */ - /* bit4 - 1 = 16 color graphics */ - pc_pcjr_mode_switch(); - break; - case 0x01: /* palette mask (bits 3-0) */ - break; - case 0x02: /* border color (bits 3-0) */ - break; - case 0x03: /* mode control 2 */ - /* bit1 - 1 = enable blink */ - /* bit3 - 1 = 2 color graphics */ - pc_pcjr_mode_switch(); - break; - case 0x04: /* reset register */ - break; - /* palette array */ - case 0x10: case 0x11: case 0x12: case 0x13: - case 0x14: case 0x15: case 0x16: case 0x17: - case 0x18: case 0x19: case 0x1a: case 0x1b: - case 0x1c: case 0x1d: case 0x1e: case 0x1f: - m_reg.data[m_reg.index] = data & 0x0F; - break; - } -} - - -int pc_t1t_device::vga_data_r(void) -{ - int data = m_reg.data[m_reg.index]; - - switch (m_reg.index) - { - case 0x00: /* mode control 1 */ - break; - case 0x01: /* palette mask (bits 3-0) */ - break; - case 0x02: /* border color (bits 3-0) */ - break; - case 0x03: /* mode control 2 */ - break; - case 0x04: /* reset register */ - break; - /* palette array */ - case 0x10: case 0x11: case 0x12: case 0x13: - case 0x14: case 0x15: case 0x16: case 0x17: - case 0x18: case 0x19: case 0x1a: case 0x1b: - case 0x1c: case 0x1d: case 0x1e: case 0x1f: - break; - } - return data; -} - -/* - * 3df RW display bank, access bank, mode - * bit 0-2 Identifies the page of main memory being displayed in units of 16K. - * 0: 0K, 1: 16K...7: 112K. In 32K modes (bits 6-7 = 2) only 0,2,4 and - * 6 are valid, as the next page will also be used. - * 3-5 Identifies the page of main memory that can be read/written at B8000h - * in units of 16K. 0: 0K, 1: 16K...7: 112K. In 32K modes (bits 6-7 = 2) - * only 0,2,4 and 6 are valid, as the next page will also be used. - * 6-7 Display mode. 0: Text, 1: 16K graphics mode (4,5,6,8) - * 2: 32K graphics mode (9,Ah) - */ -void pcvideo_t1000_device::bank_w(int data) -{ - if (m_bank != data) - { - UINT8 *ram = machine().root_device().memregion("maincpu")->base(); - int dram, vram; - m_bank = data; - /* it seems the video ram is mapped to the last 128K of main memory */ -#if 1 - if ((data&0xc0)==0xc0) /* needed for lemmings */ - { - dram = 0x80000 + ((data & 0x06) << 14); - vram = 0x80000 + ((data & 0x30) << (14-3)); - } - else - { - dram = 0x80000 + ((data & 0x07) << 14); - vram = 0x80000 + ((data & 0x38) << (14-3)); - } -#else - dram = (data & 0x07) << 14; - vram = (data & 0x38) << (14-3); -#endif - m_t1_displayram = &ram[vram]; - m_displayram = &ram[dram]; - mode_switch(); - } -} - - -void pcvideo_pcjr_device::pc_pcjr_bank_w(int data) -{ - if (m_bank != data) - { - int dram, vram; - m_bank = data; - /* it seems the video ram is mapped to the last 128K of main memory */ - if ((data&0xc0)==0xc0) /* needed for lemmings */ - { - dram = ((data & 0x06) << 14); - vram = ((data & 0x30) << (14-3)); - } - else - { - dram = ((data & 0x07) << 14); - vram = ((data & 0x38) << (14-3)); - } - machine().root_device().membank( "bank14" )->set_base( machine().device(RAM_TAG)->pointer() + vram ); - m_displayram = machine().device(RAM_TAG)->pointer() + dram; - pc_pcjr_mode_switch(); - } -} - -void pcvideo_pcjr_device::pc_pcjx_bank_w(int data) -{ - if (m_bank != data) - { - int dram, vram; - m_bank = data; - /* this probably isn't right, but otherwise the memory test stomps on the vram */ - if ((data&0xc0)==0xc0) /* needed for lemmings */ - { - dram = 0x80000 + ((data & 0x06) << 14); - vram = 0x80000 + ((data & 0x30) << (14-3)); - } - else - { - dram = 0x80000 + ((data & 0x07) << 14); - vram = 0x80000 + ((data & 0x38) << (14-3)); - } - machine().root_device().membank( "bank14" )->set_base( machine().device(RAM_TAG)->pointer() + vram ); - m_displayram = machine().device(RAM_TAG)->pointer() + dram; - pc_pcjr_mode_switch(); - } -} - -int pc_t1t_device::bank_r(void) -{ - return m_bank; -} - -/************************************************************************* - * - * T1T - * Tandy 1000 / PCjr - * - *************************************************************************/ - -WRITE8_MEMBER( pcvideo_t1000_device::write ) -{ - switch( offset ) - { - case 0: case 2: case 4: case 6: - m_mc6845->address_w( space, offset, data ); - break; - case 1: case 3: case 5: case 7: - m_mc6845->register_w( space, offset, data ); - break; - case 8: - mode_control_w(data); - break; - case 9: - color_select_w(data); - break; - case 10: - vga_index_w(data); - break; - case 11: - lightpen_strobe_w(data); - break; - case 12: - break; - case 13: - break; - case 14: - vga_data_w(data); - break; - case 15: - bank_w(data); - break; - } -} - - -WRITE8_MEMBER( pcvideo_pcjr_device::write ) -{ - switch( offset ) - { - case 0: case 4: - m_mc6845->address_w( space, offset, data ); - break; - case 1: case 5: - m_mc6845->register_w( space, offset, data ); - break; - case 10: - if ( m_address_data_ff & 0x01 ) - { - pc_pcjr_vga_data_w( data ); - } - else - { - vga_index_w( data ); - } - m_address_data_ff ^= 0x01; - break; - case 11: - lightpen_strobe_w(data); - break; - case 12: - break; - case 15: - if(m_jxkanji) - pc_pcjx_bank_w(data); - else - pc_pcjr_bank_w(data); - break; - - default: - break; - } -} - - -READ8_MEMBER( pc_t1t_device::read ) -{ - int data = 0xff; - - switch( offset ) - { - case 0: case 2: case 4: case 6: - /* return last written mc6845 address value here? */ - break; - - case 1: case 3: case 5: case 7: - data = m_mc6845->register_r( space, offset ); - break; - - case 8: - data = mode_control_r(); - break; - - case 9: - data = color_select_r(); - break; - - case 10: - m_address_data_ff = 0; - data = status_r(); - break; - - case 11: - /* -W lightpen strobe reset */ - break; - - case 12: - case 13: - break; - - case 14: - data = vga_data_r(); - break; - - case 15: - data = bank_r(); - break; - } - return data; -} - - -WRITE_LINE_MEMBER( pc_t1t_device::t1000_de_changed ) -{ - m_display_enable = state ? 1 : 0; -} - - -WRITE_LINE_MEMBER( pcvideo_t1000_device::t1000_vsync_changed ) -{ - m_vsync = state ? 8 : 0; - if ( state ) - { - m_pc_framecnt++; - } -} - - -WRITE_LINE_MEMBER( pcvideo_pcjr_device::pcjr_vsync_changed ) -{ - m_vsync = state ? 8 : 0; - if ( state ) - { - m_pc_framecnt++; - } - machine().device("pic8259")->ir5_w(state); -} diff --git a/src/mess/video/pc_t1t.h b/src/mess/video/pc_t1t.h deleted file mode 100644 index 3c89cbc0b0f..00000000000 --- a/src/mess/video/pc_t1t.h +++ /dev/null @@ -1,147 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -#ifndef PC_T1T_H -#define PC_T1T_H - -#include "video/mc6845.h" - -#define T1000_SCREEN_NAME "screen" -#define T1000_MC6845_NAME "mc6845_t1000" - -// used in tandy1000hx; used in pcjr??? -struct reg -{ - reg() - { - index = 0; - memset(&data, 0, sizeof(data)); - } - - UINT8 index; - UINT8 data[0x20]; - /* see vgadoc - 0 mode control 1 - 1 palette mask - 2 border color - 3 mode control 2 - 4 reset - 0x10-0x1f palette registers - */ -}; - -class pc_t1t_device : public device_t, - public device_video_interface -{ -public: - // construction/destruction - pc_t1t_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - - DECLARE_PALETTE_INIT( pcjr ); - - DECLARE_WRITE_LINE_MEMBER( t1000_de_changed ); - - virtual MC6845_UPDATE_ROW( crtc_update_row ); - MC6845_UPDATE_ROW( t1000_text_inten_update_row ); - MC6845_UPDATE_ROW( t1000_text_blink_update_row ); - MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row ); - MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row ); - MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row ); - MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row ); - - required_device m_mc6845; - UINT8 m_mode_control, m_color_select; - UINT8 m_status; - - struct reg m_reg; - - UINT8 m_bank; - - int m_pc_framecnt; - - UINT8 *m_displayram; - - UINT8 *m_chr_gen; - UINT8 m_chr_size; - UINT16 m_ra_offset; - - UINT8 m_address_data_ff; - - int m_update_row_type; - UINT8 m_display_enable; - UINT8 m_vsync; - UINT8 m_palette_base; - - int mode_control_r(void); - void color_select_w(int data); - int color_select_r(void); - int status_r(void); - void lightpen_strobe_w(int data); - void vga_index_w(int data); - int vga_data_r(void); - int bank_r(void); - - DECLARE_READ8_MEMBER( read ); - required_device m_palette; -}; - -class pcvideo_t1000_device : public pc_t1t_device -{ -public: - // construction/destruction - pcvideo_t1000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_WRITE8_MEMBER( write ); - DECLARE_READ8_MEMBER( videoram_r ); - DECLARE_WRITE8_MEMBER( videoram_w ); - DECLARE_WRITE_LINE_MEMBER( t1000_vsync_changed ); - -protected: - virtual machine_config_constructor device_mconfig_additions() const; - virtual void device_start(); - -private: - UINT8 *m_t1_displayram; - void mode_switch( void ); - void vga_data_w(int data); - void bank_w(int data); - void mode_control_w(int data); -}; - -extern const device_type PCVIDEO_T1000; - -#define MCFG_PCVIDEO_T1000_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, PCVIDEO_T1000, 0) - -class pcvideo_pcjr_device : public pc_t1t_device -{ -public: - // construction/destruction - pcvideo_pcjr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_WRITE8_MEMBER( write ); - DECLARE_WRITE_LINE_MEMBER( pcjr_vsync_changed ); - - UINT8 *m_jxkanji; - - virtual MC6845_UPDATE_ROW( crtc_update_row ); - MC6845_UPDATE_ROW( pcjx_text_update_row ); - MC6845_UPDATE_ROW( pcjr_gfx_2bpp_high_update_row ); - -protected: - virtual machine_config_constructor device_mconfig_additions() const; - virtual void device_start(); - -private: - void pc_pcjr_mode_switch(); - void pc_pcjr_vga_data_w(int data); - void pc_pcjr_bank_w(int data); - void pc_pcjx_bank_w(int data); -}; - -extern const device_type PCVIDEO_PCJR; - -#define MCFG_PCVIDEO_PCJR_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, PCVIDEO_PCJR, 0) - - -#endif /* PC_T1T_H */ diff --git a/src/mess/video/pcd.c b/src/mess/video/pcd.c deleted file mode 100644 index 3c8f305c078..00000000000 --- a/src/mess/video/pcd.c +++ /dev/null @@ -1,396 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Carl - -#include "pcd.h" -#include "cpu/mcs51/mcs51.h" -#include "cpu/mcs48/mcs48.h" - -const device_type PCD_VIDEO = &device_creator; -const device_type PCX_VIDEO = &device_creator; - -pcdx_video_device::pcdx_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : - device_t(mconfig, type, name, tag, owner, clock, shortname, source), - m_maincpu(*this, ":maincpu"), - m_mcu(*this, "graphics"), - m_crtc(*this, "crtc"), - m_palette(*this, "palette"), - m_gfxdecode(*this, "gfxdecode") -{ -} - -pcd_video_device::pcd_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - pcdx_video_device(mconfig, PCD_VIDEO, "Siemens PC-D Video", tag, owner, clock, "pcd_video", __FILE__), - m_vram(32*1024), - m_charram(8*1024) -{ -} - -pcx_video_device::pcx_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - pcdx_video_device(mconfig, PCX_VIDEO, "Siemens PC-X Video", tag, owner, clock, "pcx_video", __FILE__), - device_serial_interface(mconfig, *this), - m_vram(4*1024), - m_charrom(*this, "char"), - m_pic2(*this, ":pic2"), - m_txd_handler(*this) -{ -} - -ROM_START( pcd_video ) - ROM_REGION(0x400, "graphics", 0) - ROM_LOAD("s36361-d321-v1.bin", 0x000, 0x400, CRC(69baeb2a) SHA1(98b9cd0f38c51b4988a3aed0efcf004bedd115ff)) -ROM_END - -const rom_entry *pcd_video_device::device_rom_region() const -{ - return ROM_NAME( pcd_video ); -} - -ROM_START( pcx_video ) - ROM_REGION(0x2000, "char", 0) - ROM_LOAD("d12-graka.bin", 0x0000, 0x2000, CRC(e4933c16) SHA1(932ae1f0cd2b029b7f5fc3d2d1679e70b25c0828)) - - ROM_REGION(0x6000, "graphics", 0) - ROM_LOAD("d40-graka.bin", 0x0000, 0x2000, CRC(dce48252) SHA1(0d9a575b2d001168a36864d7bd5db1c3aca5fb8d)) - ROM_LOAD("d39-graka.bin", 0x4000, 0x2000, CRC(02920e25) SHA1(145a6648d75c1dc4788f9bc7790281ef7e8f8426)) -ROM_END - -const rom_entry *pcx_video_device::device_rom_region() const -{ - return ROM_NAME( pcx_video ); -} - -static const gfx_layout pcd_charlayout = -{ - 8, 14, /* 8 x 14 characters */ - 512, /* 512 characters */ - 1, /* 1 bits per pixel */ - { 0 }, /* no bitplanes */ - /* x offsets */ - { 0, 1, 2, 3, 4, 5, 6, 7 }, - /* y offsets */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8 }, - 8*16 -}; - -static GFXDECODE_START( pcx ) - GFXDECODE_ENTRY( "char", 0x0000, pcd_charlayout, 0, 1 ) -GFXDECODE_END - -static MACHINE_CONFIG_FRAGMENT( pcd_video ) - MCFG_CPU_ADD("graphics", I8741, XTAL_16MHz/2) - MCFG_DEVICE_DISABLE() - - // video hardware - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_SIZE(640, 350) - MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 349) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_UPDATE_DEVICE("crtc", scn2674_device, screen_update) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", empty) - MCFG_PALETTE_ADD("palette", 3) - MCFG_PALETTE_INIT_OWNER(pcdx_video_device, pcdx) - - MCFG_SCN2674_VIDEO_ADD("crtc", 0, NULL); - MCFG_SCN2674_TEXT_CHARACTER_WIDTH(8) - MCFG_SCN2674_GFX_CHARACTER_WIDTH(16) - MCFG_SCN2674_DRAW_CHARACTER_CALLBACK_OWNER(pcd_video_device, display_pixels) - MCFG_VIDEO_SET_SCREEN("screen") -MACHINE_CONFIG_END - -machine_config_constructor pcd_video_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( pcd_video ); -} - -static ADDRESS_MAP_START( pcx_vid_map, AS_PROGRAM, 8, pcx_video_device ) - AM_RANGE(0x0000, 0x5fff) AM_ROM AM_REGION("graphics", 0) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( pcx_vid_io, AS_IO, 8, pcx_video_device ) - AM_RANGE(0x8000, 0x8007) AM_DEVREADWRITE("crtc", scn2674_device, read, write) - AM_RANGE(0x8008, 0x8008) AM_READ(unk_r) - AM_RANGE(0xa000, 0xa001) AM_READWRITE(vram_latch_r, vram_latch_w) - AM_RANGE(0xa002, 0xa003) AM_READWRITE(term_mcu_r, term_mcu_w) - AM_RANGE(0xc000, 0xc7ff) AM_RAM - AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITE(p1_w) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( pcx_vram, AS_0, 8, pcx_video_device ) - AM_RANGE(0x0000, 0x07ff) AM_READWRITE(vram_r, vram_w) -ADDRESS_MAP_END - -static MACHINE_CONFIG_FRAGMENT( pcx_video ) - MCFG_CPU_ADD("graphics", I8031, XTAL_24MHz/2) - MCFG_CPU_PROGRAM_MAP(pcx_vid_map) - MCFG_CPU_IO_MAP(pcx_vid_io) - - // video hardware - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_SIZE(640, 350) - MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 349) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_UPDATE_DEVICE("crtc", scn2674_device, screen_update) - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", pcx) - MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") - - MCFG_SCN2674_VIDEO_ADD("crtc", 0, INPUTLINE("graphics", MCS51_INT0_LINE)); - MCFG_SCN2674_TEXT_CHARACTER_WIDTH(8) - MCFG_SCN2674_GFX_CHARACTER_WIDTH(16) - MCFG_SCN2674_DRAW_CHARACTER_CALLBACK_OWNER(pcx_video_device, display_pixels) - MCFG_VIDEO_SET_SCREEN("screen") - MCFG_DEVICE_ADDRESS_MAP(AS_0, pcx_vram) -MACHINE_CONFIG_END - -machine_config_constructor pcx_video_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( pcx_video ); -} - -SCN2674_DRAW_CHARACTER_MEMBER(pcd_video_device::display_pixels) -{ - address <<= 1; - if(lg) - { - UINT16 data = m_vram[address + 1] | (m_vram[address] << 8); - for(int i = 0; i < 16; i++) - bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (15 - i))) ? 1 : 0); - } - else - { - UINT8 data, attr; - int bgnd = 0; - data = m_charram[m_vram[address] * 16 + linecount]; - attr = m_vram[address + 1]; - if(cursor && blink) - data = 0xff; - if(ul && (attr & 0x20)) - data = 0xff; - if(attr & 8) - bgnd = 2; - if(attr & 0x10) - data = ~data; - for(int i = 0; i < 8; i++) - bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (7 - i))) ? 1 : bgnd); - } -} - -SCN2674_DRAW_CHARACTER_MEMBER(pcx_video_device::display_pixels) -{ - UINT8 data; - address <<= 1; - data = m_charrom[m_vram[address] * 16 + linecount + (m_vram[address + 1] & 0x20 ? 4096 : 0)]; - if(cursor && blink) - data = 0xff; - if(m_p1 & 0x20) - data = ~data; - for(int i = 0; i < 8; i++) - bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (7 - i))) ? 1 : 0); -} - -PALETTE_INIT_MEMBER(pcdx_video_device, pcdx) -{ - palette.set_pen_color(0,rgb_t::black); - palette.set_pen_color(1,rgb_t::white); - palette.set_pen_color(2,rgb_t(128,128,128)); -} - -WRITE8_MEMBER(pcd_video_device::vram_w) -{ - if(m_vram_sw) - m_vram[offset] = data; - else if(!(offset & 1)) - { - offset >>= 1; - m_charram[offset & 0x1fff] = data; - m_gfxdecode->gfx(0)->mark_dirty(offset/16); - } -} - -READ8_MEMBER(pcd_video_device::vram_r) -{ - return m_vram[offset]; -} - -WRITE8_MEMBER(pcd_video_device::vram_sw_w) -{ - m_vram_sw = data & 1; -} - - -READ8_MEMBER(pcd_video_device::mcu_r) -{ - return 0x20; -} - -WRITE8_MEMBER(pcd_video_device::mcu_w) -{ -} - -READ8_MEMBER(pcx_video_device::term_r) -{ - switch(offset) - { - case 0: - m_pic2->ir0_w(CLEAR_LINE); - m_term_stat &= ~2; - return m_term_key; - case 1: - m_pic2->ir0_w(CLEAR_LINE); - return m_term_stat >> 1; - } - return 0xff; -} - -WRITE8_MEMBER(pcx_video_device::term_w) -{ - if(!offset) - { - m_mcu->set_input_line(MCS51_INT1_LINE, ASSERT_LINE); - m_term_char = data; - m_term_stat |= 4; - } -} - -READ8_MEMBER(pcx_video_device::term_mcu_r) -{ - switch(offset) - { - case 0: - m_mcu->set_input_line(MCS51_INT1_LINE, CLEAR_LINE); - m_pic2->ir0_w(ASSERT_LINE); - m_term_stat &= ~4; - return m_term_char; - case 1: - return m_term_stat; - } - return 0; -} - -WRITE8_MEMBER(pcx_video_device::term_mcu_w) -{ - if(!offset) - { - m_term_key = data; - m_pic2->ir0_w(ASSERT_LINE); - m_term_stat |= 2; - } -} - -WRITE8_MEMBER(pcx_video_device::vram_w) -{ - offset <<= 1; - m_vram[offset] = m_vram_latch_w[0]; - m_vram[offset+1] = m_vram_latch_w[1]; -} - -READ8_MEMBER(pcx_video_device::vram_r) -{ - offset <<= 1; - m_vram_latch_r[0] = m_vram[offset]; - m_vram_latch_r[1] = m_vram[offset+1]; - return m_vram[offset]; -} - -WRITE8_MEMBER(pcx_video_device::vram_latch_w) -{ - m_vram_latch_w[offset] = data; -} - -READ8_MEMBER(pcx_video_device::vram_latch_r) -{ - return m_vram_latch_r[offset]; -} - -READ8_MEMBER(pcdx_video_device::detect_r) -{ - return 0; -} - -WRITE8_MEMBER(pcdx_video_device::detect_w) -{ -} - -READ8_MEMBER(pcx_video_device::unk_r) -{ - return 0x80; -} - -WRITE8_MEMBER(pcx_video_device::p1_w) -{ - m_p1 = data; -} - -void pcd_video_device::device_start() -{ - m_maincpu->space(AS_IO).install_readwrite_handler(0xfb00, 0xfb01, 0, 0, read8_delegate(FUNC(pcdx_video_device::detect_r), this), write8_delegate(FUNC(pcdx_video_device::detect_w), this), 0xff00); - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf0000, 0xf7fff, 0, 0, read8_delegate(FUNC(pcd_video_device::vram_r), this), write8_delegate(FUNC(pcd_video_device::vram_w), this), 0xffff); - m_gfxdecode->set_gfx(0, global_alloc(gfx_element(machine().device("palette"), pcd_charlayout, &m_charram[0], 0, 1, 0))); -} - -void pcd_video_device::device_reset() -{ - m_vram_sw = 1; -} - -DEVICE_ADDRESS_MAP_START(map, 16, pcd_video_device) - AM_RANGE(0x00, 0x0f) AM_DEVWRITE8("crtc", scn2674_device, write, 0x00ff) - AM_RANGE(0x00, 0x0f) AM_DEVREAD8("crtc", scn2674_device, read, 0xff00) - AM_RANGE(0x20, 0x21) AM_WRITE8(vram_sw_w, 0x00ff) - AM_RANGE(0x30, 0x33) AM_READWRITE8(mcu_r, mcu_w, 0x00ff) -ADDRESS_MAP_END - -void pcx_video_device::device_start() -{ - mcs51_cpu_device *mcu = downcast(m_mcu.target()); - m_maincpu->space(AS_IO).install_readwrite_handler(0xfb00, 0xfb01, 0, 0, read8_delegate(FUNC(pcdx_video_device::detect_r), this), write8_delegate(FUNC(pcdx_video_device::detect_w), this), 0x00ff); - m_txd_handler.resolve_safe(); - - // set serial callbacks - mcu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(pcx_video_device, tx_callback)); - mcu->i8051_set_serial_rx_callback(READ8_DELEGATE(pcx_video_device, rx_callback)); - set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1); - set_rate(600*2); // FIXME: fix the keyboard when the mc2661 baud rate calc is fixed -} - -void pcx_video_device::device_reset() -{ - m_term_key = 0; - m_term_stat = 0; - transmit_register_reset(); - receive_register_reset(); - - m_txd_handler(1); -} - -DEVICE_ADDRESS_MAP_START(map, 16, pcx_video_device) - AM_RANGE(0x0, 0xf) AM_READWRITE8(term_r, term_w, 0xffff) -ADDRESS_MAP_END - -READ8_MEMBER(pcx_video_device::rx_callback) -{ - return get_received_char(); -} - -WRITE8_MEMBER(pcx_video_device::tx_callback) -{ - transmit_register_setup(data); -} - -void pcx_video_device::tra_callback() -{ - m_txd_handler(transmit_register_get_data_bit()); -} - -void pcx_video_device::rcv_complete() -{ - receive_register_extract(); - m_mcu->set_input_line(MCS51_RX_LINE, ASSERT_LINE); - m_mcu->set_input_line(MCS51_RX_LINE, CLEAR_LINE); -} - -void pcx_video_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - device_serial_interface::device_timer(timer, id, param, ptr); -} diff --git a/src/mess/video/pcd.h b/src/mess/video/pcd.h deleted file mode 100644 index 52b61298d52..00000000000 --- a/src/mess/video/pcd.h +++ /dev/null @@ -1,98 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Carl - -#ifndef _PCD_H_ -#define _PCD_H_ - -#include "emu.h" -#include "machine/pic8259.h" -#include "video/scn2674.h" - -#define MCFG_PCX_VIDEO_TXD_HANDLER(_devcb) \ - devcb = &pcx_video_device::set_txd_handler(*device, DEVCB_##_devcb); - -class pcdx_video_device : public device_t -{ -public: - pcdx_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - - virtual DECLARE_ADDRESS_MAP(map, 16) = 0; - DECLARE_READ8_MEMBER(detect_r); - DECLARE_WRITE8_MEMBER(detect_w); - DECLARE_PALETTE_INIT(pcdx); - -protected: - required_device m_maincpu; - required_device m_mcu; - required_device m_crtc; - required_device m_palette; - required_device m_gfxdecode; -}; - -class pcd_video_device : public pcdx_video_device -{ -public: - pcd_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_ADDRESS_MAP(map, 16); - DECLARE_ADDRESS_MAP(vram_map, 8); - DECLARE_READ8_MEMBER(mcu_r); - DECLARE_WRITE8_MEMBER(mcu_w); - DECLARE_WRITE8_MEMBER(vram_sw_w); - DECLARE_READ8_MEMBER(vram_r); - DECLARE_WRITE8_MEMBER(vram_w); - - virtual const rom_entry *device_rom_region() const; - virtual machine_config_constructor device_mconfig_additions() const; - SCN2674_DRAW_CHARACTER_MEMBER(display_pixels); -protected: - void device_start(); - void device_reset(); -private: - dynamic_buffer m_vram; - dynamic_buffer m_charram; - UINT8 m_vram_sw; -}; - -class pcx_video_device : public pcdx_video_device, - public device_serial_interface -{ -public: - pcx_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - template static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast(device).m_txd_handler.set_callback(object); } - - DECLARE_ADDRESS_MAP(map, 16); - DECLARE_READ8_MEMBER(term_r); - DECLARE_WRITE8_MEMBER(term_w); - DECLARE_READ8_MEMBER(term_mcu_r); - DECLARE_WRITE8_MEMBER(term_mcu_w); - DECLARE_READ8_MEMBER(rx_callback); - DECLARE_WRITE8_MEMBER(tx_callback); - DECLARE_READ8_MEMBER(vram_r); - DECLARE_WRITE8_MEMBER(vram_w); - DECLARE_READ8_MEMBER(vram_latch_r); - DECLARE_WRITE8_MEMBER(vram_latch_w); - DECLARE_READ8_MEMBER(unk_r); - DECLARE_WRITE8_MEMBER(p1_w); - - virtual const rom_entry *device_rom_region() const; - virtual machine_config_constructor device_mconfig_additions() const; - SCN2674_DRAW_CHARACTER_MEMBER(display_pixels); -protected: - void device_start(); - void device_reset(); - void tra_callback(); - void rcv_complete(); - void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); -private: - dynamic_buffer m_vram; - required_region_ptr m_charrom; - required_device m_pic2; - devcb_write_line m_txd_handler; - UINT8 m_term_key, m_term_char, m_term_stat, m_vram_latch_r[2], m_vram_latch_w[2], m_p1; -}; - -extern const device_type PCD_VIDEO; -extern const device_type PCX_VIDEO; - -#endif diff --git a/src/mess/video/pcw.c b/src/mess/video/pcw.c deleted file mode 100644 index f4d18761636..00000000000 --- a/src/mess/video/pcw.c +++ /dev/null @@ -1,187 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker -/*************************************************************************** - - pcw.c - - Functions to emulate the video hardware of the Amstrad PCW. - -***************************************************************************/ - -#include "emu.h" -#include "includes/pcw.h" -#include "machine/ram.h" - -inline void pcw_state::pcw_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -/*************************************************************************** - Start the video hardware emulation. -***************************************************************************/ - -void pcw_state::video_start() -{ - rectangle rect(0, PCW_PRINTER_WIDTH - 1, 0, PCW_PRINTER_HEIGHT - 1); - - m_prn_output = auto_bitmap_ind16_alloc(machine(),PCW_PRINTER_WIDTH,PCW_PRINTER_HEIGHT); - m_prn_output->fill(1, rect); -} - -#if 0 -/* two colours */ -static const unsigned short pcw_colour_table[PCW_NUM_COLOURS] = -{ - 0, 1 -}; -#endif - -/* black/white */ -static const rgb_t pcw_palette[PCW_NUM_COLOURS] = -{ - rgb_t(0x000, 0x000, 0x000), - rgb_t(0x0ff, 0x0ff, 0x0ff) -}; - - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(pcw_state, pcw) -{ - palette.set_pen_colors(0, pcw_palette, ARRAY_LENGTH(pcw_palette)); -} - -/*************************************************************************** - Draw the game screen in the given bitmap_ind16. - Do NOT call osd_update_display() from this function, - it will be called by the main emulation engine. -***************************************************************************/ -UINT32 pcw_state::screen_update_pcw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y,b; - unsigned short roller_ram_offs; - unsigned char *roller_ram_ptr; - int pen0,pen1; - - pen0 = 0; - pen1 = 1; - - /* invert? */ - if (m_vdu_video_control_register & (1<<7)) - { - /* yes */ - pen1^=1; - pen0^=1; - } - - /* video enable? */ - if ((m_vdu_video_control_register & (1<<6))!=0) - { - /* render top border */ - rectangle rect(0, PCW_SCREEN_WIDTH, 0, PCW_BORDER_HEIGHT); - bitmap.fill(pen0, rect); - - /* render bottom border */ - rect.set(0, PCW_SCREEN_WIDTH, PCW_BORDER_HEIGHT + PCW_DISPLAY_HEIGHT, PCW_BORDER_HEIGHT + PCW_DISPLAY_HEIGHT + PCW_BORDER_HEIGHT); - bitmap.fill(pen0, rect); - - /* offset to start in table */ - roller_ram_offs = (m_roller_ram_offset<<1); - - for (y=0; y<256; y++) - { - int by; - unsigned short line_data; - unsigned char *line_ptr; - - x = PCW_BORDER_WIDTH; - - roller_ram_ptr = m_ram->pointer() + m_roller_ram_addr + roller_ram_offs; - - /* get line address */ - /* b16-14 control which bank the line is to be found in, b13-3 the address in the bank (in 16-byte units), and b2-0 the offset. Thus a roller RAM address bbbxxxxxxxxxxxyyy indicates bank bbb, address 00xxxxxxxxxxx0yyy. */ - line_data = ((unsigned char *)roller_ram_ptr)[0] | (((unsigned char *)roller_ram_ptr)[1]<<8); - - /* calculate address of pixel data */ - line_ptr = m_ram->pointer() + ((line_data & 0x0e000)<<1) + ((line_data & 0x01ff8)<<1) + (line_data & 0x07); - - for (by=0; by<90; by++) - { - unsigned char byte; - - byte = line_ptr[0]; - - for (b=0; b<8; b++) - { - if (byte & 0x080) - { - pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen1); - } - else - { - pcw_plot_pixel(bitmap,x+b, y+PCW_BORDER_HEIGHT, pen0); - - } - byte = byte<<1; - } - - x = x + 8; - - - line_ptr = line_ptr+8; - } - - /* update offset, wrap within 512 byte range */ - roller_ram_offs+=2; - roller_ram_offs&=511; - - } - - /* render border */ - /* 8 pixels either side of display */ - for (y=0; y<256; y++) - { - pcw_plot_pixel(bitmap, 0, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 1, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 2, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 3, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 4, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 5, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 6, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, 7, y+PCW_BORDER_HEIGHT, pen0); - - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+0, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+1, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+2, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+3, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+4, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+5, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+6, y+PCW_BORDER_HEIGHT, pen0); - pcw_plot_pixel(bitmap, PCW_BORDER_WIDTH+PCW_DISPLAY_WIDTH+7, y+PCW_BORDER_HEIGHT, pen0); - } - } - else - { - /* not video - render whole lot in pen 0 */ - rectangle rect(0, PCW_SCREEN_WIDTH, 0, PCW_SCREEN_HEIGHT); - bitmap.fill(pen0, rect); - } - return 0; -} - -UINT32 pcw_state::screen_update_pcw_printer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - // printer output - INT32 feed; - rectangle rect(0, PCW_PRINTER_WIDTH - 1, 0, PCW_PRINTER_HEIGHT - 1); - feed = -(m_paper_feed / 2); - copyscrollbitmap(bitmap,*m_prn_output,0,NULL,1,&feed,rect); - bitmap.pix16(PCW_PRINTER_HEIGHT-1, m_printer_headpos) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-2, m_printer_headpos) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-3, m_printer_headpos) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-1, m_printer_headpos-1) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-2, m_printer_headpos-1) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-1, m_printer_headpos+1) = 0; - bitmap.pix16(PCW_PRINTER_HEIGHT-2, m_printer_headpos+1) = 0; - return 0; -} diff --git a/src/mess/video/pcw16.c b/src/mess/video/pcw16.c deleted file mode 100644 index 40324af4e7e..00000000000 --- a/src/mess/video/pcw16.c +++ /dev/null @@ -1,268 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker -#include "emu.h" -#include "includes/pcw16.h" -#include "machine/ram.h" - - -#if 0 -/* 16 colours, + 1 for border */ -static const unsigned short pcw16_colour_table[PCW16_NUM_COLOURS] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31 -}; -#endif - -static const rgb_t pcw16_palette[PCW16_NUM_COLOURS] = -{ - rgb_t(0x080, 0x080, 0x080), /* light grey */ - rgb_t(0x080, 0x080, 0x080), /* light grey */ - rgb_t(0x000, 0x080, 0x080), /* magenta */ - rgb_t(0x000, 0x080, 0x080), /* magenta */ - rgb_t(0x080, 0x080, 0x080), /* light grey */ - rgb_t(0x080, 0x080, 0x080), /* light grey */ - rgb_t(0x0ff, 0x080, 0x080), /* pastel green */ - rgb_t(0x0ff, 0x080, 0x080), /* pastel green */ - rgb_t(0x000, 0x000, 0x080), /* blue */ - rgb_t(0x000, 0x000, 0x000), /* black */ - rgb_t(0x000, 0x080, 0x0ff), /* mauve */ - rgb_t(0x000, 0x000, 0x0ff), /* bright blue */ - rgb_t(0x000, 0x080, 0x000), /* red */ - rgb_t(0x000, 0x0ff, 0x000), /* bright red */ - rgb_t(0x000, 0x0ff, 0x080), /* purple */ - rgb_t(0x000, 0x0ff, 0x0ff), /* bright magenta */ - rgb_t(0x0ff, 0x000, 0x080), /* sea green */ - rgb_t(0x0ff, 0x000, 0x0ff), /* bright green */ - rgb_t(0x0ff, 0x080, 0x0ff), /* pastel cyan */ - rgb_t(0x0ff, 0x000, 0x0ff), /* bright cyan */ - rgb_t(0x0ff, 0x080, 0x000), /* lime green */ - rgb_t(0x0ff, 0x0ff, 0x000), /* bright yellow */ - rgb_t(0x0ff, 0x0ff, 0x080), /* pastel yellow */ - rgb_t(0x0ff, 0x0ff, 0x0ff), /* bright white */ - rgb_t(0x080, 0x000, 0x080), /* cyan */ - rgb_t(0x080, 0x000, 0x000), /* green */ - rgb_t(0x080, 0x080, 0x0ff), /* pastel blue */ - rgb_t(0x080, 0x000, 0x0ff), /* sky blue */ - rgb_t(0x080, 0x080, 0x000), /* yellow */ - rgb_t(0x080, 0x0ff, 0x000), /* orange */ - rgb_t(0x080, 0x0ff, 0x080), /* pink */ - rgb_t(0x080, 0x0ff, 0x0ff), /* pastel magenta */ -}; - - -inline void pcw16_state::pcw16_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -/* Initialise the palette */ -PALETTE_INIT_MEMBER(pcw16_state, pcw16) -{ - palette.set_pen_colors(0, pcw16_palette, ARRAY_LENGTH(pcw16_palette)); -} - -void pcw16_state::video_start() -{ -} - -/* 640, 1 bit per pixel */ -void pcw16_state::pcw16_vh_decode_mode0(bitmap_ind16 &bitmap, int x, int y, unsigned char byte) -{ - int b; - int local_byte; - int cols[2]; - int px; - - local_byte = byte; - - cols[0] = m_colour_palette[0]; - cols[1] = m_colour_palette[1]; - - px = x; - for (b=0; b<8; b++) - { - pcw16_plot_pixel(bitmap, px, y, cols[(local_byte>>7) & 0x01]); - px++; - - local_byte = local_byte<<1; - } -} - -/* 320, 2 bits per pixel */ -void pcw16_state::pcw16_vh_decode_mode1(bitmap_ind16 &bitmap, int x, int y, unsigned char byte) -{ - int b; - int px; - int local_byte; - int cols[4]; - - for (b=0; b<3; b++) - { - cols[b] = m_colour_palette[b]; - } - - local_byte = byte; - - px = x; - for (b=0; b<4; b++) - { - int col; - - col = cols[((local_byte>>6) & 0x03)]; - - pcw16_plot_pixel(bitmap, px, y, col); - px++; - pcw16_plot_pixel(bitmap, px, y, col); - px++; - - local_byte = local_byte<<2; - } -} - -/* 160, 4 bits per pixel */ -void pcw16_state::pcw16_vh_decode_mode2(bitmap_ind16 &bitmap, int x, int y, unsigned char byte) -{ - int px; - int b; - int local_byte; - int cols[2]; - - cols[0] = m_colour_palette[0]; - cols[1] = m_colour_palette[1]; - local_byte = byte; - - px = x; - for (b=0; b<2; b++) - { - int col; - - col = cols[((local_byte>>4)&0x0f)]; - - pcw16_plot_pixel(bitmap, px, y, col); - px++; - pcw16_plot_pixel(bitmap, px, y, col); - px++; - pcw16_plot_pixel(bitmap, px, y, col); - px++; - pcw16_plot_pixel(bitmap, px, y, col); - px++; - - local_byte = local_byte<<4; - } -} - -/*************************************************************************** - Draw the game screen in the given bitmap_ind16. - Do NOT call osd_update_display() from this function, - it will be called by the main emulation engine. -***************************************************************************/ -UINT32 pcw16_state::screen_update_pcw16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *ram = m_ram->pointer(); - unsigned char *pScanLine = (unsigned char *)ram + 0x0fc00; //0x03c00; //0x020FC00; - - int y; - int x; - - int border_colour; - - border_colour = m_video_control & 31; - - /* reverse video? */ - if (m_video_control & (1<<7)) - { - /* colour 0 and colour 1 need to be inverted? - what happens in mode 1 and 2 - ignored? or is bit 1 toggled, - or is whole lot toggled? */ - - /* force border to be colour 1 */ - border_colour = m_colour_palette[1]; - } - - if ((m_video_control & (1<<6))==0) - { - /* blank */ - rectangle rect(0, PCW16_SCREEN_WIDTH, 0, PCW16_SCREEN_HEIGHT); - bitmap.fill(border_colour, rect); - } - else - { - /* no blank */ - - - /* render top border */ - rectangle rect(0, PCW16_SCREEN_WIDTH, 0, PCW16_BORDER_HEIGHT); - bitmap.fill(border_colour, rect); - - /* render bottom border */ - rect.set(0, PCW16_SCREEN_WIDTH, PCW16_BORDER_HEIGHT + PCW16_DISPLAY_HEIGHT, PCW16_BORDER_HEIGHT + PCW16_DISPLAY_HEIGHT + PCW16_BORDER_HEIGHT); - bitmap.fill(border_colour, rect); - - /* render border on either side of display */ - bitmap.plot_box(0, PCW16_BORDER_HEIGHT, 8, PCW16_DISPLAY_HEIGHT, border_colour); - bitmap.plot_box(PCW16_DISPLAY_WIDTH + PCW16_BORDER_WIDTH, PCW16_BORDER_HEIGHT, 8, PCW16_DISPLAY_HEIGHT, border_colour); - - /* render display */ - for (y=0; y>14) & 0x03); - - /* set initial x position */ - x = PCW16_BORDER_WIDTH; - - for (b=0; b<80; b++) - { - int byte; - - byte = ram[Addr]; - - switch (mode) - { - case 0: - { - pcw16_vh_decode_mode0(bitmap, x, y+PCW16_BORDER_HEIGHT, byte); - } - break; - - case 1: - { - pcw16_vh_decode_mode1(bitmap, x, y+PCW16_BORDER_HEIGHT, byte); - } - break; - - case 3: - case 2: - { - pcw16_vh_decode_mode2(bitmap, x, y+PCW16_BORDER_HEIGHT, byte); - } - break; - } - - /* only lowest 16 bits are incremented between fetches */ - Addr = ((Addr+1) & 0x0ffff) | AddrUpper; - - x=x+8; - } - - pScanLine+=2; - } - } - return 0; -} diff --git a/src/mess/video/pdp1.c b/src/mess/video/pdp1.c deleted file mode 100644 index 2e91b2cadeb..00000000000 --- a/src/mess/video/pdp1.c +++ /dev/null @@ -1,591 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - video/pdp1.c - - PDP1 video emulation. - - We emulate three display devices: - * CRT screen - * control panel - * typewriter output - - For the actual emulation of these devices look at the machine/pdp1.c. This - file only includes the display routines. - - Raphael Nabet 2002-2004 - Based on earlier work by Chris Salomon -*/ - -#include - -#include "emu.h" -#include "cpu/pdp1/pdp1.h" -#include "includes/pdp1.h" - - - - -inline void pdp1_state::pdp1_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = color; -} - -/* - video init -*/ -void pdp1_state::video_start() -{ - m_typewriter_color = color_typewriter_black; - - /* alloc bitmaps for our private fun */ - m_panel_bitmap.allocate(panel_window_width, panel_window_height, BITMAP_FORMAT_IND16); - m_typewriter_bitmap.allocate(typewriter_window_width, typewriter_window_height, BITMAP_FORMAT_IND16); - - /* set up out bitmaps */ - pdp1_draw_panel_backdrop(m_panel_bitmap); - - const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1); - m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds); -} - - -void pdp1_state::screen_eof_pdp1(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - m_crt->eof(); - } -} - -/* - schedule a pixel to be plotted -*/ -void pdp1_state::pdp1_plot(int x, int y) -{ - /* compute pixel coordinates and plot */ - x = x*crt_window_width/01777; - y = y*crt_window_height/01777; - m_crt->plot(x, y); -} - - -/* - video_update_pdp1: effectively redraw the screen -*/ -UINT32 pdp1_state::screen_update_pdp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - pdp1_erase_lightpen(bitmap); - m_crt->update(bitmap); - pdp1_draw_lightpen(bitmap); - - pdp1_draw_panel(m_panel_bitmap); - copybitmap(bitmap, m_panel_bitmap, 0, 0, panel_window_offset_x, panel_window_offset_y, cliprect); - - copybitmap(bitmap, m_typewriter_bitmap, 0, 0, typewriter_window_offset_x, typewriter_window_offset_y, cliprect); - return 0; -} - - - -/* - Operator control panel code -*/ - -enum -{ - x_panel_col1_offset = 8, - x_panel_col2_offset = x_panel_col1_offset+144+8, - x_panel_col3_offset = x_panel_col2_offset+96+8 -}; - -enum -{ - /* column 1: registers, test word, test address */ - y_panel_pc_offset = 0, - y_panel_ma_offset = y_panel_pc_offset+2*8, - y_panel_mb_offset = y_panel_ma_offset+2*8, - y_panel_ac_offset = y_panel_mb_offset+2*8, - y_panel_io_offset = y_panel_ac_offset+2*8, - y_panel_ta_offset = y_panel_io_offset+2*8, /* test address and extend switch */ - y_panel_tw_offset = y_panel_ta_offset+2*8, - - /* column 2: 1-bit indicators */ - y_panel_run_offset = 8, - y_panel_cyc_offset = y_panel_run_offset+8, - y_panel_defer_offset = y_panel_cyc_offset+8, - y_panel_hs_cyc_offset = y_panel_defer_offset+8, - y_panel_brk_ctr_1_offset = y_panel_hs_cyc_offset+8, - y_panel_brk_ctr_2_offset = y_panel_brk_ctr_1_offset+8, - y_panel_ov_offset = y_panel_brk_ctr_2_offset+8, - y_panel_rim_offset = y_panel_ov_offset+8, - y_panel_sbm_offset = y_panel_rim_offset+8, - y_panel_exd_offset = y_panel_sbm_offset+8, - y_panel_ioh_offset = y_panel_exd_offset+8, - y_panel_ioc_offset = y_panel_ioh_offset+8, - y_panel_ios_offset = y_panel_ioc_offset+8, - - /* column 3: power, single step, single inst, sense, flags, instr... */ - y_panel_power_offset = 8, - y_panel_sngl_step_offset = y_panel_power_offset+8, - y_panel_sngl_inst_offset = y_panel_sngl_step_offset+8, - y_panel_sep1_offset = y_panel_sngl_inst_offset+8, - y_panel_ss_offset = y_panel_sep1_offset+8, - y_panel_sep2_offset = y_panel_ss_offset+3*8, - y_panel_pf_offset = y_panel_sep2_offset+8, - y_panel_ir_offset = y_panel_pf_offset+2*8 -}; - -/* draw a small 8*8 LED (or is this a lamp? ) */ -void pdp1_state::pdp1_draw_led(bitmap_ind16 &bitmap, int x, int y, int state) -{ - int xx, yy; - - for (yy=1; yy<7; yy++) - for (xx=1; xx<7; xx++) - pdp1_plot_pixel(bitmap, x+xx, y+yy, state ? pen_lit_lamp : pen_unlit_lamp); -} - -/* draw nb_bits leds which represent nb_bits bits in value */ -void pdp1_state::pdp1_draw_multipleled(bitmap_ind16 &bitmap, int x, int y, int value, int nb_bits) -{ - while (nb_bits) - { - nb_bits--; - - pdp1_draw_led(bitmap, x, y, (value >> nb_bits) & 1); - - x += 8; - } -} - - -/* draw a small 8*8 switch */ -void pdp1_state::pdp1_draw_switch(bitmap_ind16 &bitmap, int x, int y, int state) -{ - int xx, yy; - int i; - - /* erase area */ - for (yy=0; yy<8; yy++) - for (xx=0; xx<8; xx++) - pdp1_plot_pixel(bitmap, x+xx, y+yy, pen_panel_bg); - - - /* draw nut (-> circle) */ - for (i=0; i<4;i++) - { - pdp1_plot_pixel(bitmap, x+2+i, y+1, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+2+i, y+6, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+1, y+2+i, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+6, y+2+i, pen_switch_nut); - } - pdp1_plot_pixel(bitmap, x+2, y+2, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+5, y+2, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+2, y+5, pen_switch_nut); - pdp1_plot_pixel(bitmap, x+5, y+5, pen_switch_nut); - - /* draw button (->disc) */ - if (! state) - y += 4; - for (i=0; i<2;i++) - { - pdp1_plot_pixel(bitmap, x+3+i, y, pen_switch_button); - pdp1_plot_pixel(bitmap, x+3+i, y+3, pen_switch_button); - } - for (i=0; i<4;i++) - { - pdp1_plot_pixel(bitmap, x+2+i, y+1, pen_switch_button); - pdp1_plot_pixel(bitmap, x+2+i, y+2, pen_switch_button); - } -} - - -/* draw nb_bits switches which represent nb_bits bits in value */ -void pdp1_state::pdp1_draw_multipleswitch(bitmap_ind16 &bitmap, int x, int y, int value, int nb_bits) -{ - while (nb_bits) - { - nb_bits--; - - pdp1_draw_switch(bitmap, x, y, (value >> nb_bits) & 1); - - x += 8; - } -} - - -/* write a single char on screen */ -void pdp1_state::pdp1_draw_char(bitmap_ind16 &bitmap, char character, int x, int y, int color) -{ - m_gfxdecode->gfx(0)->transpen(bitmap,bitmap.cliprect(), character-32, color, 0, 0, - x+1, y, 0); -} - -/* write a string on screen */ -void pdp1_state::pdp1_draw_string(bitmap_ind16 &bitmap, const char *buf, int x, int y, int color) -{ - while (* buf) - { - pdp1_draw_char(bitmap, *buf, x, y, color); - - x += 8; - buf++; - } -} - - -/* - draw the operator control panel (fixed backdrop) -*/ -void pdp1_state::pdp1_draw_panel_backdrop(bitmap_ind16 &bitmap) -{ - /* fill with black */ - const rectangle panel_bitmap_bounds(0, panel_window_width-1, 0, panel_window_height-1); - m_panel_bitmap.fill(pen_panel_bg, panel_bitmap_bounds); - - /* column 1: registers, test word, test address */ - pdp1_draw_string(bitmap, "program counter", x_panel_col1_offset, y_panel_pc_offset, color_panel_caption); - pdp1_draw_string(bitmap, "memory address", x_panel_col1_offset, y_panel_ma_offset, color_panel_caption); - pdp1_draw_string(bitmap, "memory buffer", x_panel_col1_offset, y_panel_mb_offset, color_panel_caption); - pdp1_draw_string(bitmap, "accumulator", x_panel_col1_offset, y_panel_ac_offset, color_panel_caption); - pdp1_draw_string(bitmap, "in-out", x_panel_col1_offset, y_panel_io_offset, color_panel_caption); - pdp1_draw_string(bitmap, "extend address", x_panel_col1_offset, y_panel_ta_offset, color_panel_caption); - pdp1_draw_string(bitmap, "test word", x_panel_col1_offset, y_panel_tw_offset, color_panel_caption); - - /* column separator */ - bitmap.plot_box(x_panel_col2_offset-4, panel_window_offset_y+8, 1, 96, pen_panel_caption); - - /* column 2: 1-bit indicators */ - pdp1_draw_string(bitmap, "run", x_panel_col2_offset+8, y_panel_run_offset, color_panel_caption); - pdp1_draw_string(bitmap, "cycle", x_panel_col2_offset+8, y_panel_cyc_offset, color_panel_caption); - pdp1_draw_string(bitmap, "defer", x_panel_col2_offset+8, y_panel_defer_offset, color_panel_caption); - pdp1_draw_string(bitmap, "h. s. cycle", x_panel_col2_offset+8, y_panel_hs_cyc_offset, color_panel_caption); - pdp1_draw_string(bitmap, "brk. ctr. 1", x_panel_col2_offset+8, y_panel_brk_ctr_1_offset, color_panel_caption); - pdp1_draw_string(bitmap, "brk. ctr. 2", x_panel_col2_offset+8, y_panel_brk_ctr_2_offset, color_panel_caption); - pdp1_draw_string(bitmap, "overflow", x_panel_col2_offset+8, y_panel_ov_offset, color_panel_caption); - pdp1_draw_string(bitmap, "read in", x_panel_col2_offset+8, y_panel_rim_offset, color_panel_caption); - pdp1_draw_string(bitmap, "seq. break", x_panel_col2_offset+8, y_panel_sbm_offset, color_panel_caption); - pdp1_draw_string(bitmap, "extend", x_panel_col2_offset+8, y_panel_exd_offset, color_panel_caption); - pdp1_draw_string(bitmap, "i-o halt", x_panel_col2_offset+8, y_panel_ioh_offset, color_panel_caption); - pdp1_draw_string(bitmap, "i-o com'ds", x_panel_col2_offset+8, y_panel_ioc_offset, color_panel_caption); - pdp1_draw_string(bitmap, "i-o sync", x_panel_col2_offset+8, y_panel_ios_offset, color_panel_caption); - - /* column separator */ - bitmap.plot_box(x_panel_col3_offset-4, panel_window_offset_y+8, 1, 96, pen_panel_caption); - - /* column 3: power, single step, single inst, sense, flags, instr... */ - pdp1_draw_string(bitmap, "power", x_panel_col3_offset+16, y_panel_power_offset, color_panel_caption); - pdp1_draw_string(bitmap, "single step", x_panel_col3_offset+16, y_panel_sngl_step_offset, color_panel_caption); - pdp1_draw_string(bitmap, "single inst.", x_panel_col3_offset+16, y_panel_sngl_inst_offset, color_panel_caption); - /* separator */ - bitmap.plot_box(x_panel_col3_offset+8, y_panel_sep1_offset+4, 96, 1, pen_panel_caption); - pdp1_draw_string(bitmap, "sense switches", x_panel_col3_offset, y_panel_ss_offset, color_panel_caption); - /* separator */ - bitmap.plot_box(x_panel_col3_offset+8, y_panel_sep2_offset+4, 96, 1, pen_panel_caption); - pdp1_draw_string(bitmap, "program flags", x_panel_col3_offset, y_panel_pf_offset, color_panel_caption); - pdp1_draw_string(bitmap, "instruction", x_panel_col3_offset, y_panel_ir_offset, color_panel_caption); -} - -/* - draw the operator control panel (dynamic elements) -*/ -void pdp1_state::pdp1_draw_panel(bitmap_ind16 &bitmap) -{ - /* column 1: registers, test word, test address */ - pdp1_draw_multipleled(bitmap, x_panel_col1_offset+16, y_panel_pc_offset+8,m_maincpu->state_int(PDP1_PC), 16); - pdp1_draw_multipleled(bitmap, x_panel_col1_offset+16, y_panel_ma_offset+8,m_maincpu->state_int(PDP1_MA), 16); - pdp1_draw_multipleled(bitmap, x_panel_col1_offset, y_panel_mb_offset+8,m_maincpu->state_int(PDP1_MB), 18); - pdp1_draw_multipleled(bitmap, x_panel_col1_offset, y_panel_ac_offset+8,m_maincpu->state_int(PDP1_AC), 18); - pdp1_draw_multipleled(bitmap, x_panel_col1_offset, y_panel_io_offset+8,m_maincpu->state_int(PDP1_IO), 18); - pdp1_draw_switch(bitmap, x_panel_col1_offset, y_panel_ta_offset+8,m_maincpu->state_int(PDP1_EXTEND_SW)); - pdp1_draw_multipleswitch(bitmap, x_panel_col1_offset+16, y_panel_ta_offset+8,m_maincpu->state_int(PDP1_TA), 16); - pdp1_draw_multipleswitch(bitmap, x_panel_col1_offset, y_panel_tw_offset+8,m_maincpu->state_int(PDP1_TW), 18); - - /* column 2: 1-bit indicators */ - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_run_offset,m_maincpu->state_int(PDP1_RUN)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_cyc_offset,m_maincpu->state_int(PDP1_CYC)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_defer_offset,m_maincpu->state_int(PDP1_DEFER)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_hs_cyc_offset, 0); /* not emulated */ - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_brk_ctr_1_offset,m_maincpu->state_int(PDP1_BRK_CTR) & 1); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_brk_ctr_2_offset,m_maincpu->state_int(PDP1_BRK_CTR) & 2); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_ov_offset,m_maincpu->state_int(PDP1_OV)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_rim_offset,m_maincpu->state_int(PDP1_RIM)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_sbm_offset,m_maincpu->state_int(PDP1_SBM)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_exd_offset,m_maincpu->state_int(PDP1_EXD)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_ioh_offset,m_maincpu->state_int(PDP1_IOH)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_ioc_offset,m_maincpu->state_int(PDP1_IOC)); - pdp1_draw_led(bitmap, x_panel_col2_offset, y_panel_ios_offset,m_maincpu->state_int(PDP1_IOS)); - - /* column 3: power, single step, single inst, sense, flags, instr... */ - pdp1_draw_led(bitmap, x_panel_col3_offset, y_panel_power_offset, 1); /* always on */ - pdp1_draw_switch(bitmap, x_panel_col3_offset+8, y_panel_power_offset, 1); /* always on */ - pdp1_draw_led(bitmap, x_panel_col3_offset, y_panel_sngl_step_offset,m_maincpu->state_int(PDP1_SNGL_STEP)); - pdp1_draw_switch(bitmap, x_panel_col3_offset+8, y_panel_sngl_step_offset,m_maincpu->state_int(PDP1_SNGL_STEP)); - pdp1_draw_led(bitmap, x_panel_col3_offset, y_panel_sngl_inst_offset,m_maincpu->state_int(PDP1_SNGL_INST)); - pdp1_draw_switch(bitmap, x_panel_col3_offset+8, y_panel_sngl_inst_offset,m_maincpu->state_int(PDP1_SNGL_INST)); - pdp1_draw_multipleled(bitmap, x_panel_col3_offset, y_panel_ss_offset+8,m_maincpu->state_int(PDP1_SS), 6); - pdp1_draw_multipleswitch(bitmap, x_panel_col3_offset, y_panel_ss_offset+16,m_maincpu->state_int(PDP1_SS), 6); - pdp1_draw_multipleled(bitmap, x_panel_col3_offset, y_panel_pf_offset+8,m_maincpu->state_int(PDP1_PF), 6); - pdp1_draw_multipleled(bitmap, x_panel_col3_offset, y_panel_ir_offset+8,m_maincpu->state_int(PDP1_IR), 5); -} - - -/* - Typewriter code -*/ - - - - -enum -{ - typewriter_line_height = 8, - typewriter_write_offset_y = typewriter_window_height-typewriter_line_height, - typewriter_scroll_step = typewriter_line_height -}; - -enum -{ - tab_step = 8 -}; - - -void pdp1_state::pdp1_typewriter_linefeed() -{ - UINT8 buf[typewriter_window_width]; - int y; - - for (y=0; ypens()); - } - - const rectangle typewriter_scroll_clear_window(0, typewriter_window_width-1, typewriter_window_height-typewriter_scroll_step, typewriter_window_height-1); - m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_scroll_clear_window); -} - -void pdp1_state::pdp1_typewriter_drawchar(int character) -{ - static const char ascii_table[2][64] = - { /* n-s = non-spacing */ - { /* lower case */ - ' ', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', '*', '*', - '*', '*', '*', '*', - '0', '/', 's', 't', - 'u', 'v', 'w', 'x', - 'y', 'z', '*', ',', - '*',/*black*/ '*',/*red*/ '*',/*Tab*/ '*', - '\200',/*n-s middle dot*/'j', 'k', 'l', - 'm', 'n', 'o', 'p', - 'q', 'r', '*', '*', - '-', ')', '\201',/*n-s overstrike*/'(', - '*', 'a', 'b', 'c', - 'd', 'e', 'f', 'g', - 'h', 'i', '*',/*Lower Case*/ '.', - '*',/*Upper Case*/ '*',/*Backspace*/ '*', '*'/*Carriage Return*/ - }, - { /* upper case */ - ' ', '"', '\'', '~', - '\202',/*implies*/ '\203',/*or*/ '\204',/*and*/ '<', - '>', '\205',/*up arrow*/ '*', '*', - '*', '*', '*', '*', - '\206',/*right arrow*/'?', 'S', 'T', - 'U', 'V', 'W', 'X', - 'Y', 'Z', '*', '=', - '*',/*black*/ '*',/*red*/ '*',/*Tab*/ '*', - '_',/*n-s???*/ 'J', 'K', 'L', - 'M', 'N', 'O', 'P', - 'Q', 'R', '*', '*', - '+', ']', '|',/*n-s???*/ '[', - '*', 'A', 'B', 'C', - 'D', 'E', 'F', 'G', - 'H', 'I', '*',/*Lower Case*/ '\207',/*multiply*/ - '*',/*Upper Case*/ '*',/*Backspace*/ '*', '*'/*Carriage Return*/ - } - }; - - - - character &= 0x3f; - - switch (character) - { - case 034: - /* Black */ - m_typewriter_color = color_typewriter_black; - break; - - case 035: - /* Red */ - m_typewriter_color = color_typewriter_red; - break; - - case 036: - /* Tab */ - m_pos = m_pos + tab_step - (m_pos % tab_step); - break; - - case 072: - /* Lower case */ - m_case_shift = 0; - break; - - case 074: - /* Upper case */ - m_case_shift = 1; - break; - - case 075: - /* Backspace */ - if (m_pos) - m_pos--; - break; - - case 077: - /* Carriage Return */ - m_pos = 0; - pdp1_typewriter_linefeed(); - break; - - default: - /* Any printable character... */ - - if (m_pos >= 80) - { /* if past right border, wrap around. (Right???) */ - pdp1_typewriter_linefeed(); /* next line */ - m_pos = 0; /* return to start of line */ - } - - /* print character (lookup ASCII equivalent in table) */ - pdp1_draw_char(m_typewriter_bitmap, ascii_table[m_case_shift][character], - 8*m_pos, typewriter_write_offset_y, - m_typewriter_color); /* print char */ - - if ((character!= 040) && (character!= 056)) /* 040 and 056 are non-spacing characters */ - m_pos++; /* step carriage forward */ - - break; - } -} - - - -/* - lightpen code -*/ - -void pdp1_state::pdp1_update_lightpen_state(const lightpen_t *new_state) -{ - m_lightpen_state = *new_state; -} - -#if 1 -void pdp1_state::pdp1_draw_circle(bitmap_ind16 &bitmap, int x, int y, int radius, int color_) -{ - int interval; - int a; - - x = x*crt_window_width/01777; - y = y*crt_window_width/01777; - radius = radius*crt_window_width/01777; - - interval = ceil(radius/sqrt(2.)); - - for (a=0; a<=interval; a++) - { - int b = sqrt((double)radius*radius-a*a) + .5; - - if ((x-a >= 0) && (y-b >= 0)) - pdp1_plot_pixel(bitmap, x-a, y-b, color_); - if ((x-a >= 0) && (y+b <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, x-a, y+b, color_); - if ((x+a <= crt_window_width-1) && (y-b >= 0)) - pdp1_plot_pixel(bitmap, x+a, y-b, color_); - if ((x+a <= crt_window_width-1) && (y+b <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, x+a, y+b, color_); - - if ((x-b >= 0) && (y-a >= 0)) - pdp1_plot_pixel(bitmap, x-b, y-a, color_); - if ((x-b >= 0) && (y+a <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, x-b, y+a, color_); - if ((x+b <= crt_window_width-1) && (y-a >= 0)) - pdp1_plot_pixel(bitmap, x+b, y-a, color_); - if ((x+b <= crt_window_width-1) && (y+a <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, x+b, y+a, color_); - } -} -#else -void pdp1_state::pdp1_draw_circle(bitmap_ind16 &bitmap, int x, int y, int radius, int color) -{ - float fx, fy; - float interval; - - - fx = (float)x*crt_window_width/01777; - fy = (float)y*crt_window_height/01777; - - interval = radius/sqrt(2.); - - for (x=/*ceil*/(fx-interval); x<=fx+interval; x++) - { - float dy = sqrt(radius*radius-(x-fx)*(x-fx)); - - if ((x >= 0) && (x <= crt_window_width-1) && (fy-dy >= 0)) - pdp1_plot_pixel(bitmap, x, fy-dy, color); - if ((x >= 0) && (x <= crt_window_width-1) && (y+dy <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, x, fy+dy, color); - } - for (y=/*ceil*/(fy-interval); y<=fy+interval; y++) - { - float dx = sqrt(radius*radius-(y-fy)*(y-fy)); - - if ((fx-dx >= 0) && (y >= 0) && (y <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, fx-dx, y, color); - if ((fx+dx <= crt_window_width-1) && (y >= 0) && (y <= crt_window_height-1)) - pdp1_plot_pixel(bitmap, fx+dx, y, color); - } -} -#endif - -void pdp1_state::pdp1_erase_lightpen(bitmap_ind16 &bitmap) -{ - if (m_previous_lightpen_state.active) - { -#if 0 - if (m_previous_lightpen_state.x>0) - pdp1_plot_pixel(bitmap, m_previous_lightpen_state.x/2-1, m_previous_lightpen_state.y/2, pen_black); - if (m_previous_lightpen_state.x<1023) - pdp1_plot_pixel(bitmap, m_previous_lightpen_state.x/2+1, m_previous_lightpen_state.y/2, pen_black); - if (m_previous_lightpen_state.y>0) - pdp1_plot_pixel(bitmap, m_previous_lightpen_state.x/2, m_previous_lightpen_state.y/2-1, pen_black); - if (m_previous_lightpen_state.y<1023) - pdp1_plot_pixel(bitmap, m_previous_lightpen_state.x/2, m_previous_lightpen_state.y/2+1, pen_black); -#endif - pdp1_draw_circle(bitmap, m_previous_lightpen_state.x, m_previous_lightpen_state.y, m_previous_lightpen_state.radius, pen_black); - } -} - -void pdp1_state::pdp1_draw_lightpen(bitmap_ind16 &bitmap) -{ - if (m_lightpen_state.active) - { - int color_ = m_lightpen_state.down ? pen_lightpen_pressed : pen_lightpen_nonpressed; -#if 0 - if (m_lightpen_state.x>0) - pdp1_plot_pixel(bitmap, m_lightpen_state.x/2-1, m_lightpen_state.y/2, color); - if (m_lightpen_state.x<1023) - pdp1_plot_pixel(bitmap, m_lightpen_state.x/2+1, m_lightpen_state.y/2, color); - if (m_lightpen_state.y>0) - pdp1_plot_pixel(bitmap, m_lightpen_state.x/2, m_lightpen_state.y/2-1, color); - if (m_lightpen_state.y<1023) - pdp1_plot_pixel(bitmap, m_lightpen_state.x/2, m_lightpen_state.y/2+1, color); -#endif - pdp1_draw_circle(bitmap, m_lightpen_state.x, m_lightpen_state.y, m_lightpen_state.radius, color_); - } - m_previous_lightpen_state = m_lightpen_state; -} diff --git a/src/mess/video/pecom.c b/src/mess/video/pecom.c deleted file mode 100644 index 795e97f8ef4..00000000000 --- a/src/mess/video/pecom.c +++ /dev/null @@ -1,109 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Pecom driver by Miodrag Milanovic - - 08/11/2008 Preliminary driver. - -****************************************************************************/ - -#include "emu.h" -#include "sound/cdp1869.h" -#include "sound/wave.h" -#include "cpu/cosmac/cosmac.h" -#include "includes/pecom.h" - -WRITE8_MEMBER(pecom_state::pecom_cdp1869_w) -{ - UINT16 ma = m_cdp1802->get_memory_address(); - - switch (offset + 3) - { - case 3: - m_cdp1869->out3_w(space, ma, data); - break; - - case 4: - m_cdp1869->out4_w(space, ma, data); - break; - - case 5: - m_cdp1869->out5_w(space, ma, data); - break; - - case 6: - m_cdp1869->out6_w(space, ma, data); - break; - - case 7: - m_cdp1869->out7_w(space, ma, data); - break; - } -} - -static ADDRESS_MAP_START( cdp1869_page_ram, AS_0, 8, driver_device ) - AM_RANGE(0x000, 0x3ff) AM_MIRROR(0x400) AM_RAM -ADDRESS_MAP_END - -CDP1869_CHAR_RAM_READ_MEMBER(pecom_state::pecom_char_ram_r ) -{ - UINT8 column = pmd & 0x7f; - UINT16 charaddr = (column << 4) | cma; - - return m_charram[charaddr]; -} - -CDP1869_CHAR_RAM_WRITE_MEMBER(pecom_state::pecom_char_ram_w ) -{ - UINT8 column = pmd & 0x7f; - UINT16 charaddr = (column << 4) | cma; - - m_charram[charaddr] = data; -} - -CDP1869_PCB_READ_MEMBER(pecom_state::pecom_pcb_r ) -{ - return BIT(pmd, 7); -} - -WRITE_LINE_MEMBER(pecom_state::pecom_prd_w) -{ - // every other PRD triggers a DMAOUT request - if (m_dma) - { - m_cdp1802->set_input_line(COSMAC_INPUT_LINE_DMAOUT, HOLD_LINE); - } - - m_dma = !m_dma; -} - -VIDEO_START_MEMBER(pecom_state,pecom) -{ - /* allocate memory */ - m_charram = auto_alloc_array(machine(), UINT8, PECOM_CHAR_RAM_SIZE); - - /* register for state saving */ - save_item(NAME(m_reset)); - save_item(NAME(m_dma)); - save_pointer(NAME(m_charram), PECOM_CHAR_RAM_SIZE); -} - -MACHINE_CONFIG_FRAGMENT( pecom_video ) - MCFG_CDP1869_SCREEN_PAL_ADD(CDP1869_TAG, SCREEN_TAG, CDP1869_DOT_CLK_PAL) - - MCFG_VIDEO_START_OVERRIDE(pecom_state,pecom) - - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, cdp1869_page_ram) - MCFG_CDP1869_COLOR_CLOCK(CDP1869_COLOR_CLK_PAL) - MCFG_CDP1869_CHAR_PCB_READ_OWNER(pecom_state, pecom_pcb_r) - MCFG_CDP1869_CHAR_RAM_READ_OWNER(pecom_state, pecom_char_ram_r) - MCFG_CDP1869_CHAR_RAM_WRITE_OWNER(pecom_state, pecom_char_ram_w) - MCFG_CDP1869_PAL_NTSC_CALLBACK(VCC) - MCFG_CDP1869_PRD_CALLBACK(WRITELINE(pecom_state, pecom_prd_w)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) - MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette") - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END diff --git a/src/mess/video/pk8020.c b/src/mess/video/pk8020.c deleted file mode 100644 index 31088bb6a53..00000000000 --- a/src/mess/video/pk8020.c +++ /dev/null @@ -1,59 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - PK-8020 driver by Miodrag Milanovic - based on work of Sergey Erokhin from pk8020.narod.ru - - 18/07/2008 Preliminary driver. - -****************************************************************************/ - -#include "emu.h" -#include "includes/pk8020.h" -#include "machine/ram.h" - -void pk8020_state::video_start() -{ -} - -UINT32 pk8020_state::screen_update_pk8020(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y, x, b, j; - UINT8 *gfx = m_region_gfx1->base(); - UINT8 *ram = m_ram->pointer(); - - for (y = 0; y < 16; y++) - { - for (x = 0; x < 64; x++) - { - UINT8 chr = ram[x +(y*64) + 0x40000]; - UINT8 attr= ram[x +(y*64) + 0x40400]; - for (j = 0; j < 16; j++) { - UINT32 addr = 0x10000 + x + ((y*16+j)*64) + (m_video_page * 0xC000); - UINT8 code1 = ram[addr]; - UINT8 code2 = ram[addr + 0x4000]; - UINT8 code3 = ram[addr + 0x8000]; - UINT8 code4 = gfx[((chr<<4) + j) + (m_font*0x1000)]; - if (attr) code4 ^= 0xff; - for (b = 0; b < 8; b++) - { - UINT8 col = (((code4 >> b) & 0x01) ? 0x08 : 0x00); - col |= (((code3 >> b) & 0x01) ? 0x04 : 0x00); - col |= (((code2 >> b) & 0x01) ? 0x02 : 0x00); - col |= (((code1 >> b) & 0x01) ? 0x01 : 0x00); - bitmap.pix16((y*16)+j, x*8+(7-b)) = col; - } - } - } - } - return 0; -} - -PALETTE_INIT_MEMBER(pk8020_state, pk8020) -{ - int i; - for(i=0;i<16;i++) { - m_palette->set_pen_color( i, rgb_t(i*0x10,i*0x10,i*0x10) ); - } -} diff --git a/src/mess/video/pocketc.c b/src/mess/video/pocketc.c deleted file mode 100644 index 0cf2f505349..00000000000 --- a/src/mess/video/pocketc.c +++ /dev/null @@ -1,70 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#include "emu.h" -#include "includes/pocketc.h" - -/* PC126x - 24x2 5x7 space between char - 2000 .. 203b, 2800 .. 283b - 2040 .. 207b, 2840 .. 287b - 203d: 0 BUSY, 1 PRINT, 3 JAPAN, 4 SMALL, 5 SHIFT, 6 DEF - 207c: 1 DEF 1 RAD 2 GRAD 5 ERROR 6 FLAG */ - -static const UINT8 pocketc_palette[] = -{ - 99,107,99, - 94,111,103, - 255,255,255, - 255,255,255, - 60, 66, 60, - 0, 0, 0 -}; - -const unsigned short pocketc_state::pocketc_colortable[8][2] = { - { 5, 4 }, - { 5, 0 }, - { 5, 2 }, - { 4, 5 }, - { 1, 4 }, - { 0, 5 }, - { 1, 5 }, - { 3, 5 } -}; - -PALETTE_INIT_MEMBER(pocketc_state, pocketc) -{ - UINT8 i=0, r, b, g, color_count = 6; - - while (color_count--) - { - r = pocketc_palette[i++]; g = pocketc_palette[i++]; b = pocketc_palette[i++]; - palette.set_indirect_color(5 - color_count, rgb_t(r, g, b)); - } - - for( i = 0; i < 8; i++ ) - { - palette.set_pen_indirect(i*2, pocketc_colortable[i][0]); - palette.set_pen_indirect(i*2+1, pocketc_colortable[i][1]); - } -} - - -/* Draw an indicator (DEG, SHIFT, etc) */ -void pocketc_state::pocketc_draw_special(bitmap_ind16 &bitmap, int x, int y, const POCKETC_FIGURE fig, int color) -{ - int i,j; - for (i=0; fig[i]; i++, y++) - { - for (j=0; fig[i][j]!=0; j++) - { - switch(fig[i][j]) - { - case '1': - bitmap.pix16(y, x+j) = color; - break; - case 'e': - return; - } - } - } -} diff --git a/src/mess/video/poisk1.c b/src/mess/video/poisk1.c deleted file mode 100644 index 99532e31fed..00000000000 --- a/src/mess/video/poisk1.c +++ /dev/null @@ -1,322 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sergey Svishchev -/* - * Poisk-1 does not have a real mc6845 and always runs in graphics mode. - * Text mode is emulated by BIOS. - * Video RAM in native graphics mode starts at 0xB8000, in emulated text mode -- at 0xBC000. - */ - -#include "emu.h" - -#include "includes/poisk1.h" - -#define CGA_PALETTE_SETS 83 -/* one for colour, one for mono, 81 for colour composite */ - -#include "video/cgapal.h" - -#define BG_COLOR(x) (((x) & 7)|(((x) & 0x10) >> 1)) - -#define VERBOSE_DBG 0 - -#define DBG_LOG(N,M,A) \ - do { \ - if(VERBOSE_DBG>=N) \ - { \ - if( M ) \ - logerror("%11.6f: %-24s",machine().time().as_double(),(char*)M ); \ - logerror A; \ - } \ - } while (0) - -// - -/* - * Poisk-1 doesn't have a mc6845 and always runs in graphics mode. Text mode is emulated by BIOS; - * NMI is triggered on access to video memory and to mc6845 ports. Address and data are latched into: - * - * Port 28H (offset 0) -- lower 8 bits of address - * Port 29H (offset 1) -- high -//- and mode bits - * Port 2AH (offset 2) -- data - */ - -READ8_MEMBER(p1_state::p1_trap_r) -{ - UINT8 data = m_video.trap[offset]; - DBG_LOG(1,"trap",("R %.2x $%02x\n", 0x28+offset, data)); - if (offset == 0) - m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); - return data; -} - -WRITE8_MEMBER(p1_state::p1_trap_w) -{ - DBG_LOG(1,"trap",("W %.2x $%02x\n", 0x28+offset, data)); -} - -READ8_MEMBER(p1_state::p1_cga_r) -{ - m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - return 0; -} - -WRITE8_MEMBER(p1_state::p1_cga_w) -{ - UINT16 port = offset + 0x3d0; - - DBG_LOG(1,"cga",("W %.4x $%02x\n", port, data)); - m_video.trap[2] = data; - m_video.trap[1] = 0xC0 | ((port >> 8) & 0x3f); - m_video.trap[0] = port & 255; - m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); -} - -WRITE8_MEMBER(p1_state::p1_vram_w) -{ - DBG_LOG(1,"vram",("W %.4x $%02x\n", offset, data)); - if (m_video.videoram_base) - m_video.videoram_base[offset] = data; - m_video.trap[2] = data; - m_video.trap[1] = 0x80 | ((offset >> 8) & 0x3f); - m_video.trap[0] = offset & 255; - m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); -} - -// CGA emulator -/* -068h D42 0..2 R, G, B XXX Foreground/Background color - 3 NMI DISABLE NMI trap 1: Disabled 0: Enabled - 4 PALETTE XXX Colour palette 0: XXX 1: XXX - 5 I (INTENS) XXX Foreground/Background color intensity - 6 DISPLAY BANK XXX Video RAM page - 7 HIRES 1: 640x200 0: 320x200 -*/ - -WRITE8_MEMBER(p1_state::p1_ppi2_porta_w) -{ - address_space &space_prg = m_maincpu->space(AS_PROGRAM); - rectangle visarea; - - DBG_LOG(1,"color_select_68",("W $%02x\n", data)); - - // NMI DISABLE - if (BIT(data, 3) != BIT(m_video.color_select_68, 3)) { - if (BIT(data, 3)) { - space_prg.install_readwrite_bank( 0xb8000, 0xbbfff, "bank11" ); - } else { - space_prg.install_read_bank( 0xb8000, 0xbbfff, "bank11" ); - space_prg.install_write_handler( 0xb8000, 0xbbfff, WRITE8_DELEGATE(p1_state, p1_vram_w) ); - } - } - // DISPLAY BANK - if (BIT(data, 6) != BIT(m_video.color_select_68, 6)) { - if (BIT(data, 6)) - m_video.videoram = m_video.videoram_base + 0x4000; - else - m_video.videoram = m_video.videoram_base; - } - // HIRES -- XXX - if (BIT(data, 7) != BIT(m_video.color_select_68, 7)) { - if (BIT(data, 7)) - machine().first_screen()->set_visible_area(0, 640-1, 0, 200-1); - else - machine().first_screen()->set_visible_area(0, 320-1, 0, 200-1); - } - m_video.color_select_68 = data; - set_palette_luts(); -} - -/* -06Ah Dxx 6 Enable/Disable color burst (?) - 7 Enable/Disable D7H/D7L -*/ - -WRITE8_MEMBER(p1_state::p1_ppi_portc_w) -{ - DBG_LOG(1,"mode_control_6a",("W $%02x\n", data)); - - m_video.mode_control_6a = data; - set_palette_luts(); -} - -void p1_state::set_palette_luts(void) -{ - /* Setup 2bpp palette lookup table */ - // HIRES - if ( m_video.color_select_68 & 0x80 ) - { - m_video.palette_lut_2bpp[0] = 0; - } - else - { - m_video.palette_lut_2bpp[0] = BG_COLOR(m_video.color_select_68); - } - // B&W -- XXX -/* - if ( m_video.mode_control_6a & 0x40 ) - { - m_video.palette_lut_2bpp[1] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 3; - m_video.palette_lut_2bpp[2] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 4; - m_video.palette_lut_2bpp[3] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 7; - } - else -*/ - { - // PALETTE - if ( m_video.color_select_68 & 0x20 ) - { - m_video.palette_lut_2bpp[1] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 3; - m_video.palette_lut_2bpp[2] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 5; - m_video.palette_lut_2bpp[3] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 7; - } - else - { - m_video.palette_lut_2bpp[1] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 2; - m_video.palette_lut_2bpp[2] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 4; - m_video.palette_lut_2bpp[3] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 6; - } - } -} - -/*************************************************************************** - Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. - Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 - cga fetches 2 byte per mc6845 access. -***************************************************************************/ - -POISK1_UPDATE_ROW( p1_state::cga_gfx_2bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(ra); - UINT16 odd, offset; - int i; - - if ( ra == 0 ) DBG_LOG(1,"cga_gfx_2bpp_update_row",("\n")); - odd = ( ra & 1 ) << 13; - offset = ( ma & 0x1fff ) | odd; - for ( i = 0; i < stride; i++ ) - { - UINT8 data = videoram[ offset++ ]; - - *p = palette[m_video.palette_lut_2bpp[ ( data >> 6 ) & 0x03 ]]; p++; - *p = palette[m_video.palette_lut_2bpp[ ( data >> 4 ) & 0x03 ]]; p++; - *p = palette[m_video.palette_lut_2bpp[ ( data >> 2 ) & 0x03 ]]; p++; - *p = palette[m_video.palette_lut_2bpp[ data & 0x03 ]]; p++; - } -} - -/*************************************************************************** - Draw graphics mode with 640x200 pixels (default). - The cell size is 1x1 (1 scanline is the real default) - Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 -***************************************************************************/ - -POISK1_UPDATE_ROW( p1_state::cga_gfx_1bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(ra); - UINT8 fg = 15, bg = BG_COLOR(m_video.color_select_68); - UINT16 odd, offset; - int i; - - if ( ra == 0 ) DBG_LOG(1,"cga_gfx_1bpp_update_row",("bg %d\n", bg)); - odd = ( ra & 1 ) << 13; - offset = ( ma & 0x1fff ) | odd; - for ( i = 0; i < stride; i++ ) - { - UINT8 data = videoram[ offset++ ]; - - *p = palette[( data & 0x80 ) ? fg : bg ]; p++; - *p = palette[( data & 0x40 ) ? fg : bg ]; p++; - *p = palette[( data & 0x20 ) ? fg : bg ]; p++; - *p = palette[( data & 0x10 ) ? fg : bg ]; p++; - *p = palette[( data & 0x08 ) ? fg : bg ]; p++; - *p = palette[( data & 0x04 ) ? fg : bg ]; p++; - *p = palette[( data & 0x02 ) ? fg : bg ]; p++; - *p = palette[( data & 0x01 ) ? fg : bg ]; p++; - } -} - -/*************************************************************************** - Draw graphics mode with 640x200 pixels + extra highlight color for text - mode emulation - Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 -***************************************************************************/ - -POISK1_UPDATE_ROW( p1_state::poisk1_gfx_1bpp_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT32 *p = &bitmap.pix32(ra); - UINT8 fg, bg = BG_COLOR(m_video.color_select_68); - UINT16 odd, offset; - int i; - - if ( ra == 0 ) DBG_LOG(1,"poisk1_gfx_1bpp_update_row",("bg %d\n", bg)); - odd = ( ra & 1 ) << 13; - offset = ( ma & 0x1fff ) | odd; - for ( i = 0; i < stride; i++ ) - { - UINT8 data = videoram[ offset++ ]; - - fg = (data & 0x80) ? ( (m_video.color_select_68 & 0x20) ? 10 : 11 ) : 15; // XXX - *p = palette[bg]; p++; - *p = palette[( data & 0x40 ) ? fg : bg ]; p++; - *p = palette[( data & 0x20 ) ? fg : bg ]; p++; - *p = palette[( data & 0x10 ) ? fg : bg ]; p++; - *p = palette[( data & 0x08 ) ? fg : bg ]; p++; - *p = palette[( data & 0x04 ) ? fg : bg ]; p++; - *p = palette[( data & 0x02 ) ? fg : bg ]; p++; - *p = palette[( data & 0x01 ) ? fg : bg ]; p++; - } -} - -/* Initialise the cga palette */ -PALETTE_INIT_MEMBER(p1_state, p1) -{ - int i; - - DBG_LOG(0,"init",("palette_init()\n")); - - for ( i = 0; i < CGA_PALETTE_SETS * 16; i++ ) - { - palette.set_pen_color(i, cga_palette[i][0], cga_palette[i][1], cga_palette[i][2] ); - } -} - -void p1_state::video_start() -{ - address_space &space = m_maincpu->space( AS_PROGRAM ); - - DBG_LOG(0,"init",("video_start()\n")); - - memset(&m_video, 0, sizeof(m_video)); - m_video.videoram = m_video.videoram_base = auto_alloc_array(machine(), UINT8, 0x8000); - m_video.stride = 80; - - space.install_readwrite_bank(0xb8000, 0xbffff, "bank11" ); - machine().root_device().membank("bank11")->set_base(m_video.videoram); -} - -UINT32 p1_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - UINT16 ra, ma = 0; - - if (!m_video.stride || !m_video.videoram) return 0; - - // bit 6 of 6Ah disables color burst -- not implemented - for (ra = cliprect.min_y; ra <= cliprect.max_y; ra++) - { - if (BIT(m_video.color_select_68, 7)) { - if (BIT(m_video.mode_control_6a, 7)) { - cga_gfx_1bpp_update_row(bitmap, cliprect, m_video.videoram, ma, ra, m_video.stride); - } else { - poisk1_gfx_1bpp_update_row(bitmap, cliprect, m_video.videoram, ma, ra, m_video.stride); - } - } else { - cga_gfx_2bpp_update_row(bitmap, cliprect, m_video.videoram, ma, ra, m_video.stride); - } - if (ra & 1) ma += m_video.stride; - } - - return 0; -} diff --git a/src/mess/video/poisk1.h b/src/mess/video/poisk1.h deleted file mode 100644 index 092de267b1e..00000000000 --- a/src/mess/video/poisk1.h +++ /dev/null @@ -1,10 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sergey Svishchev -#include "emu.h" - -#define CGA_PALETTE_SETS 83 -/* one for colour, one for mono, 81 for colour composite */ - -INPUT_PORTS_EXTERN( pcvideo_poisk1 ); - -MACHINE_CONFIG_EXTERN( pcvideo_poisk1 ); diff --git a/src/mess/video/poly88.c b/src/mess/video/poly88.c deleted file mode 100644 index 83652770e56..00000000000 --- a/src/mess/video/poly88.c +++ /dev/null @@ -1,102 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Poly-88 video by Miodrag Milanovic - - 18/05/2009 Initial implementation - -****************************************************************************/ - -#include "emu.h" -#include "includes/poly88.h" - -static const UINT8 mcm6571a_shift[] = -{ - 0,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0, - 1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0 -}; - -void poly88_state::video_start() -{ - m_FNT = memregion("chargen")->base(); -} - -UINT32 poly88_state::screen_update_poly88(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y,j,b; - UINT16 addr; - int xpos; - UINT8 l,r; - - for(y = 0; y < 16; y++ ) - { - addr = y*64; - xpos = 0; - for(x = 0; x < 64; x++ ) - { - UINT8 code = m_video_ram[addr + x]; - if ((code & 0x80)==0) - { - for(j = 0; j < 15; j++ ) - { - l = j/5; - for(b = 0; b < 10; b++ ) - { - r = b/5; - if (l==0 && r==0) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,5) ? 0 : 1; - - if (l==0 && r==1) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,2) ? 0 : 1; - - if (l==1 && r==0) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,4) ? 0 : 1; - - if (l==1 && r==1) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,1) ? 0 : 1; - - if (l==2 && r==0) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,3) ? 0 : 1; - - if (l==2 && r==1) - bitmap.pix16(y*15+j, xpos+b ) = BIT(code,0) ? 0 : 1; - } - } - } - else - { - for(j = 0; j < 15; j++ ) - { - code &= 0x7f; - l = 0; - if (mcm6571a_shift[code]==0) - { - if (j < 9) - l = m_FNT[code*16 + j]; - } - else - { - if ((j > 2) && (j < 12)) - l = m_FNT[code*16 + j - 3]; - } - - for(b = 0; b < 7; b++ ) - bitmap.pix16(y*15+j, xpos+b ) = (l >> (6-b)) & 1; - - bitmap.pix16(y*15+j, xpos+7 ) = 0; - bitmap.pix16(y*15+j, xpos+8 ) = 0; - bitmap.pix16(y*15+j, xpos+9 ) = 0; - } - } - xpos += 10; - } - } - return 0; -} diff --git a/src/mess/video/pp01.c b/src/mess/video/pp01.c deleted file mode 100644 index da2ec5cfde7..00000000000 --- a/src/mess/video/pp01.c +++ /dev/null @@ -1,56 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - PP-01 driver by Miodrag Milanovic - - 08/09/2008 Preliminary driver. - -****************************************************************************/ - - -#include "includes/pp01.h" - -void pp01_state::video_start() -{ -} - -UINT32 pp01_state::screen_update_pp01(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code_r,code_g,code_b; - UINT8 col; - int y, x, b; - UINT8 *ram = m_ram->pointer(); - - for (y = 0; y < 256; y++) - { - for (x = 0; x < 32; x++) - { - code_r = ram[0x6000 + ((y+m_video_scroll)&0xff)*32 + x]; - code_g = ram[0xa000 + ((y+m_video_scroll)&0xff)*32 + x]; - code_b = ram[0xe000 + ((y+m_video_scroll)&0xff)*32 + x]; - for (b = 0; b < 8; b++) - { - col = (((code_r >> b) & 0x01) ? 4 : 0) + (((code_g >> b) & 0x01) ? 2 : 0) + (((code_b >> b) & 0x01) ? 1 : 0); - bitmap.pix16(y, x*8+(7-b)) = col; - } - } - } - return 0; -} - -static const rgb_t pp01_palette[8] = { - rgb_t(0x00, 0x00, 0x00), // 0 - rgb_t(0x00, 0x00, 0x80), // 1 - rgb_t(0x00, 0x80, 0x00), // 2 - rgb_t(0x00, 0x80, 0x80), // 3 - rgb_t(0x80, 0x00, 0x00), // 4 - rgb_t(0x80, 0x00, 0x80), // 5 - rgb_t(0x80, 0x80, 0x00), // 6 - rgb_t(0x80, 0x80, 0x80), // 7 -}; - -PALETTE_INIT_MEMBER(pp01_state, pp01) -{ - palette.set_pen_colors(0, pp01_palette, ARRAY_LENGTH(pp01_palette)); -} diff --git a/src/mess/video/primo.c b/src/mess/video/primo.c deleted file mode 100644 index 55332149128..00000000000 --- a/src/mess/video/primo.c +++ /dev/null @@ -1,47 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha -/*************************************************************************** - - primo.c - - Functions to emulate the video hardware of Primo. - - Krzysztof Strzecha - -***************************************************************************/ - -#include "emu.h" -#include "includes/primo.h" - - - -void primo_state::primo_draw_scanline(bitmap_ind16 &bitmap, int primo_scanline) -{ - int x, i; - UINT8 data; - - /* set up scanline */ - UINT16 *scanline = &bitmap.pix16(primo_scanline); - - /* address of current line in Primo video memory */ - const UINT8* primo_video_ram_line = (const UINT8*)m_maincpu->space(AS_PROGRAM).get_read_ptr(m_video_memory_base + 32 * primo_scanline); - - for (x=0; x<256; x+=8) - { - data = primo_video_ram_line[x/8]; - - for (i=0; i<8; i++) - scanline[x+i]=(data & (0x80>>i)) ? 1 : 0; - - } -} - - -UINT32 primo_state::screen_update_primo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int primo_scanline; - - for (primo_scanline=0; primo_scanline<192; primo_scanline++) - primo_draw_scanline( bitmap, primo_scanline); - return 0; -} diff --git a/src/mess/video/rm380z.c b/src/mess/video/rm380z.c deleted file mode 100644 index 4b00c5222db..00000000000 --- a/src/mess/video/rm380z.c +++ /dev/null @@ -1,406 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol,Gabriele D'Antona - -/* - -RM 380Z video code - -*/ - - -#include "includes/rm380z.h" - - -void rm380z_state::put_point(int charnum,int x,int y,int col) -{ - int mx=3; - if (y==6) mx=4; - - for (unsigned int r=y;r<(y+mx);r++) - { - for (unsigned int c=x;c<(x+3);c++) - { - m_graphic_chars[charnum][c+(r*(RM380Z_CHDIMX+1))]=col; - } - } -} - -void rm380z_state::init_graphic_chars() -{ - for (int c=0;c<0x3f;c++) - { - if (c&0x01) put_point(c,0,0,1); - else put_point(c,0,0,0); - - if (c&0x02) put_point(c,3,0,1); - else put_point(c,3,0,0); - - if (c&0x04) put_point(c,0,3,1); - else put_point(c,0,3,0); - - if (c&0x08) put_point(c,3,3,1); - else put_point(c,3,3,0); - - if (c&0x10) put_point(c,0,6,1); - else put_point(c,0,6,0); - - if (c&0x20) put_point(c,3,6,1); - else put_point(c,3,6,0); - } -} - -void rm380z_state::config_videomode() -{ - if (m_port0&0x20) - { - // 80 cols - m_videomode=RM380Z_VIDEOMODE_80COL; - } - else - { - // 40 cols - m_videomode=RM380Z_VIDEOMODE_40COL; - } - - if (m_old_videomode!=m_videomode) - { - m_old_videomode=m_videomode; - } -} - -// char attribute bits in COS 4.0 - -// 0=alternate charset -// 1=underline -// 2=dim -// 3=reverse - - -void rm380z_state::decode_videoram_char(int pos,UINT8& chr,UINT8& attrib) -{ - UINT8 ch1=m_vramchars[pos]; - UINT8 ch2=m_vramattribs[pos]; - - // "special" (unknown) cases first - if ((ch1==0x80)&&(ch2==0x04)) - { - // blank out - chr=0x20; - attrib=0; - return; - } - else if ((ch1==0)&&(ch2==8)) - { - // cursor - chr=0x20; - attrib=8; - return; - } - else if ((ch1==0)&&(ch2==0)) - { - // delete char (?) - chr=0x20; - attrib=0; - return; - } - else if ((ch1==4)&&(ch2==4)) - { - // reversed cursor? - chr=0x20; - attrib=0; - return; - } - else if ((ch1==4)&&(ch2==8)) - { - // normal cursor - chr=0x20; - attrib=8; - return; - } - else - { - chr=ch1; - attrib=ch2; - - //printf("unhandled character combination [%x][%x]\n",ch1,ch2); - } -} - -void rm380z_state::scroll_videoram() -{ - int lineWidth=0x80; - if (m_videomode==RM380Z_VIDEOMODE_40COL) - { - lineWidth=0x40; - } - - // scroll up one row of videoram - - for (int row=1;rowr[1]) - { - scroll_videoram(); - } - else if ((r[2]==0x00)&&(r[1]==0x17)) - { - // wrap-scroll - scroll_videoram(); - } - - } -} - -// after ctrl-L (clear screen?): routine at EBBD is executed -// EB30??? next line? -// memory at FF02 seems to hold the line counter (same as FBFD) -// -// basics: -// 20e2: prints "Ready:" -// 0195: prints "\n" - -WRITE8_MEMBER( rm380z_state::videoram_write ) -{ - //printf("vramw [%2.2x][%2.2x] port0 [%2.2x] fbfd [%2.2x] fbfe [%2.2x] PC [%4.4x]\n",offset,data,m_port0,m_fbfd,m_fbfe,m_maincpu->safe_pc()); - - int lineWidth=0x80; - if (m_videomode==RM380Z_VIDEOMODE_40COL) - { - lineWidth=0x40; - } - - int rowadder=(m_fbfe&0x0f)*2; - if (m_videomode==RM380Z_VIDEOMODE_40COL) rowadder=0; // FBFE register is not used in VDU-40 - - int lineAdder=rowadder*lineWidth; - int realA=(offset+lineAdder); - - // we suppose videoram is being written as character/attribute couple - // fbfc 6th bit set=attribute, unset=char - - if (!(m_port0&0x40)) - { - m_vramchars[realA%RM380Z_SCREENSIZE]=data; - } - else - { - m_vramattribs[realA%RM380Z_SCREENSIZE]=data; - } - - // - - m_mainVideoram[offset]=data; -} - -READ8_MEMBER( rm380z_state::videoram_read ) -{ - return m_mainVideoram[offset]; -} - -void rm380z_state::putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bitmap,unsigned char* chsb,int vmode) -{ - //bool attrDim=false; - bool attrRev=false; - bool attrUnder=false; - - if (attribs&0x02) attrUnder=true; - //if (attribs&0x04) attrDim=true; - if (attribs&0x08) attrRev=true; - - if ((charnum>0)&&(charnum<=0x7f)) - { - // normal chars (base set) - - if (vmode==RM380Z_VIDEOMODE_80COL) - { - int basex=RM380Z_CHDIMX*(charnum/RM380Z_NCY); - int basey=RM380Z_CHDIMY*(charnum%RM380Z_NCY); - - for (int r=0;rbase(); - - int lineWidth=0x80; - int ncols=80; - - if (m_videomode==RM380Z_VIDEOMODE_40COL) - { - lineWidth=0x40; - ncols=40; - } - - // blank screen - bitmap.fill(0); - - for (int row=0;row>4) -#define SELECT_COL(x,c) (IS_80COL ? ((((x) & 1) ? ((c) << 2) : (c)) & 0xC) : (c)) -#define FILL_WORD(c) (((c) << 12) | ((c) << 8) | ((c) << 4) | (c)) - -#define IS_80COL (m_mode&0x10) -#define IS_XOR (m_op&8) - -#define DEBUG_TEXT 0x01 -#define DEBUG_DB 0x02 -#define DEBUG_PIXEL 0x04 - -#define DEBUG_SET(flags) ((m_debug_video & (flags))==(flags)) - -static void video_debug(running_machine &machine, int ref, int params, const char *param[]); - -READ16_MEMBER(rmnimbus_state::nimbus_video_io_r) -{ - UINT16 result = 0; - - switch (offset) - { - case 0x00: - case 0x08: - result = read_pixel_data(m_x, m_y); - break; - case 0x02: - case 0x0A: - result = read_pixel_data(m_x, ++m_y); - break; - case 0x05: - case 0x0D: - result = read_pixel_data(++m_x, m_y); - break; - - case 0x10: - result = m_yline; - break; - case 0x11: - result = m_op; - break; - case 0x12: - result = m_colours; - break; - case 0x13: - result = m_mode; - break; - case 0x14: - result = m_screen->vpos() % 0xb; // TODO: verify - break; - case 0x15: - result = m_x; - break; - case 0x16: - result = m_y; - break; - default: - logerror("nimbus: unknown video reg read %02x\n", offset); - break; - } - - if(DEBUG_SET(DEBUG_TEXT)) - logerror("Nimbus video IOR at %05X from %04X mask=%04X, data=%04X\n",space.device().safe_pc(),(offset*2),mem_mask,result); - - return result; -} - -UINT8 rmnimbus_state::get_pixel(UINT16 x, UINT16 y) -{ - UINT8 result = 0; - - if((x<640) && (y<250)) - { - if(IS_80COL) - result=m_video_mem.pix16(y, x) >> 2; - else - result=m_video_mem.pix16(y, x*2); - } - - return result; -} - -UINT16 rmnimbus_state::read_pixel_line(UINT16 x, UINT16 y, UINT8 pixels, UINT8 bpp) -{ - UINT16 colour = 0; - int i; - x *= pixels; - - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("read_pixel_line(x=%d, y=%d, width=%d, bpp=%d)\n",x,y,pixels,bpp); - - for(i = 0; i < pixels - 1; i++) - { - colour |= get_pixel(i + x, y); - - if(bpp==1) - colour=((colour==SELECT_COL(x + i, FG_COLOUR)) ? 1 : 0) << 1; - else - colour <<= bpp; - } - return colour | get_pixel(x + i, y); -} - -UINT16 rmnimbus_state::read_pixel_data(UINT16 x, UINT16 y) -{ - UINT16 result=0; - - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("read_pixel_data(x=%d, y=%d), reg022=%04X\n",x,y,m_op); - - if(IS_80COL) - { - switch (m_op & WIDTH_MASK) - { - case 0x00 : break; - - case 0x01 : break; - - case 0x02 : break; - - case 0x03 : break; - - case 0x04 : - result=read_pixel_line(x,y,4,2); - break; - - case 0x05 : break; - - case 0x06 : - result=read_pixel_line(x,y,8,2); - break; - - case 0x07 : break; - } - } - else /* 40 Col */ - { - switch (m_op & WIDTH_MASK) - { - case 0x00 : break; - - case 0x01 : break; - - case 0x02 : break; - - case 0x03 : break; - - case 0x04 : break; - - case 0x05 : break; - - case 0x06 : - result=read_pixel_line(x,y,4,4); - break; - - case 0x07 : break; - } - } - - return result; -} - -/* - Write to the video registers. - - Incase anyone wonders about the DEBUG_DB statement, this allows me to log which registers - are being written to and then play them back at the real machine, this has helped greatly - in figuring out what the video registers do. - -*/ - -WRITE16_MEMBER(rmnimbus_state::nimbus_video_io_w) -{ - UINT16 colours = data; - if(offset < 0x14) - { - if(DEBUG_SET(DEBUG_TEXT)) - logerror("Nimbus video IOW at %05X write of %04X to %04X mask=%04X\n",space.device().safe_pc(),data,(offset*2),mem_mask); - - if(DEBUG_SET(DEBUG_DB)) - logerror("dw %05X,%05X\n",(offset*2),data); - } - - switch (offset) - { - case 0x00: - case 0x08: - break; - - case 0x09: - colours = FILL_WORD(FG_COLOUR); - case 0x01: - m_x = data; - break; - - case 0x02: - case 0x0A: - m_y++; - break; - - case 0x0B: - colours = FILL_WORD(FG_COLOUR); - case 0x03: - m_x = data; - m_y++; - break; - - case 0x05: - case 0x0D: - m_x++; - break; - - case 0x0E: - colours = FILL_WORD(FG_COLOUR); - case 0x06: - m_y = data; - break; - - case 0x0F: - colours = FILL_WORD(FG_COLOUR); - case 0x07: - m_y = data; - m_x++; - break; - - case 0x10: - m_yline = data; - return; - case 0x11: - m_op = data; - return; - case 0x12: - m_colours = data; - return; - case 0x13: - /* - bits 0..3 of reg026 contain the border colour. - bit 5 contains the 40/80 column (320/640 pixel) flag. - */ - m_mode = data; - return; - case 0x14: - case 0x15: - case 0x16: - case 0x17: - change_palette(offset - 0x14, data); - return; - - default: - logerror("nimbus: unknown video reg write %02x %04x\n", offset, data); - return; - } - if(offset & 0x08) - write_pixel_data(m_x, m_y, colours); -} - -void rmnimbus_state::set_pixel(UINT16 x, UINT16 y, UINT8 colour) -{ - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("set_pixel(x=%d, y=%d, colour=%04X), IS_XOR=%02X\n",x,y,colour,IS_XOR); - - if((x<640) && (y<250)) - { - if(IS_XOR) - m_video_mem.pix16(y, x)^=colour; - else - m_video_mem.pix16(y, x)=colour; - } -} - -void rmnimbus_state::set_pixel40( UINT16 x, UINT16 y, UINT8 colour) -{ - set_pixel((x*2),y,colour); - set_pixel((x*2)+1,y,colour); -} - -void rmnimbus_state::write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 pixels, UINT8 bpp) -{ - UINT8 colour; - UINT8 mask = (1 << bpp) - 1; - x *= pixels; - - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("write_pixel_line(x=%d, y=%d, data=%04X, width=%d, bpp=%d)\n",x,y,data,pixels,bpp); - - for(int i = (pixels - 1); i >= 0; i--) - { - if(bpp==1) - colour = SELECT_COL(x + i, (data & 1) ? FG_COLOUR : BG_COLOUR); - else if(IS_80COL) - colour = (data & mask) << 2; - else - colour = (data & mask); - - if(IS_80COL) - set_pixel(x + i,y,colour); - else - set_pixel40(x + i,y,colour); - - data >>= bpp; - } -} - -void rmnimbus_state::move_pixel_line(UINT16 x, UINT16 y, UINT8 pixels) -{ - x *= pixels; - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("move_pixel_line(x=%d, y=%d, width=%d)\n",x,y,pixels); - - for(int i = 0; i < pixels; i++) - { - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("x=%d\n",x + i); - m_video_mem.pix16(m_yline, x + i) = m_video_mem.pix16(y, x + i); - } -} - - - -/* - The values in the bottom 3 bits of reg022 seem to determine the number of bits per pixel - for following operations. - - The values that I have decoded so far are : - - 000 1bpp, foreground and background colours taken from reg024 - 001 2bpp, using the first 4 colours of the pallette - 010 - 011 - 100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with existing pixels then ored - with the lower byte containing the pixel data for two pixels. - 101 Move pixel data at x,reg020 to x,y, used for scrolling. - 110 if 40 col - 4bpp, 16 bit word containing the pixel data for 4 pixels. - else - 2bpp, 16 bit word containing the pixel data for 8 pixels. - 111 - - Bit 3 of reg022 is as follows : - - 0 pixels are written from supplied colour data - 1 pixels are xor'ed onto the screen -*/ - -void rmnimbus_state::write_pixel_data(UINT16 x, UINT16 y, UINT16 data) -{ - if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL)) - logerror("write_pixel_data(x=%d, y=%d, data=%04X), reg022=%04X\n",x,y,data,m_op); - - if(IS_80COL) - { - switch (m_op & WIDTH_MASK) - { - case 0x00: - write_pixel_line(x,y,data,16,1); - break; - - case 0x01: - write_pixel_line(x,y,data,8,1); - break; - - case 0x02: - write_pixel_line(x,y,data,8,1); - break; - - case 0x03: - set_pixel(x,y,SELECT_COL(x, FG_COLOUR)); - break; - - case 0x04: - write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,4,2)),4,2); - break; - - case 0x05: - move_pixel_line(x,y,16); - break; - - case 0x06: - write_pixel_line(x,y,data,8,2); - break; - - case 0x07: - set_pixel(x,y,SELECT_COL(x, FG_COLOUR)); - break; - } - } - else /* 40 Col */ - { - switch (m_op & WIDTH_MASK) - { - case 0x00: - write_pixel_line(x,y,data,8,1); - break; - - case 0x01: - write_pixel_line(x,y,data,4,2); - break; - - case 0x02: - set_pixel40(x,y,FG_COLOUR); - break; - - case 0x03: - set_pixel(x,y,FG_COLOUR); - break; - - case 0x04: - write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,2,4)),2,4); - break; - - case 0x05: - move_pixel_line(x,y,16); - break; - - case 0x06: - write_pixel_line(x,y,data,4,4); - break; - - case 0x07: - set_pixel(x,y,FG_COLOUR); - break; - } - } -} - -void rmnimbus_state::change_palette(UINT8 bank, UINT16 colours) -{ - // loop over changing colours - for(int colourno = (bank * 4); colourno < ((bank + 1) * 4); colourno++) - { - int i = (colours & 8) >> 3; - m_palette->set_pen_color(colourno, pal2bit((colours & 2) | i), pal2bit(((colours & 4) >> 1) | i), pal2bit(((colours & 1) << 1) | i)); - - if(DEBUG_SET(DEBUG_TEXT)) - logerror("set colourno[%02X], colour=%02X\n",colourno, colours & 0xf); - colours >>= 4; - } -} - -static void video_debug(running_machine &machine, int ref, int params, const char *param[]) -{ - rmnimbus_state *state = machine.driver_data(); - if(params>0) - { - int temp; - sscanf(param[0],"%d",&temp); state->m_debug_video = temp; - } - else - { - debug_console_printf(machine,"Error usage : nimbus_vid_debug \n"); - debug_console_printf(machine,"Current debuglevel=%02X\n",state->m_debug_video); - } -} - -void rmnimbus_state::video_start() -{ - m_debug_video=0; - - m_screen->register_screen_bitmap(m_video_mem); - - if (machine().debug_flags & DEBUG_FLAG_ENABLED) - { - debug_console_register_command(machine(), "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug); - } -} - -void rmnimbus_state::video_reset() -{ - m_mode = 0; - m_x = 0; - m_y = 0; - m_op = 0; - m_yline = 0; -} - -UINT32 rmnimbus_state::screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_video_mem, 0, 0, 0, 0, cliprect); - - return 0; -} diff --git a/src/mess/video/samcoupe.c b/src/mess/video/samcoupe.c deleted file mode 100644 index af931c952c7..00000000000 --- a/src/mess/video/samcoupe.c +++ /dev/null @@ -1,171 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Lee Hammerton, Dirk Best -/*************************************************************************** - - Miles Gordon Technology SAM Coupe - -***************************************************************************/ - -#include "emu.h" -#include "includes/samcoupe.h" - - -/*************************************************************************** - MACROS -***************************************************************************/ - -/* border color from border register */ -#define BORDER_COLOR(x) ((x & 0x20) >> 2 | (x & 0x07)) - -/* foreground and background color from attribute byte in mode 1 and 2 */ -#define ATTR_BG(x) ((x >> 3) & 0x07) -#define ATTR_FG(x) (((x >> 3) & 0x08) | (x & 0x07)) - - -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ - -void samcoupe_state::video_start() -{ - machine().first_screen()->register_screen_bitmap(m_bitmap); -} - -UINT32 samcoupe_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} - -void samcoupe_state::draw_mode4_line(int y, int hpos) -{ - UINT8 *videoram = m_videoram; - - /* get start address */ - UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); - - for (int i = 0; i < (SAM_BLOCK*2)/4; i++) - { - /* draw 2 pixels (doublewidth) */ - m_bitmap.pix16(y, hpos + i * 4 + 0) = m_clut[(*vram >> 4) & 0x0f]; - m_bitmap.pix16(y, hpos + i * 4 + 1) = m_clut[(*vram >> 4) & 0x0f]; - m_bitmap.pix16(y, hpos + i * 4 + 2) = m_clut[(*vram >> 0) & 0x0f]; - m_bitmap.pix16(y, hpos + i * 4 + 3) = m_clut[(*vram >> 0) & 0x0f]; - - /* move to next address */ - vram++; - - /* attribute register contains the third displayed byte */ - if (i == 2) - m_attribute = *vram; - } -} - -void samcoupe_state::draw_mode3_line(int y, int hpos) -{ - UINT8 *videoram = m_videoram; - - /* get start address */ - UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); - - for (int i = 0; i < (SAM_BLOCK*2)/4; i++) - { - /* draw 4 pixels */ - m_bitmap.pix16(y, hpos + i * 4 + 0) = m_clut[(*vram >> 6) & 0x03]; - m_bitmap.pix16(y, hpos + i * 4 + 1) = m_clut[(*vram >> 4) & 0x03]; - m_bitmap.pix16(y, hpos + i * 4 + 2) = m_clut[(*vram >> 2) & 0x03]; - m_bitmap.pix16(y, hpos + i * 4 + 3) = m_clut[(*vram >> 0) & 0x03]; - - /* move to next address */ - vram++; - - /* attribute register contains the third displayed byte */ - if (i == 2) - m_attribute = *vram; - } -} - -void samcoupe_state::draw_mode12_block(bitmap_ind16 &bitmap, int vpos, int hpos, UINT8 mask) -{ - /* extract colors from attribute */ - UINT8 ink = m_clut[ATTR_FG(m_attribute)]; - UINT8 pap = m_clut[ATTR_BG(m_attribute)]; - - /* draw block of 8 pixels (doubled to 16) */ - for (int i = 0; i < SAM_BLOCK; i++) - { - bitmap.pix16(vpos, hpos + i*2 + 0) = BIT(mask, 7 - i) ? ink : pap; - bitmap.pix16(vpos, hpos + i*2 + 1) = BIT(mask, 7 - i) ? ink : pap; - } -} - -void samcoupe_state::draw_mode2_line(int y, int hpos) -{ - UINT8 *videoram = m_videoram; - - int cell = (y - SAM_BORDER_TOP) * 32 + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2; - - UINT8 mask = videoram[cell]; - m_attribute = videoram[cell + 0x2000]; - - draw_mode12_block(m_bitmap, y, hpos, mask); -} - -void samcoupe_state::draw_mode1_line(int y, int hpos) -{ - UINT8 *videoram = m_videoram; - - UINT8 mask = videoram[((((y - SAM_BORDER_TOP) & 0xc0) << 5) | (((y - SAM_BORDER_TOP) & 0x07) << 8) | (((y - SAM_BORDER_TOP) & 0x38) << 2)) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; - m_attribute = videoram[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; - - draw_mode12_block(m_bitmap, y, hpos, mask); -} - -TIMER_CALLBACK_MEMBER(samcoupe_state::sam_video_update_callback) -{ - int vpos = machine().first_screen()->vpos(); - int hpos = machine().first_screen()->hpos(); - - int next_vpos = vpos; - int next_hpos = hpos + SAM_BLOCK*2; - - /* next scanline? */ - if (next_hpos >= SAM_BORDER_LEFT + SAM_SCREEN_WIDTH + SAM_BORDER_RIGHT) - { - next_vpos = (vpos + 1) % (SAM_BORDER_TOP + SAM_SCREEN_HEIGHT + SAM_BORDER_BOTTOM); - next_hpos = 0; - } - - /* display disabled? (only in mode 3 or 4) */ - if (BIT(m_vmpr, 6) && BIT(m_border, 7)) - { - m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, 0); - } - else - { - /* border area? */ - if (vpos < SAM_BORDER_TOP || vpos >= SAM_BORDER_TOP + SAM_SCREEN_HEIGHT || hpos < SAM_BORDER_LEFT || hpos >= SAM_BORDER_LEFT + SAM_SCREEN_WIDTH) - { - m_attribute = 0xff; - m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, m_clut[BORDER_COLOR(m_border)]); - } - else - { - /* main screen area */ - switch ((m_vmpr & 0x60) >> 5) - { - case 0: draw_mode1_line(vpos, hpos); break; - case 1: draw_mode2_line(vpos, hpos); break; - case 2: draw_mode3_line(vpos, hpos); break; - case 3: draw_mode4_line(vpos, hpos); break; - } - } - } - - /* do we need to trigger the scanline interrupt (interrupt happens at the start of the right border before the specified line)? */ - if (m_line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (m_line_int + SAM_BORDER_TOP - 1)) - samcoupe_irq(SAM_LINE_INT); - - /* schedule next update */ - m_video_update_timer->adjust(machine().first_screen()->time_until_pos(next_vpos, next_hpos)); -} diff --git a/src/mess/video/special.c b/src/mess/video/special.c deleted file mode 100644 index d868c9efded..00000000000 --- a/src/mess/video/special.c +++ /dev/null @@ -1,153 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Specialist video driver by Miodrag Milanovic - - 15/03/2008 Preliminary driver. - -****************************************************************************/ - - -#include "includes/special.h" - - -VIDEO_START_MEMBER(special_state,special) -{ - m_palette->set_pen_color(0,rgb_t::black); /* black */ - m_palette->set_pen_color(1,rgb_t::white); /* white */ -} - -UINT32 special_state::screen_update_special(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code; - int y, x, b; - - for (x = 0; x < 48; x++) - { - for (y = 0; y < 256; y++) - { - code = m_p_videoram[y + x*256]; - for (b = 7; b >= 0; b--) - bitmap.pix16(y, x*8+(7-b)) = (code >> b) & 0x01; - } - } - return 0; -} -VIDEO_START_MEMBER(special_state,specialp) -{ -} - -UINT32 special_state::screen_update_specialp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code; - int y, x, b; - - for (x = 0; x < 64; x++) - { - for (y = 0; y < 256; y++) - { - code = m_p_videoram[y + x*256]; - for (b = 7; b >= 0; b--) - bitmap.pix16(y, x*8+(7-b)) = (code >> b) & 0x01; - } - } - return 0; -} - - -static const rgb_t specimx_palette[16] = { - rgb_t(0x00, 0x00, 0x00), // 0 - rgb_t(0x00, 0x00, 0xaa), // 1 - rgb_t(0x00, 0xaa, 0x00), // 2 - rgb_t(0x00, 0xaa, 0xaa), // 3 - rgb_t(0xaa, 0x00, 0x00), // 4 - rgb_t(0xaa, 0x00, 0xaa), // 5 - rgb_t(0xaa, 0x55, 0x00), // 6 - rgb_t(0xaa, 0xaa, 0xaa), // 7 - rgb_t(0x55, 0x55, 0x55), // 8 - rgb_t(0x55, 0x55, 0xff), // 9 - rgb_t(0x55, 0xff, 0x55), // A - rgb_t(0x55, 0xff, 0xff), // B - rgb_t(0xff, 0x55, 0x55), // C - rgb_t(0xff, 0x55, 0xff), // D - rgb_t(0xff, 0xff, 0x55), // E - rgb_t(0xff, 0xff, 0xff) // F -}; - -PALETTE_INIT_MEMBER(special_state,specimx) -{ - palette.set_pen_colors(0, specimx_palette, ARRAY_LENGTH(specimx_palette)); -} - - -VIDEO_START_MEMBER(special_state,specimx) -{ - m_specimx_colorram = auto_alloc_array(machine(), UINT8, 0x3000); -} - -UINT32 special_state::screen_update_specimx(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code, color; - int y, x, b; - - for (x = 0; x < 48; x++) - { - for (y = 0; y < 256; y++) - { - code = m_ram->pointer()[0x9000 + y + x*256]; - color = m_specimx_colorram[y + x*256]; - for (b = 7; b >= 0; b--) - bitmap.pix16(y, x*8+(7-b)) = ((code >> b) & 0x01)==0 ? color & 0x0f : (color >> 4)& 0x0f ; - } - } - return 0; -} - -static const rgb_t erik_palette[8] = { - rgb_t(0x00, 0x00, 0x00), // 0 - rgb_t(0x00, 0x00, 0xff), // 1 - rgb_t(0xff, 0x00, 0x00), // 2 - rgb_t(0xff, 0x00, 0xff), // 3 - rgb_t(0x00, 0xff, 0x00), // 4 - rgb_t(0x00, 0xff, 0xff), // 5 - rgb_t(0xff, 0xff, 0x00), // 6 - rgb_t(0xff, 0xff, 0xff) // 7 -}; - -PALETTE_INIT_MEMBER(special_state,erik) -{ - palette.set_pen_colors(0, erik_palette, ARRAY_LENGTH(erik_palette)); -} - - -VIDEO_START_MEMBER(special_state,erik) -{ -} - -UINT32 special_state::screen_update_erik(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code1, code2, color1, color2; - int y, x, b; - UINT8 *erik_video_ram_p1, *erik_video_ram_p2; - - erik_video_ram_p1 = m_ram->pointer() + 0x9000; - erik_video_ram_p2 = m_ram->pointer() + 0xd000; - - for (x = 0; x < 48; x++) - { - for (y = 0; y < 256; y++) - { - code1 = erik_video_ram_p1[y + x*256]; - code2 = erik_video_ram_p2[y + x*256]; - - for (b = 7; b >= 0; b--) - { - color1 = ((code1 >> b) & 0x01)==0 ? m_erik_background : m_erik_color_1; - color2 = ((code2 >> b) & 0x01)==0 ? m_erik_background : m_erik_color_2; - bitmap.pix16(y, x*8+(7-b)) = color1 | color2; - } - } - } - return 0; -} diff --git a/src/mess/video/spectrum.c b/src/mess/video/spectrum.c deleted file mode 100644 index c663aa5b865..00000000000 --- a/src/mess/video/spectrum.c +++ /dev/null @@ -1,298 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker -/*************************************************************************** - - spectrum.c - - Functions to emulate the video hardware of the ZX Spectrum. - - Changes: - - DJR 08/02/00 - Added support for FLASH 1. - DJR 16/05/00 - Support for TS2068/TC2048 hires and 64 column modes. - DJR 19/05/00 - Speeded up Spectrum 128 screen refresh. - DJR 23/05/00 - Preliminary support for border colour emulation. - -***************************************************************************/ - -#include "emu.h" -#include "includes/spectrum.h" - -/*************************************************************************** - Start the video hardware emulation. -***************************************************************************/ -VIDEO_START_MEMBER(spectrum_state,spectrum) -{ - m_frame_invert_count = 16; - m_frame_number = 0; - m_flash_invert = 0; - - m_previous_border_x = 0; - m_previous_border_y = 0; - machine().first_screen()->register_screen_bitmap(m_border_bitmap); - m_previous_screen_x = 0; - m_previous_screen_y = 0; - machine().first_screen()->register_screen_bitmap(m_screen_bitmap); - - m_screen_location = m_video_ram; -} - -VIDEO_START_MEMBER(spectrum_state,spectrum_128) -{ - m_frame_invert_count = 16; - m_frame_number = 0; - m_flash_invert = 0; - - m_previous_border_x = 0; - m_previous_border_y = 0; - machine().first_screen()->register_screen_bitmap(m_border_bitmap); - m_previous_screen_x = 0; - m_previous_screen_y = 0; - machine().first_screen()->register_screen_bitmap(m_screen_bitmap); - - m_screen_location = m_ram->pointer() + (5 << 14); -} - - -/* return the color to be used inverting FLASHing colors if necessary */ -inline unsigned char spectrum_state::get_display_color (unsigned char color, int invert) -{ - if (invert && (color & 0x80)) - return (color & 0xc0) + ((color & 0x38) >> 3) + ((color & 0x07) << 3); - else - return color; -} - -/* Code to change the FLASH status every 25 frames. Note this must be - independent of frame skip etc. */ -void spectrum_state::screen_eof_spectrum(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - spectrum_UpdateBorderBitmap(); - spectrum_UpdateScreenBitmap(true); - - m_frame_number++; - - if (m_frame_number >= m_frame_invert_count) - { - m_frame_number = 0; - m_flash_invert = !m_flash_invert; - } - } -} - - - -/*************************************************************************** - Update the spectrum screen display. - - The screen consists of 312 scanlines as follows: - 64 border lines (the last 48 are actual border lines; the others may be - border lines or vertical retrace) - 192 screen lines - 56 border lines - - Each screen line has 48 left border pixels, 256 screen pixels and 48 right - border pixels. - - Each scanline takes 224 T-states divided as follows: - 128 Screen (reads a screen and ATTR byte [8 pixels] every 4 T states) - 24 Right border - 48 Horizontal retrace - 24 Left border - - The 128K Spectrums have only 63 scanlines before the TV picture (311 total) - and take 228 T-states per scanline. - -***************************************************************************/ - -inline void spectrum_state::spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -UINT32 spectrum_state::screen_update_spectrum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - static const rectangle rect(SPEC_LEFT_BORDER, SPEC_LEFT_BORDER + SPEC_DISPLAY_XSIZE - 1, SPEC_TOP_BORDER, SPEC_TOP_BORDER + SPEC_DISPLAY_YSIZE - 1); - - if (m_border_bitmap.valid()) - copyscrollbitmap(bitmap, m_border_bitmap, 0, 0, 0, 0, cliprect); - - spectrum_UpdateScreenBitmap(); - if (m_screen_bitmap.valid()) - copyscrollbitmap(bitmap, m_screen_bitmap, 0, 0, 0, 0, rect); - -#if 0 - // note, don't update borders in here, this can time travel w/regards to other timers and may end up giving you - // screen positions earlier than the last write handler gave you - - /* for now do a full-refresh */ - int x, y, b, scrx, scry; - unsigned short ink, pap; - unsigned char *attr, *scr; - // int full_refresh = 1; - - scr=m_screen_location; - - for (y=0; y<192; y++) - { - scrx=SPEC_LEFT_BORDER; - scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); - attr=m_screen_location + ((scry>>3)*32) + 0x1800; - - for (x=0;x<32;x++) - { - /* Get ink and paper colour with bright */ - if (m_flash_invert && (*attr & 0x80)) - { - ink=((*attr)>>3) & 0x0f; - pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - } - else - { - ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - pap=((*attr)>>3) & 0x0f; - } - - for (b=0x80;b!=0;b>>=1) - { - if (*scr&b) - spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,ink); - else - spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,pap); - } - - scr++; - attr++; - } - } -#endif - - return 0; -} - - -static const rgb_t spectrum_palette[16] = { - rgb_t(0x00, 0x00, 0x00), - rgb_t(0x00, 0x00, 0xbf), - rgb_t(0xbf, 0x00, 0x00), - rgb_t(0xbf, 0x00, 0xbf), - rgb_t(0x00, 0xbf, 0x00), - rgb_t(0x00, 0xbf, 0xbf), - rgb_t(0xbf, 0xbf, 0x00), - rgb_t(0xbf, 0xbf, 0xbf), - rgb_t(0x00, 0x00, 0x00), - rgb_t(0x00, 0x00, 0xff), - rgb_t(0xff, 0x00, 0x00), - rgb_t(0xff, 0x00, 0xff), - rgb_t(0x00, 0xff, 0x00), - rgb_t(0x00, 0xff, 0xff), - rgb_t(0xff, 0xff, 0x00), - rgb_t(0xff, 0xff, 0xff) -}; -/* Initialise the palette */ -PALETTE_INIT_MEMBER(spectrum_state,spectrum) -{ - palette.set_pen_colors(0, spectrum_palette, ARRAY_LENGTH(spectrum_palette)); -} - -void spectrum_state::spectrum_UpdateScreenBitmap(bool eof) -{ - unsigned int x = machine().first_screen()->hpos(); - unsigned int y = machine().first_screen()->vpos(); - int width = m_screen_bitmap.width(); - int height = m_screen_bitmap.height(); - - - if ((m_previous_screen_x == x) && (m_previous_screen_y == y) && !eof) - return; - - if (m_screen_bitmap.valid()) - { - //printf("update screen from %d,%d to %d,%d\n", m_previous_screen_x, m_previous_screen_y, x, y); - - do - { - UINT16 scrx = m_previous_screen_x - SPEC_LEFT_BORDER; - UINT16 scry = m_previous_screen_y - SPEC_TOP_BORDER; - - if (scrx < SPEC_DISPLAY_XSIZE && scry < SPEC_DISPLAY_YSIZE) - { - // this can/must be optimised - if ((scrx & 7) == 0) { - UINT16 *bm = &m_screen_bitmap.pix16(m_previous_screen_y, m_previous_screen_x); - UINT8 attr = *(m_screen_location + ((scry & 0xF8) << 2) + (scrx >> 3) + 0x1800); - UINT8 scr = *(m_screen_location + ((scry & 7) << 8) + ((scry & 0x38) << 2) + ((scry & 0xC0) << 5) + (scrx >> 3)); - UINT16 ink = (attr & 0x07) + ((attr >> 3) & 0x08); - UINT16 pap = (attr >> 3) & 0x0f; - - if (m_flash_invert && (attr & 0x80)) - scr = ~scr; - - for (UINT8 b = 0x80; b != 0; b >>= 1) - *bm++ = (scr & b) ? ink : pap; - } - } - - m_previous_screen_x += 1; - - if (m_previous_screen_x >= width) - { - m_previous_screen_x = 0; - m_previous_screen_y += 1; - - if (m_previous_screen_y >= height) - { - m_previous_screen_y = 0; - } - } - } while (!((m_previous_screen_x == x) && (m_previous_screen_y == y))); - - } -} - -/* The code below is just a per-pixel 'partial update' for the border */ - -void spectrum_state::spectrum_UpdateBorderBitmap() -{ - unsigned int x = machine().first_screen()->hpos(); - unsigned int y = machine().first_screen()->vpos(); - int width = m_border_bitmap.width(); - int height = m_border_bitmap.height(); - - - if (m_border_bitmap.valid()) - { - UINT16 border = m_port_fe_data & 0x07; - - //printf("update border from %d,%d to %d,%d\n", m_previous_border_x, m_previous_border_y, x, y); - - do - { - m_border_bitmap.pix16(m_previous_border_y, m_previous_border_x) = border; - - m_previous_border_x += 1; - - if (m_previous_border_x >= width) - { - m_previous_border_x = 0; - m_previous_border_y += 1; - - if (m_previous_border_y >= height) - { - m_previous_border_y = 0; - } - } - } - while (!((m_previous_border_x == x) && (m_previous_border_y == y))); - - } - else - { - // no border bitmap allocated? fatalerror? - } - - -} diff --git a/src/mess/video/ssystem3.c b/src/mess/video/ssystem3.c deleted file mode 100644 index a755dff5a4b..00000000000 --- a/src/mess/video/ssystem3.c +++ /dev/null @@ -1,236 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/****************************************************************************** - PeT mess@utanet.at -******************************************************************************/ - -#include "emu.h" -#include "includes/ssystem3.h" - -void ssystem3_state::ssystem3_lcd_reset() -{ - m_lcd.count=0; m_lcd.clock=1; -} - -void ssystem3_state::ssystem3_lcd_write(int clock, int data) -{ - if (clock&&!m_lcd.clock) { - m_lcd.data[m_lcd.count/8]&=~(1<<(m_lcd.count&7)); - if (data) m_lcd.data[m_lcd.count/8]|=1<<(m_lcd.count&7); - if (m_lcd.count+1==40) { - logerror("%.4x lcd %02x%02x%02x%02x%02x\n",(int)m_maincpu->pc(), - m_lcd.data[0], m_lcd.data[1], m_lcd.data[2], m_lcd.data[3], m_lcd.data[4]); - } - m_lcd.count=(m_lcd.count+1)%40; - } - m_lcd.clock=clock; -} - - - -static const unsigned char ssystem3_palette[] = -{ - 0,12,12, - 80,82,75, - 0,12,12 -}; - - -PALETTE_INIT_MEMBER(ssystem3_state, ssystem3) -{ - int i; - - for ( i = 0; i < sizeof(ssystem3_palette) / 3; i++ ) { - m_palette->set_pen_color(i, ssystem3_palette[i*3], ssystem3_palette[i*3+1], ssystem3_palette[i*3+2]); - } -} - - -void ssystem3_state::video_start() -{ - // artwork seams to need this - m_videoram = auto_alloc_array(machine(), UINT8, 6 * 2 + 24); -} - - -static const char led[]={ - " aaaaaaaaaaaa\r" - " f aaaaaaaaaa b\r" - " ff aaaaaaaa bb\r" - " fff aaaaaa bbb\r" - " ffff bbbb\r" - " ffff bbbb\r" - " ffff bbbb\r" - " ffff bbbb\r" - " ffff bbbb\r" - " ffff bbbb\r" - " fff bbb\r" - " f gggggggg b\r" - " gggggggggggg\r" - " gggggggggggg\r" - " e gggggggg c\r" - " eee ccc\r" - " eeee cccc\r" - " eeee cccc\r" - "eeee cccc\r" - "eeee cccc\r" - "eeee cccc\r" - "eeee cccc\r" - "eee dddddd ccc\r" - "ee dddddddd cc\r" - "e dddddddddd c\r" - " dddddddddddd" -}; - -void ssystem3_state::ssystem3_draw_7segment(bitmap_ind16 &bitmap,int value, int x, int y) -{ - int i, xi, yi, mask, color; - - for (i=0, xi=0, yi=0; led[i]; i++) { - mask=0; - switch (led[i]) { - case 'a': mask=0x80; break; - case 'b': mask=0x40; break; - case 'c': mask=0x20; break; - case 'd': mask=0x10; break; - case 'e': mask=8; break; - case 'f': mask=4; break; - case 'g': mask=2; break; - case 'h': - // this is more likely wired to the separate leds - mask=1; - break; - } - - if (mask!=0) { - color=(value&mask)?1:0; - bitmap.pix16(y+yi, x+xi) = color; - } - if (led[i]!='\r') xi++; - else { yi++, xi=0; } - } -} - -static const struct { - int x,y; -} ssystem3_led_pos[5]={ - {150,123}, - {170,123}, - {200,123}, - {220,123}, - {125,123} -}; - -static const char single_led[]= -" c 1 1\r" -" bb ccccc bb 1 1\r" -" bb c bb 1 1\r" -" bb bb bb bb 1 1\r" -" bb bbbbbbbbbbb bb 111 111\r" -" 1 1\r" -" 99 9999999 99 1 1\r" -" 99 99 1 1\r" -" 88888888888 9 1 1\r" -" 88 8 9999\r" -" 8888 6666666 8 9999\r" -" 8888 6 6\r" -" 6 777 6\r" -" 6 777 6\r" -" 6 777 6\r" -" 6 777 6\r" -" 6 77777 6\r" -" 6 77777 6 2 2 4\r" -" 6 7777777 6 2 2 4\r" -" 6 7777777 6 2 2 4\r" -" 6 777777777 6 2 2 44444\r" -" 6 777777777 6 2 2 4\r" -" 6 77777777777 6 2 2 33433\r" -" 6 7 6 2 2 4\r" -" 6666666 7 6666666 2 2 4\r" -" 7 2 2 4\r" -" 77777777777777777\r" -"\r" -"\r" -"\r" -" 5555555555555555555 000000 000000 00 00 0000000 00 00 00000000 00 00 00 0000000\r" -"5 5 0000000 00000000 000 000 00000000 00 00 00000000 00 000 00 00000000\r" -"5 5 00 00 00 0000 0000 00 00 00 00 00 00 0000 00 00\r" -"5 5 00 00 00 00 00 00 00 00000000 00 00 00 00 00 00 00 00 0000\r" -"5 5 00 00 00 00 00 00 00 0000000 00 00 00 00 00 0000 00 00\r" -"5 5 0000000 00000000 00 0000 00 00 00000000 00 00 00 000 00000000\r" -" 55555555 55555555 000000 000000 00 00 00 00 000000 00 00 00 00 0000000" -; - -void ssystem3_state::ssystem3_draw_led(bitmap_ind16 &bitmap,INT16 color, int x, int y, int ch) -{ - int j, xi=0; - for (j=0; single_led[j]; j++) { - switch (single_led[j]) { - default: - if (ch==single_led[j]) { - bitmap.pix16(y, x+xi) = color; - } - xi++; - break; - case ' ': - xi++; - break; - case '\r': - xi=0; - y++; - break; - }; - } -} - -UINT32 ssystem3_state::screen_update_ssystem3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int i; - - for (i=0; i<4; i++) { - ssystem3_draw_7segment(bitmap, m_lcd.data[1+i], ssystem3_led_pos[i].x, ssystem3_led_pos[i].y); - } - - ssystem3_draw_led(bitmap, m_lcd.data[0]&1?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '0'); //? - ssystem3_draw_led(bitmap, m_lcd.data[0]&2?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '5'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&4?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '7'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&8?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, 'b'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&0x10?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '9'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&0x20?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '8'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&0x40?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, 'c'); - ssystem3_draw_led(bitmap, m_lcd.data[0]&0x80?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '6'); - ssystem3_draw_led(bitmap, m_lcd.data[1]&1?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '2'); - ssystem3_draw_led(bitmap, m_lcd.data[2]&1?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '1'); //? - ssystem3_draw_led(bitmap, m_lcd.data[3]&1?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '3'); - ssystem3_draw_led(bitmap, m_lcd.data[4]&1?1:0, ssystem3_led_pos[4].x, ssystem3_led_pos[4].y, '4'); - - if (m_configuration->read() & 1) { // playfield(optional device) - static const int lcd_signs_on[]={ - 0, // empty - 1, // bauer - 3, // springer - 0x11, // l??ufer - 7, // turm - 0x1f, // dame - 0x17, // k??nig - 0 - }; - int y, x; - for (y=0; y<8; y++) { - for (x=0; x<8; x++) { - int figure, black; - int xp=263+x*22; - int yp=55+(y^7)*28; - ssystem3_playfield_getfigure(x, y, &figure, &black); - ssystem3_draw_led(bitmap, lcd_signs_on[figure]&1?1:0, xp, yp, '6'); - ssystem3_draw_led(bitmap, lcd_signs_on[figure]&2?1:0, xp, yp, '8'); - ssystem3_draw_led(bitmap, lcd_signs_on[figure]&4?1:0, xp, yp, '9'); - ssystem3_draw_led(bitmap, lcd_signs_on[figure]&8?1:0, xp, yp, 'b'); - ssystem3_draw_led(bitmap, lcd_signs_on[figure]&0x10?1:0, xp, yp, 'c'); - ssystem3_draw_led(bitmap, figure!=0 && black?1:0, xp, yp, '7'); - } - } - } - - return 0; -} diff --git a/src/mess/video/stic.c b/src/mess/video/stic.c deleted file mode 100644 index b5b8dbfb6a4..00000000000 --- a/src/mess/video/stic.c +++ /dev/null @@ -1,974 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods,Frank Palazzolo -/********************************************************************** - - General Instruments AY-3-8900-1 a.k.a. Standard Television Interface Chip - (STIC) emulation for Mattel Intellivision - - *********************************************************************/ - -#include "emu.h" -#include "video/stic.h" - - -const device_type STIC = &device_creator; - -//------------------------------------------------- -// stic_device - constructor -//------------------------------------------------- - -stic_device::stic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, STIC, "STIC (Standard Television Interface Chip) Video Chip", tag, owner, clock, "stic", __FILE__), - m_grom(*this, "grom"), - m_x_scale(1), - m_y_scale(1) -{ -} - - -//------------------------------------------------- -// ~stic_device - destructor -//------------------------------------------------- - -stic_device::~stic_device() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void stic_device::device_start() -{ - machine().first_screen()->register_screen_bitmap(m_bitmap); - - save_item(NAME(m_stic_registers)); - save_item(NAME(m_gramdirty)); - save_item(NAME(m_gram)); - save_item(NAME(m_gramdirtybytes)); - save_item(NAME(m_color_stack_mode)); - save_item(NAME(m_color_stack_offset)); - save_item(NAME(m_stic_handshake)); - save_item(NAME(m_border_color)); - save_item(NAME(m_col_delay)); - save_item(NAME(m_row_delay)); - save_item(NAME(m_left_edge_inhibit)); - save_item(NAME(m_top_edge_inhibit)); - save_item(NAME(m_backtab_buffer)); - for (int sp = 0; sp < STIC_MOBS; sp++) - { - save_item(m_sprite[sp].visible, "STIC sprite/m_sprite[sp].visible", sp); - save_item(m_sprite[sp].xpos, "STIC sprite/m_sprite[sp].xpos", sp); - save_item(m_sprite[sp].ypos, "STIC sprite/m_sprite[sp].ypos", sp); - save_item(m_sprite[sp].coll, "STIC sprite/m_sprite[sp].coll", sp); - save_item(m_sprite[sp].collision, "STIC sprite/m_sprite[sp].collision", sp); - save_item(m_sprite[sp].doublex, "STIC sprite/m_sprite[sp].doublex", sp); - save_item(m_sprite[sp].doubley, "STIC sprite/m_sprite[sp].doubley", sp); - save_item(m_sprite[sp].quady, "STIC sprite/m_sprite[sp].quady", sp); - save_item(m_sprite[sp].xflip, "STIC sprite/m_sprite[sp].xflip", sp); - save_item(m_sprite[sp].yflip, "STIC sprite/m_sprite[sp].yflip", sp); - save_item(m_sprite[sp].behind_foreground, "STIC sprite/m_sprite[sp].behind_foreground", sp); - save_item(m_sprite[sp].grom, "STIC sprite/m_sprite[sp].grom", sp); - save_item(m_sprite[sp].card, "STIC sprite/m_sprite[sp].card", sp); - save_item(m_sprite[sp].color, "STIC sprite/m_sprite[sp].color", sp); - save_item(m_sprite[sp].doubleyres, "STIC sprite/m_sprite[sp].doubleyres", sp); - save_item(m_sprite[sp].dirty, "STIC sprite/m_sprite[sp].dirty", sp); - save_item(m_sprite_buffers[sp], "STIC sprite/m_sprite[sp].sprite_buffers", sp); - } -} - -void stic_device::device_reset() -{ - for (int i = 0; i < STIC_MOBS; i++) - { - intv_sprite_type* s = &m_sprite[i]; - s->visible = 0; - s->xpos = 0; - s->ypos = 0; - s->coll = 0; - s->collision = 0; - s->doublex = 0; - s->doubley = 0; - s->quady = 0; - s->xflip = 0; - s->yflip = 0; - s->behind_foreground = 0; - s->grom = 0; - s->card = 0; - s->color = 0; - s->doubleyres = 0; - s->dirty = 1; - for (int j = 0; j < 16; j++) - { - for (int k = 0; k < 128; k++) - { - m_sprite_buffers[i][j][k] = 0; - } - } - } - - memset(m_stic_registers, 0, sizeof(m_stic_registers)); - m_gramdirty = 1; - for (int i = 0; i < 64; i++) - { - m_gram[i] = 0; - m_gramdirtybytes[i] = 1; - } - - m_color_stack_mode = 0; - m_color_stack_offset = 0; - m_stic_handshake = 0; - m_border_color = 0; - m_col_delay = 0; - m_row_delay = 0; - m_left_edge_inhibit = 0; - m_top_edge_inhibit = 0; -} - -ROM_START( stic_grom ) - ROM_REGION( 0x800, "grom", ROMREGION_ERASEFF ) - ROM_LOAD( "ro-3-9503-003.u21", 0, 0x0800, CRC(683a4158) SHA1(f9608bb4ad1cfe3640d02844c7ad8e0bcd974917)) -ROM_END - -const rom_entry *stic_device::device_rom_region() const -{ - return ROM_NAME( stic_grom ); -} - - - -#define FOREGROUND_BIT 0x0010 - -// conversion from Intellivision color to internal representation -#define SET_COLOR(c) ((c * 2) + 1) -#define GET_COLOR(c) ((c - 1) / 2) - -/* initialized to non-zero, because we divide by it */ - -void stic_device::intv_set_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - int w, h; - - // output scaling - x *= m_x_scale; - y *= m_y_scale; - color = SET_COLOR(color); - - for (h = 0; h < m_y_scale; h++) - for (w = 0; w < m_x_scale; w++) - bitmap.pix16(y + h, x + w) = color; -} - -UINT32 stic_device::intv_get_pixel(bitmap_ind16 &bitmap, int x, int y) -{ - return GET_COLOR(bitmap.pix16(y * m_y_scale, x * m_x_scale)); -} - -void stic_device::intv_plot_box(bitmap_ind16 &bitmap, int x, int y, int w, int h, int color) -{ - bitmap.plot_box(x * m_x_scale, y * m_y_scale, w * m_x_scale, h * m_y_scale, SET_COLOR(color)); -} - - -int stic_device::sprites_collide(int spriteNum1, int spriteNum2) -{ - INT16 x0, y0, w0, h0, x1, y1, w1, h1, x2, y2, w2, h2; - - intv_sprite_type* s1 = &m_sprite[spriteNum1]; - intv_sprite_type* s2 = &m_sprite[spriteNum2]; - - x0 = STIC_OVERSCAN_LEFT_WIDTH + m_col_delay - STIC_CARD_WIDTH; - y0 = STIC_OVERSCAN_TOP_HEIGHT + m_row_delay - STIC_CARD_HEIGHT; - x1 = (s1->xpos + x0) * STIC_X_SCALE; y1 = (s1->ypos + y0) * STIC_Y_SCALE; - x2 = (s2->xpos + x0) * STIC_X_SCALE; y2 = (s2->ypos + y0) * STIC_Y_SCALE; - w1 = (s1->doublex ? 2 : 1) * STIC_CARD_WIDTH; - w2 = (s2->doublex ? 2 : 1) * STIC_CARD_WIDTH; - h1 = (s1->quady ? 4 : 1) * (s1->doubley ? 2 : 1) * (s1->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT; - h2 = (s2->quady ? 4 : 1) * (s2->doubley ? 2 : 1) * (s2->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT; - - if ((x1 >= x2 + w2) || (y1 >= y2 + h2) || - (x2 >= x1 + w1) || (y2 >= y1 + h1)) - return FALSE; - - // iterate over the intersecting bits to see if any touch - x0 = MAX(x1, x2); - y0 = MAX(y1, y2); - w0 = MIN(x1 + w1, x2 + w2) - x0; - h0 = MIN(y1 + h1, y2 + h2) - y0; - x1 = x0 - x1; - y1 = y0 - y1; - x2 = x0 - x2; - y2 = y0 - y2; - for (x0 = 0; x0 < w0; x0++) - { - for (y0 = 0; y0 < h0; y0++) - { - if (m_sprite_buffers[spriteNum1][x0 + x1][y0 + y1] && - m_sprite_buffers[spriteNum2][x0 + x2][y0 + y2]) - return TRUE; - } - } - - return FALSE; -} - -void stic_device::determine_sprite_collisions() -{ - // check sprite to sprite collisions - for (int i = 0; i < STIC_MOBS - 1; i++) - { - intv_sprite_type* s1 = &m_sprite[i]; - if (s1->xpos == 0 || !s1->coll) - continue; - - for (int j = i + 1; j < STIC_MOBS; j++) - { - intv_sprite_type* s2 = &m_sprite[j]; - if (s2->xpos == 0 || !s2->coll) - continue; - - if (sprites_collide(i, j)) - { - s1->collision |= (1 << j); - s2->collision |= (1 << i); - } - } - } -} - -void stic_device::render_sprites() -{ - INT32 cardMemoryLocation, pixelSize; - INT32 spritePixelHeight; - INT32 nextMemoryLocation; - INT32 nextData; - INT32 nextX; - INT32 nextY; - INT32 xInc; - - for (int i = 0; i < STIC_MOBS; i++) - { - intv_sprite_type* s = &m_sprite[i]; - - if (s->grom) - cardMemoryLocation = (s->card * STIC_CARD_HEIGHT); - else - cardMemoryLocation = ((s->card & 0x003F) * STIC_CARD_HEIGHT); - - pixelSize = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1); - spritePixelHeight = pixelSize * (s->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT; - - for (int j = 0; j < spritePixelHeight; j++) - { - nextMemoryLocation = (cardMemoryLocation + (j/pixelSize)); - if (s->grom) - nextData = m_grom[nextMemoryLocation]; - else if (nextMemoryLocation < 0x200) - nextData = m_gram[nextMemoryLocation]; - else - nextData = 0xFFFF; - nextX = (s->xflip ? ((s->doublex ? 2 : 1) * STIC_CARD_WIDTH - 1) : 0); - nextY = (s->yflip ? (spritePixelHeight - j - 1) : j); - xInc = (s->xflip ? -1: 1); - - for (int k = 0; k < STIC_CARD_WIDTH * (1 + s->doublex); k++) - { - m_sprite_buffers[i][nextX + k * xInc][nextY] = (nextData & (1 << ((STIC_CARD_WIDTH - 1) - k / (1 + s->doublex)))) != 0; - } - } - } -} - -void stic_device::render_line(bitmap_ind16 &bitmap, UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor) -{ - UINT32 color; - - for (int i = 0; i < STIC_CARD_WIDTH; i++) - { - color = (nextByte & (1 << ((STIC_CARD_WIDTH - 1) - i)) ? fgcolor : bgcolor); - intv_set_pixel(bitmap, x+i, y, color); - intv_set_pixel(bitmap, x+i, y+1, color); - } -} - -void stic_device::render_colored_squares(bitmap_ind16 &bitmap, UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3) -{ - intv_plot_box(bitmap, x, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color0); - intv_plot_box(bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color1); - intv_plot_box(bitmap, x, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color2); - intv_plot_box(bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color3); -} - -void stic_device::render_color_stack_mode(bitmap_ind16 &bitmap) -{ - INT16 w, h, nextx, nexty; - UINT8 csPtr = 0; - UINT16 nextCard; - - for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE; - h < STIC_BACKTAB_HEIGHT; - h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE) - { - for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE; - w < STIC_BACKTAB_WIDTH; - w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE) - { - nextCard = m_backtab_buffer[h][w]; - - // colored squares mode - if ((nextCard & (STIC_CSTM_FG3|STIC_CSTM_SEL)) == STIC_CSTM_FG3) - { - UINT8 csColor = m_stic_registers[STIC_CSR + csPtr]; - UINT8 color0 = nextCard & STIC_CSQM_A; - UINT8 color1 = (nextCard & STIC_CSQM_B) >> 3; - UINT8 color2 = (nextCard & STIC_CSQM_C) >> 6; - UINT8 color3 = ((nextCard & STIC_CSQM_D2) >> 11) | - ((nextCard & (STIC_CSQM_D10)) >> 9); - render_colored_squares(bitmap, nextx, nexty, - (color0 == 7 ? csColor : (color0 | FOREGROUND_BIT)), - (color1 == 7 ? csColor : (color1 | FOREGROUND_BIT)), - (color2 == 7 ? csColor : (color2 | FOREGROUND_BIT)), - (color3 == 7 ? csColor : (color3 | FOREGROUND_BIT))); - } - //color stack mode - else - { - UINT8 isGrom; - UINT16 memoryLocation, fgcolor, bgcolor; - UINT8* memory; - - //advance the color pointer, if necessary - if (nextCard & STIC_CSTM_ADV) - csPtr = (csPtr+1) & (STIC_CSRS - 1); - - fgcolor = ((nextCard & STIC_CSTM_FG3) >> 9) | - (nextCard & (STIC_CSTM_FG20)) | FOREGROUND_BIT; - bgcolor = m_stic_registers[STIC_CSR + csPtr] & STIC_CSR_BG; - - isGrom = !(nextCard & STIC_CSTM_SEL); - if (isGrom) - { - memoryLocation = nextCard & STIC_CSTM_C; - memory = m_grom; - for (int j = 0; j < STIC_CARD_HEIGHT; j++) - render_line(bitmap, memory[memoryLocation + j], - nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor); - } - else - { - memoryLocation = nextCard & STIC_CSTM_C50; - memory = m_gram; - for (int j = 0; j < STIC_CARD_HEIGHT; j++) - render_line(bitmap, memory[memoryLocation + j], - nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor); - } - } - } - } -} - -void stic_device::render_fg_bg_mode(bitmap_ind16 &bitmap) -{ - INT16 w, h, nextx, nexty; - UINT8 isGrom, fgcolor, bgcolor; - UINT16 nextCard, memoryLocation; - UINT8* memory; - - for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE; - h < STIC_BACKTAB_HEIGHT; - h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE) - { - for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE; - w < STIC_BACKTAB_WIDTH; - w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE) - { - nextCard = m_backtab_buffer[h][w]; - fgcolor = (nextCard & STIC_FBM_FG) | FOREGROUND_BIT; - bgcolor = ((nextCard & STIC_FBM_BG2) >> 11) | - ((nextCard & STIC_FBM_BG310) >> 9); - - isGrom = !(nextCard & STIC_FBM_SEL); - if (isGrom) - { - memoryLocation = nextCard & STIC_FBM_C; - memory = m_grom; - for (int j = 0; j < STIC_CARD_HEIGHT; j++) - render_line(bitmap, memory[memoryLocation + j], - nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor); - } - else - { - memoryLocation = nextCard & STIC_FBM_C; - memory = m_gram; - for (int j = 0; j < STIC_CARD_HEIGHT; j++) - render_line(bitmap, memory[memoryLocation + j], - nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor); - } - } - } -} - -void stic_device::copy_sprites_to_background(bitmap_ind16 &bitmap) -{ - UINT8 width, currentPixel; - UINT8 borderCollision, foregroundCollision; - UINT8 spritePixelHeight, x, y; - INT16 leftX, nextY; - INT16 leftBorder, rightBorder, topBorder, bottomBorder; - INT32 nextX; - - for (int i = STIC_MOBS - 1; i >= 0; i--) - { - intv_sprite_type *s = &m_sprite[i]; - if (s->xpos == 0 || (!s->coll && !s->visible)) - continue; - - borderCollision = FALSE; - foregroundCollision = FALSE; - - spritePixelHeight = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1) * (s->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT; - width = (s->doublex ? 2 : 1) * STIC_CARD_WIDTH; - - leftX = (s->xpos - STIC_CARD_WIDTH + STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE; - nextY = (s->ypos - STIC_CARD_HEIGHT + STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE; - - leftBorder = (STIC_OVERSCAN_LEFT_WIDTH + (m_left_edge_inhibit ? STIC_CARD_WIDTH : 0)) * STIC_X_SCALE; - rightBorder = (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 - 1) * STIC_X_SCALE; - topBorder = (STIC_OVERSCAN_TOP_HEIGHT + (m_top_edge_inhibit ? STIC_CARD_HEIGHT : 0)) * STIC_Y_SCALE; - bottomBorder = (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE - 1; - - for (y = 0; y < spritePixelHeight; y++) - { - for (x = 0; x < width; x++) - { - //if this sprite pixel is not on, then don't paint it - if (!m_sprite_buffers[i][x][y]) - continue; - - nextX = leftX + x; - //if the next pixel location is on the border, then we - //have a border collision and we can ignore painting it - if ((nextX < leftBorder) || (nextX > rightBorder) || - (nextY < topBorder) || (nextY > bottomBorder)) - { - borderCollision = TRUE; - continue; - } - - currentPixel = intv_get_pixel(bitmap, nextX, nextY); - - //check for foreground collision - if (currentPixel & FOREGROUND_BIT) - { - foregroundCollision = TRUE; - if (s->behind_foreground) - continue; - } - - if (s->visible) - { - intv_set_pixel(bitmap, nextX, nextY, s->color | (currentPixel & FOREGROUND_BIT)); - } - } - nextY++; - } - - //update the collision bits - if (s->coll) - { - if (foregroundCollision) - s->collision |= STIC_MCR_BKGD; - if (borderCollision) - s->collision |= STIC_MCR_BRDR; - } - } -} - -void stic_device::render_background(bitmap_ind16 &bitmap) -{ - if (m_color_stack_mode) - render_color_stack_mode(bitmap); - else - render_fg_bg_mode(bitmap); -} - -#ifdef UNUSED_CODE -void stic_device::draw_background(bitmap_ind16 &bitmap, int transparency) -{ - // First, draw the background - int offs = 0; - int value = 0; - int row,col; - int fgcolor,bgcolor = 0; - int code; - - int colora, colorb, colorc, colord; - - int n_bit; - int p_bit; - int g_bit; - - int j; - - int x0 = STIC_OVERSCAN_LEFT_WIDTH + m_col_delay; - int y0 = STIC_OVERSCAN_TOP_HEIGHT + m_row_delay; - - if (m_color_stack_mode == 1) - { - m_color_stack_offset = 0; - for(row = 0; row < STIC_BACKTAB_HEIGHT; row++) - { - for(col = 0; col < STIC_BACKTAB_WIDTH; col++) - { - value = m_ram16[offs]; - - n_bit = value & STIC_CSTM_ADV; - p_bit = value & STIC_CSTM_FG3; - g_bit = value & STIC_CSTM_SEL; - - if (p_bit && (!g_bit)) // colored squares mode - { - colora = value & STIC_CSQM_A; - colorb = (value & STIC_CSQM_B) >> 3; - colorc = (value & STIC_CSQM_C) >> 6; - colord = ((n_bit & STIC_CSQM_D2) >> 11) + ((value & STIC_CSQM_D10) >> 9); - // color 7 if the top of the color stack in this mode - if (colora == 7) colora = m_stic_registers[STIC_CSR + STIC_CSR3]; - if (colorb == 7) colorb = m_stic_registers[STIC_CSR + STIC_CSR3]; - if (colorc == 7) colorc = m_stic_registers[STIC_CSR + STIC_CSR3]; - if (colord == 7) colord = m_stic_registers[STIC_CSR + STIC_CSR3]; - intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colora); - intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH)) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorb); - intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorc); - intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colord); - } - else // normal color stack mode - { - if (n_bit) // next color - { - m_color_stack_offset += 1; - m_color_stack_offset &= (STIC_CSRS - 1); - } - - if (p_bit) // pastel color set - fgcolor = (value & STIC_CSTM_FG20) + 8; - else - fgcolor = value & STIC_CSTM_FG20; - - bgcolor = m_stic_registers[STIC_CSR + m_color_stack_offset]; - code = (value & STIC_CSTM_C)>>3; - - if (g_bit) // read from gram - { - code &= (STIC_CSTM_C50 >> 3); // keep from going outside the array - //if (m_gramdirtybytes[code] == 1) - { - decodechar(m_gfxdecode->gfx(1), - code, - m_gram, - machine().config()->gfxdecodeinfo[1].gfxlayout); - m_gramdirtybytes[code] = 0; - } - // Draw GRAM char - drawgfx(bitmap,m_gfxdecode->gfx(1), - code, - bgcolor*16+fgcolor, - 0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, - 0,transparency,bgcolor); - - for(j=0;j<8;j++) - { - //intv_set_pixel(bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 1); - } - - } - else // read from grom - { - drawgfx(bitmap,m_gfxdecode->gfx(0), - code, - bgcolor*16+fgcolor, - 0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, - 0,transparency,bgcolor); - - for(j=0;j<8;j++) - { - //intv_set_pixel(bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 2); - } - } - } - offs++; - } // next col - } // next row - } - else - { - // fg/bg mode goes here - for(row = 0; row < STIC_BACKTAB_HEIGHT; row++) - { - for(col = 0; col < STIC_BACKTAB_WIDTH; col++) - { - value = m_ram16[offs]; - fgcolor = value & STIC_FBM_FG; - bgcolor = ((value & STIC_FBM_BG2) >> 11) + ((value & STIC_FBM_BG310) >> 9); - code = (value & STIC_FBM_C) >> 3; - - if (value & STIC_FBM_SEL) // read for GRAM - { - //if (m_gramdirtybytes[code] == 1) - { - decodechar(m_gfxdecode->gfx(1), - code, - m_gram, - machine().config()->gfxdecodeinfo[1].gfxlayout); - m_gramdirtybytes[code] = 0; - } - // Draw GRAM char - drawgfx(bitmap,m_gfxdecode->gfx(1), - code, - bgcolor*16+fgcolor, - 0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, - 0,transparency,bgcolor); - } - else // read from GROM - { - drawgfx(bitmap,m_gfxdecode->gfx(0), - code, - bgcolor*16+fgcolor, - 0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, - 0,transparency,bgcolor); - } - offs++; - } // next col - } // next row - } -} -#endif - -/* TBD: need to handle sprites behind foreground? */ -#ifdef UNUSED_FUNCTION -void stic_device::draw_sprites(bitmap_ind16 &bitmap, int behind_foreground) -{ - int code; - int x0 = STIC_OVERSCAN_LEFT_WIDTH + m_col_delay - STIC_CARD_WIDTH; - int y0 = STIC_OVERSCAN_TOP_HEIGHT + m_row_delay - STIC_CARD_HEIGHT; - - for (int i = STIC_MOBS - 1; i >= 0; --i) - { - intv_sprite_type *s = &m_sprite[i]; - if (s->visible && (s->behind_foreground == behind_foreground)) - { - code = s->card; - if (!s->grom) - { - code %= 64; // keep from going outside the array - if (s->yres == 1) - { - //if (m_gramdirtybytes[code] == 1) - { - decodechar(m_gfxdecode->gfx(1), - code, - m_gram, - machine().config()->gfxdecodeinfo[1].gfxlayout); - m_gramdirtybytes[code] = 0; - } - // Draw GRAM char - m_gfxdecode->gfx(1)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE, - 0x8000 * s->xsize, 0x8000 * s->ysize,0); - } - else - { - //if ((m_gramdirtybytes[code] == 1) || (m_gramdirtybytes[code+1] == 1)) - { - decodechar(m_gfxdecode->gfx(1), - code, - m_gram, - machine().config()->gfxdecodeinfo[1].gfxlayout); - decodechar(m_gfxdecode->gfx(1), - code+1, - m_gram, - machine().config()->gfxdecodeinfo[1].gfxlayout); - m_gramdirtybytes[code] = 0; - m_gramdirtybytes[code+1] = 0; - } - // Draw GRAM char - m_gfxdecode->gfx(1)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + s->yflip * s->ysize * STIC_CARD_HEIGHT, - 0x8000*s->xsize, 0x8000*s->ysize,0); - m_gfxdecode->gfx(1)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code+1, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + (1 - s->yflip) * s->ysize * STIC_CARD_HEIGHT, - 0x8000*s->xsize, 0x8000*s->ysize,0); - } - } - else - { - if (s->yres == 1) - { - // Draw GROM char - m_gfxdecode->gfx(0)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE, - 0x8000*s->xsize, 0x8000*s->ysize,0); - } - else - { - m_gfxdecode->gfx(0)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + s->yflip * s->ysize * STIC_CARD_HEIGHT, - 0x8000*s->xsize, 0x8000*s->ysize,0); - m_gfxdecode->gfx(0)->zoom_transpen(bitmap,&machine().screen[0].visarea, - code+1, - s->color, - s->xflip,s->yflip, - (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + (1 - s->yflip) * s->ysize * STIC_CARD_HEIGHT, - 0x8000*s->xsize, 0x8000*s->ysize,0); - } - } - } - } -} -#endif - -void stic_device::draw_borders(bitmap_ind16 &bitmap) -{ - intv_plot_box(bitmap, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + (m_left_edge_inhibit ? STIC_CARD_WIDTH : m_col_delay)) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, m_border_color); - intv_plot_box(bitmap, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1) * STIC_X_SCALE, 0, STIC_OVERSCAN_RIGHT_WIDTH, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, m_border_color); - - intv_plot_box(bitmap, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + (m_top_edge_inhibit ? STIC_CARD_HEIGHT : m_row_delay)) * STIC_Y_SCALE, m_border_color); - intv_plot_box(bitmap, 0, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, STIC_OVERSCAN_BOTTOM_HEIGHT * STIC_Y_SCALE, m_border_color); -} - -void stic_device::screenrefresh() -{ - if (m_stic_handshake != 0) - { - m_stic_handshake = 0; - // Render the background - render_background(m_bitmap); - // Render the sprites into their buffers - render_sprites(); - for (int i = 0; i < STIC_MOBS; i++) - m_sprite[i].collision = 0; - // Copy the sprites to the background - copy_sprites_to_background(m_bitmap); - determine_sprite_collisions(); - for (int i = 0; i < STIC_MOBS; i++) - m_stic_registers[STIC_MCR + i] |= m_sprite[i].collision; - /* draw the screen borders if enabled */ - draw_borders(m_bitmap); - } - else - { - /* STIC disabled, just fill with border color */ - m_bitmap.fill(SET_COLOR(m_border_color)); - } -} - - - -READ16_MEMBER( stic_device::read ) -{ - //logerror("%x = stic_r(%x)\n",0,offset); - switch (offset) - { - case STIC_MXR + STIC_MOB0: - case STIC_MXR + STIC_MOB1: - case STIC_MXR + STIC_MOB2: - case STIC_MXR + STIC_MOB3: - case STIC_MXR + STIC_MOB4: - case STIC_MXR + STIC_MOB5: - case STIC_MXR + STIC_MOB6: - case STIC_MXR + STIC_MOB7: - return 0x3800 | (m_stic_registers[offset] & 0x07FF); - case STIC_MYR + STIC_MOB0: - case STIC_MYR + STIC_MOB1: - case STIC_MYR + STIC_MOB2: - case STIC_MYR + STIC_MOB3: - case STIC_MYR + STIC_MOB4: - case STIC_MYR + STIC_MOB5: - case STIC_MYR + STIC_MOB6: - case STIC_MYR + STIC_MOB7: - return 0x3000 | (m_stic_registers[offset] & 0x0FFF); - case STIC_MAR + STIC_MOB0: - case STIC_MAR + STIC_MOB1: - case STIC_MAR + STIC_MOB2: - case STIC_MAR + STIC_MOB3: - case STIC_MAR + STIC_MOB4: - case STIC_MAR + STIC_MOB5: - case STIC_MAR + STIC_MOB6: - case STIC_MAR + STIC_MOB7: - return m_stic_registers[offset] & 0x3FFF; - case STIC_MCR + STIC_MOB0: - case STIC_MCR + STIC_MOB1: - case STIC_MCR + STIC_MOB2: - case STIC_MCR + STIC_MOB3: - case STIC_MCR + STIC_MOB4: - case STIC_MCR + STIC_MOB5: - case STIC_MCR + STIC_MOB6: - case STIC_MCR + STIC_MOB7: - return 0x3C00 | (m_stic_registers[offset] & 0x03FF); - case STIC_GMR: - m_color_stack_mode = 1; - //logerror("Setting color stack mode\n"); - /*** fall through ***/ - case STIC_DER: - return 0x3FFF; - case STIC_CSR + STIC_CSR0: - case STIC_CSR + STIC_CSR1: - case STIC_CSR + STIC_CSR2: - case STIC_CSR + STIC_CSR3: - case STIC_BCR: - return 0x3FF0 | (m_stic_registers[offset] & 0x000F); - case STIC_HDR: - case STIC_VDR: - return 0x3FF8 | (m_stic_registers[offset] & 0x0007); - case STIC_CBR: - return 0x3FFC | (m_stic_registers[offset] & 0x0003); - default: - //logerror("unmapped read from STIC register %02X\n", offset); - return 0x3FFF; - } -} - -WRITE16_MEMBER( stic_device::write ) -{ - intv_sprite_type *s; - - //logerror("stic_w(%x) = %x\n",offset,data); - switch (offset) - { - // X Positions - case STIC_MXR + STIC_MOB0: - case STIC_MXR + STIC_MOB1: - case STIC_MXR + STIC_MOB2: - case STIC_MXR + STIC_MOB3: - case STIC_MXR + STIC_MOB4: - case STIC_MXR + STIC_MOB5: - case STIC_MXR + STIC_MOB6: - case STIC_MXR + STIC_MOB7: - s = &m_sprite[offset & (STIC_MOBS - 1)]; - s->doublex = !!(data & STIC_MXR_XSIZE); - s->visible = !!(data & STIC_MXR_VIS); - s->coll = !!(data & STIC_MXR_COL); - s->xpos = (data & STIC_MXR_X); - break; - // Y Positions - case STIC_MYR + STIC_MOB0: - case STIC_MYR + STIC_MOB1: - case STIC_MYR + STIC_MOB2: - case STIC_MYR + STIC_MOB3: - case STIC_MYR + STIC_MOB4: - case STIC_MYR + STIC_MOB5: - case STIC_MYR + STIC_MOB6: - case STIC_MYR + STIC_MOB7: - s = &m_sprite[offset & (STIC_MOBS - 1)]; - s->yflip = !!(data & STIC_MYR_YFLIP); - s->xflip = !!(data & STIC_MYR_XFLIP); - s->quady = !!(data & STIC_MYR_YSIZE); - s->doubley = !!(data & STIC_MYR_YFULL); - s->doubleyres = !!(data & STIC_MYR_YRES); - s->ypos = (data & STIC_MYR_Y); - break; - // Attributes - case STIC_MAR + STIC_MOB0: - case STIC_MAR + STIC_MOB1: - case STIC_MAR + STIC_MOB2: - case STIC_MAR + STIC_MOB3: - case STIC_MAR + STIC_MOB4: - case STIC_MAR + STIC_MOB5: - case STIC_MAR + STIC_MOB6: - case STIC_MAR + STIC_MOB7: - s = &m_sprite[offset & (STIC_MOBS - 1)]; - s->behind_foreground = !!(data & STIC_MAR_PRI); - s->grom = !(data & STIC_MAR_SEL); - s->card = ((data & STIC_MAR_C) >> 3); - s->color = ((data & STIC_MAR_FG3) >> 9) | (data & STIC_MAR_FG20); - break; - // Collision Detection - TBD - case STIC_MCR + STIC_MOB0: - case STIC_MCR + STIC_MOB1: - case STIC_MCR + STIC_MOB2: - case STIC_MCR + STIC_MOB3: - case STIC_MCR + STIC_MOB4: - case STIC_MCR + STIC_MOB5: - case STIC_MCR + STIC_MOB6: - case STIC_MCR + STIC_MOB7: - // a MOB's own collision bit is *always* zero, even if a - // one is poked into it - data &= ~(1 << (offset & (STIC_MOBS - 1))); - break; - // Display enable - case STIC_DER: - //logerror("***Writing a %x to the STIC handshake\n",data); - m_stic_handshake = 1; - break; - // Graphics Mode - case STIC_GMR: - m_color_stack_mode = 0; - break; - // Color Stack - case STIC_CSR + STIC_CSR0: - case STIC_CSR + STIC_CSR1: - case STIC_CSR + STIC_CSR2: - case STIC_CSR + STIC_CSR3: - logerror("Setting color_stack[%x] = %x (%x)\n", offset & (STIC_CSRS - 1),data & STIC_CSR_BG, space.device().safe_pc()); - break; - // Border Color - case STIC_BCR: - //logerror("***Writing a %x to the border color\n",data); - m_border_color = data & STIC_BCR_BC; - break; - // Framing - case STIC_HDR: - m_col_delay = data & STIC_HDR_DEL; - break; - case STIC_VDR: - m_row_delay = data & STIC_VDR_DEL; - break; - case STIC_CBR: - m_left_edge_inhibit = (data & STIC_CBR_COL); - m_top_edge_inhibit = (data & STIC_CBR_ROW) >> 1; - break; - default: - //logerror("unmapped write to STIC register %02X: %04X\n", offset, data); - break; - } - - if (offset < ARRAY_LENGTH(m_stic_registers)) - m_stic_registers[offset] = data; -} - - -READ16_MEMBER( stic_device::gram_read ) -{ - return m_gram[offset]; -} - -WRITE16_MEMBER( stic_device::gram_write ) -{ - data &= 0xff; - m_gram[offset] = data; - m_gramdirtybytes[offset] = 1; - m_gramdirty = 1; -} - - - -UINT32 stic_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/stic.h b/src/mess/video/stic.h deleted file mode 100644 index 2865bfaef39..00000000000 --- a/src/mess/video/stic.h +++ /dev/null @@ -1,559 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods,Frank Palazzolo -/***************************************************************************** - * - * includes/stic.h - * - ****************************************************************************/ - -#ifndef STIC_H_ -#define STIC_H_ - -// GROM/GRAM cards are 8x8 -#define STIC_CARD_WIDTH 8 -#define STIC_CARD_HEIGHT 8 - -// Intellivision resolution is 20x12 BACKTAB CARDs, minus the rightmost column, -// for an effective resolution of (19 * 8 + 1 * 7) x (12 * 8) == 159x96. -// -// MOB scanline height can be half of a card scanline height, so y-coordinates -// are scaled by 2. -#define STIC_X_SCALE 1 -#define STIC_Y_SCALE 2 - -// the Intellivision emulation scales to match the output format at the last -// step. The Intellivision keyboard component appears to be 320x96, but can -// also run Intellivision carts, so x-coordinates are conditionally scaled -// by 2. -#define INTV_X_SCALE 1 -#define INTV_Y_SCALE 1 -#define INTVKBD_X_SCALE 2 -#define INTVKBD_Y_SCALE INTV_Y_SCALE - -// overscan sizes in intv pixels -// these values are approximate. -#define STIC_OVERSCAN_LEFT_WIDTH 13 -#define STIC_OVERSCAN_RIGHT_WIDTH 17 -#define STIC_OVERSCAN_TOP_HEIGHT 12 -#define STIC_OVERSCAN_BOTTOM_HEIGHT 12 - -//Timing constants based on Joe Zbiciak's documentation -#define STIC_CYCLES_PER_SCANLINE 57 -#define STIC_ROW_BUSRQ 110 // CPU paused during backtab row buffering -#define STIC_FRAME_BUSRQ 42 // CPU paused just after end of vblank and before first row fetch (approximate) -#define STIC_VBLANK_END 3790 -#define STIC_FIRST_FETCH 3933 - -/*** STIC registers *********************************************************/ - -// number of STIC registers -#define STIC_REGISTERS 0x33 - -// STIC MOBs (Moveable OBjects) -enum -{ - STIC_MOB0, - STIC_MOB1, - STIC_MOB2, - STIC_MOB3, - STIC_MOB4, - STIC_MOB5, - STIC_MOB6, - STIC_MOB7, - - STIC_MOBS -}; - -// STIC Color Stack -enum -{ - STIC_CSR0, - STIC_CSR1, - STIC_CSR2, - STIC_CSR3, - - STIC_CSRS -}; - -/**************************************************************************** - * * - * MXR 0000[..0007] MOB X REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-----+---+---+--+--+--+--+--+--+--+--+ * - * | | | | | |XSIZE|VIS|COL|X7|X6|X5|X4|X3|X2|X1|X0| * - * +-+-+-+-+-+-----+---+---+--+--+--+--+--+--+--+--+ * - * * - * Xn x-position [0..255] * - * COL collision detection [1=enable] * - * VIS visibility [1=visible] * - * XSIZE double width [1=double] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. If X=0, the sprite is not visible and does not register collisions. * - * 2. The horizontal handle is 8 pixels from the left of the sprite, * - * regardless of width. * - * * - ****************************************************************************/ -#define STIC_MXR 0x0000 - -#define STIC_MXR_XSIZE 0x0400 -#define STIC_MXR_VIS 0x0200 -#define STIC_MXR_COL 0x0100 -#define STIC_MXR_X 0x00FF - -/**************************************************************************** - * * - * MYR 0008[..000F] MOB Y REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-----+-----+-----+-----+----+--+--+--+--+--+--+--+ * - * | | | | |YFLIP|XFLIP|YSIZE|YFULL|YRES|Y6|Y5|Y4|Y3|Y2|Y1|Y0| * - * +-+-+-+-+-----+-----+-----+-----+----+--+--+--+--+--+--+--+ * - * * - * Yn y-position [0..127] * - * YRES y-resolution [0=8 scanlines,1=16 scanlines] * - * YFULL double scanline height [1=double] * - * YSIZE quadruple scanline height [1=quadruple] * - * XFLIP horizontally flip image [1=flip] * - * YFLIP vertically flip image [1=flip] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. A sprite with YRES=1 will display two cards. * - * 2. A sprite with YFULL=0 and YSIZE=0 will have scanlines half the * - * height of a background card. * - * 3, The minimum size of a sprite is 8x8 (XSIZE=YRES=YSIZE=YFULL=0). * - * 4. The maximum size of a sprite is 16x128 (XSIZE=YRES=YSIZE=YFULL=1). * - * 5. The Y-position is measured in double height scanlines. * - * 6. The vertical handle is 8 double height scanlines from the top of the * - * sprite, regardless of height. * - * * - ****************************************************************************/ -#define STIC_MYR 0x0008 - -#define STIC_MYR_YFLIP 0x0800 -#define STIC_MYR_XFLIP 0x0400 -#define STIC_MYR_YSIZE 0x0200 -#define STIC_MYR_YFULL 0x0100 -#define STIC_MYR_YRES 0x0080 -#define STIC_MYR_Y 0x007F - -/**************************************************************************** - * * - * SAR 0010[..0017] MOB ATTRIBUTE REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+---+---+---+-+-+--+--+--+--+--+--+---+---+---+ * - * | | |PRI|FG3|SEL| | |C5|C4|C3|C2|C1|C0|FG2|FG1|FG0| * - * +-+-+---+---+---+-+-+--+--+--+--+--+--+---+---+---+ * - * * - * FGn foreground color [0..15] * - * Cn card # [0..63] * - * SEL card memory select [0=GROM, 1=GRAM] * - * PRI sprite priority [1=behind set background bit] * - * * - ****************************************************************************/ -#define STIC_MAR 0x0010 - -#define STIC_MAR_PRI 0x2000 -#define STIC_MAR_FG3 0x1000 -#define STIC_MAR_SEL 0x0800 -#define STIC_MAR_C 0x07F8 -#define STIC_MAR_FG20 0x0007 - -/**************************************************************************** - * * - * SCR 0018[..001F] MOB COLLISION REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+----+----+----+----+----+----+----+----+----+----+ * - * | | | | | | |BRDR|BKGD|SPR7|SPR6|SPR5|SPR4|SPR3|SPR2|SPR1|SPR0| * - * +-+-+-+-+-+-+----+----+----+----+----+----+----+----+----+----+ * - * * - * SPRn 1=collision with sprite #n * - * BKGD 1=collsion with set background bit * - * BRDR 1=collision with screen border * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. All collisions are latched. Successive reads read from the latch. * - * A write will reset the latch. * - * 2. Sprites with VIS=0 register collisions. * - * 3. Sprites with X=0 do not register collisions. * - * 4. Two overlapping sprites with different priorities, one completely * - * hidden behind the background, still register a collision. * - * * - ****************************************************************************/ -#define STIC_MCR 0x0018 - -#define STIC_MCR_BRDR 0x0200 -#define STIC_MCR_BKGD 0x0100 -#define STIC_MCR_SPR7 0x0080 -#define STIC_MCR_SPR6 0x0040 -#define STIC_MCR_SPR5 0x0020 -#define STIC_MCR_SPR4 0x0010 -#define STIC_MCR_SPR3 0x0008 -#define STIC_MCR_SPR2 0x0004 -#define STIC_MCR_SPR1 0x0002 -#define STIC_MCR_SPR0 0x0001 - -/**************************************************************************** - * * - * DER 0021 DISPLAY ENABLE REGISTER W * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * | | | | | | | | | | | | | | | | | * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Any write during VBLANK enables STIC output. * - * * - ****************************************************************************/ -#define STIC_DER 0x0020 - -/**************************************************************************** - * * - * GMR 0021 GRAPHICS MODE REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * | | | | | | | | | | | | | | | | | * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Any write during VBLANK enables FOREGROUND/BACKGROUND mode. * - * 2. Any read during VBLANK enables COLOR STACK/COLORED SQUARES mode. * - * * - ****************************************************************************/ -#define STIC_GMR 0x0021 - -/**************************************************************************** - * * - * CSR 0028 COLOR STACK REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+ * - * | | | | | | | | | | | | |BG3|BG2|BG1|BG0| * - * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+ * - * * - * BGn background color [0..15] * - * * - ****************************************************************************/ -#define STIC_CSR 0x0028 - -#define STIC_CSR_BG 0x000F - -/**************************************************************************** - * * - * BCR 002C BORDER COLOR REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+ * - * | | | | | | | | | | | | |BC3|BC2|BC1|BC0| * - * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+ * - * * - * BCn border color [0..15] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Affects overscan, and column and row blockouts. * - * * - ****************************************************************************/ -#define STIC_BCR 0x002C - -#define STIC_BCR_BC 0x000F - -/**************************************************************************** - * * - * HDR 0030 HORIZONTAL DELAY REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+ * - * | | | | | | | | | | | | | |DEL2|DEL1|DEL0| * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+ * - * * - * DELn horizontal delay [0..7] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Affects both BACKTAB and MOBs. * - * * - ****************************************************************************/ -#define STIC_HDR 0x0030 - -#define STIC_HDR_DEL 0x0007 - -/**************************************************************************** - * * - * STIC_VDR 0030 VERTICAL DELAY REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+ * - * | | | | | | | | | | | | | |DEL2|DEL1|DEL0| * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+ * - * * - * DELn vertical delay [0..7] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Affects both BACKTAB and MOBs. * - * * - ****************************************************************************/ -#define STIC_VDR 0x0031 - -#define STIC_VDR_DEL 0x0007 - -/**************************************************************************** - * * - * STIC_CBR 0032 CARD BLOCKOUT REGISTER RW * - * * - * (MSB) (LSB) * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+---+ * - * | | | | | | | | | | | | | | |ROW|COL| * - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+---+ * - * * - * COL blockout first card column [1=blockout] * - * ROW blockout first card row [1=blockout] * - * * - **************************************************************************** - * * - * NOTES * - * * - * 1. Generally used in conjunction with HDR and VDR registers, to achieve * - * smooth scrolling. * - * * - ****************************************************************************/ -#define STIC_CBR 0x0032 - -#define STIC_CBR_ROW 0x0002 -#define STIC_CBR_COL 0x0001 - -/*** BACKTAB ****************************************************************/ - -// BACKTAB is made up of 20x12 cards -// (the first 19 columns are 8x8, the 20th column is 7x8) -#define STIC_BACKTAB_WIDTH 20 -#define STIC_BACKTAB_HEIGHT 12 - -/**************************************************************************** - * * - * FOREGROUND/BACKGROUND MODE * - * * - * (MSB) (LSB) * - * +-+-+---+---+---+---+---+--+--+--+--+--+--+---+---+---+ * - * | | |BG2|BG3|SEL|BG1|BG0|C5|C4|C3|C2|C1|C0|FG2|FG1|FG0| * - * +-+-+---+---+---+---+---+--+--+--+--+--+--+---+---+---+ * - * * - * FGn foreground color [0..7] * - * Cn card # [0..63] * - * SEL card memory select [0=GROM, 1=GRAM] * - * BGn background color [0..15] * - * * - ****************************************************************************/ -#define STIC_FBM_BG2 0x2000 -#define STIC_FBM_BG310 0x1600 -#define STIC_FBM_SEL 0x0800 -#define STIC_FBM_C 0x01F8 -#define STIC_FBM_FG 0x0007 - -/**************************************************************************** - * * - * COLOR STACK MODE * - * * - * (MSB) (LSB) * - * +-+-+---+---+---+--+--+--+--+--+--+--+--+---+---+---+ * - * | | |ADV|FG3|SEL|C7|C6|C5|C4|C3|C2|C1|C0|FG2|FG1|FG0| * - * +-+-+---+---+---+--+--+--+--+--+--+--+--+---+---+---+ * - * * - * FGn foreground color [0..15] * - * Cn card # [GROM=0..212, GRAM=0..63] * - * SEL card memory select [0=GROM, 1=GRAM] * - * ADV advance color stack index [1=advance] * - * * - **************************************************************************** - * * - * NOTES: * - * * - * 1. When FG3=1 and SEL=0, COLORED SQUARES MODE is enabled. * - * 2. When SEL=1, C7 and C6 can be used as user-defined flags. * - * * - ****************************************************************************/ -#define STIC_CSTM_ADV 0x2000 -#define STIC_CSTM_FG3 0x1000 -#define STIC_CSTM_SEL 0x0800 -#define STIC_CSTM_C7 0x0400 -#define STIC_CSTM_C6 0x0200 -#define STIC_CSTM_C50 0x01F8 -#define STIC_CSTM_FG20 0x0007 - -#define STIC_CSTM_C (STIC_CSTM_C7|STIC_CSTM_C6|STIC_CSTM_C50) - -/**************************************************************************** - * * - * COLORED SQUARES MODE * - * * - * (MSB) (LSB) * - * +-+-+--+-+-+--+--+--+--+--+--+--+--+--+--+--+ * - * | | |D2|1|0|D1|D0|C2|C1|C0|B2|B1|B0|A2|A1|A0| * - * +-+-+--+-+-+--+--+--+--+--+--+--+--+--+--+--+ * - * * - * An color a [0..7] * - * Bn color b [0..7] * - * Cn color c [0..7] * - * Dn color d [0..7] * - * * - **************************************************************************** - * * - * NOTES: * - * * - * 1. Each color corresponds to one of the following 4 x 4 squares: * - * * - * +---+---+ * - * | a | b | * - * +---+---+ * - * | c | d | * - * +---+---+ * - * * - * 2. When color 7 is specified, the color is taken from the color stack. * - * * - ****************************************************************************/ -#define STIC_CSQM_D2 0x2000 -#define STIC_CSQM_D10 0x0600 -#define STIC_CSQM_C 0x01C0 -#define STIC_CSQM_B 0x0038 -#define STIC_CSQM_A 0x0007 - -#define STIC_CSQM_WIDTH (STIC_CARD_WIDTH / 2) -#define STIC_CSQM_HEIGHT (STIC_CARD_HEIGHT / 2) - - - -struct intv_sprite_type -{ - int visible; - int xpos; - int ypos; - int coll; - int collision; - int doublex; - int doubley; - int quady; - int xflip; - int yflip; - int behind_foreground; - int grom; - int card; - int color; - int doubleyres; - int dirty; -}; - - -// ======================> stic_device - -class stic_device : public device_t -{ -public: - // construction/destruction - stic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - virtual ~stic_device(); - - DECLARE_READ16_MEMBER(read); - DECLARE_READ16_MEMBER(gram_read); - DECLARE_READ16_MEMBER(grom_read) { if (offset > 0x800) printf("help! %X\n", offset); return (0xff00 | m_grom[offset]); } - DECLARE_WRITE16_MEMBER(write); - DECLARE_WRITE16_MEMBER(gram_write); - - void write_to_btb(int h, int w, UINT16 data) { m_backtab_buffer[h][w] = data; } - int read_row_delay() { return m_row_delay; } - int read_stic_handshake() { return m_stic_handshake; } - void set_x_scale(int val) { m_x_scale = val; } - void set_y_scale(int val) { m_y_scale = val; } - - // device-level overrides - virtual void device_start(); - virtual const rom_entry *device_rom_region() const; - virtual void device_reset(); - - void screenrefresh(); - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - -private: - - required_region_ptr m_grom; - - void intv_set_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color); - UINT32 intv_get_pixel(bitmap_ind16 &bitmap, int x, int y); - void intv_plot_box(bitmap_ind16 &bm, int x, int y, int w, int h, int color); - int sprites_collide(int spriteNum1, int spriteNum2); - void determine_sprite_collisions(); - void render_sprites(); - void render_line(bitmap_ind16 &bitmap, UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor); - void render_colored_squares(bitmap_ind16 &bitmap, UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3); - void render_color_stack_mode(bitmap_ind16 &bitmap); - void render_fg_bg_mode(bitmap_ind16 &bitmap); - void copy_sprites_to_background(bitmap_ind16 &bitmap); - void render_background(bitmap_ind16 &bitmap); - void draw_borders(bitmap_ind16 &bitmap); - -#ifdef UNUSED_CODE - void draw_background(bitmap_ind16 &bitmap, int transparency); - void draw_sprites(bitmap_ind16 &bitmap, int behind_foreground); -#endif - - bitmap_ind16 m_bitmap; - - intv_sprite_type m_sprite[STIC_MOBS]; - UINT8 m_sprite_buffers[STIC_MOBS][STIC_CARD_WIDTH * 2][STIC_CARD_HEIGHT * 4 * 2 * 2]; - UINT16 m_backtab_buffer[STIC_BACKTAB_HEIGHT][STIC_BACKTAB_WIDTH]; - int m_color_stack_mode; - int m_stic_registers[STIC_REGISTERS]; - int m_color_stack_offset; - int m_stic_handshake; - int m_border_color; - int m_col_delay; - int m_row_delay; - int m_left_edge_inhibit; - int m_top_edge_inhibit; - int m_x_scale; - int m_y_scale; - - UINT8 m_gramdirty; - UINT8 m_gram[512]; - UINT8 m_gramdirtybytes[512]; -}; - -// device type definition -extern const device_type STIC; - - -/*************************************************************************** - DEVICE CONFIGURATION MACROS - ***************************************************************************/ - -#define MCFG_STIC_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, STIC, 0) - - -#endif /* STIC_H_ */ diff --git a/src/mess/video/super80.c b/src/mess/video/super80.c deleted file mode 100644 index 5adb90c170c..00000000000 --- a/src/mess/video/super80.c +++ /dev/null @@ -1,426 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert -/* Super80.c written by Robbbert, 2005-2010. See the driver source for documentation. */ - -/* Notes on using MAME MC6845 Device (MMD). - 1. Speed of MMD is about 20% slower than pre-MMD coding - 2. Undocumented cursor start and end-lines is not supported by MMD, so we do it here. */ - - -#include "includes/super80.h" - - - -/**************************** PALETTES for super80m and super80v ******************************************/ - -PALETTE_INIT_MEMBER( super80_state, super80m ) -{ - // RGB - //palette_set_colors_rgb(super80_rgb_palette); - m_palette->set_pen_color(0, rgb_t(0x00, 0x00, 0x00)); /* 0 Black */ - m_palette->set_pen_color(1, rgb_t(0x00, 0x00, 0x00)); /* 1 Black */ - m_palette->set_pen_color(2, rgb_t(0x00, 0x00, 0x7f)); /* 2 Blue */ - m_palette->set_pen_color(3, rgb_t(0x00, 0x00, 0xff)); /* 3 Light Blue */ - m_palette->set_pen_color(4, rgb_t(0x00, 0x7f, 0x00)); /* 4 Green */ - m_palette->set_pen_color(5, rgb_t(0x00, 0xff, 0x00)); /* 5 Bright Green */ - m_palette->set_pen_color(6, rgb_t(0x00, 0x7f, 0x7f)); /* 6 Cyan */ - m_palette->set_pen_color(7, rgb_t(0x00, 0xff, 0xff)); /* 7 Turquoise */ - m_palette->set_pen_color(8, rgb_t(0x7f, 0x00, 0x00)); /* 8 Dark Red */ - m_palette->set_pen_color(9, rgb_t(0xff, 0x00, 0x00)); /* 9 Red */ - m_palette->set_pen_color(10, rgb_t(0x7f, 0x00, 0x7f)); /* 10 Purple */ - m_palette->set_pen_color(11, rgb_t(0xff, 0x00, 0xff)); /* 11 Magenta */ - m_palette->set_pen_color(12, rgb_t(0x7f, 0x7f, 0x00)); /* 12 Lime */ - m_palette->set_pen_color(13, rgb_t(0xff, 0xff, 0x00)); /* 13 Yellow */ - m_palette->set_pen_color(14, rgb_t(0xbf, 0xbf, 0xbf)); /* 14 Off White */ - m_palette->set_pen_color(15, rgb_t(0xff, 0xff, 0xff)); /* 15 White */ - // Composite - m_palette->set_pen_color(16, rgb_t(0x00, 0x00, 0x00)); /* 0 Black */ - m_palette->set_pen_color(17, rgb_t(0x80, 0x80, 0x80)); /* 1 Grey */ - m_palette->set_pen_color(18, rgb_t(0x00, 0x00, 0xff)); /* 2 Blue */ - m_palette->set_pen_color(19, rgb_t(0xff, 0xff, 0x80)); /* 3 Light Yellow */ - m_palette->set_pen_color(20, rgb_t(0x00, 0xff, 0x00)); /* 4 Green */ - m_palette->set_pen_color(21, rgb_t(0xff, 0x80, 0xff)); /* 5 Light Magenta */ - m_palette->set_pen_color(22, rgb_t(0x00, 0xff, 0xff)); /* 6 Cyan */ - m_palette->set_pen_color(23, rgb_t(0xff, 0x40, 0x40)); /* 7 Light Red */ - m_palette->set_pen_color(24, rgb_t(0xff, 0x00, 0x00)); /* 8 Red */ - m_palette->set_pen_color(25, rgb_t(0x00, 0x80, 0x80)); /* 9 Dark Cyan */ - m_palette->set_pen_color(26, rgb_t(0xff, 0x00, 0xff)); /* 10 Magenta */ - m_palette->set_pen_color(27, rgb_t(0x80, 0xff, 0x80)); /* 11 Light Green */ - m_palette->set_pen_color(28, rgb_t(0xff, 0xff, 0x00)); /* 12 Yellow */ - m_palette->set_pen_color(29, rgb_t(0x00, 0x00, 0x80)); /* 13 Dark Blue */ - m_palette->set_pen_color(30, rgb_t(0xff, 0xff, 0xff)); /* 14 White */ - m_palette->set_pen_color(31, rgb_t(0x00, 0x00, 0x00)); /* 15 Black */ -} - - - -void super80_state::screen_eof_super80m(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - /* if we chose another palette or colour mode, enable it */ - m_palette_index = (m_io_config->read() & 0x60) ? 0 : 16; - } -} - -UINT32 super80_state::screen_update_super80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr=32,gfx,screen_on=0; - UINT16 sy=0,ma=m_vidpg,x; - - output_set_value("cass_led",BIT(m_portf0, 5)); - - if ((BIT(m_portf0, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ - screen_on++; - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 32; x++) // done this way to avoid x overflowing on page FF - { - if (screen_on) - chr = m_p_ram[ma | x] & 0x3f; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=32; - } - return 0; -} - -UINT32 super80_state::screen_update_super80d(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr=32,gfx,screen_on=0; - UINT16 sy=0,ma=m_vidpg,x; - - output_set_value("cass_led",BIT(m_portf0, 5)); - - if ((BIT(m_portf0, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ - screen_on++; - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 32; x++) - { - if (screen_on) - chr = m_p_ram[ma | x]; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[((chr & 0x7f)<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)] ^ ((chr & 0x80) ? 0xff : 0); - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=32; - } - return 0; -} - -UINT32 super80_state::screen_update_super80e(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr=32,gfx,screen_on=0; - UINT16 sy=0,ma=m_vidpg,x; - - output_set_value("cass_led",BIT(m_portf0, 5)); - - if ((BIT(m_portf0, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ - screen_on++; - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 32; x++) - { - if (screen_on) - chr = m_p_ram[ma | x]; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)]; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=32; - } - return 0; -} - -UINT32 super80_state::screen_update_super80m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr=32,gfx,screen_on=0; - UINT16 sy=0,ma=m_vidpg,x; - UINT8 col, bg=0, fg=0, options=m_io_config->read(); - - /* get selected character generator */ - UINT8 cgen = m_current_charset ^ ((options & 0x10)>>4); /* bit 0 of port F1 and cgen config switch */ - - output_set_value("cass_led",BIT(m_portf0, 5)); - - if ((BIT(m_portf0, 2)) | (!BIT(options, 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ - screen_on++; - - if (screen_on) - { - if ((options & 0x60) == 0x60) - fg = 15; /* b&w */ - else - fg = 5; /* green */ - } - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 10; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 32; x++) - { - if (screen_on) - chr = m_p_ram[ma | x]; - - if (!(options & 0x40)) - { - col = m_p_ram[0xfe00 | ma | x]; /* byte of colour to display */ - fg = m_palette_index + (col & 0x0f); - bg = m_palette_index + (col >> 4); - } - - /* get pattern of pixels for that character scanline */ - if (cgen) - gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)]; - else - gfx = m_p_chargen[0x1000 | ((chr & 0x7f)<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)] ^ ((chr & 0x80) ? 0xff : 0); - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7) ? fg : bg; - *p++ = BIT(gfx, 6) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - *p++ = BIT(gfx, 4) ? fg : bg; - *p++ = BIT(gfx, 3) ? fg : bg; - *p++ = BIT(gfx, 2) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 0) ? fg : bg; - } - } - ma+=32; - } - return 0; -} - -VIDEO_START_MEMBER(super80_state,super80) -{ - m_vidpg = 0xfe00; - m_p_chargen = memregion("chargen")->base(); - m_p_ram = memregion("maincpu")->base(); -} - -/**************************** I/O PORTS *****************************************************************/ - -WRITE8_MEMBER( super80_state::super80_f1_w ) -{ - m_vidpg = (data & 0xfe) << 8; - m_current_charset = data & 1; -} - -/*--------------------------------------------------------------- - - Super-80R and Super-80V - ----------------------------------------------------------------*/ - -static const UINT8 mc6845_mask[32]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0}; - -READ8_MEMBER( super80_state::super80v_low_r ) -{ - if BIT(m_portf0, 2) - return m_p_videoram[offset]; - else - return m_p_colorram[offset]; -} - -WRITE8_MEMBER( super80_state::super80v_low_w ) -{ - if BIT(m_portf0, 2) - m_p_videoram[offset] = data; - else - m_p_colorram[offset] = data; -} - -READ8_MEMBER( super80_state::super80v_high_r ) -{ - if (!BIT(m_portf0, 2)) - return m_p_colorram[0x800 | offset]; - else - if BIT(m_portf0, 4) - return m_p_pcgram[0x800 | offset]; - else - return m_p_pcgram[offset]; -} - -WRITE8_MEMBER( super80_state::super80v_high_w ) -{ - if (!BIT(m_portf0, 2)) - m_p_colorram[0x800 | offset] = data; - else - { - m_p_videoram[0x800 | offset] = data; - - if BIT(m_portf0, 4) - m_p_pcgram[0x800 | offset] = data; - } -} - -/* The 6845 can produce a variety of cursor shapes - all are emulated here - remove when mame fixed */ -void super80_state::mc6845_cursor_configure() -{ - UINT8 i,curs_type=0,r9,r10,r11; - - /* curs_type holds the general cursor shape to be created - 0 = no cursor - 1 = partial cursor (only shows on a block of scan lines) - 2 = full cursor - 3 = two-part cursor (has a part at the top and bottom with the middle blank) */ - - for ( i = 0; i < ARRAY_LENGTH(m_mc6845_cursor); i++) m_mc6845_cursor[i] = 0; // prepare cursor by erasing old one - - r9 = m_mc6845_reg[9]; // number of scan lines - 1 - r10 = m_mc6845_reg[10] & 0x1f; // cursor start line = last 5 bits - r11 = m_mc6845_reg[11]+1; // cursor end line incremented to suit for-loops below - - /* decide the curs_type by examining the registers */ - if (r10 < r11) curs_type=1; // start less than end, show start to end - else - if (r10 == r11) curs_type=2; // if equal, show full cursor - else curs_type=3; // if start greater than end, it's a two-part cursor - - if ((r11 - 1) > r9) curs_type=2; // if end greater than scan-lines, show full cursor - if (r10 > r9) curs_type=0; // if start greater than scan-lines, then no cursor - if (r11 > 16) r11=16; // truncate 5-bit register to fit our 4-bit hardware - - /* create the new cursor */ - if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(m_mc6845_cursor);i++) m_mc6845_cursor[i]=0xff; // turn on full cursor - - if (curs_type == 1) for (i = r10;i < r11;i++) m_mc6845_cursor[i]=0xff; // for each line that should show, turn on that scan line - - if (curs_type == 3) for (i = r11; i < r10;i++) m_mc6845_cursor[i]=0; // now take a bite out of the middle -} - -VIDEO_START_MEMBER(super80_state,super80v) -{ - m_p_pcgram = memregion("maincpu")->base()+0xf000; - m_p_videoram = memregion("videoram")->base(); - m_p_colorram = memregion("colorram")->base(); -} - -UINT32 super80_state::screen_update_super80v(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - m_s_options=m_io_config->read(); - output_set_value("cass_led",BIT(m_portf0, 5)); - m_crtc->screen_update(screen, bitmap, cliprect); - return 0; -} - -MC6845_UPDATE_ROW( super80_state::crtc_update_row ) -{ - const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT8 chr,col,gfx,fg,bg=0; - UINT16 mem,x; - UINT32 *p = &bitmap.pix32(y); - - for (x = 0; x < x_count; x++) // for each character - { - UINT8 inv=0; - // if (x == cursor_x) inv=0xff; /* uncomment when mame fixed */ - mem = (ma + x) & 0xfff; - chr = m_p_videoram[mem]; - - /* get colour or b&w */ - fg = 5; /* green */ - if ((m_s_options & 0x60) == 0x60) fg = 15; /* b&w */ - - if (~m_s_options & 0x40) - { - col = m_p_colorram[mem]; /* byte of colour to display */ - fg = m_palette_index + (col & 0x0f); - bg = m_palette_index + (col >> 4); - } - - /* if inverse mode, replace any pcgram chrs with inverse chrs */ - if ((!BIT(m_portf0, 4)) && (chr & 0x80)) // is it a high chr in inverse mode - { - inv ^= 0xff; // invert the chr - chr &= 0x7f; // and drop bit 7 - } - - /* process cursor */ - if (x == cursor_x) - inv ^= m_mc6845_cursor[ra]; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_pcgram[(chr<<4) | ra] ^ inv; - - /* Display a scanline of a character */ - *p++ = palette[BIT(gfx, 7) ? fg : bg]; - *p++ = palette[BIT(gfx, 6) ? fg : bg]; - *p++ = palette[BIT(gfx, 5) ? fg : bg]; - *p++ = palette[BIT(gfx, 4) ? fg : bg]; - *p++ = palette[BIT(gfx, 3) ? fg : bg]; - *p++ = palette[BIT(gfx, 2) ? fg : bg]; - *p++ = palette[BIT(gfx, 1) ? fg : bg]; - } -} - -/**************************** I/O PORTS *****************************************************************/ - -WRITE8_MEMBER( super80_state::super80v_10_w ) -{ - data &= 0x1f; - m_mc6845_ind = data; - m_crtc->address_w( space, 0, data ); -} - -WRITE8_MEMBER( super80_state::super80v_11_w ) -{ - m_mc6845_reg[m_mc6845_ind] = data & mc6845_mask[m_mc6845_ind]; /* save data in register */ - m_crtc->register_w( space, 0, data ); - if ((m_mc6845_ind > 8) && (m_mc6845_ind < 12)) mc6845_cursor_configure(); /* adjust cursor shape - remove when mame fixed */ -} diff --git a/src/mess/video/thomson.c b/src/mess/video/thomson.c deleted file mode 100644 index a258bb529da..00000000000 --- a/src/mess/video/thomson.c +++ /dev/null @@ -1,1387 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Antoine Mine -/********************************************************************** - - Copyright (C) Antoine Mine' 2006 - - Thomson 8-bit computers - -**********************************************************************/ - -#include -#include "includes/thomson.h" - - -#define VERBOSE 0 -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - - -/* One GPL is what is drawn in 1 us by the video system in the active window. - Most of the time, it corresponds to a 8-pixel wide horizontal span. - For some TO8/9/9+/MO6 modes, it can be 4-pixel or 16-pixel wide. - There are always 40 GPLs in an active row, and it is always defined by - two bytes in video memory (0x2000 bytes appart). -*/ - -#define THOM_GPL_PER_LINE 40 - - -/****************** dynamic screen size *****************/ - - -int thomson_state::thom_update_screen_size() -{ - const rectangle &visarea = m_screen->visible_area(); - UINT8 p = m_io_vconfig->read(); - int new_w, new_h, changed = 0; - - switch ( p & 3 ) - { - case 0: m_thom_bwidth = 56; m_thom_bheight = 47; break; /* as in original (?) */ - case 1: m_thom_bwidth = 16; m_thom_bheight = 16; break; /* small */ - default: m_thom_bwidth = 0; m_thom_bheight = 0; break; /* none */ - } - - switch ( p & 0xc ) - { - case 0: m_thom_hires = 0; break; /* low */ - case 4: m_thom_hires = 1; break; /* high */ - default: m_thom_hires = m_thom_hires_better; break; /* auto */ - } - - new_w = ( 320 + m_thom_bwidth * 2 ) * ( m_thom_hires + 1 ) - 1; - new_h = ( 200 + m_thom_bheight * 2 ) /** (m_thom_hires + 1 )*/ - 1; - if ( ( visarea.max_x != new_w ) || ( visarea.max_y != new_h ) ) - { - changed = 1; - m_screen->set_visible_area(0, new_w, 0, new_h ); - } - - return changed; -} - - - -/*********************** video timing ******************************/ - - -/* elapsed time from beginning of frame, in us */ -unsigned thomson_state::thom_video_elapsed() -{ - unsigned u; - attotime elapsed = m_thom_video_timer->elapsed(); - u = (elapsed * 1000000 ).seconds(); - if ( u >= 19968 ) - u = 19968; - return u; -} - - - -struct thom_vsignal thomson_state::thom_get_vsignal() -{ - struct thom_vsignal v; - int gpl = thom_video_elapsed() - 64 * THOM_BORDER_HEIGHT - 7; - if ( gpl < 0 ) - gpl += 19968; - - v.inil = ( gpl & 63 ) <= 40; - - v.init = gpl < (64 * THOM_ACTIVE_HEIGHT - 24); - - v.lt3 = ( gpl & 8 ) ? 1 : 0; - - v.line = gpl >> 6; - - v.count = v.line * 320 + ( gpl & 63 ) * 8; - - return v; -} - - - -/************************** lightpen *******************************/ - - - -void thomson_state::thom_get_lightpen_pos( int*x, int* y ) -{ - *x = m_io_lightpen_x->read(); - *y = m_io_lightpen_y->read(); - - if ( *x < 0 ) - *x = 0; - - if ( *y < 0 ) - *y = 0; - - if ( *x > 2 * m_thom_bwidth + 319 ) - *x = 2 * m_thom_bwidth + 319; - - if ( *y > 2 * m_thom_bheight + 199 ) - *y = 2 * m_thom_bheight + 199; -} - - - -struct thom_vsignal thomson_state::thom_get_lightpen_vsignal( int xdec, int ydec, int xdec2 ) -{ - struct thom_vsignal v; - int x, y; - int gpl; - - thom_get_lightpen_pos( &x, &y ); - x += xdec - m_thom_bwidth; - y += ydec - m_thom_bheight; - - gpl = (x >> 3) + y * 64; - if ( gpl < 0 ) - gpl += 19968; - - v.inil = (gpl & 63) <= 41; - - v.init = (gpl <= 64 * THOM_ACTIVE_HEIGHT - 24); - - v.lt3 = ( gpl & 8 ) ? 1 : 0; - - v.line = y; - - if ( v.inil && v.init ) - v.count = - ( gpl >> 6 ) * 320 + /* line */ - ( gpl & 63 ) * 8 + /* gpl inside line */ - ( (x + xdec2) & 7 ); /* pixel inside gpl */ - else - v.count = 0; - - return v; -} - - - -void thomson_state::thom_set_lightpen_callback( int nb ) -{ - LOG (( "%f thom_set_lightpen_callback called\n", machine().time().as_double())); - m_thom_lightpen_nb = nb; -} - -TIMER_CALLBACK_MEMBER( thomson_state::thom_lightpen_step ) -{ - int step = param; - - if ( m_thom_lightpen_cb ) - (this->*m_thom_lightpen_cb)( step ); - - if ( step < m_thom_lightpen_nb ) - m_thom_lightpen_timer->adjust(attotime::from_usec( 64 ), step + 1); -} - - - -/***************** scan-line oriented engine ***********************/ - -/* This code, common for all Thomson machines, emulates the TO8 - video hardware, with its 16-colors chosen among 4096, 9 video modes, - and 4 video pages. Moreover, it emulates changing the palette several times - per frame to simulate more than 16 colors per frame (and the same for mode - and page switchs) and cooper effects (distinguishing the left and right - border color of each row). - - TO7, TO7/70 and MO5 video hardware are much simpler (8 or 16 fixed colors, - one mode and one video page). Although the three are different, they can all - be emulated by the TO8 video hardware. - Thus, we use the same TO8-emulation code to deal with these simpler - hardware (although it is somewhat of an overkill). -*/ - - - -/* ---------------- state & state changes ---------------- */ - - -/* returns 1 if the mode is 640 pixel wide, 0 if it is 160 or 320 */ -int thomson_state::thom_mode_is_hires( int mode ) -{ - return ( mode == THOM_VMODE_80 ) || ( mode == THOM_VMODE_80_TO9 ); -} - - - -/* either the border index or its palette entry has changed */ -void thomson_state::thom_border_changed() -{ - unsigned l = thom_video_elapsed(); - unsigned y = l >> 6; - unsigned x = l & 63; - unsigned color = m_thom_pal[ m_thom_border_index ]; - - if ( y >= THOM_TOTAL_HEIGHT ) - { - /* end of page */ - m_thom_border_r[ THOM_TOTAL_HEIGHT ] = color; - } - else if ( ! x ) - { - /* start of line */ - m_thom_border_l[ y ] = color; - m_thom_border_r[ y ] = color; - } - else if ( x <= 19 ) - { - /* between left and right border */ - /* NOTE: this makes the lower right part of the color picker blink - in the TO8/TO9/TO9+, which actually happens on the real computer! - */ - m_thom_border_r[ y ] = color; - m_thom_border_l[ y + 1 ] = color; - } - else - { - /* end of line */ - m_thom_border_l[ y + 1 ] = color; - m_thom_border_r[ y + 1 ] = color; - } - m_thom_vstate_dirty = 1; -} - - - -/* the video mode or page has changed */ -void thomson_state::thom_gplinfo_changed() -{ - unsigned l = thom_video_elapsed() - THOM_BORDER_HEIGHT * 64 - 7; - unsigned y = l >> 6; - unsigned x = l & 63; - int modepage = ((int)m_thom_vmode << 8) | m_thom_vpage; - if ( y >= 200 || x>= 40 ) - m_thom_vmodepage[ 40 ] = modepage; - else - m_thom_vmodepage[ x ] = modepage; - m_thom_vmodepage_changed = 1; -} - - - -void thomson_state::thom_set_border_color( unsigned index ) -{ - assert( index < 16 ); - if ( index != m_thom_border_index ) - { - LOG (( "thom_set_border_color: %i at line %i col %i\n", index, thom_video_elapsed() / 64, thom_video_elapsed() % 64 )); - m_thom_border_index = index; - thom_border_changed(); - } -} - - - -void thomson_state::thom_set_palette( unsigned index, UINT16 color ) -{ - assert( index < 16 ); - - if ( color != 0x1000 ) - color &= 0xfff; - - if ( m_thom_pal[ index ] == color ) - return; - - LOG (( "thom_set_palette: %i to %03x at line %i col %i\n", index, color, thom_video_elapsed() / 64, thom_video_elapsed() % 64 )); - - m_thom_pal[ index ] = color; - if ( index == m_thom_border_index ) - thom_border_changed(); - m_thom_pal_changed = 1; - m_thom_vstate_dirty = 1; -} - - - -void thomson_state::thom_set_video_mode( unsigned mode ) -{ - assert( mode < THOM_VMODE_NB ); - - if ( mode != m_thom_vmode ) - { - LOG (( "thom_set_video_mode: %i at line %i, col %i\n", mode, thom_video_elapsed() / 64, thom_video_elapsed() % 64 )); - m_thom_vmode = mode; - thom_gplinfo_changed(); - m_thom_vstate_dirty = 1; - m_thom_hires_better |= thom_mode_is_hires( mode ); - } -} - - - -void thomson_state::thom_set_video_page( unsigned page ) -{ - assert( page < THOM_NB_PAGES ) - ; - if ( page != m_thom_vpage ) { - LOG (( "thom_set_video_page: %i at line %i col %i\n", page, thom_video_elapsed() / 64, thom_video_elapsed() % 64 )); - m_thom_vpage = page; - thom_gplinfo_changed(); - m_thom_vstate_dirty = 1; - } -} - - - -/* -------------- drawing --------------- */ - - - -typedef void ( thomson_state::*thom_scandraw ) ( UINT8* vram, UINT16* dst, UINT16* pal, int org, int len ); - - - -#define UPDATE( name, res ) \ - void thomson_state::name##_scandraw_##res ( \ - UINT8* vram, UINT16* dst, UINT16* pal, \ - int org, int len ) \ - { \ - unsigned gpl; \ - vram += org; \ - dst += org * res; \ - for ( gpl = 0; gpl < len; gpl++, dst += res, vram++ ) { \ - UINT8 rama = vram[ 0 ]; \ - UINT8 ramb = vram[ 0x2000 ]; - -#define END_UPDATE \ - } \ - } - -#define UPDATE_HI( name ) UPDATE( name, 16 ) -#define UPDATE_LOW( name ) UPDATE( name, 8 ) - - - -/* 320x200, 16-colors, constraints: 2 distinct colors per GPL (8 pixels) */ -/* this also works for TO7, assuming the 2 top bits of each color byte are 1 */ - -UPDATE_HI( to770 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ ((ramb & 7) | ((ramb>>4) & 8)) ^ 8 ]; - c[1] = pal[ ((ramb >> 3) & 15) ^ 8 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( to770 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ ((ramb & 7) | ((ramb>>4) & 8)) ^ 8 ]; - c[1] = pal[ ((ramb >> 3) & 15) ^ 8 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - - - -/* as above, different (more logical but TO7-incompatible) color encoding */ - -UPDATE_HI( mo5 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ ramb & 15 ]; - c[1] = pal[ ramb >> 4 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( mo5 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ ramb & 15 ]; - c[1] = pal[ ramb >> 4 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - - -/* as mo5, but with pastel bit switched */ - -UPDATE_HI( mo5alt ) -{ - int i; - pen_t c[2]; - c[0] = pal[ (ramb & 15) ^ 8 ]; - c[1] = pal[ (ramb >> 4) ^ 8 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( mo5alt ) -{ - int i; - pen_t c[2]; - c[0] = pal[ (ramb & 15) ^ 8 ]; - c[1] = pal[ (ramb >> 4) ^ 8 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - - - -/* as to770, but with pastel color bit unswitched */ - -UPDATE_HI( to9 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ (ramb & 7) | ((ramb>>4) & 8) ]; - c[1] = pal[ (ramb >> 3) & 15 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( to9 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ (ramb & 7) | ((ramb>>4) & 8) ]; - c[1] = pal[ (ramb >> 3) & 15 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - - - -/* 320x200, 4-colors, no constraint */ - -UPDATE_HI( bitmap4 ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - c[1][1] = pal[ 3 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ] [ ramb & 1 ]; -} -END_UPDATE - -UPDATE_LOW( bitmap4 ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - c[1][1] = pal[ 3 ]; - for ( i = 0; i < 8; i++, rama >>= 1, ramb >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ] [ ramb & 1 ]; -} -END_UPDATE - - - -/* as above, but using 2-bit pixels instead of 2 planes of 1-bit pixels */ - -UPDATE_HI( bitmap4alt ) -{ - int i; - pen_t c[4]; - c[0] = pal[ 0 ]; - c[1] = pal[ 1 ]; - c[2] = pal[ 2 ]; - c[3] = pal[ 3 ]; - for ( i = 0; i < 8; i += 2, ramb >>= 2 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ ramb & 3 ]; - for ( i = 0; i < 8; i += 2, rama >>= 2 ) - dst[ 7 - i ] = dst[ 6 - i ] = c[ rama & 3 ]; -} -END_UPDATE - -UPDATE_LOW( bitmap4alt ) -{ - int i; - pen_t c[4]; - c[0] = pal[ 0 ]; - c[1] = pal[ 1 ]; - c[2] = pal[ 2 ]; - c[3] = pal[ 3 ]; - for ( i = 0; i < 4; i++, ramb >>= 2 ) - dst[ 7 - i ] = c[ ramb & 3 ]; - for ( i = 0; i < 4; i++, rama >>= 2 ) - dst[ 3 - i ] = c[ rama & 3 ]; -} -END_UPDATE - - -/* 160x200, 4 colors, no constraint, using only one memory page (undocumented) */ - -UPDATE_HI( bitmap4althalf ) -{ - dst[ 0] = dst[ 1] = dst[ 2] = dst[ 3] = pal[ rama >> 6 ]; - dst[ 4] = dst[ 5] = dst[ 6] = dst[ 7] = pal[ (rama >> 4) & 3 ]; - dst[ 8] = dst[ 9] = dst[10] = dst[11] = pal[ (rama >> 2) & 3]; - dst[12] = dst[13] = dst[14] = dst[15] = pal[ rama & 3 ]; - (void)ramb; // ramb is not used -} -END_UPDATE - -UPDATE_LOW( bitmap4althalf ) -{ - dst[0] = dst[1] = pal[ rama >> 6 ]; - dst[2] = dst[3] = pal[ (rama >> 4) & 3 ]; - dst[4] = dst[5] = pal[ (rama >> 2) & 3]; - dst[6] = dst[7] = pal[ rama & 3 ]; - (void)ramb; // ramb is not used -} -END_UPDATE - - - -/* 160x200, 16-colors, no constraint */ - -UPDATE_HI( bitmap16 ) -{ - dst[ 0] = dst[ 1] = dst[ 2] = dst[ 3] = pal[ rama >> 4 ]; - dst[ 4] = dst[ 5] = dst[ 6] = dst[ 7] = pal[ rama & 15 ]; - dst[ 8] = dst[ 9] = dst[10] = dst[11] = pal[ ramb >> 4 ]; - dst[12] = dst[13] = dst[14] = dst[15] = pal[ ramb & 15 ]; -} -END_UPDATE - -UPDATE_LOW( bitmap16 ) -{ - dst[0] = dst[1] = pal[ rama >> 4 ]; - dst[2] = dst[3] = pal[ rama & 15 ]; - dst[4] = dst[5] = pal[ ramb >> 4 ]; - dst[6] = dst[7] = pal[ ramb & 15 ]; -} -END_UPDATE - - - -/* 640x200 (80 text column), 2-colors, no constraint */ - -UPDATE_HI( mode80 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 1 ]; - for ( i = 0; i < 8; i++, ramb >>= 1 ) - dst[ 15 - i ] = c[ ramb & 1 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( mode80 ) -{ - /* 640-pixel mode but 320 pixels emulated => we merge pixels */ - int i; - pen_t c[4]; - c[0] = pal[ 0 ]; - c[1] = c[2] = c[3] = pal[ 1 ]; - for ( i = 0; i < 4; i++, ramb >>= 2 ) - dst[ 7 - i ] = c[ ramb & 3 ]; - for ( i = 0; i < 4; i++, rama >>= 2 ) - dst[ 3 - i ] = c[ rama & 3 ]; -} -END_UPDATE - - - -/* as above, but TO9 flavor */ - -UPDATE_HI( mode80_to9 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 6 ]; - for ( i = 0; i < 8; i++, ramb >>= 1 ) - dst[ 15 - i ] = c[ ramb & 1 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( mode80_to9 ) -{ - int i; - pen_t c[4]; - c[0] = pal[ 0 ]; - c[1] = c[2] = c[3] = pal[ 6 ]; - for ( i = 0; i < 4; i++, ramb >>= 2 ) - dst[ 7 - i ] = c[ ramb & 3 ]; - for ( i = 0; i < 4; i++, rama >>= 2 ) - dst[ 3 - i ] = c[ rama & 3 ]; -} -END_UPDATE - - - -/* 320x200, 2-colors, two pages (untested) */ - -UPDATE_HI( page1 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 1 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ rama & 1 ]; - (void)ramb; -} -END_UPDATE - -UPDATE_LOW( page1 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 1 ]; - for ( i = 0; i < 8; i++, rama >>= 1 ) - dst[ 7 - i ] = c[ rama & 1 ]; - (void)ramb; -} -END_UPDATE - -UPDATE_HI( page2 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 2 ]; - for ( i = 0; i < 16; i += 2, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ ramb & 1 ]; - (void)rama; -} -END_UPDATE - -UPDATE_LOW( page2 ) -{ - int i; - pen_t c[2]; - c[0] = pal[ 0 ]; - c[1] = pal[ 2 ]; - for ( i = 0; i < 8; i++, ramb >>= 1 ) - dst[ 7 - i ] = c[ ramb & 1 ]; - (void)rama; -} -END_UPDATE - - - -/* 320x200, 2-colors, two overlaid pages */ - -UPDATE_HI( overlay ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = c[1][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - for ( i = 0; i < 16; i += 2, rama >>= 1, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = c[ ramb & 1 ] [ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( overlay ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = c[1][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - for ( i = 0; i < 8; i++, rama >>= 1, ramb >>= 1 ) - dst[ 7 - i ] = c[ ramb & 1 ] [ rama & 1 ]; -} -END_UPDATE - - -/* 160x200 undocumented variant of the above (2-colors, two overlaid pages) */ - -UPDATE_HI( overlayhalf ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = c[1][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - rama >>= 4; - ramb >>= 4; - for ( i = 0; i < 16; i += 4, rama >>= 1, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = dst[ 13 - i ] = dst[ 12 - i ] = - c[ ramb & 1 ] [ rama & 1 ]; -} -END_UPDATE - -UPDATE_LOW( overlayhalf ) -{ - int i; - pen_t c[2][2]; - c[0][0] = pal[ 0 ]; - c[0][1] = c[1][1] = pal[ 1 ]; - c[1][0] = pal[ 2 ]; - rama >>= 4; - ramb >>= 4; - for ( i = 0; i < 8; i += 2, rama >>= 1, ramb >>= 1 ) - dst[ 7 - i ] = dst[ 6 - i ] = c[ ramb & 1 ] [ rama & 1 ]; -} -END_UPDATE - - - -/* 160x200, 4-colors, four overlaid pages */ - -UPDATE_HI( overlay3 ) -{ - /* Note: "Manuel Technique" doc implies that the palette entries are 0,1,2,4,8; - we now use palette entries 0,1,2,3,4 instead, as this is what the TEO emulator uses and it has been confirmed correct - */ - static const int p[2][2][2][2] = { - { { { 0, 1 }, { 2, 1 } }, { { 3, 1 }, { 2, 1 } } }, - { { { 4, 1 }, { 2, 1 } }, { { 3, 1 }, { 2, 1 } } } - }; - int i; - for ( i = 0; i < 16; i += 4, rama >>= 1, ramb >>= 1 ) - dst[ 15 - i ] = dst[ 14 - i ] = dst[ 13 - i ] = dst[ 12 - i ] = - pal[ p[ ramb & 1 ] [ (ramb >> 4) & 1 ] - [ rama & 1 ] [ (rama >> 4) & 1 ] ]; -} -END_UPDATE - -UPDATE_LOW( overlay3 ) -{ - static const int p[2][2][2][2] = { - { { { 0, 1 }, { 2, 1 } }, { { 3, 1 }, { 2, 1 } } }, - { { { 4, 1 }, { 2, 1 } }, { { 3, 1 }, { 2, 1 } } } - }; - int i; - for ( i = 0; i < 8; i += 2, rama >>= 1, ramb >>= 1 ) - dst[ 7 - i ] = dst[ 6 - i ] = - pal[ p[ ramb & 1 ] [ (ramb >> 4) & 1 ] - [ rama & 1 ] [ (rama >> 4) & 1 ] ]; -} -END_UPDATE - - - -#define FUN(x) { &thomson_state::x##_scandraw_8, &thomson_state::x##_scandraw_16 } - - -static const thom_scandraw thom_scandraw_funcs[THOM_VMODE_NB][2] = -{ - FUN(to770), FUN(mo5), FUN(bitmap4), FUN(bitmap4alt), FUN(mode80), - FUN(bitmap16), FUN(page1), FUN(page2), FUN(overlay), FUN(overlay3), - FUN(to9), FUN(mode80_to9), - FUN(bitmap4althalf), FUN(mo5alt), FUN(overlayhalf), -}; - - - -/* called at the start of each scanline in the active area, just after - left border (-1<=y<199), and also after the last scanline (y=199) -*/ -TIMER_CALLBACK_MEMBER( thomson_state::thom_scanline_start ) -{ - int y = param; - - /* update active-area */ - if ( y >= 0 && (m_thom_vstate_dirty || m_thom_vstate_last_dirty || m_thom_vmem_dirty[y]) ) - { - int x = 0; - while ( x < 40 ) - { - int xx = x; - unsigned mode = m_thom_vmodepage[x] >> 8; - unsigned page = m_thom_vmodepage[x] & 0xff; - assert( mode < THOM_VMODE_NB ); - assert( page < 4 ); - if ( m_thom_vmodepage_changed ) - { - do - { - xx++; - } - while ( xx < 40 && m_thom_vmodepage[xx] == -1 ); - } - else - { - xx = 40; - } - (this->*thom_scandraw_funcs[ mode ][ m_thom_hires ]) - ( m_thom_vram + y * 40 + page * 0x4000, - m_thom_vbody + y * 320 * (m_thom_hires+1), - m_thom_last_pal, x, xx-x ); - x = xx; - } - m_thom_vmem_dirty[y] = 0; - } - - /* prepare for next scanline */ - if ( y == 199 ) - m_thom_scanline_timer->adjust(attotime::never); - else - { - if ( m_thom_vmodepage_changed ) - { - int x, m = 0; - for ( x = 0; x <= 40; x++ ) - { - if ( m_thom_vmodepage[x] !=-1 ) - { - m = m_thom_vmodepage[x]; - m_thom_vmodepage[x] = -1; - } - } - m_thom_vmodepage[0] = m; - m_thom_vmodepage_changed = 0; - } - - if ( m_thom_pal_changed ) - { - memcpy( m_thom_last_pal, m_thom_pal, 32 ); - m_thom_pal_changed = 0; - } - - m_thom_scanline_timer->adjust(attotime::from_usec(64), y + 1); - } -} - - - -/* -------------- misc --------------- */ - - -#define FLOP_STATE (m_thom_floppy_wcount ? 2 : m_thom_floppy_rcount ? 1 : 0) - - - -void thomson_state::thom_set_mode_point( int point ) -{ - assert( point >= 0 && point <= 1 ); - m_thom_mode_point = ( ! point ) * 0x2000; - m_vrambank->set_entry( ! point ); -} - - - -void thomson_state::thom_floppy_active( int write ) -{ - int fold = FLOP_STATE, fnew; - - /* stays up for a few frames */ - if ( write ) - m_thom_floppy_wcount = 25; - else - m_thom_floppy_rcount = 25; - - /* update icon */ - fnew = FLOP_STATE; - if ( fold != fnew ) - output_set_value( "floppy", fnew ); -} - - - -/* -------------- main update function --------------- */ - - - -UINT32 thomson_state::screen_update_thom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int y, ypos; - const int scale = m_thom_hires ? 2 : 1; - const int xbleft = m_thom_bwidth * scale; - const int xbright = ( m_thom_bwidth + THOM_ACTIVE_WIDTH ) * scale; - const int xright = ( m_thom_bwidth * 2 + THOM_ACTIVE_WIDTH ) * scale; - const int xwidth = THOM_ACTIVE_WIDTH * scale; - const int yup = THOM_BORDER_HEIGHT + THOM_ACTIVE_HEIGHT; - const int ybot = THOM_BORDER_HEIGHT + m_thom_bheight + 200; - UINT16* v = m_thom_vbody; - pen_t border = 0; - rectangle wrect(0, xright - 1, 0, 0); - rectangle lrect(0, xbleft - 1, 0, 0); - rectangle rrect(xbright, xright - 1, 0, 0); - - //LOG (( "%f thom: video update called\n", machine().time().as_double())); - - /* upper border */ - for ( y = 0; y < THOM_BORDER_HEIGHT - m_thom_bheight; y++ ) - { - if ( m_thom_border_l[ y ] != -1 ) - border = m_thom_border_l[ y ]; - } - ypos = 0; - while ( y < THOM_BORDER_HEIGHT ) - { - if ( m_thom_border_l[ y ] != -1 ) - border = m_thom_border_l[ y ]; - wrect.min_y = ypos; - do - { - y++; - ypos ++ /* += scale */; - } - while ( y < THOM_BORDER_HEIGHT && m_thom_border_l[ y ] == -1 ); - wrect.max_y = ypos - 1; - bitmap.fill(border, wrect ); - } - - /* left border */ - while ( y < yup ) - { - if ( m_thom_border_l[ y ] != -1 ) - border = m_thom_border_l[ y ]; - lrect.min_y = ypos; - do - { - y++; - ypos ++ /* += scale */; - } - while ( y < yup && m_thom_border_l[ y ] == -1 ); - lrect.max_y = ypos - 1; - bitmap.fill(border, lrect ); - } - - /* lower border */ - while (y < ybot ) - { - if ( m_thom_border_l[ y ] != -1 ) - border = m_thom_border_l[ y ]; - wrect.min_y = ypos; - do - { - y++; - ypos ++ /* += scale */; - } while ( y < ybot && m_thom_border_l[ y ] == -1 ); - wrect.max_y = ypos - 1; - bitmap.fill(border, wrect ); - } - - /* right border */ - for ( y = 0; y < THOM_BORDER_HEIGHT; y++ ) { - if ( m_thom_border_r[ y ] != -1 ) - border = m_thom_border_r[ y ]; - } - ypos = m_thom_bheight /* * scale */; - while ( y < yup ) - { - if ( m_thom_border_r[ y ] != -1 ) - border = m_thom_border_r[ y ]; - rrect.min_y = ypos; - do - { - y++; - ypos ++ /* += scale */; - } - while ( y < yup && m_thom_border_r[ y ] == -1 ); - rrect.max_y = ypos - 1; - bitmap.fill(border, rrect ); - } - - /* active area */ - ypos = m_thom_bheight /* * scale */; - for ( y = 0; y < 200; v += xwidth, y++ , ypos ++ /* += scale */ ) - { - draw_scanline16( bitmap, xbleft, ypos, xwidth, v, NULL ); -#if 0 - if ( thom_hires ) - draw_scanline16( bitmap, xbleft, ypos+1, xwidth, v, NULL ); -#endif - } - - return 0; -} - - - -/* -------------- frame start ------------------ */ - - -TIMER_CALLBACK_MEMBER( thomson_state::thom_set_init ) -{ - int init = param; - LOG (( "%f thom_set_init: %i, at line %i col %i\n", machine().time().as_double(), init, thom_video_elapsed() / 64, thom_video_elapsed() % 64 )); - - if ( m_thom_init_cb ) - (this->*m_thom_init_cb)( init ); - if ( ! init ) - m_thom_init_timer->adjust(attotime::from_usec( 64 * THOM_ACTIVE_HEIGHT - 24 ), 1-init); -} - -/* call this at the very beginning of each new frame */ -void thomson_state::thom_vblank( screen_device &screen, bool state ) -{ - // rising edge - if (state) - { - int fnew, fold = FLOP_STATE; - int i; - UINT16 b = 0; - struct thom_vsignal l = thom_get_lightpen_vsignal( 0, -1, 0 ); - - LOG (( "%f thom: video eof called\n", machine().time().as_double() )); - - /* floppy indicator count */ - if ( m_thom_floppy_wcount ) - m_thom_floppy_wcount--; - if ( m_thom_floppy_rcount ) - m_thom_floppy_rcount--; - fnew = FLOP_STATE; - if ( fnew != fold ) - output_set_value( "floppy", fnew ); - - /* prepare state for next frame */ - for ( i = 0; i <= THOM_TOTAL_HEIGHT; i++ ) - { - if ( m_thom_border_l[ i ] != -1 ) - b = m_thom_border_l[ i ]; - if ( m_thom_border_r[ i ] != -1 ) - b = m_thom_border_r[ i ]; - } - memset( m_thom_border_l, 0xff, sizeof( m_thom_border_l ) ); - memset( m_thom_border_r, 0xff, sizeof( m_thom_border_r ) ); - m_thom_border_l[ 0 ] = b; - m_thom_border_r[ 0 ] = b; - m_thom_vstate_last_dirty = m_thom_vstate_dirty; - m_thom_vstate_dirty = 0; - - /* schedule first init signal */ - m_thom_init_timer->adjust(attotime::from_usec( 64 * THOM_BORDER_HEIGHT + 7 )); - - /* schedule first lightpen signal */ - l.line &= ~1; /* hack (avoid lock in MO6 palette selection) */ - m_thom_lightpen_timer->adjust( - attotime::from_usec( 64 * ( THOM_BORDER_HEIGHT + l.line - 2 ) + 16 ), 0); - - /* schedule first active-area scanline call-back */ - m_thom_scanline_timer->adjust(attotime::from_usec( 64 * THOM_BORDER_HEIGHT + 7), -1); - - /* reset video frame time */ - m_thom_video_timer->adjust(attotime::zero); - - /* update screen size according to user options */ - if ( thom_update_screen_size() ) - m_thom_vstate_dirty = 1; - - /* hi-res automatic */ - m_thom_hires_better = thom_mode_is_hires( m_thom_vmode ); - } -} - - - -/* -------------- initialization --------------- */ - - -/* TO7, TO7/70 palette, hardcoded in ROM - without further information, we assume that the hardcoded values - are the same as those setup by the TO8/TO9+/MO6 when booting up - */ -static const UINT16 thom_pal_init[16] = -{ - 0x1000, /* 0: black */ 0x000f, /* 1: red */ - 0x00f0, /* 2: geen */ 0x00ff, /* 3: yellow */ - 0x0f00, /* 4: blue */ 0x0f0f, /* 5: purple */ - 0x0ff0, /* 6: cyan */ 0x0fff, /* 7: white */ - 0x0777, /* 8: gray */ 0x033a, /* 9: pink */ - 0x03a3, /* a: light green */ 0x03aa, /* b: light yellow */ - 0x0a33, /* c: light blue */ 0x0a3a, /* d: redish pink */ - 0x0ee7, /* e: light cyan */ 0x007b, /* f: orange */ -}; - -/* MO5 palette, hardcoded in a ROM - values are from "Manuel Technique du MO5", p.19 - */ -static const UINT16 mo5_pal_init[16] = -{ - 0x1000, /* 0: black */ 0x055f, /* 1: red */ - 0x00f0, /* 2: geen */ 0x00ff, /* 3: yellow */ - 0x0f55, /* 4: blue */ 0x0f0f, /* 5: purple */ - 0x0ff5, /* 6: cyan */ 0x0fff, /* 7: white */ - 0x0aaa, /* 8: gray */ 0x0aaf, /* 9: pink */ - 0x0afa, /* a: light green */ 0x0aff, /* b: light yellow */ - 0x0fa5, /* c: light blue */ 0x0faf, /* d: parama pink */ - 0x0ffa, /* e: light cyan */ 0x05af, /* f: orange */ -}; - - -VIDEO_START_MEMBER( thomson_state, thom ) -{ - LOG (( "thom: video start called\n" )); - - /* scan-line state */ - memset( m_thom_border_l, 0xff, sizeof( m_thom_border_l ) ); - memset( m_thom_border_r, 0xff, sizeof( m_thom_border_r ) ); - memset( m_thom_vbody, 0, sizeof( m_thom_vbody ) ); - memset( m_thom_vmodepage, 0xffff, sizeof( m_thom_vmodepage ) ); - memset( m_thom_vmem_dirty, 0, sizeof( m_thom_vmem_dirty ) ); - m_thom_border_l[ 0 ] = 0; - m_thom_border_r[ 0 ] = 0; - m_thom_vmodepage[ 0 ] = 0; - m_thom_vmodepage_changed = 0; - m_thom_vmode = 0; - m_thom_vpage = 0; - m_thom_border_index = 0; - m_thom_vstate_dirty = 1; - m_thom_vstate_last_dirty = 1; - save_pointer(NAME(m_thom_last_pal), sizeof(m_thom_last_pal)); - save_pointer(NAME(m_thom_pal), sizeof(m_thom_pal)); - save_pointer(NAME(m_thom_border_l), sizeof(m_thom_border_l)); - save_pointer(NAME(m_thom_border_r), sizeof(m_thom_border_r)); - save_pointer(NAME(m_thom_vbody), sizeof(m_thom_vbody)); - save_pointer(NAME(m_thom_vmodepage), sizeof(m_thom_vmodepage)); - save_pointer(NAME(m_thom_vmem_dirty), sizeof(m_thom_vmem_dirty)); - save_item(NAME(m_thom_pal_changed)); - save_item(NAME(m_thom_vmodepage_changed)); - save_item(NAME(m_thom_vmode)); - save_item(NAME(m_thom_vpage)); - save_item(NAME(m_thom_border_index)); - save_item(NAME(m_thom_vstate_dirty)); - save_item(NAME(m_thom_vstate_last_dirty)); - - m_thom_mode_point = 0; - save_item(NAME(m_thom_mode_point)); - m_vrambank->set_entry( 0 ); - - m_thom_floppy_rcount = 0; - m_thom_floppy_wcount = 0; - save_item(NAME(m_thom_floppy_wcount)); - save_item(NAME(m_thom_floppy_rcount)); - output_set_value( "floppy", 0 ); - - m_thom_video_timer = machine().scheduler().timer_alloc(FUNC_NULL); - - m_thom_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::thom_scanline_start),this)); - - m_thom_lightpen_nb = 0; - m_thom_lightpen_cb = NULL; - m_thom_lightpen_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::thom_lightpen_step),this)); - save_item(NAME(m_thom_lightpen_nb)); - - m_thom_init_cb = NULL; - m_thom_init_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::thom_set_init),this)); - - save_item(NAME(m_thom_bwidth)); - save_item(NAME(m_thom_bheight)); - save_item(NAME(m_thom_hires)); - save_item(NAME(m_thom_hires_better)); -} - - -/* sets the fixed palette (for MO5,TO7,TO7/70) and gamma correction */ -void thomson_state::thom_configure_palette(double gamma, const UINT16* pal, palette_device& palette) -{ - memcpy( m_thom_last_pal, pal, 32 ); - memcpy( m_thom_pal, pal, 32 ); - - for ( int i = 0; i < 4097; i++ ) - { - UINT8 r = 255. * pow( (i & 15) / 15., gamma ); - UINT8 g = 255. * pow( ((i>> 4) & 15) / 15., gamma ); - UINT8 b = 255. * pow( ((i >> 8) & 15) / 15., gamma ); - /* UINT8 alpha = i & 0x1000 ? 0 : 255; TODO: transparency */ - palette.set_pen_color(i, r, g, b ); - } -} - - -PALETTE_INIT_MEMBER(thomson_state, thom) -{ - LOG (( "thom: palette init called\n" )); - - /* TO8 and later use an EF9369 color palette chip - The spec shows a built-in gamma correction for gamma=2.8 - i.e., output is out = in ^ (1/2.8) - - For the TO7, the gamma correction is irrelevant. - - For the TO7/70, we use the same palette and gamma has the TO8, - which gives good results (but is not verified). - */ - thom_configure_palette(1.0 / 2.8, thom_pal_init, palette); -} - -PALETTE_INIT_MEMBER(thomson_state, mo5) -{ - LOG (( "thom: MO5 palette init called\n" )); - - /* The MO5 has a different fixed palette than the TO7/70. - We use a smaller gamma correction which gives intutively better - results (but is not verified). - */ - thom_configure_palette(1.0, mo5_pal_init, palette); -} - - - -/***************************** TO7 / T9000 *************************/ - - - -/* write to video memory through addresses 0x4000-0x5fff */ -WRITE8_MEMBER( thomson_state::to7_vram_w ) -{ - assert( offset < 0x2000 ); - /* force two topmost color bits to 1 */ - if ( m_thom_mode_point ) - data |= 0xc0; - if ( m_thom_vram[ offset + m_thom_mode_point ] == data ) - return; - m_thom_vram[ offset + m_thom_mode_point ] = data; - /* dirty whole scanline */ - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - -/* bits 0-13 : latched gpl of lightpen position */ -/* bit 14: latched INIT */ -/* bit 15: latched INIL */ -unsigned thomson_state::to7_lightpen_gpl ( int decx, int decy ) -{ - int x,y; - thom_get_lightpen_pos( &x, &y ); - x -= m_thom_bwidth; - y -= m_thom_bheight; - if ( x < 0 || y < 0 || x >= 320 || y >= 200 ) - return 0; - x += decx; - y += decy; - return y*40 + x/8 + (x < 320 ? 0x4000 : 0) + 0x8000; -} - - - -/************************** TO7/70 / MO5 ****************************/ - - - -/* write to video memory through addresses 0x4000-0x5fff (TO) - or 0x0000-0x1fff (MO) */ -WRITE8_MEMBER( thomson_state::to770_vram_w ) -{ - assert( offset < 0x2000 ); - if ( m_thom_vram[ offset + m_thom_mode_point ] == data ) - return; - m_thom_vram[ offset + m_thom_mode_point ] = data; - /* dirty whole scanline */ - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - - -/***************************** TO8 ******************************/ - - - -/* write to video memory through system space (always page 1) */ - -WRITE8_MEMBER( thomson_state::to8_sys_lo_w ) -{ - UINT8* dst = m_thom_vram + offset + 0x6000; - assert( offset < 0x2000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - -WRITE8_MEMBER( thomson_state::to8_sys_hi_w ) -{ - UINT8* dst = m_thom_vram + offset + 0x4000; - assert( offset < 0x2000 ); - if ( *dst == data ) return; - *dst = data; - /* dirty whole scanline */ - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - -/* write to video memory through data space */ - -WRITE8_MEMBER( thomson_state::to8_data_lo_w ) -{ - UINT8* dst = m_thom_vram + ( ( offset + 0x4000 * m_to8_data_vpage + 0x2000 ) & m_ram->mask() ); - assert( offset < 0x2000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - if ( m_to8_data_vpage >= 4 ) - return; - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - -WRITE8_MEMBER( thomson_state::to8_data_hi_w ) -{ - UINT8* dst = m_thom_vram + ( ( offset + 0x4000 * m_to8_data_vpage ) & m_ram->mask() ); - assert( offset < 0x2000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - if ( m_to8_data_vpage >= 4 ) - return; - m_thom_vmem_dirty[ offset / 40 ] = 1; -} - - - -/* write to video memory page through cartridge addresses space */ -WRITE8_MEMBER( thomson_state::to8_vcart_w ) -{ - UINT8* dst = m_thom_vram + ( ( offset + 0x4000 * m_to8_cart_vpage ) & m_ram->mask() ); - assert( offset < 0x4000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - if ( m_to8_cart_vpage >= 4 ) - return; - m_thom_vmem_dirty[ (offset & 0x1fff) / 40 ] = 1; -} - -WRITE8_MEMBER( thomson_state::mo6_vcart_lo_w ) -{ - UINT8* dst = m_thom_vram + ( ( offset + 0x3000 + 0x4000 * m_to8_cart_vpage ) & m_ram->mask() ); - assert( offset < 0x1000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - if ( m_to8_cart_vpage >= 4 ) - return; - m_thom_vmem_dirty[ (offset & 0x1fff) / 40 ] = 1; -} - -WRITE8_MEMBER( thomson_state::mo6_vcart_hi_w ) -{ - UINT8* dst = m_thom_vram + ( ( offset + 0x4000 * m_to8_cart_vpage ) & m_ram->mask() ); - assert( offset < 0x3000 ); - if ( *dst == data ) - return; - *dst = data; - /* dirty whole scanline */ - if ( m_to8_cart_vpage >= 4 ) - return; - m_thom_vmem_dirty[ (offset & 0x1fff) / 40 ] = 1; -} diff --git a/src/mess/video/ti85.c b/src/mess/video/ti85.c deleted file mode 100644 index 92ade7ae6fc..00000000000 --- a/src/mess/video/ti85.c +++ /dev/null @@ -1,194 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha,Jon Sturm -/*************************************************************************** - TI-85 driver by Krzysztof Strzecha - - Functions to emulate the video hardware of the TI-85 - -***************************************************************************/ - -#include "emu.h" -#include "includes/ti85.h" - -#define TI81_VIDEO_MEMORY_SIZE 768 -#define TI81_SCREEN_X_SIZE 12 -#define TI81_SCREEN_Y_SIZE 64 -#define TI81_NUMBER_OF_FRAMES 6 - -#define TI85_VIDEO_MEMORY_SIZE 1024 -#define TI85_SCREEN_X_SIZE 16 -#define TI85_SCREEN_Y_SIZE 64 -#define TI85_NUMBER_OF_FRAMES 6 - -#define TI86_VIDEO_MEMORY_SIZE 1024 -#define TI86_SCREEN_X_SIZE 16 -#define TI86_SCREEN_Y_SIZE 64 -#define TI86_NUMBER_OF_FRAMES 6 - - - -static const unsigned char ti85_colors[32*7][3] = -{ - { 0xae, 0xcd, 0xb0 }, { 0xaa, 0xc9, 0xae }, { 0xa6, 0xc5, 0xad }, { 0xa3, 0xc1, 0xab }, { 0x9f, 0xbd, 0xaa }, { 0x9b, 0xb9, 0xa8 }, { 0x98, 0xb5, 0xa7 }, //0x00 - { 0xae, 0xcd, 0xb0 }, { 0xa9, 0xc8, 0xae }, { 0xa4, 0xc3, 0xac }, { 0xa0, 0xbe, 0xaa }, { 0x9b, 0xb9, 0xa8 }, { 0x96, 0xb4, 0xa6 }, { 0x92, 0xaf, 0xa4 }, //0x01 - { 0xae, 0xcd, 0xb0 }, { 0xa8, 0xc7, 0xad }, { 0xa2, 0xc1, 0xab }, { 0x9d, 0xbb, 0xa9 }, { 0x97, 0xb5, 0xa6 }, { 0x91, 0xaf, 0xa4 }, { 0x8c, 0xa9, 0xa2 }, //0x02 - { 0xae, 0xcd, 0xb0 }, { 0xa7, 0xc6, 0xad }, { 0xa0, 0xbf, 0xaa }, { 0x9a, 0xb8, 0xa7 }, { 0x93, 0xb1, 0xa4 }, { 0x8c, 0xaa, 0xa1 }, { 0x86, 0xa3, 0x9f }, //0x03 - { 0xae, 0xcd, 0xb0 }, { 0xa6, 0xc5, 0xac }, { 0x9f, 0xbd, 0xa9 }, { 0x97, 0xb5, 0xa6 }, { 0x90, 0xad, 0xa3 }, { 0x88, 0xa5, 0xa0 }, { 0x81, 0x9d, 0x9d }, //0x04 - { 0xae, 0xcd, 0xb0 }, { 0xa5, 0xc4, 0xac }, { 0x9d, 0xbb, 0xa8 }, { 0x94, 0xb2, 0xa5 }, { 0x8c, 0xa9, 0xa1 }, { 0x83, 0xa0, 0x9d }, { 0x7b, 0x97, 0x9a }, //0x05 - { 0xae, 0xcd, 0xb0 }, { 0xa4, 0xc3, 0xac }, { 0x9b, 0xb9, 0xa8 }, { 0x91, 0xaf, 0xa4 }, { 0x88, 0xa5, 0xa0 }, { 0x7e, 0x9b, 0x9c }, { 0x75, 0x92, 0x98 }, //0x06 - { 0xae, 0xcd, 0xb0 }, { 0xa3, 0xc2, 0xab }, { 0x99, 0xb7, 0xa7 }, { 0x8e, 0xac, 0xa3 }, { 0x84, 0xa1, 0x9e }, { 0x79, 0x96, 0x9a }, { 0x6f, 0x8c, 0x96 }, //0x07 - { 0xae, 0xcd, 0xb0 }, { 0xa2, 0xc1, 0xab }, { 0x97, 0xb5, 0xa6 }, { 0x8c, 0xa9, 0xa1 }, { 0x80, 0x9d, 0x9c }, { 0x75, 0x91, 0x97 }, { 0x6a, 0x86, 0x93 }, //0x08 - { 0xae, 0xcd, 0xb0 }, { 0xa1, 0xc0, 0xaa }, { 0x95, 0xb3, 0xa5 }, { 0x89, 0xa6, 0xa0 }, { 0x7c, 0x99, 0x9b }, { 0x70, 0x8c, 0x96 }, { 0x64, 0x80, 0x91 }, //0x09 - { 0xae, 0xcd, 0xb0 }, { 0xa0, 0xbf, 0xaa }, { 0x93, 0xb1, 0xa4 }, { 0x86, 0xa3, 0x9f }, { 0x78, 0x95, 0x99 }, { 0x6b, 0x87, 0x93 }, { 0x5e, 0x7a, 0x8e }, //0x0a - { 0xae, 0xcd, 0xb0 }, { 0x9f, 0xbe, 0xaa }, { 0x91, 0xaf, 0xa4 }, { 0x83, 0xa0, 0x9e }, { 0x74, 0x91, 0x98 }, { 0x66, 0x82, 0x92 }, { 0x58, 0x74, 0x8c }, //0x0b - { 0xae, 0xcd, 0xb0 }, { 0x9e, 0xbd, 0xa9 }, { 0x8f, 0xad, 0xa3 }, { 0x80, 0x9e, 0x9d }, { 0x71, 0x8e, 0x96 }, { 0x62, 0x7e, 0x90 }, { 0x53, 0x6f, 0x8a }, //0x0c - { 0xa9, 0xc8, 0xae }, { 0x9a, 0xb9, 0xa8 }, { 0x8c, 0xaa, 0xa2 }, { 0x7e, 0x9b, 0x9c }, { 0x6f, 0x8c, 0x96 }, { 0x61, 0x7d, 0x90 }, { 0x53, 0x6f, 0x8a }, //0x0d - { 0xa4, 0xc3, 0xac }, { 0x96, 0xb5, 0xa6 }, { 0x89, 0xa7, 0xa0 }, { 0x7b, 0x99, 0x9b }, { 0x6e, 0x8b, 0x95 }, { 0x60, 0x7d, 0x8f }, { 0x53, 0x6f, 0x8a }, //0x0e - { 0xa0, 0xbe, 0xaa }, { 0x93, 0xb0, 0xa4 }, { 0x86, 0xa3, 0x9f }, { 0x79, 0x96, 0x9a }, { 0x6c, 0x89, 0x94 }, { 0x5f, 0x7c, 0x8f }, { 0x53, 0x6f, 0x8a }, //0x0f - { 0x9b, 0xba, 0xa8 }, { 0x8f, 0xad, 0xa3 }, { 0x83, 0xa1, 0x9e }, { 0x77, 0x94, 0x99 }, { 0x6b, 0x88, 0x94 }, { 0x5f, 0x7b, 0x8f }, { 0x53, 0x6f, 0x8a }, //0x10 - { 0x97, 0xb5, 0xa6 }, { 0x8b, 0xa9, 0xa1 }, { 0x80, 0x9d, 0x9c }, { 0x75, 0x92, 0x98 }, { 0x69, 0x86, 0x93 }, { 0x5e, 0x7a, 0x8e }, { 0x53, 0x6f, 0x8a }, //0x11 - { 0x92, 0xb0, 0xa4 }, { 0x87, 0xa5, 0x9f }, { 0x7d, 0x9a, 0x9b }, { 0x72, 0x8f, 0x97 }, { 0x68, 0x84, 0x92 }, { 0x5d, 0x79, 0x8e }, { 0x53, 0x6f, 0x8a }, //0x12 - { 0x8e, 0xac, 0xa2 }, { 0x84, 0xa1, 0x9e }, { 0x7a, 0x97, 0x9a }, { 0x70, 0x8d, 0x96 }, { 0x66, 0x83, 0x92 }, { 0x5c, 0x79, 0x8e }, { 0x53, 0x6f, 0x8a }, //0x13 - { 0x89, 0xa7, 0xa0 }, { 0x80, 0x9d, 0x9c }, { 0x77, 0x94, 0x98 }, { 0x6e, 0x8b, 0x95 }, { 0x65, 0x81, 0x91 }, { 0x5c, 0x78, 0x8d }, { 0x53, 0x6f, 0x8a }, //0x14 - { 0x85, 0xa2, 0x9e }, { 0x7c, 0x99, 0x9a }, { 0x74, 0x91, 0x97 }, { 0x6c, 0x88, 0x94 }, { 0x63, 0x80, 0x90 }, { 0x5b, 0x77, 0x8d }, { 0x53, 0x6f, 0x8a }, //0x15 - { 0x80, 0x9e, 0x9d }, { 0x78, 0x96, 0x99 }, { 0x71, 0x8e, 0x96 }, { 0x69, 0x86, 0x93 }, { 0x62, 0x7e, 0x90 }, { 0x5a, 0x76, 0x8d }, { 0x53, 0x6f, 0x8a }, //0x16 - { 0x7c, 0x99, 0x9b }, { 0x75, 0x92, 0x98 }, { 0x6e, 0x8b, 0x95 }, { 0x67, 0x84, 0x92 }, { 0x60, 0x7d, 0x8f }, { 0x59, 0x76, 0x8c }, { 0x53, 0x6f, 0x8a }, //0x17 - { 0x77, 0x94, 0x99 }, { 0x71, 0x8d, 0x96 }, { 0x6b, 0x87, 0x94 }, { 0x65, 0x81, 0x91 }, { 0x5f, 0x7b, 0x8f }, { 0x59, 0x75, 0x8c }, { 0x53, 0x6f, 0x8a }, //0x18 - { 0x73, 0x90, 0x97 }, { 0x6d, 0x8a, 0x94 }, { 0x68, 0x85, 0x92 }, { 0x63, 0x7f, 0x90 }, { 0x5d, 0x7a, 0x8e }, { 0x58, 0x74, 0x8c }, { 0x53, 0x6f, 0x8a }, //0x19 - { 0x6e, 0x8b, 0x95 }, { 0x69, 0x86, 0x93 }, { 0x65, 0x81, 0x91 }, { 0x60, 0x7d, 0x8f }, { 0x5c, 0x78, 0x8d }, { 0x57, 0x73, 0x8b }, { 0x53, 0x6f, 0x8a }, //0x1a - { 0x6a, 0x86, 0x93 }, { 0x66, 0x82, 0x91 }, { 0x62, 0x7e, 0x90 }, { 0x5e, 0x7a, 0x8e }, { 0x5a, 0x76, 0x8d }, { 0x56, 0x72, 0x8b }, { 0x53, 0x6f, 0x8a }, //0x1b - { 0x65, 0x82, 0x91 }, { 0x62, 0x7e, 0x8f }, { 0x5f, 0x7b, 0x8e }, { 0x5c, 0x78, 0x8d }, { 0x59, 0x75, 0x8c }, { 0x56, 0x72, 0x8b }, { 0x53, 0x6f, 0x8a }, //0x1c - { 0x61, 0x7d, 0x8f }, { 0x5e, 0x7a, 0x8e }, { 0x5c, 0x78, 0x8d }, { 0x5a, 0x76, 0x8c }, { 0x57, 0x73, 0x8b }, { 0x55, 0x71, 0x8a }, { 0x53, 0x6f, 0x8a }, //0x1d - { 0x5c, 0x78, 0x8d }, { 0x5a, 0x76, 0x8c }, { 0x59, 0x75, 0x8c }, { 0x57, 0x73, 0x8b }, { 0x56, 0x72, 0x8b }, { 0x54, 0x70, 0x8a }, { 0x53, 0x6f, 0x8a }, //0x1e - { 0x57, 0x74, 0x8c }, { 0x56, 0x73, 0x8b }, { 0x55, 0x72, 0x8b }, { 0x55, 0x71, 0x8b }, { 0x54, 0x70, 0x8a }, { 0x53, 0x6f, 0x8a }, { 0x53, 0x6f, 0x8a } //0x1f -}; - -static const unsigned short ti85_palette[32][7] = -{ - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }, - { 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d }, - { 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14 }, - { 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b }, - { 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22 }, - { 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29 }, - { 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30 }, - { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }, - { 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e }, - { 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45 }, - { 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c }, - { 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53 }, - { 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a }, - { 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61 }, - { 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68 }, - { 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f }, - { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76 }, - { 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d }, - { 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84 }, - { 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b }, - { 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92 }, - { 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 }, - { 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0 }, - { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7 }, - { 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae }, - { 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5 }, - { 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc }, - { 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3 }, - { 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca }, - { 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1 }, - { 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 }, - { 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf } -}; - -PALETTE_INIT_MEMBER(ti85_state, ti85) -{ - UINT8 i, j, r, g, b; - - for ( i = 0; i < 224; i++ ) - { - r = ti85_colors[i][0]; g = ti85_colors[i][1]; b = ti85_colors[i][2]; - palette.set_indirect_color(i, rgb_t(r, g, b)); - } - - for (i=0; i < 32; i++) - for (j=0; j < 7; j++) - palette.set_pen_indirect(i*7+j, ti85_palette[i][j]); - - if (!strncmp(machine().system().name, "ti81", 4)) - { - m_ti_video_memory_size = TI81_VIDEO_MEMORY_SIZE; - m_ti_screen_x_size = TI81_SCREEN_X_SIZE; - m_ti_screen_y_size = TI81_SCREEN_Y_SIZE; - m_ti_number_of_frames = TI81_NUMBER_OF_FRAMES; - } - else if (!strncmp(machine().system().name, "ti85", 4)) - { - m_ti_video_memory_size = TI85_VIDEO_MEMORY_SIZE; - m_ti_screen_x_size = TI85_SCREEN_X_SIZE; - m_ti_screen_y_size = TI85_SCREEN_Y_SIZE; - m_ti_number_of_frames = TI85_NUMBER_OF_FRAMES; - } - else if (!strncmp(machine().system().name, "ti86", 4)) - { - m_ti_video_memory_size = TI86_VIDEO_MEMORY_SIZE; - m_ti_screen_x_size = TI86_SCREEN_X_SIZE; - m_ti_screen_y_size = TI86_SCREEN_Y_SIZE; - m_ti_number_of_frames = TI86_NUMBER_OF_FRAMES; - } - else - { - /* don't allocate memory for the others drivers */ - return; - } - - m_frames = auto_alloc_array_clear(machine(), UINT8, m_ti_number_of_frames*m_ti_video_memory_size); -} - -void ti85_state::video_start() -{ -} - -UINT32 ti85_state::screen_update_ti85(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - int x,y,b; - int brightnes; - int lcdmem; - - if (!m_LCD_status || !m_timer_interrupt_mask) - { - for (y=0; y>(7-b)) & 0x01) - + ((*(m_frames+1*m_ti_video_memory_size+y*m_ti_screen_x_size+x)>>(7-b)) & 0x01) - + ((*(m_frames+2*m_ti_video_memory_size+y*m_ti_screen_x_size+x)>>(7-b)) & 0x01) - + ((*(m_frames+3*m_ti_video_memory_size+y*m_ti_screen_x_size+x)>>(7-b)) & 0x01) - + ((*(m_frames+4*m_ti_video_memory_size+y*m_ti_screen_x_size+x)>>(7-b)) & 0x01) - + ((*(m_frames+5*m_ti_video_memory_size+y*m_ti_screen_x_size+x)>>(7-b)) & 0x01); - - bitmap.pix16(y, x*8+b) = ti85_palette[m_LCD_contrast&0x1f][brightnes]; - } - return 0; -} - -PALETTE_INIT_MEMBER(ti85_state,ti82) -{ - palette.set_pen_color(0, rgb_t(160, 190, 170)); - palette.set_pen_color(1, rgb_t(83, 111, 138)); -} diff --git a/src/mess/video/timex.c b/src/mess/video/timex.c deleted file mode 100644 index 6b7bd460366..00000000000 --- a/src/mess/video/timex.c +++ /dev/null @@ -1,270 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker -/*************************************************************************** - - timex.c - - Functions to emulate the video hardware of the Timex ZX Spectrum clones. - - Changes: - - DJR 08/02/00 - Added support for FLASH 1. - DJR 16/05/00 - Support for TS2068/TC2048 hires and 64 column modes. - DJR 19/05/00 - Speeded up Spectrum 128 screen refresh. - DJR 23/05/00 - Preliminary support for border colour emulation. - -***************************************************************************/ - -#include "emu.h" -#include "includes/spectrum.h" -#include "machine/ram.h" - -inline void spectrum_state::spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = (UINT16)color; -} - -/* Update FLASH status for ts2068. Assumes flash update every 1/2s. */ -VIDEO_START_MEMBER(spectrum_state,ts2068) -{ - VIDEO_START_CALL_MEMBER( spectrum ); - m_frame_invert_count = 30; -} - -void spectrum_state::screen_eof_timex(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - spectrum_UpdateBorderBitmap(); - - m_frame_number++; - - if (m_frame_number >= m_frame_invert_count) - { - m_frame_number = 0; - m_flash_invert = !m_flash_invert; - } - } -} - - -/******************************************************************* - * - * Update the TS2068 display. - * - * Port ff is used to set the display mode. - * - * bits 2..0 Video Mode Select - * 000 = Primary DFILE active (at 0x4000-0x5aff) - * 001 = Secondary DFILE active (at 0x6000-0x7aff) - * 010 = Extended Colour Mode (chars at 0x4000-0x57ff, colors 0x6000-0x7aff) - * 110 = 64 column mode (columns 0,2,4,...62 from DFILE 1 - * columns 1,3,5,...63 from DFILE 2) - * other = unpredictable results - * - * bits 5..3 64 column mode ink/paper selection (attribute value in brackets) - * 000 = Black/White (56) 100 = Green/Magenta (28) - * 001 = Blue/Yellow (49) 101 = Cyan/Red (21) - * 010 = Red/Cyan (42) 110 = Yellow/Blue (14) - * 011 = Magenta/Green (35) 111 = White/Black (7) - * - *******************************************************************/ - -/* Draw a scanline in TS2068/TC2048 hires mode (code modified from COUPE.C) */ -void spectrum_state::ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int borderlines) -{ - int x,b,scrx,scry; - unsigned short ink,pap; - unsigned char *attr, *scr; - - scrx=TS2068_LEFT_BORDER; - scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); - - scr=m_ram->pointer() + y*32; - attr=scr + 0x2000; - - for (x=0;x<32;x++) - { - /* Get ink and paper colour with bright */ - if (m_flash_invert && (*attr & 0x80)) - { - ink=((*attr)>>3) & 0x0f; - pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - } - else - { - ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - pap=((*attr)>>3) & 0x0f; - } - - for (b=0x80;b!=0;b>>=1) - { - if (*scr&b) - { - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); - } - else - { - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); - } - } - scr++; - attr++; - } -} - -/* Draw a scanline in TS2068/TC2048 64-column mode */ -void spectrum_state::ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int borderlines, unsigned short inkcolor) -{ - int x,b,scrx,scry; - unsigned char *scr1, *scr2; - - scrx=TS2068_LEFT_BORDER; - scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); - - scr1=m_ram->pointer() + y*32; - scr2=scr1 + 0x2000; - - for (x=0;x<32;x++) - { - for (b=0x80;b!=0;b>>=1) - { - if (*scr1&b) - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); - else - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); - } - scr1++; - - for (b=0x80;b!=0;b>>=1) - { - if (*scr2&b) - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); - else - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); - } - scr2++; - } -} - -/* Draw a scanline in TS2068/TC2048 lores (normal Spectrum) mode */ -void spectrum_state::ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int borderlines, int screen) -{ - int x,b,scrx,scry; - unsigned short ink,pap; - unsigned char *attr, *scr; - - scrx=TS2068_LEFT_BORDER; - scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); - - scr = m_ram->pointer() + y*32 + screen*0x2000; - attr = m_ram->pointer() + ((scry>>3)*32) + screen*0x2000 + 0x1800; - - for (x=0;x<32;x++) - { - /* Get ink and paper colour with bright */ - if (m_flash_invert && (*attr & 0x80)) - { - ink=((*attr)>>3) & 0x0f; - pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - } - else - { - ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); - pap=((*attr)>>3) & 0x0f; - } - - for (b=0x80;b!=0;b>>=1) - { - if (*scr&b) - { - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); - } - else - { - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); - spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); - } - } - scr++; - attr++; - } -} - -UINT32 spectrum_state::screen_update_ts2068(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - /* for now TS2068 will do a full-refresh */ - int count; - - if (m_border_bitmap.valid()) - copyscrollbitmap(bitmap, m_border_bitmap, 0, 0, 0, 0, cliprect); - - if ((m_port_ff_data & 7) == 6) - { - /* 64 Column mode */ - unsigned short inkcolor = (m_port_ff_data & 0x38) >> 3; - for (count = 0; count < 192; count++) - ts2068_64col_scanline(bitmap, count, TS2068_TOP_BORDER, inkcolor); - } - else if ((m_port_ff_data & 7) == 2) - { - /* Extended Color mode */ - for (count = 0; count < 192; count++) - ts2068_hires_scanline(bitmap, count, TS2068_TOP_BORDER); - } - else if ((m_port_ff_data & 7) == 1) - { - /* Screen 6000-7aff */ - for (count = 0; count < 192; count++) - ts2068_lores_scanline(bitmap, count, TS2068_TOP_BORDER, 1); - } - else - { - /* Screen 4000-5aff */ - for (count = 0; count < 192; count++) - ts2068_lores_scanline(bitmap, count, TS2068_TOP_BORDER, 0); - } - - return 0; -} - -UINT32 spectrum_state::screen_update_tc2048(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - /* for now TS2068 will do a full-refresh */ - int count; - - if (m_border_bitmap.valid()) - copyscrollbitmap(bitmap, m_border_bitmap, 0, 0, 0, 0, cliprect); - - if ((m_port_ff_data & 7) == 6) - { - /* 64 Column mode */ - unsigned short inkcolor = (m_port_ff_data & 0x38) >> 3; - for (count = 0; count < 192; count++) - ts2068_64col_scanline(bitmap, count, SPEC_TOP_BORDER, inkcolor); - } - else if ((m_port_ff_data & 7) == 2) - { - /* Extended Color mode */ - for (count = 0; count < 192; count++) - ts2068_hires_scanline(bitmap, count, SPEC_TOP_BORDER); - } - else if ((m_port_ff_data & 7) == 1) - { - /* Screen 6000-7aff */ - for (count = 0; count < 192; count++) - ts2068_lores_scanline(bitmap, count, SPEC_TOP_BORDER, 1); - } - else - { - /* Screen 4000-5aff */ - for (count = 0; count < 192; count++) - ts2068_lores_scanline(bitmap, count, SPEC_TOP_BORDER, 0); - } - - return 0; -} diff --git a/src/mess/video/tmc1800.c b/src/mess/video/tmc1800.c deleted file mode 100644 index 57aef139bef..00000000000 --- a/src/mess/video/tmc1800.c +++ /dev/null @@ -1,70 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "emu.h" -#include "includes/tmc1800.h" -#include "cpu/cosmac/cosmac.h" -#include "video/cdp1861.h" -#include "sound/cdp1864.h" -#include "machine/rescap.h" - -/* Telmac 2000 */ - -READ_LINE_MEMBER( tmc2000_state::rdata_r ) -{ - return BIT(m_color, 2); -} - -READ_LINE_MEMBER( tmc2000_state::bdata_r ) -{ - return BIT(m_color, 1); -} - -READ_LINE_MEMBER( tmc2000_state::gdata_r ) -{ - return BIT(m_color, 0); -} - -/* OSM-200 */ - -UINT32 osc1000b_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - return 0; -} - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( tmc1800_video ) - MCFG_DEVICE_ADD(CDP1861_TAG, CDP1861, XTAL_1_75MHz) - MCFG_CDP1861_IRQ_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT)) - MCFG_CDP1861_DMA_OUT_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT)) - MCFG_CDP1861_EFX_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1)) - MCFG_CDP1861_SCREEN_ADD(CDP1861_TAG, SCREEN_TAG, XTAL_1_75MHz) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( osc1000b_video ) - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DRIVER(osc1000b_state, screen_update) - MCFG_SCREEN_REFRESH_RATE(50) - MCFG_SCREEN_SIZE(320, 200) - MCFG_SCREEN_VISIBLE_AREA(0, 319, 0, 199) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( tmc2000_video ) - MCFG_CDP1864_SCREEN_ADD(SCREEN_TAG, XTAL_1_75MHz) - MCFG_SCREEN_UPDATE_DEVICE(CDP1864_TAG, cdp1864_device, screen_update) - - MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_CDP1864_ADD(CDP1864_TAG, SCREEN_TAG, XTAL_1_75MHz, GND, INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1), NULL, READLINE(tmc2000_state, rdata_r), READLINE(tmc2000_state, bdata_r), READLINE(tmc2000_state, gdata_r)) - MCFG_CDP1864_CHROMINANCE(RES_K(1.21), RES_K(2.05), RES_K(2.26), RES_K(3.92)) // RL64, RL63, RL61, RL65 (also RH62 (2K pot) in series, but ignored here) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END - -MACHINE_CONFIG_FRAGMENT( nano_video ) - MCFG_CDP1864_SCREEN_ADD(SCREEN_TAG, XTAL_1_75MHz) - MCFG_SCREEN_UPDATE_DEVICE(CDP1864_TAG, cdp1864_device, screen_update) - - MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_CDP1864_ADD(CDP1864_TAG, SCREEN_TAG, XTAL_1_75MHz, GND, INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT), INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1), NULL, VCC, VCC, VCC) - MCFG_CDP1864_CHROMINANCE(RES_K(1.21), RES_INF, RES_INF, 0) // R18 (unconfirmed) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END diff --git a/src/mess/video/tmc600.c b/src/mess/video/tmc600.c deleted file mode 100644 index f36568af698..00000000000 --- a/src/mess/video/tmc600.c +++ /dev/null @@ -1,141 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "emu.h" -#include "sound/cdp1869.h" -#include "includes/tmc600.h" - -WRITE8_MEMBER( tmc600_state::vismac_register_w ) -{ - m_vismac_reg_latch = data; -} - -WRITE8_MEMBER( tmc600_state::vismac_data_w ) -{ - UINT16 ma = m_maincpu->get_memory_address(); - - switch (m_vismac_reg_latch) - { - case 0x20: - // character color latch - m_vismac_color_latch = data; - break; - - case 0x30: - // background color latch - m_vismac_bkg_latch = data & 0x07; - - m_vis->out3_w(space, ma, data); - break; - - case 0x40: - m_vis->out4_w(space, ma, data); - break; - - case 0x50: - m_vis->out5_w(space, ma, data); - break; - - case 0x60: - m_vis->out6_w(space, ma, data); - break; - - case 0x70: - m_vis->out7_w(space, ma, data); - break; - } -} - -TIMER_DEVICE_CALLBACK_MEMBER(tmc600_state::blink_tick) -{ - m_blink = !m_blink; -} - -UINT8 tmc600_state::get_color(UINT16 pma) -{ - UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK; - UINT8 color = m_color_ram[pageaddr]; - - if (BIT(color, 3) && m_blink) - { - color = m_vismac_bkg_latch; - } - - return color; -} - -WRITE8_MEMBER( tmc600_state::page_ram_w ) -{ - m_page_ram[offset] = data; - m_color_ram[offset] = m_vismac_color_latch; -} - -static ADDRESS_MAP_START( cdp1869_page_ram, AS_0, 8, tmc600_state ) - AM_RANGE(0x000, 0x3ff) AM_MIRROR(0x400) AM_RAM AM_SHARE("page_ram") AM_WRITE(page_ram_w) -ADDRESS_MAP_END - -CDP1869_CHAR_RAM_READ_MEMBER( tmc600_state::tmc600_char_ram_r ) -{ - UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK; - UINT8 color = get_color(pageaddr); - UINT16 charaddr = ((cma & 0x08) << 8) | (pmd << 3) | (cma & 0x07); - UINT8 cdb = m_char_rom[charaddr] & 0x3f; - - int ccb0 = BIT(color, 2); - int ccb1 = BIT(color, 1); - - return (ccb1 << 7) | (ccb0 << 6) | cdb; -} - -CDP1869_PCB_READ_MEMBER( tmc600_state::tmc600_pcb_r ) -{ - UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK; - UINT8 color = get_color(pageaddr); - - return BIT(color, 0); -} - -void tmc600_state::video_start() -{ - // allocate memory - m_color_ram.allocate(TMC600_PAGE_RAM_SIZE); - - // register for state saving - save_item(NAME(m_vismac_reg_latch)); - save_item(NAME(m_vismac_color_latch)); - save_item(NAME(m_vismac_bkg_latch)); - save_item(NAME(m_blink)); -} - -static const gfx_layout tmc600_charlayout = -{ - 6, 9, // 6 x 9 characters - 256, // 256 characters - 1, // 1 bits per pixel - { 0 }, // no bitplanes - // x offsets - { 2, 3, 4, 5, 6, 7 }, - // y offsets - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 2048*8 }, - 8*8 // every char takes 8 x 8 bytes -}; - -static GFXDECODE_START( tmc600 ) - GFXDECODE_ENTRY( "chargen", 0x0000, tmc600_charlayout, 0, 36 ) -GFXDECODE_END - -MACHINE_CONFIG_FRAGMENT( tmc600_video ) - // video hardware - MCFG_CDP1869_SCREEN_PAL_ADD(CDP1869_TAG, SCREEN_TAG, CDP1869_DOT_CLK_PAL) - MCFG_TIMER_DRIVER_ADD_PERIODIC("blink", tmc600_state, blink_tick, attotime::from_hz(2)) - - MCFG_GFXDECODE_ADD("gfxdecode", CDP1869_TAG":palette", tmc600) - - // sound hardware - MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, cdp1869_page_ram) - MCFG_CDP1869_COLOR_CLOCK(CDP1869_COLOR_CLK_PAL) - MCFG_CDP1869_CHAR_PCB_READ_OWNER(tmc600_state, tmc600_pcb_r) - MCFG_CDP1869_CHAR_RAM_READ_OWNER(tmc600_state, tmc600_char_ram_r) - MCFG_CDP1869_PAL_NTSC_CALLBACK(VCC) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) -MACHINE_CONFIG_END diff --git a/src/mess/video/trs80.c b/src/mess/video/trs80.c deleted file mode 100644 index beb34edc691..00000000000 --- a/src/mess/video/trs80.c +++ /dev/null @@ -1,588 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert and unknown others -/*************************************************************************** - - trs80.c - - Functions to emulate the video hardware of the TRS80. - -***************************************************************************/ - -#include "includes/trs80.h" - -/* Bit assignment for "state->m_mode" - d7 Page select - d6 LNW80 switch to graphics ram - d5 LNW80 colour or monochrome (1=colour) - d4 LNW80 lores or hires (1=hires) also does 64 or 80 chars per line - d3 LNW80 invert entire screen / Model III/4 Invert characters with bit 7 set (1=invert) - d2 80/40 or 64/32 characters per line (1=80) - d1 7 or 8 bit video (1=requires 7-bit, 0=don't care) - d0 80/64 or 40/32 characters per line (1=32) */ - - -WRITE8_MEMBER( trs80_state::trs80m4_88_w ) -{ -/* This is for the programming of the CRTC registers. - However this CRTC is mask-programmed, and only the - start address register can be used. The cursor and - light-pen facilities are ignored. The character clock - is changed depending on the screen size chosen. - Therefore it is easier to use normal - coding rather than the mc6845 device. */ - - if (!offset) m_crtc_reg = data & 0x1f; - - if (offset) switch (m_crtc_reg) - { - case 12: - m_start_address = (m_start_address & 0x00ff) | (data << 8); - break; - case 13: - m_start_address = (m_start_address & 0xff00) | data; - } -} - - -void trs80_state::video_start() -{ - m_p_chargen = memregion("chargen")->base(); - m_size_store = 0xff; - m_mode &= 2; -} - - -/* 7 or 8-bit video, 32/64 characters per line = trs80, trs80l2, sys80 */ -UINT32 trs80_state::screen_update_trs80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx,gfxbit; - UINT16 sy=0,ma=0,x; - UINT8 cols = BIT(m_mode, 0) ? 32 : 64; - UINT8 skip = BIT(m_mode, 0) ? 2 : 1; - - if (m_mode != m_size_store) - { - m_size_store = m_mode & 1; - screen.set_visible_area(0, cols*6-1, 0, 16*12-1); - } - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 12; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x+=skip) - { - chr = m_p_videoram[x]; - - if (chr & 0x80) - { - gfxbit = (ra & 0x0c)>>1; - /* Display one line of a lores character (6 pixels) */ - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - gfxbit++; - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - } - else - { - if (BIT(m_mode, 1) & (chr < 32)) chr+=64; - - // if g,j,p,q,y; lower the descender - if ((chr==0x2c)||(chr==0x3b)||(chr==0x67)||(chr==0x6a)||(chr==0x70)||(chr==0x71)||(chr==0x79)) - { - if ((ra < 10) && (ra > 1)) - gfx = m_p_chargen[(chr<<3) | (ra-2) ]; - else - gfx = 0; - } - else - { - if (ra < 8) - gfx = m_p_chargen[(chr<<3) | ra ]; - else - gfx = 0; - } - - /* Display a scanline of a character (6 pixels) */ - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - } - ma+=64; - } - return 0; -} - -/* 8-bit video, 32/64/40/80 characters per line = trs80m3, trs80m4. */ -UINT32 trs80_state::screen_update_trs80m4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx,gfxbit; - UINT16 sy=0,ma=0,x; - UINT8 skip=1; - UINT8 cols = BIT(m_mode, 2) ? 80 : 64; - UINT8 rows = BIT(m_mode, 2) ? 24 : 16; - UINT8 lines = BIT(m_mode, 2) ? 10 : 12; - UINT8 s_cols = cols; - UINT8 mask = BIT(m_mode, 5) ? 0xff : 0xbf; /* Select Japanese or extended chars */ - - if (m_mode & 1) - { - s_cols >>= 1; - skip = 2; - } - - if ((m_mode & 0x7f) != m_size_store) - { - m_size_store = m_mode & 5; - screen.set_visible_area(0, s_cols*8-1, 0, rows*lines-1); - } - - for (y = 0; y < rows; y++) - { - for (ra = 0; ra < lines; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + cols; x+=skip) - { - chr = m_p_videoram[x+m_start_address]; - - if (((chr & 0xc0) == 0xc0) && (~m_mode & 8)) - { - if (ra < 8) - gfx = m_p_chargen[((chr&mask)<<3) | ra ]; - else - gfx = 0; - - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - else - if ((chr & 0x80) && (~m_mode & 8)) - { - gfxbit = (ra & 0x0c)>>1; - /* Display one line of a lores character */ - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - gfxbit++; - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - } - else - { - /* get pattern of pixels for that character scanline */ - if (ra < 8) - gfx = m_p_chargen[((chr&0x7f)<<3) | ra ]; - else - gfx = 0; - - /* if inverse mode, and bit 7 set, invert gfx */ - if (BIT(m_mode, 3) & BIT(chr, 7)) - gfx ^= 0xff; - - /* Display a scanline of a character */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - } - ma+=cols; - } - return 0; -} - -/* 7 or 8-bit video, 64/32 characters per line = ht1080z, ht1080z2, ht108064 */ -UINT32 trs80_state::screen_update_ht1080z(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx,gfxbit; - UINT16 sy=0,ma=0,x; - UINT8 cols = BIT(m_mode, 0) ? 32 : 64; - UINT8 skip = BIT(m_mode, 0) ? 2 : 1; - - if (m_mode != m_size_store) - { - m_size_store = m_mode & 1; - screen.set_visible_area(0, cols*6-1, 0, 16*12-1); - } - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 12; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x+=skip) - { - chr = m_p_videoram[x]; - - if (chr & 0x80) - { - gfxbit = (ra & 0x0c)>>1; - /* Display one line of a lores character (6 pixels) */ - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - gfxbit++; - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - *p++ = BIT(chr, gfxbit); - } - else - { - if ((m_mode & 2) && (chr < 32)) chr+=64; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<4) | ra ]; - - /* Display a scanline of a character (6 pixels) */ - *p++ = BIT(gfx, 7); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = 0; /* fix for ht108064 */ - } - } - } - ma+=64; - } - return 0; -} - -/* 8-bit video, 64/80 characters per line = lnw80 */ -UINT32 trs80_state::screen_update_lnw80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - static const UINT16 rows[] = { 0, 0x200, 0x100, 0x300, 1, 0x201, 0x101, 0x301 }; - UINT8 chr,gfx,gfxbit,bg=7,fg=0; - UINT16 sy=0,ma=0,x,y,ra; - UINT8 cols = BIT(m_mode, 4) ? 80 : 64; - - /* Although the OS can select 32-character mode, it is not supported by hardware */ - if (m_mode != m_size_store) - { - m_size_store = m_mode & 0x10; - screen.set_visible_area(0, cols*6-1, 0, 16*12-1); - } - - if (m_mode & 8) - { - bg = 0; - fg = 7; - } - - switch (m_mode & 0x30) - { - case 0: // MODE 0 - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 12; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x++) - { - chr = m_p_videoram[x]; - - if (chr & 0x80) - { - gfxbit = (ra & 0x0c)>>1; - /* Display one line of a lores character (6 pixels) */ - *p++ = BIT(chr, gfxbit) ? fg : bg; - *p++ = BIT(chr, gfxbit) ? fg : bg; - *p++ = BIT(chr, gfxbit) ? fg : bg; - gfxbit++; - *p++ = BIT(chr, gfxbit) ? fg : bg; - *p++ = BIT(chr, gfxbit) ? fg : bg; - *p++ = BIT(chr, gfxbit) ? fg : bg; - } - else - { - /* get pattern of pixels for that character scanline */ - if (ra < 8) - gfx = m_p_chargen[(chr<<1) | rows[ra] ]; - else - gfx = 0; - - /* Display a scanline of a character (6 pixels) */ - *p++ = BIT(gfx, 2) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 6) ? fg : bg; - *p++ = BIT(gfx, 7) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - *p++ = BIT(gfx, 3) ? fg : bg; - } - } - } - ma+=64; - } - break; - - case 0x10: // MODE 1 - for (y = 0; y < 0x400; y+=0x40) - { - for (ra = 0; ra < 0x3000; ra+=0x400) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 0x40; x++) - { - gfx = m_p_gfxram[ y | x | ra]; - /* Display 6 pixels in normal region */ - *p++ = BIT(gfx, 0) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 2) ? fg : bg; - *p++ = BIT(gfx, 3) ? fg : bg; - *p++ = BIT(gfx, 4) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - } - - for (x = 0; x < 0x10; x++) - { - gfx = m_p_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; - /* Display 6 pixels in extended region */ - *p++ = BIT(gfx, 0) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 2) ? fg : bg; - *p++ = BIT(gfx, 3) ? fg : bg; - *p++ = BIT(gfx, 4) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - } - } - } - break; - - case 0x20: // MODE 2 - /* it seems the text video ram can have an effect in this mode, - not explained clearly, so not emulated */ - for (y = 0; y < 0x400; y+=0x40) - { - for (ra = 0; ra < 0x3000; ra+=0x400) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 0x40; x++) - { - gfx = m_p_gfxram[ y | x | ra]; - /* Display 6 pixels in normal region */ - fg = (gfx & 0x38) >> 3; - *p++ = fg; - *p++ = fg; - *p++ = fg; - fg = gfx & 0x07; - *p++ = fg; - *p++ = fg; - *p++ = fg; - } - } - } - break; - - case 0x30: // MODE 3 - /* the manual does not explain at all how colour is determined - for the extended area. Further, the background colour - is not mentioned anywhere. Black is assumed. */ - for (y = 0; y < 0x400; y+=0x40) - { - for (ra = 0; ra < 0x3000; ra+=0x400) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = 0; x < 0x40; x++) - { - gfx = m_p_gfxram[ y | x | ra]; - fg = (m_p_videoram[ 0x3c00 | x | y ] & 0x38) >> 3; - /* Display 6 pixels in normal region */ - *p++ = BIT(gfx, 0) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 2) ? fg : bg; - fg = m_p_videoram[ 0x3c00 | x | y ] & 0x07; - *p++ = BIT(gfx, 3) ? fg : bg; - *p++ = BIT(gfx, 4) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - } - - for (x = 0; x < 0x10; x++) - { - gfx = m_p_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; - fg = (m_p_gfxram[ 0x3c00 | x | y ] & 0x38) >> 3; - /* Display 6 pixels in extended region */ - *p++ = BIT(gfx, 0) ? fg : bg; - *p++ = BIT(gfx, 1) ? fg : bg; - *p++ = BIT(gfx, 2) ? fg : bg; - fg = m_p_gfxram[ 0x3c00 | x | y ] & 0x07; - *p++ = BIT(gfx, 3) ? fg : bg; - *p++ = BIT(gfx, 4) ? fg : bg; - *p++ = BIT(gfx, 5) ? fg : bg; - } - } - } - break; - } - return 0; -} - -/* lores characters are in the character generator. Each character is 8x16. */ -UINT32 trs80_state::screen_update_radionic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 y,ra,chr,gfx; - UINT16 sy=0,ma=0,x; - UINT8 cols = BIT(m_mode, 0) ? 32 : 64; - UINT8 skip = BIT(m_mode, 0) ? 2 : 1; - - if (m_mode != m_size_store) - { - m_size_store = m_mode & 1; - screen.set_visible_area(0, cols*8-1, 0, 16*16-1); - } - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 16; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x+=skip) - { - chr = m_p_videoram[x]; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<3) | (ra & 7) | (ra & 8) << 8]; - - /* Display a scanline of a character (8 pixels) */ - *p++ = BIT(gfx, 0); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 6); - *p++ = BIT(gfx, 7); - } - } - ma+=64; - } - return 0; -} - -UINT32 trs80_state::screen_update_meritum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -/* lores characters are in the character generator. Each character is 6x11. */ -{ - UINT8 y,ra,chr,gfx; - UINT16 sy=0,ma=0,x; - UINT8 cols = BIT(m_mode, 0) ? 32 : 64; - UINT8 skip = BIT(m_mode, 0) ? 2 : 1; - - if (m_mode != m_size_store) - { - m_size_store = m_mode; - screen.set_visible_area(0, cols*6-1, 0, 16*11-1); - } - - for (y = 0; y < 16; y++) - { - for (ra = 0; ra < 11; ra++) - { - UINT16 *p = &bitmap.pix16(sy++); - - for (x = ma; x < ma + 64; x+=skip) - { - chr = m_p_videoram[x]; - - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<4) | ra]; - - /* Display a scanline of a character (6 pixels) */ - *p++ = BIT(gfx, 5); - *p++ = BIT(gfx, 4); - *p++ = BIT(gfx, 3); - *p++ = BIT(gfx, 2); - *p++ = BIT(gfx, 1); - *p++ = BIT(gfx, 0); - } - } - ma+=64; - } - return 0; -} - - - -/*************************************************************************** - Write to video ram -***************************************************************************/ - -READ8_MEMBER( trs80_state::trs80_videoram_r ) -{ - if ((m_mode & 0x80) && (~m_model4 & 1)) offset |= 0x400; - return m_p_videoram[offset]; -} - -WRITE8_MEMBER( trs80_state::trs80_videoram_w ) -{ - if ((m_mode & 0x80) && (~m_model4 & 1)) offset |= 0x400; - m_p_videoram[offset] = data; -} - - -/*************************************************************************** - Write to graphics ram -***************************************************************************/ - -READ8_MEMBER( trs80_state::trs80_gfxram_r ) -{ - return m_p_gfxram[offset]; -} - -WRITE8_MEMBER( trs80_state::trs80_gfxram_w ) -{ - m_p_gfxram[offset] = data; -} - - -/*************************************************************************** - Palettes -***************************************************************************/ - -/* Levels are unknown - guessing */ -static const rgb_t lnw80_palette[] = -{ - rgb_t(220, 220, 220), // white - rgb_t(0, 175, 0), // green - rgb_t(200, 200, 0), // yellow - rgb_t(255, 0, 0), // red - rgb_t(255, 0, 255), // magenta - rgb_t(0, 0, 175), // blue - rgb_t(0, 255, 255), // cyan - rgb_t(0, 0, 0), // black -}; - -PALETTE_INIT_MEMBER(trs80_state,lnw80) -{ - palette.set_pen_colors(0, lnw80_palette, ARRAY_LENGTH(lnw80_palette)); -} diff --git a/src/mess/video/tx0.c b/src/mess/video/tx0.c deleted file mode 100644 index 35e105107e7..00000000000 --- a/src/mess/video/tx0.c +++ /dev/null @@ -1,469 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Raphael Nabet -/* - TX-0 - - Raphael Nabet, 2004 -*/ - -#include "emu.h" - -#include "cpu/pdp1/tx0.h" -#include "includes/tx0.h" -#include "video/crt.h" - - - - -inline void tx0_state::tx0_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix16(y, x) = color; -} - -/* - video init -*/ -void tx0_state::video_start() -{ - m_typewriter_color = color_typewriter_black; - - /* alloc bitmaps for our private fun */ - m_panel_bitmap.allocate(panel_window_width, panel_window_height, BITMAP_FORMAT_IND16); - m_typewriter_bitmap.allocate(typewriter_window_width, typewriter_window_height, BITMAP_FORMAT_IND16); - - /* set up out bitmaps */ - tx0_draw_panel_backdrop(m_panel_bitmap); - - const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1); - m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds); -} - - -void tx0_state::screen_eof_tx0(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - m_crt->eof(); - } -} - - -/* - schedule a pixel to be plotted -*/ -void tx0_state::tx0_plot(int x, int y) -{ - /* compute pixel coordinates and plot */ - x = x*crt_window_width/0777; - y = y*crt_window_height/0777; - m_crt->plot(x, y); -} - - -/* - screen_update_tx0: effectively redraw the screen -*/ -UINT32 tx0_state::screen_update_tx0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_crt->update(bitmap); - - tx0_draw_panel(m_panel_bitmap); - copybitmap(bitmap, m_panel_bitmap, 0, 0, panel_window_offset_x, panel_window_offset_y, cliprect); - - copybitmap(bitmap, m_typewriter_bitmap, 0, 0, typewriter_window_offset_x, typewriter_window_offset_y, cliprect); - return 0; -} - - - -/* - Operator control panel code -*/ - -enum -{ - x_panel_col1a_offset = 0, - x_panel_col1b_offset = 24, - x_panel_col2_offset = x_panel_col1a_offset+184+8 -}; - -enum -{ - /* column 1: registers, test accumulator, test buffer, toggle switch storage */ - y_panel_pc_offset = 0, - y_panel_mar_offset = y_panel_pc_offset+2*8, - y_panel_mbr_offset = y_panel_mar_offset+2*8, - y_panel_ac_offset = y_panel_mbr_offset+2*8, - y_panel_lr_offset = y_panel_ac_offset+2*8, - y_panel_xr_offset = y_panel_lr_offset+2*8, - y_panel_tbr_offset = y_panel_xr_offset+2*8, - y_panel_tac_offset = y_panel_tbr_offset+2*8, - y_panel_tss_offset = y_panel_tac_offset+2*8, - - /* column 2: stop c0, stop c1, cm sel, 1-bit indicators, instr, flags */ - y_panel_stop_c0_offset = 8, - y_panel_stop_c1_offset = y_panel_stop_c0_offset+8, - y_panel_gbl_cm_sel_offset = y_panel_stop_c1_offset+8, - y_panel_run_offset = y_panel_gbl_cm_sel_offset+8, - y_panel_cycle1_offset = y_panel_run_offset+8, - y_panel_cycle2_offset = y_panel_cycle1_offset+8, - y_panel_rim_offset = y_panel_cycle2_offset+8, - y_panel_ioh_offset = y_panel_rim_offset+8, - y_panel_ios_offset = y_panel_ioh_offset+8, - y_panel_ir_offset = y_panel_ios_offset+8, - y_panel_pf_offset = y_panel_ir_offset+2*8 -}; - -/* draw a small 8*8 LED (or is this a lamp? ) */ -void tx0_state::tx0_draw_led(bitmap_ind16 &bitmap, int x, int y, int state) -{ - int xx, yy; - - for (yy=1; yy<7; yy++) - for (xx=1; xx<7; xx++) - tx0_plot_pixel(bitmap, x+xx, y+yy, state ? pen_lit_lamp : pen_unlit_lamp); -} - -/* draw nb_bits leds which represent nb_bits bits in value */ -void tx0_state::tx0_draw_multipleled(bitmap_ind16 &bitmap, int x, int y, int value, int nb_bits) -{ - while (nb_bits) - { - nb_bits--; - - tx0_draw_led(bitmap, x, y, (value >> nb_bits) & 1); - - x += 8; - } -} - - -/* draw a small 8*8 switch */ -void tx0_state::tx0_draw_switch(bitmap_ind16 &bitmap, int x, int y, int state) -{ - int xx, yy; - int i; - - /* erase area */ - for (yy=0; yy<8; yy++) - for (xx=0; xx<8; xx++) - tx0_plot_pixel(bitmap, x+xx, y+yy, pen_panel_bg); - - - /* draw nut (-> circle) */ - for (i=0; i<4;i++) - { - tx0_plot_pixel(bitmap, x+2+i, y+1, pen_switch_nut); - tx0_plot_pixel(bitmap, x+2+i, y+6, pen_switch_nut); - tx0_plot_pixel(bitmap, x+1, y+2+i, pen_switch_nut); - tx0_plot_pixel(bitmap, x+6, y+2+i, pen_switch_nut); - } - tx0_plot_pixel(bitmap, x+2, y+2, pen_switch_nut); - tx0_plot_pixel(bitmap, x+5, y+2, pen_switch_nut); - tx0_plot_pixel(bitmap, x+2, y+5, pen_switch_nut); - tx0_plot_pixel(bitmap, x+5, y+5, pen_switch_nut); - - /* draw button (->disc) */ - if (! state) - y += 4; - for (i=0; i<2;i++) - { - tx0_plot_pixel(bitmap, x+3+i, y, pen_switch_button); - tx0_plot_pixel(bitmap, x+3+i, y+3, pen_switch_button); - } - for (i=0; i<4;i++) - { - tx0_plot_pixel(bitmap, x+2+i, y+1, pen_switch_button); - tx0_plot_pixel(bitmap, x+2+i, y+2, pen_switch_button); - } -} - - -/* draw nb_bits switches which represent nb_bits bits in value */ -void tx0_state::tx0_draw_multipleswitch(bitmap_ind16 &bitmap, int x, int y, int value, int nb_bits) -{ - while (nb_bits) - { - nb_bits--; - - tx0_draw_switch(bitmap, x, y, (value >> nb_bits) & 1); - - x += 8; - } -} - - -/* write a single char on screen */ -void tx0_state::tx0_draw_char(bitmap_ind16 &bitmap, char character, int x, int y, int color) -{ - m_gfxdecode->gfx(0)->transpen(bitmap,bitmap.cliprect(), character-32, color, 0, 0, - x+1, y, 0); -} - -/* write a string on screen */ -void tx0_state::tx0_draw_string(bitmap_ind16 &bitmap, const char *buf, int x, int y, int color) -{ - while (* buf) - { - tx0_draw_char(bitmap, *buf, x, y, color); - - x += 8; - buf++; - } -} - - -/* draw a vertical line */ -void tx0_state::tx0_draw_vline(bitmap_ind16 &bitmap, int x, int y, int height, int color) -{ - while (height--) - tx0_plot_pixel(bitmap, x, y++, color); -} - -#ifdef UNUSED_FUNCTION -/* draw a horizontal line */ -void tx0_state::tx0_draw_hline(bitmap_ind16 &bitmap, int x, int y, int width, int color) -{ - while (width--) - tx0_plot_pixel(bitmap, x++, y, color); -} -#endif - -/* - draw the operator control panel (fixed backdrop) -*/ -void tx0_state::tx0_draw_panel_backdrop(bitmap_ind16 &bitmap) -{ - int i; - char buf[3]; - - /* fill with black */ - const rectangle panel_bitmap_bounds(0, panel_window_width-1, 0, panel_window_height-1); - m_panel_bitmap.fill(pen_panel_bg, panel_bitmap_bounds); - - /* column 1: registers, test accumulator, test buffer, toggle switch storage */ - tx0_draw_string(bitmap, "program counter", x_panel_col1b_offset, y_panel_pc_offset, color_panel_caption); - tx0_draw_string(bitmap, "memory address reg.", x_panel_col1b_offset, y_panel_mar_offset, color_panel_caption); - tx0_draw_string(bitmap, "memory buffer reg.", x_panel_col1b_offset, y_panel_mbr_offset, color_panel_caption); - tx0_draw_string(bitmap, "accumulator", x_panel_col1b_offset, y_panel_ac_offset, color_panel_caption); - tx0_draw_string(bitmap, "live register", x_panel_col1b_offset, y_panel_lr_offset, color_panel_caption); - tx0_draw_string(bitmap, "index register", x_panel_col1b_offset, y_panel_xr_offset, color_panel_caption); - tx0_draw_string(bitmap, "TBR", x_panel_col1b_offset, y_panel_tbr_offset, color_panel_caption); - tx0_draw_string(bitmap, "TAC", x_panel_col1b_offset, y_panel_tac_offset, color_panel_caption); - tx0_draw_string(bitmap, "cm", x_panel_col1a_offset+8, y_panel_tss_offset, color_panel_caption); - tx0_draw_string(bitmap, "TSS", x_panel_col1a_offset+24, y_panel_tss_offset, color_panel_caption); - tx0_draw_string(bitmap, "lr", x_panel_col1a_offset+168, y_panel_tss_offset, color_panel_caption); - for (i=0; i<16; i++) - { - sprintf(buf, "%2o", i); - tx0_draw_string(bitmap, buf, x_panel_col1a_offset, y_panel_tss_offset+8+i*8, color_panel_caption); - } - - /* column separator */ - tx0_draw_vline(bitmap, x_panel_col2_offset-4, 8, 248, pen_panel_caption); - - /* column 2: stop c0, stop c1, cm sel, 1-bit indicators, instr, flags */ - tx0_draw_string(bitmap, "stop c0", x_panel_col2_offset+8, y_panel_stop_c0_offset, color_panel_caption); - tx0_draw_string(bitmap, "stop c1", x_panel_col2_offset+8, y_panel_stop_c1_offset, color_panel_caption); - tx0_draw_string(bitmap, "cm select", x_panel_col2_offset+8, y_panel_gbl_cm_sel_offset, color_panel_caption); - tx0_draw_string(bitmap, "run", x_panel_col2_offset+8, y_panel_run_offset, color_panel_caption); - tx0_draw_string(bitmap, "cycle1", x_panel_col2_offset+8, y_panel_cycle1_offset, color_panel_caption); - tx0_draw_string(bitmap, "cycle2", x_panel_col2_offset+8, y_panel_cycle2_offset, color_panel_caption); - tx0_draw_string(bitmap, "read in", x_panel_col2_offset+8, y_panel_rim_offset, color_panel_caption); - tx0_draw_string(bitmap, "i-o halt", x_panel_col2_offset+8, y_panel_ioh_offset, color_panel_caption); - tx0_draw_string(bitmap, "i-o sync", x_panel_col2_offset+8, y_panel_ios_offset, color_panel_caption); - tx0_draw_string(bitmap, "instr", x_panel_col2_offset+8, y_panel_ir_offset, color_panel_caption); - tx0_draw_string(bitmap, "pgm flags", x_panel_col2_offset+8, y_panel_pf_offset, color_panel_caption); -} - - -/* - draw the operator control panel (dynamic elements) -*/ -void tx0_state::tx0_draw_panel(bitmap_ind16 &bitmap) -{ - int cm_sel, lr_sel; - int i; - - /* column 1: registers, test accumulator, test buffer, toggle switch storage */ - tx0_draw_multipleled(bitmap, x_panel_col1b_offset+2*8, y_panel_pc_offset+8, m_maincpu->state_int(TX0_PC), 16); - tx0_draw_multipleled(bitmap, x_panel_col1b_offset+2*8, y_panel_mar_offset+8, m_maincpu->state_int(TX0_MAR), 16); - tx0_draw_multipleled(bitmap, x_panel_col1b_offset, y_panel_mbr_offset+8, m_maincpu->state_int(TX0_MBR), 18); - tx0_draw_multipleled(bitmap, x_panel_col1b_offset, y_panel_ac_offset+8, m_maincpu->state_int(TX0_AC), 18); - tx0_draw_multipleled(bitmap, x_panel_col1b_offset, y_panel_lr_offset+8, m_maincpu->state_int(TX0_LR), 18); - tx0_draw_multipleled(bitmap, x_panel_col1b_offset+4*8, y_panel_xr_offset+8, m_maincpu->state_int(TX0_XR), 14); - tx0_draw_multipleswitch(bitmap, x_panel_col1b_offset, y_panel_tbr_offset+8, m_maincpu->state_int(TX0_TBR), 18); - tx0_draw_multipleswitch(bitmap, x_panel_col1b_offset, y_panel_tac_offset+8, m_maincpu->state_int(TX0_TAC), 18); - cm_sel = m_maincpu->state_int(TX0_CM_SEL); - lr_sel = m_maincpu->state_int(TX0_LR_SEL); - for (i=0; i<16; i++) - { - tx0_draw_switch(bitmap, x_panel_col1a_offset+16, y_panel_tss_offset+8+i*8, (cm_sel >> i) & 1); - tx0_draw_multipleswitch(bitmap, x_panel_col1a_offset+24, y_panel_tss_offset+8+i*8, m_maincpu->state_int(TX0_TSS00+i), 18); - tx0_draw_switch(bitmap, x_panel_col1a_offset+168, y_panel_tss_offset+8+i*8, (lr_sel >> i) & 1); - } - - /* column 2: stop c0, stop c1, cm sel, 1-bit indicators, instr, flags */ - tx0_draw_switch(bitmap, x_panel_col2_offset, y_panel_stop_c0_offset, m_maincpu->state_int(TX0_STOP_CYC0)); - tx0_draw_switch(bitmap, x_panel_col2_offset, y_panel_stop_c1_offset, m_maincpu->state_int(TX0_STOP_CYC1)); - tx0_draw_switch(bitmap, x_panel_col2_offset, y_panel_gbl_cm_sel_offset, m_maincpu->state_int(TX0_GBL_CM_SEL)); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_run_offset, m_maincpu->state_int(TX0_RUN)); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_cycle1_offset, m_maincpu->state_int(TX0_CYCLE) & 1); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_cycle2_offset, m_maincpu->state_int(TX0_CYCLE) & 2); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_rim_offset, m_maincpu->state_int(TX0_RIM)); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_ioh_offset, m_maincpu->state_int(TX0_IOH)); - tx0_draw_led(bitmap, x_panel_col2_offset, y_panel_ios_offset, m_maincpu->state_int(TX0_IOS)); - tx0_draw_multipleled(bitmap, x_panel_col2_offset, y_panel_ir_offset+8, m_maincpu->state_int(TX0_IR), 5); - tx0_draw_multipleled(bitmap, x_panel_col2_offset, y_panel_pf_offset+8, m_maincpu->state_int(TX0_PF), 6); -} - - - -/* - Typewriter code -*/ - - - - - -enum -{ - typewriter_line_height = 8, - typewriter_write_offset_y = typewriter_window_height-typewriter_line_height, - typewriter_scroll_step = typewriter_line_height -}; - -enum -{ - tab_step = 8 -}; - - -void tx0_state::tx0_typewriter_linefeed() -{ - UINT8 buf[typewriter_window_width]; - int y; - - for (y=0; ypens()); - } - - const rectangle typewriter_scroll_clear_window(0, typewriter_window_width-1, typewriter_window_height-typewriter_scroll_step, typewriter_window_height-1); - m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_scroll_clear_window); -} - -void tx0_state::tx0_typewriter_drawchar(int character) -{ - static const char ascii_table[2][64] = - { - { /* lower case */ - '\0', '\0', 'e', '8', - '\0', '|', 'a', '3', - ' ', '=', 's', '4', - 'i', '+', 'u', '2', - '\0',/*color shift*/'.', 'd', '5', - 'r', '1', 'j', '7', - 'n', ',', 'f', '6', - 'c', '-', 'k', '\0', - 't', '\0', 'z', '\0',/*back space*/ - 'l', '\0',/*tab*/ 'w', '\0', - 'h', '\0',/*carr. return*/'y', '\0', - 'p', '\0', 'q', '\0', - 'o', '\0',/*stop*/ 'b', '\0', - 'g', '\0', '9', '\0', - 'm', '\0',/*upper case*/ 'x', '\0', - 'v', '\0',/*lower case*/ '0', '\0'/*delete*/ - }, - { /* upper case */ - '\0', '\0', 'E', '\210', - '\0', '_', 'A', '\203', - ' ', ':', 'S', '\204', - 'I', '/', 'U', '\202', - '\0',/*color shift*/')', 'D', '\205', - 'R', '\201', 'J', '\207', - 'N', '(', 'F', '\206', - 'C', '\212',/*macron*/ 'K', '\0', - 'T', '\0', 'Z', '\0',/*back space*/ - 'L', '\0',/*tab*/ 'W', '\0', - 'H', '\0',/*carr. return*/'Y', '\0', - 'P', '\0', 'Q', '\0', - 'O', '\0',/*stop*/ 'B', '\0', - 'G', '\0', '\211', '\0', - 'M', '\0',/*upper case*/ 'X', '\0', - 'V', '\0',/*lower case*/ '\200', '\0'/*delete*/ - } - }; - - - - character &= 0x3f; - - switch (character) - { - case 020: -#if 0 - /* color shift */ - m_typewriter_color = color_typewriter_black; - m_typewriter_color = color_typewriter_red; -#endif - break; - - case 043: - /* Backspace */ - if (m_pos) - m_pos--; - break; - - case 045: - /* Tab */ - m_pos = m_pos + tab_step - (m_pos % tab_step); - break; - - case 051: - /* Carriage Return */ - m_pos = 0; - tx0_typewriter_linefeed(); - break; - - case 061: - /* Stop */ - /* ?????? */ - break; - - case 071: - /* Upper case */ - m_case_shift = 1; - break; - - case 075: - /* Lower case */ - m_case_shift = 0; - break; - - case 077: - /* Delete */ - /* ?????? */ - break; - - default: - /* Any printable character... */ - - if (m_pos >= 80) - { /* if past right border, wrap around. (Right???) */ - tx0_typewriter_linefeed(); /* next line */ - m_pos = 0; /* return to start of line */ - } - - /* print character (lookup ASCII equivalent in table) */ - tx0_draw_char(m_typewriter_bitmap, ascii_table[m_case_shift][character], - 8*m_pos, typewriter_write_offset_y, - m_typewriter_color); /* print char */ - - m_pos++; /* step carriage forward */ - break; - } -} diff --git a/src/mess/video/ut88.c b/src/mess/video/ut88.c deleted file mode 100644 index e5fcae9e678..00000000000 --- a/src/mess/video/ut88.c +++ /dev/null @@ -1,44 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - UT88 video driver by Miodrag Milanovic - - 06/03/2008 Preliminary driver. - -****************************************************************************/ - - -#include "includes/ut88.h" - - -const gfx_layout ut88_charlayout = -{ - 8, 8, /* 8x8 characters */ - 256, /* 256 characters */ - 1, /* 1 bits per pixel */ - {0}, /* no bitplanes; 1 bit per pixel */ - {0, 1, 2, 3, 4, 5, 6, 7}, - {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, - 8*8 /* size of one char */ -}; - -VIDEO_START_MEMBER(ut88_state,ut88) -{ -} - -UINT32 ut88_state::screen_update_ut88(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x,y; - - for(y = 0; y < 28; y++ ) - { - for(x = 0; x < 64; x++ ) - { - int code = m_p_videoram[ x + y*64 ] & 0x7f; - int attr = m_p_videoram[ x+1 + y*64 ] & 0x80; - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, code | attr, 0, 0,0, x*8,y*8); - } - } - return 0; -} diff --git a/src/mess/video/uv201.c b/src/mess/video/uv201.c deleted file mode 100644 index ae18cee5d2d..00000000000 --- a/src/mess/video/uv201.c +++ /dev/null @@ -1,589 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - VideoBrain UV201/UV202 video chip emulation - -**********************************************************************/ - -#include "uv201.h" - - - -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define LOG 1 - - -// screen parameters -#define SCREEN_WIDTH 232 -#define SCREEN_HEIGHT 262 -#define VISAREA_WIDTH 193 -#define VBLANK_WIDTH 21 -#define HBLANK_WIDTH 39 -#define HSYNC_WIDTH 18 -#define HFP_WIDTH 16 -#define HBP_WIDTH 5 -#define HBLANK_END HSYNC_WIDTH + HFP_WIDTH -#define HBLANK_START HBLANK_END + VISAREA_WIDTH - - -// write-only registers -#define REGISTER_COMMAND 0xf7 -#define REGISTER_BACKGROUND 0xf5 -#define REGISTER_FINAL_MODIFIER 0xf2 -#define REGISTER_Y_INTERRUPT 0xf0 - - -// read-only registers -#define REGISTER_X_FREEZE 0xf8 -#define REGISTER_Y_FREEZE_LOW 0xf9 -#define REGISTER_Y_FREEZE_HIGH 0xfa -#define REGISTER_CURRENT_Y_LOW 0xfb - - -// read/write registers - RAM memory -#define RAM_RP_LO 0x00 // cartridge pointer low order -#define RAM_RP_HI_COLOR 0x10 // cartridge pointer high order and color -#define RAM_DX_INT_XCOPY 0x20 // dX, intensity, X-copy -#define RAM_DY 0x30 // dY -#define RAM_X 0x40 // X value -#define RAM_Y_LO_A 0x50 // Y value low order list A -#define RAM_Y_LO_B 0x60 // Y value low order list B -#define RAM_XY_HI_A 0x70 // Y value high order and X order list A -#define RAM_XY_HI_B 0x80 // Y value high order and X order list B - - -// command register bits -#define COMMAND_YINT_H_O 0x80 -#define COMMAND_A_B 0x40 -#define COMMAND_Y_ZM 0x20 -#define COMMAND_KBD 0x10 -#define COMMAND_INT 0x08 -#define COMMAND_ENB 0x04 -#define COMMAND_FRZ 0x02 -#define COMMAND_X_ZM 0x01 - - -#define IS_CHANGED(_bit) \ - ((m_cmd & _bit) != (data & _bit)) - -#define RAM(_offset) \ - m_ram[_offset + i] - -#define RAM_XORD(_offset) \ - m_ram[_offset + xord] - -#define IS_VISIBLE(_y) \ - ((_y >= cliprect.min_y) && (_y <= cliprect.max_y)) - -#define DRAW_PIXEL(_scanline, _dot) \ - if (IS_VISIBLE(_scanline)) bitmap.pix32((_scanline), HSYNC_WIDTH + HFP_WIDTH + _dot) = m_palette_val[pixel]; - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -// device type definition -const device_type UV201 = &device_creator; - - -//------------------------------------------------- -// uv201_device - constructor -//------------------------------------------------- - -uv201_device::uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, UV201, "UV201", tag, owner, clock, "uv201", __FILE__), - device_video_interface(mconfig, *this), - m_write_ext_int(*this), - m_write_hblank(*this), - m_read_db(*this) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void uv201_device::device_start() -{ - // resolve callbacks - m_write_ext_int.resolve_safe(); - m_write_hblank.resolve_safe(); - m_read_db.resolve_safe(0); - - // allocate timers - m_timer_y_odd = timer_alloc(TIMER_Y_ODD); - m_timer_y_even = timer_alloc(TIMER_Y_EVEN); - m_timer_hblank_on = timer_alloc(TIMER_HBLANK_ON); - m_timer_hblank_off = timer_alloc(TIMER_HBLANK_OFF); - - initialize_palette(); - - memset(m_ram, 0x00, sizeof(m_ram)); - m_y_int = 0; - m_fmod = 0; - m_bg = 0; - m_cmd = 0; - m_freeze_x = 0; - m_freeze_y = 0; - m_field = 0; - - // state saving - save_item(NAME(m_ram)); - save_item(NAME(m_y_int)); - save_item(NAME(m_fmod)); - save_item(NAME(m_bg)); - save_item(NAME(m_cmd)); - save_item(NAME(m_freeze_x)); - save_item(NAME(m_freeze_y)); - save_item(NAME(m_field)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void uv201_device::device_reset() -{ - m_write_ext_int(CLEAR_LINE); - - m_write_hblank(1); - m_timer_hblank_off->adjust(attotime::from_ticks( HBLANK_END, m_clock )); -} - - -//------------------------------------------------- -// device_timer - handle timer events -//------------------------------------------------- - -void uv201_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - int scanline = m_screen->vpos(); - - switch (id) - { - case TIMER_Y_ODD: - case TIMER_Y_EVEN: - if ((m_cmd & COMMAND_INT) && !(m_cmd & COMMAND_FRZ)) - { - if (LOG) logerror("Y-Interrupt at scanline %u\n", scanline); - - m_freeze_y = scanline; - - m_write_ext_int(ASSERT_LINE); - m_write_ext_int(CLEAR_LINE); - } - break; - - case TIMER_HBLANK_ON: - m_write_hblank(1); - - m_timer_hblank_off->adjust(attotime::from_ticks( HBLANK_WIDTH, m_clock ) ); - break; - - case TIMER_HBLANK_OFF: - m_write_hblank(0); - - m_timer_hblank_on->adjust(attotime::from_ticks( VISAREA_WIDTH, m_clock ) ); - break; - } -} - - -//------------------------------------------------- -// initialize_palette - -//------------------------------------------------- - -void uv201_device::initialize_palette() -{ - UINT8 offlointensity = 0x00; - UINT8 offhiintensity = 0xc0; - - UINT8 onlointensity = 0xa0; - UINT8 onhiintensity = 0xff; - - for (int i = 0; i < 4; i++) - { - int offset = i * 8; - UINT8 onvalue, offvalue; - - if (offset < 16) - { - offvalue = offlointensity; - onvalue = onlointensity; - } - else - { - offvalue = offhiintensity; - onvalue = onhiintensity; - } - - m_palette_val[offset + 0] = rgb_t(offvalue, offvalue, offvalue); // black - m_palette_val[offset + 1] = rgb_t(onvalue, offvalue, offvalue); // red - m_palette_val[offset + 2] = rgb_t(offvalue, onvalue, offvalue); // green - m_palette_val[offset + 3] = rgb_t(onvalue, onvalue, offvalue); // red-green - m_palette_val[offset + 4] = rgb_t(offvalue, offvalue, onvalue); // blue - m_palette_val[offset + 5] = rgb_t(onvalue, offvalue, onvalue); // red-blue - m_palette_val[offset + 6] = rgb_t(offvalue, onvalue, onvalue); // green-blue - m_palette_val[offset + 7] = rgb_t(onvalue, onvalue, onvalue); // white - } -} - - -//------------------------------------------------- -// get_field_vpos - get scanline within field -//------------------------------------------------- - -int uv201_device::get_field_vpos() -{ - int vpos = m_screen->vpos(); - - if (vpos >= SCREEN_HEIGHT) - { - // even field - vpos -= SCREEN_HEIGHT; - } - - return vpos; -} - - -//------------------------------------------------- -// get_field - get video field -//------------------------------------------------- - -int uv201_device::get_field() -{ - return m_screen->vpos() < SCREEN_HEIGHT; -} - - -//------------------------------------------------- -// set_y_interrupt - set Y interrupt timer -//------------------------------------------------- - -void uv201_device::set_y_interrupt() -{ - int scanline = ((m_cmd & COMMAND_YINT_H_O) << 1) | m_y_int; - - m_timer_y_odd->adjust(m_screen->time_until_pos(scanline), 0, m_screen->frame_period()); - //m_timer_y_even->adjust(m_screen->time_until_pos(scanline + SCREEN_HEIGHT), 0, m_screen->frame_period()); -} - - -//------------------------------------------------- -// do_partial_update - update screen -//------------------------------------------------- - -void uv201_device::do_partial_update() -{ - int vpos = m_screen->vpos(); - - if (LOG) logerror("Partial screen update at scanline %u\n", vpos); - - m_screen->update_partial(vpos); -} - - -//------------------------------------------------- -// read - -//------------------------------------------------- - -READ8_MEMBER( uv201_device::read ) -{ - UINT8 data = 0xff; - - switch (offset) - { - case REGISTER_X_FREEZE: - data = m_freeze_x; - - if (LOG) logerror("X-Freeze %02x\n", data); - break; - - case REGISTER_Y_FREEZE_LOW: - data = m_freeze_y & 0xff; - - if (LOG) logerror("Y-Freeze Low %02x\n", data); - break; - - case REGISTER_Y_FREEZE_HIGH: - /* - - bit signal description - - 0 Y-F8 Y freeze high order (MSB) bit - 1 Y-C8 current Y counter high order (MSB) bit - 2 - 3 - 4 - 5 - 6 - 7 O/_E odd/even field - - */ - - data = (get_field() << 7) | (BIT(get_field_vpos(), 8) << 1) | BIT(m_freeze_y, 8); - - if (LOG) logerror("Y-Freeze High %02x\n", data); - break; - - case REGISTER_CURRENT_Y_LOW: - data = get_field_vpos() & 0xff; - - if (LOG) logerror("Current-Y Low %02x\n", data); - break; - - default: - if (offset < 0x90) - data = m_ram[offset]; - else - if (LOG) logerror("Unknown VLSI read from %02x!\n", offset); - } - - return data; -} - - -//------------------------------------------------- -// write - -//------------------------------------------------- - -WRITE8_MEMBER( uv201_device::write ) -{ - switch (offset) - { - case REGISTER_Y_INTERRUPT: - if (LOG) logerror("Y-Interrupt %02x\n", data); - - if (m_y_int != data) - { - m_y_int = data; - set_y_interrupt(); - } - break; - - case REGISTER_FINAL_MODIFIER: - /* - - bit signal description - - 0 RED red - 1 GREEN green - 2 BLUE blue - 3 INT 0 intensity 0 - 4 INT 1 intensity 1 - 5 not used - 6 not used - 7 not used - - */ - - if (LOG) logerror("Final Modifier %02x\n", data); - - do_partial_update(); - m_fmod = data & 0x1f; - break; - - case REGISTER_BACKGROUND: - /* - - bit signal description - - 0 RED red - 1 GREEN green - 2 BLUE blue - 3 INT 0 intensity 0 - 4 INT 1 intensity 1 - 5 not used - 6 not used - 7 not used - - */ - - if (LOG) logerror("Background %02x\n", data); - - do_partial_update(); - m_bg = data & 0x1f; - break; - - case REGISTER_COMMAND: - /* - - bit signal description - - 0 X-ZM X zoom - 1 FRZ freeze - 2 ENB video enable - 3 INT interrupt enable - 4 KBD general purpose output - 5 Y-ZM Y zoom - 6 A/_B list selection - 7 YINT H.O. Y COMMAND_INT register high order bit - - */ - - if (LOG) logerror("Command %02x\n", data); - - if (IS_CHANGED(COMMAND_YINT_H_O)) - { - set_y_interrupt(); - } - - if (IS_CHANGED(COMMAND_A_B) || IS_CHANGED(COMMAND_Y_ZM) || IS_CHANGED(COMMAND_X_ZM)) - { - do_partial_update(); - } - - m_cmd = data; - break; - - default: - if (offset < 0x90) - m_ram[offset] = data; - else - logerror("Unknown VLSI write %02x to %02x!\n", data, offset); - } -} - - -//------------------------------------------------- -// ext_int_w - external interrupt write -//------------------------------------------------- - -WRITE_LINE_MEMBER( uv201_device::ext_int_w ) -{ - if (!state && (m_cmd & COMMAND_FRZ)) - { - m_freeze_y = get_field_vpos(); - m_freeze_x = m_screen->hpos(); - } -} - - -//------------------------------------------------- -// kbd_r - keyboard select read -//------------------------------------------------- - -READ_LINE_MEMBER( uv201_device::kbd_r ) -{ - return (m_cmd & COMMAND_KBD) ? 1 : 0; -} - - -//------------------------------------------------- -// screen_update - -//------------------------------------------------- - -UINT32 uv201_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(rgb_t(0x00,0x00,0x00), cliprect); - - if (!(m_cmd & COMMAND_ENB)) - { - return 0; - } - - for (int y = 0; y < SCREEN_HEIGHT; y++) - { - for (int x = 0; x < VISAREA_WIDTH; x++) - { - int pixel = m_bg; - DRAW_PIXEL(y, x); - } - } - - for (int i = 0; i < 16; i++) - { - UINT8 xy_hi = (m_cmd & COMMAND_A_B) ? RAM(RAM_XY_HI_A) : RAM(RAM_XY_HI_B); - UINT8 y_lo = (m_cmd & COMMAND_A_B) ? RAM(RAM_Y_LO_A) : RAM(RAM_Y_LO_B); - UINT16 y = (BIT(xy_hi, 7) << 8) | y_lo; - int xord = xy_hi & 0x0f; - - UINT8 rp_hi_color = RAM_XORD(RAM_RP_HI_COLOR); - UINT8 rp_lo = RAM_XORD(RAM_RP_LO); - UINT16 rp = ((rp_hi_color << 8) | rp_lo) & 0x1fff; - - if (rp < 0x800) rp |= 0x2000; - - UINT8 dx_int_xcopy = RAM_XORD(RAM_DX_INT_XCOPY); - int color = ((dx_int_xcopy & 0x60) >> 2) | (BIT(rp_hi_color, 5) << 2) | (BIT(rp_hi_color, 6) << 1) | (BIT(rp_hi_color, 7)); - UINT8 dx = dx_int_xcopy & 0x1f; - UINT8 dy = RAM_XORD(RAM_DY); - int xcopy = BIT(dx_int_xcopy, 7); - UINT8 x = RAM_XORD(RAM_X); - - if (LOG) logerror("Object %u xord %u y %u x %u dy %u dx %u xcopy %u color %u rp %04x\n", i, xord, y, x, dy, dx, xcopy, color, rp); - - if (rp == 0) continue; - if (y > SCREEN_HEIGHT) continue; - - for (int sy = 0; sy < dy; sy++) - { - for (int sx = 0; sx < dx; sx++) - { - UINT8 data = m_read_db(rp); - - for (int bit = 0; bit < 8; bit++) - { - int pixel = ((BIT(data, 7) ? color : m_bg) ^ m_fmod) & 0x1f; - - if (m_cmd & COMMAND_Y_ZM) - { - int scanline = y + (sy * 2); - - if (m_cmd & COMMAND_X_ZM) - { - int dot = (x * 2) + (sx * 16) + (bit * 2); - - DRAW_PIXEL(scanline, dot); - DRAW_PIXEL(scanline, dot + 1); - DRAW_PIXEL(scanline + 1, dot); - DRAW_PIXEL(scanline + 1, dot + 1); - } - else - { - int dot = x + (sx * 8) + bit; - - DRAW_PIXEL(scanline, dot); - DRAW_PIXEL(scanline + 1, dot); - } - } - else - { - int scanline = y + sy; - - if (m_cmd & COMMAND_X_ZM) - { - int dot = (x * 2) + (sx * 16) + (bit * 2); - - DRAW_PIXEL(scanline, dot); - DRAW_PIXEL(scanline, dot + 1); - } - else - { - int dot = x + (sx * 8) + bit; - - DRAW_PIXEL(scanline, dot); - } - } - - data <<= 1; - } - - if (!xcopy) rp++; - } - - if (xcopy) rp++; - } - } - - return 0; -} diff --git a/src/mess/video/uv201.h b/src/mess/video/uv201.h deleted file mode 100644 index 336dd8f4141..00000000000 --- a/src/mess/video/uv201.h +++ /dev/null @@ -1,159 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - VideoBrain UV201/UV202 video chip emulation - -********************************************************************** - _____ _____ - GND 1 |* \_/ | 40 DMAREQ - G 2 | | 39 /CE - I 3 | | 38 RESET - B 4 | | 37 BISTROBE - R 5 | | 36 UMIREQ0 - BA0 6 | | 35 BRCLK - BA1 7 | | 34 HBLANK - BA2 8 | | 33 VBLANK - BA3 9 | | 32 R/W - BA4 10 | UV201 | 31 keypad column 8 - BA5 11 | | 30 EXT INT - BA6 12 | | 29 FIELD - BA7 13 | | 28 BD7 - BA8 14 | | 27 BD6 - BA9 15 | | 26 BD5 - BA10 16 | | 25 BD4 - BA11 17 | | 24 BD3 - BA12 18 | | 23 BD2 - +5V 19 | | 22 BD1 - +12V 20 |_____________| 21 BD0 - - _____ _____ - UMIREQ1 1 |* \_/ | 40 BISTROBE - UMIREQ0 2 | | 39 CPUREQ1 - CPUREQ0 3 | | 38 GND - XIN 4 | | 37 /800-BFF - XOUT 5 | | 36 RST - DMAREQ0 6 | | 35 DMAREQ1 - CPU CLK 7 | | 34 COLCLK - WACK 8 | | 33 BRCLK - D0 9 | | 32 D7 - BD0 10 | UV202 | 31 BD7 - D1 11 | | 30 D6 - BD1 12 | | 29 BD6 - D2 13 | | 28 D5 - BD2 14 | | 27 BD5 - D3 15 | | 26 D4 - BD3 16 | | 25 BD4 - HBLANK 17 | | 24 FIELD - VBLANK 18 | | 23 SCANLINE - BURST 19 | | 22 +12V - CSYNCH 20 |_____________| 21 +5V - -**********************************************************************/ - -#pragma once - -#ifndef __UV201__ -#define __UV201__ - -#include "emu.h" - - - -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_UV201_ADD(_tag, _screen_tag, _clock, _config) \ - MCFG_SCREEN_ADD(_screen_tag, RASTER) \ - MCFG_SCREEN_UPDATE_DEVICE(_tag, uv201_device, screen_update) \ - MCFG_SCREEN_RAW_PARAMS(_clock, 232, 18, 232, 262, 21, 262) \ - MCFG_DEVICE_ADD(_tag, UV201, _clock) \ - MCFG_VIDEO_SET_SCREEN(_screen_tag) - - -#define MCFG_UV201_EXT_INT_CALLBACK(_write) \ - devcb = &uv201_device::set_ext_int_wr_callback(*device, DEVCB_##_write); - -#define MCFG_UV201_HBLANK_CALLBACK(_write) \ - devcb = &uv201_device::set_hblank_wr_callback(*device, DEVCB_##_write); - -#define MCFG_UV201_DB_CALLBACK(_read) \ - devcb = &uv201_device::set_db_rd_callback(*device, DEVCB_##_read); - - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> uv201_device - -class uv201_device : public device_t, - public device_video_interface -{ -public: - // construction/destruction - uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - template static devcb_base &set_ext_int_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_ext_int.set_callback(object); } - template static devcb_base &set_hblank_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_hblank.set_callback(object); } - template static devcb_base &set_db_rd_callback(device_t &device, _Object object) { return downcast(device).m_read_db.set_callback(object); } - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - - DECLARE_WRITE_LINE_MEMBER( ext_int_w ); - DECLARE_READ_LINE_MEMBER( kbd_r ); - - UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - -private: - enum - { - TIMER_Y_ODD, - TIMER_Y_EVEN, - TIMER_HBLANK_ON, - TIMER_HBLANK_OFF - }; - - void initialize_palette(); - int get_field_vpos(); - int get_field(); - void set_y_interrupt(); - void do_partial_update(); - - devcb_write_line m_write_ext_int; - devcb_write_line m_write_hblank; - devcb_read8 m_read_db; - - rgb_t m_palette_val[32]; - UINT8 m_ram[0x90]; - UINT8 m_y_int; - UINT8 m_fmod; - UINT8 m_bg; - UINT8 m_cmd; - UINT8 m_freeze_x; - UINT16 m_freeze_y; - int m_field; - - // timers - emu_timer *m_timer_y_odd; - emu_timer *m_timer_y_even; - emu_timer *m_timer_hblank_on; - emu_timer *m_timer_hblank_off; -}; - - -// device type definition -extern const device_type UV201; - - - -#endif diff --git a/src/mess/video/v1050.c b/src/mess/video/v1050.c deleted file mode 100644 index 2154b01fb42..00000000000 --- a/src/mess/video/v1050.c +++ /dev/null @@ -1,124 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -#include "includes/v1050.h" - -/* - - TODO: - - - bright in reverse video - -*/ - -#define V1050_ATTR_BRIGHT 0x01 -#define V1050_ATTR_BLINKING 0x02 -#define V1050_ATTR_ATTEN 0x04 -#define V1050_ATTR_REVERSE 0x10 -#define V1050_ATTR_BLANK 0x20 -#define V1050_ATTR_BOLD 0x40 -#define V1050_ATTR_BLINK 0x80 - -/* Video RAM Access */ - -READ8_MEMBER( v1050_state::attr_r ) -{ - return m_attr; -} - -WRITE8_MEMBER( v1050_state::attr_w ) -{ - m_attr = data; -} - -READ8_MEMBER( v1050_state::videoram_r ) -{ - if (offset >= 0x2000) - { - m_attr = (m_attr & 0xfc) | (m_attr_ram[offset] & 0x03); - } - - return m_video_ram[offset]; -} - -WRITE8_MEMBER( v1050_state::videoram_w ) -{ - m_video_ram[offset] = data; - - if (offset >= 0x2000 && BIT(m_attr, 2)) - { - m_attr_ram[offset] = m_attr & 0x03; - } -} - -/* MC6845 Interface */ - -MC6845_UPDATE_ROW( v1050_state::crtc_update_row ) -{ - int column, bit; - - for (column = 0; column < x_count; column++) - { - UINT16 address = (((ra & 0x03) + 1) << 13) | ((ma & 0x1fff) + column); - UINT8 data = m_video_ram[address & V1050_VIDEORAM_MASK]; - UINT8 attr = (m_attr & 0xfc) | (m_attr_ram[address] & 0x03); - - for (bit = 0; bit < 8; bit++) - { - int x = (column * 8) + bit; - int color = BIT(data, 7); - - /* blinking */ - if ((attr & V1050_ATTR_BLINKING) && !(attr & V1050_ATTR_BLINK)) color = 0; - - /* reverse video */ - color ^= BIT(attr, 4); - - /* bright */ - if (color && (!(attr & V1050_ATTR_BOLD) ^ (attr & V1050_ATTR_BRIGHT))) color = 2; - - /* display blank */ - if (attr & V1050_ATTR_BLANK) color = 0; - - bitmap.pix32(vbp + y, hbp + x) = m_palette->pen(de ? color : 0); - - data <<= 1; - } - } -} - -WRITE_LINE_MEMBER( v1050_state::crtc_vs_w ) -{ - m_subcpu->set_input_line(INPUT_LINE_IRQ0, state ? ASSERT_LINE : CLEAR_LINE); - - set_interrupt(INT_VSYNC, state); -} - -/* Video Start */ - -void v1050_state::video_start() -{ - /* allocate memory */ - m_attr_ram.allocate(V1050_VIDEORAM_SIZE); - - /* register for state saving */ - save_item(NAME(m_attr)); -} - -/* Machine Drivers */ - -MACHINE_CONFIG_FRAGMENT( v1050_video ) - MCFG_MC6845_ADD(H46505_TAG, H46505, SCREEN_TAG, XTAL_15_36MHz/8) - MCFG_MC6845_SHOW_BORDER_AREA(true) - MCFG_MC6845_CHAR_WIDTH(8) - MCFG_MC6845_UPDATE_ROW_CB(v1050_state, crtc_update_row) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(v1050_state, crtc_vs_w)) - - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) - MCFG_SCREEN_UPDATE_DEVICE(H46505_TAG, h46505_device, screen_update) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) - MCFG_SCREEN_SIZE(640, 400) - MCFG_SCREEN_VISIBLE_AREA(0,640-1, 0, 400-1) - - MCFG_PALETTE_ADD_MONOCHROME_GREEN_HIGHLIGHT("palette") -MACHINE_CONFIG_END diff --git a/src/mess/video/vc4000.c b/src/mess/video/vc4000.c deleted file mode 100644 index d8ba1ca6f30..00000000000 --- a/src/mess/video/vc4000.c +++ /dev/null @@ -1,650 +0,0 @@ -// license:??? -// copyright-holders:Peter Trauner, Manfred Schneider, Robbbert - -#include "includes/vc4000.h" - - -/* - emulation of signetics 2636 video/audio device - - seams to me like a special microcontroller - mask programmed - - note about mame s2636 emulation: - less encapsuled - missing grid, sound generation, retriggered sprites, paddle reading, score display - not "rasterline" based - */ - -#define STICKCENTRE (105) -#define STICKLOW (20) -#define STICKHIGH (225) - -#define VC4000_END_LINE (269) - - - -void vc4000_state::video_start() -{ - int i; - - for (i=0;i<0x20; i++) - { - m_sprite_collision[i]=0; - if ((i&3)==3) m_sprite_collision[i]|=0x20; - if ((i&5)==5) m_sprite_collision[i]|=0x10; - if ((i&9)==9) m_sprite_collision[i]|=8; - if ((i&6)==6) m_sprite_collision[i]|=4; - if ((i&0xa)==0xa) m_sprite_collision[i]|=2; - if ((i&0xc)==0xc) m_sprite_collision[i]|=1; - m_background_collision[i]=0; - if ((i&0x11)==0x11) m_background_collision[i]|=0x80; - if ((i&0x12)==0x12) m_background_collision[i]|=0x40; - if ((i&0x14)==0x14) m_background_collision[i]|=0x20; - if ((i&0x18)==0x18) m_background_collision[i]|=0x10; - } - - m_joy1_x = STICKCENTRE; - m_joy1_y = STICKCENTRE; - m_joy2_x = STICKCENTRE; - m_joy2_y = STICKCENTRE; - - memset(&m_video, 0, sizeof(m_video)); - for (i=0; i<3; i++) - { - m_video.sprites[i].data = &m_video.reg.d.sprites[i]; - m_video.sprites[i].mask = 1 << i; - } - m_video.sprites[3].data = &m_video.reg.d.sprite4; - m_video.sprites[3].mask = 1 << 3; - - m_bitmap = auto_bitmap_ind16_alloc(machine(), m_screen->width(), m_screen->height()); -} - -inline UINT8 vc4000_state::vc4000_joystick_return_to_centre(UINT8 joy) -{ - UINT8 data; - - if (joy > (STICKCENTRE+5)) - data=joy-5; - else - if (joy < (STICKCENTRE-5)) - data=joy+5; - else - data=105; - - return data; -} - -READ8_MEMBER( vc4000_state::vc4000_video_r ) -{ - UINT8 data=0; - if (offset > 0xcf) offset &= 0xcf; // c0-cf is mirrored at d0-df, e0-ef, f0-ff - switch (offset) - { - case 0xca: // Background-sprite collision (bit 7-4) and sprite finished (bit 3-0) - data |= m_video.background_collision; - m_video.background_collision=0; - if (m_video.sprites[3].finished) - { - data |= 1; - m_video.sprites[3].finished = FALSE; - } - - if (m_video.sprites[2].finished) - { - data |= 2; - m_video.sprites[2].finished = FALSE; - } - if (m_video.sprites[1].finished) - { - data |= 4; - m_video.sprites[1].finished = FALSE; - } - if (m_video.sprites[0].finished) - { - data |= 8; - m_video.sprites[0].finished = FALSE; - } - break; - - case 0xcb: // VRST-Flag (bit 6) and intersprite collision (bit5-0) - data = m_video.sprite_collision | (m_video.reg.d.sprite_collision & 0xc0); - m_video.sprite_collision = 0; - m_video.reg.d.sprite_collision &= 0xbf; - break; - -#ifndef ANALOG_HACK - case 0xcc: - if (!activeS2650_FO)) data = m_io_joy1_x->read(); - else data = m_io_joy1_y->read(); - break; - case 0xcd: - if (!activecpu_get_reg(S2650_FO)) data = m_io_joy2_x->read(); - else data = m_io_joy2_y->read(); - break; -#else - - case 0xcc: /* left joystick */ - if (m_config->read()&1) - { /* paddle */ - if (!m_maincpu->state_int(S2650_FO)) - { - data = m_joys->read() & 0x03; - switch (data) - { - case 0x01: - m_joy1_x-=5; - if (m_joy1_x < STICKLOW) m_joy1_x=STICKLOW; - break; - case 0x02: - m_joy1_x+=5; - if (m_joy1_x > STICKHIGH) m_joy1_x=STICKHIGH; - break; - case 0x00: - m_joy1_x = vc4000_joystick_return_to_centre(m_joy1_x); - } - data = m_joy1_x; - } - else - { - data = m_joys->read() & 0x0c; - switch (data) - { - case 0x08: - m_joy1_y-=5; - if (m_joy1_y < STICKLOW) m_joy1_y=STICKLOW; - break; - case 0x04: - m_joy1_y+=5; - if (m_joy1_y > STICKHIGH) m_joy1_y=STICKHIGH; - break; - // case 0x00: - // m_joy1_y = vc4000_joystick_return_to_centre(m_joy1_y); - } - data = m_joy1_y; - } - } - else - { /* buttons */ - if (!m_maincpu->state_int(S2650_FO)) - { - data = m_joys->read() & 0x03; - switch (data) - { - case 0x01: - m_joy1_x=STICKLOW; - break; - case 0x02: - m_joy1_x=STICKHIGH; - break; - default: /* autocentre */ - m_joy1_x=STICKCENTRE; - } - data = m_joy1_x; - } - else - { - data = m_joys->read() & 0x0c; - switch (data) - { - case 0x08: - m_joy1_y=STICKLOW; - break; - case 0x04: - m_joy1_y=STICKHIGH; - break; - default: - m_joy1_y=STICKCENTRE; - } - data = m_joy1_y; - } - } - break; - - case 0xcd: /* right joystick */ - if (m_config->read()&1) - { - if (!m_maincpu->state_int(S2650_FO)) - { - data = m_joys->read() & 0x30; - switch (data) - { - case 0x10: - m_joy2_x-=5; - if (m_joy2_x < STICKLOW) m_joy2_x=STICKLOW; - break; - case 0x20: - m_joy2_x+=5; - if (m_joy2_x > STICKHIGH) m_joy2_x=STICKHIGH; - case 0x00: - m_joy2_x = vc4000_joystick_return_to_centre(m_joy2_x); - break; - } - data = m_joy2_x; - } - else - { - data = m_joys->read() & 0xc0; - switch (data) - { - case 0x80: - m_joy2_y-=5; - if (m_joy2_y < STICKLOW) m_joy2_y=STICKLOW; - break; - case 0x40: - m_joy2_y+=5; - if (m_joy2_y > STICKHIGH) m_joy2_y=STICKHIGH; - break; - // case 0x00: - // m_joy2_y = vc4000_joystick_return_to_centre(m_joy2_y); - } - data = m_joy2_y; - } - } - else - { - if (!m_maincpu->state_int(S2650_FO)) - { - data = m_joys->read() & 0x30; - switch (data) - { - case 0x10: - m_joy2_x=STICKLOW; - break; - case 0x20: - m_joy2_x=STICKHIGH; - break; - default: /* autocentre */ - m_joy2_x=STICKCENTRE; - } - data = m_joy2_x; - } - else - { - data = m_joys->read() & 0xc0; - switch (data) - { - case 0x80: - m_joy2_y=STICKLOW; - break; - case 0x40: - m_joy2_y=STICKHIGH; - break; - default: - m_joy2_y=STICKCENTRE; - } - data = m_joy2_y; - } - } - break; -#endif - - default: - data = m_video.reg.data[offset]; - break; - } - return data; -} - -WRITE8_MEMBER( vc4000_state::vc4000_video_w ) -{ -// m_video.reg.data[offset]=data; - if (offset > 0xcf) offset &= 0xcf; // c0-cf is mirrored at d0-df, e0-ef, f0-ff - - switch (offset) - { - case 0xc0: // Sprite size - m_video.sprites[0].size=1<<(data&3); - m_video.sprites[1].size=1<<((data>>2)&3); - m_video.sprites[2].size=1<<((data>>4)&3); - m_video.sprites[3].size=1<<((data>>6)&3); - break; - - case 0xc1: // Sprite 1+2 color - m_video.sprites[0].scolor=((~data>>3)&7); - m_video.sprites[1].scolor=(~data&7); - break; - - case 0xc2: // Sprite 2+3 color - m_video.sprites[2].scolor=((~data>>3)&7); - m_video.sprites[3].scolor=(~data&7); - break; - - case 0xc3: // Score control - m_video.reg.d.score_control = data; - break; - - case 0xc6: // Background color - m_video.reg.d.background = data; - break; - - case 0xc7: // Soundregister - m_video.reg.data[offset] = data; - m_custom->soundport_w(0, data); - break; - - case 0xc8: // Digits 1 and 2 - m_video.reg.d.bcd[0] = data; - break; - - case 0xc9: // Digits 3 and 4 - m_video.reg.d.bcd[1] = data; - break; - - case 0xca: // Background-sprite collision (bit 7-4) and sprite finished (bit 3-0) - m_video.reg.data[offset]=data; - m_video.background_collision=data; - break; - - case 0xcb: // VRST-Flag (bit 6) and intersprite collision (bit5-0) - m_video.reg.data[offset]=data; - m_video.sprite_collision=data; - break; - - default: - m_video.reg.data[offset]=data; - } -} - - -READ8_MEMBER( vc4000_state::vc4000_vsync_r ) -{ - return m_video.line >= VC4000_END_LINE ? 0x80 : 0; -} - -static const char led[20][12+1] = -{ - "aaaabbbbcccc", - "aaaabbbbcccc", - "aaaabbbbcccc", - "aaaabbbbcccc", - "llll dddd", - "llll dddd", - "llll dddd", - "llll dddd", - "kkkkmmmmeeee", - "kkkkmmmmeeee", - "kkkkmmmmeeee", - "kkkkmmmmeeee", - "jjjj ffff", - "jjjj ffff", - "jjjj ffff", - "jjjj ffff", - "iiiihhhhgggg", - "iiiihhhhgggg", - "iiiihhhhgggg", - "iiiihhhhgggg" -}; - - -void vc4000_state::vc4000_draw_digit(bitmap_ind16 &bitmap, int x, int y, int d, int line) -{ - static const int digit_to_segment[0x10]={ - 0x0fff, 0x007c, 0x17df, 0x15ff, 0x1c7d, 0x1df7, 0x1ff7, 0x007f, 0x1fff, 0x1dff - }; - - int i=line,j; - - for (j=0; j>4)&7)^7; - } -} - -inline void vc4000_state::vc4000_collision_plot(UINT8 *collision, UINT8 data, UINT8 color, int scale) -{ - int i,j,m; - - for (j=0,m=0x80; j<8; j++, m>>=1) - { - if (data&m) - for (i=0; iy=This->data->y1; - This->state=0; - This->delay=0; - This->finished=FALSE; - } - - This->finished_now=FALSE; - - if (m_video.line>VC4000_END_LINE) return; - - switch (This->state) - { - case 0: - if (m_video.line != This->y + 2) break; - This->state++; - - case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:case 9:case 10: - - vc4000_collision_plot(collision+This->data->x1, This->data->bitmap[This->state-1],This->mask,This->size); - - for (j=0,m=0x80; j<8; j++, m>>=1) - { - if (This->data->bitmap[This->state-1]&m) - { - for (i=0; isize; i++) - { - m_objects[This->data->x1 + i + j*This->size] |= This->scolor; - m_objects[This->data->x1 + i + j*This->size] &= 7; - } - } - } - - This->delay++; - - if (This->delay>=This->size) - { - This->delay=0; - This->state++; - } - - if (This->state>10) - { - This->finished=TRUE; - This->finished_now=TRUE; - } - - break; - - case 11: - This->y=This->data->y2; - - if (This->y==255) - This->y=0; - else - This->y++; - - if (This->y>252) break; - - This->delay=0; - This->state++; - - case 12: - if (This->y!=0) - { - This->y--; - break; - } - This->state++; - - case 13: case 14: case 15: case 16: case 17: case 18: case 19:case 20:case 21:case 22: - - vc4000_collision_plot(collision+This->data->x2,This->data->bitmap[This->state-13],This->mask,This->size); - for (j=0,m=0x80; j<8; j++, m>>=1) - { - if (This->data->bitmap[This->state-13]&m) - { - for (i=0; isize; i++) - { - int offset = This->data->x2 + i + j*This->size; - - // clip objects outside the object buffer. - // someone who knows this hardware should look at - // it properly. - if (offset < 256) - { - m_objects[offset] |= This->scolor; - m_objects[offset] &= 7; - } - } - } - } - This->delay++; - if (This->delaysize) break; - This->delay=0; - This->state++; - if (This->state<23) break; - This->finished=TRUE; - This->finished_now=TRUE; - This->state=11; - break; - } -} - -inline void vc4000_state::vc4000_draw_grid(UINT8 *collision) -{ - int width = m_screen->width(); - int height = m_screen->height(); - int i, j, m, x, line=m_video.line-20; - int w, k; - - if (m_video.line>=height) return; - - m_bitmap->plot_box(0, m_video.line, width, 1, (m_video.reg.d.background)&7); - - if (line<0 || line>=200) return; - if (~m_video.reg.d.background & 8) return; - - i=(line/20)*2; - if (line%20>=2) i++; - - k=m_video.reg.d.grid_control[i>>2]; - switch (k>>6) { - default: - case 0:case 2: w=1;break; - case 1: w=2;break; - case 3: w=4;break; - } - switch (i&3) { - case 0: - if (k&1) w=8;break; - case 1: - if ((line%40)<=10) { - if (k&2) w=8; - } else { - if (k&4) w=8; - } - break; - case 2: if (k&8) w=8;break; - case 3: - if ((line%40)<=30) { - if (k&0x10) w=8; - } else { - if (k&0x20) w=8; - } - break; - } - for (x=30, j=0, m=0x80; j<16; j++, x+=8, m>>=1) - { - if (m_video.reg.d.grid[i][j>>3]&m) - { - int l; - for (l=0; lplot_box(x, m_video.line, w, 1, (m_video.reg.d.background>>4)&7); - } - if (j==7) m=0x100; - } -} - -INTERRUPT_GEN_MEMBER(vc4000_state::vc4000_video_line) -{ - int x,y,i; - UINT8 collision[400]={0}; // better alloca or gcc feature of non constant long automatic arrays - const rectangle &visarea = m_screen->visible_area(); - assert(ARRAY_LENGTH(collision) >= m_screen->width()); - - m_video.line++; - if (m_irq_pause) m_irq_pause++; - if (m_video.line>311) m_video.line=0; - - if (m_video.line==0) - { - m_video.background_collision=0; - m_video.sprite_collision=0; - m_video.reg.d.sprite_collision=0; -// logerror("begin of frame\n"); - } - - if (m_irq_pause>10) - { - m_maincpu->set_input_line(0, CLEAR_LINE); - m_irq_pause = 0; - } - - if (m_video.line <= VC4000_END_LINE) - { - vc4000_draw_grid(collision); - - /* init object colours */ - for (i=visarea.min_x; ipix16(m_video.line, i) = m_objects[i]; - } - - y = m_video.reg.d.score_control&1?200:20; - - if ((m_video.line>=y)&&(m_video.line>4, m_video.line-y); - vc4000_draw_digit(*m_bitmap, x+16, y, m_video.reg.d.bcd[0]&0xf, m_video.line-y); - if (m_video.reg.d.score_control&2) x -= 16; - vc4000_draw_digit(*m_bitmap, x+48, y, m_video.reg.d.bcd[1]>>4, m_video.line-y); - vc4000_draw_digit(*m_bitmap, x+64, y, m_video.reg.d.bcd[1]&0xf, m_video.line-y); - } - } - if (m_video.line==VC4000_END_LINE) m_video.reg.d.sprite_collision |=0x40; - - if (((m_video.line == VC4000_END_LINE) | - (m_video.sprites[3].finished_now) | - (m_video.sprites[2].finished_now) | - (m_video.sprites[1].finished_now) | - (m_video.sprites[0].finished_now)) && (!m_irq_pause)) - { - m_maincpu->set_input_line_and_vector(0, ASSERT_LINE, 3); - m_irq_pause=1; - } -} - -UINT32 vc4000_state::screen_update_vc4000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/vector06.c b/src/mess/video/vector06.c deleted file mode 100644 index 9ae05a221f9..00000000000 --- a/src/mess/video/vector06.c +++ /dev/null @@ -1,61 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - Vector06c driver by Miodrag Milanovic - - 10/07/2008 Preliminary driver. - -****************************************************************************/ - - -#include "includes/vector06.h" - - -void vector06_state::video_start() -{ -} - -UINT32 vector06_state::screen_update_vector06(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 code1,code2,code3,code4; - UINT8 col; - int y, x, b,draw_y; - UINT8 *ram = m_ram->pointer(); - - int width = (m_video_mode==0x00) ? 256 : 512; - rectangle screen_area(0,width+64-1,0,256+64-1); - // fill border color - bitmap.fill(m_color_index, screen_area); - - // draw image - for (x = 0; x < 32; x++) - { - for (y = 0; y < 256; y++) - { - // port A of 8255 also used as scroll - draw_y = ((255-y-m_keyboard_mask) & 0xff) +32; - code1 = ram[0x8000 + x*256 + y]; - code2 = ram[0xa000 + x*256 + y]; - code3 = ram[0xc000 + x*256 + y]; - code4 = ram[0xe000 + x*256 + y]; - for (b = 0; b < 8; b++) - { - col = ((code1 >> b) & 0x01) * 8 + ((code2 >> b) & 0x01) * 4 + ((code3 >> b) & 0x01)* 2+ ((code4 >> b) & 0x01); - if (m_video_mode==0x00) { - bitmap.pix16(draw_y, x*8+(7-b)+32) = col; - } else { - bitmap.pix16(draw_y, x*16+(7-b)*2+1+32) = ((code2 >> b) & 0x01) * 2; - bitmap.pix16(draw_y, x*16+(7-b)*2+32) = ((code3 >> b) & 0x01) * 2; - } - } - } - } - return 0; -} - -PALETTE_INIT_MEMBER(vector06_state, vector06) -{ - for (UINT8 i=0; i<16; i++) - m_palette->set_pen_color( i, rgb_t::black ); -} diff --git a/src/mess/video/vtech2.c b/src/mess/video/vtech2.c deleted file mode 100644 index dedbf31efc9..00000000000 --- a/src/mess/video/vtech2.c +++ /dev/null @@ -1,312 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller -/*************************************************************************** - vtech2.c - - video hardware - Juergen Buchmueller MESS driver, Jan 2000 - Davide Moretti ROM dump and hardware description - -****************************************************************************/ - -#include "emu.h" - -#include "includes/vtech2.h" - -#define BORDER_H 64 -#define BORDER_V 32 - -/* public */ - -/* - * when in text mode (bit 3 of I/O area = 0) - * bit 3 2 1 0 mode - * 0 x x 0 40 columns x 24 rows display RAM at bank 7 1F800-1FFFF - * 1 x x 0 40 columns x 24 rows display RAM at bank 3 0F800-0FFFF - * 0 x x 1 80 columns x 24 rows display RAM at bank 7 1F800-1FFFF - * 1 x x 1 80 columns x 24 rows display RAM at bank 3 0F800-0FFFF - * - * when in graphics mode (bit 3 of I/O area = 1) - * bit 3 2 1 0 mode - * 0 0 0 x GR5 bank 7 1C000-1FFFF - * 1 0 0 x GR5 bank 3 0C000-0FFFF - * 0 0 1 0 GR4 bank 7 1C000-1FFFF - * 1 0 1 0 GR4 bank 3 0C000-0FFFF - * 0 0 1 1 GR3 bank 7 1C000-1FFFF - * 1 0 1 1 GR3 bank 3 1C000-1FFFF - * 0 1 0 x GR0 bank 7 1E000-1FFFF - * 1 1 0 x GR0 bank 3 0E000-0FFFF - * 0 1 1 0 GR2 bank 7 1E000-1FFFF - * 1 1 1 0 GR2 bank 3 0E000-0FFFF - * 0 1 1 1 GR1 bank 7 1E000-1FFFF - * 1 1 1 1 GR1 bank 3 0E000-0FFFF - */ - -void vtech2_state::video_start() -{ -} - -static const int offs_2[192] = { - 0x0000,0x0800,0x1000,0x1800,0x2000,0x2800,0x3000,0x3800, - 0x0100,0x0900,0x1100,0x1900,0x2100,0x2900,0x3100,0x3900, - 0x0200,0x0a00,0x1200,0x1a00,0x2200,0x2a00,0x3200,0x3a00, - 0x0300,0x0b00,0x1300,0x1b00,0x2300,0x2b00,0x3300,0x3b00, - 0x0400,0x0c00,0x1400,0x1c00,0x2400,0x2c00,0x3400,0x3c00, - 0x0500,0x0d00,0x1500,0x1d00,0x2500,0x2d00,0x3500,0x3d00, - 0x0600,0x0e00,0x1600,0x1e00,0x2600,0x2e00,0x3600,0x3e00, - 0x0700,0x0f00,0x1700,0x1f00,0x2700,0x2f00,0x3700,0x3f00, - 0x0050,0x0850,0x1050,0x1850,0x2050,0x2850,0x3050,0x3850, - 0x0150,0x0950,0x1150,0x1950,0x2150,0x2950,0x3150,0x3950, - 0x0250,0x0a50,0x1250,0x1a50,0x2250,0x2a50,0x3250,0x3a50, - 0x0350,0x0b50,0x1350,0x1b50,0x2350,0x2b50,0x3350,0x3b50, - 0x0450,0x0c50,0x1450,0x1c50,0x2450,0x2c50,0x3450,0x3c50, - 0x0550,0x0d50,0x1550,0x1d50,0x2550,0x2d50,0x3550,0x3d50, - 0x0650,0x0e50,0x1650,0x1e50,0x2650,0x2e50,0x3650,0x3e50, - 0x0750,0x0f50,0x1750,0x1f50,0x2750,0x2f50,0x3750,0x3f50, - 0x00a0,0x08a0,0x10a0,0x18a0,0x20a0,0x28a0,0x30a0,0x38a0, - 0x01a0,0x09a0,0x11a0,0x19a0,0x21a0,0x29a0,0x31a0,0x39a0, - 0x02a0,0x0aa0,0x12a0,0x1aa0,0x22a0,0x2aa0,0x32a0,0x3aa0, - 0x03a0,0x0ba0,0x13a0,0x1ba0,0x23a0,0x2ba0,0x33a0,0x3ba0, - 0x04a0,0x0ca0,0x14a0,0x1ca0,0x24a0,0x2ca0,0x34a0,0x3ca0, - 0x05a0,0x0da0,0x15a0,0x1da0,0x25a0,0x2da0,0x35a0,0x3da0, - 0x06a0,0x0ea0,0x16a0,0x1ea0,0x26a0,0x2ea0,0x36a0,0x3ea0, - 0x07a0,0x0fa0,0x17a0,0x1fa0,0x27a0,0x2fa0,0x37a0,0x3fa0 -}; - -static const int offs_1[192] = { - 0x2000,0x2080,0x2800,0x2880,0x3000,0x3080,0x3800,0x3880, - 0x2100,0x2180,0x2900,0x2980,0x3100,0x3180,0x3900,0x3980, - 0x2200,0x2280,0x2a00,0x2a80,0x3200,0x3280,0x3a00,0x3a80, - 0x2300,0x2380,0x2b00,0x2b80,0x3300,0x3380,0x3b00,0x3b80, - 0x2400,0x2480,0x2c00,0x2c80,0x3400,0x3480,0x3c00,0x3c80, - 0x2500,0x2580,0x2d00,0x2d80,0x3500,0x3580,0x3d00,0x3d80, - 0x2600,0x2680,0x2e00,0x2e80,0x3600,0x3680,0x3e00,0x3e80, - 0x2700,0x2780,0x2f00,0x2f80,0x3700,0x3780,0x3f00,0x3f80, - 0x2028,0x20a8,0x2828,0x28a8,0x3028,0x30a8,0x3828,0x38a8, - 0x2128,0x21a8,0x2928,0x29a8,0x3128,0x31a8,0x3928,0x39a8, - 0x2228,0x22a8,0x2a28,0x2aa8,0x3228,0x32a8,0x3a28,0x3aa8, - 0x2328,0x23a8,0x2b28,0x2ba8,0x3328,0x33a8,0x3b28,0x3ba8, - 0x2428,0x24a8,0x2c28,0x2ca8,0x3428,0x34a8,0x3c28,0x3ca8, - 0x2528,0x25a8,0x2d28,0x2da8,0x3528,0x35a8,0x3d28,0x3da8, - 0x2628,0x26a8,0x2e28,0x2ea8,0x3628,0x36a8,0x3e28,0x3ea8, - 0x2728,0x27a8,0x2f28,0x2fa8,0x3728,0x37a8,0x3f28,0x3fa8, - 0x2050,0x20d0,0x2850,0x28d0,0x3050,0x30d0,0x3850,0x38d0, - 0x2150,0x21d0,0x2950,0x29d0,0x3150,0x31d0,0x3950,0x39d0, - 0x2250,0x22d0,0x2a50,0x2ad0,0x3250,0x32d0,0x3a50,0x3ad0, - 0x2350,0x23d0,0x2b50,0x2bd0,0x3350,0x33d0,0x3b50,0x3bd0, - 0x2450,0x24d0,0x2c50,0x2cd0,0x3450,0x34d0,0x3c50,0x3cd0, - 0x2550,0x25d0,0x2d50,0x2dd0,0x3550,0x35d0,0x3d50,0x3dd0, - 0x2650,0x26d0,0x2e50,0x2ed0,0x3650,0x36d0,0x3e50,0x3ed0, - 0x2750,0x27d0,0x2f50,0x2fd0,0x3750,0x37d0,0x3f50,0x3fd0 -}; - -static const int offs_0[96] = { - 0x2000,0x2800,0x3000,0x3800,0x2100,0x2900,0x3100,0x3900, - 0x2200,0x2a00,0x3200,0x3a00,0x2300,0x2b00,0x3300,0x3b00, - 0x2400,0x2c00,0x3400,0x3c00,0x2500,0x2d00,0x3500,0x3d00, - 0x2600,0x2e00,0x3600,0x3e00,0x2700,0x2f00,0x3700,0x3f00, - 0x2050,0x2850,0x3050,0x3850,0x2150,0x2950,0x3150,0x3950, - 0x2250,0x2a50,0x3250,0x3a50,0x2350,0x2b50,0x3350,0x3b50, - 0x2450,0x2c50,0x3450,0x3c50,0x2550,0x2d50,0x3550,0x3d50, - 0x2650,0x2e50,0x3650,0x3e50,0x2750,0x2f50,0x3750,0x3f50, - 0x20a0,0x28a0,0x30a0,0x38a0,0x21a0,0x29a0,0x31a0,0x39a0, - 0x22a0,0x2aa0,0x32a0,0x3aa0,0x23a0,0x2ba0,0x33a0,0x3ba0, - 0x24a0,0x2ca0,0x34a0,0x3ca0,0x25a0,0x2da0,0x35a0,0x3da0, - 0x26a0,0x2ea0,0x36a0,0x3ea0,0x27a0,0x2fa0,0x37a0,0x3fa0 -}; - -UINT32 vtech2_state::screen_update_laser(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT8 *videoram = m_videoram; - int offs, x, y; - int full_refresh = 1; - - if( full_refresh ) - bitmap.fill(((m_laser_bg_mode >> 4) & 15)<<1, cliprect); - - if (m_laser_latch & 0x08) - { - /* graphics modes */ - switch (m_laser_bg_mode & 7) - { - case 0: - case 1: - /* - * GR 5 - * 640x192 1bpp - */ - for( y = 0; y < 192; y++ ) - { - offs = offs_2[y]; - for( x = 0; x < 80; x++, offs++ ) - { - int sx, sy, code, color = m_laser_two_color; - sy = BORDER_V/2 + y; - sx = BORDER_H/2 + x * 8; - code = videoram[offs]; - m_gfxdecode->gfx(2)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - break; - - case 2: - /* - * GR 4 - * 320x192 1bpp with two colors per 8 pixels - */ - for( y = 0; y < 192; y++ ) - { - offs = offs_2[y]; - for( x = 0; x < 40; x++, offs += 2 ) - { - int sx, sy, code, color; - sy = BORDER_V/2 + y; - sx = BORDER_H/2 + x * 16; - code = videoram[offs]; - color = videoram[offs+1]; - m_gfxdecode->gfx(3)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - break; - - case 3: - /* - * GR 3 - * 160x192 4bpp - */ - for( y = 0; y < 192; y++ ) - { - offs = offs_2[y]; - for( x = 0; x < 80; x++, offs++ ) - { - int sx, sy, code; - sy = BORDER_V/2 + y; - sx = BORDER_H/2 + x * 8; - code = videoram[offs]; - m_gfxdecode->gfx(5)->opaque(bitmap,cliprect,code,0,0,0,sx,sy); - } - } - break; - - case 4: - case 5: - /* - * GR 0 - * 160x96 4bpp - */ - for( y = 0; y < 96; y++ ) - { - offs = offs_0[y]; - for( x = 0; x < 80; x++, offs++ ) - { - int sx, sy, code; - sy = BORDER_V/2 + y * 2; - sx = BORDER_H/2 + x * 8; - code = videoram[offs]; - m_gfxdecode->gfx(6)->opaque(bitmap,cliprect,code,0,0,0,sx,sy); - } - } - break; - - case 6: - /* - * GR 2 - * 320x192 1bpp - */ - for( y = 0; y < 192; y++ ) - { - offs = offs_1[y]; - for( x = 0; x < 40; x++, offs++ ) - { - int sx, sy, code, color = m_laser_two_color; - sy = BORDER_V/2 + y; - sx = BORDER_H/2 + x * 16; - code = videoram[offs]; - m_gfxdecode->gfx(3)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - break; - - case 7: - /* - * GR 1 - * 160x192 1bpp with two colors per 8 pixels - */ - for( y = 0; y < 192; y++ ) - { - offs = offs_1[y]; - for( x = 0; x < 20; x++, offs += 2 ) - { - int sx, sy, code, color; - sy = BORDER_V/2 + y; - sx = BORDER_H/2 + x * 32; - code = videoram[offs]; - color = videoram[offs+1]; - m_gfxdecode->gfx(4)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - break; - } - } - else - { - /* text modes */ - if (m_laser_bg_mode & 1) - { - /* 80 columns text mode */ - for( y = 0; y < 24; y++ ) - { - offs = ((y & 7) << 8) + ((y >> 3) * 80); - for( x = 0; x < 80; x++, offs++ ) - { - int sx, sy, code, color = m_laser_two_color; - sy = BORDER_V/2 + y * 8; - sx = BORDER_H/2 + x * 8; - code = videoram[0x3800+offs]; - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - } - else - { - /* 40 columns text mode */ - for( y = 0; y < 24; y++ ) - { - offs = ((y & 7) << 8) + ((y >> 3) * 80); - for( x = 0; x < 40; x++, offs += 2 ) - { - int sx, sy, code, color = 0; - sy = BORDER_V/2 + y * 8; - sx = BORDER_H/2 + x * 16; - code = videoram[0x3800+offs]; - color = videoram[0x3801+offs]; - m_gfxdecode->gfx(1)->opaque(bitmap,cliprect,code,color,0,0,sx,sy); - } - } - } - } - - if( m_laser_frame_time > 0 ) - { - popmessage("%s", m_laser_frame_message); - } - return 0; -} - -WRITE8_MEMBER(vtech2_state::laser_bg_mode_w) -{ - if (m_laser_bg_mode != data) - { - m_laser_bg_mode = data; - logerror("laser border:$%X mode:$%X\n", data >> 4, data & 15); - } -} - -WRITE8_MEMBER(vtech2_state::laser_two_color_w) -{ - if (m_laser_two_color != data) - { - m_laser_two_color = data; - logerror("laser foreground:$%X background:$%X\n", data >> 4, data & 15); - } -} diff --git a/src/mess/video/vtvideo.c b/src/mess/video/vtvideo.c deleted file mode 100644 index 5170143d749..00000000000 --- a/src/mess/video/vtvideo.c +++ /dev/null @@ -1,956 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Miodrag Milanovic,Karl-Ludwig Deisenhofer -/********************************************************************** -DEC VT Terminal video emulation -[ DC012 and DC011 emulation ] - -01/05/2009 Initial implementation [Miodrag Milanovic] -Enhancements (2013 - 2015) by Karl-Ludwig Deisenhofer. - -DEC VIDEO : STATE AS OF JULY 2014 ---------------------------------- -Code developed with Rainbow-100 hardware in mind (a PC-like machine with a video circuit similar to a VT100 equipped w. AVO) -Details (termination characters, option hardware, MHFU watchdog) differ when compared to VT. - -As of July 2014, the Rainbow video section is more mature than the 'VT100_VIDEO' part (essentially unchanged since 2009). -List of features not yet ported to VT: line doubler; 48 line mode; soft scroll; intensity / palette, AVO (ext.attributes) - -FIXME: work out the differences and identify common code between VT and Rainbow. Unify different code trees. - -- REQUIRED TODOS / TESTS : - * do line and character attributes (plus combinations) match real hardware? - * how does the AVO fit in? - -- SCROLLING REGIONS / SPLIT SCREEN SCROLLING UNTESTED (if you open > 1 file with the VAX editor EDT) - See VT100 Technical Manual: 4.7.4 Address Shuffling to 4.7.9 Split Screen Smooth Scrolling. - More on scrolling regions: Rainbow 100 B technical documentation (QV069-GZ) April 1985 page 22 - -- NEW - INTERLACED MODE (Rainbow only): - Vertical resolution increases from 240 to 480, while the refresh rate halves (flickers on CRTs). - To accomplish this, the display controller repeats even lines in odd scans. - VTVIDEO activates line doubling in 24 line, interlaced mode only. - - Although the DC12 has the ability to display 48 lines, most units are low on screen RAM and - won't even show 80 x 48. -> REASON: (83 x 48 = 3984 Byte) > (screen RAM) minus 'scratch area' - On a VT-180, BIOS scratch requires up to 700 bytes used for SETUP, flags, SILO, keyboard. - -- POSSIBLE IMPROVEMENTS: - -* exact colors for different VR201 monitors (for white, green and amber) - -* ACCURATE VIDEO DELAYS: - Position of the first visible scanline (relative to the vertical reset) depends on - content of fill bytes at the beginning of screen RAM. - - Six invisible, linked lines are initially provided (at location $EE000+ on a Rainbow). - Real-world DC hardware parses the (circular) chain until interrupted by blanking. - BIOS assumes 2 lines are omitted @ 60 and 5 lines are at 50 Hertz (-> longer blank). - - VTVIDEO keeps it simple and skips up to 6 lines considered 'illegal' (offset < $12). - Works even in cases where undocumented delays or lines are poked (SQUINT; VIDEO.PAS). - - Accurate timings for 4 modes (from VT-180 manual 6-30 on): - Vertical frequency = (2 * HF = 31.468 Khz) / DIVIDER - - 50 NI: (2 * HF = 31.468 Khz) / 630 - - 50 interlaced: (2 * HF = 31.468 Khz) / 629 - - 60 NI: (2 * HF = 31.468 Khz) / 524 - - 60 interlaced: (2 * HF = 31.468 Khz) / 525 -**********************************************************************/ - -#include "emu.h" -#include "video/vtvideo.h" - -/*************************************************************************** -PARAMETERS -***************************************************************************/ - -#define VERBOSE 1 - -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - - -const device_type VT100_VIDEO = &device_creator; -const device_type RAINBOW_VIDEO = &device_creator; - - -vt100_video_device::vt100_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) -: device_t(mconfig, type, name, tag, owner, clock, shortname, source), -device_video_interface(mconfig, *this), -m_read_ram(*this), -m_write_clear_video_interrupt(*this), -m_char_rom_tag(""), -m_palette(*this, "palette") -{ -} - - -vt100_video_device::vt100_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) -: device_t(mconfig, VT100_VIDEO, "VT100 Video", tag, owner, clock, "vt100_video", __FILE__), -device_video_interface(mconfig, *this), -m_read_ram(*this), -m_write_clear_video_interrupt(*this), -m_char_rom_tag(""), -m_palette(*this, "palette") -{ -} - - -rainbow_video_device::rainbow_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) -: vt100_video_device(mconfig, RAINBOW_VIDEO, "Rainbow Video", tag, owner, clock, "rainbow_video", __FILE__) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void vt100_video_device::device_start() -{ - /* resolve callbacks */ - m_read_ram.resolve_safe(0); - m_write_clear_video_interrupt.resolve_safe(); - - m_gfx = machine().root_device().memregion(m_char_rom_tag)->base(); - assert(m_gfx != NULL); - - // LBA7 is scan line frequency update - machine().scheduler().timer_pulse(attotime::from_nsec(31778), timer_expired_delegate(FUNC(vt100_video_device::lba7_change), this)); - - save_item(NAME(m_lba7)); - save_item(NAME(m_scroll_latch)); - save_item(NAME(m_blink_flip_flop)); - save_item(NAME(m_reverse_field)); - save_item(NAME(m_basic_attribute)); - save_item(NAME(m_columns)); - save_item(NAME(m_height)); - save_item(NAME(m_height_MAX)); - save_item(NAME(m_fill_lines)); - save_item(NAME(m_frequency)); - save_item(NAME(m_interlaced)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void vt100_video_device::device_reset() -{ - m_palette->set_pen_color(0, 0x00, 0x00, 0x00); // black - m_palette->set_pen_color(1, 0xff, 0xff, 0xff); // white - - m_height = 25; - m_height_MAX = 25; - - m_lba7 = 0; - - m_scroll_latch = 0; - m_scroll_latch_valid = false; - m_last_scroll = 0; - - m_blink_flip_flop = 0; - m_reverse_field = 0; - m_basic_attribute = 0; - - m_columns = 80; - m_frequency = 60; - - m_interlaced = 1; - m_fill_lines = 2; // for 60Hz - recompute_parameters(); -} - -// ****** RAINBOW ****** -// 4 color (= monochrome intensities) palette, 24 and 48 line modes. -void rainbow_video_device::device_reset() -{ - MHFU_FLAG = false; - MHFU_counter = 0; // **** MHFU: OFF ON COLD BOOT ! **** - - // (rest of the palette is set in the main program) - m_palette->set_pen_color(0, 0x00, 0x00, 0x00); // black - - m_height = 24; // <---- DEC-100 - m_height_MAX = 48; - - m_lba7 = 0; - - m_scroll_latch = 0; - m_scroll_latch_valid = false; - m_last_scroll = 0; - - m_blink_flip_flop = 0; - m_reverse_field = 0; - m_basic_attribute = 0; - - m_columns = 80; - - m_frequency = 60; - - m_interlaced = 1; - m_fill_lines = 2; // for 60Hz (not in use any longer -> detected) - recompute_parameters(); -} - -/*************************************************************************** -IMPLEMENTATION -***************************************************************************/ - -// Also used by Rainbow-100 ************ -void vt100_video_device::recompute_parameters() -{ - rectangle visarea; - int horiz_pix_total = 0; - - // RAINBOW: 240 scan lines in non-interlaced mode (480 interlaced). VT-100 : same (?) - m_linedoubler = false; // 24 "true" lines (240) -OR- 48 lines with NO ghost lines (true 480) - if ((m_interlaced) && (m_height == 24)) - m_linedoubler = true; // 24 lines with 'double scan' (false 480) - - int vert_pix_total = ((m_linedoubler == false) ? m_height : m_height_MAX) * 10; - - if (m_columns == 132) - horiz_pix_total = m_columns * 9; // display 1 less filler pixel in 132 char. mode - else - horiz_pix_total = m_columns * 10; // normal 80 character mode. - - visarea.set(0, horiz_pix_total - 1, 0, vert_pix_total - 1); - machine().first_screen()->configure(horiz_pix_total, vert_pix_total, visarea, HZ_TO_ATTOSECONDS((m_interlaced == 0) ? m_frequency : (m_frequency/2) )); - - if (VERBOSE) - { - printf("\n(RECOMPUTE) HPIX: %d - VPIX: %d", horiz_pix_total, vert_pix_total); - printf("\n(RECOMPUTE) FREQUENCY: %d", (m_interlaced == 0) ? m_frequency : (m_frequency / 2)); - if (m_interlaced) - printf("\n(RECOMPUTE) * INTERLACED *"); - if (m_linedoubler) - printf("\n(RECOMPUTE) * LINEDOUBLER *"); - } -} - - -READ8_MEMBER(vt100_video_device::lba7_r) -{ - return m_lba7; -} - - -// Also used by Rainbow-100 ************ -WRITE8_MEMBER(vt100_video_device::dc012_w) -{ - // Writes to [10C] and [0C] are treated differently - // - see 3.1.3.9.5 DC012 Programming Information (PC-100 spec) - - // MHFU is disabled by writing 00 to port 010C. - - // Code recognition is abysmal - sorry for that. - if (data == 0) - { - UINT8 *rom = machine().root_device().memregion("maincpu")->base(); - if (rom != NULL) - { - UINT32 PC = space.device().safe_pc(); - if ((rom[ PC - 1] == 0xe6) && - (rom[ PC ] == 0x0c) - ) - { - // OUT 0C,al < DO NOTHING > - } - else - { - //UINT8 magic1= rom[PC - 1]; - //printf("\n PC %05x - MHFU MAGIC -1 %02x\n", PC, magic1); - //UINT8 magic2 = rom[PC - 2]; - //printf("\n PC %05x - MHFU MAGIC -2 %02x\n", PC, magic2); - //if (VERBOSE) - - //if(1 ) - if ((rom[PC - 2] == 0x0C) && - (rom[PC - 1] == 0x01) - ) - { - if (MHFU_FLAG == true) - printf("MHFU *** DISABLED *** %05x \n", PC); - - MHFU_FLAG = false; - MHFU_counter = 0; - } - } - - } // DATA == 0 ONLY .... - - } - else - { - //if (VERBOSE) - if (MHFU_FLAG == false) - printf("MHFU ___ENABLED___ %05x \n", space.device().safe_pc()); - - // RESET - MHFU_FLAG = true; - MHFU_counter = 0; - } - - if (!(data & 0x08)) - { - if (!(data & 0x04)) - { - m_scroll_latch_valid = false; // LSB is written first. - // set lower part scroll - m_scroll_latch = data & 0x03; - } - else - { - // set higher part scroll - m_scroll_latch = (m_scroll_latch & 0x03) | ((data & 0x03) << 2); - m_scroll_latch_valid = true; - } - } - else - { - switch (data & 0x0f) - { - case 0x08: - // toggle blink flip flop - m_blink_flip_flop = !(m_blink_flip_flop) ? 1 : 0; - break; - case 0x09: - // clear vertical frequency interrupt; - m_write_clear_video_interrupt(0); - break; - case 0x0a: - // set reverse field on - m_reverse_field = 1; - break; - case 0x0b: - // set reverse field off - m_reverse_field = 0; - break; - - // Writing a 11XX bit combination clears the blink-flip flop (valid for 0x0C - 0x0F): - case 0x0c: - // set basic attribute to underline / blink flip-flop off - m_blink_flip_flop = 0; - m_basic_attribute = 0; // (VT-100 without AVO): reverse video is interpreted as underline (basic_attribute 0) - break; - - case 0x0d: - // (DEC Rainbow 100 DEFAULT) : reverse video with 24 lines / blink flip-flop off - m_blink_flip_flop = 0; - m_basic_attribute = 1; // (VT-100 without AVO): reverse video is interpreted as reverse (basic_attribute 1) - - if (m_height_MAX == 25) break; // Abort on VT-100 for now. - - m_height = 24; // (DEC Rainbow 100) : 24 line display - recompute_parameters(); - break; - - case 0x0e: - m_blink_flip_flop = 0; // 'unsupported' DC012 command. Turns blink flip-flop off (11XX). - break; - - case 0x0f: - // (DEC Rainbow 100): reverse video with 48 lines / blink flip-flop off - m_blink_flip_flop = 0; - m_basic_attribute = 1; - - // 0x0f = 'reserved' on VT 100 - // Abort on VT-100 for now. - if (m_height_MAX == 25) break; - - m_height = 48; // (DEC Rainbow 100) : 48 line display - recompute_parameters(); - break; - } - } -} - -// Writing to DC011 resets internal counters (& disturbs display) on real hardware. -WRITE8_MEMBER(vt100_video_device::dc011_w) -{ - if (!BIT(data, 5)) - { - m_interlaced = 1; - - if (!BIT(data, 4)) - m_columns = 80; - else - m_columns = 132; - } - else - { - m_interlaced = 0; - - if (!BIT(data, 4)) - { - m_frequency = 60; - m_fill_lines = 2; - } - else - { - m_frequency = 50; - m_fill_lines = 5; - } - } - - recompute_parameters(); -} - -WRITE8_MEMBER(vt100_video_device::brightness_w) -{ - //m_palette->set_pen_color(1, data, data, data); -} - - - -void vt100_video_device::display_char(bitmap_ind16 &bitmap, UINT8 code, int x, int y, UINT8 scroll_region, UINT8 display_type) -{ - UINT8 line = 0; - int bit = 0, prevbit, invert = 0, j; - int double_width = (display_type == 2) ? 1 : 0; - - for (int i = 0; i < 10; i++) - { - switch (display_type) - { - case 0: // bottom half, double height - j = (i >> 1) + 5; break; - case 1: // top half, double height - j = (i >> 1); break; - case 2: // double width - case 3: // normal - j = i; break; - default: j = 0; break; - } - // modify line since that is how it is stored in rom - if (j == 0) j = 15; else j = j - 1; - - line = m_gfx[(code & 0x7f) * 16 + j]; - - if (m_basic_attribute == 1) - { - if ((code & 0x80) == 0x80) - invert = 1; - else - invert = 0; - } - - for (int b = 0; b < 8; b++) - { - prevbit = bit; - bit = BIT((line << b), 7); - if (double_width) - { - bitmap.pix16(y * 10 + i, x * 20 + b * 2) = (bit | prevbit) ^ invert; - bitmap.pix16(y * 10 + i, x * 20 + b * 2 + 1) = bit ^ invert; - } - else - { - bitmap.pix16(y * 10 + i, x * 10 + b) = (bit | prevbit) ^ invert; - } - } - prevbit = bit; - // char interleave is filled with last bit - if (double_width) - { - bitmap.pix16(y * 10 + i, x * 20 + 16) = (bit | prevbit) ^ invert; - bitmap.pix16(y * 10 + i, x * 20 + 17) = bit ^ invert; - bitmap.pix16(y * 10 + i, x * 20 + 18) = bit ^ invert; - bitmap.pix16(y * 10 + i, x * 20 + 19) = bit ^ invert; - } - else - { - bitmap.pix16(y * 10 + i, x * 10 + 8) = (bit | prevbit) ^ invert; - bitmap.pix16(y * 10 + i, x * 10 + 9) = bit ^ invert; - } - } -} - -void vt100_video_device::video_update(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT16 addr = 0; - int line = 0; - int xpos = 0; - int ypos = 0; - UINT8 code; - int x = 0; - UINT8 scroll_region = 1; // binary 1 - UINT8 display_type = 3; // binary 11 - UINT16 temp = 0; - - if (m_read_ram(0) != 0x7f) - return; - - while (line < (m_height + m_fill_lines)) - { - code = m_read_ram(addr + xpos); - if (code == 0x7f) - { - // end of line, fill empty till end of line - if (line >= m_fill_lines) - { - for (x = xpos; x < ((display_type == 2) ? (m_columns / 2) : m_columns); x++) - { - display_char(bitmap, code, x, ypos, scroll_region, display_type); - } - } - // move to new data - temp = m_read_ram(addr + xpos + 1) * 256 + m_read_ram(addr + xpos + 2); - addr = (temp)& 0x1fff; - // if A12 is 1 then it is 0x2000 block, if 0 then 0x4000 (AVO) - if (addr & 0x1000) addr &= 0xfff; else addr |= 0x2000; - scroll_region = (temp >> 15) & 1; - display_type = (temp >> 13) & 3; - if (line >= m_fill_lines) - { - ypos++; - } - xpos = 0; - line++; - } - else - { - // display regular char - if (line >= m_fill_lines) - { - display_char(bitmap, code, xpos, ypos, scroll_region, display_type); - } - xpos++; - if (xpos > m_columns) - { - line++; - xpos = 0; - } - } - } - -} - -// ****** RAINBOW ****** -// Display 10 scan lines (or 20 in interlaced mode) for one character @ position X/Y -// NOTE: X or Y indicate a character position! - -// 5 possible CHARACTER STATES (normal, reverse, bold, blink, underline) are encoded into display_type. -// From the VT-180 specs, chapter 6-43 (where multiple attributes are described): -// 1) reverse characters [ XOR of reverse video and reverse screen (A) ] normally have dim backgrounds with black characters (B) -// 2) bold and reverse together give a background of normal intensity - -// 3) blink controls intensity: normal chars vary between A) normal and dim (B) bold chars vary between bright and normal -// 4) blink applied to a -// A) reverse character causes it to alternate between normal and reverse video representation -// B) non-rev. " : alternate between usual intensity and the next lower intensity -// 5) underline causes the 9.th scan to be forced to -// A) white of the same intensity as the characters (for nonreversed characters), -// b) to black (for reverse characters) -// LINE ATTRIBUTE 'double_height' always is interpreted as 'double width + double height' - -// ATTRIBUTES: No attributes = 0x0E -// 1 = display char. in REVERSE (encoded as 8 in display_type) HIGH ACTIVE -// 0 = display char. in BOLD (encoded as 16 in display_type) LOW ACTIVE -// 0 = display char. w. BLINK (encoded as 32 in display_type) LOW ACTIVE -// 0 = display char. w. UNDERLINE (encoded as 64 in display_type) LOW ACTIVE -void rainbow_video_device::display_char(bitmap_ind16 &bitmap, UINT8 code, int x, int y, UINT8 scroll_region, UINT8 display_type) -{ - UINT16 x_preset = x << 3; // x_preset = x * 9 (= 132 column mode) - x_preset += x; - - if (m_columns == 80) - x_preset += x; // x_preset = x * 10 (80 column mode) - - UINT16 y_preset; - - UINT16 CHARPOS_y_preset = y << 3; // CHARPOS_y_preset = y * 10; - CHARPOS_y_preset += y; - CHARPOS_y_preset += y; - - UINT16 DOUBLE_x_preset = x_preset << 1; // 18 for 132 column mode, else 20 (x_preset * 2) - - UINT8 line = 0; - int bit = 0, j = 0; - int fg_intensity; - int back_intensity, back_default_intensity; - - int invert = (display_type & 8) ? 1 : 0; // REVERSE - int bold = (display_type & 16) ? 0 : 1; // BIT 4 - int blink = (display_type & 32) ? 0 : 1; // BIT 5 - int underline = (display_type & 64) ? 0 : 1; // BIT 6 - bool blank = (display_type & 128) ? true : false; // BIT 7 - - display_type = display_type & 3; - - // * SCREEN ATTRIBUTES (see VT-180 manual 6-30) * - // 'reverse field' = reverse video over entire screen - - // For reference: a complete truth table can be taken from TABLE 4-6-4 / VT100 technical manual. - // Following IF statements implement it in full. Code segments should not be shuffled. - invert = invert ^ m_reverse_field ^ m_basic_attribute; - - fg_intensity = bold + 2; // FOREGROUND (FG): normal (2) or bright (3) - - back_intensity = 0; // DO NOT SHUFFLE CODE AROUND !! - if ((blink != 0) && (m_blink_flip_flop != 0)) - fg_intensity -= 1; // normal => dim bright => normal (when bold) - - // INVERSION: background gets foreground intensity (reduced by 1). - // _RELIES ON_ on_ previous evaluation of the BLINK signal (fg_intensity). - if (invert != 0) - { - back_intensity = fg_intensity - 1; // BG: normal => dim; dim => OFF; bright => normal - - if (back_intensity != 0) // FG: avoid 'black on black' - fg_intensity = 0; - else - fg_intensity = fg_intensity + 1; // FG: dim => normal; normal => bright - } - - // BG: DEFAULT for entire character (underline overrides this for 1 line) - - back_default_intensity = back_intensity; - - bool double_width = (display_type != 3) ? true : false; // all except normal: double width - bool double_height = (display_type & 1) ? false : true; // 0,2 = double height - - int smooth_offset = 0; - if (scroll_region != 0) - smooth_offset = m_last_scroll; // valid after VBI - - int i = 0; - int extra_scan_line = 0; - for (int scan_line = 0; scan_line < (m_linedoubler ? 20 : 10); scan_line++) - { - y_preset = CHARPOS_y_preset + scan_line; - - // 'i' points to char-rom (plus scroll offset; if active) - - // IF INTERLACED: odd lines = even lines - i = (m_linedoubler ? (scan_line >> 1) : scan_line) + smooth_offset; - - if (i > 9) // handle everything in one loop (in case of smooth scroll): - { - extra_scan_line += 1; - - // Fetch appropriate character bitmap (one scan line) - - // IF INTERLACED: no odd lines - i = smooth_offset - (m_linedoubler ? (extra_scan_line >> 1) : extra_scan_line); - - if (CHARPOS_y_preset >= extra_scan_line) // If result not negative... - y_preset = CHARPOS_y_preset - extra_scan_line; // correct Y pos. - else - { - y_preset = (m_linedoubler ? 480 : 240) - extra_scan_line; - i = 0; // blank line. Might not work with TCS or other charsets (FIXME) - } - } - - switch (display_type) - { - case 0: // bottom half of 'double height, double width' char. - j = (i >> 1) + 5; - break; - - case 2: // top half of 'double height, double width' char. - j = (i >> 1); - break; - - default: // 1: double width - // 3: normal - j = i; - break; - } - - // modify line since that is how it is stored in rom - if (j == 0) j = 15; else j = j - 1; - - line = m_gfx[(code << 4) + j]; // code * 16 - - // UNDERLINED CHARACTERS (CASE 5 - different in 1 line): - back_intensity = back_default_intensity; // 0, 1, 2 - if (underline != 0) - { - if (i == 8) - { - if (invert == 0) - line = 0xff; // CASE 5 A) - else - { - line = 0x00; // CASE 5 B) - back_intensity = 0; // OVERRIDE: BLACK BACKGROUND - } - } - } - - for (int b = 0; b < 8; b++) // 0..7 - { - if (blank) - { - bit = m_reverse_field ^ m_basic_attribute; - } - else - { - bit = BIT((line << b), 7); - - if (bit > 0) - bit = fg_intensity; - else - bit = back_intensity; - } - - // Double, 'double_height + double_width', then normal. - if (double_width) - { - bitmap.pix16(y_preset, DOUBLE_x_preset + (b << 1) + 1) = bit; - bitmap.pix16(y_preset, DOUBLE_x_preset + (b << 1)) = bit; - - if (double_height) - { - bitmap.pix16(1 + y_preset, DOUBLE_x_preset + (b << 1) + 1) = bit; - bitmap.pix16(1 + y_preset, DOUBLE_x_preset + (b << 1)) = bit; - } - } - else - { - bitmap.pix16(y_preset, x_preset + b) = bit; - } - } // for (8 bit) - - // char interleave (X) is filled with last bit - if (double_width) - { - // double chars: 18 or 20 bits - bitmap.pix16(y_preset, DOUBLE_x_preset + 16) = bit; - bitmap.pix16(y_preset, DOUBLE_x_preset + 17) = bit; - - if (m_columns == 80) - { - bitmap.pix16(y_preset, DOUBLE_x_preset + 18) = bit; - bitmap.pix16(y_preset, DOUBLE_x_preset + 19) = bit; - } - } - else - { // normal chars: 9 or 10 bits - bitmap.pix16(y_preset, x_preset + 8) = bit; - - if (m_columns == 80) - bitmap.pix16(y_preset, x_preset + 9) = bit; - } - } // for (scan_line) - -} - -// ****** RAINBOW ****** -void rainbow_video_device::video_update(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - UINT16 addr = 0; - UINT16 attr_addr = 0; - int line = 0; - int xpos = 0; - int ypos = 0; - UINT8 code; - int x = 0; - UINT8 scroll_region = 0; // DEFAULT TO 0 = NOT PART OF scroll_region - UINT8 display_type = 3; // NORMAL DISPLAY - binary 11 - UINT16 temp = 0; - - if (m_read_ram(0) != 0xff) // video uninitialized? - return; - - // Skip fill (0xFF) lines and put result in ADDR. - for (int xp = 1; xp <= 6; xp += 1) // beware of circular references - { - // Fetch LINE ATTRIBUTE before it is gone - attr_addr = 0x1000 | ((addr + 1) & 0x0fff); - - temp = m_read_ram(addr + 2) * 256 + m_read_ram(addr + 1); - addr = (temp)& 0x0fff; - - temp = m_read_ram(attr_addr); - scroll_region = (temp)& 1; - display_type = (temp >> 1) & 3; - - if (addr >= 0x12) - break; - } - - int vert_charlines_MAX = ((m_linedoubler == false) ? m_height : m_height_MAX); - while (line < vert_charlines_MAX ) - { - code = m_read_ram(addr + xpos); - - if (code == 0x00) // TODO: investigate side effect on regular zero character! - display_type |= 0x80; // DEFAULT: filler chars (till end of line) and empty lines (00) will be blanked - else - display_type &= 0x7f; // else activate display. - - if (code == 0xff) // end of line, fill empty till end of line - { - // HINT: display_type is already shifted! All except 3 is DOUBLE WIDTH 40 or 66 chars per line - for (x = xpos; x < ((display_type != 3) ? (m_columns / 2) : m_columns); x++) - { - display_char(bitmap, code, x, ypos, scroll_region, display_type | 0x80); - } - - // LINE ATTRIBUTE - valid for all chars on next line ** DO NOT SHUFFLE ** - attr_addr = 0x1000 | ((addr + xpos + 1) & 0x0fff); - - // MOVE TO NEW DATA - temp = m_read_ram(addr + xpos + 2) * 256 + m_read_ram(addr + xpos + 1); - addr = (temp)& 0x0fff; - - temp = m_read_ram(attr_addr); - scroll_region = (temp)& 1; - display_type = (temp >> 1) & 3; - - ypos++; // Y + 1 in non-interlaced mode - if (m_linedoubler) - ypos++; // Y + 2 in 'double scan' mode (see -> 'display_char') - - if (ypos > vert_charlines_MAX) // prevent invalid Y pos. - break; - - xpos = 0; - line++; - } - else - { - attr_addr = 0x1000 | ((addr + xpos) & 0x0fff); - temp = (m_read_ram(attr_addr) & 15) << 3; // get character attributes - - // see 'display_char' for an explanation of attribute encoding - - display_char(bitmap, code, xpos, ypos, scroll_region, display_type | temp); - - xpos++; - if (xpos > m_columns) - { - xpos = 0; - line++; - } - } // (else) valid char - - } // while - -} - -void rainbow_video_device::notify_vblank(bool v) -{ - static bool v_last; - m_notify_vblank = v; - - if (m_scroll_latch_valid) - { - // Line linking / unlinking is done during VBI (see 4.7.4 and up in VT manual). - if ((v == false) && (v_last == true)) - m_last_scroll = m_scroll_latch; - } - - v_last = v; -} - -void rainbow_video_device::palette_select(int choice) -{ - switch (choice) - { - default: - case 0x01: - m_palette->set_pen_color(1, 0xff - 100, 0xff - 100, 0xff - 100); // WHITE (dim) - m_palette->set_pen_color(2, 0xff - 50, 0xff - 50, 0xff - 50); // WHITE NORMAL - m_palette->set_pen_color(3, 0xff, 0xff, 0xff); // WHITE (brighter) - break; - - case 0x02: - m_palette->set_pen_color(1, 35, 200 - 55, 75); // GREEN (dim) - m_palette->set_pen_color(2, 35 + 55, 200, 75 + 55); // GREEN (NORMAL) - m_palette->set_pen_color(3, 35 + 110, 200 + 55, 75 + 110); // GREEN (brighter) - break; - - case 0x03: - m_palette->set_pen_color(1, 213 - 47, 146 - 47, 82 - 47); // AMBER (dim) - m_palette->set_pen_color(2, 213, 146, 82); // AMBER (NORMAL) - m_palette->set_pen_color(3, 255, 193, 129); // AMBER (brighter) - break; - } -} - -// ****** RAINBOW ****** -void rainbow_video_device::video_blanking(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - // 'In reverse screen mode, termination forces the beam to the screen background intensity' - // Background intensity means 'dim' (1) according to one source. - bitmap.fill(((m_reverse_field ^ m_basic_attribute) ? 1 : 0), cliprect); -} - - - -int rainbow_video_device::MHFU(int ASK) -{ - switch (ASK) - { - case 1: // "true": RETURN BOOLEAN (MHFU disabled or enabled?) - return MHFU_FLAG; - - case -1: // -1: increment IF ENABLED, return counter value (=> Rainbow.c) - if (MHFU_FLAG == true) - MHFU_counter++; - return MHFU_counter; - - case -100: // -100 : RESET and ENABLE MHFU counter - MHFU_counter = 0; - if(1) //if (VERBOSE) - printf("-100 MHFU * reset and ENABLE * \n"); - - if(1) // if (VERBOSE) - { - if (MHFU_FLAG == false) - printf("-100 MHFU ___ENABLED___\n"); - } - MHFU_FLAG = true; - - return -100; - - case -200: // -200 : RESET and DISABLE MHFU - MHFU_counter = 0; - - if(1) //if (VERBOSE) - { - if (MHFU_FLAG == true) - printf("MHFU *** DISABLED *** \n"); - } - MHFU_FLAG = false; - - return -200; - - default: - assert(1); - return -255; - } // switch -} - -TIMER_CALLBACK_MEMBER(vt100_video_device::lba7_change) -{ - m_lba7 = (m_lba7) ? 0 : 1; -} - -static MACHINE_CONFIG_FRAGMENT(vt100_video) -MCFG_PALETTE_ADD_MONOCHROME_GREEN("palette") -MACHINE_CONFIG_END - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor vt100_video_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME(vt100_video); -} - -static MACHINE_CONFIG_FRAGMENT(rainbow_video) -MCFG_PALETTE_ADD("palette", 4) -MACHINE_CONFIG_END - -//------------------------------------------------- -// machine_config_additions - return a pointer to -// the device's machine fragment -//------------------------------------------------- - -machine_config_constructor rainbow_video_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME(rainbow_video); -} diff --git a/src/mess/video/vtvideo.h b/src/mess/video/vtvideo.h deleted file mode 100644 index 49dbcfef7cd..00000000000 --- a/src/mess/video/vtvideo.h +++ /dev/null @@ -1,113 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Miodrag Milanovic,Karl-Ludwig Deisenhofer -/********************************************************************** - -DEC VT Terminal video emulation -[ DC012 and DC011 emulation ] - -01/05/2009 Initial implementation [Miodrag Milanovic] - -**********************************************************************/ - -#ifndef __VT_VIDEO__ -#define __VT_VIDEO__ - -#include "emu.h" - -class vt100_video_device : public device_t, - public device_video_interface -{ -public: - vt100_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - vt100_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~vt100_video_device() {} - - template static devcb_base &set_ram_rd_callback(device_t &device, _Object object) { return downcast(device).m_read_ram.set_callback(object); } - template static devcb_base &set_clear_video_irq_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_clear_video_interrupt.set_callback(object); } - - static void set_chargen_tag(device_t &device, const char *tag) { downcast(device).m_char_rom_tag = tag; } - - DECLARE_READ8_MEMBER(lba7_r); - DECLARE_WRITE8_MEMBER(dc012_w); - DECLARE_WRITE8_MEMBER(dc011_w); - DECLARE_WRITE8_MEMBER(brightness_w); - - virtual void video_update(bitmap_ind16 &bitmap, const rectangle &cliprect); -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual machine_config_constructor device_mconfig_additions() const; - - // internal state - void recompute_parameters(); - virtual void display_char(bitmap_ind16 &bitmap, UINT8 code, int x, int y, UINT8 scroll_region, UINT8 display_type); - TIMER_CALLBACK_MEMBER(lba7_change); - - devcb_read8 m_read_ram; - devcb_write8 m_write_clear_video_interrupt; - - UINT8 *m_gfx; /* content of char rom */ - - int m_lba7; - - bool MHFU_FLAG; - int MHFU_counter; - - // dc012 attributes - UINT8 m_scroll_latch; - bool m_scroll_latch_valid; - UINT8 m_blink_flip_flop; - UINT8 m_reverse_field; - UINT8 m_basic_attribute; - // dc011 attributes - UINT8 m_columns; - UINT8 m_height; - UINT8 m_height_MAX; - UINT8 m_fill_lines; - UINT8 m_frequency; - UINT8 m_interlaced; - - const char *m_char_rom_tag; /* character rom region */ - required_device m_palette; - - bool m_notify_vblank; - int m_last_scroll; - - bool m_linedoubler; -}; - - -class rainbow_video_device : public vt100_video_device -{ -public: - rainbow_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - virtual void video_update(bitmap_ind16 &bitmap, const rectangle &cliprect); - virtual void video_blanking(bitmap_ind16 &bitmap, const rectangle &cliprect); - - int MHFU(int); - void palette_select(int choice); - void notify_vblank(bool choice); -protected: - virtual void display_char(bitmap_ind16 &bitmap, UINT8 code, int x, int y, UINT8 scroll_region, UINT8 display_type); - virtual void device_reset(); - virtual machine_config_constructor device_mconfig_additions() const; -}; - -extern const device_type VT100_VIDEO; -extern const device_type RAINBOW_VIDEO; - - -#define MCFG_VT_SET_SCREEN MCFG_VIDEO_SET_SCREEN - -#define MCFG_VT_CHARGEN(_tag) \ - vt100_video_device::set_chargen_tag(*device, _tag); - -#define MCFG_VT_VIDEO_RAM_CALLBACK(_read) \ - devcb = &vt100_video_device::set_ram_rd_callback(*device, DEVCB_##_read); - -#define MCFG_VT_VIDEO_CLEAR_VIDEO_INTERRUPT_CALLBACK(_write) \ - devcb = &vt100_video_device::set_clear_video_irq_wr_callback(*device, DEVCB_##_write); - -#endif diff --git a/src/mess/video/wswan_video.c b/src/mess/video/wswan_video.c deleted file mode 100644 index 8dbb60f0db8..00000000000 --- a/src/mess/video/wswan_video.c +++ /dev/null @@ -1,1216 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Anthony Kruize, Wilbert Pol -/*************************************************************************** - - wswan_video.c - - File to handle video emulation of the Bandai WonderSwan VDP. - - Anthony Kruize - Wilbert Pol - - TODO: - - remove the redundant parts of m_regs - - split the Color VDP from the Mono VDP? - - ***************************************************************************/ - -#include "wswan_video.h" - -const device_type WSWAN_VIDEO = &device_creator; - - -wswan_video_device::wswan_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, WSWAN_VIDEO, "Bandai WonderSwan VDP", tag, owner, clock, "wswan_video", __FILE__), - m_vdp_type(VDP_TYPE_WSWAN) -{ -} - - -void wswan_video_device::common_save() -{ - save_item(NAME(m_bitmap)); - save_item(NAME(m_vram)); - save_item(NAME(m_palette_port)); - save_item(NAME(m_pal)); - save_item(NAME(m_regs)); - - save_item(NAME(m_layer_bg_enable)); - save_item(NAME(m_layer_fg_enable)); - save_item(NAME(m_sprites_enable)); - save_item(NAME(m_window_sprites_enable)); - save_item(NAME(m_window_fg_mode)); - save_item(NAME(m_bg_control)); - save_item(NAME(m_current_line)); - save_item(NAME(m_line_compare)); - save_item(NAME(m_sprite_table_address)); - save_item(NAME(m_sprite_table_buffer)); - save_item(NAME(m_sprite_first)); - save_item(NAME(m_sprite_count)); - save_item(NAME(m_sprite_first_latch)); - save_item(NAME(m_sprite_count_latch)); - save_item(NAME(m_layer_bg_address)); - save_item(NAME(m_layer_fg_address)); - save_item(NAME(m_window_fg_left)); - save_item(NAME(m_window_fg_top)); - save_item(NAME(m_window_fg_right)); - save_item(NAME(m_window_fg_bottom)); - save_item(NAME(m_window_sprites_left)); - save_item(NAME(m_window_sprites_top)); - save_item(NAME(m_window_sprites_right)); - save_item(NAME(m_window_sprites_bottom)); - save_item(NAME(m_layer_bg_scroll_x)); - save_item(NAME(m_layer_bg_scroll_y)); - save_item(NAME(m_layer_fg_scroll_x)); - save_item(NAME(m_layer_fg_scroll_y)); - save_item(NAME(m_lcd_control)); - save_item(NAME(m_icons)); - save_item(NAME(m_color_mode)); - save_item(NAME(m_colors_16)); - save_item(NAME(m_tile_packed)); - save_item(NAME(m_timer_hblank_enable)); - save_item(NAME(m_timer_hblank_mode)); - save_item(NAME(m_timer_hblank_reload)); - save_item(NAME(m_timer_hblank_count)); - save_item(NAME(m_timer_vblank_enable)); - save_item(NAME(m_timer_vblank_mode)); - save_item(NAME(m_timer_vblank_reload)); - save_item(NAME(m_timer_vblank_count)); - save_item(NAME(m_main_palette)); -} - -void wswan_video_device::device_start() -{ - machine().first_screen()->register_screen_bitmap(m_bitmap); - - m_timer = timer_alloc(TIMER_SCANLINE); - m_timer->adjust(attotime::from_ticks(256, 3072000), 0, attotime::from_ticks(256, 3072000)); - - // bind callbacks - m_set_irq_cb.bind_relative_to(*owner()); - m_snd_dma_cb.bind_relative_to(*owner()); - - if (m_vdp_type == VDP_TYPE_WSC) - { - m_vram.resize(0x10000); - memset(&m_vram[0], 0, 0x10000); - m_palette_vram = &m_vram[0xfe00]; - } - else - { - m_vram.resize(0x4000); - memset(&m_vram[0], 0, 0x4000); - m_palette_vram = &m_vram[0]; - } - - common_save(); -} - -// This is a copy of ws_portram_init -// TODO: remove unneeded parts! -static const UINT8 vdp_regs_init[256] = -{ - 0x00, 0x00, 0x00/*?*/, 0xbb, 0x00, 0x00, 0x00, 0x26, 0xfe, 0xde, 0xf9, 0xfb, 0xdb, 0xd7, 0x7f, 0xf5, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x9e, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x99, 0xfd, 0xb7, 0xdf, - 0x30, 0x57, 0x75, 0x76, 0x15, 0x73, 0x70/*77?*/, 0x77, 0x20, 0x75, 0x50, 0x36, 0x70, 0x67, 0x50, 0x77, - 0x57, 0x54, 0x75, 0x77, 0x75, 0x17, 0x37, 0x73, 0x50, 0x57, 0x60, 0x77, 0x70, 0x77, 0x10, 0x73, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, - 0x87, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x4f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xdb, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x00, 0x83, 0x00, - 0x2f, 0x3f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, - 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, - 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, - 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 -}; - - -void wswan_video_device::device_reset() -{ - m_layer_bg_enable = 0; - m_layer_fg_enable = 0; - m_sprites_enable = 0; - m_window_sprites_enable = 0; - m_window_fg_mode = 0; - m_bg_control = 0; - m_current_line = 145; // Randomly chosen, beginning of VBlank period to give cart some time to boot up - m_line_compare = 0; - m_sprite_table_address = 0; - m_sprite_first = 0; - m_sprite_count = 0; - m_sprite_first_latch = 0; - m_sprite_count_latch = 0; - m_layer_bg_address = 0; - m_layer_fg_address = 0; - m_window_fg_left = 0; - m_window_fg_top = 0; - m_window_fg_right = 0; - m_window_fg_bottom = 0; - m_window_sprites_left = 0; - m_window_sprites_top = 0; - m_window_sprites_right = 0; - m_window_sprites_bottom = 0; - m_layer_bg_scroll_x = 0; - m_layer_bg_scroll_y = 0; - m_layer_fg_scroll_x = 0; - m_layer_fg_scroll_y = 0; - m_lcd_control = 0x01; - m_icons = 0; - m_color_mode = 0; - m_colors_16 = 0; - m_tile_packed = 0; - m_timer_hblank_enable = 0; - m_timer_hblank_mode = 0; - m_timer_hblank_reload = 0; - m_timer_hblank_count = 0; - m_timer_vblank_enable = 0; - m_timer_vblank_mode = 0; - m_timer_vblank_reload = 0; - m_timer_vblank_count = 0; /* Vertical blank timer counter value */ - - memset(m_sprite_table_buffer, 0, sizeof(m_sprite_table_buffer)); - memset(m_main_palette, 0, sizeof(m_main_palette)); - memcpy(m_regs, vdp_regs_init, 256); - for (int i = 0; i < 0x20; i++) - m_palette_port[i] = m_regs[i + 0x20]; - - setup_palettes(); -} - - -void wswan_video_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case TIMER_SCANLINE: - scanline_interrupt(); - break; - } -} - - -void wswan_video_device::setup_palettes() -{ - if (m_color_mode) - { - for (int i = 0; i < 16; i++) - for (int j = 0; j < 16; j++) - m_pal[i][j] = ((m_palette_vram[(i << 5) + j * 2 + 1] << 8) | m_palette_vram[(i << 5) + j * 2]) & 0x0fff; - } - else - { - for (int i = 0; i < 16; i++) - { - m_pal[i][0] = (m_palette_port[(i << 1)] >> 0) & 0x07; - m_pal[i][1] = (m_palette_port[(i << 1)] >> 4) & 0x07; - m_pal[i][2] = (m_palette_port[(i << 1) + 1] >> 0) & 0x07; - m_pal[i][3] = (m_palette_port[(i << 1) + 1] >> 4) & 0x07; - } - } -} - -void wswan_video_device::draw_background() -{ - UINT16 map_addr = m_layer_bg_address + (((m_current_line + m_layer_bg_scroll_y) & 0xf8) << 3); - UINT8 start_column = (m_layer_bg_scroll_x >> 3); - - for (int column = 0; column < 29; column++) - { - UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; - int x_offset, tile_line, tile_address; - int tile_data = (m_vram[map_addr + (((start_column + column) & 0x1f) << 1) + 1] << 8) - | m_vram[map_addr + (((start_column + column) & 0x1f) << 1)]; - int tile_number = tile_data & 0x01ff; - int tile_palette = (tile_data >> 9) & 0x0f; - - tile_line = (m_current_line + m_layer_bg_scroll_y) & 0x07; - if (tile_data & 0x8000) // vflip - tile_line = 7 - tile_line; - - if (m_colors_16) - { - tile_address = ((tile_data & 0x2000) ? 0x8000 : 0x4000) + (tile_number * 32) + (tile_line << 2); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 24) | (m_vram[tile_address + 1] << 16) | (m_vram[tile_address + 2] << 8) | m_vram[tile_address + 3]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = m_vram[tile_address + 2] << 2; - plane3 = m_vram[tile_address + 3] << 3; - } - } - else - { - tile_address = 0x2000 + (tile_number * 16) + (tile_line << 1); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 8) | m_vram[tile_address + 1]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = 0; - plane3 = 0; - } - } - - for (int x = 0; x < 8; x++) - { - int col; - if (m_tile_packed) - { - if (m_colors_16) - { - col = plane0 & 0x0f; - plane0 = plane0 >> 4; - } - else - { - col = plane0 & 0x03; - plane0 = plane0 >> 2; - } - } - else - { - col = (plane3 & 8) | (plane2 & 4) | (plane1 & 2) | (plane0 & 1); - plane3 = plane3 >> 1; - plane2 = plane2 >> 1; - plane1 = plane1 >> 1; - plane0 = plane0 >> 1; - } - - if (tile_data & 0x4000) - x_offset = x + (column << 3) - (m_layer_bg_scroll_x & 0x07); - else - x_offset = 7 - x + (column << 3) - (m_layer_bg_scroll_x & 0x07); - - if (x_offset >= 0 && x_offset < WSWAN_X_PIXELS) - { - if (m_colors_16) - { - if (col) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - { - /* Hmmmm, what should we do here... Is this correct?? */ - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - } - } - } - else - { - if (col || !(tile_palette & 4)) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - m_bitmap.pix16(m_current_line, x_offset) = m_main_palette[m_pal[tile_palette][col]]; - } - } - } - } - } -} - -void wswan_video_device::draw_foreground_0() -{ - UINT16 map_addr = m_layer_fg_address + (((m_current_line + m_layer_fg_scroll_y) & 0xf8) << 3); - UINT8 start_column = (m_layer_fg_scroll_x >> 3); - - for (int column = 0; column < 29; column++) - { - UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; - int x_offset, tile_line, tile_address; - int tile_data = (m_vram[map_addr + (((start_column + column) & 0x1f) << 1) + 1] << 8) - | m_vram[map_addr + (((start_column + column) & 0x1f) << 1)]; - int tile_number = tile_data & 0x01ff; - int tile_palette = (tile_data >> 9) & 0x0f; - - tile_line = (m_current_line + m_layer_fg_scroll_y) & 0x07; - if (tile_data & 0x8000) // vflip - tile_line = 7 - tile_line; - - if (m_colors_16) - { - tile_address = ((tile_data & 0x2000) ? 0x8000 : 0x4000) + (tile_number * 32) + (tile_line << 2); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 24) | (m_vram[tile_address + 1] << 16) | (m_vram[tile_address + 2] << 8) | m_vram[tile_address + 3]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = m_vram[tile_address + 2] << 2; - plane3 = m_vram[tile_address + 3] << 3; - } - } - else - { - tile_address = 0x2000 + (tile_number * 16) + (tile_line << 1); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 8) | m_vram[tile_address + 1]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = 0; - plane3 = 0; - } - } - - for (int x = 0; x < 8; x++ ) - { - int col; - if (m_tile_packed) - { - if (m_colors_16) - { - col = plane0 & 0x0f; - plane0 = plane0 >> 4; - } - else - { - col = plane0 & 0x03; - plane0 = plane0 >> 2; - } - } - else - { - col = (plane3 & 8) | (plane2 & 4) | (plane1 & 2) | (plane0 & 1); - plane3 = plane3 >> 1; - plane2 = plane2 >> 1; - plane1 = plane1 >> 1; - plane0 = plane0 >> 1; - } - - if (tile_data & 0x4000) - x_offset = x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - else - x_offset = 7 - x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - - if (x_offset >= 0 && x_offset < WSWAN_X_PIXELS) - { - if (m_colors_16) - { - if (col) - { -// if (m_color_mode) { - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; -// } else { -// /* Hmmmm, what should we do here... Is this correct?? */ -// m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; -// } - } - } - else - { - if (col || !(tile_palette & 4)) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - m_bitmap.pix16(m_current_line, x_offset) = m_main_palette[m_pal[tile_palette][col]]; - } - } - } - } - } -} - -void wswan_video_device::draw_foreground_2() -{ - UINT16 map_addr = m_layer_fg_address + (((m_current_line + m_layer_fg_scroll_y) & 0xf8) << 3); - UINT8 start_column = (m_layer_fg_scroll_x >> 3); - - for (int column = 0; column < 29; column++) - { - UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; - int x_offset, tile_line, tile_address; - int tile_data = (m_vram[map_addr + (((start_column + column) & 0x1f) << 1) + 1] << 8) - | m_vram[map_addr + (((start_column + column) & 0x1f) << 1)]; - int tile_number = tile_data & 0x01ff; - int tile_palette = (tile_data >> 9) & 0x0f; - - tile_line = (m_current_line + m_layer_fg_scroll_y) & 0x07; - if (tile_data & 0x8000) // vflip - tile_line = 7 - tile_line; - - - if (m_colors_16) - { - tile_address = ((tile_data & 0x2000) ? 0x8000 : 0x4000) + (tile_number * 32) + (tile_line << 2); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 24) | (m_vram[tile_address + 1] << 16) | (m_vram[tile_address + 2] << 8) | m_vram[tile_address + 3]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = m_vram[tile_address + 2] << 2; - plane3 = m_vram[tile_address + 3] << 3; - } - } - else - { - tile_address = 0x2000 + (tile_number * 16) + (tile_line << 1); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 8) | m_vram[tile_address + 1]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = 0; - plane3 = 0; - } - } - - for (int x = 0; x < 8; x++) - { - int col; - if (m_tile_packed) - { - if (m_colors_16) - { - col = plane0 & 0x0f; - plane0 = plane0 >> 4; - } - else - { - col = plane0 & 0x03; - plane0 = plane0 >> 2; - } - } - else - { - col = (plane3 & 8) | (plane2 & 4) | (plane1 & 2) | (plane0 & 1); - plane3 = plane3 >> 1; - plane2 = plane2 >> 1; - plane1 = plane1 >> 1; - plane0 = plane0 >> 1; - } - - if (tile_data & 0x4000) - x_offset = x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - else - x_offset = 7 - x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - - if (x_offset >= 0 && x_offset >= m_window_fg_left && x_offset < m_window_fg_right && x_offset < WSWAN_X_PIXELS) - { - if (m_colors_16) - { - if (col) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - /* Hmmmm, what should we do here... Is this correct?? */ - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - } - } - else - { - if (col || !(tile_palette & 4)) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - m_bitmap.pix16(m_current_line, x_offset) = m_main_palette[m_pal[tile_palette][col]]; - } - } - } - } - } -} - -void wswan_video_device::draw_foreground_3() -{ - UINT16 map_addr = m_layer_fg_address + (((m_current_line + m_layer_fg_scroll_y) & 0xf8) << 3); - UINT8 start_column = (m_layer_fg_scroll_x >> 3); - - for (int column = 0; column < 29; column++) - { - UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; - int x_offset, tile_line, tile_address; - int tile_data = (m_vram[map_addr + (((start_column + column) & 0x1f) << 1) + 1] << 8) - | m_vram[map_addr + (((start_column + column) & 0x1f) << 1)]; - int tile_number = tile_data & 0x01ff; - int tile_palette = (tile_data >> 9) & 0x0f; - - tile_line = (m_current_line + m_layer_fg_scroll_y) & 0x07; - if (tile_data & 0x8000) // vflip - tile_line = 7 - tile_line; - - if (m_colors_16) - { - tile_address = ((tile_data & 0x2000) ? 0x8000 : 0x4000) + (tile_number * 32) + (tile_line << 2); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 24) | (m_vram[tile_address + 1] << 16) | (m_vram[tile_address + 2] << 8) | m_vram[tile_address + 3]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = m_vram[tile_address + 2] << 2; - plane3 = m_vram[tile_address + 3] << 3; - } - } - else - { - tile_address = 0x2000 + (tile_number * 16) + (tile_line << 1); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 8) | m_vram[tile_address + 1]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = 0; - plane3 = 0; - } - } - - for (int x = 0; x < 8; x++) - { - int col; - if (m_tile_packed) - { - if (m_colors_16) - { - col = plane0 & 0x0f; - plane0 = plane0 >> 4; - } - else - { - col = plane0 & 0x03; - plane0 = plane0 >> 2; - } - } - else - { - col = (plane3 & 8) | (plane2 & 4) | (plane1 & 2) | (plane0 & 1); - plane3 = plane3 >> 1; - plane2 = plane2 >> 1; - plane1 = plane1 >> 1; - plane0 = plane0 >> 1; - } - - if (tile_data & 0x4000) - x_offset = x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - else - x_offset = 7 - x + (column << 3) - (m_layer_fg_scroll_x & 0x07); - - if ((x_offset >= 0 && x_offset < m_window_fg_left) || (x_offset >= m_window_fg_right && x_offset < WSWAN_X_PIXELS)) - { - if (m_colors_16) - { - if (col) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - /* Hmmmm, what should we do here... Is this correct?? */ - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - } - } - else - { - if (col || !(tile_palette & 4)) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - m_bitmap.pix16(m_current_line, x_offset) = m_main_palette[m_pal[tile_palette][col]]; - } - } - } - } - } -} - -void wswan_video_device::handle_sprites(int mask) -{ - if (m_sprite_count == 0) - return; - - for (int i = m_sprite_first + m_sprite_count - 1; i >= m_sprite_first; i--) - { - UINT16 tile_data = (m_sprite_table_buffer[i * 4 + 1] << 8) | m_sprite_table_buffer[i * 4]; - UINT8 y = m_sprite_table_buffer[ i * 4 + 2 ]; - UINT8 x = m_sprite_table_buffer[ i * 4 + 3 ]; - int tile_line = (m_current_line - y) & 0xff; - - if ((tile_line >= 0) && (tile_line < 8) && ((tile_data & 0x2000) == mask)) - { - UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; - int x_offset, tile_address; - int tile_number = tile_data & 0x01ff; - int tile_palette = 8 + ((tile_data >> 9) & 0x07); - int check_clip = 0; - - if (tile_data & 0x8000) - tile_line = 7 - tile_line; - - if (m_colors_16) - { - tile_address = 0x4000 + (tile_number * 32) + (tile_line << 2); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 24) | (m_vram[tile_address + 1] << 16) | (m_vram[tile_address + 2] << 8) | m_vram[tile_address + 3]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = m_vram[tile_address + 2] << 2; - plane3 = m_vram[tile_address + 3] << 3; - } - } - else - { - tile_address = 0x2000 + (tile_number * 16) + (tile_line << 1); - if (m_tile_packed) - { - plane0 = (m_vram[tile_address + 0] << 8) | m_vram[tile_address + 1]; - } - else - { - plane0 = m_vram[tile_address + 0]; - plane1 = m_vram[tile_address + 1] << 1; - plane2 = 0; - plane3 = 0; - } - } - - if (m_window_sprites_enable) - { - if (tile_data & 0x1000) - { - if (m_current_line >= m_window_sprites_top && m_current_line <= m_window_sprites_bottom) - check_clip = 1; - } - else - { - if (m_current_line < m_window_sprites_top || m_current_line > m_window_sprites_bottom) - continue; - } - } - - for (int j = 0; j < 8; j++) - { - int col; - if (m_tile_packed) - { - if (m_colors_16) - { - col = plane0 & 0x0f; - plane0 = plane0 >> 4; - } - else - { - col = plane0 & 0x03; - plane0 = plane0 >> 2; - } - } - else - { - col = (plane3 & 8) | (plane2 & 4) | (plane1 & 2) | (plane0 & 1); - plane3 = plane3 >> 1; - plane2 = plane2 >> 1; - plane1 = plane1 >> 1; - plane0 = plane0 >> 1; - } - - if (tile_data & 0x4000) - x_offset = x + j; - else - x_offset = x + 7 - j; - - x_offset = x_offset & 0xff; - - if (m_window_sprites_enable) - { - if (tile_data & 0x1000 && check_clip) - { - if (x_offset >= m_window_sprites_left && x_offset <= m_window_sprites_right) - continue; - } - else - { - if (x_offset < m_window_sprites_left || x_offset > m_window_sprites_right) - { -// continue; - } - } - } - if (x_offset >= 0 && x_offset < WSWAN_X_PIXELS) - { - if (m_colors_16) - { - if (col) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - /* Hmmmm, what should we do here... Is this correct?? */ - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - } - } - else - { - if (col || !(tile_palette & 4)) - { - if (m_color_mode) - m_bitmap.pix16(m_current_line, x_offset) = m_pal[tile_palette][col]; - else - m_bitmap.pix16(m_current_line, x_offset) = m_main_palette[m_pal[tile_palette][col]]; - } - } - } - } - } - } -} - - -void wswan_video_device::refresh_scanline() -{ - setup_palettes(); - - rectangle rec(0, WSWAN_X_PIXELS, m_current_line, m_current_line); - if (m_lcd_control) - { - /* Not sure if these background color checks and settings are correct */ - if (m_color_mode && m_colors_16) - m_bitmap.fill(m_pal[m_bg_control >> 4][m_bg_control & 0x0f], rec); - else - m_bitmap.fill(m_main_palette[m_bg_control & 0x07], rec); - } - else - { - m_bitmap.fill(0, rec); - return; - } - - // Draw background layer - if (m_layer_bg_enable) - draw_background(); - - // Draw sprites between background and foreground layers - if (m_sprites_enable) - handle_sprites(0); - - // Draw foreground layer, taking window settings into account - if (m_layer_fg_enable) - { - switch (m_window_fg_mode) - { - case 0: // FG inside & outside window area - draw_foreground_0(); - break; - case 1: // ??? - logerror("Unknown foreground mode 1 set\n"); - break; - case 2: // FG only inside window area - if (m_current_line >= m_window_fg_top && m_current_line <= m_window_fg_bottom) - draw_foreground_2(); - break; - case 3: // FG only outside window area - if (m_current_line < m_window_fg_top || m_current_line > m_window_fg_bottom) - draw_foreground_0(); - else - draw_foreground_3(); - break; - } - } - - // Draw sprites in front of foreground layer - if (m_sprites_enable) - handle_sprites(0x2000); -} - - - -UINT32 wswan_video_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} - - -READ8_MEMBER(wswan_video_device::reg_r) -{ - UINT8 value = m_regs[offset]; - - if (offset >= 0x20 && offset < 0x40) - return m_palette_port[offset & 0x1f]; - - switch (offset) - { - case 0x01: - value = m_bg_control; - break; - case 0x02: - value = m_current_line; - break; - case 0x14: - value = m_lcd_control; - break; - case 0xa8: - value = m_timer_hblank_count & 0xff; - break; - case 0xa9: - value = m_timer_hblank_count >> 8; - break; - case 0xaa: - value = m_timer_vblank_count & 0xff; - break; - case 0xab: - value = m_timer_vblank_count >> 8; - break; - } - - return value; -} - - -WRITE8_MEMBER(wswan_video_device::reg_w) -{ - if (offset >= 0x20 && offset < 0x40) - { - // 0x20-0x3f tile/sprite palette settings - // even offs - // Bit 0-3 - Palette (offs & 0x1f)/2 index 0 - // Bit 4-7 - Palette (offs & 0x1f)/2 index 1 - // odd offs - // Bit 0-3 - Palette (offs & 0x1f)/2 index 2 - // Bit 4-7 - Palette (offs & 0x1f)/2 index 3 - m_palette_port[offset & 0x1f] = data; - return; - } - - switch (offset) - { - case 0x00: // Display control - // Bit 0 - Background layer enable - // Bit 1 - Foreground layer enable - // Bit 2 - Sprites enable - // Bit 3 - Sprite window enable - // Bit 4-5 - Foreground window configuration - // 00 - Foreground layer is displayed inside and outside foreground window area - // 01 - Unknown - // 10 - Foreground layer is displayed only inside foreground window area - // 11 - Foreground layer is displayed outside foreground window area - // Bit 6-7 - Unknown - m_layer_bg_enable = data & 0x1; - m_layer_fg_enable = (data & 0x2) >> 1; - m_sprites_enable = (data & 0x4) >> 2; - m_window_sprites_enable = (data & 0x8) >> 3; - m_window_fg_mode = (data & 0x30) >> 4; - break; - case 0x01: // Background colour - // In 16 colour mode: - // Bit 0-3 - Palette index - // Bit 4-7 - Palette number - // Otherwise: - // Bit 0-2 - Main palette index - // Bit 3-7 - Unknown - m_bg_control = data; - break; - case 0x02: // Current scanline (Most likely read-only) - logerror("Write to current scanline! Current value: %d Data to write: %d\n", m_current_line, data); - // Returning so we don't overwrite the value here, not that it really matters - return; - case 0x03: // Line compare - m_line_compare = data; - logerror("Write to line compare: %d\n", data); - break; - case 0x04: // Sprite table base address - // Bit 0-5 - Determine sprite table base address 0 0xxxxxx0 00000000 - // Bit 6-7 - Unknown - m_sprite_table_address = (data & 0x3f) << 9; - break; - case 0x05: // First sprite number (the one we start drawing with) - m_sprite_first_latch = data; - if (data) logerror("non-zero first sprite %d\n", data); - break; - case 0x06: // Number of sprites to draw - m_sprite_count_latch = data; - break; - case 0x07: // Background/Foreground table base addresses - // Bit 0-2 - Determine background table base address 00xxx000 00000000 - // Bit 3 - Unknown - // Bit 4-6 - Determine foreground table base address 00xxx000 00000000 - // Bit 7 - Unknown - m_layer_bg_address = (data & 0x7) << 11; - m_layer_fg_address = (data & 0x70) << 7; - break; - case 0x08: // Left coordinate of foreground window - m_window_fg_left = data; - break; - case 0x09: // Top coordinate of foreground window - m_window_fg_top = data; - break; - case 0x0a: // Right coordinate of foreground window - m_window_fg_right = data; - break; - case 0x0b: // Bottom coordinate of foreground window - m_window_fg_bottom = data; - break; - case 0x0c: // Left coordinate of sprite window - m_window_sprites_left = data; - break; - case 0x0d: // Top coordinate of sprite window - m_window_sprites_top = data; - break; - case 0x0e: // Right coordinate of sprite window - m_window_sprites_right = data; - break; - case 0x0f: // Bottom coordinate of sprite window - m_window_sprites_bottom = data; - break; - case 0x10: // Background layer X scroll - m_layer_bg_scroll_x = data; - break; - case 0x11: // Background layer Y scroll - m_layer_bg_scroll_y = data; - break; - case 0x12: // Foreground layer X scroll - m_layer_fg_scroll_x = data; - break; - case 0x13: // Foreground layer Y scroll - m_layer_fg_scroll_y = data; - break; - case 0x14: // LCD control - // Bit 0 - LCD enable - // Bit 1-7 - Unknown - m_lcd_control = data; - break; - case 0x15: // LCD icons - // Bit 0 - LCD sleep icon enable - // Bit 1 - Vertical position icon enable - // Bit 2 - Horizontal position icon enable - // Bit 3 - Dot 1 icon enable - // Bit 4 - Dot 2 icon enable - // Bit 5 - Dot 3 icon enable - // Bit 6-7 - Unknown - m_icons = data; /* ummmmm */ - break; - case 0x1c: // Palette colors 0 and 1 - // Bit 0-3 - Gray tone setting for main palette index 0 - // Bit 4-7 - Gray tone setting for main palette index 1 - if (m_vdp_type == VDP_TYPE_WSC) - { - int i = 15 - (data & 0x0f); - int j = 15 - ((data & 0xf0) >> 4); - m_main_palette[0] = (i << 8) | (i << 4) | i; - m_main_palette[1] = (j << 8) | (j << 4) | j; - } - else - { - m_main_palette[0] = data & 0x0f; - m_main_palette[1] = (data & 0xf0) >> 4; - } - break; - case 0x1d: // Palette colors 2 and 3 - // Bit 0-3 - Gray tone setting for main palette index 2 - // Bit 4-7 - Gray tone setting for main palette index 3 - if (m_vdp_type == VDP_TYPE_WSC) - { - int i = 15 - (data & 0x0f); - int j = 15 - ((data & 0xf0) >> 4); - m_main_palette[2] = (i << 8) | (i << 4) | i; - m_main_palette[3] = (j << 8) | (j << 4) | j; - } - else - { - m_main_palette[2] = data & 0x0f; - m_main_palette[3] = (data & 0xf0) >> 4; - } - break; - case 0x1e: // Palette colors 4 and 5 - // Bit 0-3 - Gray tone setting for main palette index 4 - // Bit 4-7 - Gray tone setting for main palette index 5 - if (m_vdp_type == VDP_TYPE_WSC) - { - int i = 15 - (data & 0x0f); - int j = 15 - ((data & 0xf0) >> 4); - m_main_palette[4] = (i << 8) | (i << 4) | i; - m_main_palette[5] = (j << 8) | (j << 4) | j; - } - else - { - m_main_palette[4] = data & 0x0f; - m_main_palette[5] = (data & 0xf0) >> 4; - } - break; - case 0x1f: // Palette colors 6 and 7 - // Bit 0-3 - Gray tone setting for main palette index 6 - // Bit 4-7 - Gray tone setting for main palette index 7 - if (m_vdp_type == VDP_TYPE_WSC) - { - int i = 15 - (data & 0x0f); - int j = 15 - ((data & 0xf0) >> 4); - m_main_palette[6] = (i << 8) | (i << 4) | i; - m_main_palette[7] = (j << 8) | (j << 4) | j; - } - else - { - m_main_palette[6] = data & 0x0f; - m_main_palette[7] = (data & 0xf0) >> 4; - } - break; - case 0x60: // Video mode - // Bit 0-4 - Unknown - // Bit 5 - Packed mode 0 = not packed mode, 1 = packed mode - // Bit 6 - 4/16 colour mode select: 0 = 4 colour mode, 1 = 16 colour mode - // Bit 7 - monochrome/colour mode select: 0 = monochrome mode, 1 = colour mode - /* - * 111 - packed, 16 color, use 4000/8000, color - * 110 - not packed, 16 color, use 4000/8000, color - * 101 - packed, 4 color, use 2000, color - * 100 - not packed, 4 color, use 2000, color - * 011 - packed, 16 color, use 4000/8000, monochrome - * 010 - not packed, 16 color , use 4000/8000, monochrome - * 001 - packed, 4 color, use 2000, monochrome - * 000 - not packed, 4 color, use 2000, monochrome - Regular WS monochrome - */ - if (m_vdp_type == VDP_TYPE_WSC) - { - m_color_mode = data & 0x80; - m_colors_16 = data & 0x40; - m_tile_packed = data & 0x20; - } - break; - case 0xa2: // Timer control - // Bit 0 - HBlank Timer enable - // Bit 1 - HBlank Timer mode: 0 = one shot, 1 = auto reset - // Bit 2 - VBlank Timer(1/75s) enable - // Bit 3 - VBlank Timer mode: 0 = one shot, 1 = auto reset - // Bit 4-7 - Unknown - m_timer_hblank_enable = BIT(data, 0); - m_timer_hblank_mode = BIT(data, 1); - m_timer_vblank_enable = BIT(data, 2); - m_timer_vblank_mode = BIT(data, 3); - break; - case 0xa4: // HBlank timer frequency reload value (bits 0-7) - m_timer_hblank_reload &= 0xff00; - m_timer_hblank_reload += data; - m_timer_hblank_count = m_timer_hblank_reload; - break; - case 0xa5: // HBlank timer frequency reload value (bits 8-15) - m_timer_hblank_reload &= 0xff; - m_timer_hblank_reload += data << 8; - m_timer_hblank_count = m_timer_hblank_reload; - break; - case 0xa6: // VBlank timer frequency reload value (bits 0-7) - m_timer_vblank_reload &= 0xff00; - m_timer_vblank_reload += data; - m_timer_vblank_count = m_timer_vblank_reload; - break; - case 0xa7: // VBlank timer frequency reload value (bits 8-15) - m_timer_vblank_reload &= 0xff; - m_timer_vblank_reload += data << 8; - m_timer_vblank_count = m_timer_vblank_reload; - break; - case 0xa8: // HBlank counter (bits 0-7) - case 0xa9: // HBlank counter (bits 8-15) - case 0xaa: // VBlank counter (bits 0-7) - case 0xab: // VBlank counter (bits 8-15) - break; - } - - m_regs[offset] = data; -} - - -void wswan_video_device::scanline_interrupt() -{ - if (m_current_line < 144) - refresh_scanline(); - - // Decrement 12kHz (HBlank) counter - if (m_timer_hblank_enable && m_timer_hblank_reload != 0) - { - m_timer_hblank_count--; - logerror("timer_hblank_count: %X\n", m_timer_hblank_count); - if (m_timer_hblank_count == 0) - { - if (m_timer_hblank_mode) - m_timer_hblank_count = m_timer_hblank_reload; - else - m_timer_hblank_reload = 0; - - logerror( "triggering hbltmr interrupt\n" ); - m_set_irq_cb(WSWAN_VIDEO_IFLAG_HBLTMR); - } - } - - // Handle Sound DMA - m_snd_dma_cb(); - -// m_current_line = (m_current_line + 1) % 159; - - if (m_current_line == 144) // buffer sprite table - { - memcpy(m_sprite_table_buffer, &m_vram[m_sprite_table_address], 512); - m_sprite_first = m_sprite_first_latch; // always zero? - m_sprite_count = m_sprite_count_latch; - } - - if (m_current_line == 144) - { - m_set_irq_cb(WSWAN_VIDEO_IFLAG_VBL); - /* Decrement 75Hz (VBlank) counter */ - if (m_timer_vblank_enable && m_timer_vblank_reload != 0) - { - m_timer_vblank_count--; - logerror("timer_vblank_count: %X\n", m_timer_vblank_count); - if (m_timer_vblank_count == 0) - { - if (m_timer_vblank_mode) - m_timer_vblank_count = m_timer_vblank_reload; - else - m_timer_vblank_reload = 0; - - logerror("triggering vbltmr interrupt\n"); - m_set_irq_cb(WSWAN_VIDEO_IFLAG_VBLTMR); - } - } - } - -// m_current_line = (m_current_line + 1) % 159; - - if (m_current_line == m_line_compare) - m_set_irq_cb(WSWAN_VIDEO_IFLAG_LCMP); - - m_current_line = (m_current_line + 1) % 159; -} - - -READ8_MEMBER(wswan_video_device::vram_r) -{ - return m_vram[offset]; -} - -WRITE8_MEMBER(wswan_video_device::vram_w) -{ - m_vram[offset] = data; -} diff --git a/src/mess/video/wswan_video.h b/src/mess/video/wswan_video.h deleted file mode 100644 index 2d51c9800c4..00000000000 --- a/src/mess/video/wswan_video.h +++ /dev/null @@ -1,149 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Anthony Kruize, Wilbert Pol -/********************************************************************** - - wswan.h - - File to handle video emulation of the Bandai WonderSwan. - - Anthony Kruize - Wilbert Pol - -**********************************************************************/ - -#ifndef __WSWAN_VIDEO__ -#define __WSWAN_VIDEO__ - -#include "emu.h" - -enum -{ - VDP_TYPE_WSWAN = 0, - VDP_TYPE_WSC -}; - -#define WSWAN_X_PIXELS (28*8) -#define WSWAN_Y_PIXELS (18*8) - - - -typedef device_delegate wswan_video_irq_cb_delegate; -#define WSWAN_VIDEO_IRQ_CB_MEMBER(_name) void _name(int irq) - -typedef device_delegate wswan_video_dmasnd_cb_delegate; -#define WSWAN_VIDEO_DMASND_CB_MEMBER(_name) void _name(void) - -#define MCFG_WSWAN_VIDEO_IRQ_CB(_class, _method) \ - wswan_video_device::set_irq_callback(*device, wswan_video_irq_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); - -#define MCFG_WSWAN_VIDEO_DMASND_CB(_class, _method) \ - wswan_video_device::set_dmasnd_callback(*device, wswan_video_dmasnd_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); - -#define MCFG_WSWAN_VIDEO_TYPE( _type) \ - wswan_video_device::set_vdp_type(*device, _type); - - -class wswan_video_device : public device_t -{ -public: - wswan_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~wswan_video_device() {} - - // static configuration - static void set_irq_callback(device_t &device, wswan_video_irq_cb_delegate callback) { downcast(device).m_set_irq_cb = callback; } - static void set_dmasnd_callback(device_t &device, wswan_video_dmasnd_cb_delegate callback) { downcast(device).m_snd_dma_cb = callback; } - static void set_vdp_type(device_t &device, int type) { downcast(device).m_vdp_type = type; } - - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - - virtual DECLARE_READ8_MEMBER(vram_r); - virtual DECLARE_WRITE8_MEMBER(vram_w); - virtual DECLARE_READ8_MEMBER(reg_r); - virtual DECLARE_WRITE8_MEMBER(reg_w); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - - void setup_palettes(); - void draw_background(); - void draw_foreground_0(); - void draw_foreground_2(); - void draw_foreground_3(); - void handle_sprites(int mask); - void refresh_scanline(); - void scanline_interrupt(); - void common_save(); - - bitmap_ind16 m_bitmap; - UINT8 m_layer_bg_enable; /* Background layer on/off */ - UINT8 m_layer_fg_enable; /* Foreground layer on/off */ - UINT8 m_sprites_enable; /* Sprites on/off */ - UINT8 m_window_sprites_enable; /* Sprite window on/off */ - UINT8 m_window_fg_mode; /* 0:inside/outside, 1:??, 2:inside, 3:outside */ - UINT8 m_bg_control; - UINT8 m_current_line; /* Current scanline : 0-158 (159?) */ - UINT8 m_line_compare; /* Line to trigger line interrupt on */ - UINT32 m_sprite_table_address; /* Address of the sprite table */ - UINT8 m_sprite_table_buffer[512]; - UINT8 m_sprite_first; /* First sprite to draw */ - UINT8 m_sprite_count; /* Number of sprites to draw */ - UINT8 m_sprite_first_latch; - UINT8 m_sprite_count_latch; - UINT16 m_layer_bg_address; /* Address of the background screen map */ - UINT16 m_layer_fg_address; /* Address of the foreground screen map */ - UINT8 m_window_fg_left; /* Left coordinate of foreground window */ - UINT8 m_window_fg_top; /* Top coordinate of foreground window */ - UINT8 m_window_fg_right; /* Right coordinate of foreground window */ - UINT8 m_window_fg_bottom; /* Bottom coordinate of foreground window */ - UINT8 m_window_sprites_left; /* Left coordinate of sprites window */ - UINT8 m_window_sprites_top; /* Top coordinate of sprites window */ - UINT8 m_window_sprites_right; /* Right coordinate of sprites window */ - UINT8 m_window_sprites_bottom; /* Bottom coordinate of sprites window */ - UINT8 m_layer_bg_scroll_x; /* Background layer X scroll */ - UINT8 m_layer_bg_scroll_y; /* Background layer Y scroll */ - UINT8 m_layer_fg_scroll_x; /* Foreground layer X scroll */ - UINT8 m_layer_fg_scroll_y; /* Foreground layer Y scroll */ - UINT8 m_lcd_control; /* LCD on/off */ - UINT8 m_icons; /* FIXME: What do we do with these? Maybe artwork? */ - UINT8 m_color_mode; /* monochrome/color mode */ - UINT8 m_colors_16; /* 4/16 colors mode */ - UINT8 m_tile_packed; /* layered/packed tile mode switch */ - UINT8 m_timer_hblank_enable; /* Horizontal blank interrupt on/off */ - UINT8 m_timer_hblank_mode; /* Horizontal blank timer mode */ - UINT16 m_timer_hblank_reload; /* Horizontal blank timer reload value */ - UINT16 m_timer_hblank_count; /* Horizontal blank timer counter value */ - UINT8 m_timer_vblank_enable; /* Vertical blank interrupt on/off */ - UINT8 m_timer_vblank_mode; /* Vertical blank timer mode */ - UINT16 m_timer_vblank_reload; /* Vertical blank timer reload value */ - UINT16 m_timer_vblank_count; /* Vertical blank timer counter value */ - int m_main_palette[8]; - emu_timer *m_timer; - - dynamic_buffer m_vram; - UINT8 *m_palette_vram; - UINT8 m_palette_port[0x20]; - int m_pal[16][16]; - UINT8 m_regs[256]; - - wswan_video_irq_cb_delegate m_set_irq_cb; - wswan_video_dmasnd_cb_delegate m_snd_dma_cb; - int m_vdp_type; - - // timer IDs - static const device_timer_id TIMER_SCANLINE = 0; - - // interrupt flags - // these are the same as the wswan.h ones - static const UINT8 WSWAN_VIDEO_IFLAG_LCMP = 0x10; - static const UINT8 WSWAN_VIDEO_IFLAG_VBLTMR = 0x20; - static const UINT8 WSWAN_VIDEO_IFLAG_VBL = 0x40; - static const UINT8 WSWAN_VIDEO_IFLAG_HBLTMR = 0x80; -}; - -extern const device_type WSWAN_VIDEO; - - -#endif diff --git a/src/mess/video/x68k.c b/src/mess/video/x68k.c deleted file mode 100644 index fce9998286a..00000000000 --- a/src/mess/video/x68k.c +++ /dev/null @@ -1,1267 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Barry Rodewald,Carl -/* - - Sharp X68000 video functions - driver by Barry Rodewald - - X68000 video hardware (there are some minor revisions to these custom chips across various X680x0 models): - Custom sprite controller "Cynthia" - Custom CRT controller "Vinas / Vicon" - Custom video controller "VSOP / VIPS" - Custom video data selector "Cathy" - - In general terms: - 1 "Text" layer - effectively a 4bpp bitmap split into 4 planes at 1bpp each - 512kB "text" VRAM - can write to multiple planes at once - can copy one character line to another character line - is 1024x1024 in size - Up to 4 graphic layers - can be 4 layers with a 16 colour palette, 2 layers with a 256 colour palette, - or 1 layer at 16-bit RGB. - 512k graphic VRAM - all layers are 512x512, but at 16 colours, the 4 layers can be combined into 1 1024x1024 layer - one or more layers can be cleared at once quickly with a simple hardware function - 2 tilemapped layers - can be 8x8 or 16x16, 16 colours per tile, max 256 colours overall - 1 sprite layer - up to 128 16x16 sprites, 16 colours per sprite, maximum 16 sprites per scanline (not yet implemented). - - Questions: What do the other bits in m_video.reg[2] do? - What is "special priority mode"? - How is the intensity applied during blending if at all? - Black appears to be opaque only at priority 2 but not 3, is that right? - Are the gfx layers blended from the bottom up or all at once? - -*/ - -#include "emu.h" - -#include "machine/mc68901.h" -#include "includes/x68k.h" -#include "machine/ram.h" - - -PALETTE_DECODER_MEMBER(x68k_state, GGGGGRRRRRBBBBBI) -{ - UINT8 i = raw & 1; - UINT8 r = pal6bit(((raw >> 5) & 0x3e) | i); - UINT8 g = pal6bit(((raw >> 10) & 0x3e) | i); - UINT8 b = pal6bit(((raw >> 0) & 0x3e) | i); - return rgb_t(r, g, b); -} - -inline void x68k_state::x68k_plot_pixel(bitmap_rgb32 &bitmap, int x, int y, UINT32 color) -{ - bitmap.pix32(y, x) = (UINT16)color; -} -/* -bitmap_rgb32* ::x68k_get_gfx_page(int pri,int type) -{ - if(type == GFX16) - { - switch(pri) - { - case 0: - return x68k_gfx_0_bitmap_16; - case 1: - return x68k_gfx_1_bitmap_16; - case 2: - return x68k_gfx_2_bitmap_16; - case 3: - return x68k_gfx_3_bitmap_16; - default: - return x68k_gfx_0_bitmap_16; // should never reach here. - } - } - if(type == GFX256) - { - switch(pri) - { - case 0: - case 1: - return x68k_gfx_0_bitmap_256; - case 2: - case 3: - return x68k_gfx_1_bitmap_256; - default: - return x68k_gfx_0_bitmap_256; // should never reach here. - } - } - if(type == GFX65536) - return x68k_gfx_0_bitmap_65536; - - return NULL; // should never reach here either. -} -*/ -void x68k_state::x68k_crtc_text_copy(int src, int dest, UINT8 planes) -{ - // copys one raster in T-VRAM to another raster - int src_ram = src * 256; // 128 bytes per scanline - int dest_ram = dest * 256; - - // update RAM in each plane - if(planes & 1) - memcpy(&m_tvram[dest_ram],&m_tvram[src_ram],512); - if(planes & 2) - memcpy(&m_tvram[dest_ram+0x10000],&m_tvram[src_ram+0x10000],512); - if(planes & 4) - memcpy(&m_tvram[dest_ram+0x20000],&m_tvram[src_ram+0x20000],512); - if(planes & 8) - memcpy(&m_tvram[dest_ram+0x30000],&m_tvram[src_ram+0x30000],512); -} - -TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_operation_end) -{ - int bit = param; - m_crtc.operation &= ~bit; -} - -void x68k_state::x68k_crtc_refresh_mode() -{ -// rectangle rect; -// double scantime; - rectangle scr,visiblescr; - int length; - - // Calculate data from register values - m_crtc.vmultiple = 1; - if((m_crtc.reg[20] & 0x10) != 0 && (m_crtc.reg[20] & 0x0c) == 0) - m_crtc.vmultiple = 2; // 31.5kHz + 256 lines = doublescan - if(m_crtc.interlace != 0) - m_crtc.vmultiple = 0.5f; // 31.5kHz + 1024 lines or 15kHz + 512 lines = interlaced - m_crtc.htotal = (m_crtc.reg[0] + 1) * 8; - m_crtc.vtotal = (m_crtc.reg[4] + 1) / m_crtc.vmultiple; // default is 567 (568 scanlines) - m_crtc.hbegin = (m_crtc.reg[2] * 8) + 1; - m_crtc.hend = (m_crtc.reg[3] * 8); - m_crtc.vbegin = (m_crtc.reg[6]) / m_crtc.vmultiple; - m_crtc.vend = (m_crtc.reg[7] - 1) / m_crtc.vmultiple; - if((m_crtc.vmultiple == 2) && !(m_crtc.reg[7] & 1)) // otherwise if the raster irq line == vblank line, the raster irq fires too late - m_crtc.vend++; - m_crtc.hsync_end = (m_crtc.reg[1]) * 8; - m_crtc.vsync_end = (m_crtc.reg[5]) / m_crtc.vmultiple; - m_crtc.hsyncadjust = m_crtc.reg[8]; - scr.set(0, m_crtc.htotal - 8, 0, m_crtc.vtotal); - if(scr.max_y <= m_crtc.vend) - scr.max_y = m_crtc.vend + 2; - if(scr.max_x <= m_crtc.hend) - scr.max_x = m_crtc.hend + 2; - visiblescr.set(m_crtc.hbegin, m_crtc.hend, m_crtc.vbegin, m_crtc.vend); - - // expand visible area to the size indicated by CRTC reg 20 - length = m_crtc.hend - m_crtc.hbegin; - if (length < m_crtc.width) - { - visiblescr.min_x = m_crtc.hbegin - ((m_crtc.width - length)/2); - visiblescr.max_x = m_crtc.hend + ((m_crtc.width - length)/2); - } - length = m_crtc.vend - m_crtc.vbegin; - if (length < m_crtc.height) - { - visiblescr.min_y = m_crtc.vbegin - ((m_crtc.height - length)/2); - visiblescr.max_y = m_crtc.vend + ((m_crtc.height - length)/2); - } - // bounds check - if(visiblescr.min_x < 0) - visiblescr.min_x = 0; - if(visiblescr.min_y < 0) - visiblescr.min_y = 0; - if(visiblescr.max_x >= scr.max_x) - visiblescr.max_x = scr.max_x - 2; - if(visiblescr.max_y >= scr.max_y - 1) - visiblescr.max_y = scr.max_y - 2; - -// logerror("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i\n",m_crtc.reg[0],m_crtc.reg[1],m_crtc.reg[2],m_crtc.reg[3], -// m_crtc.reg[4],m_crtc.reg[5],m_crtc.reg[6],m_crtc.reg[7],m_crtc.reg[8],m_crtc.reg[9]); - logerror("video_screen_configure(machine.first_screen(),%i,%i,[%i,%i,%i,%i],55.45)\n",scr.max_x,scr.max_y,visiblescr.min_x,visiblescr.min_y,visiblescr.max_x,visiblescr.max_y); - m_screen->configure(scr.max_x,scr.max_y,visiblescr,HZ_TO_ATTOSECONDS(55.45)); -} - -TIMER_CALLBACK_MEMBER(x68k_state::x68k_hsync) -{ - int hstate = param; - attotime hsync_time; - - m_crtc.hblank = hstate; - m_mfpdev->i7_w(!m_crtc.hblank); - - if(m_crtc.operation & 8) - x68k_crtc_text_copy((m_crtc.reg[22] & 0xff00) >> 8,(m_crtc.reg[22] & 0x00ff),(m_crtc.reg[21] & 0xf)); - - if(m_crtc.vmultiple == 2) // 256-line (doublescan) - { - if(hstate == 1) - { - if(m_oddscanline == 1) - { - int scan = m_screen->vpos(); - if(scan > m_crtc.vend) - scan = m_crtc.vbegin; - hsync_time = m_screen->time_until_pos(scan,(m_crtc.htotal + m_crtc.hend) / 2); - m_scanline_timer->adjust(hsync_time); - if(scan != 0) - { - if((ioport("options")->read() & 0x04)) - { - m_screen->update_partial(scan); - } - } - } - else - { - int scan = m_screen->vpos(); - if(scan > m_crtc.vend) - scan = m_crtc.vbegin; - hsync_time = m_screen->time_until_pos(scan,m_crtc.hend / 2); - m_scanline_timer->adjust(hsync_time); - if(scan != 0) - { - if((ioport("options")->read() & 0x04)) - { - m_screen->update_partial(scan); - } - } - } - } - if(hstate == 0) - { - if(m_oddscanline == 1) - { - int scan = m_screen->vpos(); - if(scan > m_crtc.vend) - scan = m_crtc.vbegin; - else - scan++; - hsync_time = m_screen->time_until_pos(scan,m_crtc.hbegin / 2); - m_scanline_timer->adjust(hsync_time, 1); - m_oddscanline = 0; - } - else - { - hsync_time = m_screen->time_until_pos(m_screen->vpos(),(m_crtc.htotal + m_crtc.hbegin) / 2); - m_scanline_timer->adjust(hsync_time, 1); - m_oddscanline = 1; - } - } - } - else // 512-line - { - if(hstate == 1) - { - int scan = m_screen->vpos(); - if(scan > m_crtc.vend) - scan = 0; - hsync_time = m_screen->time_until_pos(scan,m_crtc.hend); - m_scanline_timer->adjust(hsync_time); - if(scan != 0) - { - if((ioport("options")->read() & 0x04)) - { - m_screen->update_partial(scan); - } - } - } - if(hstate == 0) - { - hsync_time = m_screen->time_until_pos(m_screen->vpos()+1,m_crtc.hbegin); - m_scanline_timer->adjust(hsync_time, 1); - } - } -} - -TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_raster_end) -{ - m_mfpdev->i6_w(1); -} - -TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_raster_irq) -{ - int scan = param; - attotime irq_time; - attotime end_time; - - if(scan <= m_crtc.vtotal) - { - m_mfpdev->i6_w(0); - m_screen->update_partial(scan); - irq_time = m_screen->time_until_pos(scan,m_crtc.hbegin); - // end of HBlank period clears GPIP6 also? - end_time = m_screen->time_until_pos(scan,m_crtc.hend); - m_raster_irq->adjust(irq_time, scan); - timer_set(end_time, TIMER_X68K_CRTC_RASTER_END); - logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,m_screen->vpos()); - } -} - -TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_vblank_irq) -{ - int val = param; - attotime irq_time; - int vblank_line; - - if(val == 1) // V-DISP on - { - m_crtc.vblank = 1; - vblank_line = m_crtc.vbegin; - irq_time = m_screen->time_until_pos(vblank_line,2); - m_vblank_irq->adjust(irq_time); - logerror("CRTC: VBlank on\n"); - } - if(val == 0) // V-DISP off - { - m_crtc.vblank = 0; - vblank_line = m_crtc.vend; - if(vblank_line > m_crtc.vtotal) - vblank_line = m_crtc.vtotal; - irq_time = m_screen->time_until_pos(vblank_line,2); - m_vblank_irq->adjust(irq_time, 1); - logerror("CRTC: VBlank off\n"); - } - - m_mfpdev->tai_w(!m_crtc.vblank); - m_mfpdev->i4_w(!m_crtc.vblank); -} - - -// CRTC "VINAS 1+2 / VICON" at 0xe80000 -/* 0xe80000 - Registers (all are 16-bit): - * 0 - Horizontal Total (in characters) - * 1 - Horizontal Sync End - * 2 - Horizontal Display Begin - * 3 - Horizontal Display End - * 4 - Vertical Total (in scanlines) - * 5 - Vertical Sync End - * 6 - Vertical Display Begin - * 7 - Vertical Display End - * 8 - Fine Horizontal Sync Adjustment - * 9 - Raster Line (for Raster IRQ mapped to MFP GPIP6) - * 10/11 - Text Layer X and Y Scroll - * 12/13 - Graphic Layer 0 X and Y Scroll - * 14/15 - Graphic Layer 1 X and Y Scroll - * 16/17 - Graphic Layer 2 X and Y Scroll - * 18/19 - Graphic Layer 3 X and Y Scroll - * 20 - bit 12 - Text VRAM mode : 0 = display, 1 = buffer - * bit 11 - Graphic VRAM mode : 0 = display, 1 = buffer - * bit 10 - "Real" screen size : 0 = 512x512, 1 = 1024x1024 - * bits 8,9 - Colour mode : - * 00 = 16 colour 01 = 256 colour - * 10 = Undefined 11 = 65,536 colour - * bit 4 - Horizontal Frequency : 0 = 15.98kHz, 1 = 31.50kHz - * bits 2,3 - Vertical dots : - * 00 = 256 01 = 512 - * 10 or 11 = 1024 (interlaced) - * bits 0,1 - Horizontal dots : - * 00 = 256 01 = 512 - * 10 = 768 11 = 50MHz clock mode (Compact XVI or later) - * 21 - bit 9 - Text Screen Access Mask Enable - * bit 8 - Text Screen Simultaneous Plane Access Enable - * bits 4-7 - Text Screen Simultaneous Plane Access Select - * bits 0-3 - Text Screen Line Copy Plane Select - * Graphic Screen High-speed Clear Page Select - * 22 - Text Screen Line Copy - * bits 15-8 - Source Line - * bits 7-0 - Destination Line - * 23 - Text Screen Mask Pattern - * - * 0xe80481 - Operation Port (8-bit): - * bit 3 - Text Screen Line Copy Begin - * bit 1 - Graphic Screen High-speed Clear Begin - * bit 0 - Image Taking Begin (?) - * Operation Port bits are cleared automatically when the requested - * operation is completed. - */ -WRITE16_MEMBER(x68k_state::x68k_crtc_w ) -{ - if (offset < 0x24) - COMBINE_DATA(m_crtc.reg+offset); - switch(offset) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - x68k_crtc_refresh_mode(); - break; - case 9: // CRTC raster IRQ (GPIP6) - { - attotime irq_time; - data = m_crtc.reg[9]; - irq_time = m_screen->time_until_pos((data) / m_crtc.vmultiple,2); - - if(irq_time.as_double() > 0) - m_raster_irq->adjust(irq_time, (data) / m_crtc.vmultiple); - } - logerror("CRTC: Write to raster IRQ register - %i\n",data); - break; - case 20: - if(ACCESSING_BITS_0_7) - { - m_crtc.interlace = 0; - switch(data & 0x0c) - { - case 0x00: - m_crtc.height = 256; - break; - case 0x08: - case 0x0c: // TODO: 1024 vertical, if horizontal freq = 31kHz - m_crtc.height = 512; - m_crtc.interlace = 1; // if 31kHz, 1024 lines = interlaced - break; - case 0x04: - m_crtc.height = 512; - if(!(m_crtc.reg[20] & 0x0010)) // if 15kHz, 512 lines = interlaced - m_crtc.interlace = 1; - break; - } - switch(data & 0x03) - { - case 0x00: - m_crtc.width = 256; - break; - case 0x01: - m_crtc.width = 512; - break; - case 0x02: - case 0x03: // 0x03 = 50MHz clock mode (XVI only) - m_crtc.width = 768; - break; - } - } -/* if(ACCESSING_BITS_8_15) - { - m_crtc.interlace = 0; - if(data & 0x0400) - m_crtc.interlace = 1; - }*/ - x68k_crtc_refresh_mode(); - break; - case 576: // operation register - m_crtc.operation = data; - if(data & 0x02) // high-speed graphic screen clear - { - memset(&m_gvram[0],0,0x40000); - timer_set(attotime::from_msec(10), TIMER_X68K_CRTC_OPERATION_END, 0x02); // time taken to do operation is a complete guess. - } - break; - } -// logerror("CRTC: [%08x] Wrote %04x to CRTC register %i\n",m_maincpu->safe_pc(),data,offset); -} - -READ16_MEMBER(x68k_state::x68k_crtc_r ) -{ - if(offset < 24) - { -// logerror("CRTC: [%08x] Read %04x from CRTC register %i\n",m_maincpu->safe_pc(),m_crtc.reg[offset],offset); - switch(offset) - { - case 9: - return 0; - case 10: // Text X/Y scroll - case 11: - case 12: // Graphic layer 0 scroll - case 13: - return m_crtc.reg[offset] & 0x3ff; - case 14: // Graphic layer 1 scroll - case 15: - case 16: // Graphic layer 2 scroll - case 17: - case 18: // Graphic layer 3 scroll - case 19: - return m_crtc.reg[offset] & 0x1ff; - default: - return m_crtc.reg[offset]; - } - } - if(offset == 576) // operation port, operation bits are set to 0 when operation is complete - return m_crtc.operation; -// logerror("CRTC: [%08x] Read from unknown CRTC register %i\n",activecpu_get_pc(),offset); - return 0xffff; -} - -WRITE16_MEMBER(x68k_state::x68k_gvram_w ) -{ -// int xloc,yloc,pageoffset; - /* - G-VRAM usage is determined by colour depth and "real" screen size. - - For screen size of 1024x1024, all G-VRAM space is used, in one big page. - At 1024x1024 real screen size, colour depth is always 4bpp, and ranges from - 0xc00000-0xdfffff. - - For screen size of 512x512, the colour depth determines the page usage. - 16 colours = 4 pages - 256 colours = 2 pages - 65,536 colours = 1 page - Page 1 - 0xc00000-0xc7ffff Page 2 - 0xc80000-0xcfffff - Page 3 - 0xd00000-0xd7ffff Page 4 - 0xd80000-0xdfffff - */ - - // handle different G-VRAM page setups - if(m_crtc.reg[20] & 0x0800) // G-VRAM set to buffer - { - if(offset < 0x40000) - COMBINE_DATA(&m_gvram[offset]); - } - else - { - switch(m_crtc.reg[20] & 0x0300) - { - case 0x0300: - if(offset < 0x40000) - COMBINE_DATA(&m_gvram[offset]); - break; - case 0x0100: - if(offset < 0x40000) - { - m_gvram[offset] = (m_gvram[offset] & 0xff00) | (data & 0x00ff); - } - if(offset >= 0x40000 && offset < 0x80000) - { - m_gvram[offset-0x40000] = (m_gvram[offset-0x40000] & 0x00ff) | ((data & 0x00ff) << 8); - } - break; - case 0x0000: - if(offset < 0x40000) - { - m_gvram[offset] = (m_gvram[offset] & 0xfff0) | (data & 0x000f); - } - if(offset >= 0x40000 && offset < 0x80000) - { - m_gvram[offset-0x40000] = (m_gvram[offset-0x40000] & 0xff0f) | ((data & 0x000f) << 4); - } - if(offset >= 0x80000 && offset < 0xc0000) - { - m_gvram[offset-0x80000] = (m_gvram[offset-0x80000] & 0xf0ff) | ((data & 0x000f) << 8); - } - if(offset >= 0xc0000 && offset < 0x100000) - { - m_gvram[offset-0xc0000] = (m_gvram[offset-0xc0000] & 0x0fff) | ((data & 0x000f) << 12); - } - break; - default: - logerror("G-VRAM written while layer setup is undefined.\n"); - } - } -} - -WRITE16_MEMBER(x68k_state::x68k_tvram_w ) -{ - UINT16 text_mask; - - text_mask = ~(m_crtc.reg[23]) & mem_mask; - - if(!(m_crtc.reg[21] & 0x0200)) // text access mask enable - text_mask = 0xffff & mem_mask; - - mem_mask = text_mask; - - if(m_crtc.reg[21] & 0x0100) - { // simultaneous T-VRAM plane access (I think ;)) - int plane,wr; - offset = offset & 0x00ffff; - wr = (m_crtc.reg[21] & 0x00f0) >> 4; - for(plane=0;plane<4;plane++) - { - if(wr & (1 << plane)) - { - COMBINE_DATA(&m_tvram[offset+0x10000*plane]); - } - } - } - else - { - COMBINE_DATA(&m_tvram[offset]); - } -} - -READ16_MEMBER(x68k_state::x68k_gvram_r ) -{ - UINT16 ret = 0; - - if(m_crtc.reg[20] & 0x0800) // G-VRAM set to buffer - return m_gvram[offset]; - - switch(m_crtc.reg[20] & 0x0300) // colour setup determines G-VRAM use - { - case 0x0300: // 65,536 colour (RGB) - 16-bits per word - if(offset < 0x40000) - ret = m_gvram[offset]; - else - ret = 0xffff; - break; - case 0x0100: // 256 colour (paletted) - 8 bits per word - if(offset < 0x40000) - ret = m_gvram[offset] & 0x00ff; - if(offset >= 0x40000 && offset < 0x80000) - ret = (m_gvram[offset-0x40000] & 0xff00) >> 8; - if(offset >= 0x80000) - ret = 0xffff; - break; - case 0x0000: // 16 colour (paletted) - 4 bits per word - if(offset < 0x40000) - ret = m_gvram[offset] & 0x000f; - if(offset >= 0x40000 && offset < 0x80000) - ret = (m_gvram[offset-0x40000] & 0x00f0) >> 4; - if(offset >= 0x80000 && offset < 0xc0000) - ret = (m_gvram[offset-0x80000] & 0x0f00) >> 8; - if(offset >= 0xc0000 && offset < 0x100000) - ret = (m_gvram[offset-0xc0000] & 0xf000) >> 12; - break; - default: - logerror("G-VRAM read while layer setup is undefined.\n"); - ret = 0xffff; - } - - return ret; -} - -READ16_MEMBER(x68k_state::x68k_tvram_r ) -{ - return m_tvram[offset]; -} - -WRITE16_MEMBER(x68k_state::x68k_spritereg_w ) -{ - COMBINE_DATA(&m_spritereg[offset]); - switch(offset) - { - case 0x400: - m_bg0_8->set_scrollx(0,(data - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - m_bg0_16->set_scrollx(0,(data - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - break; - case 0x401: - m_bg0_8->set_scrolly(0,(data - m_crtc.vbegin) & 0x3ff); - m_bg0_16->set_scrolly(0,(data - m_crtc.vbegin) & 0x3ff); - break; - case 0x402: - m_bg1_8->set_scrollx(0,(data - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - m_bg1_16->set_scrollx(0,(data - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - break; - case 0x403: - m_bg1_8->set_scrolly(0,(data - m_crtc.vbegin) & 0x3ff); - m_bg1_16->set_scrolly(0,(data - m_crtc.vbegin) & 0x3ff); - break; - case 0x406: // BG H-DISP (normally equals CRTC reg 2 value + 4) - if(data != 0x00ff) - { - m_crtc.bg_visible_width = (m_crtc.reg[3] - ((data & 0x003f) - 4)) * 8; - m_crtc.bg_hshift = ((data - (m_crtc.reg[2]+4)) * 8); - if(m_crtc.bg_hshift > 0) - m_crtc.bg_hshift = 0; - } - break; - case 0x407: // BG V-DISP (like CRTC reg 6) - m_crtc.bg_vshift = m_crtc.vshift; - break; - case 0x408: // BG H/V-Res - m_crtc.bg_hvres = data & 0x1f; - if(data != 0xff) - { // Handle when the PCG is using 256 and the CRTC is using 512 - if((m_crtc.bg_hvres & 0x0c) == 0x00 && (m_crtc.reg[20] & 0x0c) == 0x04) - m_crtc.bg_double = 2; - else - m_crtc.bg_double = 1; - } - else - m_crtc.bg_double = 1; - break; - } -} - -READ16_MEMBER(x68k_state::x68k_spritereg_r ) -{ - if(offset >= 0x400 && offset < 0x404) - return m_spritereg[offset] & 0x3ff; - return m_spritereg[offset]; -} - -WRITE16_MEMBER(x68k_state::x68k_spriteram_w ) -{ - COMBINE_DATA(m_spriteram+offset); - m_video.tile8_dirty[offset / 16] = 1; - m_video.tile16_dirty[offset / 64] = 1; - if(offset < 0x2000) - { - m_bg1_8->mark_all_dirty(); - m_bg1_16->mark_all_dirty(); - m_bg0_8->mark_all_dirty(); - m_bg0_16->mark_all_dirty(); - } - if(offset >= 0x2000 && offset < 0x3000) - { - m_bg1_8->mark_tile_dirty(offset & 0x0fff); - m_bg1_16->mark_tile_dirty(offset & 0x0fff); - } - if(offset >= 0x3000) - { - m_bg0_8->mark_tile_dirty(offset & 0x0fff); - m_bg0_16->mark_tile_dirty(offset & 0x0fff); - } -} - -READ16_MEMBER(x68k_state::x68k_spriteram_r ) -{ - return m_spriteram[offset]; -} - -void x68k_state::x68k_draw_text(bitmap_rgb32 &bitmap, int xscr, int yscr, rectangle rect) -{ - unsigned int line,pixel; // location on screen - UINT32 loc; // location in TVRAM - UINT32 colour; - int bit; - - for(line=rect.min_y;line<=rect.max_y;line++) // per scanline - { - // adjust for scroll registers - loc = (((line - m_crtc.vbegin) + yscr) & 0x3ff) * 64; - loc += (xscr / 16) & 0x7f; - loc &= 0xffff; - bit = 15 - (xscr & 0x0f); - for(pixel=rect.min_x;pixel<=rect.max_x;pixel++) // per pixel - { - colour = (((m_tvram[loc] >> bit) & 0x01) ? 1 : 0) - + (((m_tvram[loc+0x10000] >> bit) & 0x01) ? 2 : 0) - + (((m_tvram[loc+0x20000] >> bit) & 0x01) ? 4 : 0) - + (((m_tvram[loc+0x30000] >> bit) & 0x01) ? 8 : 0); - // Colour 0 is displayable if the text layer is at the priority level 2 - if((m_pcgpalette->pen(colour) & 0xffffff) || ((m_video.reg[1] & 0x0c00) == 0x0800)) - bitmap.pix32(line, pixel) = m_pcgpalette->pen(colour); - bit--; - if(bit < 0) - { - bit = 15; - loc++; - loc &= 0xffff; - } - } - } -} - -bool x68k_state::x68k_draw_gfx_scanline( bitmap_ind16 &bitmap, rectangle cliprect, UINT8 priority) -{ - int pixel; - int page; - UINT32 loc; // location in GVRAM - UINT32 lineoffset; - UINT16 xscr,yscr; - UINT16 colour = 0; - int shift; - int scanline; - bool blend, ret = false; - UINT16 *pal = (UINT16 *)m_gfxpalette->basemem().base(); - - for(scanline=cliprect.min_y;scanline<=cliprect.max_y;scanline++) // per scanline - { - if(m_crtc.reg[20] & 0x0400) // 1024x1024 "real" screen size - use 1024x1024 16-colour gfx layer - { - // adjust for scroll registers - if(m_video.reg[2] & 0x0010 && priority == m_video.gfxlayer_pri[0]) - { - xscr = (m_crtc.reg[12] & 0x3ff); - yscr = (m_crtc.reg[13] & 0x3ff); - lineoffset = (((scanline - m_crtc.vbegin) + yscr) & 0x3ff) * 1024; - loc = xscr & 0x3ff; - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - switch(lineoffset & 0xc0000) - { - case 0x00000: - colour = m_gvram[lineoffset + (loc & 0x3ff)] & 0x000f; - break; - case 0x40000: - colour = (m_gvram[(lineoffset - 0x40000) + (loc & 0x3ff)] & 0x00f0) >> 4; - break; - case 0x80000: - colour = (m_gvram[(lineoffset - 0x80000) + (loc & 0x3ff)] & 0x0f00) >> 8; - break; - case 0xc0000: - colour = (m_gvram[(lineoffset - 0xc0000) + (loc & 0x3ff)] & 0xf000) >> 12; - break; - } - if(colour || (priority == 3)) - bitmap.pix16(scanline, pixel) = colour; - loc++; - loc &= 0x3ff; - } - } - } - else // else 512x512 "real" screen size - { - if(m_video.reg[2] & (1 << priority)) - { - page = m_video.gfxlayer_pri[priority]; - // adjust for scroll registers - switch(m_video.reg[0] & 0x03) - { - case 0x00: // 16 colours - xscr = ((m_crtc.reg[12+(page*2)])) & 0x1ff; - yscr = ((m_crtc.reg[13+(page*2)])) & 0x1ff; - lineoffset = (((scanline - m_crtc.vbegin) + yscr) & 0x1ff) * 512; - loc = xscr & 0x1ff; - shift = 4; - if((m_video.reg[2] & 0x1a00) == 0x1a00) - ret = true; - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - colour = ((m_gvram[lineoffset + loc] >> page*shift) & 0x000f); - if(ret && (colour & 1)) - { - blend = true; - colour &= 0xfe; - } - else - blend = false; - if(colour || (priority == 3)) - { - if(ret) - { - if(blend && bitmap.pix16(scanline, pixel)) - bitmap.pix16(scanline, pixel) = ((bitmap.pix16(scanline, pixel) >> 1) & 0x7bde) + ((pal[colour] >> 1) & 0x7bde) + 1; - else - bitmap.pix16(scanline, pixel) = (pal[colour] & 0xfffe) + blend; - } - else - bitmap.pix16(scanline, pixel) = colour; - } - loc++; - loc &= 0x1ff; - } - break; - case 0x01: // 256 colours - if(page == 0 || page == 2) - { - xscr = ((m_crtc.reg[12+(page*2)])) & 0x1ff; - yscr = ((m_crtc.reg[13+(page*2)])) & 0x1ff; - lineoffset = (((scanline - m_crtc.vbegin) + yscr) & 0x1ff) * 512; - loc = xscr & 0x1ff; - shift = 4; - if((m_video.reg[2] & 0x1a00) == 0x1a00) - ret = true; - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - colour = ((m_gvram[lineoffset + loc] >> page*shift) & 0x00ff); - if(ret && (colour & 1)) - { - blend = true; - colour &= 0xfe; - } - else - blend = false; - if(colour || (priority == 3)) - { - if(ret) - { - if(blend && bitmap.pix16(scanline, pixel)) - bitmap.pix16(scanline, pixel) = ((bitmap.pix16(scanline, pixel) >> 1) & 0x7bde) + ((pal[colour] >> 1) & 0x7bde) + 1; - else - bitmap.pix16(scanline, pixel) = (pal[colour] & 0xfffe) + blend; - } - else - bitmap.pix16(scanline, pixel) = colour; - } - loc++; - loc &= 0x1ff; - } - } - break; - case 0x03: // 65536 colours - xscr = ((m_crtc.reg[12])) & 0x1ff; - yscr = ((m_crtc.reg[13])) & 0x1ff; - lineoffset = (((scanline - m_crtc.vbegin) + yscr) & 0x1ff) * 512; - loc = xscr & 0x1ff; - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - colour = m_gvram[lineoffset + loc]; - if(colour || (priority == 3)) - bitmap.pix16(scanline, pixel) = colour; - loc++; - loc &= 0x1ff; - } - break; - } - } - } - } - return ret; -} - -void x68k_state::x68k_draw_gfx(bitmap_rgb32 &bitmap,rectangle cliprect) -{ - int priority, scanline, pixel; - bool gfxblend=false; - //rectangle rect; - //int xscr,yscr; - //int gpage; - - if(m_crtc.reg[20] & 0x0800) // if graphic layers are set to buffer, then they aren't visible - return; - - m_gfxbitmap->fill(0, cliprect); - - for(priority=3;priority>=0;priority--) - { - gfxblend = x68k_draw_gfx_scanline(*m_gfxbitmap,cliprect,priority); - } - - for(scanline=cliprect.min_y;scanline<=cliprect.max_y;scanline++) - { - UINT16 colour; - bool blend = false; - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - if((m_video.reg[0] & 0x03) == 3) - { - colour = m_gfxbitmap->pix16(scanline, pixel); - if(colour || (m_video.gfx_pri == 2)) - bitmap.pix32(scanline, pixel) = GGGGGRRRRRBBBBBI_decoder(colour); - } - else if(gfxblend) - { - colour = m_gfxbitmap->pix16(scanline, pixel); - if(((m_video.reg[2] & 0x1900) == 0x1900) && (m_video.gfx_pri != 2) && (colour & 1)) - blend = true; - else - blend = false; - if(colour || (m_video.gfx_pri == 2)) - { - if(blend) - bitmap.pix32(scanline, pixel) = ((bitmap.pix32(scanline, pixel) >> 1) & 0xff7f7f7f) + ((pal555(colour, 6, 11, 1) >> 1) & 0x7f7f7f); - else - bitmap.pix32(scanline, pixel) = pal555(colour, 6, 11, 1); - } - } - else - { - colour = m_gfxbitmap->pix16(scanline, pixel) & 0xff; - if(((m_video.reg[2] & 0x1900) == 0x1900) && (m_video.gfx_pri != 2) && (colour & 1)) - { - blend = true; - colour &= 0xfe; - } - else - blend = false; - if((colour && (m_gfxpalette->pen(colour) & 0xffffff)) || (m_video.gfx_pri == 2)) - { - if(blend) - bitmap.pix32(scanline, pixel) = ((bitmap.pix32(scanline, pixel) >> 1) & 0xff7f7f7f) + ((m_gfxpalette->pen(colour) >> 1) & 0x7f7f7f); - else - bitmap.pix32(scanline, pixel) = m_gfxpalette->pen(colour); - } - } - } - } -} - -// Sprite controller "Cynthia" at 0xeb0000 -void x68k_state::x68k_draw_sprites(bitmap_ind16 &bitmap, int priority, rectangle cliprect) -{ - /* - 0xeb0000 - 0xeb07ff - Sprite registers (up to 128) - + 00 : b9-0, Sprite X position - + 02 : b9-0, Sprite Y position - + 04 : b15, Vertical Reversing (flipping?) - b14, Horizontal Reversing - b11-8, Sprite colour - b7-0, Sprite tile code (in PCG) - + 06 : b1-0, Priority - 00 = Sprite not displayed - - 0xeb0800 - BG0 X Scroll (10-bit) - 0xeb0802 - BG0 Y Scroll - 0xeb0804 - BG1 X Scroll - 0xeb0806 - BG1 Y Scroll - 0xeb0808 - BG control - b9, BG/Sprite display (RAM and register access is faster if 1) - b4, PCG area 1 available - b3, BG1 display enable - b1, PCG area 0 available - b0, BG0 display enable - 0xeb080a - Horizontal total (like CRTC reg 0 - is 0xff if in 256x256?) - 0xeb080c - Horizontal display position (like CRTC reg 2 - +4) - 0xeb080e - Vertical display position (like CRTC reg 6) - 0xeb0810 - Resolution setting - b4, "L/H" (apparently 15kHz/31kHz switch for sprites/BG?) - b3-2, V-Res - b1-0, H-Res (0 = 8x8 tilemaps, 1 = 16x16 tilemaps, 2 or 3 = unknown) - */ - int ptr,pri; - - for(ptr=508;ptr>=0;ptr-=4) // stepping through sprites - { - pri = m_spritereg[ptr+3] & 0x03; -#ifdef MAME_DEBUG - if(!(machine().input().code_pressed(KEYCODE_I))) -#endif - if(pri == priority) - { // if at the right priority level, draw the sprite - rectangle rect; - int code = m_spritereg[ptr+2] & 0x00ff; - int colour = (m_spritereg[ptr+2] & 0x0f00) >> 8; - int xflip = m_spritereg[ptr+2] & 0x4000; - int yflip = m_spritereg[ptr+2] & 0x8000; - int sx = (m_spritereg[ptr+0] & 0x3ff) - 16; - int sy = (m_spritereg[ptr+1] & 0x3ff) - 16; - - rect.min_x=m_crtc.hshift; - rect.min_y=m_crtc.vshift; - rect.max_x=rect.min_x + m_crtc.visible_width-1; - rect.max_y=rect.min_y + m_crtc.visible_height-1; - - sx += m_crtc.bg_hshift; - sx += m_sprite_shift; - - m_gfxdecode->gfx(1)->zoom_transpen(bitmap,cliprect,code,colour,xflip,yflip,m_crtc.hbegin+sx,m_crtc.vbegin+(sy*m_crtc.bg_double),0x10000,0x10000*m_crtc.bg_double,0x00); - } - } -} - -static const gfx_layout x68k_pcg_8 = -{ - 8,8, - 256, - 4, - { 0,1,2,3 }, - { 8,12,0,4,24,28,16,20 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, - 32*8 -}; - -static const gfx_layout x68k_pcg_16 = -{ - 16,16, - 256, - 4, - { 0,1,2,3 }, - { 8,12,0,4,24,28,16,20,8+64*8,12+64*8,64*8,4+64*8,24+64*8,28+64*8,16+64*8,20+64*8 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, - 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 }, - 128*8 -}; - -TILE_GET_INFO_MEMBER(x68k_state::x68k_get_bg0_tile) -{ - int code = m_spriteram[0x3000+tile_index] & 0x00ff; - int colour = (m_spriteram[0x3000+tile_index] & 0x0f00) >> 8; - int flags = (m_spriteram[0x3000+tile_index] & 0xc000) >> 14; - SET_TILE_INFO_MEMBER(0,code,colour,flags); -} - -TILE_GET_INFO_MEMBER(x68k_state::x68k_get_bg1_tile) -{ - int code = m_spriteram[0x2000+tile_index] & 0x00ff; - int colour = (m_spriteram[0x2000+tile_index] & 0x0f00) >> 8; - int flags = (m_spriteram[0x2000+tile_index] & 0xc000) >> 14; - SET_TILE_INFO_MEMBER(0,code,colour,flags); -} - -TILE_GET_INFO_MEMBER(x68k_state::x68k_get_bg0_tile_16) -{ - int code = m_spriteram[0x3000+tile_index] & 0x00ff; - int colour = (m_spriteram[0x3000+tile_index] & 0x0f00) >> 8; - int flags = (m_spriteram[0x3000+tile_index] & 0xc000) >> 14; - SET_TILE_INFO_MEMBER(1,code,colour,flags); -} - -TILE_GET_INFO_MEMBER(x68k_state::x68k_get_bg1_tile_16) -{ - int code = m_spriteram[0x2000+tile_index] & 0x00ff; - int colour = (m_spriteram[0x2000+tile_index] & 0x0f00) >> 8; - int flags = (m_spriteram[0x2000+tile_index] & 0xc000) >> 14; - SET_TILE_INFO_MEMBER(1,code,colour,flags); -} - -VIDEO_START_MEMBER(x68k_state,x68000) -{ - int gfx_index; - - for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) - if (m_gfxdecode->gfx(gfx_index) == 0) - break; - - /* create the char set (gfx will then be updated dynamically from RAM) */ - m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_pcgpalette, x68k_pcg_8, memregion("user1")->base(), 0, 32, 0))); - - gfx_index++; - - m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_pcgpalette, x68k_pcg_16, memregion("user1")->base(), 0, 32, 0))); - m_gfxdecode->gfx(gfx_index)->set_colors(32); - - /* Tilemaps */ - m_bg0_8 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(x68k_state::x68k_get_bg0_tile),this),TILEMAP_SCAN_ROWS,8,8,64,64); - m_bg1_8 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(x68k_state::x68k_get_bg1_tile),this),TILEMAP_SCAN_ROWS,8,8,64,64); - m_bg0_16 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(x68k_state::x68k_get_bg0_tile_16),this),TILEMAP_SCAN_ROWS,16,16,64,64); - m_bg1_16 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(x68k_state::x68k_get_bg1_tile_16),this),TILEMAP_SCAN_ROWS,16,16,64,64); - - m_bg0_8->set_transparent_pen(0); - m_bg1_8->set_transparent_pen(0); - m_bg0_16->set_transparent_pen(0); - m_bg1_16->set_transparent_pen(0); - - m_pcgbitmap = auto_bitmap_ind16_alloc(machine(), 1024, 1024); - m_pcgbitmap->fill(0); - - m_gfxbitmap = auto_bitmap_ind16_alloc(machine(), 1024, 1024); - m_gfxbitmap->fill(0); - -// m_scanline_timer->adjust(attotime::zero, 0, attotime::from_hz(55.45)/568); -} - -UINT32 x68k_state::screen_update_x68000(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - rectangle rect(0,0,0,0); - int priority; - int xscr,yscr; - int x; - tilemap_t* x68k_bg0; - tilemap_t* x68k_bg1; - int pixel, scanline; - //UINT8 *rom; - - if((m_spritereg[0x408] & 0x03) == 0x00) // Sprite/BG H-Res 0=8x8, 1=16x16, 2 or 3 = undefined. - { - x68k_bg0 = m_bg0_8; - x68k_bg1 = m_bg1_8; - } - else - { - x68k_bg0 = m_bg0_16; - x68k_bg1 = m_bg1_16; - } -// rect.max_x=m_crtc.width; -// rect.max_y=m_crtc.height; - bitmap.fill(0, cliprect); - - if(m_sysport.contrast == 0) // if monitor contrast is 0, then don't bother displaying anything - return 0; - - rect.min_x=m_crtc.hbegin; - rect.min_y=m_crtc.vbegin; -// rect.max_x=rect.min_x + m_crtc.visible_width-1; -// rect.max_y=rect.min_y + m_crtc.visible_height-1; - rect.max_x=m_crtc.hend; - rect.max_y=m_crtc.vend; - - if(rect.min_y < cliprect.min_y) - rect.min_y = cliprect.min_y; - if(rect.max_y > cliprect.max_y) - rect.max_y = cliprect.max_y; - - // update tiles - //rom = memregion("user1")->base(); - for(x=0;x<256;x++) - { - if(m_video.tile16_dirty[x] != 0) - { - m_gfxdecode->gfx(1)->mark_dirty(x); - m_video.tile16_dirty[x] = 0; - } - if(m_video.tile8_dirty[x] != 0) - { - m_gfxdecode->gfx(0)->mark_dirty(x); - m_video.tile8_dirty[x] = 0; - } - } - - - for(priority=2;priority>=0;priority--) - { - // Graphics screen(s) - if(priority == m_video.gfx_pri) - x68k_draw_gfx(bitmap,rect); - - // Sprite / BG Tiles - if(priority == m_video.sprite_pri /*&& (m_spritereg[0x404] & 0x0200)*/ && (m_video.reg[2] & 0x0040)) - { - m_pcgbitmap->fill(0, rect); - x68k_draw_sprites(*m_pcgbitmap,1,rect); - if((m_spritereg[0x404] & 0x0008)) - { - if((m_spritereg[0x404] & 0x0030) == 0x10) // BG1 TXSEL - { - x68k_bg0->set_scrollx(0,(m_spritereg[0x402] - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - x68k_bg0->set_scrolly(0,(m_spritereg[0x403] - m_crtc.vbegin) & 0x3ff); - x68k_bg0->draw(screen, *m_pcgbitmap,rect,0,0); - } - else - { - x68k_bg1->set_scrollx(0,(m_spritereg[0x402] - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - x68k_bg1->set_scrolly(0,(m_spritereg[0x403] - m_crtc.vbegin) & 0x3ff); - x68k_bg1->draw(screen, *m_pcgbitmap,rect,0,0); - } - } - x68k_draw_sprites(*m_pcgbitmap,2,rect); - if((m_spritereg[0x404] & 0x0001)) - { - if((m_spritereg[0x404] & 0x0006) == 0x02) // BG0 TXSEL - { - x68k_bg0->set_scrollx(0,(m_spritereg[0x400] - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - x68k_bg0->set_scrolly(0,(m_spritereg[0x401] - m_crtc.vbegin) & 0x3ff); - x68k_bg0->draw(screen, *m_pcgbitmap,rect,0,0); - } - else - { - x68k_bg1->set_scrollx(0,(m_spritereg[0x400] - m_crtc.hbegin - m_crtc.bg_hshift) & 0x3ff); - x68k_bg1->set_scrolly(0,(m_spritereg[0x401] - m_crtc.vbegin) & 0x3ff); - x68k_bg1->draw(screen, *m_pcgbitmap,rect,0,0); - } - } - x68k_draw_sprites(*m_pcgbitmap,3,rect); - - for(scanline=rect.min_y;scanline<=rect.max_y;scanline++) - { - for(pixel=m_crtc.hbegin;pixel<=m_crtc.hend;pixel++) - { - UINT8 colour = m_pcgbitmap->pix16(scanline, pixel) & 0xff; - if((colour && (m_pcgpalette->pen(colour) & 0xffffff)) || ((m_video.reg[1] & 0x3000) == 0x2000)) - bitmap.pix32(scanline, pixel) = m_pcgpalette->pen(colour); - } - } - } - - // Text screen - if(m_video.reg[2] & 0x0020 && priority == m_video.text_pri) - { - xscr = (m_crtc.reg[10] & 0x3ff); - yscr = (m_crtc.reg[11] & 0x3ff); - if(!(m_crtc.reg[20] & 0x1000)) // if text layer is set to buffer, then it's not visible - x68k_draw_text(bitmap,xscr,yscr,rect); - } - } - -#ifdef MAME_DEBUG - if(machine().input().code_pressed(KEYCODE_9)) - { - m_sprite_shift--; - popmessage("Sprite shift = %i",m_sprite_shift); - } - if(machine().input().code_pressed(KEYCODE_0)) - { - m_sprite_shift++; - popmessage("Sprite shift = %i",m_sprite_shift); - } - -#endif - -#ifdef MAME_DEBUG -// popmessage("Layer priorities [%04x] - Txt: %i Spr: %i Gfx: %i Layer Pri0-3: %i %i %i %i",m_video.reg[1],m_video.text_pri,m_video.sprite_pri, -// m_video.gfx_pri,m_video.gfxlayer_pri[0],m_video.gfxlayer_pri[1],m_video.gfxlayer_pri[2],m_video.gfxlayer_pri[3]); -// popmessage("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i",m_crtc.reg[0],m_crtc.reg[1],m_crtc.reg[2],m_crtc.reg[3], -// m_crtc.reg[4],m_crtc.reg[5],m_crtc.reg[6],m_crtc.reg[7],m_crtc.reg[8],m_crtc.reg[9]); -// popmessage("Visible resolution = %ix%i (%s) Screen size = %ix%i",m_crtc.visible_width,m_crtc.visible_height,m_crtc.interlace ? "Interlaced" : "Non-interlaced",m_crtc.video_width,m_crtc.video_height); -// popmessage("VBlank : scanline = %i",m_scanline); -// popmessage("CRTC/BG compare H-TOTAL %i/%i H-DISP %i/%i V-DISP %i/%i BG Res %02x",m_crtc.reg[0],m_spritereg[0x405],m_crtc.reg[2],m_spritereg[0x406], -// m_crtc.reg[6],m_spritereg[0x407],m_spritereg[0x408]); -// popmessage("BG Scroll - BG0 X %i Y %i BG1 X %i Y %i",m_spriteram[0x400],m_spriteram[0x401],m_spriteram[0x402],m_spriteram[0x403]); -// popmessage("uPD72065 status = %02x",upd765_status_r(machine(), space, 0)); -// popmessage("Layer enable - 0x%02x",m_video.reg[2] & 0xff); -// popmessage("Graphic layer scroll - %i, %i - %i, %i - %i, %i - %i, %i", -// m_crtc.reg[12],m_crtc.reg[13],m_crtc.reg[14],m_crtc.reg[15],m_crtc.reg[16],m_crtc.reg[17],m_crtc.reg[18],m_crtc.reg[19]); -// popmessage("IOC IRQ status - %02x",m_ioc.irqstatus); -// popmessage("RAM: mouse data - %02x %02x %02x %02x",m_ram->pointer()[0x931],m_ram->pointer()[0x930],m_ram->pointer()[0x933],m_ram->pointer()[0x932]); -#endif - return 0; -} diff --git a/src/mess/video/z88.c b/src/mess/video/z88.c deleted file mode 100644 index 4b9a0b07f88..00000000000 --- a/src/mess/video/z88.c +++ /dev/null @@ -1,175 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker,Sandro Ronco -/*************************************************************************** - - z88.c - - Functions to emulate the video hardware of the Cambridge Z88 - -***************************************************************************/ - -#include "includes/z88.h" - - -inline void z88_state::plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT16 color) -{ - if (xset_pen_color(0, rgb_t(138, 146, 148)); - m_palette->set_pen_color(1, rgb_t(92, 83, 88)); - m_palette->set_pen_color(2, rgb_t(122, 126, 129)); -} - -/* temp - change to gfxelement structure */ - -void z88_state::vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx) -{ - for (int h=0; h<8; h++) - { - UINT8 data = gfx[h]; - - for (int b=0; b<8; b++) - { - plot_pixel(bitmap, x+b, y+h, (data & 0x80) ? pen1 : pen0); - - data = data<<1; - } - } -} - -void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx) -{ - for (int h=0; h<8; h++) - { - UINT8 data = gfx[h]<<2; - - for (int b=0; b<6; b++) - { - plot_pixel(bitmap, x+1+b, y+h, (data & 0x80) ? pen1 : pen0); - data = data<<1; - } - } -} - -void z88_state::vh_render_line(bitmap_ind16 &bitmap, int x, int y, UINT16 pen) -{ - for (int i=0; i<8; i++) - plot_pixel(bitmap, x + i, y + 7, pen); -} - -UPD65031_SCREEN_UPDATE(z88_state::lcd_update) -{ - if (sbf == 0) - { - // LCD disabled - bitmap.fill(0); - } - else - { - UINT8 *vram = convert_address(sbf<<11); - - for (int y=0; y<(Z88_SCREEN_HEIGHT>>3); y++) - { - int x = 0, c = 0; - - while (x < Z88_SCREEN_WIDTH) - { - UINT16 pen0, pen1; - UINT8 *char_gfx; - UINT8 byte0 = vram[(y * 0x100) + c]; - UINT8 byte1 = vram[(y * 0x100) + c + 1]; - - // inverted graphics? - if (byte1 & Z88_SCR_HW_REV) - { - pen0 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; - pen1 = 0; - } - else - { - pen0 = 0; - pen1 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; - } - - if ((byte1 & Z88_SCR_HW_NULL) == Z88_SCR_HW_NULL) - { - // hidden - } - else if (!(byte1 & Z88_SCR_HW_HRS) || (((byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS))) - { - // low-res 6x8 - UINT16 ch = (byte0 | (byte1<<8)) & 0x1ff; - - if ((ch & 0x01c0) == 0x01c0) - { - ch &= 0x3f; - - char_gfx = convert_address(lores0<<9); - } - else - { - char_gfx = convert_address(lores1<<12); - } - - char_gfx += (ch<<3); - - // cursor flash - if (flash && (byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS) - vh_render_6x8(bitmap, x,(y<<3), pen1, pen0, char_gfx); - else - vh_render_6x8(bitmap, x,(y<<3), pen0, pen1, char_gfx); - - // underline? - if (byte1 & Z88_SCR_HW_UND) - vh_render_line(bitmap, x, (y<<3), pen1); - - x += 6; - } - else if ((byte1 & Z88_SCR_HW_HRS) && !(byte1 & Z88_SCR_HW_REV)) - { - // high-res 8x8 - UINT16 ch = (byte0 | (byte1<<8)) & 0x3ff; - - if (ch & 0x0100) - { - ch &= 0xff; - char_gfx = convert_address(hires1<<11); - } - else - { - ch &= 0xff; - char_gfx = convert_address(hires0<<13); - } - - char_gfx += (ch<<3); - - // flash - if ((byte1 & Z88_SCR_HW_FLS) && flash) - pen0 = pen1 = 0; - - vh_render_8x8(bitmap, x,(y<<3), pen0, pen1, char_gfx); - - x += 8; - } - - // every char takes 2 bytes - c += 2; - } - } - } -} diff --git a/src/mess/video/zx.c b/src/mess/video/zx.c deleted file mode 100644 index 8948a395246..00000000000 --- a/src/mess/video/zx.c +++ /dev/null @@ -1,223 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller, Krzysztof Strzecha, Robbbert -/*************************************************************************** - zx.c - - video hardware - Juergen Buchmueller , Dec 1999 - - The ZX has a very unorthodox video RAM system. To start a scanline, - the CPU must jump to video RAM at 0xC000, which is a mirror of the - RAM at 0x4000. The video chip (ULA?) pulls a switcharoo and changes - the video bytes as they are fetched by the CPU. - - The video chip draws the scanline until a HALT instruction (0x76) is - reached, which indicates no further video RAM for this scanline. Any - other video byte is used to generate a tile and at the same time, - appears to the CPU as a NOP (0x00) instruction. - -****************************************************************************/ - -#include "includes/zx.h" - - -void zx_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case TIMER_TAPE_PULSE: - zx_tape_pulse(ptr, param); - break; - case TIMER_ULA_NMI: - zx_ula_nmi(ptr, param); - break; - case TIMER_ULA_IRQ: - zx_ula_irq(ptr, param); - break; - default: - assert_always(FALSE, "Unknown id in zx_state::device_timer"); - } -} - - -/* - * Toggle the video output between black and white. - * This happens whenever the ULA scanline IRQs are enabled/disabled. - * Normally this is done during the synchronized zx_ula_r() function, - * which outputs 8 pixels per code, but if the video sync is off - * (during tape IO or sound output) zx_ula_bkgnd() is used to - * simulate the display of a ZX80/ZX81. - */ -void zx_state::zx_ula_bkgnd(UINT8 color) -{ - int width = m_screen->width(); - int height = m_screen->height(); - const rectangle &visarea = m_screen->visible_area(); - - if (m_ula_frame_vsync == 0 && color != m_old_c) - { - int y, new_x, new_y; - rectangle r; - bitmap_ind16 &bitmap = m_bitmap; - - new_y = machine().first_screen()->vpos(); - new_x = machine().first_screen()->hpos(); -/* logerror("zx_ula_bkgnd: %3d,%3d - %3d,%3d\n", state->m_old_x, state->m_old_y, new_x, new_y);*/ - y = m_old_y; - for (;;) - { - if (y == new_y) - { - r.set(m_old_x, new_x, y, y); - bitmap.fill(color, r); - break; - } - else - { - r.set(m_old_x, visarea.max_x, y, y); - bitmap.fill(color, r); - m_old_x = 0; - } - if (++y == height) - y = 0; - } - m_old_x = (new_x + 1) % width; - m_old_y = new_y; - m_old_c = color; - } -} - -/* - * PAL: 310 total lines, - * 0.. 55 vblank - * 56..247 192 visible lines - * 248..303 vblank - * 304... vsync - * NTSC: 262 total lines - * 0.. 31 vblank - * 32..223 192 visible lines - * 224..233 vblank - */ -TIMER_CALLBACK_MEMBER(zx_state::zx_ula_nmi) -{ - /* - * An NMI is issued on the ZX81 every 64us for the blanked - * scanlines at the top and bottom of the display. - */ - int height = m_screen->height(); - const rectangle& r1 = m_screen->visible_area(); - rectangle r; - - bitmap_ind16 &bitmap = m_bitmap; - r.set(r1.min_x, r1.max_x, m_ula_scanline_count, m_ula_scanline_count); - bitmap.fill(1, r); -// logerror("ULA %3d[%d] NMI, R:$%02X, $%04x\n", machine().first_screen()->vpos(), ula_scancode_count, (unsigned) m_maincpu->state_int(Z80_R), (unsigned) m_maincpu->state_int(Z80_PC)); - m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); - if (++m_ula_scanline_count == height) - m_ula_scanline_count = 0; -} - -TIMER_CALLBACK_MEMBER(zx_state::zx_ula_irq) -{ - /* - * An IRQ is issued on the ZX80/81 whenever the R registers - * bit 6 goes low. In MESS this IRQ timed from the first read - * from the copy of the DFILE in the upper 32K in zx_ula_r(). - */ - if (m_ula_irq_active) - { -// logerror("ULA %3d[%d] IRQ, R:$%02X, $%04x\n", machine().first_screen()->vpos(), ula_scancode_count, (unsigned) m_maincpu->state_int(Z80_R), (unsigned) m_maincpu->state_int(Z80_PC)); - - m_ula_irq_active = 0; - m_maincpu->set_input_line(0, HOLD_LINE); - } -} - -void zx_state::zx_ula_r(int offs, memory_region *region, const UINT8 param) -{ - int offs0 = offs & 0x7fff; - UINT8 *rom = m_region_maincpu->base(); - UINT8 chr = rom[offs0]; - - if ((!m_ula_irq_active) && (chr == 0x76)) - { - bitmap_ind16 &bitmap = m_bitmap; - UINT16 y, *scanline; - UINT16 ireg = m_maincpu->state_int(Z80_I) << 8; - UINT8 data, *chrgen, creg; - - if (param) - creg = m_maincpu->state_int(Z80_B); - else - creg = m_maincpu->state_int(Z80_C); - - chrgen = region->base(); - - if ((++m_ula_scanline_count == m_screen->height()) || (creg == 32)) - { - m_ula_scanline_count = 0; - m_offs1 = offs0; - } - - m_ula_frame_vsync = 3; - - m_charline_ptr = 0; - - for (y = m_offs1+1; ((y < offs0) && (m_charline_ptr < ARRAY_LENGTH(m_charline))); y++) - { - m_charline[m_charline_ptr] = rom[y]; - m_charline_ptr++; - } - for (y = m_charline_ptr; y < ARRAY_LENGTH(m_charline); y++) - m_charline[y] = 0; - - timer_set(m_maincpu->cycles_to_attotime(((32 - m_charline_ptr) << 2)), TIMER_ULA_IRQ); - m_ula_irq_active++; - - scanline = &bitmap.pix16(m_ula_scanline_count); - y = 0; - - for (m_charline_ptr = 0; m_charline_ptr < ARRAY_LENGTH(m_charline); m_charline_ptr++) - { - chr = m_charline[m_charline_ptr]; - data = chrgen[ireg | ((chr & 0x3f) << 3) | ((8 - creg)&7) ]; - if (chr & 0x80) data ^= 0xff; - - scanline[y++] = (data >> 7) & 1; - scanline[y++] = (data >> 6) & 1; - scanline[y++] = (data >> 5) & 1; - scanline[y++] = (data >> 4) & 1; - scanline[y++] = (data >> 3) & 1; - scanline[y++] = (data >> 2) & 1; - scanline[y++] = (data >> 1) & 1; - scanline[y++] = (data >> 0) & 1; - m_charline[m_charline_ptr] = 0; - } - - if (creg == 1) m_offs1 = offs0; - } -} - -void zx_state::video_start() -{ - m_ula_nmi = timer_alloc(TIMER_ULA_NMI); - m_ula_irq_active = 0; - m_screen->register_screen_bitmap(m_bitmap); -} - -void zx_state::screen_eof_zx(screen_device &screen, bool state) -{ - // rising edge - if (state) - { - /* decrement video synchronization counter */ - if (m_ula_frame_vsync) - --m_ula_frame_vsync; - } -} - -UINT32 zx_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); - return 0; -} diff --git a/src/mess/video/zx8301.c b/src/mess/video/zx8301.c deleted file mode 100644 index a7c115e8237..00000000000 --- a/src/mess/video/zx8301.c +++ /dev/null @@ -1,334 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Sinclair ZX8301 emulation - -**********************************************************************/ - -/* - - TODO: - - - wait state on memory access during video update - - proper video timing - - get rid of flash timer - -*/ - -#include "zx8301.h" - - - -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define LOG 0 - - -// low resolution palette -static const int ZX8301_COLOR_MODE4[] = { 0, 2, 4, 7 }; - - -static const rgb_t PALETTE_ZX8301[] = -{ - rgb_t(0x00, 0x00, 0x00), // black - rgb_t(0x00, 0x00, 0xff), // blue - rgb_t(0xff, 0x00, 0x00), // red - rgb_t(0xff, 0x00, 0xff), // magenta - rgb_t(0x00, 0xff, 0x00), // green - rgb_t(0x00, 0xff, 0xff), // cyan - rgb_t(0xff, 0xff, 0x00), // yellow - rgb_t(0xff, 0xff, 0xff) // white -}; - - - -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// devices -const device_type ZX8301 = &device_creator; - - -// default address map -static ADDRESS_MAP_START( zx8301, AS_0, 8, zx8301_device ) - AM_RANGE(0x00000, 0x1ffff) AM_RAM -ADDRESS_MAP_END - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -const address_space_config *zx8301_device::memory_space_config(address_spacenum spacenum) const -{ - return (spacenum == AS_0) ? &m_space_config : NULL; -} - - - -//************************************************************************** -// INLINE HELPERS -//************************************************************************** - -//------------------------------------------------- -// readbyte - read a byte at the given address -//------------------------------------------------- - -inline UINT8 zx8301_device::readbyte(offs_t address) -{ - return space().read_byte(address); -} - - -//------------------------------------------------- -// writebyte - write a byte at the given address -//------------------------------------------------- - -inline void zx8301_device::writebyte(offs_t address, UINT8 data) -{ - space().write_byte(address, data); -} - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// zx8301_device - constructor -//------------------------------------------------- - -zx8301_device::zx8301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ZX8301, "Sinclair ZX8301", tag, owner, clock, "zx8301", __FILE__), - device_memory_interface(mconfig, *this), - device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, NULL, *ADDRESS_MAP_NAME(zx8301)), - m_cpu(*this), - m_write_vsync(*this), - m_dispoff(1), - m_mode8(0), - m_base(0), - m_flash(1), - m_vsync(1), - m_vda(0) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void zx8301_device::device_start() -{ - // resolve callbacks - m_write_vsync.resolve_safe(); - - // allocate timers - m_vsync_timer = timer_alloc(TIMER_VSYNC); - m_flash_timer = timer_alloc(TIMER_FLASH); - - // adjust timer periods - m_vsync_timer->adjust(attotime::zero, 0, attotime::from_hz(50)); - m_flash_timer->adjust(attotime::from_hz(2), 0, attotime::from_hz(2)); - - // register for state saving - save_item(NAME(m_dispoff)); - save_item(NAME(m_mode8)); - save_item(NAME(m_base)); - save_item(NAME(m_flash)); - save_item(NAME(m_vsync)); - save_item(NAME(m_vda)); -} - - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- - -void zx8301_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case TIMER_VSYNC: - //m_vsync = !m_vsync; - m_write_vsync(m_vsync); - break; - - case TIMER_FLASH: - m_flash = !m_flash; - break; - } -} - - -//------------------------------------------------- -// control_w - display control register -//------------------------------------------------- - -WRITE8_MEMBER( zx8301_device::control_w ) -{ - /* - - bit description - - 0 - 1 display off - 2 - 3 graphics mode - 4 - 5 - 6 - 7 display base address - - */ - - if (LOG) logerror("ZX8301 Control: %02x\n", data); - - // display off - m_dispoff = BIT(data, 1); - - // graphics mode - m_mode8 = BIT(data, 3); - - // display base address - m_base = BIT(data, 7); -} - - -//------------------------------------------------- -// data_r - RAM read -//------------------------------------------------- - -READ8_MEMBER( zx8301_device::data_r ) -{ - if (LOG) logerror("ZX8301 RAM Read: %06x\n", offset); - - if (m_vda) - { - m_cpu->spin_until_time(m_screen->time_until_pos(256, 0)); - } - - return readbyte(offset); -} - - -//------------------------------------------------- -// data_w - RAM write -//------------------------------------------------- - -WRITE8_MEMBER( zx8301_device::data_w ) -{ - if (LOG) logerror("ZX8301 RAM Write: %06x = %02x\n", offset, data); - - if (m_vda) - { - m_cpu->spin_until_time(m_screen->time_until_pos(256, 0)); - } - - writebyte(offset, data); -} - - -//------------------------------------------------- -// draw_line_mode4 - draw mode 4 line -//------------------------------------------------- - -void zx8301_device::draw_line_mode4(bitmap_rgb32 &bitmap, int y, UINT16 da) -{ - int x = 0; - - for (int word = 0; word < 64; word++) - { - UINT8 byte_high = readbyte(da++); - UINT8 byte_low = readbyte(da++); - - for (int pixel = 0; pixel < 8; pixel++) - { - int red = BIT(byte_low, 7); - int green = BIT(byte_high, 7); - int color = (green << 1) | red; - - bitmap.pix32(y, x++) = PALETTE_ZX8301[ZX8301_COLOR_MODE4[color]]; - - byte_high <<= 1; - byte_low <<= 1; - } - } -} - - -//------------------------------------------------- -// draw_line_mode8 - draw mode 8 line -//------------------------------------------------- - -void zx8301_device::draw_line_mode8(bitmap_rgb32 &bitmap, int y, UINT16 da) -{ - int x = 0; - - for (int word = 0; word < 64; word++) - { - UINT8 byte_high = readbyte(da++); - UINT8 byte_low = readbyte(da++); - - for (int pixel = 0; pixel < 4; pixel++) - { - int red = BIT(byte_low, 7); - int green = BIT(byte_high, 7); - int blue = BIT(byte_low, 6); - int flash = BIT(byte_high, 6); - - int color = (green << 2) | (red << 1) | blue; - - if (flash && m_flash) - { - color = 0; - } - - bitmap.pix32(y, x++) = PALETTE_ZX8301[color]; - bitmap.pix32(y, x++) = PALETTE_ZX8301[color]; - - byte_high <<= 2; - byte_low <<= 2; - } - } -} - - -//------------------------------------------------- -// screen_update - -//------------------------------------------------- - -UINT32 zx8301_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - if (!m_dispoff) - { - UINT32 da = m_base << 15; - - for (int y = 0; y < 256; y++) - { - if (m_mode8) - { - draw_line_mode8(bitmap, y, da); - } - else - { - draw_line_mode4(bitmap, y, da); - } - - da += 128; - } - } - else - { - bitmap.fill(rgb_t::black, cliprect); - } - - return 0; -} diff --git a/src/mess/video/zx8301.h b/src/mess/video/zx8301.h deleted file mode 100644 index c91b1c65bca..00000000000 --- a/src/mess/video/zx8301.h +++ /dev/null @@ -1,123 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Sinclair ZX8301 emulation - -********************************************************************** - _____ _____ - DTACKL 1 |* \_/ | 40 WEL - A17 2 | | 39 PCENL - A16 3 | | 38 VDA - RDWL 4 | | 37 ROWL - DSMCL 5 | | 36 TX0EL - VCC 6 | | 35 XTAL2 - CLKCPU 7 | | 34 XTAL1 - RASL 8 | | 33 ROM0EH - CAS0L 9 | | 32 BLUE - CAS1L 10 | ZX8301 | 31 GREEN - VSYNCH 11 | ULA | 30 RED - CSYNCL 12 | | 29 DB7 - DA0 13 | | 28 DA7 - DB0 14 | | 27 DA6 - VDD 15 | | 26 DB6 - DB1 16 | | 25 DB5 - DA1 17 | | 24 DA5 - DA2 18 | | 23 DB4 - DB2 19 | | 22 DA4 - DA3 20 |_____________| 21 DB3 - -**********************************************************************/ - -#pragma once - -#ifndef __ZX8301__ -#define __ZX8301__ - -#include "emu.h" - - - -///************************************************************************* -// INTERFACE CONFIGURATION MACROS -///************************************************************************* - -#define MCFG_ZX8301_CPU(_tag) \ - zx8301_device::static_set_cpu_tag(*device, "^" _tag); - -#define MCFG_ZX8301_VSYNC_CALLBACK(_write) \ - devcb = &zx8301_device::set_vsync_wr_callback(*device, DEVCB_##_write); - - - -///************************************************************************* -// TYPE DEFINITIONS -///************************************************************************* - -// ======================> zx8301_device - -class zx8301_device : public device_t, - public device_memory_interface, - public device_video_interface -{ -public: - // construction/destruction - zx8301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - template static devcb_base &set_vsync_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_vsync.set_callback(object); } - static void static_set_cpu_tag(device_t &device, const char *tag) { downcast(device).m_cpu.set_tag(tag); } - - DECLARE_WRITE8_MEMBER( control_w ); - DECLARE_READ8_MEMBER( data_r ); - DECLARE_WRITE8_MEMBER( data_w ); - - UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - - // device_config_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; - - // address space configurations - const address_space_config m_space_config; - - inline UINT8 readbyte(offs_t address); - inline void writebyte(offs_t address, UINT8 data); - - void draw_line_mode4(bitmap_rgb32 &bitmap, int y, UINT16 da); - void draw_line_mode8(bitmap_rgb32 &bitmap, int y, UINT16 da); - -private: - enum - { - TIMER_VSYNC, - TIMER_FLASH - }; - - required_device m_cpu; - - devcb_write_line m_write_vsync; - - //address_space *m_data; - - int m_dispoff; // display off - int m_mode8; // mode8 active - int m_base; // video ram base address - int m_flash; // flash - int m_vsync; // vertical sync - int m_vda; // valid data address - - emu_timer *m_vsync_timer; // vertical sync timer - emu_timer *m_flash_timer; // flash timer -}; - - -// device type definition -extern const device_type ZX8301; - - - -#endif -- cgit v1.2.3