src/mess/drivers/bml3.c
| r13896 | r13897 | |
| 5 | 5 | preliminary driver by Angelo Salese |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | | - no documentation, the entire driver is just a bunch of educated |
| 9 | | guesses ... |
| 10 | 8 | - keyboard shift key is ugly mapped. |
| 11 | 9 | - understand how to load a tape |
| 12 | 10 | - every time that you switch with NEW ON command, there's a "device i/o error" if |
| r13896 | r13897 | |
| 72 | 70 | DECLARE_READ8_MEMBER(bml3_vram_attr_r); |
| 73 | 71 | DECLARE_WRITE8_MEMBER(bml3_vram_attr_w); |
| 74 | 72 | DECLARE_WRITE8_MEMBER(bml3_beep_w); |
| 75 | | UINT16 m_cursor_addr; |
| 76 | | UINT16 m_cursor_raster; |
| 77 | 73 | UINT8 m_attr_latch; |
| 78 | 74 | UINT8 m_io_latch; |
| 79 | 75 | UINT8 m_hres_reg; |
| 80 | 76 | UINT8 m_vres_reg; |
| 81 | 77 | UINT8 m_keyb_press; |
| 82 | 78 | UINT8 m_keyb_press_flag; |
| 83 | | int m_addr_latch; |
| 84 | 79 | UINT8 *m_p_chargen; |
| 85 | 80 | UINT8 m_psg_latch; |
| 86 | 81 | void m6845_change_clock(UINT8 setting); |
| 82 | UINT8 m_crtc_vreg[0x100],m_crtc_index; |
| 83 | UINT16 m_kanji_addr; |
| 87 | 84 | }; |
| 88 | 85 | |
| 86 | #define mc6845_h_char_total (state->m_crtc_vreg[0]) |
| 87 | #define mc6845_h_display (state->m_crtc_vreg[1]) |
| 88 | #define mc6845_h_sync_pos (state->m_crtc_vreg[2]) |
| 89 | #define mc6845_sync_width (state->m_crtc_vreg[3]) |
| 90 | #define mc6845_v_char_total (state->m_crtc_vreg[4]) |
| 91 | #define mc6845_v_total_adj (state->m_crtc_vreg[5]) |
| 92 | #define mc6845_v_display (state->m_crtc_vreg[6]) |
| 93 | #define mc6845_v_sync_pos (state->m_crtc_vreg[7]) |
| 94 | #define mc6845_mode_ctrl (state->m_crtc_vreg[8]) |
| 95 | #define mc6845_tile_height (state->m_crtc_vreg[9]+1) |
| 96 | #define mc6845_cursor_y_start (state->m_crtc_vreg[0x0a]) |
| 97 | #define mc6845_cursor_y_end (state->m_crtc_vreg[0x0b]) |
| 98 | #define mc6845_start_addr (((state->m_crtc_vreg[0x0c]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0d] & 0xff)) |
| 99 | #define mc6845_cursor_addr (((state->m_crtc_vreg[0x0e]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0f] & 0xff)) |
| 100 | #define mc6845_light_pen_addr (((state->m_crtc_vreg[0x10]<<8) & 0x3f00) | (state->m_crtc_vreg[0x11] & 0xff)) |
| 101 | #define mc6845_update_addr (((state->m_crtc_vreg[0x12]<<8) & 0x3f00) | (state->m_crtc_vreg[0x13] & 0xff)) |
| 89 | 102 | |
| 90 | 103 | |
| 91 | 104 | static VIDEO_START( bml3 ) |
| r13896 | r13897 | |
| 116 | 129 | int tile = vram[count+0x0000]; |
| 117 | 130 | int color = vram[count+0x4000] & 7; |
| 118 | 131 | int reverse = vram[count+0x4000] & 8; |
| 119 | | int h_factor = (height^1) + 1; |
| 120 | 132 | //attr & 0x10 is used ... bitmap mode? (apparently bits 4 and 7 are used for that) |
| 121 | 133 | |
| 122 | | for(yi=0;yi<8;yi++) |
| 134 | for(yi=0;yi<mc6845_tile_height;yi++) |
| 123 | 135 | { |
| 124 | 136 | for(xi=0;xi<8;xi++) |
| 125 | 137 | { |
| 126 | 138 | int pen; |
| 127 | 139 | |
| 128 | 140 | if(reverse) |
| 129 | | pen = (state->m_p_chargen[tile*16+yi*h_factor] >> (7-xi) & 1) ? 0 : color; |
| 141 | pen = (state->m_p_chargen[tile*16+yi*2] >> (7-xi) & 1) ? 0 : color; |
| 130 | 142 | else |
| 131 | | pen = (state->m_p_chargen[tile*16+yi*h_factor] >> (7-xi) & 1) ? color : 0; |
| 143 | pen = (state->m_p_chargen[tile*16+yi*2] >> (7-xi) & 1) ? color : 0; |
| 132 | 144 | |
| 133 | | bitmap.pix16(y*8+yi, x*8+xi) = pen; |
| 145 | bitmap.pix16(y*mc6845_tile_height+yi, x*8+xi) = pen; |
| 134 | 146 | } |
| 135 | 147 | } |
| 136 | 148 | |
| 137 | | if(state->m_cursor_addr-0x400 == count) |
| 149 | if(mc6845_cursor_addr-0x400 == count) |
| 138 | 150 | { |
| 139 | 151 | int xc,yc,cursor_on; |
| 140 | 152 | |
| 141 | 153 | cursor_on = 0; |
| 142 | | switch(state->m_cursor_raster & 0x60) |
| 154 | switch(mc6845_cursor_y_start & 0x60) |
| 143 | 155 | { |
| 144 | 156 | case 0x00: cursor_on = 1; break; //always on |
| 145 | 157 | case 0x20: cursor_on = 0; break; //always off |
| r13896 | r13897 | |
| 149 | 161 | |
| 150 | 162 | if(cursor_on) |
| 151 | 163 | { |
| 152 | | for(yc=0;yc<(8-(state->m_cursor_raster & 7));yc++) |
| 164 | for(yc=0;yc<(8-(mc6845_cursor_y_start & 7));yc++) |
| 153 | 165 | { |
| 154 | 166 | for(xc=0;xc<8;xc++) |
| 155 | 167 | { |
| 156 | | if(height) |
| 157 | | { |
| 158 | | bitmap.pix16((y*8+yc+7)*2+0, x*8+xc) = 7; |
| 159 | | bitmap.pix16((y*8+yc+7)*2+1, x*8+xc) = 7; |
| 160 | | } |
| 161 | | else |
| 162 | | bitmap.pix16(y*8+yc+7, x*8+xc) = 7; |
| 168 | bitmap.pix16(y*mc6845_tile_height+yc+7, x*8+xc) = 7; |
| 163 | 169 | } |
| 164 | 170 | } |
| 165 | 171 | } |
| r13896 | r13897 | |
| 176 | 182 | { |
| 177 | 183 | if(offset == 0) |
| 178 | 184 | { |
| 179 | | m_addr_latch = data; |
| 185 | m_crtc_index = data; |
| 180 | 186 | m_crtc->address_w(space, 0, data); |
| 181 | 187 | } |
| 182 | 188 | else |
| 183 | 189 | { |
| 184 | | if(m_addr_latch == 0x0a) |
| 185 | | m_cursor_raster = data; |
| 186 | | if(m_addr_latch == 0x0e) |
| 187 | | m_cursor_addr = ((data<<8) & 0x3f00) | (m_cursor_addr & 0xff); |
| 188 | | else if(m_addr_latch == 0x0f) |
| 189 | | m_cursor_addr = (m_cursor_addr & 0x3f00) | (data & 0xff); |
| 190 | | |
| 190 | m_crtc_vreg[m_crtc_index] = data; |
| 191 | 191 | m_crtc->register_w(space, 0, data); |
| 192 | 192 | } |
| 193 | 193 | } |
| r13896 | r13897 | |
| 207 | 207 | |
| 208 | 208 | void bml3_state::m6845_change_clock(UINT8 setting) |
| 209 | 209 | { |
| 210 | | int m6845_clock = XTAL_3_579545MHz; |
| 210 | int m6845_clock = XTAL_1MHz; |
| 211 | 211 | |
| 212 | 212 | switch(setting & 0x88) |
| 213 | 213 | { |
| 214 | | case 0x00: m6845_clock = XTAL_3_579545MHz/4; break; //320 x 200 |
| 215 | | case 0x08: m6845_clock = XTAL_3_579545MHz/2; break; //320 x 375 |
| 216 | | case 0x80: m6845_clock = XTAL_3_579545MHz/2; break; //640 x 200 |
| 217 | | case 0x88: m6845_clock = XTAL_3_579545MHz/1; break; //640 x 375 |
| 214 | case 0x00: m6845_clock = XTAL_1MHz; break; //320 x 200 |
| 215 | case 0x08: m6845_clock = XTAL_1MHz*2; break; //320 x 375 |
| 216 | case 0x80: m6845_clock = XTAL_1MHz*2; break; //640 x 200 |
| 217 | case 0x88: m6845_clock = XTAL_1MHz*4; break; //640 x 375 |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | m_crtc->set_clock(m6845_clock); |
| r13896 | r13897 | |
| 264 | 264 | |
| 265 | 265 | READ8_MEMBER( bml3_state::bml3_fdd_r ) |
| 266 | 266 | { |
| 267 | | printf("FDD 0xff20 R\n"); |
| 267 | //printf("FDD 0xff20 R\n"); |
| 268 | 268 | return -1; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | WRITE8_MEMBER( bml3_state::bml3_fdd_w ) |
| 272 | 272 | { |
| 273 | | printf("FDD 0xff20 W %02x\n",data); |
| 273 | //printf("FDD 0xff20 W %02x\n",data); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | READ8_MEMBER( bml3_state::bml3_kanji_r ) |
| 277 | 277 | { |
| 278 | | printf("KANJI %04x R\n",offset+0xff75); |
| 279 | | return -1; |
| 278 | // return m_kanji_rom[m_kanji_addr << 1 + offset]; |
| 279 | return machine().rand(); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | WRITE8_MEMBER( bml3_state::bml3_kanji_w ) |
| 283 | 283 | { |
| 284 | | printf("KANJI %04x W %02x\n",offset+0xff75,data); |
| 284 | m_kanji_addr &= (0xff << (offset*8)); |
| 285 | m_kanji_addr |= (data << ((offset^1)*8)); |
| 285 | 286 | } |
| 286 | 287 | |
| 287 | 288 | READ8_MEMBER( bml3_state::bml3_psg_latch_r) |
| r13896 | r13897 | |
| 364 | 365 | |
| 365 | 366 | static INPUT_PORTS_START( bml3 ) |
| 366 | 367 | PORT_START("DSW") |
| 367 | | PORT_DIPNAME( 0x01, 0x00, "DSW" ) |
| 368 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 369 | | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 370 | | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) ) |
| 371 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 372 | | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 373 | | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) |
| 374 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 375 | | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 368 | PORT_DIPNAME( 0x07, 0x01, "NewOn" ) // TODO |
| 369 | PORT_DIPSETTING( 0x00, "0" ) |
| 370 | PORT_DIPSETTING( 0x01, "1" ) |
| 371 | PORT_DIPSETTING( 0x02, "2" ) |
| 372 | PORT_DIPSETTING( 0x03, "3" ) |
| 373 | PORT_DIPSETTING( 0x04, "4" ) |
| 374 | PORT_DIPSETTING( 0x05, "5" ) |
| 375 | PORT_DIPSETTING( 0x06, "6" ) |
| 376 | PORT_DIPSETTING( 0x07, "7" ) |
| 376 | 377 | PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) ) |
| 377 | 378 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 378 | 379 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| r13896 | r13897 | |
| 671 | 672 | MCFG_GFXDECODE(bml3) |
| 672 | 673 | |
| 673 | 674 | /* Devices */ |
| 674 | | MCFG_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 675 | MCFG_MC6845_ADD("crtc", H46505, XTAL_1MHz, mc6845_intf) |
| 675 | 676 | MCFG_TIMER_ADD_PERIODIC("keyboard_timer", keyboard_callback, attotime::from_hz(240/8)) |
| 676 | 677 | MCFG_MC6843_ADD( "mc6843", bml3_6843_if ) |
| 677 | 678 | MCFG_PIA6821_ADD("pia6821", bml3_pia_config) |
| r13896 | r13897 | |
| 705 | 706 | ROM_LOAD("font.rom", 0x00000, 0x1000, BAD_DUMP CRC(0b6f2f10) SHA1(dc411b447ca414e94843636d8b5f910c954581fb) ) // handcrafted |
| 706 | 707 | |
| 707 | 708 | ROM_REGION( 0x8000, "vram", ROMREGION_ERASEFF ) |
| 709 | |
| 710 | ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF ) |
| 711 | ROM_LOAD("kanji.rom", 0x00000, 0x20000, NO_DUMP ) |
| 708 | 712 | ROM_END |
| 709 | 713 | |
| 710 | 714 | /* Driver */ |