src/mess/drivers/pc8801.c
| r10095 | r10096 | |
| 9 | 9 | later models at some point. |
| 10 | 10 | - macros for the various rom / ram areas, it might require various attempts in order to finally get a reasonable arrangement ... |
| 11 | 11 | - dipswitches are WRONG |
| 12 | | - implement proper i8214 routing, also add irq latch mechanism. |
| 12 | - implement proper i8214 routing, also add irq latch mechanism; |
| 13 | - implement proper upd3301 / i8257 support; |
| 13 | 14 | - below notes states that plain PC-8801 doesn't have a disk CPU, but the BIOS clearly checks the floppy ports. Wrong info? |
| 14 | 15 | - joystick / mouse support; |
| 15 | 16 | - cursor is 8 x 10, not 8 x 8 as current implementation. |
| r10095 | r10096 | |
| 143 | 144 | static UINT8 dmac_mode; |
| 144 | 145 | static UINT8 alu_ctrl1,alu_ctrl2; |
| 145 | 146 | static UINT8 extram_mode,extram_bank; |
| 147 | static UINT8 txt_width, txt_color; |
| 146 | 148 | static int vblank_pos; |
| 147 | 149 | |
| 148 | 150 | static void pc8801_update_irq(running_machine *machine) |
| r10095 | r10096 | |
| 202 | 204 | |
| 203 | 205 | } |
| 204 | 206 | |
| 205 | | static UINT8 calc_cursor_pos(running_machine *machine,int x,int y,int yi) |
| 206 | | { |
| 207 | | if(!(crtc.cursor_on)) // don't bother if cursor is off |
| 208 | | return 0; |
| 209 | | |
| 210 | | if(x == crtc.param[4][0] && y == crtc.param[4][1]) /* check if position matches */ |
| 211 | | { |
| 212 | | /* don't pass through if we are using underscore */ |
| 213 | | if((!(crtc.param[0][2] & 0x40)) && yi != 7) |
| 214 | | return 0; |
| 215 | | |
| 216 | | /* finally check if blinking is currently active high */ |
| 217 | | if(!(crtc.param[0][2] & 0x20)) |
| 218 | | return 1; |
| 219 | | |
| 220 | | if(((machine->primary_screen->frame_number() / blink_speed) & 1) == 0) |
| 221 | | return 1; |
| 222 | | |
| 223 | | return 0; |
| 224 | | } |
| 225 | | |
| 226 | | return 0; |
| 227 | | } |
| 228 | | |
| 229 | 207 | static void draw_bitmap_3bpp(running_machine *machine, bitmap_t *bitmap) |
| 230 | 208 | { |
| 231 | 209 | int x,y,xi; |
| r10095 | r10096 | |
| 270 | 248 | { |
| 271 | 249 | for(xi=0;xi<8;xi++) |
| 272 | 250 | { |
| 273 | | int pen = 0; |
| 251 | int pen; |
| 274 | 252 | |
| 253 | pen = 0; |
| 275 | 254 | /* TODO: dunno if layer_mask is correct here */ |
| 276 | 255 | if(!(layer_mask & 2)) { pen = ((gvram[count+0x0000] >> (7-xi)) & 1) << 0; } |
| 277 | 256 | |
| r10095 | r10096 | |
| 292 | 271 | { |
| 293 | 272 | for(xi=0;xi<8;xi++) |
| 294 | 273 | { |
| 295 | | int pen = 0; |
| 274 | int pen; |
| 296 | 275 | |
| 276 | pen = 0; |
| 297 | 277 | /* TODO: dunno if layer_mask is correct here */ |
| 298 | 278 | if(!(layer_mask & 4)) { pen = ((gvram[count+0x4000] >> (7-xi)) & 1) << 0; } |
| 299 | 279 | |
| r10095 | r10096 | |
| 306 | 286 | } |
| 307 | 287 | } |
| 308 | 288 | |
| 309 | | static VIDEO_UPDATE( pc8801 ) |
| 289 | static UINT8 calc_cursor_pos(running_machine *machine,int x,int y,int yi) |
| 310 | 290 | { |
| 291 | if(!(crtc.cursor_on)) // don't bother if cursor is off |
| 292 | return 0; |
| 293 | |
| 294 | if(x == crtc.param[4][0] && y == crtc.param[4][1]) /* check if position matches */ |
| 295 | { |
| 296 | /* don't pass through if we are using underscore */ |
| 297 | if((!(crtc.param[0][2] & 0x40)) && yi != 7) |
| 298 | return 0; |
| 299 | |
| 300 | /* finally check if blinking is currently active high */ |
| 301 | if(!(crtc.param[0][2] & 0x20)) |
| 302 | return 1; |
| 303 | |
| 304 | if(((machine->primary_screen->frame_number() / blink_speed) & 1) == 0) |
| 305 | return 1; |
| 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | static void draw_text_80(running_machine *machine, bitmap_t *bitmap,int y_size) |
| 314 | { |
| 311 | 315 | int x,y; |
| 312 | 316 | int xi,yi; |
| 313 | | UINT8 *vram = screen->machine->region("maincpu")->base() + WRAM_BASE; |
| 317 | UINT8 *vram = machine->region("maincpu")->base() + WRAM_BASE; |
| 314 | 318 | UINT8 is_cursor; |
| 315 | | bitmap_fill(bitmap, cliprect, screen->machine->pens[0]); |
| 319 | UINT8 y_height; |
| 316 | 320 | |
| 317 | | if(gfx_ctrl & 8) |
| 321 | y_height = y_size == 20 ? 10 : 8; |
| 322 | |
| 323 | for(y=0;y<y_size;y++) |
| 318 | 324 | { |
| 319 | | if(gfx_ctrl & 0x10) |
| 320 | | draw_bitmap_3bpp(screen->machine,bitmap); |
| 321 | | else |
| 322 | | draw_bitmap_1bpp(screen->machine,bitmap); |
| 325 | for(x=0;x<80;x++) |
| 326 | { |
| 327 | for(yi=0;yi<8;yi++) |
| 328 | { |
| 329 | is_cursor = calc_cursor_pos(machine,x,y,yi); |
| 330 | |
| 331 | for(xi=0;xi<8;xi++) |
| 332 | { |
| 333 | int res_x,res_y; |
| 334 | int tile; |
| 335 | int color; |
| 336 | UINT8 *gfx_data = machine->region("gfx1")->base(); |
| 337 | |
| 338 | tile = vram[x+(y*120)+dma_address[2]]; |
| 339 | |
| 340 | res_x = x*8+xi; |
| 341 | res_y = y*y_height+yi; |
| 342 | |
| 343 | if(is_cursor) |
| 344 | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7; |
| 345 | else |
| 346 | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1; |
| 347 | |
| 348 | if((res_x)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y) |
| 349 | if(color != -1) |
| 350 | *BITMAP_ADDR16(bitmap, res_y, res_x) = machine->pens[color]; |
| 351 | } |
| 352 | } |
| 353 | } |
| 323 | 354 | } |
| 355 | } |
| 324 | 356 | |
| 325 | | if(!(layer_mask & 1) && dmac_mode & 4 && crtc.status & 0x10 && crtc.irq_mask == 3) |
| 357 | static void draw_text_40(running_machine *machine, bitmap_t *bitmap, int y_size) |
| 358 | { |
| 359 | int x,y; |
| 360 | int xi,yi; |
| 361 | UINT8 *vram = machine->region("maincpu")->base() + WRAM_BASE; |
| 362 | UINT8 is_cursor; |
| 363 | UINT8 y_height; |
| 364 | |
| 365 | y_height = y_size == 20 ? 10 : 8; |
| 366 | |
| 367 | for(y=0;y<y_size;y++) |
| 326 | 368 | { |
| 327 | | for(y=0;y<25;y++) |
| 369 | for(x=0;x<80;x++) |
| 328 | 370 | { |
| 329 | | for(x=0;x<80;x++) |
| 371 | if(x & 1) |
| 372 | continue; |
| 373 | |
| 374 | for(yi=0;yi<8;yi++) |
| 330 | 375 | { |
| 331 | | for(yi=0;yi<8;yi++) |
| 376 | is_cursor = calc_cursor_pos(machine,x,y,yi); |
| 377 | |
| 378 | for(xi=0;xi<8;xi++) |
| 332 | 379 | { |
| 333 | | for(xi=0;xi<8;xi++) |
| 334 | | { |
| 335 | | int res_x,res_y; |
| 336 | | int tile; |
| 337 | | int color; |
| 338 | | UINT8 *gfx_data = screen->machine->region("gfx1")->base(); |
| 380 | int res_x,res_y; |
| 381 | int tile; |
| 382 | int color; |
| 383 | UINT8 *gfx_data = machine->region("gfx1")->base(); |
| 339 | 384 | |
| 340 | | tile = vram[x+(y*120)+dma_address[2]]; |
| 385 | tile = vram[x+(y*120)+dma_address[2]]; |
| 341 | 386 | |
| 342 | | res_x = x*8+xi; |
| 343 | | res_y = y*8+yi; |
| 387 | res_x = (x*8)+xi*2; |
| 388 | res_y = (y*y_height)+yi; |
| 344 | 389 | |
| 345 | | is_cursor = calc_cursor_pos(screen->machine,x,y,yi); |
| 390 | if(is_cursor) |
| 391 | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7; |
| 392 | else |
| 393 | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1; |
| 346 | 394 | |
| 347 | | if(is_cursor) |
| 348 | | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7; |
| 349 | | else |
| 350 | | color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1; |
| 351 | | |
| 352 | | if((res_x)<=screen->machine->primary_screen->visible_area().max_x && (res_y)<=screen->machine->primary_screen->visible_area().max_y) |
| 353 | | if(color != -1) |
| 354 | | *BITMAP_ADDR16(bitmap, res_y, res_x) = screen->machine->pens[color]; |
| 355 | | } |
| 395 | if((res_x)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y) |
| 396 | if(color != -1) |
| 397 | *BITMAP_ADDR16(bitmap, res_y, res_x) = machine->pens[color]; |
| 398 | if((res_x+1)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y) |
| 399 | if(color != -1) |
| 400 | *BITMAP_ADDR16(bitmap, res_y, res_x+1) = machine->pens[color]; |
| 356 | 401 | } |
| 357 | 402 | } |
| 358 | 403 | } |
| 359 | 404 | } |
| 405 | } |
| 360 | 406 | |
| 407 | static VIDEO_UPDATE( pc8801 ) |
| 408 | { |
| 409 | bitmap_fill(bitmap, cliprect, screen->machine->pens[0]); |
| 410 | |
| 411 | if(gfx_ctrl & 8) |
| 412 | { |
| 413 | if(gfx_ctrl & 0x10) |
| 414 | draw_bitmap_3bpp(screen->machine,bitmap); |
| 415 | else |
| 416 | draw_bitmap_1bpp(screen->machine,bitmap); |
| 417 | } |
| 418 | |
| 419 | if(!(layer_mask & 1) && dmac_mode & 4 && crtc.status & 0x10 && crtc.irq_mask == 3) |
| 420 | { |
| 421 | static int y_size; |
| 422 | |
| 423 | y_size = (crtc.param[0][1] & 0x3f) + 1; |
| 424 | |
| 425 | if(y_size < 20) y_size = 20; |
| 426 | if(y_size > 25) y_size = 25; |
| 427 | |
| 428 | if(txt_width) |
| 429 | draw_text_80(screen->machine,bitmap,y_size); |
| 430 | else |
| 431 | draw_text_40(screen->machine,bitmap,y_size); |
| 432 | } |
| 433 | |
| 361 | 434 | return 0; |
| 362 | 435 | } |
| 363 | 436 | |
| r10095 | r10096 | |
| 782 | 855 | rtc_irq_mask = data & 1; |
| 783 | 856 | vrtc_irq_mask = data & 2; |
| 784 | 857 | |
| 785 | | if(data & 4) |
| 786 | | printf("IRQ mask %02x\n",data); |
| 858 | //if(data & 4) |
| 859 | // printf("IRQ mask %02x\n",data); |
| 787 | 860 | } |
| 788 | 861 | |
| 789 | 862 | static READ8_HANDLER( pc8801_window_bank_r ) |
| r10095 | r10096 | |
| 1015 | 1088 | return 0; |
| 1016 | 1089 | } |
| 1017 | 1090 | |
| 1091 | static WRITE8_HANDLER( pc8801_txt_cmt_ctrl_w ) |
| 1092 | { |
| 1093 | /* bits 2 to 5 are cmt related */ |
| 1094 | |
| 1095 | txt_width = data & 1; |
| 1096 | txt_color = data & 2; |
| 1097 | } |
| 1098 | |
| 1018 | 1099 | static ADDRESS_MAP_START( pc8801_io, ADDRESS_SPACE_IO, 8 ) |
| 1019 | 1100 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 1020 | 1101 | ADDRESS_MAP_UNMAP_HIGH |
| r10095 | r10096 | |
| 1037 | 1118 | AM_RANGE(0x00, 0x02) AM_WRITE(pc8801_pcg8100_w) |
| 1038 | 1119 | // AM_RANGE(0x10, 0x10) AM_WRITE(pc88_rtc_w) |
| 1039 | 1120 | AM_RANGE(0x21, 0x21) AM_READ(sio_status_r) /* RS-232C and cassette */ |
| 1040 | | AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") //AM_WRITE(pc88sr_outport_30) |
| 1121 | AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") AM_WRITE(pc8801_txt_cmt_ctrl_w) |
| 1041 | 1122 | AM_RANGE(0x31, 0x31) AM_READ_PORT("DSW2") AM_WRITE(pc8801_gfx_ctrl_w) |
| 1042 | 1123 | AM_RANGE(0x32, 0x32) AM_READWRITE(pc8801_misc_ctrl_r, pc8801_misc_ctrl_w) |
| 1043 | 1124 | AM_RANGE(0x34, 0x34) AM_WRITE(pc8801_alu_ctrl1_w) |