src/state.c

changeset 55
ba6b8e570062
parent 52
a350dfa92895
child 60
96f3df0b3cbb
     1.1 --- a/src/state.c	Mon Dec 06 01:43:04 2010 +0000
     1.2 +++ b/src/state.c	Sun Dec 12 23:47:35 2010 +0000
     1.3 @@ -26,9 +26,15 @@
     1.4  	// Load ROMs
     1.5  	FILE *r14c, *r15c;
     1.6  	r14c = fopen("roms/14c.bin", "rb");
     1.7 -//	if (r14c == NULL) FAIL("unable to open roms/14c.bin");
     1.8 +	if (r14c == NULL) {
     1.9 +		fprintf(stderr, "[state] Error loading roms/14c.bin.\n");
    1.10 +		return -3;
    1.11 +	}
    1.12  	r15c = fopen("roms/15c.bin", "rb");
    1.13 -//	if (r15c == NULL) FAIL("unable to open roms/15c.bin");
    1.14 +	if (r15c == NULL) {
    1.15 +		fprintf(stderr, "[state] Error loading roms/15c.bin.\n");
    1.16 +		return -3;
    1.17 +	}
    1.18  
    1.19  	// get ROM file size
    1.20  	fseek(r14c, 0, SEEK_END);
    1.21 @@ -37,8 +43,14 @@
    1.22  	fseek(r15c, 0, SEEK_END);
    1.23  	size_t romlen2 = ftell(r15c);
    1.24  	fseek(r15c, 0, SEEK_SET);
    1.25 -//	if (romlen2 != romlen) FAIL("ROMs are not the same size!");
    1.26 -//	if ((romlen + romlen2) > ROM_SIZE) FAIL("ROMs are too large to fit in memory!");
    1.27 +	if (romlen2 != romlen) {
    1.28 +		fprintf(stderr, "[state] ROMs are not the same size!\n");
    1.29 +		return -3;
    1.30 +	}
    1.31 +	if ((romlen + romlen2) > ROM_SIZE) {
    1.32 +		fprintf(stderr, "[state] ROM files are too large!\n");
    1.33 +		return -3;
    1.34 +	}
    1.35  
    1.36  	// sanity checks completed; load the ROMs!
    1.37  	uint8_t *romdat1, *romdat2;