src/mess/drivers/mz2500.c
| r8957 | r8958 | |
| 76 | 76 | [2] xx-- ---- kanji select |
| 77 | 77 | */ |
| 78 | 78 | |
| 79 | | static void draw_80x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) |
| 79 | static void draw_80x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 map_addr) |
| 80 | 80 | { |
| 81 | 81 | UINT8 *vram = memory_region(machine, "maincpu"); |
| 82 | 82 | int x,y,count,xi,yi; |
| 83 | 83 | UINT8 *gfx_data; |
| 84 | 84 | UINT8 y_step; |
| 85 | UINT8 s_y; |
| 85 | 86 | |
| 86 | | count = 0x70000; |
| 87 | count = (map_addr & 0x7ff); |
| 87 | 88 | |
| 88 | 89 | y_step = (text_font_reg) ? 1 : 2; |
| 90 | s_y = text_reg[9] & 0xf; |
| 89 | 91 | |
| 90 | | for (y=0;y<25;y+=y_step) |
| 92 | for (y=0;y<26;y+=y_step) |
| 91 | 93 | { |
| 92 | 94 | for (x=0;x<80;x++) |
| 93 | 95 | { |
| 94 | | int tile = vram[count+0x0000] & 0xff; |
| 95 | | int attr = vram[count+0x0800]; |
| 96 | | int tile_bank = vram[count+0x1000] & 0x3f; |
| 97 | | int gfx_sel = (attr & 0x38) | (vram[count+0x1000] & 0xc0); |
| 98 | | //int gfx_num; |
| 96 | int tile = vram[0x70000+count+0x0000] & 0xff; |
| 97 | int attr = vram[0x70000+count+0x0800]; |
| 98 | int tile_bank = vram[0x70000+count+0x1000] & 0x3f; |
| 99 | int gfx_sel = (attr & 0x38) | (vram[0x70000+count+0x1000] & 0xc0); |
| 99 | 100 | int color = attr & 7; |
| 100 | 101 | |
| 102 | if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms |
| 103 | gfx_data = memory_region(machine,"pcg"); |
| 101 | 104 | if(gfx_sel == 0x80) |
| 102 | 105 | { |
| 103 | 106 | gfx_data = memory_region(machine,"kanji"); |
| r8957 | r8958 | |
| 138 | 141 | } |
| 139 | 142 | |
| 140 | 143 | if(pen) |
| 141 | | *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = machine->pens[pen]; |
| 144 | { |
| 145 | if((y*8+yi-s_y) >= 0 && (y*8+yi-s_y) < 200) |
| 146 | *BITMAP_ADDR16(bitmap, (y*8+yi-s_y), x*8+xi) = machine->pens[pen]; |
| 147 | } |
| 142 | 148 | } |
| 143 | 149 | } |
| 144 | 150 | //drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_num],tile,color,0,0,x*8,(y)*8); |
| 145 | 151 | |
| 146 | 152 | count++; |
| 153 | count&=0x7ff; |
| 147 | 154 | } |
| 148 | 155 | } |
| 149 | 156 | } |
| 150 | 157 | |
| 151 | | static void draw_40x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int plane) |
| 158 | static void draw_40x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int plane,UINT16 map_addr) |
| 152 | 159 | { |
| 153 | 160 | UINT8 *vram = memory_region(machine, "maincpu"); |
| 154 | 161 | int x,y,count,xi,yi; |
| 155 | 162 | UINT8 *gfx_data; |
| 156 | 163 | UINT8 y_step; |
| 164 | UINT8 s_y; |
| 157 | 165 | |
| 158 | | count = 0x70000 + (plane * 0x400); |
| 166 | count = (((plane * 0x400) + map_addr) & 0x7ff); |
| 159 | 167 | |
| 160 | 168 | y_step = (text_font_reg) ? 1 : 2; |
| 169 | s_y = text_reg[9] & 0xf; |
| 161 | 170 | |
| 162 | | for (y=0;y<25;y+=y_step) |
| 171 | for (y=0;y<26;y+=y_step) |
| 163 | 172 | { |
| 164 | 173 | for (x=0;x<40;x++) |
| 165 | 174 | { |
| 166 | | int tile = vram[count+0x0000] & 0xff; |
| 167 | | int attr = vram[count+0x0800]; |
| 168 | | int tile_bank = vram[count+0x1000] & 0x3f; |
| 169 | | int gfx_sel = (attr & 0x38) | (vram[count+0x1000] & 0xc0); |
| 175 | int tile = vram[0x70000+count+0x0000] & 0xff; |
| 176 | int attr = vram[0x70000+count+0x0800]; |
| 177 | int tile_bank = vram[0x70000+count+0x1000] & 0x3f; |
| 178 | int gfx_sel = (attr & 0x38) | (vram[0x70000+count+0x1000] & 0xc0); |
| 170 | 179 | //int gfx_num; |
| 171 | 180 | int color = attr & 7; |
| 172 | 181 | |
| 173 | | if(gfx_sel == 0x80 || gfx_sel == 0xc0) |
| 174 | | gfx_data = memory_region(machine,"kanji"); //TODO |
| 182 | if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms |
| 183 | gfx_data = memory_region(machine,"pcg"); |
| 184 | else if(gfx_sel == 0x80) |
| 185 | { |
| 186 | gfx_data = memory_region(machine,"kanji"); |
| 187 | tile|= tile_bank << 8; |
| 188 | if(y_step == 2) |
| 189 | tile &= 0x3ffe; |
| 190 | } |
| 191 | else if(gfx_sel == 0xc0) |
| 192 | { |
| 193 | gfx_data = memory_region(machine,"kanji"); |
| 194 | tile|= (tile_bank << 8); |
| 195 | if(y_step == 2) |
| 196 | tile &= 0x3ffe; |
| 197 | tile|=0x4000; |
| 198 | } |
| 175 | 199 | else |
| 200 | { |
| 176 | 201 | gfx_data = memory_region(machine,"pcg"); |
| 202 | } |
| 177 | 203 | |
| 178 | | tile|= tile_bank << 8; |
| 179 | | |
| 180 | 204 | for(yi=0;yi<8*y_step;yi++) |
| 181 | 205 | { |
| 182 | 206 | for(xi=0;xi<8;xi++) |
| r8957 | r8958 | |
| 195 | 219 | pen = ((gfx_data[tile*8+yi+((gfx_sel & 0x30)<<7)]>>(7-xi)) & 1) ? color : 0; |
| 196 | 220 | |
| 197 | 221 | if(pen) |
| 198 | | *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = machine->pens[pen]; |
| 222 | { |
| 223 | if((y*8+yi-s_y) >= 0 && (y*8+yi-s_y) < 200) |
| 224 | *BITMAP_ADDR16(bitmap, (y*8+yi-s_y), x*8+xi) = machine->pens[pen]; |
| 225 | } |
| 199 | 226 | } |
| 200 | 227 | } |
| 201 | 228 | //drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_num],tile,color,0,0,x*8,(y)*8); |
| 202 | 229 | |
| 203 | 230 | count++; |
| 231 | count&=0x7ff; |
| 204 | 232 | } |
| 205 | 233 | } |
| 206 | 234 | } |
| 207 | 235 | |
| 208 | 236 | static void draw_tv_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) |
| 209 | 237 | { |
| 210 | | //w = (text_col_size) ? 2 : 1; //80 : 40 |
| 238 | UINT16 base_addr; |
| 239 | |
| 240 | base_addr = text_reg[1] | ((text_reg[2] & 0x7) << 8); |
| 241 | |
| 242 | // popmessage("%02x",text_reg[9]); |
| 243 | |
| 211 | 244 | if(text_col_size) |
| 212 | | draw_80x25(machine,bitmap,cliprect); |
| 245 | draw_80x25(machine,bitmap,cliprect,base_addr); |
| 213 | 246 | else |
| 214 | 247 | { |
| 215 | 248 | int tv_mode; |
| r8957 | r8958 | |
| 220 | 253 | { |
| 221 | 254 | // case 0: mixed 6bpp mode |
| 222 | 255 | case 1: |
| 223 | | draw_40x25(machine,bitmap,cliprect,0); |
| 256 | draw_40x25(machine,bitmap,cliprect,0,base_addr); |
| 224 | 257 | break; |
| 225 | 258 | case 2: |
| 226 | | draw_40x25(machine,bitmap,cliprect,1); |
| 259 | draw_40x25(machine,bitmap,cliprect,1,base_addr); |
| 227 | 260 | break; |
| 228 | 261 | case 3: |
| 229 | | draw_40x25(machine,bitmap,cliprect,0); |
| 230 | | draw_40x25(machine,bitmap,cliprect,1); |
| 262 | draw_40x25(machine,bitmap,cliprect,0,base_addr); |
| 263 | draw_40x25(machine,bitmap,cliprect,1,base_addr); |
| 231 | 264 | break; |
| 232 | 265 | default: popmessage("%02x %02x %02x",tv_mode & 3,text_reg[1],text_reg[2]); break; |
| 233 | 266 | } |
| r8957 | r8958 | |
| 242 | 275 | int x,y,xi,pen_i; |
| 243 | 276 | UINT32 wa_reg; |
| 244 | 277 | UINT8 s_x; |
| 278 | UINT8 base_mask; |
| 245 | 279 | |
| 246 | | count = (cg_reg[0x10]) | ((cg_reg[0x11] & 0x3f) << 8); |
| 247 | | wa_reg = (cg_reg[0x12]) | ((cg_reg[0x13] & 0x3f) << 8); |
| 280 | base_mask = (x_size == 640) ? 0x3f : 0x1f; |
| 281 | |
| 282 | count = (cg_reg[0x10]) | ((cg_reg[0x11] & base_mask) << 8); |
| 283 | wa_reg = (cg_reg[0x12]) | ((cg_reg[0x13] & base_mask) << 8); |
| 248 | 284 | /* TODO: layer 2 scrolling */ |
| 249 | 285 | s_x = (cg_reg[0x0f] & 0xf); |
| 250 | 286 | |
| r8957 | r8958 | |
| 267 | 303 | *BITMAP_ADDR16(bitmap, y, x+xi+s_x) = machine->pens[(clut16[pen] & 0x0f)+0x200]; |
| 268 | 304 | } |
| 269 | 305 | count++; |
| 270 | | count&=0x3fff; |
| 306 | count&=((base_mask<<8) | 0xff); |
| 271 | 307 | if(count > wa_reg) |
| 272 | 308 | count = 0; |
| 273 | 309 | } |
| r8957 | r8958 | |
| 341 | 377 | draw_tv_screen(screen->machine,bitmap,cliprect); |
| 342 | 378 | draw_cg_screen(screen->machine,bitmap,cliprect); |
| 343 | 379 | //draw_tv_screen(screen->machine,bitmap,cliprect); |
| 344 | | popmessage("%02x (%02x %02x) (%02x %02x) (%02x %02x) (%02x %02x)",cg_reg[0x0f],cg_reg[0x10],cg_reg[0x11],cg_reg[0x12],cg_reg[0x13],cg_reg[0x14],cg_reg[0x15],cg_reg[0x16],cg_reg[0x17]); |
| 380 | // popmessage("%02x (%02x %02x) (%02x %02x) (%02x %02x) (%02x %02x)",cg_reg[0x0f],cg_reg[0x10],cg_reg[0x11],cg_reg[0x12],cg_reg[0x13],cg_reg[0x14],cg_reg[0x15],cg_reg[0x16],cg_reg[0x17]); |
| 345 | 381 | } |
| 346 | 382 | else //4096 mode colors |
| 347 | 383 | { |
| r8957 | r8958 | |
| 460 | 496 | //printf("%04x %02x\n",offset+bank_num*0x2000,data); |
| 461 | 497 | break; |
| 462 | 498 | } |
| 499 | case 0x38: |
| 500 | { |
| 501 | // TVRAM |
| 502 | ram[offset+cur_bank*0x2000] = data; |
| 503 | break; |
| 504 | } |
| 463 | 505 | case 0x39: |
| 464 | 506 | { |
| 507 | ram[offset+cur_bank*0x2000] = data; |
| 465 | 508 | if(kanji_bank & 0x80) //kanji ROM |
| 466 | 509 | { |
| 467 | 510 | //NOP |
| r8957 | r8958 | |
| 529 | 572 | |
| 530 | 573 | bank_val[bank_addr] = data & 0x3f; |
| 531 | 574 | |
| 532 | | //printf("%02x %02x\n",data & 0x3f,bank_addr); |
| 533 | | |
| 534 | 575 | // if((data*2) >= 0x70) |
| 535 | 576 | // printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2); |
| 536 | 577 | |
| r8957 | r8958 | |
| 562 | 603 | [1] xxxx xxxx TV map offset low address value |
| 563 | 604 | [2] ---- -xxx TV map offset high address value |
| 564 | 605 | |
| 565 | | [9] ---- xxxx vertical scrolling? (val * 2) |
| 606 | [9] ---- xxxx vertical scrolling shift position |
| 566 | 607 | */ |
| 567 | 608 | |
| 568 | 609 | static UINT8 pal_256_param(int index, int param) |
| r8957 | r8958 | |
| 658 | 699 | irq_mask[2] = (data & 0x02); //printer |
| 659 | 700 | irq_mask[3] = (data & 0x01); //RP5c15 |
| 660 | 701 | |
| 661 | | printf("%02x\n",data); |
| 702 | // printf("%02x\n",data); |
| 662 | 703 | } |
| 663 | 704 | |
| 664 | 705 | static WRITE8_HANDLER( mz2500_irq_data_w ) |
| r8957 | r8958 | |
| 889 | 930 | hs = (cg_reg[0x0c] & 0x7f)*8; |
| 890 | 931 | he = (cg_reg[0x0d] & 0x7f)*8; |
| 891 | 932 | |
| 892 | | popmessage("%d %d %d %d %02x",vs,ve,hs,he,cg_reg[0x0e]); |
| 933 | //popmessage("%d %d %d %d %02x",vs,ve,hs,he,cg_reg[0x0e]); |
| 893 | 934 | |
| 894 | 935 | space->machine->primary_screen->configure(720, 480, visarea, space->machine->primary_screen->frame_period().attoseconds); //TODO |
| 895 | 936 | } |
| r8957 | r8958 | |
| 1524 | 1565 | ROM_REGION( 0x40000, "dictionary", 0 ) |
| 1525 | 1566 | ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) ) |
| 1526 | 1567 | |
| 1527 | | ROM_REGION( 0x2000, "pcg", ROMREGION_ERASEFF ) |
| 1568 | ROM_REGION( 0x2000, "pcg", ROMREGION_ERASE00 ) |
| 1528 | 1569 | |
| 1529 | 1570 | ROM_REGION( 0x8000, "rom", ROMREGION_ERASEFF ) |
| 1530 | 1571 | ROM_LOAD( "file.rom", 0x00000, 0x8000, CRC(a7bf39ce) SHA1(3f4a237fc4f34bac6fe2bbda4ce4d16d42400081) ) //optional? |