src/mess/drivers/bml3.c
| r8644 | r8645 | |
| 10 | 10 | #include "cpu/m6809/m6809.h" |
| 11 | 11 | #include "video/mc6845.h" |
| 12 | 12 | |
| 13 | | static UINT8 *work_ram; |
| 14 | 13 | static UINT16 cursor_addr,cursor_raster; |
| 14 | static UINT8 attr_latch; |
| 15 | 15 | |
| 16 | 16 | static VIDEO_START( bml3 ) |
| 17 | 17 | { |
| r8644 | r8645 | |
| 22 | 22 | int x,y,count; |
| 23 | 23 | int xi,yi; |
| 24 | 24 | static UINT8 *gfx_rom = memory_region(screen->machine, "char"); |
| 25 | static UINT8 *vram = memory_region(screen->machine, "vram"); |
| 25 | 26 | |
| 26 | | count = 0x0400; |
| 27 | count = 0x0000; |
| 27 | 28 | |
| 28 | 29 | for(y=0;y<25;y++) |
| 29 | 30 | { |
| 30 | 31 | for(x=0;x<40;x++) |
| 31 | 32 | { |
| 32 | | int pen_b = work_ram[count+0x0000]; |
| 33 | | int pen_r = work_ram[count+0x0000]; |
| 34 | | int pen_g = work_ram[count+0x0000]; |
| 33 | int tile = vram[count+0x0000]; |
| 34 | int color = vram[count+0x4000] & 7; |
| 35 | //attr & 0x10 is used ... bitmap mode? (apparently bits 4 and 7 are used for that) |
| 35 | 36 | |
| 36 | 37 | for(yi=0;yi<8;yi++) |
| 37 | 38 | { |
| 38 | 39 | for(xi=0;xi<8;xi++) |
| 39 | 40 | { |
| 40 | | int pen[3],color; |
| 41 | int pen; |
| 41 | 42 | |
| 42 | | pen[0] = (gfx_rom[pen_b*8+yi] >> (7-xi) & 1) ? 1 : 0; |
| 43 | | pen[1] = (gfx_rom[pen_r*8+yi] >> (7-xi) & 1) ? 2 : 0; |
| 44 | | pen[2] = (gfx_rom[pen_g*8+yi] >> (7-xi) & 1) ? 4 : 0; |
| 43 | pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0; |
| 45 | 44 | |
| 46 | | color = (pen[0]) | (pen[1]) | (pen[2]); |
| 47 | | |
| 48 | | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[color]; |
| 45 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen]; |
| 49 | 46 | } |
| 50 | 47 | } |
| 51 | 48 | |
| 52 | | if(cursor_addr == count) |
| 49 | if(cursor_addr-0x400 == count) |
| 53 | 50 | { |
| 54 | 51 | int xc,yc,cursor_on; |
| 55 | 52 | |
| r8644 | r8645 | |
| 103 | 100 | } |
| 104 | 101 | } |
| 105 | 102 | |
| 103 | /* |
| 104 | Keyboard scancode table (notice that we're using Sharp X1 char, so some bits might be different): |
| 105 | 0x00: right or space |
| 106 | 0x01: up |
| 107 | 0x02: ? |
| 108 | 0x03: left |
| 109 | 0x04: down |
| 110 | 0x05: right or space |
| 111 | 0x06 |
| 112 | 0x07: (changes the items at the bottom, caps lock?) |
| 113 | 0x08 |
| 114 | 0x09 |
| 115 | 0x0a |
| 116 | 0x0b |
| 117 | 0x0c |
| 118 | 0x0d: 8 |
| 119 | 0x0e: 9 |
| 120 | 0x0f: * |
| 121 | 0x10: 7 |
| 122 | 0x11: 4 |
| 123 | 0x12: 6 |
| 124 | 0x13: 8 |
| 125 | 0x14: 0 |
| 126 | 0x15: ^ |
| 127 | 0x16: - |
| 128 | 0x17: 3 |
| 129 | 0x18: backspace |
| 130 | 0x19: 5 |
| 131 | 0x1a: 1 |
| 132 | 0x1b: 2 |
| 133 | 0x1c: 9 |
| 134 | 0x1d: 7 |
| 135 | 0x1e: backspace |
| 136 | 0x1f: Yen symbol? |
| 137 | 0x20: U |
| 138 | 0x21: R |
| 139 | 0x22: Y |
| 140 | 0x23: I |
| 141 | 0x24: P |
| 142 | 0x25: [ |
| 143 | 0x26: @ |
| 144 | 0x27: 0 |
| 145 | 0x28: Q |
| 146 | 0x29: T |
| 147 | 0x2a: W |
| 148 | 0x2b: E |
| 149 | 0x2c: O |
| 150 | 0x2d: . |
| 151 | 0x2e: HOME |
| 152 | 0x2f: ENTER |
| 153 | 0x30: J |
| 154 | 0x31: F |
| 155 | 0x32: H |
| 156 | 0x33: K |
| 157 | 0x34: ; |
| 158 | 0x35: ] |
| 159 | 0x36: : |
| 160 | 0x37: 4 |
| 161 | 0x38: A |
| 162 | 0x39: G |
| 163 | 0x3a: S |
| 164 | 0x3b: D |
| 165 | 0x3c: L |
| 166 | 0x3d: 5 |
| 167 | 0x3e: 6 |
| 168 | 0x3f: - |
| 169 | 0x40: M |
| 170 | 0x41: V |
| 171 | 0x42: N |
| 172 | 0x43: , |
| 173 | 0x44: / |
| 174 | 0x45: / |
| 175 | 0x46: _ |
| 176 | 0x47: 1 |
| 177 | 0x48: Z |
| 178 | 0x49: B |
| 179 | 0x4a: X |
| 180 | 0x4b: C |
| 181 | 0x4c: . |
| 182 | 0x4d: 2 |
| 183 | 0x4e: 3 |
| 184 | 0x4f: + |
| 185 | 0x50: PF1 |
| 186 | 0x51: PF2 |
| 187 | 0x52: PF3 |
| 188 | 0x53: PF4 |
| 189 | 0x54: PF5 |
| 190 | 0x55-0x7f: unused |
| 191 | */ |
| 192 | |
| 193 | static READ8_HANDLER( bml3_keyboard_r ) |
| 194 | { |
| 195 | static int scancode; |
| 196 | |
| 197 | if(input_code_pressed_once(space->machine, KEYCODE_Z)) |
| 198 | scancode++; |
| 199 | |
| 200 | if(input_code_pressed_once(space->machine, KEYCODE_X)) |
| 201 | scancode--; |
| 202 | |
| 203 | popmessage("%02x",scancode); |
| 204 | |
| 205 | return scancode | 0x80; |
| 206 | } |
| 207 | |
| 106 | 208 | /* Note: this custom code is there just for simplicity, it'll be nuked in the end */ |
| 107 | 209 | static READ8_HANDLER( bml3_io_r ) |
| 108 | 210 | { |
| 109 | 211 | static UINT8 *rom = memory_region(space->machine, "maincpu"); |
| 110 | 212 | |
| 111 | | if(offset < 0xc0) |
| 213 | if(offset == 0xc8) //??? |
| 214 | return 0; |
| 215 | |
| 216 | if(offset == 0xc9) |
| 217 | return 0x11; //put 320 x 200 mode |
| 218 | |
| 219 | if(offset == 0xe0) return bml3_keyboard_r(space,0); |
| 220 | |
| 221 | // if(offset == 0xcb || offset == 0xc4) |
| 222 | |
| 223 | // if(offset == 0x40 || offset == 0x42 || offset == 0x44 || offset == 0x46) |
| 224 | |
| 225 | |
| 226 | if(offset < 0xf0) |
| 112 | 227 | { |
| 113 | 228 | logerror("I/O read [%02x] at PC=%04x\n",offset,cpu_get_pc(space->cpu)); |
| 114 | 229 | return 0; |
| 115 | 230 | } |
| 116 | 231 | |
| 117 | | if(offset == 0xc8) //this seems the keyboard status |
| 118 | | return 0; |
| 119 | | |
| 120 | | if(offset == 0xc9) |
| 121 | | return 0x11; //put 320 x 200 mode |
| 122 | | |
| 123 | 232 | /* TODO: pretty sure that there's a bankswitch for this */ |
| 124 | 233 | return rom[offset+0xff00]; |
| 125 | 234 | } |
| r8644 | r8645 | |
| 127 | 236 | static WRITE8_HANDLER( bml3_io_w ) |
| 128 | 237 | { |
| 129 | 238 | if(offset == 0xc6 || offset == 0xc7) { bml3_6845_w(space,offset-0xc6,data); } |
| 239 | else if(offset == 0xd8) { attr_latch = data; } |
| 130 | 240 | else |
| 131 | 241 | { |
| 132 | 242 | logerror("I/O write %02x -> [%02x] at PC=%04x\n",data,offset,cpu_get_pc(space->cpu)); |
| 133 | 243 | } |
| 134 | 244 | } |
| 135 | 245 | |
| 246 | static READ8_HANDLER( bml3_vram_r ) |
| 247 | { |
| 248 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 249 | |
| 250 | /* TODO: this presumably also triggers an attr latch read */ |
| 251 | |
| 252 | return vram[offset]; |
| 253 | } |
| 254 | |
| 255 | static WRITE8_HANDLER( bml3_vram_w ) |
| 256 | { |
| 257 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 258 | |
| 259 | vram[offset] = data; |
| 260 | vram[offset+0x4000] = attr_latch; |
| 261 | } |
| 262 | |
| 136 | 263 | static ADDRESS_MAP_START(bml3_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 137 | 264 | ADDRESS_MAP_UNMAP_HIGH |
| 138 | | AM_RANGE(0x0000, 0x9fff) AM_RAM AM_BASE(&work_ram) |
| 265 | AM_RANGE(0x0000, 0x03ff) AM_RAM |
| 266 | AM_RANGE(0x0400, 0x43ff) AM_READWRITE(bml3_vram_r,bml3_vram_w) |
| 267 | AM_RANGE(0x4400, 0x9fff) AM_RAM |
| 139 | 268 | AM_RANGE(0xff00, 0xffff) AM_READWRITE(bml3_io_r,bml3_io_w) |
| 140 | 269 | AM_RANGE(0xa000, 0xffff) AM_ROM |
| 141 | 270 | ADDRESS_MAP_END |
| r8644 | r8645 | |
| 164 | 293 | NULL /* update address callback */ |
| 165 | 294 | }; |
| 166 | 295 | |
| 296 | static INTERRUPT_GEN( bml3_irq ) |
| 297 | { |
| 298 | cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE); |
| 299 | } |
| 167 | 300 | |
| 301 | static PALETTE_INIT( bml3 ) |
| 302 | { |
| 303 | int i; |
| 304 | |
| 305 | for(i=0;i<8;i++) |
| 306 | palette_set_color_rgb(machine, i, pal1bit(i >> 1),pal1bit(i >> 2),pal1bit(i >> 0)); |
| 307 | } |
| 308 | |
| 309 | |
| 168 | 310 | static MACHINE_DRIVER_START( bml3 ) |
| 169 | 311 | /* basic machine hardware */ |
| 170 | 312 | MDRV_CPU_ADD("maincpu",M6809, XTAL_1MHz) |
| 171 | 313 | MDRV_CPU_PROGRAM_MAP(bml3_mem) |
| 314 | MDRV_CPU_VBLANK_INT("screen", bml3_irq ) |
| 172 | 315 | |
| 173 | 316 | MDRV_MACHINE_RESET(bml3) |
| 174 | 317 | |
| r8644 | r8645 | |
| 180 | 323 | MDRV_SCREEN_SIZE(640, 480) |
| 181 | 324 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 182 | 325 | MDRV_PALETTE_LENGTH(8) |
| 326 | MDRV_PALETTE_INIT(bml3) |
| 183 | 327 | |
| 184 | 328 | MDRV_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 185 | 329 | |
| r8644 | r8645 | |
| 195 | 339 | ROM_REGION( 0x800, "char", 0 ) |
| 196 | 340 | ROM_LOAD("char.rom", 0x00000, 0x00800, BAD_DUMP CRC(e3995a57) SHA1(1c1a0d8c9f4c446ccd7470516b215ddca5052fb2) ) //Taken from Sharp X1 |
| 197 | 341 | ROM_FILL( 0x0000, 0x0008, 0x00) |
| 342 | |
| 343 | ROM_REGION( 0x8000, "vram", ROMREGION_ERASEFF ) |
| 198 | 344 | ROM_END |
| 199 | 345 | |
| 200 | 346 | /* Driver */ |