src/mame/drivers/megadriv.c
| r9359 | r9360 | |
| 245 | 245 | #159 Runlength Mode |
| 246 | 246 | #160 Runlength Mode |
| 247 | 247 | #161 Runlength Mode |
| 248 | |
| 249 | |
| 250 | ---------------------------- |
| 251 | SegaCD notes |
| 252 | ---------------------------- |
| 253 | |
| 254 | the use of the MAME tilemap system for the SegaCD 'Roz tilemap' isn't intended as a long-term |
| 255 | solution. (In reality it's not a displayable tilemap anyway, just a source buffer which has |
| 256 | a tilemap-like structure, from which data is copied) |
| 257 | |
| 248 | 258 | */ |
| 249 | 259 | |
| 250 | 260 | |
| r9359 | r9360 | |
| 378 | 388 | UINT8 ext; |
| 379 | 389 | UINT8 ctrl; |
| 380 | 390 | }segacd_cdd; |
| 391 | static void segacd_mark_tiles_dirty(running_machine* machine, int offset); |
| 381 | 392 | |
| 382 | 393 | #ifdef UNUSED_FUNCTION |
| 383 | 394 | /* taken from segaic16.c */ |
| r9359 | r9360 | |
| 3809 | 3820 | |
| 3810 | 3821 | static UINT16* segacd_4meg_prgram; // pointer to SubCPU PrgRAM |
| 3811 | 3822 | static UINT16 segacd_hint_register; |
| 3823 | static UINT16 segacd_imagebuffer_vdot_size; |
| 3812 | 3824 | |
| 3813 | 3825 | static UINT16 a12000_halt_reset_reg = 0x0000; |
| 3826 | int segacd_conversion_active = 0; |
| 3827 | static UINT16 segacd_stampmap_base_address; |
| 3828 | static tilemap_t *segacd_stampmap[4]; |
| 3829 | static void segacd_mark_stampmaps_dirty(void); |
| 3814 | 3830 | |
| 3831 | |
| 3815 | 3832 | static WRITE16_HANDLER( scd_a12000_halt_reset_w ) |
| 3816 | 3833 | { |
| 3817 | 3834 | COMBINE_DATA(&a12000_halt_reset_reg); |
| r9359 | r9360 | |
| 3870 | 3887 | static int segacd_maincpu_has_ram_access = 0; |
| 3871 | 3888 | static int segacd_4meg_prgbank = 0; // which bank the MainCPU can see of the SubCPU PrgRAM |
| 3872 | 3889 | static int segacd_memory_priority_mode = 0; |
| 3890 | static int segacd_stampsize; |
| 3873 | 3891 | |
| 3874 | 3892 | |
| 3875 | 3893 | static READ16_HANDLER( scd_a12002_memory_mode_r ) |
| r9359 | r9360 | |
| 4112 | 4130 | static int segacd_cdc_regaddress; |
| 4113 | 4131 | static int segacd_cdc_destination_device; |
| 4114 | 4132 | static UINT8 segacd_cdc_registers[0x10]; |
| 4115 | | int segacd_conversion_active = 0; |
| 4116 | 4133 | |
| 4134 | |
| 4117 | 4135 | static WRITE16_HANDLER( segacd_cdc_mode_address_w ) |
| 4118 | 4136 | { |
| 4119 | 4137 | if (ACCESSING_BITS_0_7) |
| r9359 | r9360 | |
| 4234 | 4252 | { |
| 4235 | 4253 | // is this correct? |
| 4236 | 4254 | if (segacd_maincpu_has_ram_access) |
| 4255 | { |
| 4237 | 4256 | COMBINE_DATA(&segacd_dataram[offset]); |
| 4257 | segacd_mark_tiles_dirty(space->machine, offset); |
| 4258 | } |
| 4238 | 4259 | else |
| 4239 | 4260 | { |
| 4240 | 4261 | printf("Illegal: segacd_main_dataram_part1_w in mode 0 without permission\n"); |
| r9359 | r9360 | |
| 4287 | 4308 | } |
| 4288 | 4309 | |
| 4289 | 4310 | |
| 4311 | // the tiles in RAM are 8x8 tiles |
| 4312 | // they are referenced in the cell look-up map as either 16x16 or 32x32 tiles (made of 4 / 16 8x8 tiles) |
| 4290 | 4313 | |
| 4314 | #define SEGACD_BYTES_PER_TILE16 (128) |
| 4315 | #define SEGACD_BYTES_PER_TILE32 (512) |
| 4316 | |
| 4317 | #define SEGACD_NUM_TILES16 (0x40000/SEGACD_BYTES_PER_TILE16) |
| 4318 | #define SEGACD_NUM_TILES32 (0x40000/SEGACD_BYTES_PER_TILE32) |
| 4319 | |
| 4320 | /* |
| 4321 | static const gfx_layout sega_8x8_layout = |
| 4322 | { |
| 4323 | 8,8, |
| 4324 | SEGACD_NUM_TILES16, |
| 4325 | 4, |
| 4326 | { 0,1,2,3 }, |
| 4327 | { 8,12,0,4,24,28,16,20 }, |
| 4328 | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, |
| 4329 | 8*32 |
| 4330 | }; |
| 4331 | */ |
| 4332 | |
| 4333 | /* also create pre-rotated versions.. - it might still be possible to use these decodes with our own copying routines */ |
| 4334 | |
| 4335 | |
| 4336 | #define _16x16_SEQUENCE_1 { 8,12,0,4,24,28,16,20, 512+8, 512+12, 512+0, 512+4, 512+24, 512+28, 512+16, 512+20 }, |
| 4337 | #define _16x16_SEQUENCE_1_FLIP { 512+20,512+16,512+28,512+24,512+4,512+0, 512+12,512+8, 20,16,28,24,4,0,12,8 }, |
| 4338 | |
| 4339 | #define _16x16_SEQUENCE_2 { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 8*32, 9*32,10*32,11*32,12*32,13*32,14*32,15*32 }, |
| 4340 | #define _16x16_SEQUENCE_2_FLIP { 16*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32, 8*32, 7*32, 6*32, 5*32, 4*32, 3*32, 2*32, 1*32, 0*32 }, |
| 4341 | |
| 4342 | |
| 4343 | #define _16x16_START \ |
| 4344 | { \ |
| 4345 | 16,16, \ |
| 4346 | SEGACD_NUM_TILES16, \ |
| 4347 | 4, \ |
| 4348 | { 0,1,2,3 }, \ |
| 4349 | |
| 4350 | #define _16x16_END \ |
| 4351 | 8*128 \ |
| 4352 | }; \ |
| 4353 | |
| 4354 | #define _32x32_START \ |
| 4355 | { \ |
| 4356 | 32,32, \ |
| 4357 | SEGACD_NUM_TILES32, \ |
| 4358 | 4, \ |
| 4359 | { 0,1,2,3 }, \ |
| 4360 | |
| 4361 | |
| 4362 | #define _32x32_END \ |
| 4363 | 8*512 \ |
| 4364 | }; \ |
| 4365 | |
| 4366 | |
| 4367 | |
| 4368 | #define _32x32_SEQUENCE_1 \ |
| 4369 | { 8,12,0,4,24,28,16,20, \ |
| 4370 | 1024+8, 1024+12, 1024+0, 1024+4, 1024+24, 1024+28, 1024+16, 1024+20, \ |
| 4371 | 2048+8, 2048+12, 2048+0, 2048+4, 2048+24, 2048+28, 2048+16, 2048+20, \ |
| 4372 | 3072+8, 3072+12, 3072+0, 3072+4, 3072+24, 3072+28, 3072+16, 3072+20 \ |
| 4373 | }, \ |
| 4374 | |
| 4375 | #define _32x32_SEQUENCE_1_FLIP \ |
| 4376 | { 3072+20, 3072+16, 3072+28, 3072+24, 3072+4, 3072+0, 3072+12, 3072+8, \ |
| 4377 | 2048+20, 2048+16, 2048+28, 2048+24, 2048+4, 2048+0, 2048+12, 2048+8, \ |
| 4378 | 1024+20, 1024+16, 1024+28, 1024+24, 1024+4, 1024+0, 1024+12, 1024+8, \ |
| 4379 | 20, 16, 28, 24, 4, 0, 12, 8}, \ |
| 4380 | |
| 4381 | |
| 4382 | #define _32x32_SEQUENCE_2 \ |
| 4383 | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, \ |
| 4384 | 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32, \ |
| 4385 | 16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32, \ |
| 4386 | 24*32,25*32, 26*32, 27*32, 28*32, 29*32, 30*32, 31*32}, \ |
| 4387 | |
| 4388 | #define _32x32_SEQUENCE_2_FLIP \ |
| 4389 | { 31*32, 30*32, 29*32, 28*32, 27*32, 26*32, 25*32, 24*32, \ |
| 4390 | 23*32, 22*32, 21*32, 20*32, 19*32, 18*32, 17*32, 16*32, \ |
| 4391 | 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32 , 8*32 , \ |
| 4392 | 7*32 , 6*32 , 5*32 , 4*32 , 3*32 , 2*32 , 1*32 , 0*32}, \ |
| 4393 | |
| 4394 | |
| 4395 | /* 16x16 decodes */ |
| 4396 | static const gfx_layout sega_16x16_r00_f0_layout = |
| 4397 | _16x16_START |
| 4398 | _16x16_SEQUENCE_1 |
| 4399 | _16x16_SEQUENCE_2 |
| 4400 | _16x16_END |
| 4401 | |
| 4402 | static const gfx_layout sega_16x16_r01_f0_layout = |
| 4403 | _16x16_START |
| 4404 | _16x16_SEQUENCE_2 |
| 4405 | _16x16_SEQUENCE_1_FLIP |
| 4406 | _16x16_END |
| 4407 | |
| 4408 | static const gfx_layout sega_16x16_r10_f0_layout = |
| 4409 | _16x16_START |
| 4410 | _16x16_SEQUENCE_1_FLIP |
| 4411 | _16x16_SEQUENCE_2_FLIP |
| 4412 | _16x16_END |
| 4413 | |
| 4414 | static const gfx_layout sega_16x16_r11_f0_layout = |
| 4415 | _16x16_START |
| 4416 | _16x16_SEQUENCE_2_FLIP |
| 4417 | _16x16_SEQUENCE_1 |
| 4418 | _16x16_END |
| 4419 | |
| 4420 | static const gfx_layout sega_16x16_r00_f1_layout = |
| 4421 | _16x16_START |
| 4422 | _16x16_SEQUENCE_1_FLIP |
| 4423 | _16x16_SEQUENCE_2 |
| 4424 | _16x16_END |
| 4425 | |
| 4426 | static const gfx_layout sega_16x16_r01_f1_layout = |
| 4427 | _16x16_START |
| 4428 | _16x16_SEQUENCE_2 |
| 4429 | _16x16_SEQUENCE_1 |
| 4430 | _16x16_END |
| 4431 | |
| 4432 | static const gfx_layout sega_16x16_r10_f1_layout = |
| 4433 | _16x16_START |
| 4434 | _16x16_SEQUENCE_1 |
| 4435 | _16x16_SEQUENCE_2_FLIP |
| 4436 | _16x16_END |
| 4437 | |
| 4438 | static const gfx_layout sega_16x16_r11_f1_layout = |
| 4439 | _16x16_START |
| 4440 | _16x16_SEQUENCE_2_FLIP |
| 4441 | _16x16_SEQUENCE_1_FLIP |
| 4442 | _16x16_END |
| 4443 | |
| 4444 | /* 32x32 decodes */ |
| 4445 | static const gfx_layout sega_32x32_r00_f0_layout = |
| 4446 | _32x32_START |
| 4447 | _32x32_SEQUENCE_1 |
| 4448 | _32x32_SEQUENCE_2 |
| 4449 | _32x32_END |
| 4450 | |
| 4451 | static const gfx_layout sega_32x32_r01_f0_layout = |
| 4452 | _32x32_START |
| 4453 | _32x32_SEQUENCE_2 |
| 4454 | _32x32_SEQUENCE_1_FLIP |
| 4455 | _32x32_END |
| 4456 | |
| 4457 | static const gfx_layout sega_32x32_r10_f0_layout = |
| 4458 | _32x32_START |
| 4459 | _32x32_SEQUENCE_1_FLIP |
| 4460 | _32x32_SEQUENCE_2_FLIP |
| 4461 | _32x32_END |
| 4462 | |
| 4463 | static const gfx_layout sega_32x32_r11_f0_layout = |
| 4464 | _32x32_START |
| 4465 | _32x32_SEQUENCE_2_FLIP |
| 4466 | _32x32_SEQUENCE_1 |
| 4467 | _32x32_END |
| 4468 | |
| 4469 | static const gfx_layout sega_32x32_r00_f1_layout = |
| 4470 | _32x32_START |
| 4471 | _32x32_SEQUENCE_1_FLIP |
| 4472 | _32x32_SEQUENCE_2 |
| 4473 | _32x32_END |
| 4474 | |
| 4475 | static const gfx_layout sega_32x32_r01_f1_layout = |
| 4476 | _32x32_START |
| 4477 | _32x32_SEQUENCE_2 |
| 4478 | _32x32_SEQUENCE_1 |
| 4479 | _32x32_END |
| 4480 | |
| 4481 | static const gfx_layout sega_32x32_r10_f1_layout = |
| 4482 | _32x32_START |
| 4483 | _32x32_SEQUENCE_1 |
| 4484 | _32x32_SEQUENCE_2_FLIP |
| 4485 | _32x32_END |
| 4486 | |
| 4487 | static const gfx_layout sega_32x32_r11_f1_layout = |
| 4488 | _32x32_START |
| 4489 | _32x32_SEQUENCE_2_FLIP |
| 4490 | _32x32_SEQUENCE_1_FLIP |
| 4491 | _32x32_END |
| 4492 | |
| 4493 | |
| 4494 | static void segacd_mark_tiles_dirty(running_machine* machine, int offset) |
| 4495 | { |
| 4496 | gfx_element_mark_dirty(machine->gfx[0], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4497 | gfx_element_mark_dirty(machine->gfx[1], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4498 | gfx_element_mark_dirty(machine->gfx[2], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4499 | gfx_element_mark_dirty(machine->gfx[3], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4500 | gfx_element_mark_dirty(machine->gfx[4], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4501 | gfx_element_mark_dirty(machine->gfx[5], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4502 | gfx_element_mark_dirty(machine->gfx[6], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4503 | gfx_element_mark_dirty(machine->gfx[7], (offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 4504 | |
| 4505 | gfx_element_mark_dirty(machine->gfx[8], (offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4506 | gfx_element_mark_dirty(machine->gfx[9], (offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4507 | gfx_element_mark_dirty(machine->gfx[10],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4508 | gfx_element_mark_dirty(machine->gfx[11],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4509 | gfx_element_mark_dirty(machine->gfx[12],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4510 | gfx_element_mark_dirty(machine->gfx[13],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4511 | gfx_element_mark_dirty(machine->gfx[14],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4512 | gfx_element_mark_dirty(machine->gfx[15],(offset*2)/(SEGACD_BYTES_PER_TILE32)); |
| 4513 | } |
| 4514 | |
| 4515 | // mame specific.. map registers to which tilemap cache we use |
| 4516 | static int segacd_get_active_stampmap_tilemap(void) |
| 4517 | { |
| 4518 | return (segacd_stampsize & 0x6)>>1; |
| 4519 | } |
| 4520 | |
| 4521 | static void segacd_mark_stampmaps_dirty(void) |
| 4522 | { |
| 4523 | tilemap_mark_all_tiles_dirty(segacd_stampmap[segacd_get_active_stampmap_tilemap()]); |
| 4524 | |
| 4525 | //tilemap_mark_all_tiles_dirty(segacd_stampmap[0]); |
| 4526 | //tilemap_mark_all_tiles_dirty(segacd_stampmap[1]); |
| 4527 | //tilemap_mark_all_tiles_dirty(segacd_stampmap[2]); |
| 4528 | //tilemap_mark_all_tiles_dirty(segacd_stampmap[3]); |
| 4529 | } |
| 4530 | |
| 4531 | static TILE_GET_INFO( get_stampmap_16x16_1x1_tile_info ) |
| 4532 | { |
| 4533 | int tile_region = 0; // 16x16 tiles |
| 4534 | int tile_base = (segacd_stampmap_base_address & 0xff80) * 4; |
| 4535 | |
| 4536 | int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff]; |
| 4537 | int tileno = tiledat & 0x07ff; |
| 4538 | int xflip = tiledat & 0x8000; |
| 4539 | int roll = (tiledat & 0x6000)>>13; |
| 4540 | |
| 4541 | if (xflip) tile_region += 4; |
| 4542 | tile_region+=roll; |
| 4543 | |
| 4544 | SET_TILE_INFO(tile_region, tileno, 0, 0); |
| 4545 | } |
| 4546 | |
| 4547 | static TILE_GET_INFO( get_stampmap_16x16_16x16_tile_info ) |
| 4548 | { |
| 4549 | int tile_region = 0; // 16x16 tiles |
| 4550 | int tile_base = (0x8000) * 4; // fixed address in this mode |
| 4551 | |
| 4552 | int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff]; |
| 4553 | int tileno = tiledat & 0x07ff; |
| 4554 | int xflip = tiledat & 0x8000; |
| 4555 | int roll = (tiledat & 0x6000)>>13; |
| 4556 | |
| 4557 | if (xflip) tile_region += 4; |
| 4558 | tile_region+=roll; |
| 4559 | |
| 4560 | SET_TILE_INFO(tile_region, tileno, 0, 0); |
| 4561 | } |
| 4562 | |
| 4563 | static TILE_GET_INFO( get_stampmap_32x32_1x1_tile_info ) |
| 4564 | { |
| 4565 | int tile_region = 8; // 32x32 tiles |
| 4566 | int tile_base = (segacd_stampmap_base_address & 0xffe0) * 4; |
| 4567 | |
| 4568 | int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff]; |
| 4569 | int tileno = (tiledat & 0x07fc)>>2; |
| 4570 | int xflip = tiledat & 0x8000; |
| 4571 | int roll = (tiledat & 0x6000)>>13; |
| 4572 | |
| 4573 | if (xflip) tile_region += 4; |
| 4574 | tile_region+=roll; |
| 4575 | |
| 4576 | SET_TILE_INFO(tile_region, tileno, 0, 0); |
| 4577 | } |
| 4578 | |
| 4579 | static TILE_GET_INFO( get_stampmap_32x32_16x16_tile_info ) |
| 4580 | { |
| 4581 | int tile_region = 8; // 32x32 tiles |
| 4582 | int tile_base = (segacd_stampmap_base_address & 0xe000) * 4; |
| 4583 | |
| 4584 | int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff]; |
| 4585 | int tileno = (tiledat & 0x07fc)>>2; |
| 4586 | int xflip = tiledat & 0x8000; |
| 4587 | int roll = (tiledat & 0x6000)>>13; |
| 4588 | |
| 4589 | if (xflip) tile_region += 4; |
| 4590 | tile_region+=roll; |
| 4591 | |
| 4592 | SET_TILE_INFO(tile_region, tileno, 0, 0); |
| 4593 | } |
| 4594 | |
| 4595 | |
| 4596 | |
| 4291 | 4597 | /* main CPU map set up in INIT */ |
| 4292 | 4598 | void segacd_init_main_cpu( running_machine* machine ) |
| 4293 | 4599 | { |
| r9359 | r9360 | |
| 4323 | 4629 | segacd_gfx_conversion_timer = timer_alloc(machine, segacd_gfx_conversion_timer_callback, 0); |
| 4324 | 4630 | timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime_never, 0); |
| 4325 | 4631 | |
| 4632 | |
| 4633 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 4634 | machine->gfx[0] = gfx_element_alloc(machine, &sega_16x16_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4635 | machine->gfx[1] = gfx_element_alloc(machine, &sega_16x16_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4636 | machine->gfx[2] = gfx_element_alloc(machine, &sega_16x16_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4637 | machine->gfx[3] = gfx_element_alloc(machine, &sega_16x16_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4638 | machine->gfx[4] = gfx_element_alloc(machine, &sega_16x16_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4639 | machine->gfx[5] = gfx_element_alloc(machine, &sega_16x16_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4640 | machine->gfx[6] = gfx_element_alloc(machine, &sega_16x16_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4641 | machine->gfx[7] = gfx_element_alloc(machine, &sega_16x16_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4642 | |
| 4643 | machine->gfx[8] = gfx_element_alloc(machine, &sega_32x32_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4644 | machine->gfx[9] = gfx_element_alloc(machine, &sega_32x32_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4645 | machine->gfx[10]= gfx_element_alloc(machine, &sega_32x32_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4646 | machine->gfx[11]= gfx_element_alloc(machine, &sega_32x32_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4647 | machine->gfx[12]= gfx_element_alloc(machine, &sega_32x32_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4648 | machine->gfx[13]= gfx_element_alloc(machine, &sega_32x32_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4649 | machine->gfx[14]= gfx_element_alloc(machine, &sega_32x32_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4650 | machine->gfx[15]= gfx_element_alloc(machine, &sega_32x32_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4651 | |
| 4652 | /* as a temporary measure we use the MAME tilemaps, this is hideously inefficient as we have to mark the active one as |
| 4653 | dirty before each operation due to the RAM based tiles. For the larger tilemaps this means we have to re-render a 4096x4096 |
| 4654 | bitmap to the tilemap cache on each blit operation just to copy the few needed tiles out of it, needless to say, this is SLOW. |
| 4655 | Eventually the tilemaps will be replaced with a get_pixel function which will perform all the needed lookups on a per-pixel |
| 4656 | basis instead of re-rendering the whole thing */ |
| 4657 | segacd_stampmap[0] = tilemap_create(machine, get_stampmap_16x16_1x1_tile_info, tilemap_scan_rows, 16, 16, 16, 16); |
| 4658 | segacd_stampmap[1] = tilemap_create(machine, get_stampmap_32x32_1x1_tile_info, tilemap_scan_rows, 32, 32, 8, 8); |
| 4659 | segacd_stampmap[2] = tilemap_create(machine, get_stampmap_16x16_16x16_tile_info, tilemap_scan_rows, 16, 16, 256, 256); // 128kb! |
| 4660 | segacd_stampmap[3] = tilemap_create(machine, get_stampmap_32x32_16x16_tile_info, tilemap_scan_rows, 32, 32, 128, 128); // 32kb! |
| 4326 | 4661 | } |
| 4327 | 4662 | |
| 4663 | |
| 4664 | |
| 4328 | 4665 | static MACHINE_RESET( segacd ) |
| 4329 | 4666 | { |
| 4330 | 4667 | int i; |
| r9359 | r9360 | |
| 4414 | 4751 | { |
| 4415 | 4752 | // is this correct? |
| 4416 | 4753 | if (!segacd_maincpu_has_ram_access) |
| 4754 | { |
| 4417 | 4755 | COMBINE_DATA(&segacd_dataram[offset]); |
| 4756 | segacd_mark_tiles_dirty(space->machine, offset); |
| 4757 | } |
| 4418 | 4758 | else |
| 4419 | 4759 | { |
| 4420 | 4760 | printf("Illegal: segacd_sub_dataram_part1_w in mode 0 without permission\n"); |
| r9359 | r9360 | |
| 4598 | 4938 | } |
| 4599 | 4939 | } |
| 4600 | 4940 | |
| 4601 | | int segacd_stampsize; |
| 4602 | 4941 | |
| 4942 | |
| 4603 | 4943 | static READ16_HANDLER( segacd_stampsize_r ) |
| 4604 | 4944 | { |
| 4605 | 4945 | UINT16 retdata = 0x0000; |
| r9359 | r9360 | |
| 4648 | 4988 | } |
| 4649 | 4989 | |
| 4650 | 4990 | printf("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask); |
| 4991 | |
| 4992 | { |
| 4993 | int base = (data & 0xfffe) * 4; |
| 4651 | 4994 | |
| 4652 | | segacd_conversion_active = 1; |
| 4995 | printf("actual base = %06x\n", base + 0x80000); |
| 4653 | 4996 | |
| 4654 | | timer_adjust_oneshot(segacd_gfx_conversion_timer, ATTOTIME_IN_HZ(1), 0); |
| 4997 | // nasty nasty nasty |
| 4998 | segacd_mark_stampmaps_dirty(); |
| 4999 | |
| 5000 | segacd_conversion_active = 1; |
| 5001 | timer_adjust_oneshot(segacd_gfx_conversion_timer, ATTOTIME_IN_HZ(1), 0); |
| 5002 | |
| 5003 | |
| 5004 | int i; |
| 5005 | |
| 5006 | for (i=0;i<segacd_imagebuffer_vdot_size;i++) |
| 5007 | { |
| 5008 | int currbase = base + i * 0x8; |
| 5009 | UINT16 param1 = segacd_dataram[(currbase+0x0)>>1]; |
| 5010 | UINT16 param2 = segacd_dataram[(currbase+0x2)>>1]; |
| 5011 | UINT16 param3 = segacd_dataram[(currbase+0x4)>>1]; |
| 5012 | UINT16 param4 = segacd_dataram[(currbase+0x6)>>1]; |
| 5013 | |
| 5014 | |
| 5015 | printf("%06x: %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4); |
| 5016 | |
| 5017 | } |
| 5018 | |
| 5019 | { |
| 5020 | // not real code.. yet |
| 5021 | // should copy part of the stamp into the imagebuffer area using the rotation / zooming parameters given |
| 5022 | // (while we're using the MAME tilemaps that means, part of the tilemap cache into the ram buffer for the image) |
| 5023 | |
| 5024 | bitmap_t *srcbitmap = tilemap_get_pixmap(segacd_stampmap[segacd_get_active_stampmap_tilemap()]); |
| 5025 | UINT16* x; |
| 5026 | x = BITMAP_ADDR16(srcbitmap,10,10); |
| 5027 | UINT16 datax; |
| 5028 | datax = x[0]; |
| 5029 | |
| 5030 | } |
| 5031 | |
| 5032 | } |
| 5033 | |
| 4655 | 5034 | } |
| 4656 | 5035 | |
| 5036 | // actually just the low 8 bits? |
| 5037 | READ16_HANDLER( segacd_imagebuffer_vdot_size_r ) |
| 5038 | { |
| 5039 | return segacd_imagebuffer_vdot_size; |
| 5040 | } |
| 5041 | |
| 5042 | WRITE16_HANDLER( segacd_imagebuffer_vdot_size_w ) |
| 5043 | { |
| 5044 | printf("segacd_imagebuffer_vdot_size_w %04x %04x\n",data,mem_mask); |
| 5045 | COMBINE_DATA(&segacd_imagebuffer_vdot_size); |
| 5046 | } |
| 5047 | |
| 5048 | |
| 5049 | // basically the 'tilemap' base address, for the 16x16 / 32x32 source tiles |
| 5050 | static READ16_HANDLER( segacd_stampmap_base_address_r ) |
| 5051 | { |
| 5052 | // different bits are valid in different modes, but I'm guessing the register |
| 5053 | // always returns all the bits set, even if they're not used? |
| 5054 | return segacd_stampmap_base_address; |
| 5055 | |
| 5056 | } |
| 5057 | |
| 5058 | static WRITE16_HANDLER( segacd_stampmap_base_address_w ) |
| 5059 | { |
| 5060 | COMBINE_DATA(&segacd_stampmap_base_address); |
| 5061 | } |
| 5062 | |
| 4657 | 5063 | static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 4658 | 5064 | AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&segacd_4meg_prgram) |
| 4659 | 5065 | |
| r9359 | r9360 | |
| 4684 | 5090 | // AM_RANGE(0xff804e, 0xff804f) // Font bit |
| 4685 | 5091 | // AM_RANGE(0xff8050, 0xff8057) // Font data (read only) |
| 4686 | 5092 | AM_RANGE(0xff8058, 0xff8059) AM_READWRITE(segacd_stampsize_r, segacd_stampsize_w) // Stamp size |
| 4687 | | // AM_RANGE(0xff805a, 0xff805b) // Stamp map base address |
| 5093 | AM_RANGE(0xff805a, 0xff805b) AM_READWRITE(segacd_stampmap_base_address_r, segacd_stampmap_base_address_w) // Stamp map base address |
| 4688 | 5094 | // AM_RANGE(0xff805c, 0xff805d) // Image buffer V cell size |
| 4689 | 5095 | // AM_RANGE(0xff805e, 0xff805f) // Image buffer start address |
| 4690 | 5096 | // AM_RANGE(0xff8060, 0xff8061) // Image buffer offset |
| 4691 | 5097 | // AM_RANGE(0xff8062, 0xff8063) // Image buffer H dot size |
| 4692 | | // AM_RANGE(0xff8064, 0xff8065) // Image buffer V dot size |
| 5098 | AM_RANGE(0xff8064, 0xff8065) AM_READWRITE(segacd_imagebuffer_vdot_size_r, segacd_imagebuffer_vdot_size_w ) // Image buffer V dot size |
| 4693 | 5099 | AM_RANGE(0xff8066, 0xff8067) AM_WRITE(segacd_trace_vector_base_address_w)// Trace vector base address |
| 4694 | 5100 | // AM_RANGE(0xff8068, 0xff8069) // Subcode address |
| 4695 | 5101 | |
| r9359 | r9360 | |
| 7605 | 8011 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) |
| 7606 | 8012 | MACHINE_CONFIG_END |
| 7607 | 8013 | |
| 8014 | |
| 8015 | |
| 7608 | 8016 | MACHINE_CONFIG_DERIVED( genesis_scd, megadriv ) |
| 7609 | 8017 | |
| 7610 | 8018 | MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */ |