Previous 15994 Revisions Next

r7667 Tuesday 30th March, 2010 at 06:04:03 UTC by Curt Coder
[STUDIO2] Moved st2 cartridge load to formats.
[src/mess]mess.mak
[src/mess/drivers]studio2.c
[src/mess/formats]studio2_st2.c* studio2_st2.h*
[src/mess/includes]studio2.h

src/mess/includes/studio2.h
r7666r7667
33
44#include "cpu/cdp1802/cdp1802.h"
55
6#define SCREEN_TAG   "screen"
7#define CDP1802_TAG "cdp1802"
8#define CDP1861_TAG "cdp1861"
6#define CDP1802_TAG "ic1"
7#define CDP1861_TAG "ic2"
98#define CDP1864_TAG "cdp1864"
9#define SCREEN_TAG   "screen"
1010
11#define ST2_BLOCK_SIZE 256
12
1311class studio2_state
1412{
1513public:
r7666r7667
3533   running_device *cdp1864;
3634};
3735
38typedef struct _st2_header st2_header;
39struct _st2_header
40{
41   UINT8 header[4];         /* "RCA2" in ASCII code */
42   UINT8 blocks;            /* Total number of 256 byte blocks in file (including this one) */
43   UINT8 format;            /* Format Code (this is format number 1) */
44   UINT8 video;            /* If non-zero uses a special video driver, and programs cannot assume that it uses the standard Studio 2 one (top of screen at $0900+RB.0). A value of '1' here indicates the RAM is used normally, but scrolling is not (e.g. the top of the page is always at $900) */
45   UINT8 reserved0;
46   UINT8 author[2];         /* 2 byte ASCII code indicating the identity of the program coder */
47   UINT8 dumper[2];         /* 2 byte ASCII code indicating the identity of the ROM Source */
48   UINT8 reserved1[4];
49   UINT8 catalogue[10];      /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
50   UINT8 reserved2[6];
51   UINT8 title[32];         /* Cartridge Program Title as ASCIIZ string */
52   UINT8 page[64];            /* Contain the page addresses for each 256 byte block. The first byte at 64, contains the target address of the data at offset 256, the second byte contains the target address of the data at offset 512, and so on. Unused block bytes should be filled with $00 (an invalid page address). So, if byte 64 contains $1C, the ROM is paged into memory from $1C00-$1CFF */
53   UINT8 reserved3[128];
54};
55
5636#endif
src/mess/formats/studio2_st2.c
r0r7667
1/*********************************************************************
2
3    formats/studio2_st2.c
4
5    Cartridge code for RCA Studio II st2 files
6
7*********************************************************************/
8
9#include "emu.h"
10#include "includes/studio2.h"
11
12/***************************************************************************
13    PARAMETERS
14***************************************************************************/
15
16#define LOG 1
17
18#define ST2_BLOCK_SIZE 256
19
20/***************************************************************************
21    TYPE DEFINITIONS
22***************************************************************************/
23
24typedef struct _st2_header st2_header;
25struct _st2_header
26{
27   UINT8 header[4];         /* "RCA2" in ASCII code */
28   UINT8 blocks;            /* Total number of 256 byte blocks in file (including this one) */
29   UINT8 format;            /* Format Code (this is format number 1) */
30   UINT8 video;            /* If non-zero uses a special video driver, and programs cannot assume that it uses the standard Studio 2 one (top of screen at $0900+RB.0). A value of '1' here indicates the RAM is used normally, but scrolling is not (e.g. the top of the page is always at $900) */
31   UINT8 reserved0;
32   UINT8 author[2];         /* 2 byte ASCII code indicating the identity of the program coder */
33   UINT8 dumper[2];         /* 2 byte ASCII code indicating the identity of the ROM Source */
34   UINT8 reserved1[4];
35   UINT8 catalogue[10];      /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
36   UINT8 reserved2[6];
37   UINT8 title[32];         /* Cartridge Program Title as ASCIIZ string */
38   UINT8 page[64];            /* Contain the page addresses for each 256 byte block. The first byte at 64, contains the target address of the data at offset 256, the second byte contains the target address of the data at offset 512, and so on. Unused block bytes should be filled with $00 (an invalid page address). So, if byte 64 contains $1C, the ROM is paged into memory from $1C00-$1CFF */
39   UINT8 reserved3[128];
40};
41
42/***************************************************************************
43    IMPLEMENTATION
44***************************************************************************/
45
46DEVICE_IMAGE_LOAD( st2_cartslot_load )
47{
48   st2_header header;
49
50   /* check file size */
51   int filesize = image_length(image);
52
53   if (filesize <= ST2_BLOCK_SIZE) {
54      logerror("Error loading cartridge: Invalid ROM file: %s.\n", image_filename(image));
55      return INIT_FAIL;
56   }
57
58   /* read ST2 header */
59   if (image_fread(image, &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
60      logerror("Error loading cartridge: Unable to read header from file: %s.\n", image_filename(image));
61      return INIT_FAIL;
62   }
63
64   if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
65   if (LOG) logerror("ST2 Title: %s\n", header.title);
66
67   /* read ST2 cartridge into memory */
68   for (int block = 0; block < (header.blocks - 1); block++)
69   {
70      UINT16 offset = header.page[block] << 8;
71      UINT8 *ptr = ((UINT8 *) memory_region(image->machine, CDP1802_TAG)) + offset;
72
73      if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
74
75      if (image_fread(image, ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
76         logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image_filename(image));
77         return INIT_FAIL;
78      }
79   }
80
81   return INIT_PASS;
82}
src/mess/formats/studio2_st2.h
r0r7667
1/*********************************************************************
2
3    formats/studio2_St2.h
4
5    Cartridge code for RCA Studio II st2 files
6
7*********************************************************************/
8
9#pragma once
10
11#ifndef __STUDIO2_ST2__
12#define __STUDIO2_ST2__
13
14#include "emu.h"
15
16DEVICE_IMAGE_LOAD( st2_cartslot_load );
17
18#endif
src/mess/mess.mak
r7666r7667
12211221   $(MESS_DRIVERS)/mikrosha.o   \
12221222
12231223$(MESSOBJ)/rca.a:            \
1224   $(MESS_DRIVERS)/studio2.o   \
1225   $(MESS_FORMATS)/studio2_st2.o   \
12241226   $(MESS_DRIVERS)/vip.o      \
12251227   $(MESS_AUDIO)/vp550.o      \
12261228   $(MESS_AUDIO)/vp595.o      \
1227   $(MESS_DRIVERS)/studio2.o   \
12281229
12291230$(MESSOBJ)/rm.a:            \
12301231   $(MESS_DRIVERS)/rmnimbus.o   \
src/mess/drivers/studio2.c
r7666r7667
196196#include "emu.h"
197197#include "includes/studio2.h"
198198#include "cpu/cdp1802/cdp1802.h"
199#include "video/cdp1861.h"
200#include "sound/cdp1864.h"
201199#include "devices/cartslot.h"
200#include "formats/studio2_st2.h"
202201#include "sound/beep.h"
202#include "sound/cdp1864.h"
203203#include "sound/discrete.h"
204#include "video/cdp1861.h"
204205
205206/* Read/Write Handlers */
206207
r7666r7667
514515   state->cdp1864->reset();
515516}
516517
517static DEVICE_IMAGE_LOAD( studio2_cart )
518{
519   st2_header header;
520   int block;
518/* Machine Drivers */
521519
522   /* check file size */
523   int filesize = image_length(image);
524
525   if (filesize <= ST2_BLOCK_SIZE) {
526      logerror( "Error loading cartridge: Invalid ROM file: %s.\n", image_filename(image));
527      return INIT_FAIL;
528   }
529
530   /* read ST2 header */
531   if (image_fread(image, &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
532      logerror( "Error loading cartridge: Unable to read header from file: %s.\n", image_filename(image));
533      return INIT_FAIL;
534   }
535
536   //logerror("ST2 Catalogue: %s\n", header.catalogue);
537   //logerror("ST2 Title: %s\n", header.title);
538
539   /* read ST2 cartridge into memory */
540   for (block = 0; block < (header.blocks - 1); block++)
541   {
542      UINT16 offset = header.page[block] << 8;
543      UINT8 *ptr = ((UINT8 *) memory_region(image->machine, CDP1802_TAG)) + offset;
544
545      //logerror("ST2 Reading block %u to %04x\n", block, offset);
546
547      if (image_fread(image, ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
548         logerror( "Error loading cartridge: Unable to read contents from file: %s.\n", image_filename(image));
549         return INIT_FAIL;
550      }
551   }
552
553   return INIT_PASS;
554}
555
556520static MACHINE_DRIVER_START( studio2_cartslot )
557521   MDRV_CARTSLOT_ADD("cart")
558522   MDRV_CARTSLOT_EXTENSION_LIST("st2")
559523   MDRV_CARTSLOT_NOT_MANDATORY
560   MDRV_CARTSLOT_LOAD(studio2_cart)
524   MDRV_CARTSLOT_LOAD(st2_cartslot_load)
561525MACHINE_DRIVER_END
562526
563/* Machine Drivers */
564
565527static MACHINE_DRIVER_START( studio2 )
566528   MDRV_DRIVER_DATA(studio2_state)
567529

Previous 15994 Revisions Next


© 1998-2018 The MESS Team