Previous 15994 Revisions Next

r7723 Monday 5th April, 2010 at 19:34:25 UTC by Wilbert Pol
[SCV] Added support for on-cart RAM and banking.
[docs]messnew.txt
[hash]scv.xml
[src/mess/drivers]scv.c

hash/scv.xml
r7722r7723
8787      </part>
8888   </software>
8989
90   <software name="doreamon">
91      <description>Doreamon</description>
92      <year>1985</year>
93      <publisher>Epoch</publisher>
94      <part name="cart" interface="scv_cart">
95         <dataarea name="rom" size="65536">
96            <rom name="doreamon.0" size="32768" crc="ee0b874d" sha1="425eb6ed31faa2afdecc216145616f577f72db9a" offset="0" />
97            <rom name="doreamon.1" size="32768" crc="d2de91a6" sha1="6aba5ee3d08afad222bec9a176c2607829fa5cc6" offset="8000" />
98         </dataarea>
99      </part>
100   </software>
101
90102   <software name="elevfght">
91103      <description>Elevator Fight</description>
92104      <year>1984</year>
r7722r7723
237249
238250<!--
239251   /* Basic Nyuumon */
240   /* Doraemon */
241252   /* Dragon Ball */
242253   /* Dragon Slayer */
243254   /* Lupin III - needs redump */
src/mess/drivers/scv.c
r7722r7723
1616static READ8_HANDLER( scv_portb_r );
1717static READ8_HANDLER( scv_portc_r );
1818static WRITE8_HANDLER( scv_portc_w );
19static WRITE8_HANDLER( scv_cart_ram_w );
1920
2021
22class scv_state
23{
24public:
25   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, scv_state(machine)); }
26
27   scv_state(running_machine &machine) { }
28
29   UINT8   *vram;
30   UINT8   porta;
31   UINT8   portc;
32   emu_timer   *vb_timer;
33   UINT8   *cart_rom;
34   UINT32   cart_rom_size;
35   UINT8   *cart_ram;
36   UINT32   cart_ram_size;
37};
38
39
2140static UINT8 *scv_vram;
22static UINT8 scv_porta;
23static UINT8 scv_portc;
24static emu_timer *scv_vb_timer;
2541
2642
2743static ADDRESS_MAP_START( scv_mem, ADDRESS_SPACE_PROGRAM, 8 )
r7722r7723
3147
3248   AM_RANGE( 0x3600, 0x3600 ) AM_DEVWRITE( "upd1771c", upd1771_w )
3349
34   AM_RANGE( 0x8000, 0xff7f ) AM_ROM AM_REGION("cart", 0)
50   AM_RANGE( 0x8000, 0x9fff ) AM_ROMBANK("bank0")
51   AM_RANGE( 0xa000, 0xbfff ) AM_ROMBANK("bank1")
52   AM_RANGE( 0xc000, 0xdfff ) AM_ROMBANK("bank2")
53   AM_RANGE( 0xe000, 0xff7f ) AM_READ_BANK("bank3")   AM_WRITE( scv_cart_ram_w )
3554   AM_RANGE( 0xff80, 0xffff ) AM_RAM      /* upd7801 internal RAM */
3655ADDRESS_MAP_END
3756
r7722r7723
129148INPUT_PORTS_END
130149
131150
151static WRITE8_HANDLER( scv_cart_ram_w )
152{
153   scv_state *state = (scv_state *)space->machine->driver_data;
154
155   /* Check if cartridge ram is available and enabled */
156   if ( state->cart_ram && state->cart_ram_size && ( state->portc & 0x20 ) )
157   {
158      state->cart_ram[offset] = data;
159   }
160}
161
162
132163static WRITE8_HANDLER( scv_porta_w )
133164{
134   scv_porta = data;
165   scv_state *state = (scv_state *)space->machine->driver_data;
166
167   state->porta = data;
135168}
136169
137170
138171static READ8_HANDLER( scv_portb_r )
139172{
173   scv_state *state = (scv_state *)space->machine->driver_data;
140174   UINT8 data = 0xff;
141175
142   if ( ! ( scv_porta & 0x01 ) )
176   if ( ! ( state->porta & 0x01 ) )
143177      data &= input_port_read( space->machine, "PA0" );
144178
145   if ( ! ( scv_porta & 0x02 ) )
179   if ( ! ( state->porta & 0x02 ) )
146180      data &= input_port_read( space->machine, "PA1" );
147181
148   if ( ! ( scv_porta & 0x04 ) )
182   if ( ! ( state->porta & 0x04 ) )
149183      data &= input_port_read( space->machine, "PA2" );
150184
151   if ( ! ( scv_porta & 0x08 ) )
185   if ( ! ( state->porta & 0x08 ) )
152186      data &= input_port_read( space->machine, "PA3" );
153187
154   if ( ! ( scv_porta & 0x10 ) )
188   if ( ! ( state->porta & 0x10 ) )
155189      data &= input_port_read( space->machine, "PA4" );
156190
157   if ( ! ( scv_porta & 0x20 ) )
191   if ( ! ( state->porta & 0x20 ) )
158192      data &= input_port_read( space->machine, "PA5" );
159193
160   if ( ! ( scv_porta & 0x40 ) )
194   if ( ! ( state->porta & 0x40 ) )
161195      data &= input_port_read( space->machine, "PA6" );
162196
163   if ( ! ( scv_porta & 0x80 ) )
197   if ( ! ( state->porta & 0x80 ) )
164198      data &= input_port_read( space->machine, "PA7" );
165199
166200   return data;
r7722r7723
169203
170204static READ8_HANDLER( scv_portc_r )
171205{
172   UINT8 data = 0xff;
206   scv_state *state = (scv_state *)space->machine->driver_data;
207   UINT8 data = state->portc;
173208
174209   data = ( data & 0xfe ) | ( input_port_read( space->machine, "PC0" ) & 0x01 );
175210
r7722r7723
177212}
178213
179214
215static void scv_set_banks( running_machine *machine )
216{
217   scv_state *state = (scv_state *)machine->driver_data;
218
219   switch( state->cart_rom_size )
220   {
221   case 0x2000:
222      memory_set_bankptr( machine, "bank0", state->cart_rom );
223      memory_set_bankptr( machine, "bank1", state->cart_rom );
224      memory_set_bankptr( machine, "bank2", state->cart_rom );
225      memory_set_bankptr( machine, "bank3", state->cart_rom );
226      break;
227   case 0x4000:
228      memory_set_bankptr( machine, "bank0", state->cart_rom );
229      memory_set_bankptr( machine, "bank1", state->cart_rom + 0x2000 );
230      memory_set_bankptr( machine, "bank2", state->cart_rom );
231      memory_set_bankptr( machine, "bank3", state->cart_rom + 0x2000 );
232      break;
233   case 0x8000:
234      memory_set_bankptr( machine, "bank0", state->cart_rom );
235      memory_set_bankptr( machine, "bank1", state->cart_rom + 0x2000 );
236      memory_set_bankptr( machine, "bank2", state->cart_rom + 0x4000 );
237      memory_set_bankptr( machine, "bank3", state->cart_rom + 0x6000 );
238      break;
239   case 0x10000:
240   case 0x20000:
241      memory_set_bankptr( machine, "bank0", state->cart_rom + ( ( state->portc & 0x20 ) ? 0x8000 : 0 ) );
242      memory_set_bankptr( machine, "bank1", state->cart_rom + ( ( state->portc & 0x20 ) ? 0xa000 : 0x2000 ) );
243      memory_set_bankptr( machine, "bank2", state->cart_rom + ( ( state->portc & 0x20 ) ? 0xc000 : 0x4000 ) );
244      memory_set_bankptr( machine, "bank3", state->cart_rom + ( ( state->portc & 0x20 ) ? 0xe000 : 0x6000 ) );
245      break;
246   }
247
248   /* Check if cartridge RAM is available and should be enabled */
249   if ( state->cart_ram && state->cart_ram_size && ( state->portc & 0x20 ) )
250   {
251      memory_set_bankptr( machine, "bank3", state->cart_ram );
252   }
253
254}
255
256
180257static WRITE8_HANDLER( scv_portc_w )
181258{
182   scv_portc = data;
259   scv_state *state = (scv_state *)space->machine->driver_data;
260
261   logerror("%04x: scv_portc_w: data = 0x%02x\n", cpu_get_pc(devtag_get_device(space->machine, "maincpu")), data );
262   state->portc = data;
263
264   scv_set_banks( space->machine );
183265}
184266
185267
268static DEVICE_START( scv_cart )
269{
270   scv_state *state = (scv_state *)device->machine->driver_data;
271
272   state->cart_rom = memory_region( device->machine, "cart" );
273   state->cart_rom_size = memory_region_length( device->machine, "cart" );
274   state->cart_ram = NULL;
275   state->cart_ram_size = 0;
276
277   scv_set_banks( device->machine );
278}
279
280
186281static DEVICE_IMAGE_LOAD( scv_cart )
187282{
283   scv_state *state = (scv_state *)image->machine->driver_data;
188284
189   UINT8 *cart = memory_region( image->machine, "cart" );
190   int size = image_length( image );
285   if ( image_software_entry(image) == NULL )
286   {
287      UINT8 *cart = memory_region( image->machine, "cart" );
288      int size = image_length( image );
191289
192   if ( size > 0x8000 )
193   {
194      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size" );
195      return INIT_FAIL;
290      if ( size > memory_region_length( image->machine, "cart" ) )
291      {
292         image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size" );
293         return INIT_FAIL;
294      }
295
296      if ( image_fread( image, cart, size ) != size )
297      {
298         image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file" );
299         return INIT_FAIL;
300      }
301
302      state->cart_rom = cart;
303      state->cart_rom_size = size;
304      state->cart_ram = NULL;
305      state->cart_ram_size = 0;
196306   }
197
198   if ( image_fread( image, cart, size ) != size )
307   else
199308   {
200      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file" );
201      return INIT_FAIL;
309      state->cart_rom = image_get_software_region( image, "rom" );
310      state->cart_rom_size = image_get_software_region_length( image, "rom" );
311      state->cart_ram = image_get_software_region( image, "ram" );
312      state->cart_ram_size = image_get_software_region_length( image, "ram" );
202313   }
203314
315   scv_set_banks( image->machine );
316
204317   return INIT_PASS;
205318}
206319
r7722r7723
229342
230343static TIMER_CALLBACK( scv_vb_callback )
231344{
345   scv_state *state = (scv_state *)machine->driver_data;
232346   int vpos = video_screen_get_vpos(machine->primary_screen);
233347
234348   switch( vpos )
r7722r7723
241355      break;
242356   }
243357
244   timer_adjust_oneshot( scv_vb_timer, video_screen_get_time_until_pos( machine->primary_screen, ( vpos + 1 ) % 262, 0 ), 0 );
358   timer_adjust_oneshot( state->vb_timer, video_screen_get_time_until_pos( machine->primary_screen, ( vpos + 1 ) % 262, 0 ), 0 );
245359}
246360
247361
r7722r7723
535649
536650static MACHINE_START( scv )
537651{
538   scv_vb_timer = timer_alloc( machine, scv_vb_callback, NULL );
652   scv_state *state = (scv_state *)machine->driver_data;
653
654   state->vb_timer = timer_alloc( machine, scv_vb_callback, NULL );
539655}
540656
541657
542658static MACHINE_RESET( scv )
543659{
544   timer_adjust_oneshot( scv_vb_timer, video_screen_get_time_until_pos( machine->primary_screen, 0, 0 ), 0 );
660   scv_state *state = (scv_state *)machine->driver_data;
661
662   timer_adjust_oneshot( state->vb_timer, video_screen_get_time_until_pos( machine->primary_screen, 0, 0 ), 0 );
545663}
546664
547665
r7722r7723
569687
570688
571689static MACHINE_DRIVER_START( scv )
690   MDRV_DRIVER_DATA( scv_state )
691
572692   MDRV_CPU_ADD( "maincpu", UPD7801, XTAL_4MHz )
573693   MDRV_CPU_PROGRAM_MAP( scv_mem )
574694   MDRV_CPU_IO_MAP( scv_io )
r7722r7723
597717   MDRV_CARTSLOT_ADD( "cart" )
598718   MDRV_CARTSLOT_EXTENSION_LIST( "bin" )
599719   MDRV_CARTSLOT_NOT_MANDATORY
720   MDRV_CARTSLOT_INTERFACE("scv_cart")
721   MDRV_CARTSLOT_START( scv_cart )
600722   MDRV_CARTSLOT_LOAD( scv_cart )
723
724   /* Software lists */
725   MDRV_SOFTWARE_LIST_ADD("scv")
601726MACHINE_DRIVER_END
602727
603728
604729static MACHINE_DRIVER_START( scv_pal )
730   MDRV_DRIVER_DATA( scv_state )
731
605732   MDRV_CPU_ADD( "maincpu", UPD7801, 3780000 )
606733   MDRV_CPU_PROGRAM_MAP( scv_mem )
607734   MDRV_CPU_IO_MAP( scv_io )
r7722r7723
630757   MDRV_CARTSLOT_ADD( "cart" )
631758   MDRV_CARTSLOT_EXTENSION_LIST( "bin" )
632759   MDRV_CARTSLOT_NOT_MANDATORY
760   MDRV_CARTSLOT_INTERFACE("scv_cart")
761   MDRV_CARTSLOT_START( scv_cart )
633762   MDRV_CARTSLOT_LOAD( scv_cart )
763
764   /* Software lists */
765   MDRV_SOFTWARE_LIST_ADD("scv")
634766MACHINE_DRIVER_END
635767
636768
r7722r7723
641773   ROM_REGION( 0x400, "charrom", 0 )
642774   ROM_LOAD( "epochtv.chr", 0, 0x400, BAD_DUMP CRC(db521533) SHA1(40b4e44838c35191f115437a14f200f052e71509) )
643775
644   ROM_REGION( 0x8000, "cart", ROMREGION_ERASEFF )
776   ROM_REGION( 0x20000, "cart", ROMREGION_ERASEFF )
645777ROM_END
646778
647779
r7722r7723
651783   ROM_REGION( 0x400, "charrom", 0 )
652784   ROM_LOAD( "epochtv.chr", 0, 0x400, BAD_DUMP CRC(db521533) SHA1(40b4e44838c35191f115437a14f200f052e71509) )
653785
654   ROM_REGION( 0x8000, "cart", ROMREGION_ERASEFF )
786   ROM_REGION( 0x20000, "cart", ROMREGION_ERASEFF )
655787ROM_END
656788
657789
docs/messnew.txt
r7722r7723
3535
3636- [SAMCOUPE] Rewrote video rendering to render partial scanlines.  [Dirk Best]
3737
38- [SCV] Added support for on-cart RAM and banking.  [Wilbert Pol]
39
3840- [TANDY2K] Implemented DMA mux register. [Curt Coder]
3941
4042- [TI99] Cleanups.  [Michael Zapf]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team