Previous 15994 Revisions Next

r4454 Friday 3rd April, 2009 at 08:39:02 UTC by Curt Coder
[STUDIO2] Fixed .st2 cartridge loading.
[docs]messnew.txt
[src/mess/drivers]studio2.c
[src/mess/includes]studio2.h

src/mess/includes/studio2.h
r4453r4454
88#define CDP1861_TAG "cdp1861"
99#define CDP1864_TAG "cdp1864"
1010
11#define ST2_HEADER_SIZE         256
11#define ST2_BLOCK_SIZE 256
1212
1313typedef struct _studio2_state studio2_state;
1414struct _studio2_state
r4453r4454
2929   const device_config *cdp1864;
3030};
3131
32typedef struct _st2_header st2_header;
33struct _st2_header
34{
35   UINT8 header[4];         /* "RCA2" in ASCII code */
36   UINT8 blocks;            /* Total number of 256 byte blocks in file (including this one) */
37   UINT8 format;            /* Format Code (this is format number 1) */
38   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) */
39   UINT8 reserved0;
40   UINT8 author[2];         /* 2 byte ASCII code indicating the identity of the program coder */
41   UINT8 dumper[2];         /* 2 byte ASCII code indicating the identity of the ROM Source */
42   UINT8 reserved1[4];
43   UINT8 catalogue[10];      /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
44   UINT8 reserved2[6];
45   UINT8 title[32];         /* Cartridge Program Title as ASCIIZ string */
46   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 */
47   UINT8 reserved3[128];
48};
49
3250#endif
src/mess/drivers/studio2.c
r4453r4454
476476
477477static DEVICE_IMAGE_LOAD( studio2_cart )
478478{
479   UINT8   *ptr = NULL;
480   UINT8   header[ST2_HEADER_SIZE];
481   int   filesize;
479   st2_header header;
480   int block;
482481
483   filesize = image_length( image );
484   if ( filesize <= ST2_HEADER_SIZE ) {
485      logerror( "Error loading cartridge: Invalid ROM file: %s.\n", image_filename( image ) );
482   /* check file size */
483   int filesize = image_length(image);
484
485   if (filesize <= ST2_BLOCK_SIZE) {
486      logerror( "Error loading cartridge: Invalid ROM file: %s.\n", image_filename(image));
486487      return INIT_FAIL;
487488   }
488489
489490   /* read ST2 header */
490   if ( image_fread(image, header, ST2_HEADER_SIZE ) != ST2_HEADER_SIZE ) {
491      logerror( "Error loading cartridge: Unable to read header from file: %s.\n", image_filename( image ) );
491   if (image_fread(image, &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
492      logerror( "Error loading cartridge: Unable to read header from file: %s.\n", image_filename(image));
492493      return INIT_FAIL;
493494   }
494   filesize -= ST2_HEADER_SIZE;
495   /* Read ST2 cartridge contents */
496   ptr = ((UINT8 *)memory_region(image->machine,  CDP1802_TAG ) ) + 0x0400;
497   if ( image_fread(image, ptr, filesize ) != filesize ) {
498      logerror( "Error loading cartridge: Unable to read contents from file: %s.\n", image_filename( image ) );
499      return INIT_FAIL;
495
496   //logerror("ST2 Catalogue: %s\n", header.catalogue);
497   //logerror("ST2 Title: %s\n", header.title);
498
499   /* read ST2 cartridge into memory */
500   for (block = 0; block < (header.blocks - 1); block++)
501   {
502      UINT16 offset = header.page[block] << 8;
503      UINT8 *ptr = ((UINT8 *) memory_region(image->machine, CDP1802_TAG)) + offset;
504
505      //logerror("ST2 Reading block %u to %04x\n", block, offset);
506
507      if (image_fread(image, ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
508         logerror( "Error loading cartridge: Unable to read contents from file: %s.\n", image_filename(image));
509         return INIT_FAIL;
510      }
500511   }
501512
502513   return INIT_PASS;
docs/messnew.txt
r4453r4454
1313
1414- [TRS80] Added parallel printer [Robbbert]
1515
16- [STUDIO2] Fixed .st2 cartridge loading. [Curt Coder]
1617
1718
19
1820User Interface Changes:
1921-----------------------
2022(none)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team