src/state.c

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