diff options
author | Angelo Salese <angelosa@users.noreply.github.com> | 2010-10-12 00:09:27 +0000 |
---|---|---|
committer | Angelo Salese <angelosa@users.noreply.github.com> | 2010-10-12 00:09:27 +0000 |
commit | d1bcf2c6b549cb2e46e92da48d5b0076c4c8c3ff (patch) | |
tree | 1d2204516fc7ab37705e4831fb94bb75c086cb8e /src/mame/drivers/megadriv.c | |
parent | 12fe16133b432b57d8708db5cee71bded09fc010 (diff) |
Daily work about Mega CD from MESS
Diffstat (limited to 'src/mame/drivers/megadriv.c')
-rw-r--r-- | src/mame/drivers/megadriv.c | 191 |
1 files changed, 171 insertions, 20 deletions
diff --git a/src/mame/drivers/megadriv.c b/src/mame/drivers/megadriv.c index a8bbd4ffd7f..368bcf97dec 100644 --- a/src/mame/drivers/megadriv.c +++ b/src/mame/drivers/megadriv.c @@ -259,6 +259,7 @@ a tilemap-like structure, from which data is copied) #include "emu.h" +#include "coreutil.h" #include "cpu/z80/z80.h" #include "sound/sn76496.h" #include "sound/2612intf.h" @@ -269,6 +270,8 @@ a tilemap-like structure, from which data is copied) #include "includes/megadriv.h" #include "cpu/sh2/sh2.h" #include "cpu/sh2/sh2comn.h" +#include "devices/chd_cd.h" +#include "sound/cdda.h" #define MEGADRIV_VDP_VRAM(address) megadrive_vdp_vram[(address)&0x7fff] @@ -388,6 +391,16 @@ static struct UINT8 ext; UINT8 ctrl; }segacd_cdd; +static struct +{ + UINT32 current_frame; + UINT32 end_frame; + UINT32 last_frame; + + cdrom_file *cd; + const cdrom_toc* toc; +}segacd; + static void segacd_mark_tiles_dirty(running_machine* machine, int offset); #ifdef UNUSED_FUNCTION @@ -843,6 +856,8 @@ static UINT16 vdp_get_word_from_68k_mem_default(running_machine *machine, UINT32 // note, the RV bit on 32x is important for this to work, because it causes a normal cart mapping - see tempo address_space *space68k = machine->device<legacy_cpu_device>("maincpu")->space(); + //printf("vdp_get_word_from_68k_mem_default %08x\n", source); + if (( source >= 0x000000 ) && ( source <= 0x3fffff )) { if (_svp_cpu != NULL) @@ -3825,6 +3840,8 @@ static UINT16 segacd_imagebuffer_vdot_size; static UINT16 a12000_halt_reset_reg = 0x0000; int segacd_conversion_active = 0; static UINT16 segacd_stampmap_base_address; +static UINT16 segacd_imagebuffer_start_address; +static UINT16 segacd_imagebuffer_offset; static tilemap_t *segacd_stampmap[4]; static void segacd_mark_stampmaps_dirty(void); @@ -4230,11 +4247,16 @@ static READ16_HANDLER( segacd_main_dataram_part1_r ) { // is this correct? if (segacd_maincpu_has_ram_access) + { + //printf("segacd_main_dataram_part1_r in mode 0 %08x %04x\n", offset*2, segacd_dataram[offset]); + return segacd_dataram[offset]; + + } else { printf("Illegal: segacd_main_dataram_part1_r in mode 0 without permission\n"); - return 0x0000; + return 0xffff; } } else if (segacd_ram_mode==1) @@ -4303,7 +4325,7 @@ static TIMER_CALLBACK( segacd_gfx_conversion_timer_callback ) if (segacd_irq_mask & 0x02) cputag_set_input_line(machine, "segacd_68k", 1, HOLD_LINE); - + segacd_conversion_active = 0; } @@ -4676,6 +4698,26 @@ static MACHINE_RESET( segacd ) } segacd_cdd_rx[9] = 0xf; // default checksum + + /* init cd-rom device */ + + { + running_device *device; + + device = machine->device("cdrom"); + if ( device ) + { + segacd.cd = mess_cd_get_cdrom_file(device); + if ( segacd.cd ) + { + segacd.toc = cdrom_get_toc( segacd.cd ); + cdda_set_cdrom( machine->device("cdda"), segacd.cd ); + segacd.last_frame = cdrom_get_track_start( segacd.cd, cdrom_get_last_track( segacd.cd ) - 1 ); + segacd.last_frame += segacd.toc->tracks[ cdrom_get_last_track( segacd.cd ) - 1 ].frames; + segacd.end_frame = segacd.last_frame; + } + } + } } @@ -4897,13 +4939,24 @@ static void segacd_cdd_get_status(running_machine *machine) { // ... + /*segacd_cdd.status = 0; + segacd_cdd.minute = 0; + segacd_cdd.seconds = 0; + segacd_cdd.frame = 0; + segacd_cdd.ext = 0;*/ + cdd_hock_irq(machine,1); } static void segacd_cdd_stop_all(running_machine *machine) { - // ... - segacd_cdd.ctrl |= 0x100; // set data bit + segacd_cdd.ctrl |= 0x100; + + segacd_cdd.status = 0; + segacd_cdd.minute = 0; + segacd_cdd.seconds = 0; + segacd_cdd.frame = 0; + segacd_cdd.ext = 0; //cdd_hock_irq(machine,1); // doesn't work? } @@ -4911,11 +4964,54 @@ static void segacd_cdd_stop_all(running_machine *machine) static void segacd_cdd_get_toc_info(running_machine *machine) { - segacd_cdd.status = ((segacd_cdd_tx[3] & 0xf) << 4) | (segacd_cdd.status & 0xf); + segacd_cdd.status = (segacd_cdd_tx[3] & 0xf) | (segacd_cdd.status & 0xf0); + + logerror("CDD: TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]); switch(segacd_cdd_tx[3] & 0xf) { - default: printf("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]); + case 0x3: //Get Total Length (in MSF) + if ( ! segacd.cd ) // no cd is present + { + segacd_cdd.status = (0) | (segacd_cdd.status & 0xf0); + segacd_cdd.minute = 0; + segacd_cdd.seconds = 0; + segacd_cdd.frame = 0; + } + else + { + UINT32 frame,msf; + + frame = segacd.toc->tracks[segacd.toc->numtrks-1].physframeofs; + frame += segacd.toc->tracks[segacd.toc->numtrks-1].frames; + msf = lba_to_msf( frame ); + + segacd_cdd.status = (0x3 & 0xf) | (segacd_cdd.status & 0xf0); + segacd_cdd.minute = ((msf >> 16) & 0xff); + segacd_cdd.seconds = ((msf >> 8) & 0xff); + segacd_cdd.frame = ((msf >> 0) & 0xff); + } + segacd_cdd.ext = 0; + cdd_hock_irq(machine,1); + return; + case 0x4: //Get First and Last Track Number + if ( ! segacd.cd ) // no cd is present + { + segacd_cdd.status = (0) | (segacd_cdd.status & 0xf0); + segacd_cdd.minute = 0; + segacd_cdd.seconds = 0; + } + else + { + segacd_cdd.status = (0x4 & 0xf) | (segacd_cdd.status & 0xf0); + segacd_cdd.minute = dec_2_bcd(1); + segacd_cdd.seconds = dec_2_bcd(segacd.toc->numtrks); + } + segacd_cdd.frame = 0; + segacd_cdd.ext = 0; + cdd_hock_irq(machine,1); + return; + //default: logerror("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]); } cdd_hock_irq(machine,1); @@ -4928,12 +5024,14 @@ static WRITE8_HANDLER( segacd_cdd_tx_w ) if(offset == 9) //execute the command when crc is sent (TODO: I wonder if we need to check if crc is valid. Plus obviously this shouldn't be instant) { + logerror("CDD: command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]); + switch(segacd_cdd_tx[0] & 0xf) { case 0x0: segacd_cdd_get_status(space->machine); break; case 0x1: segacd_cdd_stop_all(space->machine); break; case 0x2: segacd_cdd_get_toc_info(space->machine); break; - default: printf("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]); + //default: logerror("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]); } } } @@ -4972,7 +5070,7 @@ static WRITE16_HANDLER( segacd_stampsize_w ) } - + if (ACCESSING_BITS_8_15) { if (data&0xff00) printf(" unused bits (MSB) set in stampsize!\n"); @@ -4987,19 +5085,19 @@ WRITE16_HANDLER( segacd_trace_vector_base_address_w ) printf("ILLEGAL: segacd_trace_vector_base_address_w %04x %04x in mode 1!\n",data,mem_mask); } - printf("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask); - + logerror("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask); + { int base = (data & 0xfffe) * 4; - printf("actual base = %06x\n", base + 0x80000); + logerror("actual base = %06x\n", base + 0x80000); // nasty nasty nasty segacd_mark_stampmaps_dirty(); segacd_conversion_active = 1; timer_adjust_oneshot(segacd_gfx_conversion_timer, ATTOTIME_IN_HZ(1), 0); - + int i; @@ -5012,10 +5110,10 @@ WRITE16_HANDLER( segacd_trace_vector_base_address_w ) UINT16 param4 = segacd_dataram[(currbase+0x6)>>1]; - printf("%06x: %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4); + logerror("%06x: %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4); } - + { // not real code.. yet // should copy part of the stamp into the imagebuffer area using the rotation / zooming parameters given @@ -5025,8 +5123,21 @@ WRITE16_HANDLER( segacd_trace_vector_base_address_w ) UINT16* x; x = BITMAP_ADDR16(srcbitmap,10,10); UINT16 datax; - datax = x[0]; - + datax = x[0]; + + for (int i=0;i<0x100;i++) + { + int offsetx = ((segacd_imagebuffer_start_address&0xfff8)*2)+i; + + //printf("data write %08x\n", offsetx*2); + + + segacd_dataram[offsetx]=mame_rand(space->machine); + + segacd_mark_tiles_dirty(space->machine, offsetx); + } + + } } @@ -5056,10 +5167,39 @@ static READ16_HANDLER( segacd_stampmap_base_address_r ) } static WRITE16_HANDLER( segacd_stampmap_base_address_w ) -{ +{ // WORD ACCESS + + // low 3 bitsa aren't used, are they stored? COMBINE_DATA(&segacd_stampmap_base_address); } +// destination for 'rendering' the section of the tilemap(stampmap) requested +static READ16_HANDLER( segacd_imagebuffer_start_address_r ) +{ + return segacd_imagebuffer_start_address; +} + +static WRITE16_HANDLER( segacd_imagebuffer_start_address_w ) +{ + COMBINE_DATA(&segacd_imagebuffer_start_address); + + int base = (segacd_imagebuffer_start_address & 0xfffe) * 4; + + printf("segacd_imagebuffer_start_address_w %04x %04x (actual base = %06x)\n", data, segacd_imagebuffer_start_address, base); +} + +static READ16_HANDLER( segacd_imagebuffer_offset_r ) +{ + return segacd_imagebuffer_offset; +} + +static WRITE16_HANDLER( segacd_imagebuffer_offset_w ) +{ + COMBINE_DATA(&segacd_imagebuffer_offset); + printf("segacd_imagebuffer_offset_w %04x\n", segacd_imagebuffer_offset); +} + + static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&segacd_4meg_prgram) @@ -5092,8 +5232,8 @@ static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xff8058, 0xff8059) AM_READWRITE(segacd_stampsize_r, segacd_stampsize_w) // Stamp size AM_RANGE(0xff805a, 0xff805b) AM_READWRITE(segacd_stampmap_base_address_r, segacd_stampmap_base_address_w) // Stamp map base address // AM_RANGE(0xff805c, 0xff805d) // Image buffer V cell size -// AM_RANGE(0xff805e, 0xff805f) // Image buffer start address -// AM_RANGE(0xff8060, 0xff8061) // Image buffer offset + AM_RANGE(0xff805e, 0xff805f) AM_READWRITE(segacd_imagebuffer_start_address_r, segacd_imagebuffer_start_address_w) // Image buffer start address + AM_RANGE(0xff8060, 0xff8061) AM_READWRITE(segacd_imagebuffer_offset_r, segacd_imagebuffer_offset_w) // AM_RANGE(0xff8062, 0xff8063) // Image buffer H dot size AM_RANGE(0xff8064, 0xff8065) AM_READWRITE(segacd_imagebuffer_vdot_size_r, segacd_imagebuffer_vdot_size_w ) // Image buffer V dot size AM_RANGE(0xff8066, 0xff8067) AM_WRITE(segacd_trace_vector_base_address_w)// Trace vector base address @@ -8017,12 +8157,24 @@ MACHINE_CONFIG_DERIVED( genesis_scd, megadriv ) MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */ MDRV_CPU_PROGRAM_MAP(segacd_map) + + MDRV_SOUND_ADD( "cdda", CDDA, 0 ) + MDRV_SOUND_ROUTE( 0, "lspeaker", 1.00 ) + MDRV_SOUND_ROUTE( 1, "rspeaker", 1.00 ) + + MDRV_CDROM_ADD( "cdrom" ) MACHINE_CONFIG_END MACHINE_CONFIG_DERIVED( genesis_32x_scd, genesis_32x ) MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */ MDRV_CPU_PROGRAM_MAP(segacd_map) + + MDRV_SOUND_ADD( "cdda", CDDA, 0 ) + MDRV_SOUND_ROUTE( 0, "lspeaker", 1.00 ) + MDRV_SOUND_ROUTE( 1, "rspeaker", 1.00 ) + + MDRV_CDROM_ADD( "cdrom" ) MACHINE_CONFIG_END @@ -8098,7 +8250,6 @@ static void megadriv_init_common(running_machine *machine) printf("Sega CD secondary 68k cpu found '%s'\n", _segacd_68k_cpu->tag() ); sega_cd_connected = 1; segacd_init_main_cpu(machine); - } _svp_cpu = machine->device<cpu_device>("svp"); |