src/mess/drivers/pc6001.c
| r8727 | r8728 | |
| 126 | 126 | static UINT8 cas_switch,sys_latch; |
| 127 | 127 | static UINT32 cas_offset; |
| 128 | 128 | static UINT32 cas_maxsize; |
| 129 | /* PC6001mk2 specific */ |
| 130 | static UINT8 ex_vram_bank, bgcol_bank,exgfx_mode; |
| 129 | 131 | |
| 130 | 132 | //#define CAS_LENGTH 0x1655 |
| 131 | 133 | |
| r8727 | r8728 | |
| 342 | 344 | |
| 343 | 345 | attr = pc6001_video_ram[0]; |
| 344 | 346 | |
| 345 | | if(attr == 0x0f) |
| 347 | if(exgfx_mode) |
| 346 | 348 | { |
| 347 | | int xi,yi,pen,fgcol,color; |
| 349 | int xi,yi,pen,fgcol,bgcol,color; |
| 348 | 350 | UINT8 *gfx_data = memory_region(screen->machine, "gfx1"); |
| 349 | 351 | |
| 350 | 352 | for(y=0;y<25;y++) |
| r8727 | r8728 | |
| 360 | 362 | { |
| 361 | 363 | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 362 | 364 | |
| 363 | | fgcol = /*(attr & 2) ? 2 : */7; |
| 365 | fgcol = (attr & 0x0f) + 0x10; |
| 366 | bgcol = ((attr & 0x70) >> 4) + 0x10 + bgcol_bank*8; |
| 364 | 367 | |
| 365 | | if((attr & 0x0f) == 0x00) //TODO |
| 366 | | color = pen ? 0 : fgcol; |
| 367 | | else |
| 368 | | color = pen ? fgcol : 0; |
| 368 | color = pen ? fgcol : bgcol; |
| 369 | 369 | |
| 370 | | if ((x*8+xi) < screen->visible_area().max_x && (y*12+yi) < screen->visible_area().max_y) |
| 370 | if ((x*8+xi) <= screen->visible_area().max_x && (y*12+yi) <= screen->visible_area().max_y) |
| 371 | 371 | *BITMAP_ADDR16(bitmap, ((y*12+yi)), (x*8+xi)) = screen->machine->pens[color]; |
| 372 | 372 | } |
| 373 | 373 | } |
| r8727 | r8728 | |
| 644 | 644 | i8255a_w(device,offset,data); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | static void vram_bank_change(running_machine *machine,UINT8 vram_bank) |
| 648 | { |
| 649 | UINT8 *work_ram = memory_region(machine, "maincpu"); |
| 650 | |
| 651 | popmessage("%02x",vram_bank); |
| 652 | |
| 653 | switch(vram_bank) |
| 654 | { |
| 655 | case 0x04: pc6001_video_ram = work_ram + 0x30000; break; |
| 656 | case 0x06: pc6001_video_ram = work_ram + 0x34000; break; |
| 657 | case 0x24: pc6001_video_ram = work_ram + 0x34000; break; |
| 658 | case 0x40: pc6001_video_ram = work_ram + 0x34000; break; |
| 659 | case 0x44: pc6001_video_ram = work_ram + 0x28000; break; |
| 660 | case 0x46: pc6001_video_ram = work_ram + 0x30000; break; |
| 661 | case 0x60: pc6001_video_ram = work_ram + 0x34000; break; |
| 662 | default: |
| 663 | printf("Unhandled vram bank %02x\n",vram_bank); |
| 664 | break; |
| 665 | } |
| 666 | |
| 667 | exgfx_mode = ((vram_bank & 2) == 0); |
| 668 | } |
| 669 | |
| 647 | 670 | static WRITE8_HANDLER ( pc6001m2_system_latch_w ) |
| 648 | 671 | { |
| 649 | 672 | // UINT8 *work_ram = memory_region(space->machine, "maincpu"); |
| r8727 | r8728 | |
| 670 | 693 | } |
| 671 | 694 | |
| 672 | 695 | sys_latch = data; |
| 673 | | // printf("%02x B0\n",data); |
| 696 | vram_bank_change(space->machine,(ex_vram_bank & 0x06) | ((sys_latch & 0x06) << 4)); |
| 697 | |
| 698 | //printf("%02x B0\n",data); |
| 674 | 699 | } |
| 675 | 700 | |
| 676 | 701 | |
| 677 | 702 | static WRITE8_HANDLER( pc6001m2_vram_bank_w ) |
| 678 | 703 | { |
| 679 | | UINT8 *work_ram = memory_region(space->machine, "maincpu"); |
| 704 | // UINT32 startaddr[] = {WRAM(6), WRAM(6), WRAM(0), WRAM(4) }; |
| 680 | 705 | |
| 681 | | UINT32 startaddr[] = {WRAM(6), WRAM(6), WRAM(0), WRAM(4) }; |
| 706 | ex_vram_bank = data; |
| 707 | vram_bank_change(space->machine,(ex_vram_bank & 0x06) | ((sys_latch & 0x06) << 4)); |
| 682 | 708 | |
| 683 | | pc6001_video_ram = work_ram + startaddr[(data >> 1) & 0x03]; |
| 709 | // pc6001_video_ram = work_ram + startaddr[(data >> 1) & 0x03]; |
| 710 | } |
| 684 | 711 | |
| 685 | | printf("%08x\n",startaddr[(data >> 1) & 0x03]); |
| 686 | | |
| 687 | | printf("%02x c1\n",data); |
| 712 | static WRITE8_HANDLER( pc6001m2_col_bank_w ) |
| 713 | { |
| 714 | bgcol_bank = (data & 2) >> 1; |
| 688 | 715 | } |
| 689 | 716 | |
| 690 | 717 | static ADDRESS_MAP_START(pc6001m2_map, ADDRESS_SPACE_PROGRAM, 8) |
| r8727 | r8728 | |
| 710 | 737 | AM_RANGE(0xa1, 0xa1) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 711 | 738 | AM_RANGE(0xa2, 0xa2) AM_DEVREAD("ay8910", ay8910_r) |
| 712 | 739 | AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001m2_system_latch_w) |
| 740 | AM_RANGE(0xc0, 0xc0) AM_WRITE(pc6001m2_col_bank_w) |
| 713 | 741 | AM_RANGE(0xc1, 0xc1) AM_WRITE(pc6001m2_vram_bank_w) |
| 714 | 742 | AM_RANGE(0xf0, 0xf0) AM_WRITE(pc6001m2_bank_r0_w) |
| 715 | 743 | AM_RANGE(0xf1, 0xf1) AM_WRITE(pc6001m2_bank_r1_w) |
| r8727 | r8728 | |
| 1145 | 1173 | |
| 1146 | 1174 | }; |
| 1147 | 1175 | |
| 1176 | static const rgb_t mk2_defcolors[] = |
| 1177 | { |
| 1178 | MAKE_RGB(0x00, 0x00, 0x00), /* BLACK */ |
| 1179 | MAKE_RGB(0xff, 0xaf, 0x00), /* ORANGE */ |
| 1180 | MAKE_RGB(0x00, 0xff, 0xaf), /* tone of GREEN */ |
| 1181 | MAKE_RGB(0xaf, 0xff, 0x00), /* tone of GREEN */ |
| 1182 | MAKE_RGB(0xaf, 0x00, 0xff), /* VIOLET */ |
| 1183 | MAKE_RGB(0xff, 0x00, 0xaf), /* SCARLET */ |
| 1184 | MAKE_RGB(0x00, 0xaf, 0xff), /* LIGHT BLUE */ |
| 1185 | MAKE_RGB(0xaf, 0xaf, 0xaf), /* GRAY */ |
| 1186 | MAKE_RGB(0x00, 0x00, 0x00), /* BLACK */ |
| 1187 | MAKE_RGB(0xff, 0x00, 0x00), /* RED */ |
| 1188 | MAKE_RGB(0x00, 0xff, 0x00), /* GREEN */ |
| 1189 | MAKE_RGB(0xff, 0xff, 0x00), /* YELLOW */ |
| 1190 | MAKE_RGB(0x00, 0x00, 0xff), /* BLUE */ |
| 1191 | MAKE_RGB(0xff, 0x00, 0xff), /* PINK */ |
| 1192 | MAKE_RGB(0x00, 0xff, 0xff), /* CYAN */ |
| 1193 | MAKE_RGB(0xff, 0xff, 0xff) /* WHITE */ |
| 1194 | }; |
| 1195 | |
| 1148 | 1196 | static PALETTE_INIT(pc6001) |
| 1149 | 1197 | { |
| 1150 | 1198 | int i; |
| r8727 | r8728 | |
| 1153 | 1201 | palette_set_color(machine, i+8,defcolors[i]); |
| 1154 | 1202 | } |
| 1155 | 1203 | |
| 1204 | static PALETTE_INIT(pc6001m2) |
| 1205 | { |
| 1206 | int i; |
| 1207 | |
| 1208 | for(i=0;i<8;i++) |
| 1209 | palette_set_color(machine, i+8,defcolors[i]); |
| 1210 | |
| 1211 | for(i=0x10;i<0x20;i++) |
| 1212 | palette_set_color(machine, i,mk2_defcolors[i-0x10]); |
| 1213 | } |
| 1214 | |
| 1156 | 1215 | static const cassette_config pc6001_cassette_config = |
| 1157 | 1216 | { |
| 1158 | 1217 | pc6001_cassette_formats, |
| r8727 | r8728 | |
| 1255 | 1314 | MDRV_MACHINE_RESET(pc6001m2) |
| 1256 | 1315 | |
| 1257 | 1316 | MDRV_VIDEO_UPDATE(pc6001m2) |
| 1317 | MDRV_PALETTE_LENGTH(16+32) |
| 1318 | MDRV_PALETTE_INIT(pc6001m2) |
| 1258 | 1319 | |
| 1259 | 1320 | /* basic machine hardware */ |
| 1260 | 1321 | MDRV_CPU_MODIFY("maincpu") |