MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / read_kickstart

Function read_kickstart

src/memory.cpp:1687–1788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1685static const uae_char *kickstring = "exec.library";
1686
1687static int read_kickstart(struct zfile *f, uae_u8 *mem, int size, int dochecksum, int noalias)
1688{
1689 uae_char buffer[11];
1690 int i, j, oldpos;
1691 int cr = 0, kickdisk = 0;
1692
1693 if (size < 0) {
1694 zfile_fseek(f, 0, SEEK_END);
1695 size = zfile_ftell32(f) & ~0x3ff;
1696 zfile_fseek(f, 0, SEEK_SET);
1697 }
1698 oldpos = zfile_ftell32(f);
1699 i = zfile_fread32(buffer, 1, sizeof(buffer), f);
1700 if (i < sizeof(buffer))
1701 return 0;
1702 if (!memcmp(buffer, "KICK", 4)) {
1703 zfile_fseek(f, 512, SEEK_SET);
1704 kickdisk = 1;
1705#if 0
1706 } else if (size >= ROM_SIZE_512 && !memcmp (buffer, "AMIG", 4)) {
1707 /* ReKick */
1708 zfile_fseek (f, oldpos + 0x6c, SEEK_SET);
1709 cr = 2;
1710#endif
1711 } else if (memcmp((uae_char*)buffer, "AMIROMTYPE1", 11) != 0) {
1712 zfile_fseek(f, oldpos, SEEK_SET);
1713 } else {
1714 cloanto_rom = 1;
1715 cr = 1;
1716 }
1717
1718 memset(mem, 0, size);
1719 if (size >= 131072) {
1720 for (i = 0; i < 8; i++) {
1721 mem[size - 16 + i * 2 + 1] = 0x18 + i;
1722 }
1723 mem[size - 20] = size >> 24;
1724 mem[size - 19] = size >> 16;
1725 mem[size - 18] = size >> 8;
1726 mem[size - 17] = size >> 0;
1727 }
1728
1729 i = zfile_fread32(mem, 1, size, f);
1730
1731 if (kickdisk && i > ROM_SIZE_256)
1732 i = ROM_SIZE_256;
1733#if 0
1734 if (i >= ROM_SIZE_256 && (i != ROM_SIZE_256 && i != ROM_SIZE_512 && i != ROM_SIZE_512 * 2 && i != ROM_SIZE_512 * 4)) {
1735 notify_user (NUMSG_KSROMREADERROR);
1736 return 0;
1737 }
1738#endif
1739 if (i < size - 20)
1740 kickstart_fix_checksum(mem, size);
1741 j = 1;
1742 while (j < i)
1743 j <<= 1;
1744 i = j;

Callers 4

load_extendedkickstartFunction · 0.85
load_kickstartFunction · 0.85
read_kickstart_versionFunction · 0.85

Calls 9

zfile_fseekFunction · 0.85
zfile_ftell32Function · 0.85
zfile_fread32Function · 0.85
kickstart_fix_checksumFunction · 0.85
decode_romFunction · 0.85
is_board_enabledFunction · 0.85
a1000_handle_kickstartFunction · 0.85
kickstart_checksumFunction · 0.85
notify_userFunction · 0.50

Tested by

no test coverage detected