ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/main_unix.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.2 by cebix, 2002-02-21T15:12:12Z vs.
Revision 1.3 by gbeauche, 2002-04-21T15:07:08Z

# Line 263 | Line 263 | extern void paranoia_check(void);
263   #endif
264  
265  
266 // Decode LZSS data
267 static void decode_lzss(const uint8 *src, uint8 *dest, int size)
268 {
269        char dict[0x1000];
270        int run_mask = 0, dict_idx = 0xfee;
271        for (;;) {
272                if (run_mask < 0x100) {
273                        // Start new run
274                        if (--size < 0)
275                                break;
276                        run_mask = *src++ | 0xff00;
277                }
278                bool bit = run_mask & 1;
279                run_mask >>= 1;
280                if (bit) {
281                        // Verbatim copy
282                        if (--size < 0)
283                                break;
284                        int c = *src++;
285                        dict[dict_idx++] = c;
286                        *dest++ = c;
287                        dict_idx &= 0xfff;
288                } else {
289                        // Copy from dictionary
290                        if (--size < 0)
291                                break;
292                        int idx = *src++;
293                        if (--size < 0)
294                                break;
295                        int cnt = *src++;
296                        idx |= (cnt << 4) & 0xf00;
297                        cnt = (cnt & 0x0f) + 3;
298                        while (cnt--) {
299                                char c = dict[idx++];
300                                dict[dict_idx++] = c;
301                                *dest++ = c;
302                                idx &= 0xfff;
303                                dict_idx &= 0xfff;
304                        }
305                }
306        }
307 }
308
309
266   /*
267   *  Main program
268   */
# Line 540 | Line 496 | int main(int argc, char **argv)
496          rom_tmp = new uint8[ROM_SIZE];
497          actual = read(rom_fd, (void *)rom_tmp, ROM_SIZE);
498          close(rom_fd);
499 <        if (actual == ROM_SIZE) {
500 <                // Plain ROM image
501 <                memcpy((void *)ROM_BASE, rom_tmp, ROM_SIZE);
502 <                delete[] rom_tmp;
547 <        } else {
548 <                if (strncmp((char *)rom_tmp, "<CHRP-BOOT>", 11) == 0) {
549 <                        // CHRP compressed ROM image
550 <                        D(bug("CHRP ROM image\n"));
551 <                        uint32 lzss_offset, lzss_size;
552 <
553 <                        char *s = strstr((char *)rom_tmp, "constant lzss-offset");
554 <                        if (s == NULL) {
555 <                                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
556 <                                goto quit;
557 <                        }
558 <                        s -= 7;
559 <                        if (sscanf(s, "%06x", &lzss_offset) != 1) {
560 <                                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
561 <                                goto quit;
562 <                        }
563 <                        s = strstr((char *)rom_tmp, "constant lzss-size");
564 <                        if (s == NULL) {
565 <                                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
566 <                                goto quit;
567 <                        }
568 <                        s -= 7;
569 <                        if (sscanf(s, "%06x", &lzss_size) != 1) {
570 <                                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
571 <                                goto quit;
572 <                        }
573 <                        D(bug("Offset of compressed data: %08x\n", lzss_offset));
574 <                        D(bug("Size of compressed data: %08x\n", lzss_size));
575 <
576 <                        D(bug("Uncompressing ROM...\n"));
577 <                        decode_lzss(rom_tmp + lzss_offset, (uint8 *)ROM_BASE, lzss_size);
578 <                        delete[] rom_tmp;
579 <                } else if (rom_size != 4*1024*1024) {
499 >        
500 >        // Decode Mac ROM
501 >        if (!DecodeROM(rom_tmp, actual)) {
502 >                if (rom_size != 4*1024*1024) {
503                          ErrorAlert(GetString(STR_ROM_SIZE_ERR));
504                          goto quit;
505                  } else {
# Line 584 | Line 507 | int main(int argc, char **argv)
507                          goto quit;
508                  }
509          }
510 +        delete[] rom_tmp;
511  
512          // Load NVRAM
513          XPRAMInit();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines