src/mess/machine/rm380z.c
| r0 | r13914 | |
| 1 | |
| 2 | /* |
| 3 | |
| 4 | RM 380Z machine |
| 5 | |
| 6 | */ |
| 7 | |
| 8 | #include "emu.h" |
| 9 | #include "cpu/z80/z80.h" |
| 10 | #include "machine/ram.h" |
| 11 | #include "imagedev/flopdrv.h" |
| 12 | #include "machine/terminal.h" |
| 13 | #include "machine/wd17xx.h" |
| 14 | #include "includes/rm380z.h" |
| 15 | |
| 16 | |
| 17 | WRITE8_MEMBER( rm380z_state::port_write ) |
| 18 | { |
| 19 | switch ( offset ) |
| 20 | { |
| 21 | case 0x00: // PORT0 |
| 22 | //printf("write of [%x] to FBFC\n",data); |
| 23 | m_port0 = data; |
| 24 | if (data&0x01) |
| 25 | { |
| 26 | //printf("WARNING: bit0 of port0 reset\n"); |
| 27 | m_port0_kbd=0; |
| 28 | } |
| 29 | config_memory_map(); |
| 30 | break; |
| 31 | |
| 32 | case 0x01: // screen line counter (?) |
| 33 | printf("write of [%x] to FBFD at PC [%x]\n",data,cpu_get_pc(machine().device("maincpu"))); |
| 34 | m_fbfd=data; |
| 35 | break; |
| 36 | |
| 37 | case 0x02: // something related to screen position |
| 38 | //printf("write of [%x] to FBFE\n",data); |
| 39 | m_fbfe=data; |
| 40 | break; |
| 41 | |
| 42 | case 0x03: // user I/O port |
| 43 | //printf("write of [%x] to FBFF\n",data); |
| 44 | //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data ); |
| 45 | break; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | READ8_MEMBER( rm380z_state::port_read ) |
| 50 | { |
| 51 | UINT8 data = 0xFF; |
| 52 | |
| 53 | switch ( offset ) |
| 54 | { |
| 55 | case 0x00: // PORT0 |
| 56 | //m_port0_kbd=getKeyboard(); |
| 57 | data = m_port0_kbd; |
| 58 | //if (m_port0_kbd!=0) m_port0_kbd=0; |
| 59 | //m_port0_kbd=0; |
| 60 | //printf("read of port0 (kbd) at [%f] from PC [%x]\n",machine().time().as_double(),cpu_get_pc(machine().device("maincpu"))); |
| 61 | break; |
| 62 | |
| 63 | case 0x01: // "counter" (?) |
| 64 | //printf("%s: Read from counter FBFD\n", machine().describe_context()); |
| 65 | data = 0x00; |
| 66 | break; |
| 67 | |
| 68 | case 0x02: // PORT1 |
| 69 | data = m_port1; |
| 70 | break; |
| 71 | |
| 72 | case 0x03: // user port |
| 73 | //printf("%s: Read from user port\n", machine().describe_context()); |
| 74 | break; |
| 75 | } |
| 76 | |
| 77 | return data; |
| 78 | } |
| 79 | |
| 80 | #define LINE_SUBDIVISION 40 |
| 81 | #define TIMER_SPEED 50*100*LINE_SUBDIVISION |
| 82 | |
| 83 | // |
| 84 | // this simulates line+frame blanking |
| 85 | // according to the System manual, "frame blanking bit (bit 6) of port1 becomes high |
| 86 | // for about 4.5 milliseconds every 20 milliseconds" |
| 87 | // |
| 88 | |
| 89 | static TIMER_CALLBACK(static_vblank_timer) |
| 90 | { |
| 91 | //printf("timer callback called at [%f]\n",machine.time().as_double()); |
| 92 | |
| 93 | rm380z_state *state = machine.driver_data<rm380z_state>(); |
| 94 | |
| 95 | state->m_rasterlineCtr++; |
| 96 | state->m_rasterlineCtr%=(100*LINE_SUBDIVISION); |
| 97 | |
| 98 | if (state->m_rasterlineCtr>=((100-22)*LINE_SUBDIVISION)) |
| 99 | { |
| 100 | // frame blanking |
| 101 | state->m_port1=0x41; |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | state->m_port1=0x00; |
| 106 | } |
| 107 | |
| 108 | if ((state->m_rasterlineCtr%LINE_SUBDIVISION)==0) state->m_port1|=0x80; // line blanking |
| 109 | } |
| 110 | |
| 111 | // |
| 112 | // ports c0-cf are related to the floppy disc controller |
| 113 | // c0-c3: wd1771 |
| 114 | // c4-c8: disk drive port0 |
| 115 | // |
| 116 | // CP/M booting: |
| 117 | // from the service manual: "the B command reads a sector from drive 0, track 0, sector 1 into memory |
| 118 | // at 0x0080 to 0x00FF, then jumps to it if there is no error." |
| 119 | // |
| 120 | |
| 121 | /* |
| 122 | WRITE8_MEMBER( rm380z_state::rm380z_io_w ) |
| 123 | { |
| 124 | UINT8 portnum=offset&0xff; |
| 125 | device_t *fdc = machine().device("wd1771"); |
| 126 | |
| 127 | //printf("port write of [%x] at [%x] from PC [%x]\n",data,portnum,cpu_get_pc(machine().device("maincpu"))); |
| 128 | |
| 129 | if (portnum==0xc0) |
| 130 | { |
| 131 | wd17xx_command_w(fdc, 0, data); |
| 132 | //printf("wrote command [%x] to floppy disk\n",data); |
| 133 | } |
| 134 | else if (portnum==0xc1) |
| 135 | { |
| 136 | wd17xx_track_w(fdc, 0, data); |
| 137 | //printf("wrote track data [%x] to floppy disk\n",data); |
| 138 | } |
| 139 | else if (portnum==0xc2) |
| 140 | { |
| 141 | wd17xx_sector_w(fdc, 0, data); |
| 142 | //printf("wrote sector data [%x] to floppy disk\n",data); |
| 143 | } |
| 144 | else if (portnum==0xc3) |
| 145 | { |
| 146 | wd17xx_data_w(fdc, 0, data); |
| 147 | //printf("wrote data [%x] to floppy disk\n",data); |
| 148 | } |
| 149 | else if (portnum==0xc4) |
| 150 | { |
| 151 | //printf("disk drive port0 write [%x]\n",data); |
| 152 | |
| 153 | // drive port0 |
| 154 | if (data&0x01) |
| 155 | { |
| 156 | // drive select bit 0 |
| 157 | wd17xx_set_drive(fdc,0); |
| 158 | } |
| 159 | |
| 160 | if (data&0x08) |
| 161 | { |
| 162 | // motor on |
| 163 | } |
| 164 | |
| 165 | // "MSEL (dir/side select bit) |
| 166 | if (data&0x20) |
| 167 | { |
| 168 | wd17xx_set_side(fdc,1); |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | wd17xx_set_side(fdc,0); |
| 173 | } |
| 174 | |
| 175 | // set drive en- (?) |
| 176 | if (data&0x40) |
| 177 | { |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | READ8_MEMBER( rm380z_state::rm380z_io_r ) |
| 183 | { |
| 184 | UINT8 retval=0; |
| 185 | UINT8 portnum=offset&0xff; |
| 186 | device_t *fdc = machine().device("wd1771"); |
| 187 | |
| 188 | //printf("port read at [%x] from PC [%x]\n",portnum,cpu_get_pc(machine().device("maincpu"))); |
| 189 | |
| 190 | if (portnum==0xc0) |
| 191 | { |
| 192 | retval=wd17xx_status_r(fdc,0); |
| 193 | //printf("disk drive status read is [%x]\n",retval); |
| 194 | } |
| 195 | else if (portnum==0xc1) |
| 196 | { |
| 197 | retval=wd17xx_track_r(fdc, 0); |
| 198 | //printf("disk drive track read is [%x]\n",retval); |
| 199 | } |
| 200 | else if (portnum==0xc2) |
| 201 | { |
| 202 | retval=wd17xx_sector_r(fdc, 0); |
| 203 | //printf("disk drive sector read is [%x]\n",retval); |
| 204 | } |
| 205 | else if (portnum==0xc3) |
| 206 | { |
| 207 | retval=wd17xx_data_r(fdc, 0); |
| 208 | //printf("disk drive data read [%x] at PC [%x]\n",retval,cpu_get_pc(machine().device("maincpu"))); |
| 209 | } |
| 210 | else if (portnum==0xc9) |
| 211 | { |
| 212 | return 0x01; |
| 213 | } |
| 214 | else if (portnum==0xcc) |
| 215 | { |
| 216 | // CTC (?) |
| 217 | return 0x00; |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | printf("Unknown system port read [%x] PC [%x]\n",portnum,cpu_get_pc(machine().device("maincpu"))); |
| 222 | return 0x00; |
| 223 | } |
| 224 | |
| 225 | return retval; |
| 226 | } |
| 227 | */ |
| 228 | |
| 229 | WRITE8_MEMBER( rm380z_state::disk_0_control ) |
| 230 | { |
| 231 | device_t *fdc = machine().device("wd1771"); |
| 232 | |
| 233 | printf("disk drive port0 write [%x]\n",data); |
| 234 | |
| 235 | // drive port0 |
| 236 | if (data&0x01) |
| 237 | { |
| 238 | // drive select bit 0 |
| 239 | wd17xx_set_drive(fdc,0); |
| 240 | } |
| 241 | |
| 242 | if (data&0x08) |
| 243 | { |
| 244 | // motor on |
| 245 | } |
| 246 | |
| 247 | // "MSEL (dir/side select bit) |
| 248 | if (data&0x20) |
| 249 | { |
| 250 | wd17xx_set_side(fdc,1); |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | wd17xx_set_side(fdc,0); |
| 255 | } |
| 256 | |
| 257 | // set drive en- (?) |
| 258 | if (data&0x40) |
| 259 | { |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | WRITE8_MEMBER( rm380z_state::keyboard_put ) |
| 264 | { |
| 265 | m_port0_kbd = data; |
| 266 | } |
| 267 | |
| 268 | void rm380z_state::machine_reset() |
| 269 | { |
| 270 | m_port0=0x00; |
| 271 | m_port0_kbd=0x00; |
| 272 | m_port1=0x00; |
| 273 | m_fbfd=0x00; |
| 274 | m_fbfe=0x00; |
| 275 | m_old_fbfd=0x00; |
| 276 | |
| 277 | m_rasterlineCtr=0; |
| 278 | |
| 279 | memset(m_mainVideoram,0,0x600); |
| 280 | memset(m_vramattribs,0,0x600); |
| 281 | memset(m_vramchars,0,0x600); |
| 282 | memset(m_vram,0,0x600); |
| 283 | |
| 284 | config_memory_map(); |
| 285 | |
| 286 | machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer)); |
| 287 | |
| 288 | wd17xx_reset(machine().device("wd1771")); |
| 289 | } |
| 290 | |
| 291 | void rm380z_state::config_memory_map() |
| 292 | { |
| 293 | address_space *program = m_maincpu->space(AS_PROGRAM); |
| 294 | UINT8 *rom = machine().region(MAINCPU_TAG)->base(); |
| 295 | UINT8* m_ram_p = m_messram->pointer(); |
| 296 | |
| 297 | if ( PORTS_ENABLED_HIGH ) |
| 298 | { |
| 299 | program->install_ram( 0x0000, 0xDFFF, m_ram_p ); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | program->install_rom( 0x0000, 0x0FFF, rom ); |
| 304 | program->install_readwrite_handler(0x1BFC, 0x1BFF,read8_delegate(FUNC(rm380z_state::port_read), this),write8_delegate(FUNC(rm380z_state::port_write), this) ); |
| 305 | program->install_rom( 0x1C00, 0x1DFF, rom + 0x1400 ); |
| 306 | program->install_ram( 0x4000, 0xDFFF, m_ram_p ); |
| 307 | } |
| 308 | } |
src/mess/drivers/rm380z.c
| r13913 | r13914 | |
| 1 | 1 | |
| 2 | 2 | /* |
| 3 | 3 | |
| 4 | | Research Machines RM-380Z |
| 5 | | microcomputer produced by Research Machines Limited |
| 4 | Research Machines 380Z (aka "RML 380Z" or "RM 380Z") |
| 5 | Microcomputer produced by Research Machines Limited, Oxford, UK |
| 6 | 6 | 1978-1985 |
| 7 | | MESS driver by judge, friol |
| 7 | MESS driver by Wilbert Pol and friol |
| 8 | Driver started on 22/12/2011 |
| 8 | 9 | |
| 9 | 10 | === |
| 10 | 11 | |
| 11 | | Memory map: |
| 12 | Memory map from sevice manual: |
| 12 | 13 | |
| 13 | | 0x0000-0x0fff - COS ROM (in page 0)/RAM (in page 1) |
| 14 | | 0x1c00-0x1dff - additional ROM (?) |
| 15 | | 0x4000-0xbc00 - RAM page0 |
| 16 | | 0xE000-0xEFFF - COS ROM mirror |
| 17 | | 0xF000-0xF5FF - video ram |
| 18 | | 0xf600-0xf9ff - ROM (?) |
| 19 | | 0xfa00-0xffff - RAM |
| 14 | PAGE SEL bit in PORT0 set to 0: |
| 20 | 15 | |
| 21 | | 0xfbfc - port0 |
| 22 | | 0xfbfd - "scroll" register in COS 4.0 (?) |
| 16 | 0000-3BFF - CPU RAM row 1 (15KB!) |
| 17 | 3C00-7BFF - CPU RAM row 2 (16KB) |
| 18 | 7C00-BBFF - Add-on RAM row 1 or HRG RAM (16KB) |
| 19 | BC00-DFFF - Add-on RAM row 2 (9KB!) |
| 20 | E000-EFFF - ROM (COS) |
| 21 | F000-F5FF - VUD and HRG Video RAM |
| 22 | F600-F9FF - ROM (monitor extension) |
| 23 | FA00-FAFF - Reserved, RAM? |
| 24 | FB00-FBFF - Memory-mapped ports (FBFC-FBFF) |
| 25 | FC00-FFFF - RAM |
| 23 | 26 | |
| 27 | PAGE SEL bit in PORT0 set to 1: |
| 28 | 0000-0FFF - ROM (COS mirror from E000) |
| 29 | 1B00-1BFF - Memory-mapped ports (1BFC-1BFF) |
| 30 | 1C00-1DFF - ROM |
| 31 | 4000-7FFF - CPU RAM row 1 (16KB!, this RAM normally appears at 0000) |
| 32 | 8000-BFFF - ??? |
| 33 | C000-DFFF - ??? |
| 34 | E000-EFFF - ROM (COS) |
| 35 | F000-F5FF - VDU and HRG Video RAM |
| 36 | F600-F9FF - ROM (monitor extension) |
| 37 | FA00-FAFF - Reserved, RAM? |
| 38 | FB00-FBFF - Memory-mapped ports (FBFC-FBFF) |
| 39 | FC00-FFFF - RAM |
| 40 | |
| 41 | 40x24 - 6 pixels wide (5 + spacing), 9 pixels high = 240x216 |
| 42 | Video input clock is 4MHz (8MHz/2) |
| 43 | |
| 24 | 44 | According to the manuals, VDU-1 chargen is Texas 74LS262. |
| 25 | 45 | |
| 26 | 46 | === |
| 27 | 47 | |
| 28 | | COS 4.0 disassembly |
| 48 | Notes on COS 4.0 disassembly: |
| 29 | 49 | |
| 30 | 50 | - routine at 0xe438 is called at startup in COS 4.0 and it sets the RST vectors in RAM |
| 31 | 51 | - routine at 0xe487 finds "top" of system RAM and stores it in 0x0006 and 0x000E |
| r13913 | r13914 | |
| 36 | 56 | |
| 37 | 57 | #define ADDRESS_MAP_MODERN |
| 38 | 58 | |
| 39 | | |
| 40 | 59 | #include "emu.h" |
| 41 | 60 | #include "cpu/z80/z80.h" |
| 61 | #include "machine/ram.h" |
| 42 | 62 | #include "imagedev/flopdrv.h" |
| 43 | 63 | #include "machine/terminal.h" |
| 44 | 64 | #include "machine/wd17xx.h" |
| 65 | #include "includes/rm380z.h" |
| 45 | 66 | |
| 46 | 67 | |
| 47 | | #define PORTS_ENABLED_HIGH ( m_port0 & 0x80 ) |
| 48 | | #define PORTS_ENABLED_LOW ( ( m_port0 & 0x80 ) == 0x00 ) |
| 49 | | |
| 50 | | // |
| 51 | | // |
| 52 | | // |
| 53 | | |
| 54 | | class rm380z_state : public driver_device |
| 55 | | { |
| 56 | | private: |
| 57 | | |
| 58 | | UINT8 decode_videoram_char(UINT8 ch1,UINT8 ch2); |
| 59 | | |
| 60 | | protected: |
| 61 | | virtual void machine_reset(); |
| 62 | | |
| 63 | | public: |
| 64 | | |
| 65 | | UINT8 m_port0; |
| 66 | | UINT8 m_port0_kbd; |
| 67 | | UINT8 m_port1; |
| 68 | | UINT8 m_fbfd; |
| 69 | | UINT8 *m_cos_rom; |
| 70 | | |
| 71 | | int m_ksampler; |
| 72 | | |
| 73 | | UINT8 m_vram[0x600]; |
| 74 | | UINT8 m_mainVideoram[0x600]; |
| 75 | | |
| 76 | | UINT8 m_vramchars[0x600]; |
| 77 | | UINT8 m_vramattribs[0x600]; |
| 78 | | |
| 79 | | UINT8 m_mainram[0x10000]; |
| 80 | | |
| 81 | | int m_rasterlineCtr; |
| 82 | | emu_timer* m_vblankTimer; |
| 83 | | int m_old_fbfd; |
| 84 | | |
| 85 | | required_device<cpu_device> m_maincpu; |
| 86 | | optional_device<device_t> m_fdc; |
| 87 | | |
| 88 | | rm380z_state(const machine_config &mconfig, device_type type, const char *tag): driver_device(mconfig, type, tag), |
| 89 | | m_maincpu(*this, "maincpu"), |
| 90 | | m_fdc(*this, "wd1771") |
| 91 | | { |
| 92 | | } |
| 93 | | |
| 94 | | DECLARE_READ8_MEMBER( port_fbfc_read ); |
| 95 | | DECLARE_WRITE8_MEMBER( port_fbfc_write ); |
| 96 | | |
| 97 | | DECLARE_READ8_MEMBER( main_read ); |
| 98 | | DECLARE_WRITE8_MEMBER( main_write ); |
| 99 | | |
| 100 | | DECLARE_READ8_MEMBER( videoram_read ); |
| 101 | | DECLARE_WRITE8_MEMBER( videoram_write ); |
| 102 | | |
| 103 | | DECLARE_WRITE8_MEMBER(disk_0_control); |
| 104 | | |
| 105 | | DECLARE_WRITE8_MEMBER( keyboard_put ); |
| 106 | | |
| 107 | | }; |
| 108 | | |
| 109 | | |
| 110 | | WRITE8_MEMBER( rm380z_state::port_fbfc_write ) |
| 111 | | { |
| 112 | | switch ( offset ) |
| 113 | | { |
| 114 | | case 0x00: // PORT0 |
| 115 | | //printf("write of [%x] to FBFC\n",data); |
| 116 | | m_port0 = data; |
| 117 | | if (data&0x01) |
| 118 | | { |
| 119 | | //printf("WARNING: bit0 of port0 reset\n"); |
| 120 | | m_port0_kbd=0; |
| 121 | | } |
| 122 | | break; |
| 123 | | |
| 124 | | case 0x01: // screen line counter (?) |
| 125 | | //printf("write of [%x] to FBFD\n",data&0x1f); |
| 126 | | m_fbfd=data&0x1f; |
| 127 | | break; |
| 128 | | |
| 129 | | case 0x02: // PORT1 |
| 130 | | //printf("write of [%x] to FBFE\n",data); |
| 131 | | break; |
| 132 | | |
| 133 | | case 0x03: // user I/O port |
| 134 | | //printf("write of [%x] to FBFF\n",data); |
| 135 | | //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data ); |
| 136 | | break; |
| 137 | | } |
| 138 | | } |
| 139 | | READ8_MEMBER( rm380z_state::port_fbfc_read ) |
| 140 | | { |
| 141 | | UINT8 data = 0xFF; |
| 142 | | |
| 143 | | switch ( offset ) |
| 144 | | { |
| 145 | | case 0x00: // PORT0 |
| 146 | | //m_port0_kbd=getKeyboard(); |
| 147 | | data = m_port0_kbd; |
| 148 | | //if (m_port0_kbd!=0) m_port0_kbd=0; |
| 149 | | //m_port0_kbd=0; |
| 150 | | //printf("read of port0 (kbd) at [%f] from PC [%x]\n",machine().time().as_double(),cpu_get_pc(machine().device("maincpu"))); |
| 151 | | break; |
| 152 | | |
| 153 | | case 0x01: // "counter" (?) |
| 154 | | printf("%s: Read from counter FBFD\n", machine().describe_context()); |
| 155 | | data = 0x00; |
| 156 | | break; |
| 157 | | |
| 158 | | case 0x02: // PORT1 |
| 159 | | data = m_port1; |
| 160 | | break; |
| 161 | | |
| 162 | | case 0x03: // user port |
| 163 | | printf("%s: Read from user port\n", machine().describe_context()); |
| 164 | | break; |
| 165 | | } |
| 166 | | |
| 167 | | return data; |
| 168 | | } |
| 169 | | |
| 170 | | #define LINE_SUBDIVISION 40 |
| 171 | | #define TIMER_SPEED 50*100*LINE_SUBDIVISION |
| 172 | | |
| 173 | | // |
| 174 | | // this simulates line+frame blanking |
| 175 | | // according to the System manual, "frame blanking bit (bit 6) of port1 becomes high |
| 176 | | // for about 4.5 milliseconds every 20 milliseconds" |
| 177 | | // |
| 178 | | |
| 179 | | static TIMER_CALLBACK(static_vblank_timer) |
| 180 | | { |
| 181 | | //printf("timer callback called at [%f]\n",machine.time().as_double()); |
| 182 | | |
| 183 | | rm380z_state *state = machine.driver_data<rm380z_state>(); |
| 184 | | |
| 185 | | state->m_rasterlineCtr++; |
| 186 | | state->m_rasterlineCtr%=(100*LINE_SUBDIVISION); |
| 187 | | |
| 188 | | if (state->m_rasterlineCtr>=((100-22)*LINE_SUBDIVISION)) |
| 189 | | { |
| 190 | | // frame blanking |
| 191 | | state->m_port1=0x41; |
| 192 | | } |
| 193 | | else |
| 194 | | { |
| 195 | | state->m_port1=0x00; |
| 196 | | } |
| 197 | | |
| 198 | | if ((state->m_rasterlineCtr%LINE_SUBDIVISION)==0) state->m_port1|=0x80; // line blanking |
| 199 | | |
| 200 | | // |
| 201 | | // poll keyboard at fixed intervals, otherwise keys get pressed too fast |
| 202 | | // |
| 203 | | |
| 204 | | state->m_ksampler++; |
| 205 | | if (state->m_ksampler>(4*100*LINE_SUBDIVISION)) |
| 206 | | { |
| 207 | | state->m_ksampler=0; |
| 208 | | } |
| 209 | | } |
| 210 | | |
| 211 | | void rm380z_state::machine_reset() |
| 212 | | { |
| 213 | | m_port0=0x00; |
| 214 | | m_port0_kbd=0x00; |
| 215 | | m_port1=0x00; |
| 216 | | m_fbfd=0x00; |
| 217 | | m_old_fbfd=0x00; |
| 218 | | |
| 219 | | m_rasterlineCtr=0; |
| 220 | | m_ksampler=0; |
| 221 | | |
| 222 | | memset(m_vramattribs,0,0x600); |
| 223 | | memset(m_vramchars,0,0x600); |
| 224 | | |
| 225 | | m_cos_rom=machine().region("maincpu")->base(); |
| 226 | | |
| 227 | | machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer)); |
| 228 | | |
| 229 | | wd17xx_reset(machine().device("wd1771")); |
| 230 | | } |
| 231 | | |
| 232 | | // |
| 233 | | |
| 234 | | WRITE8_MEMBER( rm380z_state::main_write ) |
| 235 | | { |
| 236 | | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 237 | | |
| 238 | | if ( PORTS_ENABLED_LOW ) |
| 239 | | { |
| 240 | | if ((offset>=0x1bfc)&&(offset<=0x1bff)) |
| 241 | | { |
| 242 | | state->port_fbfc_write(space,offset-0x1bfc,data); |
| 243 | | return; |
| 244 | | } |
| 245 | | |
| 246 | | if ((offset>=0x0000)&&(offset<0x1000)) |
| 247 | | { |
| 248 | | // ROM |
| 249 | | printf("ERROR: write on rom at [%x]\n",offset); |
| 250 | | return; |
| 251 | | } |
| 252 | | else if ((offset>=0x1000)&&(offset<0x4000)) |
| 253 | | { |
| 254 | | // ? |
| 255 | | printf("WARNING: unhandled write page0 at [%x]\n",offset); |
| 256 | | return; |
| 257 | | } |
| 258 | | else if ((offset>=0x4000)&&(offset<0xBC00)) |
| 259 | | { |
| 260 | | state->m_mainram[offset-0x4000]=data; |
| 261 | | return; |
| 262 | | } |
| 263 | | } |
| 264 | | else |
| 265 | | { |
| 266 | | if ((offset==0x000e)||(offset==0x000f)) |
| 267 | | { |
| 268 | | printf("WARNING: writing [%x] at 0x000f at PC [%x]\n",data,cpu_get_pc(machine().device("maincpu"))); |
| 269 | | } |
| 270 | | |
| 271 | | //if ((offset>=0x0000)&&(offset<0x7c00)) |
| 272 | | if ((offset>=0x0000)&&(offset<0xdf00)) |
| 273 | | { |
| 274 | | // RAM |
| 275 | | state->m_mainram[offset]=data; |
| 276 | | return; |
| 277 | | } |
| 278 | | } |
| 279 | | |
| 280 | | //printf("ERROR: unhandled default write at [%x] of [%x]\n",offset,data); |
| 281 | | } |
| 282 | | |
| 283 | | READ8_MEMBER( rm380z_state::main_read ) |
| 284 | | { |
| 285 | | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 286 | | |
| 287 | | if ( PORTS_ENABLED_LOW ) |
| 288 | | { |
| 289 | | if ((offset>=0x1bfc)&&(offset<=0x1bff)) |
| 290 | | { |
| 291 | | return state->port_fbfc_read(space,offset-0x1bfc); |
| 292 | | } |
| 293 | | |
| 294 | | if ((offset>=0x0000)&&(offset<0x1000)) |
| 295 | | { |
| 296 | | // ROM |
| 297 | | return state->m_cos_rom[offset+ 0xe000]; |
| 298 | | } |
| 299 | | else if ((offset>=0x1c00)&&(offset<=0x1dff)) |
| 300 | | { |
| 301 | | return m_cos_rom[offset]; |
| 302 | | } |
| 303 | | else if ((offset>=0x1000)&&(offset<0x4000)) |
| 304 | | { |
| 305 | | // ? |
| 306 | | //printf("WARNING: unhandled read page0 at [%x]\n",offset); |
| 307 | | return 0xff; |
| 308 | | } |
| 309 | | else if ((offset>=0x4000)&&(offset<0xBC00)) |
| 310 | | { |
| 311 | | return state->m_mainram[offset-0x4000]; |
| 312 | | } |
| 313 | | } |
| 314 | | else |
| 315 | | { |
| 316 | | //if ((offset>=0x0000)&&(offset<0x7c00)) |
| 317 | | if ((offset>=0x0000)&&(offset<0xdf00)) |
| 318 | | { |
| 319 | | // ROM |
| 320 | | return state->m_mainram[offset]; |
| 321 | | } |
| 322 | | } |
| 323 | | |
| 324 | | //printf("ERROR: unhandled default read at [%x]\n",offset); |
| 325 | | return 0xff; |
| 326 | | } |
| 327 | | |
| 328 | | // |
| 329 | | |
| 330 | | UINT8 rm380z_state::decode_videoram_char(UINT8 ch1,UINT8 ch2) |
| 331 | | { |
| 332 | | if ((ch1>0x0f)&&(ch1<0x80)) |
| 333 | | { |
| 334 | | return ch1; |
| 335 | | } |
| 336 | | else if ((ch2>0x0f)&&(ch2<0x80)) |
| 337 | | { |
| 338 | | return ch2; |
| 339 | | } |
| 340 | | else if (ch1==0x80) |
| 341 | | { |
| 342 | | // "blank"? |
| 343 | | return 0x80; |
| 344 | | } |
| 345 | | else if ((ch1==0)&&(ch2==8)) |
| 346 | | { |
| 347 | | // cursor |
| 348 | | return 0x7f; |
| 349 | | } |
| 350 | | else if ((ch1==0)&&(ch2==0)) |
| 351 | | { |
| 352 | | return 0x20; |
| 353 | | } |
| 354 | | else if ((ch1==4)&&(ch2==4)) |
| 355 | | { |
| 356 | | // reversed cursor? |
| 357 | | return 0x20; |
| 358 | | } |
| 359 | | else if ((ch1==4)&&(ch2==8)) |
| 360 | | { |
| 361 | | // normal cursor |
| 362 | | return 0x7f; |
| 363 | | } |
| 364 | | else |
| 365 | | { |
| 366 | | //printf("unhandled character combination [%x][%x]\n",ch1,ch2); |
| 367 | | } |
| 368 | | |
| 369 | | return 0; |
| 370 | | } |
| 371 | | |
| 372 | | WRITE8_MEMBER( rm380z_state::videoram_write ) |
| 373 | | { |
| 374 | | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 375 | | |
| 376 | | //printf("vramw [%x][%x] port0 [%x] fbfd [%x]\n",offset,data,state->m_port0,m_fbfd); |
| 377 | | |
| 378 | | if (m_old_fbfd>m_fbfd) |
| 379 | | { |
| 380 | | printf("WARN: fbfd wrapped\n"); |
| 381 | | } |
| 382 | | m_old_fbfd=m_fbfd; |
| 383 | | |
| 384 | | int lineAdder=(m_fbfd&0x1f)*0x40; |
| 385 | | int realA=offset+lineAdder; |
| 386 | | |
| 387 | | // we suppose videoram is being written as character/attribute couple |
| 388 | | // fbfc 6th bit set=attribute, unset=char |
| 389 | | |
| 390 | | if (!(state->m_port0&0x40)) |
| 391 | | { |
| 392 | | m_vramchars[realA%0x600]=data; |
| 393 | | } |
| 394 | | else |
| 395 | | { |
| 396 | | m_vramattribs[realA%0x600]=data; |
| 397 | | } |
| 398 | | |
| 399 | | UINT8 curch=decode_videoram_char(m_vramchars[realA],m_vramattribs[realA]); |
| 400 | | state->m_vram[realA%0x600]=curch; |
| 401 | | |
| 402 | | state->m_mainVideoram[offset]=data; |
| 403 | | } |
| 404 | | |
| 405 | | READ8_MEMBER( rm380z_state::videoram_read ) |
| 406 | | { |
| 407 | | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 408 | | //printf("read from videoram at [%x]\n",offset); |
| 409 | | //return state->m_vram[offset]; |
| 410 | | return state->m_mainVideoram[offset]; |
| 411 | | } |
| 412 | | |
| 413 | | // |
| 414 | | // ports c0-cf are related to the floppy disc controller |
| 415 | | // c0-c3: wd1771 |
| 416 | | // c4-c8: disk drive port0 |
| 417 | | // code at f7df writes 2f to c0 |
| 418 | | // code at e526 reads from c1 |
| 419 | | // |
| 420 | | // the manual says: "the B command reads a sector from drive 0, track 0, sector 1 into memory |
| 421 | | // at 0x0080 to 0x00FF, then jumps to it if there is no error. |
| 422 | | // |
| 423 | | |
| 424 | | |
| 425 | | WRITE8_MEMBER( rm380z_state::disk_0_control ) |
| 426 | | { |
| 427 | | device_t *fdc = machine().device("wd1771"); |
| 428 | | |
| 429 | | printf("disk drive port0 write [%x]\n",data); |
| 430 | | |
| 431 | | // drive port0 |
| 432 | | if (data&0x01) |
| 433 | | { |
| 434 | | // drive select bit 0 |
| 435 | | wd17xx_set_drive(fdc,0); |
| 436 | | } |
| 437 | | |
| 438 | | if (data&0x08) |
| 439 | | { |
| 440 | | // motor on |
| 441 | | } |
| 442 | | |
| 443 | | // "MSEL (dir/side select bit) |
| 444 | | if (data&0x20) |
| 445 | | { |
| 446 | | wd17xx_set_side(fdc,1); |
| 447 | | } |
| 448 | | else |
| 449 | | { |
| 450 | | wd17xx_set_side(fdc,0); |
| 451 | | } |
| 452 | | |
| 453 | | // set drive en- (?) |
| 454 | | if (data&0x40) |
| 455 | | { |
| 456 | | } |
| 457 | | } |
| 458 | | |
| 459 | 68 | static ADDRESS_MAP_START(rm380z_mem, AS_PROGRAM, 8, rm380z_state) |
| 460 | | AM_RANGE( 0x0000, 0xdfff ) AM_READWRITE(main_read,main_write) |
| 461 | | AM_RANGE( 0xe000, 0xefff ) AM_ROM |
| 69 | AM_RANGE( 0xe000, 0xefff ) AM_ROM AM_REGION(MAINCPU_TAG, 0) |
| 462 | 70 | AM_RANGE( 0xf000, 0xf5ff ) AM_READWRITE(videoram_read,videoram_write) |
| 463 | | AM_RANGE( 0xf600, 0xf9ff ) AM_ROM /* Extra ROM space for COS4.0 */ |
| 71 | AM_RANGE( 0xf600, 0xf9ff ) AM_ROM AM_REGION(MAINCPU_TAG, 0x1000) /* Extra ROM space for COS4.0 */ |
| 464 | 72 | AM_RANGE( 0xfa00, 0xfbfb ) AM_RAM |
| 465 | | AM_RANGE( 0xfbfc, 0xfbff ) AM_READWRITE( port_fbfc_read, port_fbfc_write ) |
| 73 | AM_RANGE( 0xfbfc, 0xfbff ) AM_READWRITE( port_read, port_write ) |
| 466 | 74 | AM_RANGE( 0xfc00, 0xffff ) AM_RAM |
| 467 | 75 | ADDRESS_MAP_END |
| 468 | 76 | |
| 469 | | // ports c0-c3 are related to the floppy disk controller |
| 470 | | // which seems to be based on WD1771 from the documentation |
| 471 | | // (n.b.: this is not working properly, need to get real fdc mapping) |
| 472 | | |
| 473 | 77 | static ADDRESS_MAP_START( rm380z_io , AS_IO, 8, rm380z_state) |
| 474 | 78 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 79 | //AM_RANGE(0x0000, 0xffff) AM_READWRITE(rm380z_io_r, rm380z_io_w) |
| 475 | 80 | AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_status_r, wd17xx_command_w) |
| 476 | 81 | AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_track_r, wd17xx_track_w) |
| 477 | 82 | AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_sector_r, wd17xx_sector_w) |
| r13913 | r13914 | |
| 480 | 85 | AM_RANGE(0xcc, 0xcc) AM_NOP // CTC (?) |
| 481 | 86 | ADDRESS_MAP_END |
| 482 | 87 | |
| 88 | static GENERIC_TERMINAL_INTERFACE( terminal_intf ) |
| 89 | { |
| 90 | DEVCB_DRIVER_MEMBER(rm380z_state, keyboard_put) |
| 91 | }; |
| 483 | 92 | |
| 484 | 93 | INPUT_PORTS_START( rm380z ) |
| 485 | 94 | INPUT_PORTS_END |
| r13913 | r13914 | |
| 488 | 97 | // |
| 489 | 98 | // |
| 490 | 99 | |
| 491 | | #define chdimx 5 |
| 492 | | #define chdimy 9 |
| 493 | | #define ncx 8 |
| 494 | | #define ncy 16 |
| 495 | | #define screencols 40 |
| 496 | | #define screenrows 24 |
| 497 | | |
| 498 | | static void putChar(int charnum,int x,int y,UINT16* pscr,unsigned char* chsb) |
| 499 | | { |
| 500 | | if ((charnum>0)&&(charnum<=0x7f)) |
| 501 | | { |
| 502 | | int basex=chdimx*(charnum/ncy); |
| 503 | | int basey=chdimy*(charnum%ncy); |
| 504 | | |
| 505 | | int inix=x*chdimx; |
| 506 | | int iniy=y*chdimx*screencols*chdimy; |
| 507 | | |
| 508 | | for (int r=0;r<chdimy;r++) |
| 509 | | { |
| 510 | | for (int c=0;c<chdimx;c++) |
| 511 | | { |
| 512 | | pscr[(inix+c)+(iniy+(r*chdimx*screencols))]=(chsb[((basey+r)*(chdimx*ncx))+(basex+c)])==0xff?0:1; |
| 513 | | } |
| 514 | | } |
| 515 | | } |
| 516 | | } |
| 517 | | |
| 518 | | static SCREEN_UPDATE( rm380z ) |
| 519 | | { |
| 520 | | rm380z_state *state = screen.machine().driver_data<rm380z_state>(); |
| 521 | | |
| 522 | | unsigned char* pChar=screen.machine().region("gfx")->base(); |
| 523 | | UINT16* scrptr = &bitmap.pix16(0, 0); |
| 524 | | |
| 525 | | for (int row=0;row<screenrows;row++) |
| 526 | | { |
| 527 | | for (int col=0;col<screencols;col++) |
| 528 | | { |
| 529 | | unsigned char curchar=state->m_vram[(row*64)+col]; |
| 530 | | putChar(curchar,col,row,scrptr,pChar); |
| 531 | | } |
| 532 | | } |
| 533 | | |
| 534 | | return 0; |
| 535 | | } |
| 536 | | |
| 537 | | |
| 538 | | WRITE8_MEMBER( rm380z_state::keyboard_put ) |
| 539 | | { |
| 540 | | m_port0_kbd = data; |
| 541 | | } |
| 542 | | |
| 543 | | |
| 544 | | static GENERIC_TERMINAL_INTERFACE( terminal_intf ) |
| 545 | | { |
| 546 | | DEVCB_DRIVER_MEMBER(rm380z_state, keyboard_put) |
| 547 | | }; |
| 548 | | |
| 549 | | |
| 550 | 100 | static const floppy_interface rm380z_floppy_interface = |
| 551 | 101 | { |
| 552 | 102 | DEVCB_NULL, |
| r13913 | r13914 | |
| 560 | 110 | NULL |
| 561 | 111 | }; |
| 562 | 112 | |
| 113 | static SCREEN_UPDATE( rm380z ) |
| 114 | { |
| 115 | rm380z_state *state = screen.machine().driver_data<rm380z_state>(); |
| 116 | state->update_screen(bitmap); |
| 117 | return 0; |
| 118 | } |
| 563 | 119 | |
| 564 | 120 | static MACHINE_CONFIG_START( rm380z, rm380z_state ) |
| 565 | 121 | /* basic machine hardware */ |
| r13913 | r13914 | |
| 578 | 134 | MCFG_PALETTE_LENGTH(2) |
| 579 | 135 | MCFG_PALETTE_INIT(black_and_white) |
| 580 | 136 | |
| 137 | /* RAM configurations */ |
| 138 | MCFG_RAM_ADD(RAM_TAG) |
| 139 | MCFG_RAM_DEFAULT_SIZE("56K") |
| 140 | |
| 581 | 141 | /* floppy disk */ |
| 582 | 142 | MCFG_FD1771_ADD("wd1771", default_wd17xx_interface) |
| 583 | 143 | MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, rm380z_floppy_interface) |
| 584 | | |
| 144 | |
| 145 | /* keyboard */ |
| 585 | 146 | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf) |
| 147 | |
| 586 | 148 | MACHINE_CONFIG_END |
| 587 | 149 | |
| 588 | 150 | /* ROM definition */ |
| 589 | 151 | ROM_START( rm380z ) |
| 590 | | ROM_REGION( 0x10000, "maincpu", 0 ) |
| 591 | | ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1c00, 0x0200, CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff)) |
| 592 | | ROM_LOAD( "cos40b-m.bin", 0xe000, 0x1000, CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f)) |
| 593 | | ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0xf600, 0x0400, CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a)) |
| 152 | ROM_REGION( 0x10000, MAINCPU_TAG, 0 ) |
| 153 | ROM_LOAD( "cos40b-m.bin", 0x0000, 0x1000, CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f)) |
| 154 | ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0x1000, 0x400, CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a)) |
| 155 | ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1400, 0x200, CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff)) |
| 156 | // chargen ROM is undumped, afaik |
| 594 | 157 | ROM_REGION( 0x1680, "gfx", 0 ) |
| 595 | | ROM_LOAD( "ch3.raw", 0x0000, 0x1680, CRC(e0b10221) SHA1(95304ccad9a7af49d79a349feb2bc23035f90abc)) |
| 158 | ROM_LOAD( "ch3.raw", 0x0000, 0x1680, BAD_DUMP CRC(e0b10221) SHA1(95304ccad9a7af49d79a349feb2bc23035f90abc)) |
| 596 | 159 | ROM_END |
| 597 | 160 | |
| 598 | 161 | /* Driver */ |