Previous 199869 Revisions Next

r21476 Thursday 28th February, 2013 at 00:58:59 UTC by Angelo Salese
Clean-ups
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21475r21476
1010   http://www.google.com/patents/US6141122
1111
1212    TODO:
13   - walk the dog
13   - Understand what the 0x400000c reads on SH-2 really do.
14   - Remove SH-2 watchdog hack, if we ever bother about it ...
1415   - improve sound emulation
15    - i8237 purpose is unknown, might even not be at the right place ...
16    - i8237 purpose is unknown (missing ROM for comms?).
1617   - verify zooming etc. our current algorithm is a bit ugly for text
1718
1819
19
2020=======================================================================================================
2121
2222Cool Riders
r21475r21476
277277
278278
279279#include "emu.h"
280#include "debugger.h"
281280#include "cpu/sh2/sh2.h"
282281#include "cpu/m68000/m68000.h"
283282#include "sound/scsp.h"
284#include "machine/am9517a.h"
285283#include "machine/nvram.h"
286284#include "rendlay.h"
287285
r21475r21476
342340   UINT32 m_clipvals[2][3];
343341   UINT8  m_clipblitterMode[2]; // hack
344342
345
346343   required_device<cpu_device> m_maincpu;
347344   required_device<cpu_device> m_subcpu;
348345   required_device<cpu_device> m_soundcpu;
r21475r21476
373370   bitmap_ind16 m_bg_bitmap;
374371   bitmap_ind16 m_bg_bitmap2;
375372
376
377373   bitmap_ind16 m_screen1_bitmap;
378374   bitmap_ind16 m_screen2_bitmap;
379375   int m_scsp_last_line;
r21475r21476
452448   static void *draw_object_threaded(void *param, int threadid);
453449   int m_usethreads;
454450
455
456
457451   struct cool_render_object
458452   {
459453      UINT8* indirect_tiles;
r21475r21476
476470   int m_listcount1;
477471   int m_listcount2;
478472
479
480
481
482
483473   // the decode cache mechansim is an optimization
484474   // we know all gfx are in ROM, and that calling the RLE decompression every time they're used is slow, so we cache the decoded tiles
485475   // and objects after they're used, for future re-use, quite handy with a driving game.
r21475r21476
515505
516506   };
517507
518   
519508   struct objcachemanager
520509   {
521510      int current_object;
r21475r21476
526515   };
527516
528517   objcachemanager decode[2];
529
530
531
532
533518};
534519
535520#define PRINT_BLIT_STUFF \
r21475r21476
567552   machine().primary_screen->register_screen_bitmap(m_bg_bitmap);
568553   machine().primary_screen->register_screen_bitmap(m_bg_bitmap2);
569554
570
571
572555   machine().primary_screen->register_screen_bitmap(m_screen1_bitmap);
573556   machine().primary_screen->register_screen_bitmap(m_screen2_bitmap);
574557
575558   machine().gfx[m_gfx_index] = auto_alloc(machine(), gfx_element(machine(), h1_tile_layout, m_h1_pcg, 8, 0));
576559}
577560
578// might be a page 'map / base' setup somewhere, but it's just used for ingame backgrounds
579/* 0x00000 - 0x1ffff = screen 1 */
580/* 0x20000 - 0x3ffff = screen 2 */
581/* 0x40000 - 0xfffff = ? */
582561/*
583562   vregs are setted up with one of DMA commands (see below)
584563   0x3e09b80 screen 1 base, 0x3e9bc0 screen 2 base
r21475r21476
590569   (everything else is unknown at current time)
591570*/
592571
593
594
595
596
597572#define COOLRIDERS_DRAWGFX_CORE(PIXEL_TYPE, COOL_PIXEL_OP)                               \
598573do {                                                                                    \
599574   do {                                                                                \
r21475r21476
790765
791766void coolridr_state::draw_bg_coolridr(bitmap_ind16 &bitmap, const rectangle &cliprect, int which)
792767{
793
794768   int bg_r,bg_g,bg_b;
795769
796
797
798
799
800770   if(m_pen_fill[which])
801771   {
802772#if 0
r21475r21476
811781      bg_g = (((m_pen_fill[which] >> 8) & 0x78) >> 2) | (((m_pen_fill[which] >> 8) & 0x80) >> 7);
812782      bg_b = (((m_pen_fill[which] >> 0) & 0x78) >> 2) | (((m_pen_fill[which] >> 0) & 0x80) >> 7);
813783      bitmap.fill( (bg_r<<10) | (bg_g << 5) | bg_b  ,cliprect);
814
815784   }
816785   else
817786   {
r21475r21476
837806
838807      bitmap.fill(VREG(0x3c),cliprect);
839808
840     
809
841810      UINT16 basey = scrolly>>4;
842811      for (int y=0;y<25;y++)
843812       {
r21475r21476
864833{
865834   if(m_rgb_ctrl[which].gradient)
866835   {
867      if( (m_rgb_ctrl[which].setting == 0x1240) || (m_rgb_ctrl[which].setting == 0x920) || (m_rgb_ctrl[which].setting == 0x800) )
836      if( (m_rgb_ctrl[which].setting == 0x1240) || (m_rgb_ctrl[which].setting == 0x920) || (m_rgb_ctrl[which].setting == 0x800) )
868837      {
869838      }
870839      else
r21475r21476
883852      if(m_rgb_ctrl[which].gradient)
884853      {
885854         /* fade-in / outs */
886         if(m_rgb_ctrl[which].setting == 0x1240)
855         if(m_rgb_ctrl[which].setting == 0x1240)
887856         {
888857            r -= m_rgb_ctrl[which].gradient;
889858            g -= m_rgb_ctrl[which].gradient;
r21475r21476
914883      m_fadedpals[i] = (r<<10|g<<5|b);
915884   }
916885
917
918
919886   if (which==0)
920887   {
921888      for (int y=0;y<384;y++)
r21475r21476
972939/* end video */
973940
974941
975
976
977
978942#define RLE_BLOCK(writeaddrxor) \
979943   /* skip the decoding if it's the same tile as last time! */ \
980944   if (!current_decoded) \
r21475r21476
13811345   //   b1colorNumber = space.machine().rand()&0xfff;
13821346   }
13831347
1384
1385
1386
13871348//   if(b1colorNumber > 0x60 || b2colorNumber)
13881349//      printf("%08x %08x\n",b1colorNumber,b2colorNumber);
13891350
r21475r21476
19541915      int hPosition = 0;
19551916
19561917
1957     
1918
19581919      if (!indirect_zoom_enable)
19591920      {
19601921
r21475r21476
19901951      {
19911952
19921953         int current_decoded = false;
1993         
1954
19941955         if (!indirect_tile_enable && size < DECODECACHE_NUMSPRITETILES)
19951956         {
19961957            tempshape = object->state->decode[screen].objcache[use_object].tiles[v*used_hCellCount + h].tempshape_multi;
r21475r21476
20281989            if (blit_rotate)
20291990            {
20301991               #define GET_PIX GET_PIX_ROTATED
2031               YXLOOP   
1992               YXLOOP
20321993                    #undef GET_PIX
20331994            }
20341995            else // no rotate
20351996            {
20361997               #define GET_PIX GET_PIX_NORMAL
2037               YXLOOP   
1998               YXLOOP
20381999                    #undef GET_PIX
20392000
20402001            }
r21475r21476
26092570
26102571            // copy our old buffer to the actual screen
26112572            copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites, 0, 0, 0, 0, visarea);
2612           
26132573
26142574
26152575
2576
26162577            //m_temp_bitmap_sprites2.fill(0xff000000, visarea);
26172578            // render the tilemap to the backbuffer, ready for having sprites drawn on it
26182579            draw_bg_coolridr(m_temp_bitmap_sprites, visarea, 0);
2619            // wipe the z-buffer ready for the sprites           
2580            // wipe the z-buffer ready for the sprites
26202581            /* m_zbuffer_bitmap.fill(0xffff, visarea); */
26212582            // almost certainly wrong
26222583            m_clipvals[0][0] = 0;
26232584            m_clipvals[0][1] = 0;
26242585            m_clipvals[0][2] = 0;
26252586            m_clipblitterMode[0] = 0xff;
2626         
2587
26272588            /* bubble sort, might be something better to use instead */
26282589            for (int pass = 0 ; pass < ( m_listcount1 - 1 ); pass++)
26292590            {
r21475r21476
26482609               {
26492610                  draw_object_threaded((void*)m_cool_render_object_list1[i],0);
26502611               }
2651            }   
2652   
2612            }
2613
26532614            m_listcount1 = 0;
2654         
26552615
2616
26562617         }
26572618         else if(m_blitterClearMode == 0x8c800000)
26582619         {
r21475r21476
26612622
26622623            // copy our old buffer to the actual screen
26632624            copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2, 0, 0, 0, 0, visarea);
2664           
26652625
26662626
26672627
2628
26682629            //m_temp_bitmap_sprites2.fill(0xff000000, visarea);
26692630            // render the tilemap to the backbuffer, ready for having sprites drawn on it
26702631            draw_bg_coolridr(m_temp_bitmap_sprites2, visarea, 1);
2671            // wipe the z-buffer ready for the sprites           
2632            // wipe the z-buffer ready for the sprites
26722633            /* m_zbuffer_bitmap2.fill(0xffff, visarea); */
26732634            // almost certainly wrong
26742635            m_clipvals[1][0] = 0;
26752636            m_clipvals[1][1] = 0;
26762637            m_clipvals[1][2] = 0;
26772638            m_clipblitterMode[1] = 0xff;
2678   
2639
26792640               /* bubble sort, might be something better to use instead */
26802641            for (int pass = 0 ; pass < ( m_listcount2 - 1 ); pass++)
26812642            {
r21475r21476
27002661               {
27012662                  draw_object_threaded((void*)m_cool_render_object_list2[i],0);
27022663               }
2703            }   
2704   
2664            }
2665
27052666            m_listcount2 = 0;
2706         
2667
27072668         }
27082669
27092670         //printf("frame\n");
r21475r21476
27192680
27202681READ32_MEMBER(coolridr_state::sysh1_unk_blit_r)
27212682{
2722//   if(offset == 0x0c/4) reads
2683//   if(offset == 0x0c/4) // TODO
27232684
27242685   return m_sysh1_txt_blit[offset];
27252686}
r21475r21476
27712732   do{
27722733      cmd = (m_framebuffer_vram[(0+dma_index)/4] & 0xfc000000) >> 24;
27732734
2774
27752735      switch(cmd)
27762736      {
27772737         case 0x00: /* end of list marker */
r21475r21476
28542814         case 0x44: /* screen 2 / */
28552815            m_rgb_ctrl[(cmd & 4) >> 2].setting = m_framebuffer_vram[(0+dma_index)/4] & 0xffffe0;
28562816            m_rgb_ctrl[(cmd & 4) >> 2].gradient = m_framebuffer_vram[(0+dma_index)/4] & 0x1f;
2857
2858
28592817            dma_index+=4;
28602818            break;
28612819         default:
r21475r21476
30463004   AM_RANGE(0x03200000, 0x0327ffff) AM_READWRITE16(h1_soundram2_r, h1_soundram2_w,0xffffffff) //AM_SHARE("soundram2")
30473005   AM_RANGE(0x03300000, 0x03300fff) AM_DEVREADWRITE16_LEGACY("scsp2", scsp_r, scsp_w, 0xffffffff)
30483006
3049//   AM_RANGE(0x04000000, 0x0400001f) AM_DEVREADWRITE8("i8237", am9517a_device, read, write, 0xffffffff)
30503007   AM_RANGE(0x04000000, 0x0400003f) AM_READWRITE(sysh1_sound_dma_r,sysh1_sound_dma_w) AM_SHARE("sound_dma")
3051//   AM_RANGE(0x04200000, 0x0420003f) AM_RAM /* hi-word for DMA? */
3008//   AM_RANGE(0x04200000, 0x0420003f) AM_RAM /* unknown */
30523009
30533010   AM_RANGE(0x05000000, 0x05000fff) AM_RAM
30543011   AM_RANGE(0x05200000, 0x052001ff) AM_RAM
r21475r21476
30733030WRITE8_MEMBER(coolridr_state::sound_to_sh1_w)
30743031{
30753032   sound_fifo = data;
3076//   sound_data = data;
3077//   printf("%02x sound\n",data);
30783033}
30793034
30803035static ADDRESS_MAP_START( system_h1_sound_map, AS_PROGRAM, 16, coolridr_state )
r21475r21476
34443399
34453400   if(scanline == 0)
34463401      m_maincpu->set_input_line(6, HOLD_LINE);
3447
34483402}
34493403
34503404TIMER_DEVICE_CALLBACK_MEMBER(coolridr_state::system_h1_sub)
34513405{
34523406   int scanline = param;
34533407
3454   /* 10: reads from 0x4000000 (sound irq) */
3455   /* 12: reads from inputs (so presumably V-Blank) */
3456   /* 14: tries to r/w to 0x62***** area (network irq?) */
3408   /* 0xa: reads from 0x4000000 (sound irq) */
3409   /* 0xc: reads from inputs (so presumably V-Blank) */
3410   /* 0xe: tries to r/w to 0x62***** area (network irq?) */
34573411
34583412   if(scanline == 384)
34593413      m_subcpu->set_input_line(0xc, HOLD_LINE);
r21475r21476
34763430
34773431   romoffset += (_20bitwordnum>>3)*2;
34783432
3479
3480
34813433   if (temp==0)
34823434   {
34833435      testvalue  = READ_COMPRESSED_ROM(0+inc);
r21475r21476
35873539
35883540void coolridr_state::machine_reset()
35893541{
3590//  machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
35913542   m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
35923543
3593
3594
3595//   memcpy(m_soundram, memregion("soundcpu")->base()+0x80000, 0x80000);
3596//  m_soundcpu->reset();
3597
35983544   m_usethreads = m_io_config->read()&1;
35993545}
36003546
3601#if 0
3602static I8237_INTERFACE( dmac_intf )
3603{
3604   DEVCB_NULL, //DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_dma_hrq_changed),
3605   DEVCB_NULL, //DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_tc_w),
3606   DEVCB_NULL, //DEVCB_DRIVER_MEMBER(coolridr_state, coolridr_dma_read_byte),
3607   DEVCB_NULL,//DEVCB_DRIVER_MEMBER(coolridr_state, coolridr_dma_write_byte),
3608   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
3609   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
3610   { DEVCB_NULL /*DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_dack0_w)*/,
3611      DEVCB_NULL/*DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_dack1_w)*/,
3612      DEVCB_NULL/*DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_dack2_w)*/,
3613      DEVCB_NULL/*DEVCB_DRIVER_LINE_MEMBER(coolridr_state, coolridr_dack3_w)*/ }
3614};
3615#endif
3616
36173547static void scsp_irq(device_t *device, int irq)
36183548{
36193549   coolridr_state *state = device->machine().driver_data<coolridr_state>();
r21475r21476
36823612   MCFG_CPU_PROGRAM_MAP(coolridr_submap)
36833613   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer2", coolridr_state, system_h1_sub, "lscreen", 0, 1)
36843614
3685//   MCFG_I8237_ADD("i8237", 16000000, dmac_intf)
36863615   MCFG_NVRAM_ADD_0FILL("nvram")
36873616
36883617   MCFG_GFXDECODE(coolridr)
r21475r21476
37883717{
37893718   offs_t pc = downcast<cpu_device *>(&space.device())->pc();
37903719
3791
37923720   if(pc == 0x6002cba || pc == 0x6002d42)
37933721      return 0;
37943722
r21475r21476
38053733{
38063734   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60d8894, 0x060d8897, read32_delegate(FUNC(coolridr_state::coolridr_hack2_r), this));
38073735
3808
38093736   sh2drc_set_options(machine().device("maincpu"), SH2DRC_FASTEST_OPTIONS);
38103737   sh2drc_set_options(machine().device("sub"), SH2DRC_FASTEST_OPTIONS);
38113738}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team