add idz repository layer

This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent 6beb3b2343
commit 8817029258
39 changed files with 375 additions and 99 deletions
+15
View File
@@ -0,0 +1,15 @@
export function bitmap(buf: Buffer): number[] {
const result = new Array();
for (let byteNo = 0; byteNo < buf.length; byteNo++) {
const byte = buf.readUInt8(byteNo);
for (let bitNo = 0; bitNo < 8; bitNo++) {
if (byte & (1 << bitNo)) {
result.push(8 * byteNo + bitNo);
}
}
}
return result;
}
+3
View File
@@ -1,3 +1,4 @@
import { BackgroundCode, TitleCode } from "../model/base";
import { Chara } from "../model/chara";
export function chara(buf: Buffer): Chara {
@@ -10,5 +11,7 @@ export function chara(buf: Buffer): Chara {
field_0A: buf.readUInt16LE(0x0a),
field_0C: buf.readUInt16LE(0x0c),
field_0E: buf.readUInt16LE(0x0e),
title: buf.readUInt16LE(0x10) as TitleCode, // Swapped on load
background: buf.readUInt16LE(0x12) as BackgroundCode, // Swapped on load
};
}
+1 -3
View File
@@ -19,8 +19,6 @@ export function createProfile(buf: Buffer): CreateProfileRequest {
),
field_0034: buf.readUInt32LE(0x0034),
car: car(buf.slice(0x0040, 0x00a0)),
chara: chara(buf.slice(0x00a0, 0x00b0)),
field_00B0: buf.readUInt16LE(0x00b0),
field_00B2: buf.readUInt8(0x00b2),
chara: chara(buf.slice(0x00a0, 0x00b4)),
};
}
+2 -1
View File
@@ -1,4 +1,5 @@
import { RequestCode } from "./_defs";
import { AimeId } from "../model/base";
import { DiscoverProfileRequest } from "../request/discoverProfile";
discoverProfile.msgCode = 0x006b as RequestCode;
@@ -7,6 +8,6 @@ discoverProfile.msgLen = 0x0010;
export function discoverProfile(buf: Buffer): DiscoverProfileRequest {
return {
type: "discover_profile_req",
aimeId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}
+2 -1
View File
@@ -1,4 +1,5 @@
import { RequestCode } from "./_defs";
import { AimeId } from "../model/base";
import { LoadProfileRequest } from "../request/loadProfile";
loadProfile.msgCode = 0x0067 as RequestCode;
@@ -7,7 +8,7 @@ loadProfile.msgLen = 0x0020;
export function loadProfile(buf: Buffer): LoadProfileRequest {
return {
type: "load_profile_req",
aimeId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004) as AimeId,
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
};
}
+3 -1
View File
@@ -1,4 +1,6 @@
import { RequestCode } from "./_defs";
import { Id } from "../model/base";
import { Profile } from "../model/profile";
import { LoadStockerRequest } from "../request/loadStocker";
loadStocker.msgCode = 0x00a7 as RequestCode;
@@ -7,6 +9,6 @@ loadStocker.msgLen = 0x0010;
export function loadStocker(buf: Buffer): LoadStockerRequest {
return {
type: "load_stocker_req",
profileId: buf.readUInt32LE(0x0004),
profileId: buf.readUInt32LE(0x0004) as Id<Profile>,
};
}
+3 -1
View File
@@ -1,4 +1,6 @@
import { RequestCode } from "./_defs";
import { Id } from "../model/base";
import { Profile } from "../model/profile";
import { SaveSettingsRequest } from "../request/saveSettings";
saveSettings.msgCode = 0x00a5 as RequestCode;
@@ -11,7 +13,7 @@ export function saveSettings(buf: Buffer): SaveSettingsRequest {
return {
type: "save_settings_req",
profileId: buf.readUInt32LE(0x0004),
profileId: buf.readUInt32LE(0x0004) as Id<Profile>,
dpoint: buf.readUInt32LE(0x0008),
settings: {
bgMusic: buf.readUInt16LE(0x0002),
+7 -1
View File
@@ -1,4 +1,8 @@
import { bitmap } from "./_bitmap";
import { chara } from "./_chara";
import { RequestCode } from "./_defs";
import { BackgroundCode, Id } from "../model/base";
import { Profile } from "../model/profile";
import { SaveStockerRequest } from "../request/saveStocker";
saveStocker.msgCode = 0x00a6 as RequestCode;
@@ -7,6 +11,8 @@ saveStocker.msgLen = 0x00c0;
export function saveStocker(buf: Buffer): SaveStockerRequest {
return {
type: "save_stocker_req",
profileId: buf.readUInt32LE(0x0004),
profileId: buf.readUInt32LE(0x0004) as Id<Profile>,
backgrounds: bitmap(buf.slice(0x0008, 0x002c)) as BackgroundCode[],
chara: chara(buf.slice(0x009e, 0x00b2)),
};
}