trunk/src/emu/bus/isa/num9rev.c
r0 | r241717 | |
| 1 | // license:BSD-3-Clause |
| 2 | // Number Nine Revolution 512x32/1024x8 |
| 3 | // TODO: for 1024x768 mode the 7220 is programmed for 512x768, how does that work? |
| 4 | |
| 5 | #include "emu.h" |
| 6 | #include "num9rev.h" |
| 7 | |
| 8 | //************************************************************************** |
| 9 | // GLOBAL VARIABLES |
| 10 | //************************************************************************** |
| 11 | |
| 12 | const device_type ISA8_NUM_9_REV = &device_creator<isa8_number_9_rev_device>; |
| 13 | |
| 14 | static ADDRESS_MAP_START( upd7220_map, AS_0, 8, isa8_number_9_rev_device ) |
| 15 | AM_RANGE(0x00000, 0x3ffff) AM_NOP |
| 16 | ADDRESS_MAP_END |
| 17 | |
| 18 | UPD7220_DISPLAY_PIXELS_MEMBER( isa8_number_9_rev_device::hgdc_display_pixels ) |
| 19 | { |
| 20 | palette_t *pal = m_palette->palette(); |
| 21 | if(!m_1024) |
| 22 | { |
| 23 | rgb_t color(0); |
| 24 | UINT16 overlay; |
| 25 | if(((address << 3) + 0xc0008) > (1024*1024)) |
| 26 | return; |
| 27 | for(int i = 0; i < 8; i++) |
| 28 | { |
| 29 | UINT32 addr = (address << 3) + i; |
| 30 | overlay = m_ram[addr + 0xc0000] << 1; |
| 31 | overlay = m_overlay[overlay + ((m_mode & 8) ? 512 : 0)] | (m_overlay[overlay + 1 + ((m_mode & 8) ? 512 : 0)] << 8); |
| 32 | color.set_r(pal->entry_color(m_ram[addr] | ((overlay & 0xf) << 8)).r()); |
| 33 | color.set_g(pal->entry_color(m_ram[addr + 0x40000] | ((overlay & 0xf0) << 4)).g()); |
| 34 | color.set_b(pal->entry_color(m_ram[addr + 0x80000] | (overlay & 0xf00)).b()); |
| 35 | bitmap.pix32(y, x + i) = color; |
| 36 | } |
| 37 | } |
| 38 | else |
| 39 | { |
| 40 | if(((address << 3) + 8) > (1024*1024)) |
| 41 | return; |
| 42 | for(int i = 0; i < 8; i++) |
| 43 | bitmap.pix32(y, x + i) = pal->entry_color(m_ram[(address << 3) + i]); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | static MACHINE_CONFIG_FRAGMENT( num_9_rev ) |
| 48 | MCFG_SCREEN_ADD("screen", RASTER) |
| 49 | MCFG_SCREEN_SIZE(512, 448) |
| 50 | MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 448-1) |
| 51 | MCFG_SCREEN_REFRESH_RATE(60) |
| 52 | MCFG_SCREEN_UPDATE_DRIVER(isa8_number_9_rev_device, screen_update) |
| 53 | MCFG_PALETTE_ADD("palette", 4096) |
| 54 | |
| 55 | MCFG_DEVICE_ADD("upd7220", UPD7220, XTAL_4_433619MHz/2) // unknown clock |
| 56 | MCFG_DEVICE_ADDRESS_MAP(AS_0, upd7220_map) |
| 57 | MCFG_UPD7220_DISPLAY_PIXELS_CALLBACK_OWNER(isa8_number_9_rev_device, hgdc_display_pixels) |
| 58 | MCFG_VIDEO_SET_SCREEN("screen") |
| 59 | MACHINE_CONFIG_END |
| 60 | |
| 61 | //------------------------------------------------- |
| 62 | // machine_config_additions - device-specific |
| 63 | // machine configurations |
| 64 | //------------------------------------------------- |
| 65 | |
| 66 | machine_config_constructor isa8_number_9_rev_device::device_mconfig_additions() const |
| 67 | { |
| 68 | return MACHINE_CONFIG_NAME( num_9_rev ); |
| 69 | } |
| 70 | |
| 71 | //************************************************************************** |
| 72 | // LIVE DEVICE |
| 73 | //************************************************************************** |
| 74 | |
| 75 | //------------------------------------------------- |
| 76 | // isa16_vga_device - constructor |
| 77 | //------------------------------------------------- |
| 78 | |
| 79 | isa8_number_9_rev_device::isa8_number_9_rev_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 80 | device_t(mconfig, ISA8_NUM_9_REV, "Number Nine Revolution 512x32/1024x8", tag, owner, clock, "number_9_rev", __FILE__), |
| 81 | device_isa8_card_interface(mconfig, *this), |
| 82 | m_upd7220(*this, "upd7220"), |
| 83 | m_palette(*this, "palette"), |
| 84 | m_ram(1024*1024), |
| 85 | m_overlay(1024) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | //------------------------------------------------- |
| 90 | // device_start - device-specific startup |
| 91 | //------------------------------------------------- |
| 92 | |
| 93 | void isa8_number_9_rev_device::device_start() |
| 94 | { |
| 95 | set_isa_device(); |
| 96 | |
| 97 | m_isa->install_memory(0xc0000, 0xc0001, 0, 0, read8_delegate(FUNC(upd7220_device::read), (upd7220_device *)m_upd7220), write8_delegate(FUNC(upd7220_device::write), (upd7220_device *)m_upd7220)); |
| 98 | m_isa->install_memory(0xc0100, 0xc03ff, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::pal8_r), this), write8_delegate(FUNC(isa8_number_9_rev_device::pal8_w), this)); |
| 99 | m_isa->install_memory(0xc0400, 0xc0401, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::bank_r), this), write8_delegate(FUNC(isa8_number_9_rev_device::bank_w), this)); |
| 100 | m_isa->install_memory(0xc0500, 0xc06ff, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::overlay_r), this), write8_delegate(FUNC(isa8_number_9_rev_device::overlay_w), this)); |
| 101 | m_isa->install_memory(0xc0700, 0xc070f, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::ctrl_r), this), write8_delegate(FUNC(isa8_number_9_rev_device::ctrl_w), this)); |
| 102 | m_isa->install_memory(0xc1000, 0xc3fff, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::pal12_r), this), write8_delegate(FUNC(isa8_number_9_rev_device::pal12_w), this)); |
| 103 | m_isa->install_memory(0xa0000, 0xaffff, 0, 0, read8_delegate(FUNC(isa8_number_9_rev_device::read8), this), write8_delegate(FUNC(isa8_number_9_rev_device::write8), this)); |
| 104 | } |
| 105 | |
| 106 | //------------------------------------------------- |
| 107 | // device_reset - device-specific reset |
| 108 | //------------------------------------------------- |
| 109 | |
| 110 | void isa8_number_9_rev_device::device_reset() |
| 111 | { |
| 112 | m_bank = 0; |
| 113 | m_mode = 0; |
| 114 | m_1024 = false; |
| 115 | } |
| 116 | |
| 117 | READ8_MEMBER(isa8_number_9_rev_device::read8) |
| 118 | { |
| 119 | if((m_mode & 1) && !m_1024) |
| 120 | return m_ram[offset + ((m_mode & 0xc) << 14)]; |
| 121 | else if((m_mode & 4) && !m_1024) |
| 122 | { |
| 123 | UINT32 newoff = ((offset & 3) << 18) | (m_bank << 14) | ((offset >> 2) & 0x3fff); |
| 124 | return m_ram[newoff]; |
| 125 | } |
| 126 | else |
| 127 | return m_ram[offset + (m_bank << 16)]; |
| 128 | } |
| 129 | |
| 130 | WRITE8_MEMBER(isa8_number_9_rev_device::write8) |
| 131 | { |
| 132 | if(m_1024 || ((m_mode & 6) == 0)) |
| 133 | m_ram[offset + (m_bank << 16)] = data; |
| 134 | else if((m_mode & 1) || ((m_mode & 6) == 2)) |
| 135 | { |
| 136 | UINT8 bank = m_bank; |
| 137 | if(m_mode & 1) |
| 138 | bank = (m_mode & 0xc) >> 2; |
| 139 | else |
| 140 | { |
| 141 | if(m_bank >= 12) |
| 142 | { |
| 143 | m_ram[offset + (m_bank << 16)] = data; |
| 144 | return; |
| 145 | } |
| 146 | bank &= 3; |
| 147 | } |
| 148 | |
| 149 | m_ram[offset + (bank << 16)] = data; |
| 150 | m_ram[offset + ((bank + 4) << 16)] = data; |
| 151 | m_ram[offset + ((bank + 8) << 16)] = data; |
| 152 | } |
| 153 | else if(m_mode & 4) |
| 154 | { |
| 155 | UINT32 newoff = ((offset & 3) << 18) | (m_bank << 14) | ((offset >> 2) & 0x3fff); |
| 156 | if((newoff >= 0xc0000) && ((m_mode & 6) == 6)) |
| 157 | return; |
| 158 | m_ram[newoff] = data; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | READ8_MEMBER(isa8_number_9_rev_device::pal8_r) |
| 163 | { |
| 164 | offset += 0x100; |
| 165 | palette_t *pal = m_palette->palette(); |
| 166 | switch(offset & 0xf00) |
| 167 | { |
| 168 | case 0x100: |
| 169 | return pal->entry_color(offset).r(); |
| 170 | case 0x200: |
| 171 | return pal->entry_color(offset).g(); |
| 172 | case 0x300: |
| 173 | return pal->entry_color(offset).b(); |
| 174 | } |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | WRITE8_MEMBER(isa8_number_9_rev_device::pal8_w) |
| 179 | { |
| 180 | offset += 0x100; |
| 181 | palette_t *pal = m_palette->palette(); |
| 182 | rgb_t pen = pal->entry_color(offset); |
| 183 | switch(offset & 0xf00) |
| 184 | { |
| 185 | case 0x100: |
| 186 | pen.set_r(data); |
| 187 | break; |
| 188 | case 0x200: |
| 189 | pen.set_g(data); |
| 190 | break; |
| 191 | case 0x300: |
| 192 | pen.set_b(data); |
| 193 | break; |
| 194 | } |
| 195 | pal->entry_set_color(offset, pen); |
| 196 | } |
| 197 | |
| 198 | READ8_MEMBER(isa8_number_9_rev_device::pal12_r) |
| 199 | { |
| 200 | UINT16 color = offset & 0xfff; |
| 201 | palette_t *pal = m_palette->palette(); |
| 202 | switch(offset & 0xf000) |
| 203 | { |
| 204 | case 0x0000: |
| 205 | return pal->entry_color(color).r(); |
| 206 | case 0x1000: |
| 207 | return pal->entry_color(color).g(); |
| 208 | case 0x2000: |
| 209 | return pal->entry_color(color).b(); |
| 210 | } |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | WRITE8_MEMBER(isa8_number_9_rev_device::pal12_w) |
| 215 | { |
| 216 | UINT16 color = offset & 0xfff; |
| 217 | palette_t *pal = m_palette->palette(); |
| 218 | rgb_t pen = pal->entry_color(color); |
| 219 | switch(offset & 0xf000) |
| 220 | { |
| 221 | case 0x0000: |
| 222 | pen.set_r(data); |
| 223 | break; |
| 224 | case 0x1000: |
| 225 | pen.set_g(data); |
| 226 | break; |
| 227 | case 0x2000: |
| 228 | pen.set_b(data); |
| 229 | break; |
| 230 | } |
| 231 | pal->entry_set_color(color, pen); |
| 232 | } |
| 233 | |
| 234 | READ8_MEMBER(isa8_number_9_rev_device::overlay_r) |
| 235 | { |
| 236 | return m_overlay[offset + ((m_mode & 8) ? 512 : 0)]; |
| 237 | } |
| 238 | WRITE8_MEMBER(isa8_number_9_rev_device::overlay_w) |
| 239 | { |
| 240 | m_overlay[offset + ((m_mode & 8) ? 512 : 0)] = data; |
| 241 | } |
| 242 | |
| 243 | READ8_MEMBER(isa8_number_9_rev_device::bank_r) |
| 244 | { |
| 245 | return m_bank; |
| 246 | } |
| 247 | |
| 248 | WRITE8_MEMBER(isa8_number_9_rev_device::bank_w) |
| 249 | { |
| 250 | m_bank = data & 0xf; |
| 251 | } |
| 252 | |
| 253 | READ8_MEMBER(isa8_number_9_rev_device::ctrl_r) |
| 254 | { |
| 255 | switch(offset & 0xf) |
| 256 | { |
| 257 | case 0: |
| 258 | case 1: |
| 259 | case 2: |
| 260 | case 3: |
| 261 | // zoom, set to same value as 7220 external zoom factor |
| 262 | break; |
| 263 | case 4: |
| 264 | return (m_mode & 2) ? 0xff : 0; |
| 265 | case 5: |
| 266 | return (m_mode & 4) ? 0xff : 0; |
| 267 | case 6: |
| 268 | return (m_mode & 8) ? 0xff : 0; |
| 269 | case 15: |
| 270 | return (m_mode & 1) ? 0xff : 0; |
| 271 | } |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | WRITE8_MEMBER(isa8_number_9_rev_device::ctrl_w) |
| 276 | { |
| 277 | switch(offset & 0xf) |
| 278 | { |
| 279 | case 0: |
| 280 | case 1: |
| 281 | case 2: |
| 282 | case 3: |
| 283 | // zoom |
| 284 | break; |
| 285 | case 4: |
| 286 | if(data & 0x80) |
| 287 | m_mode |= 2; |
| 288 | else |
| 289 | m_mode &= ~2; |
| 290 | break; |
| 291 | case 5: |
| 292 | if(data & 0x80) |
| 293 | m_mode |= 4; |
| 294 | else |
| 295 | m_mode &= ~4; |
| 296 | break; |
| 297 | case 6: |
| 298 | if(data & 0x80) |
| 299 | m_mode |= 8; |
| 300 | else |
| 301 | m_mode &= ~8; |
| 302 | break; |
| 303 | case 15: |
| 304 | if(data & 0x80) |
| 305 | m_mode |= 1; |
| 306 | else |
| 307 | m_mode &= ~1; |
| 308 | break; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | UINT32 isa8_number_9_rev_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 313 | { |
| 314 | rectangle visarea = screen.visible_area(); |
| 315 | // try to support the 1024x8 or at least don't crash as there's no way to detect it |
| 316 | m_1024 = (visarea.width() * visarea.height()) > (512 * 512); |
| 317 | return m_upd7220->screen_update(screen, bitmap, cliprect); |
| 318 | } |
trunk/src/emu/bus/isa/num9rev.h
r0 | r241717 | |
| 1 | #pragma once |
| 2 | |
| 3 | #ifndef __NUM9REV_H__ |
| 4 | #define __NUM9REV_H__ |
| 5 | |
| 6 | #include "emu.h" |
| 7 | #include "isa.h" |
| 8 | #include "video/upd7220.h" |
| 9 | #include "machine/bankdev.h" |
| 10 | |
| 11 | //************************************************************************** |
| 12 | // TYPE DEFINITIONS |
| 13 | //************************************************************************** |
| 14 | |
| 15 | // ======================> isa16_vga_device |
| 16 | |
| 17 | class isa8_number_9_rev_device : |
| 18 | public device_t, |
| 19 | public device_isa8_card_interface |
| 20 | { |
| 21 | public: |
| 22 | // construction/destruction |
| 23 | isa8_number_9_rev_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 24 | |
| 25 | // optional information overrides |
| 26 | virtual machine_config_constructor device_mconfig_additions() const; |
| 27 | |
| 28 | UPD7220_DISPLAY_PIXELS_MEMBER(hgdc_display_pixels); |
| 29 | DECLARE_READ8_MEMBER(pal8_r); |
| 30 | DECLARE_WRITE8_MEMBER(pal8_w); |
| 31 | DECLARE_READ8_MEMBER(pal12_r); |
| 32 | DECLARE_WRITE8_MEMBER(pal12_w); |
| 33 | DECLARE_READ8_MEMBER(overlay_r); |
| 34 | DECLARE_WRITE8_MEMBER(overlay_w); |
| 35 | DECLARE_READ8_MEMBER(bank_r); |
| 36 | DECLARE_WRITE8_MEMBER(bank_w); |
| 37 | DECLARE_READ8_MEMBER(ctrl_r); |
| 38 | DECLARE_WRITE8_MEMBER(ctrl_w); |
| 39 | DECLARE_READ8_MEMBER(read8); |
| 40 | DECLARE_WRITE8_MEMBER(write8); |
| 41 | |
| 42 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 43 | protected: |
| 44 | // device-level overrides |
| 45 | virtual void device_start(); |
| 46 | virtual void device_reset(); |
| 47 | private: |
| 48 | required_device<upd7220_device> m_upd7220; |
| 49 | required_device<palette_device> m_palette; |
| 50 | dynamic_buffer m_ram; |
| 51 | dynamic_buffer m_overlay; |
| 52 | |
| 53 | UINT8 m_bank; |
| 54 | UINT8 m_mode; |
| 55 | bool m_1024; |
| 56 | }; |
| 57 | |
| 58 | // device type definition |
| 59 | extern const device_type ISA8_NUM_9_REV; |
| 60 | |
| 61 | #endif /* __NUM9REV_H__ */ |