Previous 15994 Revisions Next

r13015 Sunday 9th October, 2011 at 01:48:37 UTC by Robbbert
GAMECOM - moved base pointer into the driver state
[src/mess/drivers]gamecom.c
[src/mess/includes]gamecom.h
[src/mess/machine]gamecom.c
[src/mess/video]gamecom.c

src/mess/machine/gamecom.c
r13014r13015
11
2#include "emu.h"
32#include "includes/gamecom.h"
43
54
r13014r13015
3029{
3130   char bank[8];
3231   sprintf(bank,"bank%d",mmu);
33   if ( data < 0x20 )
32   if (data < 0x20)
3433   {
3534      /* select internal ROM bank */
3635      memory_set_bankptr( machine(), bank, machine().region("kernel")->base() + (data << 13) );
r13014r13015
4544
4645void gamecom_state::handle_stylus_press( int column )
4746{
48   UINT8 * RAM = machine().region("maincpu")->base();
4947   static const UINT16 row_data[17] = { 0x3FE, 0x3FD, 0x3FB, 0x3F7, 0x3EF, 0x3DF, 0x3BF, 0x37F, 0x2FF, 0x1FF };
5048
5149   if ( column == 0 )
r13014r13015
6462
6563   if ( m_stylus_x == column )
6664   {
67      RAM[SM8521_P0] = row_data[m_stylus_y];
68      RAM[SM8521_P1] = ( RAM[SM8521_P1] & 0xFC ) | ( ( row_data[m_stylus_y] >> 8 ) & 3 );
65      m_p_ram[SM8521_P0] = row_data[m_stylus_y];
66      m_p_ram[SM8521_P1] = ( m_p_ram[SM8521_P1] & 0xFC ) | ( ( row_data[m_stylus_y] >> 8 ) & 3 );
6967   }
7068   else
7169   {
72      RAM[SM8521_P0] = 0xFF;
73      RAM[SM8521_P1] = ( RAM[SM8521_P1] & 0xFC ) | 3;
70      m_p_ram[SM8521_P0] = 0xFF;
71      m_p_ram[SM8521_P1] = ( m_p_ram[SM8521_P1] & 0xFC ) | 3;
7472   }
7573}
7674
7775WRITE8_MEMBER( gamecom_state::gamecom_pio_w )
7876{
79   UINT8 * RAM = machine().region("maincpu")->base();
8077   offset += 0x14;
81   RAM[offset] = data;
78   m_p_ram[offset] = data;
8279   switch( offset )
8380   {
84   case SM8521_P2:      switch( ( RAM[SM8521_P1] << 8 ) | data )
81   case SM8521_P2:      switch( ( m_p_ram[SM8521_P1] << 8 ) | data )
8582            {
8683            case 0xFBFF:   /* column #0 */
8784                  /* P0 bit 0 cleared => 01 */
r13014r13015
143140                  /* P0 bit 7 cleared => 8B (button A) */
144141                  /* P1 bit 0 cleared => 8C (button B) */
145142                  /* P1 bit 1 cleared => 8D (button C) */
146               RAM[SM8521_P0] = input_port_read(machine(), "IN0");
147               RAM[SM8521_P1] = (RAM[SM8521_P1] & 0xFC) | ( input_port_read(machine(), "IN1") & 3 );
143               m_p_ram[SM8521_P0] = input_port_read(machine(), "IN0");
144               m_p_ram[SM8521_P1] = (m_p_ram[SM8521_P1] & 0xFC) | ( input_port_read(machine(), "IN1") & 3 );
148145               break;
149146            case 0xFFFF:   /* keys #2 */
150147                  /* P0 bit 0 cleared => 88 (power) */
r13014r13015
157154                  /* P0 bit 7 cleared => A0 */
158155                  /* P1 bit 0 cleared => A0 */
159156                  /* P1 bit 1 cleared => A0 */
160               RAM[SM8521_P0] = (RAM[SM8521_P0] & 0xFC) | ( input_port_read(machine(), "IN2") & 3 );
161               RAM[SM8521_P1] = 0xFF;
157               m_p_ram[SM8521_P0] = (m_p_ram[SM8521_P0] & 0xFC) | ( input_port_read(machine(), "IN2") & 3 );
158               m_p_ram[SM8521_P1] = 0xFF;
162159               break;
163160            }
164161            return;
r13014r13015
177174
178175READ8_MEMBER( gamecom_state::gamecom_pio_r )
179176{
180   UINT8 * RAM = machine().region("maincpu")->base();
181   return RAM[offset + 0x14];
177   return m_p_ram[offset + 0x14];
182178}
183179
184180READ8_MEMBER( gamecom_state::gamecom_internal_r )
185181{
186   UINT8 * RAM = machine().region("maincpu")->base();
187   return RAM[offset + 0x20];
182   return m_p_ram[offset + 0x20];
188183}
189184
190185WRITE8_MEMBER( gamecom_state::gamecom_internal_w )
191186{
192   UINT8 * RAM = machine().region("maincpu")->base();
193187   offset += 0x20;
194188   switch( offset )
195189   {
r13014r13015
220214      m_timer[0].enabled = data & 0x80;
221215      m_timer[0].state_limit = gamecom_timer_limit[data & 0x07];
222216      m_timer[0].state_count = 0;
223      RAM[SM8521_TM0D] = 0;
217      m_p_ram[SM8521_TM0D] = 0;
224218      break;
225219   case SM8521_TM1D:
226220      m_timer[1].check_value = data;
r13014r13015
229223      m_timer[1].enabled = data & 0x80;
230224      m_timer[1].state_limit = gamecom_timer_limit[data & 0x07];
231225      m_timer[1].state_count = 0;
232      RAM[SM8521_TM1D] = 0;
226      m_p_ram[SM8521_TM1D] = 0;
233227      break;
234228   case SM8521_CLKT:   /* bit 6-7 */
235229      if ( data & 0x80 )
r13014r13015
338332      logerror( "%X: Write to reserved address (0x%02X). Value written: 0x%02X\n", cpu_get_pc(m_maincpu), offset, data );
339333      break;
340334   }
341   RAM[offset] = data;
335   m_p_ram[offset] = data;
342336}
343337
344338
r13014r13015
362356
363357
364358   if ( state->m_dma.decrement_x || state->m_dma.decrement_y )
365   {
366359      logerror( "TODO: Decrement-x and decrement-y are not supported yet\n" );
367   }
360
368361   state->m_dma.width_x = RAM[SM8521_DMDX];
369362   state->m_dma.width_x_count = 0;
370363   state->m_dma.width_y = RAM[SM8521_DMDY];
r13014r13015
377370   state->m_dma.dest_x_current = state->m_dma.dest_x;
378371   state->m_dma.dest_y = RAM[SM8521_DMY2];
379372   state->m_dma.dest_width = ( RAM[SM8521_LCH] & 0x20 ) ? 50 : 40;
380   state->m_dma.palette[0] = ( RAM[SM8521_DMPL] & 0x03 );
381   state->m_dma.palette[1] = ( RAM[SM8521_DMPL] & 0x0C ) >> 2;
382   state->m_dma.palette[2] = ( RAM[SM8521_DMPL] & 0x30 ) >> 4;
383   state->m_dma.palette[3] = ( RAM[SM8521_DMPL] & 0xC0 ) >> 6;
373   state->m_dma.palette[0] = RAM[SM8521_DMPL] & 0x03;
374   state->m_dma.palette[1] = ( RAM[SM8521_DMPL] >> 2 ) & 3;
375   state->m_dma.palette[2] = ( RAM[SM8521_DMPL] >> 4 ) & 3;
376   state->m_dma.palette[3] = RAM[SM8521_DMPL] >> 6;
384377   state->m_dma.source_mask = 0x1FFF;
385378   state->m_dma.dest_mask = 0x1FFF;
386379//  logerror("DMA: width %Xx%X, source (%X,%X), dest (%X,%X), transfer_mode %X, banks %X \n", state->m_dma.width_x, state->m_dma.width_y, state->m_dma.source_x, state->m_dma.source_y, state->m_dma.dest_x, state->m_dma.dest_y, state->m_dma.transfer_mode, RAM[SM8521_DMVP] );
r13014r13015
398391      state->m_dma.source_width = 64;
399392      state->m_dma.source_mask = 0x3FFF;
400393      if ( RAM[SM8521_DMBR] < 16 )
401      {
402394         state->m_dma.source_bank = device->machine().region("kernel")->base() + (RAM[SM8521_DMBR] << 14);
403      }
404395      else
405      {
406         if (state->m_cartridge)
407            state->m_dma.source_bank = state->m_cartridge + (RAM[SM8521_DMBR] << 14);
408      }
396      if (state->m_cartridge)
397         state->m_dma.source_bank = state->m_cartridge + (RAM[SM8521_DMBR] << 14);
398
409399      state->m_dma.dest_bank = &state->m_p_videoram[(RAM[SM8521_DMVP] & 0x02) ? 0x2000 : 0x0000];
410400      break;
411401   case 0x04:
r13014r13015
443433         /* Read pixel data */
444434         switch ( state->m_dma.source_x_current & 0x03 )
445435         {
446         case 0x00: source_pixel = ( state->m_dma.source_bank[src_addr] & 0xC0 ) >> 6; break;
447         case 0x01: source_pixel = ( state->m_dma.source_bank[src_addr] & 0x30 ) >> 4; break;
448         case 0x02: source_pixel = ( state->m_dma.source_bank[src_addr] & 0x0C ) >> 2; break;
449         case 0x03: source_pixel = ( state->m_dma.source_bank[src_addr] & 0x03 );      break;
436         case 0x00: source_pixel = state->m_dma.source_bank[src_addr] >> 6; break;
437         case 0x01: source_pixel = ( state->m_dma.source_bank[src_addr] >> 4 ) & 3; break;
438         case 0x02: source_pixel = ( state->m_dma.source_bank[src_addr] >> 2 ) & 3; break;
439         case 0x03: source_pixel = state->m_dma.source_bank[src_addr] & 3;      break;
450440         }
451441
452442         if ( !state->m_dma.overwrite_mode && source_pixel == 0 )
453443         {
454444            switch ( state->m_dma.dest_x_current & 0x03 )
455445            {
456            case 0x00: dest_pixel = ( state->m_dma.dest_bank[dest_addr] & 0xC0 ) >> 6; break;
457            case 0x01: dest_pixel = ( state->m_dma.dest_bank[dest_addr] & 0x30 ) >> 4; break;
458            case 0x02: dest_pixel = ( state->m_dma.dest_bank[dest_addr] & 0x0C ) >> 2; break;
459            case 0x03: dest_pixel = ( state->m_dma.dest_bank[dest_addr] & 0x03 );      break;
446            case 0x00: dest_pixel = state->m_dma.dest_bank[dest_addr] >> 6; break;
447            case 0x01: dest_pixel = ( state->m_dma.dest_bank[dest_addr] >> 4 ) & 3; break;
448            case 0x02: dest_pixel = ( state->m_dma.dest_bank[dest_addr] >> 2 ) & 3; break;
449            case 0x03: dest_pixel = state->m_dma.dest_bank[dest_addr] & 3;      break;
460450            }
461451            source_pixel = dest_pixel;
462452         }
r13014r13015
486476         {
487477            state->m_dma.source_x_current--;
488478            if ( ( state->m_dma.source_x_current & 0x03 ) == 0x03 )
489            {
490479               state->m_dma.source_current--;
491            }
492480         }
493481         else
494482         {
495483            state->m_dma.source_x_current++;
496484            if ( ( state->m_dma.source_x_current & 0x03 ) == 0x00 )
497            {
498485               state->m_dma.source_current++;
499            }
500486         }
501487         state->m_dma.dest_x_current++;
502488         if ( ( state->m_dma.dest_x_current & 0x03 ) == 0x00 )
503         {
504489            state->m_dma.dest_current++;
505         }
506490      }
507491
508492      /* Advance a line */
r13014r13015
555539{
556540   gamecom_state *state = machine.driver_data<gamecom_state>();
557541   state->m_clock_timer = machine.scheduler().timer_alloc(FUNC(gamecom_clock_timer_callback));
542   state->m_p_ram = machine.region("maincpu")->base(); // required here because pio_w gets called before machine_reset
558543}
559544
560545DEVICE_IMAGE_LOAD( gamecom_cart1 )
src/mess/video/gamecom.c
r13014r13015
1#include "emu.h"
1
22#include "includes/gamecom.h"
33
44#define Y_PIXELS 200
55
66
7static TIMER_CALLBACK( gamecom_scanline ) {
7static TIMER_CALLBACK( gamecom_scanline )
8   {
89   gamecom_state *state = machine.driver_data<gamecom_state>();
9   UINT8 * RAM = machine.region("maincpu")->base();
1010   // draw line
11   if ( state->m_scanline == 0 ) {
12      state->m_base_address = ( RAM[SM8521_LCDC] & 0x40 ) ? 0x2000 : 0x0000;
13   }
14   if ( ~RAM[SM8521_LCDC] & 0x80 ) {
11   if ( state->m_scanline == 0 )
12      state->m_base_address = ( state->m_p_ram[SM8521_LCDC] & 0x40 ) ? 0x2000 : 0x0000;
13
14   if ( ~state->m_p_ram[SM8521_LCDC] & 0x80 )
15   {
1516      rectangle rec;
1617      rec.min_x = 0;
1718      rec.max_x = Y_PIXELS - 1;
1819      rec.min_y = rec.max_y = state->m_scanline;
1920      bitmap_fill( machine.generic.tmpbitmap, &rec , 0);
2021      return;
21   } else {
22   }
23   else
24   {
2225      UINT8 *line = &state->m_p_videoram[ state->m_base_address + 40 * state->m_scanline ];
2326      int   pal[4];
2427      int   i;
2528
26      switch( RAM[SM8521_LCDC] & 0x30 ) {
29      switch( state->m_p_ram[SM8521_LCDC] & 0x30 )
30      {
2731      case 0x00:
2832         pal[0] = 4;
2933         pal[1] = 3;
r13014r13015
4953         pal[3] = 0;
5054         break;
5155      }
52      for( i = 0; i < 40; i++ ) {
56      for( i = 0; i < 40; i++ )
57      {
5358         UINT8 p = line[i];
5459         *BITMAP_ADDR16(machine.generic.tmpbitmap, i * 4 + 0, state->m_scanline) = pal[ ( p >> 6 ) & 3 ];
5560         *BITMAP_ADDR16(machine.generic.tmpbitmap, i * 4 + 1, state->m_scanline) = pal[ ( p >> 4 ) & 3 ];
r13014r13015
6974   state->m_scanline_timer->adjust( machine.primary_screen->time_until_pos(0 ), 0, machine.primary_screen->scan_period() );
7075
7176}
72
src/mess/includes/gamecom.h
r13014r13015
1111#ifndef GAMECOM_H_
1212#define GAMECOM_H_
1313
14#include "emu.h"
1415#include "cpu/sm8500/sm8500.h"
1516#include "imagedev/cartslot.h"
1617#include "rendlay.h"
r13014r13015
218219   DECLARE_READ8_MEMBER( gamecom_pio_r );
219220   DECLARE_WRITE8_MEMBER( gamecom_internal_w );
220221   DECLARE_WRITE8_MEMBER( gamecom_pio_w );
222   UINT8 *m_p_ram;
221223   UINT8 *m_p_videoram;
222224   UINT8 *m_cartridge1;
223225   UINT8 *m_cartridge2;
src/mess/drivers/gamecom.c
r13014r13015
1616***************************************************************************/
1717#define ADDRESS_MAP_MODERN
1818
19#include "emu.h"
2019#include "includes/gamecom.h"
2120
2221static ADDRESS_MAP_START(gamecom_mem_map, AS_PROGRAM, 8, gamecom_state)
r13014r13015
152151
153152/*    YEAR  NAME     PARENT COMPAT MACHINE  INPUT    INIT    COMPANY  FULLNAME */
154153CONS( 1997, gamecom, 0,     0,     gamecom, gamecom, gamecom,"Tiger", "Game.com", GAME_NOT_WORKING | GAME_NO_SOUND)
155
156

Previous 15994 Revisions Next


© 1998-2018 The MESS Team