X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffileio.cpp;h=3ad949fc3dc33e47d85007b404a66bfb9ce97513;hb=HEAD;hp=ab9344a4e64e82a887a3c60b2e7ee8655d171aea;hpb=7fb379d6be716f3b6c9dd15d604805c8987d7de0;p=wozmaker diff --git a/src/fileio.cpp b/src/fileio.cpp index ab9344a..3ad949f 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -83,11 +83,8 @@ uint8_t * ReadFile(const char * filename, uint32_t * size) bool LoadA2R(const char * filename) { -/* -Really, this crap should go into fileio.cpp. !!! FIX !!! -*/ - static uint8_t a2rHdr[8] = { 0x41, 0x32, 0x52, 0x32, 0xFF, 0x0A, 0x0D, 0x0A }; - static uint8_t a2rHdr1[8] = { 0x41, 0x32, 0x52, 0x31, 0xFF, 0x0A, 0x0D, 0x0A }; + static uint8_t a2rHdr1[] = "A2R1\xFF\x0A\x0D\x0A"; + static uint8_t a2rHdr[] = "A2R2\xFF\x0A\x0D\x0A"; if (Global::a2r != NULL) free(Global::a2r); @@ -324,9 +321,10 @@ uint8_t * GetMetadata(const char * keyword) for(uint8_t i=0; i= kwLen) - && (memcmp(Global::meta[i], keyword, kwLen) == 0)) + && (memcmp(Global::meta[i], keyword, kwLen) == 0) + && (Global::meta[i][kwLen] == 0x09)) { - return &Global::meta[i][kwLen]; + return &Global::meta[i][kwLen + 1]; } } @@ -336,7 +334,7 @@ uint8_t * GetMetadata(const char * keyword) uint16_t GetRequiredMachineBits(void) { - uint8_t * kw = GetMetadata("requires_machine\x09"); + uint8_t * kw = GetMetadata("requires_machine"); uint32_t kwLen = strlen((char *)kw); uint16_t bits = 0; char type[8]; @@ -380,34 +378,41 @@ uint16_t GetRequiredMachineBits(void) uint16_t GetRequiredRAMInK(void) { - char * kw = (char *)GetMetadata("requires_ram\x09"); + uint16_t ram[13] = { 16, 24, 32, 48, 64, 128, 256, 512, 768, 1024, 1280, 1536, 0 }; + return ram[GetRequiredRAMIndex()]; +} + + +uint16_t GetRequiredRAMIndex(void) +{ + char * kw = (char *)GetMetadata("requires_ram"); if (strcmp(kw, "16K") == 0) - return 16; + return 0; else if (strcmp(kw, "24K") == 0) - return 24; + return 1; else if (strcmp(kw, "32K") == 0) - return 32; + return 2; else if (strcmp(kw, "48K") == 0) - return 48; + return 3; else if (strcmp(kw, "64K") == 0) - return 64; + return 4; else if (strcmp(kw, "128K") == 0) - return 128; + return 5; else if (strcmp(kw, "256K") == 0) - return 256; + return 6; else if (strcmp(kw, "512K") == 0) - return 512; + return 7; else if (strcmp(kw, "768K") == 0) - return 768; + return 8; else if (strcmp(kw, "1M") == 0) - return 1024; + return 9; else if (strcmp(kw, "1.25M") == 0) - return 1280; + return 10; else if (strcmp(kw, "1.5M+") == 0) - return 1536; + return 11; - return 0; + return 12; } /* METADATA Keywords (standard)