eliminate dead code

This commit is contained in:
Kelvin Sherlock 2013-05-12 22:25:20 -04:00
parent 6952c106b6
commit 20a1e81d60

View File

@ -110,26 +110,6 @@ void WriteLong(void *data, uint32_t offset, uint32_t value)
((uint8_t *)data)[offset++] = value;
}
/*
//0x0316 = MPWArgs *
struct MPWArgs
{
uint32_t MPGM; // = 'MPGM';
int32_t argptr;
args:
uint16_t SH;
uint32_t argc;
uint32_t argv;
uint32_t envp;
envp stored as key\0value\0, not key=value\0
};
0x910 = name ptr (32-char pstring)
*/
uint32_t load(const char *file)
{
@ -273,208 +253,7 @@ uint32_t load(const char *file)
return returnAddress;
}
#if 0
void InitializeMPW(int argc, char **argv)
{
argv[0] = basename(argv[0]);
// 0x0910 CurApName
{
char * name = argv[0];
char str32[32];
int l = strlen(name);
l = std::min(l, 32);
str32[0] = l;
memcpy(str32 + 1, name, l);
while (l < 32) str32[l++] = 0;
memcpy(Memory + 0x910, str32, 32);
}
// 0x0316 is a pointer to the argc, argv, envp.
// very ugly.
uint32_t argvAddress = 0;
uint32_t envpAddress = 0;
{
std::vector<uint32_t> argvSpine;
argvSpine.reserve(argc + 1);
for (int i = 0; i < argc; ++i)
{
int length;
uint32_t address;
length = strlen(argv[i]);
address = EmulatedNewPtr(length + 1);
memcpy(Memory + address, argv[i], length + 1);
argvSpine.push_back(address);
}
argvSpine.push_back(0);
argvAddress = EmulatedNewPtr(4 * argvSpine.size());
uint32_t address = argvAddress;
for (uint32_t x : argvSpine)
{
WriteLong(Memory, address, x);
address += 4;
}
}
// same thing for envp... but \0 instead of =
{
envpAddress = EmulatedNewPtr(4);
WriteLong(Memory, envpAddress, 0);
}
// _macpgminfo
uint32_t address = EmulatedNewPtr(8 + 0x30);
address = 0x2000; // monitor reads...
WriteLong(Memory, 0x0316, address);
WriteLong(Memory, address, 0x4d50474d); // MPGM - magic
WriteLong(Memory, address + 4, 0x2100 /* address + 8 */); // block ptr
// address += 8;
address = 0x2100;
WriteWord(Memory, address + 0x00, 0x5348); // SH - more magic
WriteLong(Memory, address + 0x02, argc);
WriteLong(Memory, address + 0x06, argvAddress);
WriteLong(Memory, address + 0x0a, envpAddress);
// possible the application exit code...
WriteLong(Memory, address + 0x0e, 0x00007000);
WriteLong(Memory, address + 0x12, 0x00008000);
WriteLong(Memory, address + 0x16, 0x00009000);
WriteWord(Memory, address + 0x1a, 0x0190); // ????
// default file table? block of size 0x3c.
// copied into IntEnv+0x1c
// _initIOPtable
WriteLong(Memory, address + 0x1c, 0x0000a000);
// stdin
WriteLong(Memory, 0x0000a000+0, 0x00010000); // ???
WriteLong(Memory, 0x0000a000+4, 0x00003000); // type ptr (FSYS)
WriteLong(Memory, 0x0000a000+8, STDIN_FILENO); // ptr to refcount/fd struct?
WriteLong(Memory, 0x0000a000+12, 0x00000000); // transferCount
WriteLong(Memory, 0x0000a000+16, 0x00000000); // transferBuffer
// stdout
//0x0001 = readable
//0x0002 = writable
// others?...
WriteLong(Memory, 0x0000a000+20, 0x00020000); // ??? {uint16_t flags, uint16_t error? }
WriteLong(Memory, 0x0000a000+24, 0x00003000); // type ptr (FSYS)
WriteLong(Memory, 0x0000a000+28, STDOUT_FILENO); // ptr to refcount/fd struct?
WriteLong(Memory, 0x0000a000+32, 0x00000000); //???
WriteLong(Memory, 0x0000a000+36, 0x00000000); //???
// stderr
WriteLong(Memory, 0x0000a000+40, 0x00020000); // ???
WriteLong(Memory, 0x0000a000+44, 0x00003000); // type ptr (FSYS)
WriteLong(Memory, 0x0000a000+48, STDERR_FILENO); // ptr to refcount/fd struct?
WriteLong(Memory, 0x0000a000+52, 0x00000000); //???
WriteLong(Memory, 0x0000a000+56, 0x00000000); //???
WriteWord(Memory, 0xf000, MPW::fQuit);
WriteWord(Memory, 0xf002, 0x4E75); // rts
WriteWord(Memory, 0xf004, MPW::fAccess);
WriteWord(Memory, 0xf006, 0x4E75); // rts
WriteWord(Memory, 0xf008, MPW::fClose);
WriteWord(Memory, 0xf00a, 0x4E75); // rts
WriteWord(Memory, 0xf00c, MPW::fRead);
WriteWord(Memory, 0xf00e, 0x4E75); // rts
WriteWord(Memory, 0xf010, MPW::fWrite);
WriteWord(Memory, 0xf012, 0x4E75); // rts
WriteWord(Memory, 0xf014, MPW::fIOCtl);
WriteWord(Memory, 0xf016, 0x4E75); // rts
// StdDevs (0x78 bytes)
// copied into a $78 byte buffer stored at _IntEnv+20
// this has pointers to read/write functions
// (although the executable has it's own functions as well...)
WriteLong(Memory, address + 0x20, 0x00003000);
WriteLong(Memory, 0x00003000+0, 0x46535953); // 'FSYS'
WriteLong(Memory, 0x00003000+4, 0xf004); //access
WriteLong(Memory, 0x00003000+8, 0xf008); // close
WriteLong(Memory, 0x00003000+12, 0xf00c); // read
WriteLong(Memory, 0x00003000+16, 0xf010); // write
WriteLong(Memory, 0x00003000+20, 0xf014); // ioctl
WriteLong(Memory, 0x00003000+24, 0x45434f4e); // 'ECON'
WriteLong(Memory, 0x00003000+28, 0); //access
WriteLong(Memory, 0x00003000+32, 0); // close
WriteLong(Memory, 0x00003000+36, 0); // read
WriteLong(Memory, 0x00003000+40, 0); // write
WriteLong(Memory, 0x00003000+44, 0); // ioctl
WriteLong(Memory, 0x00003000+48, 0x53595354); // 'SYST'
WriteLong(Memory, 0x00003000+52, 0); //access
WriteLong(Memory, 0x00003000+56, 0); // close
WriteLong(Memory, 0x00003000+60, 0); // read
WriteLong(Memory, 0x00003000+68, 0); // write
WriteLong(Memory, 0x00003000+72, 0); // ioctl
WriteLong(Memory, 0x00003000+76, 0);
WriteLong(Memory, 0x00003000+80, 0);
WriteLong(Memory, 0x00003000+84, 0);
WriteLong(Memory, 0x00003000+88, 0);
WriteLong(Memory, 0x00003000+92, 0);
WriteLong(Memory, 0x00003000+96, 0);
WriteLong(Memory, 0x00003000+100, 0);
WriteLong(Memory, 0x00003000+104, 0);
WriteLong(Memory, 0x00003000+108, 0);
WriteLong(Memory, 0x00003000+112, 0);
WriteLong(Memory, 0x00003000+116, 0);
// _RTInit fills in this location with &_IntEnv.
WriteLong(Memory, address + 0x24, 0x00004000);
WriteLong(Memory, address + 0x28, 0x00005000);
WriteLong(Memory, address + 0x2c, 0x00006000);
// 0x1c should have something, too .... :(
// 0x031a - Lo3Bytes
WriteLong(Memory, 0x031a, 0x00ffffff);
// 0x0a02 - OneOne
WriteLong(Memory, 0x0a02, 0x00010001);
// 0x0a06 - MinusOne
WriteLong(Memory, 0x0a06, 0xffffffff);
// todo -- expects high stack, low heap.
// the allocator currently works from the top down,
// so put stack at top of memory?
// 0x0130 -- ApplLimit
WriteLong(Memory, 0x0130, Flags.ram - 1);
}
#endif
void GlobalInit()
{