src/mess/drivers/bml3.c
| r8658 | r8659 | |
| 1 | | /*************************************************************************** |
| 1 | /************************************************************************************** |
| 2 | 2 | |
| 3 | | Hitachi Basic Master Level 3 (MB-6890) |
| 3 | Basic Master Level 3 (MB-6890) (c) 1980 Hitachi |
| 4 | 4 | |
| 5 | | 13/07/2010 Skeleton driver. |
| 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 | - keyboard shift key, necessary for some key commands |
| 11 | - every time that you switch with NEW ON command, there's a "device i/o error" if |
| 12 | the hres_reg bit 5 is active. |
| 8 | 13 | |
| 14 | NOTES: |
| 15 | - NEW ON changes the video mode, they are: |
| 16 | 0: 320 x 200, bit 5 active |
| 17 | 1: 320 x 200, bit 5 unactive |
| 18 | 2: 320 x 375, bit 5 active |
| 19 | 3: 320 x 375, bit 5 unactive |
| 20 | 4: 640 x 200, bit 5 active |
| 21 | 5: 640 x 200, bit 5 unactive |
| 22 | 6: 640 x 375, bit 5 active |
| 23 | 7: 640 x 375, bit 5 unactive |
| 24 | 8-15: same as above plus sets bit 4 |
| 25 | 16-31: same as above plus shows the bar at the bottom |
| 26 | |
| 27 | **************************************************************************************/ |
| 28 | |
| 9 | 29 | #include "emu.h" |
| 10 | 30 | #include "cpu/m6809/m6809.h" |
| 11 | 31 | #include "video/mc6845.h" |
| 32 | #include "sound/beep.h" |
| 12 | 33 | |
| 13 | 34 | static UINT16 cursor_addr,cursor_raster; |
| 14 | | static UINT8 attr_latch; |
| 35 | static UINT8 attr_latch,io_latch; |
| 36 | static UINT8 hres_reg, vres_reg; |
| 15 | 37 | |
| 16 | 38 | static VIDEO_START( bml3 ) |
| 17 | 39 | { |
| r8658 | r8659 | |
| 21 | 43 | { |
| 22 | 44 | int x,y,count; |
| 23 | 45 | int xi,yi; |
| 46 | int width,height; |
| 24 | 47 | static UINT8 *gfx_rom = memory_region(screen->machine, "char"); |
| 25 | 48 | static UINT8 *vram = memory_region(screen->machine, "vram"); |
| 26 | 49 | |
| 27 | 50 | count = 0x0000; |
| 28 | 51 | |
| 52 | width = (hres_reg & 0x80) ? 80 : 40; |
| 53 | height = (vres_reg & 0x08) ? 1 : 0; |
| 54 | |
| 55 | popmessage("%02x %02x",hres_reg,vres_reg); |
| 56 | |
| 29 | 57 | for(y=0;y<25;y++) |
| 30 | 58 | { |
| 31 | | for(x=0;x<40;x++) |
| 59 | for(x=0;x<width;x++) |
| 32 | 60 | { |
| 33 | 61 | int tile = vram[count+0x0000]; |
| 34 | 62 | int color = vram[count+0x4000] & 7; |
| r8658 | r8659 | |
| 46 | 74 | else |
| 47 | 75 | pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0; |
| 48 | 76 | |
| 49 | | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen]; |
| 77 | if(height) |
| 78 | { |
| 79 | *BITMAP_ADDR16(bitmap, (y*8+yi)*2+0, x*8+xi) = screen->machine->pens[pen]; |
| 80 | *BITMAP_ADDR16(bitmap, (y*8+yi)*2+1, x*8+xi) = screen->machine->pens[pen]; |
| 81 | } |
| 82 | else |
| 83 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen]; |
| 50 | 84 | } |
| 51 | 85 | } |
| 52 | 86 | |
| r8658 | r8659 | |
| 69 | 103 | { |
| 70 | 104 | for(xc=0;xc<8;xc++) |
| 71 | 105 | { |
| 72 | | *BITMAP_ADDR16(bitmap, y*8+yc+7, x*8+xc) = screen->machine->pens[0x7]; |
| 106 | if(height) |
| 107 | { |
| 108 | *BITMAP_ADDR16(bitmap, (y*8+yc+7)*2+0, x*8+xc) = screen->machine->pens[0x7]; |
| 109 | *BITMAP_ADDR16(bitmap, (y*8+yc+7)*2+1, x*8+xc) = screen->machine->pens[0x7]; |
| 110 | } |
| 111 | else |
| 112 | *BITMAP_ADDR16(bitmap, y*8+yc+7, x*8+xc) = screen->machine->pens[0x7]; |
| 73 | 113 | } |
| 74 | 114 | } |
| 75 | 115 | } |
| r8658 | r8659 | |
| 129 | 169 | { |
| 130 | 170 | static UINT8 *rom = memory_region(space->machine, "maincpu"); |
| 131 | 171 | |
| 132 | | // if(offset == 0xc4) return bml3_cmt_r(space,0); //maybe 0xc4 is the status and 0xc5 the data? d7 and ea seems to be related too |
| 172 | if(offset == 0x19) return io_latch; |
| 173 | if(offset == 0xc4) return 0xff; //some video modes wants this to be high |
| 174 | //maybe 0xc4 is the status and 0xc5 the data? d7 and ea seems to be related too |
| 133 | 175 | if(offset == 0xc8) return 0; //??? checks bit 7, scrolls vertically if active high |
| 134 | 176 | if(offset == 0xc9) return 0x11; //0x01 put 320 x 200 mode, 0x07 = 640 x 375 |
| 135 | | // if(offset == 0xcb) return mame_rand(space->machine); |
| 177 | |
| 178 | /* one of these sets something, apparently available RAM space is smaller if one of these bits is zero (?) */ |
| 179 | // if(offset == 0x40) return 0 ? 0xff : 0x00; |
| 180 | // if(offset == 0x42) return 0 ? 0xff : 0x00; |
| 181 | // if(offset == 0x44) return 0 ? 0xff : 0x00; |
| 182 | // if(offset == 0x46) return 0 ? 0xff : 0x00; |
| 183 | |
| 136 | 184 | if(offset == 0xd8) return attr_latch; |
| 137 | 185 | if(offset == 0xe0) return bml3_keyboard_r(space,0); |
| 138 | 186 | |
| r8658 | r8659 | |
| 140 | 188 | |
| 141 | 189 | // if(offset == 0x40 || offset == 0x42 || offset == 0x44 || offset == 0x46) |
| 142 | 190 | |
| 143 | | |
| 144 | 191 | if(offset < 0xf0) |
| 145 | 192 | { |
| 146 | | logerror("I/O read [%02x] at PC=%04x\n",offset,cpu_get_pc(space->cpu)); |
| 147 | | return 0; |
| 193 | //if(cpu_get_pc(space->cpu) != 0xf838 && cpu_get_pc(space->cpu) != 0xfac4 && cpu_get_pc(space->cpu) != 0xf83c) |
| 194 | if(offset >= 0xd0 && offset < 0xe0) |
| 195 | logerror("I/O read [%02x] at PC=%04x\n",offset,cpu_get_pc(space->cpu)); |
| 196 | return 0;//mame_rand(space->machine); |
| 148 | 197 | } |
| 149 | 198 | |
| 150 | 199 | /* TODO: pretty sure that there's a bankswitch for this */ |
| 151 | 200 | return rom[offset+0xff00]; |
| 152 | 201 | } |
| 153 | 202 | |
| 203 | static void m6845_change_clock(running_machine *machine, UINT8 setting) |
| 204 | { |
| 205 | int m6845_clock = XTAL_3_579545MHz; |
| 206 | |
| 207 | switch(setting & 0x88) |
| 208 | { |
| 209 | case 0x00: m6845_clock = XTAL_3_579545MHz/4; break; //320 x 200 |
| 210 | case 0x08: m6845_clock = XTAL_3_579545MHz/2; break; //320 x 375 |
| 211 | case 0x80: m6845_clock = XTAL_3_579545MHz/2; break; //640 x 200 |
| 212 | case 0x88: m6845_clock = XTAL_3_579545MHz/1; break; //640 x 375 |
| 213 | } |
| 214 | |
| 215 | mc6845_set_clock(machine->device("crtc"), m6845_clock); |
| 216 | } |
| 217 | |
| 218 | static WRITE8_HANDLER( bml3_hres_reg_w ) |
| 219 | { |
| 220 | /* |
| 221 | x--- ---- width (1) 80 / (0) 40 |
| 222 | -x-- ---- used in some modes, unknown purpose |
| 223 | --x- ---- used in some modes, unknown purpose (also wants $ffc4 to be 0xff), color / monochrome switch? |
| 224 | */ |
| 225 | |
| 226 | hres_reg = data; |
| 227 | |
| 228 | m6845_change_clock(space->machine,(hres_reg & 0x80) | (vres_reg & 0x08)); |
| 229 | } |
| 230 | |
| 231 | static WRITE8_HANDLER( bml3_vres_reg_w ) |
| 232 | { |
| 233 | /* |
| 234 | ---- x--- char height |
| 235 | */ |
| 236 | vres_reg = data; |
| 237 | |
| 238 | m6845_change_clock(space->machine,(hres_reg & 0x80) | (vres_reg & 0x08)); |
| 239 | } |
| 240 | |
| 154 | 241 | static WRITE8_HANDLER( bml3_io_w ) |
| 155 | 242 | { |
| 156 | | if(offset == 0xc6 || offset == 0xc7) { bml3_6845_w(space,offset-0xc6,data); } |
| 157 | | else if(offset == 0xd8) { attr_latch = data; } |
| 243 | if(offset == 0x19) { io_latch = data; } //??? |
| 244 | else if(offset == 0xc6 || offset == 0xc7) { bml3_6845_w(space,offset-0xc6,data); } |
| 245 | else if(offset == 0xd0) { bml3_hres_reg_w(space,0,data); } |
| 246 | else if(offset == 0xd3) { /* every time that the user presses a key, unknown purpose */ } |
| 247 | else if(offset == 0xd6) { bml3_vres_reg_w(space,0,data); } |
| 248 | else if(offset == 0xd8) { attr_latch = data; } |
| 158 | 249 | else |
| 159 | 250 | { |
| 160 | 251 | logerror("I/O write %02x -> [%02x] at PC=%04x\n",data,offset,cpu_get_pc(space->cpu)); |
| r8658 | r8659 | |
| 285 | 376 | PORT_BIT(0xffe00000,IP_ACTIVE_HIGH,IPT_UNKNOWN) |
| 286 | 377 | INPUT_PORTS_END |
| 287 | 378 | |
| 379 | static MACHINE_START(bml3) |
| 380 | { |
| 381 | beep_set_frequency(machine->device("beeper"),300); //guesswork |
| 382 | beep_set_state(machine->device("beeper"),0); |
| 383 | } |
| 288 | 384 | |
| 289 | 385 | static MACHINE_RESET(bml3) |
| 290 | 386 | { |
| r8658 | r8659 | |
| 309 | 405 | cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE); |
| 310 | 406 | } |
| 311 | 407 | |
| 408 | #if 0 |
| 409 | static INTERRUPT_GEN( bml3_firq ) |
| 410 | { |
| 411 | cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, HOLD_LINE); |
| 412 | } |
| 413 | #endif |
| 414 | |
| 312 | 415 | static PALETTE_INIT( bml3 ) |
| 313 | 416 | { |
| 314 | 417 | int i; |
| r8658 | r8659 | |
| 320 | 423 | |
| 321 | 424 | static MACHINE_DRIVER_START( bml3 ) |
| 322 | 425 | /* basic machine hardware */ |
| 323 | | MDRV_CPU_ADD("maincpu",M6809, XTAL_1MHz) |
| 324 | | MDRV_CPU_PROGRAM_MAP(bml3_mem) |
| 426 | MDRV_CPU_ADD("maincpu",M6809, XTAL_1MHz) |
| 427 | MDRV_CPU_PROGRAM_MAP(bml3_mem) |
| 325 | 428 | MDRV_CPU_VBLANK_INT("screen", bml3_irq ) |
| 429 | // MDRV_CPU_PERIODIC_INT(bml3_firq,45) |
| 326 | 430 | |
| 327 | | MDRV_MACHINE_RESET(bml3) |
| 431 | MDRV_MACHINE_START(bml3) |
| 432 | MDRV_MACHINE_RESET(bml3) |
| 328 | 433 | |
| 329 | | /* video hardware */ |
| 330 | | MDRV_SCREEN_ADD("screen", RASTER) |
| 331 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 332 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 333 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 334 | | MDRV_SCREEN_SIZE(640, 480) |
| 335 | | MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1) |
| 336 | | MDRV_PALETTE_LENGTH(8) |
| 337 | | MDRV_PALETTE_INIT(bml3) |
| 434 | /* video hardware */ |
| 435 | MDRV_SCREEN_ADD("screen", RASTER) |
| 436 | MDRV_SCREEN_REFRESH_RATE(60) |
| 437 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 438 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 439 | MDRV_SCREEN_SIZE(640, 480) |
| 440 | MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1) |
| 441 | MDRV_PALETTE_LENGTH(8) |
| 442 | MDRV_PALETTE_INIT(bml3) |
| 338 | 443 | |
| 339 | 444 | MDRV_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 340 | 445 | |
| 341 | | MDRV_VIDEO_START(bml3) |
| 342 | | MDRV_VIDEO_UPDATE(bml3) |
| 446 | MDRV_VIDEO_START(bml3) |
| 447 | MDRV_VIDEO_UPDATE(bml3) |
| 448 | |
| 449 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 450 | |
| 451 | MDRV_SOUND_ADD("beeper", BEEP, 0) |
| 452 | MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50) |
| 343 | 453 | MACHINE_DRIVER_END |
| 344 | 454 | |
| 345 | 455 | /* ROM definition */ |