mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-24 13:32:39 +00:00
GetIntlResource stub, move pack6 to its own file.
This commit is contained in:
parent
bfc36cb872
commit
ab6259c030
@ -21,6 +21,7 @@ set(TOOLBOX_SRC
|
||||
qd.cpp
|
||||
sane.cpp
|
||||
saneparser.cpp
|
||||
packages.cpp
|
||||
pathnames.cpp
|
||||
process.cpp
|
||||
utility.cpp
|
||||
|
@ -954,57 +954,6 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Trap Manager
|
||||
|
161
toolbox/packages.cpp
Normal file
161
toolbox/packages.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Kelvin W Sherlock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cerrno>
|
||||
#include <cctype>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
#include <cpu/fmem.h>
|
||||
|
||||
#include <macos/sysequ.h>
|
||||
#include <macos/errors.h>
|
||||
#include <macos/traps.h>
|
||||
|
||||
#include "toolbox.h"
|
||||
#include "stackframe.h"
|
||||
#include "os.h"
|
||||
#include "packages.h"
|
||||
|
||||
using ToolBox::Log;
|
||||
using OS::MacToUnix;
|
||||
|
||||
namespace Packages {
|
||||
|
||||
|
||||
uint16_t IUDateString()
|
||||
{
|
||||
// void IUDateString(long dateTime,DateForm longFlag,Str255 result)
|
||||
// DateForm doesn't seem to do anything.
|
||||
|
||||
char buffer[256];
|
||||
int length;
|
||||
std::string out;
|
||||
|
||||
uint32_t dateTime;
|
||||
uint8_t flag;
|
||||
uint32_t result;
|
||||
|
||||
|
||||
StackFrame<10>(dateTime, flag, result);
|
||||
|
||||
Log(" IUDateString(%08x, %02x, %08x)\n", dateTime, flag, result);
|
||||
|
||||
time_t t = MacToUnix(dateTime);
|
||||
struct tm *tm = ::localtime(&t);
|
||||
|
||||
// not strictly correct -- uses %d/%d/%2d form.
|
||||
length = std::strftime(buffer, sizeof(buffer), "%m/%d/%y", tm);
|
||||
out.assign(buffer, length);
|
||||
|
||||
ToolBox::WritePString(result, out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t IUTimeString()
|
||||
{
|
||||
// void IUTimeString(long dateTime,Boolean wantSeconds,Str255 result)
|
||||
// output: 12:00:00 AM or 12:00 AM
|
||||
|
||||
char buffer[256];
|
||||
int length;
|
||||
std::string out;
|
||||
|
||||
uint32_t dateTime;
|
||||
uint8_t wantSeconds;
|
||||
uint32_t result;
|
||||
|
||||
|
||||
StackFrame<10>(dateTime, wantSeconds, result);
|
||||
Log(" IUTimeString(%08x, %02x, %08x)\n", dateTime, wantSeconds, result);
|
||||
|
||||
time_t t = MacToUnix(dateTime);
|
||||
struct tm *tm = ::localtime(&t);
|
||||
|
||||
length = std::strftime(buffer, sizeof(buffer), wantSeconds ? "%I:%M:%S %p" : "%I:%M %p", tm);
|
||||
|
||||
out.assign(buffer, length);
|
||||
|
||||
ToolBox::WritePString(result, out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t GetIntlResource()
|
||||
{
|
||||
// FUNCTION GetIntlResource (theID: Integer) :Handle;
|
||||
|
||||
// todo -- actually load the resource
|
||||
|
||||
/*
|
||||
* theID Contains an integer (0, 1, 2, 4, or 5 respectively for
|
||||
* the 'itl0', 'itl1', 'itl2', 'itl4', and 'itl5'resources) to
|
||||
* identify the type of the desired international resource.
|
||||
*/
|
||||
|
||||
|
||||
uint16_t theID;
|
||||
|
||||
uint32_t sp = StackFrame<2>(theID);
|
||||
|
||||
Log(" GetIntlResource(%04x)\n", theID);
|
||||
|
||||
ToolReturn<4>(sp, 0);
|
||||
return 0; // should set res error.
|
||||
}
|
||||
|
||||
uint16_t Pack6(uint16_t trap)
|
||||
{
|
||||
|
||||
uint16_t selector;
|
||||
StackFrame<2>(selector);
|
||||
|
||||
Log("%04x Pack6(%04x)\n", trap, selector);
|
||||
|
||||
switch(selector)
|
||||
{
|
||||
case 0x0000:
|
||||
return IUDateString();
|
||||
case 0x0002:
|
||||
return IUTimeString();
|
||||
case 0x0006:
|
||||
return GetIntlResource();
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Pack6: selector %04x not supported\n", selector);
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
27
toolbox/packages.h
Normal file
27
toolbox/packages.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef __mpw_packages_h__
|
||||
#define __mpw_packages_h__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Packages {
|
||||
|
||||
uint16_t Pack0(uint16_t);
|
||||
uint16_t Pack1(uint16_t);
|
||||
uint16_t Pack2(uint16_t);
|
||||
uint16_t Pack3(uint16_t);
|
||||
uint16_t Pack4(uint16_t);
|
||||
uint16_t Pack5(uint16_t);
|
||||
uint16_t Pack6(uint16_t);
|
||||
uint16_t Pack7(uint16_t);
|
||||
uint16_t Pack8(uint16_t);
|
||||
uint16_t Pack9(uint16_t);
|
||||
uint16_t Pack10(uint16_t);
|
||||
uint16_t Pack11(uint16_t);
|
||||
uint16_t Pack12(uint16_t);
|
||||
uint16_t Pack13(uint16_t);
|
||||
uint16_t Pack14(uint16_t);
|
||||
uint16_t Pack15(uint16_t);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -51,7 +51,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// yuck. TST.W d0
|
||||
extern "C" void cpuSetFlagsNZ00NewW(UWO res);
|
||||
|
||||
@ -376,7 +375,7 @@ namespace ToolBox {
|
||||
|
||||
|
||||
case 0xa9ed:
|
||||
d0 = OS::Pack6(trap);
|
||||
d0 = Packages::Pack6(trap);
|
||||
break;
|
||||
|
||||
//_CmpString [MARKS,CASE]
|
||||
|
Loading…
Reference in New Issue
Block a user