Previous 15994 Revisions Next

r9362 Monday 11th October, 2010 at 21:54:02 UTC by Angelo Salese
[Mega CD]: Basic CD-ROM loading (nothing yet works)
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9361r9362
259259
260260
261261#include "emu.h"
262#include "coreutil.h"
262263#include "cpu/z80/z80.h"
263264#include "sound/sn76496.h"
264265#include "sound/2612intf.h"
r9361r9362
269270#include "includes/megadriv.h"
270271#include "cpu/sh2/sh2.h"
271272#include "cpu/sh2/sh2comn.h"
273#include "devices/chd_cd.h"
274#include "sound/cdda.h"
272275
273276#define MEGADRIV_VDP_VRAM(address) megadrive_vdp_vram[(address)&0x7fff]
274277
r9361r9362
388391   UINT8 ext;
389392   UINT8 ctrl;
390393}segacd_cdd;
394static struct
395{
396   UINT32   current_frame;
397   UINT32   end_frame;
398   UINT32   last_frame;
399
400   cdrom_file   *cd;
401   const cdrom_toc*   toc;
402}segacd;
403
391404static void segacd_mark_tiles_dirty(running_machine* machine, int offset);
392405
393406#ifdef UNUSED_FUNCTION
r9361r9362
42384251         //printf("segacd_main_dataram_part1_r in mode 0 %08x %04x\n", offset*2, segacd_dataram[offset]);
42394252
42404253         return segacd_dataram[offset];
4241     
4254
42424255      }
42434256      else
42444257      {
r9361r9362
43124325
43134326   if (segacd_irq_mask & 0x02)
43144327      cputag_set_input_line(machine, "segacd_68k", 1, HOLD_LINE);
4315   
4328
43164329   segacd_conversion_active = 0;
43174330}
43184331
r9361r9362
46854698   }
46864699
46874700   segacd_cdd_rx[9] = 0xf; // default checksum
4701
4702   /* init cd-rom device */
4703
4704   {
4705      running_device *device;
4706
4707      device = machine->device("cdrom");
4708      if ( device )
4709      {
4710         segacd.cd = mess_cd_get_cdrom_file(device);
4711         if ( segacd.cd )
4712         {
4713            segacd.toc = cdrom_get_toc( segacd.cd );
4714            cdda_set_cdrom( machine->device("cdda"), segacd.cd );
4715            segacd.last_frame = cdrom_get_track_start( segacd.cd, cdrom_get_last_track( segacd.cd ) - 1 );
4716            segacd.last_frame += segacd.toc->tracks[ cdrom_get_last_track( segacd.cd ) - 1 ].frames;
4717            segacd.end_frame = segacd.last_frame;
4718         }
4719      }
4720   }
46884721}
46894722
46904723
r9361r9362
49064939{
49074940   // ...
49084941
4942   /*segacd_cdd.status = 0;
4943   segacd_cdd.minute = 0;
4944   segacd_cdd.seconds = 0;
4945   segacd_cdd.frame = 0;
4946   segacd_cdd.ext = 0;*/
4947
49094948   cdd_hock_irq(machine,1);
49104949}
49114950
49124951static void segacd_cdd_stop_all(running_machine *machine)
49134952{
4914   // ...
4915   segacd_cdd.ctrl |= 0x100; // set data bit
4953   segacd_cdd.ctrl |= 0x100;
49164954
4955   segacd_cdd.status = 0;
4956   segacd_cdd.minute = 0;
4957   segacd_cdd.seconds = 0;
4958   segacd_cdd.frame = 0;
4959   segacd_cdd.ext = 0;
4960
49174961   //cdd_hock_irq(machine,1); // doesn't work?
49184962}
49194963
49204964
49214965static void segacd_cdd_get_toc_info(running_machine *machine)
49224966{
4923   segacd_cdd.status = ((segacd_cdd_tx[3] & 0xf) << 4) | (segacd_cdd.status & 0xf);
4967   segacd_cdd.status = (segacd_cdd_tx[3] & 0xf) | (segacd_cdd.status & 0xf0);
49244968
4969   logerror("CDD: TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]);
4970
49254971   switch(segacd_cdd_tx[3] & 0xf)
49264972   {
4927      default: printf("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]);
4973      case 0x3: //Get Total Length (in MSF)
4974         if ( ! segacd.cd ) // no cd is present
4975         {
4976            segacd_cdd.status = (0) | (segacd_cdd.status & 0xf0);
4977            segacd_cdd.minute = 0;
4978            segacd_cdd.seconds = 0;
4979            segacd_cdd.frame = 0;
4980         }
4981         else
4982         {
4983            UINT32 frame,msf;
4984
4985            frame = segacd.toc->tracks[segacd.toc->numtrks-1].physframeofs;
4986            frame += segacd.toc->tracks[segacd.toc->numtrks-1].frames;
4987            msf = lba_to_msf( frame );
4988
4989            segacd_cdd.status = (0x3 & 0xf) | (segacd_cdd.status & 0xf0);
4990            segacd_cdd.minute = ((msf >> 16) & 0xff);
4991            segacd_cdd.seconds = ((msf >> 8) & 0xff);
4992            segacd_cdd.frame = ((msf >> 0) & 0xff);
4993         }
4994         segacd_cdd.ext = 0;
4995         cdd_hock_irq(machine,1);
4996         return;
4997      case 0x4: //Get First and Last Track Number
4998         if ( ! segacd.cd ) // no cd is present
4999         {
5000            segacd_cdd.status = (0) | (segacd_cdd.status & 0xf0);
5001            segacd_cdd.minute = 0;
5002            segacd_cdd.seconds = 0;
5003         }
5004         else
5005         {
5006            segacd_cdd.status = (0x4 & 0xf) | (segacd_cdd.status & 0xf0);
5007            segacd_cdd.minute = dec_2_bcd(1);
5008            segacd_cdd.seconds = dec_2_bcd(segacd.toc->numtrks);
5009         }
5010         segacd_cdd.frame = 0;
5011         segacd_cdd.ext = 0;
5012         cdd_hock_irq(machine,1);
5013         return;
5014      //default: logerror("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]);
49285015   }
49295016
49305017   cdd_hock_irq(machine,1);
r9361r9362
49375024
49385025   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)
49395026   {
5027      logerror("CDD: command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]);
5028
49405029      switch(segacd_cdd_tx[0] & 0xf)
49415030      {
49425031         case 0x0: segacd_cdd_get_status(space->machine); break;
49435032         case 0x1: segacd_cdd_stop_all(space->machine); break;
49445033         case 0x2: segacd_cdd_get_toc_info(space->machine); break;
4945         default: printf("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]);
5034         //default: logerror("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]);
49465035      }
49475036   }
49485037}
r9361r9362
49815070
49825071
49835072   }
4984   
5073
49855074   if (ACCESSING_BITS_8_15)
49865075   {
49875076      if (data&0xff00) printf("    unused bits (MSB) set in stampsize!\n");
r9361r9362
49975086   }
49985087
49995088   logerror("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask);
5000   
5089
50015090   {
50025091      int base = (data & 0xfffe) * 4;
50035092
r9361r9362
50085097
50095098      segacd_conversion_active = 1;
50105099      timer_adjust_oneshot(segacd_gfx_conversion_timer, ATTOTIME_IN_HZ(1), 0);
5011     
50125100
5101
50135102      int i;
50145103
50155104      for (i=0;i<segacd_imagebuffer_vdot_size;i++)
r9361r9362
50215110         UINT16 param4 = segacd_dataram[(currbase+0x6)>>1];
50225111
50235112
5024         logerror("%06x:  %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4);
5113         logerror("%06x:  %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4);
50255114
50265115      }
5027     
5116
50285117      {
50295118         // not real code.. yet
50305119         // should copy part of the stamp into the imagebuffer area using the rotation / zooming parameters given
r9361r9362
50345123         UINT16* x;
50355124         x = BITMAP_ADDR16(srcbitmap,10,10);
50365125         UINT16 datax;
5037         datax = x[0];
5038     
5126         datax = x[0];
5127
50395128         for (int i=0;i<0x100;i++)
50405129         {
50415130            int offsetx = ((segacd_imagebuffer_start_address&0xfff8)*2)+i;
r9361r9362
80688157
80698158   MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
80708159   MDRV_CPU_PROGRAM_MAP(segacd_map)
8160
8161   MDRV_SOUND_ADD( "cdda", CDDA, 0 )
8162   MDRV_SOUND_ROUTE( 0, "lspeaker", 1.00 )
8163   MDRV_SOUND_ROUTE( 1, "rspeaker", 1.00 )
8164
8165   MDRV_CDROM_ADD( "cdrom" )
80718166MACHINE_CONFIG_END
80728167
80738168MACHINE_CONFIG_DERIVED( genesis_32x_scd, genesis_32x )
80748169
80758170   MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
80768171   MDRV_CPU_PROGRAM_MAP(segacd_map)
8172
8173   MDRV_SOUND_ADD( "cdda", CDDA, 0 )
8174   MDRV_SOUND_ROUTE( 0, "lspeaker", 1.00 )
8175   MDRV_SOUND_ROUTE( 1, "rspeaker", 1.00 )
8176
8177   MDRV_CDROM_ADD( "cdrom" )
80778178MACHINE_CONFIG_END
80788179
80798180
r9361r9362
81498250      printf("Sega CD secondary 68k cpu found '%s'\n", _segacd_68k_cpu->tag() );
81508251      sega_cd_connected = 1;
81518252      segacd_init_main_cpu(machine);
8152
81538253   }
81548254
81558255   _svp_cpu = machine->device<cpu_device>("svp");

Previous 15994 Revisions Next


© 1998-2018 The MESS Team