src/mess/machine/a2videoterm.c
| r0 | r14980 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | a2videoterm.c |
| 4 | |
| 5 | Implementation of the Videx VideoTerm 80-column card |
| 6 | |
| 7 | Notes (from Videoterm user's manual, which contains |
| 8 | schematics and firmware source listings). |
| 9 | |
| 10 | C0nX: C0n0 is 6845 register address, |
| 11 | C0n1 is 6845 register data. |
| 12 | |
| 13 | Bits 2 & 3 on any access to C0nX set the VRAM page at CC00. |
| 14 | |
| 15 | C800-CBFF: ROM |
| 16 | CC00-CDFF: VRAM window |
| 17 | |
| 18 | TODO: |
| 19 | Cursor is probably not completely right. |
| 20 | Add font ROM select. |
| 21 | |
| 22 | *********************************************************************/ |
| 23 | |
| 24 | #include "a2videoterm.h" |
| 25 | #include "includes/apple2.h" |
| 26 | |
| 27 | |
| 28 | /*************************************************************************** |
| 29 | PARAMETERS |
| 30 | ***************************************************************************/ |
| 31 | |
| 32 | //************************************************************************** |
| 33 | // GLOBAL VARIABLES |
| 34 | //************************************************************************** |
| 35 | |
| 36 | const device_type A2BUS_VIDEOTERM = &device_creator<a2bus_videoterm_device>; |
| 37 | |
| 38 | #define VIDEOTERM_ROM_REGION "vterm_rom" |
| 39 | #define VIDEOTERM_GFX_REGION "vterm_gfx" |
| 40 | #define VIDEOTERM_SCREEN_NAME "vterm_screen" |
| 41 | #define VIDEOTERM_MC6845_NAME "mc6845_vterm" |
| 42 | |
| 43 | #define MDA_CLOCK 16257000 |
| 44 | |
| 45 | static MC6845_UPDATE_ROW( videoterm_update_row ); |
| 46 | |
| 47 | static const mc6845_interface mc6845_mda_intf = |
| 48 | { |
| 49 | VIDEOTERM_SCREEN_NAME, /* screen number */ |
| 50 | 8, /* number of pixels per video memory address */ |
| 51 | NULL, /* begin_update */ |
| 52 | videoterm_update_row, /* update_row */ |
| 53 | NULL, /* end_update */ |
| 54 | DEVCB_NULL, /* on_de_changed */ |
| 55 | DEVCB_NULL, /* on_cur_changed */ |
| 56 | DEVCB_NULL, /* on hsync changed */ |
| 57 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_videoterm_device, vsync_changed), /* on_vsync_changed */ |
| 58 | NULL |
| 59 | }; |
| 60 | |
| 61 | MACHINE_CONFIG_FRAGMENT( a2videoterm ) |
| 62 | MCFG_SCREEN_ADD( VIDEOTERM_SCREEN_NAME, RASTER) // 560x216? (80x24 7x9 characters) |
| 63 | MCFG_SCREEN_RAW_PARAMS(MDA_CLOCK, 882, 0, 720, 370, 0, 350 ) |
| 64 | MCFG_SCREEN_UPDATE_DEVICE( VIDEOTERM_MC6845_NAME, mc6845_device, screen_update ) |
| 65 | |
| 66 | MCFG_MC6845_ADD( VIDEOTERM_MC6845_NAME, MC6845, MDA_CLOCK/9, mc6845_mda_intf) |
| 67 | MACHINE_CONFIG_END |
| 68 | |
| 69 | ROM_START( a2videoterm ) |
| 70 | ROM_REGION(0x400, VIDEOTERM_ROM_REGION, 0) |
| 71 | ROM_LOAD( "videx videoterm rom 2.4.bin", 0x000000, 0x000400, CRC(bbe3bb28) SHA1(bb653836e84850ce3197f461d4e19355f738cfbf) ) |
| 72 | |
| 73 | ROM_REGION(0x5000, VIDEOTERM_GFX_REGION, 0) |
| 74 | ROM_LOAD( "videx videoterm character rom normal.bin", 0x000000, 0x000800, CRC(87f89f08) SHA1(410b54f33d13c82e3857f1be906d93a8c5b8d321) ) |
| 75 | ROM_LOAD( "videx videoterm character rom normal uppercase.bin", 0x000800, 0x000800, CRC(3d94a7a4) SHA1(5518254f24bc945aab13bc71ecc9526d6dd8e033) ) |
| 76 | ROM_LOAD( "videx videoterm character rom apl.bin", 0x001000, 0x000800, CRC(1adb704e) SHA1(a95df910eca33188cacee333b1325aa47edbcc25) ) |
| 77 | ROM_LOAD( "videx videoterm character rom epson.bin", 0x001800, 0x000800, CRC(0c6ef8d0) SHA1(db72c0c120086f1aa4a87120c5d7993c4a9d3a18) ) |
| 78 | ROM_LOAD( "videx videoterm character rom french.bin", 0x002000, 0x000800, CRC(266aa837) SHA1(2c6b4e9d342dbb2de8e278740f11925a9d8c6616) ) |
| 79 | ROM_LOAD( "videx videoterm character rom german.bin", 0x002800, 0x000800, CRC(df7324fa) SHA1(0ce58d2ffadbebc8db9f85bbb9a08a4f142af682) ) |
| 80 | ROM_LOAD( "videx videoterm character rom katakana.bin", 0x003000, 0x000800, CRC(b728690e) SHA1(e018fa66b0ff560313bb35757c9ce7adecae0c3a) ) |
| 81 | ROM_LOAD( "videx videoterm character rom spanish.bin", 0x003800, 0x000800, CRC(439eac08) SHA1(d6f9f8eb7702440d9ae39129ea4f480b80fc4608) ) |
| 82 | ROM_LOAD( "videx videoterm character rom super and subscript.bin", 0x004000, 0x000800, CRC(08b7c538) SHA1(7f4029d97be05680fe695debe07cea07666419e0) ) |
| 83 | ROM_LOAD( "videx videoterm character rom symbol.bin", 0x004800, 0x000800, CRC(82bce582) SHA1(29dfa8c5257dbf25651c6bffa9cdb453482aa70e) ) |
| 84 | ROM_END |
| 85 | |
| 86 | /*************************************************************************** |
| 87 | FUNCTION PROTOTYPES |
| 88 | ***************************************************************************/ |
| 89 | |
| 90 | //------------------------------------------------- |
| 91 | // machine_config_additions - device-specific |
| 92 | // machine configurations |
| 93 | //------------------------------------------------- |
| 94 | |
| 95 | machine_config_constructor a2bus_videoterm_device::device_mconfig_additions() const |
| 96 | { |
| 97 | return MACHINE_CONFIG_NAME( a2videoterm ); |
| 98 | } |
| 99 | |
| 100 | //------------------------------------------------- |
| 101 | // rom_region - device-specific ROM region |
| 102 | //------------------------------------------------- |
| 103 | |
| 104 | const rom_entry *a2bus_videoterm_device::device_rom_region() const |
| 105 | { |
| 106 | return ROM_NAME( a2videoterm ); |
| 107 | } |
| 108 | |
| 109 | //************************************************************************** |
| 110 | // LIVE DEVICE |
| 111 | //************************************************************************** |
| 112 | |
| 113 | a2bus_videoterm_device::a2bus_videoterm_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : |
| 114 | device_t(mconfig, type, name, tag, owner, clock), |
| 115 | device_a2bus_card_interface(mconfig, *this), |
| 116 | m_crtc(*this, VIDEOTERM_MC6845_NAME) |
| 117 | { |
| 118 | m_shortname = "a2vidtrm"; |
| 119 | } |
| 120 | |
| 121 | a2bus_videoterm_device::a2bus_videoterm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 122 | device_t(mconfig, A2BUS_VIDEOTERM, "Videx VideoTerm", tag, owner, clock), |
| 123 | device_a2bus_card_interface(mconfig, *this), |
| 124 | m_crtc(*this, VIDEOTERM_MC6845_NAME) |
| 125 | { |
| 126 | m_shortname = "a2vidtrm"; |
| 127 | } |
| 128 | |
| 129 | //------------------------------------------------- |
| 130 | // device_start - device-specific startup |
| 131 | //------------------------------------------------- |
| 132 | |
| 133 | void a2bus_videoterm_device::device_start() |
| 134 | { |
| 135 | // set_a2bus_device makes m_slot valid |
| 136 | set_a2bus_device(); |
| 137 | |
| 138 | astring tempstring; |
| 139 | m_rom = device().machine().root_device().memregion(this->subtag(tempstring, VIDEOTERM_ROM_REGION))->base(); |
| 140 | |
| 141 | astring tempstring2; |
| 142 | m_chrrom = device().machine().root_device().memregion(this->subtag(tempstring2, VIDEOTERM_GFX_REGION))->base(); |
| 143 | |
| 144 | memset(m_ram, 0, 4*512); |
| 145 | |
| 146 | save_item(NAME(m_ram)); |
| 147 | save_item(NAME(m_framecnt)); |
| 148 | save_item(NAME(m_rambank)); |
| 149 | } |
| 150 | |
| 151 | void a2bus_videoterm_device::device_reset() |
| 152 | { |
| 153 | m_rambank = 0; |
| 154 | m_framecnt = 0; |
| 155 | } |
| 156 | |
| 157 | |
| 158 | /*------------------------------------------------- |
| 159 | read_c0nx - called for reads from this card's c0nx space |
| 160 | -------------------------------------------------*/ |
| 161 | |
| 162 | UINT8 a2bus_videoterm_device::read_c0nx(address_space &space, UINT8 offset) |
| 163 | { |
| 164 | // printf("Read c0n%x (PC=%x)\n", offset, cpu_get_pc(&space.device())); |
| 165 | |
| 166 | m_rambank = ((offset>>2) & 3) * 512; |
| 167 | |
| 168 | if (offset == 1) |
| 169 | { |
| 170 | return m_crtc->register_r(space, offset); // status_r? |
| 171 | } |
| 172 | |
| 173 | return 0xff; |
| 174 | } |
| 175 | |
| 176 | |
| 177 | /*------------------------------------------------- |
| 178 | write_c0nx - called for writes to this card's c0nx space |
| 179 | -------------------------------------------------*/ |
| 180 | |
| 181 | void a2bus_videoterm_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data) |
| 182 | { |
| 183 | // printf("Write %02x to c0n%x (PC=%x)\n", data, offset, cpu_get_pc(&space.device())); |
| 184 | |
| 185 | if (offset == 0) |
| 186 | { |
| 187 | m_crtc->address_w(space, offset, data); |
| 188 | } |
| 189 | else if (offset == 1) |
| 190 | { |
| 191 | m_crtc->register_w(space, offset, data); |
| 192 | } |
| 193 | |
| 194 | m_rambank = ((offset>>2) & 3) * 512; |
| 195 | } |
| 196 | |
| 197 | /*------------------------------------------------- |
| 198 | read_cnxx - called for reads from this card's cnxx space |
| 199 | -------------------------------------------------*/ |
| 200 | |
| 201 | UINT8 a2bus_videoterm_device::read_cnxx(address_space &space, UINT8 offset) |
| 202 | { |
| 203 | // one slot image at the start of the ROM, it appears |
| 204 | return m_rom[offset]; |
| 205 | } |
| 206 | |
| 207 | /*------------------------------------------------- |
| 208 | write_cnxx - called for writes to this card's cnxx space |
| 209 | the firmware writes here to switch in our $C800 a lot |
| 210 | -------------------------------------------------*/ |
| 211 | void a2bus_videoterm_device::write_cnxx(address_space &space, UINT8 offset, UINT8 data) |
| 212 | { |
| 213 | } |
| 214 | |
| 215 | /*------------------------------------------------- |
| 216 | read_c800 - called for reads from this card's c800 space |
| 217 | -------------------------------------------------*/ |
| 218 | |
| 219 | UINT8 a2bus_videoterm_device::read_c800(address_space &space, UINT16 offset) |
| 220 | { |
| 221 | // ROM at c800-cbff |
| 222 | // bankswitched RAM at cc00-cdff |
| 223 | if (offset < 0x400) |
| 224 | { |
| 225 | // printf("Read VRAM at %x = %02x\n", offset+m_rambank, m_ram[offset + m_rambank]); |
| 226 | return m_rom[offset]; |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | return m_ram[(offset-0x400) + m_rambank]; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | /*------------------------------------------------- |
| 235 | write_c800 - called for writes to this card's c800 space |
| 236 | -------------------------------------------------*/ |
| 237 | void a2bus_videoterm_device::write_c800(address_space &space, UINT16 offset, UINT8 data) |
| 238 | { |
| 239 | if (offset >= 0x400) |
| 240 | { |
| 241 | // printf("%02x to VRAM at %x\n", data, offset-0x400+m_rambank); |
| 242 | m_ram[(offset-0x400) + m_rambank] = data; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | static MC6845_UPDATE_ROW( videoterm_update_row ) |
| 247 | { |
| 248 | a2bus_videoterm_device *vterm = downcast<a2bus_videoterm_device *>(device->owner()); |
| 249 | const rgb_t *palette = palette_entry_list_raw(bitmap.palette()); |
| 250 | UINT32 *p = &bitmap.pix32(y); |
| 251 | UINT16 chr_base = ra; //( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra; |
| 252 | int i; |
| 253 | |
| 254 | for ( i = 0; i < x_count; i++ ) |
| 255 | { |
| 256 | UINT16 offset = ( ma + i ) & 0x7ff; |
| 257 | UINT8 chr = vterm->m_ram[ offset ]; |
| 258 | UINT8 data = vterm->m_chrrom[ chr_base + chr * 16 ]; |
| 259 | UINT8 fg = 15; |
| 260 | UINT8 bg = 0; |
| 261 | |
| 262 | if ( i == cursor_x ) |
| 263 | { |
| 264 | if ( vterm->m_framecnt & 0x08 ) |
| 265 | { |
| 266 | data = 0xFF; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | *p = palette[( data & 0x80 ) ? fg : bg]; p++; |
| 271 | *p = palette[( data & 0x40 ) ? fg : bg]; p++; |
| 272 | *p = palette[( data & 0x20 ) ? fg : bg]; p++; |
| 273 | *p = palette[( data & 0x10 ) ? fg : bg]; p++; |
| 274 | *p = palette[( data & 0x08 ) ? fg : bg]; p++; |
| 275 | *p = palette[( data & 0x04 ) ? fg : bg]; p++; |
| 276 | *p = palette[( data & 0x02 ) ? fg : bg]; p++; |
| 277 | *p = palette[( data & 0x01 ) ? fg : bg]; p++; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | WRITE_LINE_MEMBER( a2bus_videoterm_device::vsync_changed ) |
| 282 | { |
| 283 | if ( state ) |
| 284 | { |
| 285 | m_framecnt++; |
| 286 | } |
| 287 | } |
| 288 | |
src/mess/machine/a2videoterm.h
| r0 | r14980 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | a2videoterm.h |
| 4 | |
| 5 | Implementation of the Apple II Memory Expansion Card |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef __A2BUS_VIDEOTERM__ |
| 10 | #define __A2BUS_VIDEOTERM__ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "machine/a2bus.h" |
| 14 | #include "video/mc6845.h" |
| 15 | |
| 16 | //************************************************************************** |
| 17 | // TYPE DEFINITIONS |
| 18 | //************************************************************************** |
| 19 | |
| 20 | class a2bus_videoterm_device: |
| 21 | public device_t, |
| 22 | public device_a2bus_card_interface |
| 23 | { |
| 24 | public: |
| 25 | // construction/destruction |
| 26 | a2bus_videoterm_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| 27 | a2bus_videoterm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 28 | |
| 29 | // optional information overrides |
| 30 | virtual machine_config_constructor device_mconfig_additions() const; |
| 31 | virtual const rom_entry *device_rom_region() const; |
| 32 | |
| 33 | DECLARE_WRITE_LINE_MEMBER(vsync_changed); |
| 34 | |
| 35 | UINT8 *m_rom, *m_chrrom; |
| 36 | UINT8 m_ram[512*4]; |
| 37 | int m_framecnt; |
| 38 | |
| 39 | protected: |
| 40 | virtual void device_start(); |
| 41 | virtual void device_reset(); |
| 42 | |
| 43 | // overrides of standard a2bus slot functions |
| 44 | virtual UINT8 read_c0nx(address_space &space, UINT8 offset); |
| 45 | virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data); |
| 46 | virtual UINT8 read_cnxx(address_space &space, UINT8 offset); |
| 47 | virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data); |
| 48 | virtual UINT8 read_c800(address_space &space, UINT16 offset); |
| 49 | virtual void write_c800(address_space &space, UINT16 offset, UINT8 data); |
| 50 | |
| 51 | required_device<mc6845_device> m_crtc; |
| 52 | |
| 53 | private: |
| 54 | int m_rambank; |
| 55 | }; |
| 56 | |
| 57 | // device type definition |
| 58 | extern const device_type A2BUS_VIDEOTERM; |
| 59 | |
| 60 | #endif /* __A2BUS_VIDEOTERM__ */ |
| 61 | |