mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
Pack6 support (very limited)
This commit is contained in:
parent
5c00dc1ca5
commit
8235193554
@ -1,6 +1,7 @@
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <cctype>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
@ -683,5 +684,57 @@ namespace OS
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t Pack6(uint16_t trap)
|
||||
{
|
||||
char buffer[256];
|
||||
int length;
|
||||
std::string out;
|
||||
|
||||
uint32_t dateTime;
|
||||
uint16_t flag;
|
||||
uint32_t result;
|
||||
uint16_t selector;
|
||||
|
||||
// todo -- variable number of args. Pop selector, act from that.
|
||||
|
||||
StackFrame<12>(dateTime, flag, result, selector);
|
||||
|
||||
Log("%04x Pack6(%08x, %04x, %08x, %04x)\n",
|
||||
trap, dateTime, flag, result, selector);
|
||||
|
||||
struct tm *tm;
|
||||
time_t t;
|
||||
t = MacToUnix(dateTime);
|
||||
|
||||
tm = ::localtime(&t);
|
||||
|
||||
if (selector == 0x00)
|
||||
{
|
||||
// void IUDateString(long dateTime,DateForm longFlag,Str255 result)
|
||||
// DateForm doesn't seem to do anything.
|
||||
|
||||
// not strictly correct -- uses %d/%d/%2d form.
|
||||
length = std::strftime(buffer, sizeof(buffer), "%m/%d/%y", tm);
|
||||
out.assign(buffer, length);
|
||||
}
|
||||
else if (selector == 0x02)
|
||||
{
|
||||
// void IUTimeString(long dateTime,Boolean wantSeconds,Str255 result)
|
||||
// output: 12:00:00 AM or 12:00 AM
|
||||
|
||||
length = std::strftime(buffer, sizeof(buffer), flag ? "%I:%M:%S %p" : "%I:%M %p", tm);
|
||||
|
||||
out.assign(buffer, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Pack6: selector %04x not supported\n", selector);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ToolBox::WritePString(result, out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -127,6 +127,7 @@ namespace OS
|
||||
#pragma mark - Time Utilities
|
||||
uint16_t ReadDateTime(uint16_t trap);
|
||||
uint16_t SecondsToDate(uint16_t trap);
|
||||
uint16_t Pack6(uint16_t trap);
|
||||
|
||||
uint16_t TickCount(uint16_t trap);
|
||||
|
||||
|
@ -113,6 +113,10 @@ namespace ToolBox {
|
||||
d0 = OS::TickCount(trap);
|
||||
break;
|
||||
|
||||
case 0xa9ed:
|
||||
d0 = OS::Pack6(trap);
|
||||
break;
|
||||
|
||||
//_CmpString [MARKS,CASE]
|
||||
case 0xa03c:
|
||||
case 0xa23c:
|
||||
|
Loading…
Reference in New Issue
Block a user