Previous 199869 Revisions Next

r25425 Wednesday 25th September, 2013 at 19:25:52 UTC by hap
protection emulation should be crashproof now
[src/mame/drivers]sidepckt.c
[src/mame/includes]sidepckt.h
[src/mame/video]sidepckt.c

trunk/src/mame/includes/sidepckt.h
r25424r25425
1/******************************************************************************
2
3    Data East Side Pocket hardware
4
5******************************************************************************/
6
17class sidepckt_state : public driver_device
28{
39public:
r25424r25425
39   sidepckt_state(const machine_config &mconfig, device_type type, const char *tag)
410      : driver_device(mconfig, type, tag),
11      m_maincpu(*this, "maincpu"),
12      m_audiocpu(*this, "audiocpu"),
513      m_videoram(*this, "videoram"),
614      m_colorram(*this, "colorram"),
7      m_spriteram(*this, "spriteram"),
8      m_maincpu(*this, "maincpu"),
9      m_audiocpu(*this, "audiocpu")  { }
15      m_spriteram(*this, "spriteram")
16   { }
1017
1118   tilemap_t *m_bg_tilemap;
19   required_device<cpu_device> m_maincpu;
20   required_device<cpu_device> m_audiocpu;
1221   required_shared_ptr<UINT8> m_videoram;
1322   required_shared_ptr<UINT8> m_colorram;
1423   required_shared_ptr<UINT8> m_spriteram;
15   int m_i8751_return;
16   int m_current_ptr;
17   int m_current_table;
18   int m_in_math;
19   int m_math_param;
24
25   const UINT8* m_prot_table[3];
26   UINT8 m_i8751_return;
27   UINT8 m_current_ptr;
28   UINT8 m_current_table;
29   UINT8 m_in_math;
30   UINT8 m_math_param;
31
2032   DECLARE_WRITE8_MEMBER(sound_cpu_command_w);
2133   DECLARE_READ8_MEMBER(sidepckt_i8751_r);
r25424r25425
2638   DECLARE_WRITE8_MEMBER(sidepckt_colorram_w);
2739   DECLARE_WRITE8_MEMBER(sidepckt_flipscreen_w);
2840   DECLARE_DRIVER_INIT(sidepckt);
29   DECLARE_DRIVER_INIT(sidepctj);
41   DECLARE_DRIVER_INIT(sidepcktj);
3042   TILE_GET_INFO_MEMBER(get_tile_info);
43   virtual void machine_reset();
3144   virtual void video_start();
3245   virtual void palette_init();
3346   UINT32 screen_update_sidepckt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3447   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
35   required_device<cpu_device> m_maincpu;
36   required_device<cpu_device> m_audiocpu;
3748};
trunk/src/mame/video/sidepckt.c
r25424r25425
1/******************************************************************************
2
3    Data East Side Pocket hardware
4
5    Functions to emulate the video hardware
6
7******************************************************************************/
8
19#include "emu.h"
210#include "includes/sidepckt.h"
311
trunk/src/mame/drivers/sidepckt.c
r25424r25425
130130#include "sound/3526intf.h"
131131#include "includes/sidepckt.h"
132132
133// protection tables
134static const UINT8 sidepckt_prot_table_1[0x10]={0x05,0x03,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
135static const UINT8 sidepckt_prot_table_2[0x10]={0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff};
136static const UINT8 sidepckt_prot_table_3[0x10]={0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff};
133137
138static const UINT8 sidepcktj_prot_table_1[0x10]={0x05,0x03,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
139static const UINT8 sidepcktj_prot_table_2[0x10]={0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff};
140static const UINT8 sidepcktj_prot_table_3[0x10]={0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff};
141
142
134143WRITE8_MEMBER(sidepckt_state::sound_cpu_command_w)
135144{
136145   soundlatch_byte_w(space, offset, data);
r25424r25425
144153
145154WRITE8_MEMBER(sidepckt_state::sidepckt_i8751_w)
146155{
147   static const int table_1[]={5,3,2};
148   static const int table_2[]={0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff};
149   static const int table_3[]={0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff};
150
151156   m_maincpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE); /* i8751 triggers FIRQ on main cpu */
152157
153158   /* This function takes multiple parameters */
154   if (m_in_math==1) {
155      m_in_math=2;
156      m_i8751_return=m_math_param=data;
159   if (m_in_math == 1)
160   {
161      m_in_math = 2;
162      m_math_param = data;
163      m_i8751_return = m_math_param;
157164   }
158   else if (m_in_math==2) {
159      m_in_math=0;
160      m_i8751_return=m_math_param/data;
165   else if (m_in_math == 2)
166   {
167      m_in_math = 0;
168      m_i8751_return = (data) ? (m_math_param / data) : 0;
161169   }
162   else switch (data) {
170   else switch (data)
171   {
163172      case 1: /* ID Check */
164         m_current_table=1; m_current_ptr=0; m_i8751_return=table_1[m_current_ptr++]; break;
165
166173      case 2: /* Protection data (executable code) */
167         m_current_table=2; m_current_ptr=0; m_i8751_return=table_2[m_current_ptr++]; break;
168
169174      case 3: /* Protection data (executable code) */
170         m_current_table=3; m_current_ptr=0; m_i8751_return=table_3[m_current_ptr++]; break;
171
172      case 4: /* Divide function - multiple parameters */
173         m_in_math=1;
174         m_i8751_return=4;
175         break;
176
175         m_current_table = data - 1;
176         m_current_ptr = 0;
177177      case 6: /* Read table data */
178         if (m_current_table==1)
179         {
180            assert(m_current_ptr >= 0 && m_current_ptr < ARRAY_LENGTH(table_1));
181            m_i8751_return=table_1[m_current_ptr++];
182         }
183         if (m_current_table==2) m_i8751_return=table_2[m_current_ptr++];
184         if (m_current_table==3) m_i8751_return=table_3[m_current_ptr++];
178         m_i8751_return = m_prot_table[m_current_table][m_current_ptr];
179         m_current_ptr = (m_current_ptr + 1) & 0x0f;
185180         break;
186   }
187}
188181
189WRITE8_MEMBER(sidepckt_state::sidepctj_i8751_w)
190{
191   static const int table_1[]={5,3,0};
192   static const int table_2[]={0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff};
193   static const int table_3[]={0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff};
194
195   m_maincpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE); /* i8751 triggers FIRQ on main cpu */
196
197   /* This function takes multiple parameters */
198   if (m_in_math==1) {
199      m_in_math=2;
200      m_i8751_return=m_math_param=data;
201   }
202   else if (m_in_math==2) {
203      m_in_math=0;
204      m_i8751_return=m_math_param/data;
205   }
206   else switch (data) {
207      case 1: /* ID Check */
208         m_current_table=1; m_current_ptr=0; m_i8751_return=table_1[m_current_ptr++]; break;
209
210      case 2: /* Protection data (executable code) */
211         m_current_table=2; m_current_ptr=0; m_i8751_return=table_2[m_current_ptr++]; break;
212
213      case 3: /* Protection data (executable code) */
214         m_current_table=3; m_current_ptr=0; m_i8751_return=table_3[m_current_ptr++]; break;
215
216182      case 4: /* Divide function - multiple parameters */
217         m_in_math=1;
218         m_i8751_return=4;
183         m_in_math = 1;
184         m_i8751_return = 4;
219185         break;
220186
221      case 6: /* Read table data */
222         if (m_current_table==1)
223         {
224            assert(m_current_ptr >= 0 && m_current_ptr < ARRAY_LENGTH(table_1));
225            m_i8751_return=table_1[m_current_ptr++];
226         }
227         if (m_current_table==2) m_i8751_return=table_2[m_current_ptr++];
228         if (m_current_table==3) m_i8751_return=table_3[m_current_ptr++];
187      default:
229188         break;
230189   }
231190}
r25424r25425
246205   AM_RANGE(0x3003, 0x3003) AM_READ_PORT("DSW2")
247206   AM_RANGE(0x3004, 0x3004) AM_WRITE(sound_cpu_command_w)
248207   AM_RANGE(0x300c, 0x300c) AM_READNOP AM_WRITE(sidepckt_flipscreen_w)
249//  AM_RANGE(0x3014, 0x3014) //i8751 read
250//  AM_RANGE(0x3018, 0x3018) //i8751 write
208   AM_RANGE(0x3014, 0x3014) AM_READ(sidepckt_i8751_r)
209   AM_RANGE(0x3018, 0x3018) AM_WRITE(sidepckt_i8751_w)
251210   AM_RANGE(0x4000, 0xffff) AM_ROM
252211ADDRESS_MAP_END
253212
213static ADDRESS_MAP_START( sidepcktb_map, AS_PROGRAM, 8, sidepckt_state )
214   AM_RANGE(0x3014, 0x3014) AM_READNOP
215   AM_RANGE(0x3018, 0x3018) AM_WRITENOP
216   AM_IMPORT_FROM( sidepckt_map )
217ADDRESS_MAP_END
218
219
254220static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, sidepckt_state )
255221   AM_RANGE(0x0000, 0x0fff) AM_RAM
256222   AM_RANGE(0x1000, 0x1001) AM_DEVWRITE("ym1", ym2203_device, write)
r25424r25425
386352GFXDECODE_END
387353
388354
355void sidepckt_state::machine_reset()
356{
357   m_i8751_return = 0;
358   m_current_ptr = 0;
359   m_current_table = 0;
360   m_in_math = 0;
361   m_math_param = 0;
362}
389363
390364static MACHINE_CONFIG_START( sidepckt, sidepckt_state )
391365
392366   /* basic machine hardware */
393   MCFG_CPU_ADD("maincpu", M6809, 2000000)        /* 2 MHz */
367   MCFG_CPU_ADD("maincpu", M6809, 2000000) /* 2 MHz */
394368   MCFG_CPU_PROGRAM_MAP(sidepckt_map)
395   MCFG_CPU_VBLANK_INT_DRIVER("screen", sidepckt_state, nmi_line_pulse)
369   MCFG_CPU_VBLANK_INT_DRIVER("screen", sidepckt_state, nmi_line_pulse)
396370
397   MCFG_CPU_ADD("audiocpu", M6502, 1500000)        /* 1.5 MHz */
371   MCFG_CPU_ADD("audiocpu", M6502, 1500000) /* 1.5 MHz */
398372   MCFG_CPU_PROGRAM_MAP(sound_map)
399                        /* NMIs are triggered by the main cpu */
400373
401374   /* video hardware */
402375   MCFG_SCREEN_ADD("screen", RASTER)
403   MCFG_SCREEN_REFRESH_RATE(58)
404   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */  /* VERIFY:  May be 55 or 56 */)
376   MCFG_SCREEN_REFRESH_RATE(58) /* VERIFY: May be 55 or 56 */
377   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */ )
405378   MCFG_SCREEN_SIZE(32*8, 32*8)
406379   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
407380   MCFG_SCREEN_UPDATE_DRIVER(sidepckt_state, screen_update_sidepckt)
r25424r25425
409382   MCFG_GFXDECODE(sidepckt)
410383   MCFG_PALETTE_LENGTH(256)
411384
412
413385   /* sound hardware */
414386   MCFG_SPEAKER_STANDARD_MONO("mono")
415387
r25424r25425
421393   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
422394MACHINE_CONFIG_END
423395
396static MACHINE_CONFIG_DERIVED( sidepcktb, sidepckt )
424397
398   /* basic machine hardware */
399   MCFG_CPU_MODIFY("maincpu")
400   MCFG_CPU_PROGRAM_MAP(sidepcktb_map)
401MACHINE_CONFIG_END
402
403
425404/***************************************************************************
426405
427406  Game driver(s)
r25424r25425
504483
505484DRIVER_INIT_MEMBER(sidepckt_state,sidepckt)
506485{
507   m_maincpu->space(AS_PROGRAM).install_read_handler(0x3014, 0x3014, read8_delegate(FUNC(sidepckt_state::sidepckt_i8751_r),this));
508   m_maincpu->space(AS_PROGRAM).install_write_handler(0x3018, 0x3018, write8_delegate(FUNC(sidepckt_state::sidepckt_i8751_w),this));
486   m_prot_table[0] = sidepckt_prot_table_1;
487   m_prot_table[1] = sidepckt_prot_table_2;
488   m_prot_table[2] = sidepckt_prot_table_3;
509489}
510490
511DRIVER_INIT_MEMBER(sidepckt_state,sidepctj)
491DRIVER_INIT_MEMBER(sidepckt_state,sidepcktj)
512492{
513   m_maincpu->space(AS_PROGRAM).install_read_handler(0x3014, 0x3014, read8_delegate(FUNC(sidepckt_state::sidepckt_i8751_r),this));
514   m_maincpu->space(AS_PROGRAM).install_write_handler(0x3018, 0x3018, write8_delegate(FUNC(sidepckt_state::sidepctj_i8751_w),this));
493   m_prot_table[0] = sidepcktj_prot_table_1;
494   m_prot_table[1] = sidepcktj_prot_table_2;
495   m_prot_table[2] = sidepcktj_prot_table_3;
515496}
516497
517498
518GAME( 1986, sidepckt,  0,        sidepckt, sidepckt, sidepckt_state,  sidepckt, ROT0, "Data East Corporation", "Side Pocket (World)", GAME_NO_COCKTAIL )
519GAME( 1986, sidepcktj, sidepckt, sidepckt, sidepcktj, sidepckt_state, sidepctj, ROT0, "Data East Corporation", "Side Pocket (Japan)", GAME_NO_COCKTAIL )
520GAME( 1986, sidepcktb, sidepckt, sidepckt, sidepcktb, driver_device, 0,        ROT0, "bootleg", "Side Pocket (bootleg)", GAME_NO_COCKTAIL )
499GAME( 1986, sidepckt,  0,        sidepckt,  sidepckt,  sidepckt_state, sidepckt,  ROT0, "Data East Corporation", "Side Pocket (World)", GAME_NO_COCKTAIL )
500GAME( 1986, sidepcktj, sidepckt, sidepckt,  sidepcktj, sidepckt_state, sidepcktj, ROT0, "Data East Corporation", "Side Pocket (Japan)", GAME_NO_COCKTAIL )
501GAME( 1986, sidepcktb, sidepckt, sidepcktb, sidepcktb, driver_device,  0,         ROT0, "bootleg", "Side Pocket (bootleg)", GAME_NO_COCKTAIL )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team