|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #include "object.h"
8: #include "logger.h"
9: #include "mpu.h"
10: #include "textscreen.h"
11:
12: // 全オブジェクトのリスト
13: std::vector<Object*> gObjects;
14:
15: // コンストラクタ
16: Object::Object()
17: {
18: logname = "?";
19: devname = "?";
20:
21: // 自分自身をリストに繋ぐ
22: gObjects.push_back(this);
23: }
24:
25: // デストラクタ
26: Object::~Object()
27: {
28: }
29:
30: // メッセージ表示
31: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
32: void
1.1.1.6 ! root 33: Object::putmsgn(const char *fmt, ...) const
1.1 root 34: {
1.1.1.2 root 35: char buf[1024];
1.1 root 36: int len;
1.1.1.6 ! root 37: va_list ap;
1.1 root 38:
39: // デバイス名だけ生表示されても分かりづらいので括弧でもつけておく
1.1.1.3 root 40: len = snprintf(buf, sizeof(buf), "(%s) ", devname.c_str());
1.1.1.6 ! root 41: va_start(ap, fmt);
1.1.1.2 root 42: vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
1.1.1.6 ! root 43: va_end(ap);
! 44:
1.1.1.3 root 45: gLogger.Write(buf);
1.1 root 46: }
47:
48: // ログ出力 (可変引数)
49: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
50: void
1.1.1.6 ! root 51: Object::putlogn(const char *fmt, ...) const
1.1 root 52: {
1.1.1.2 root 53: char buf[1024];
1.1.1.6 ! root 54: va_list ap;
1.1 root 55: uint64 vt;
56: int len = 0;
57:
1.1.1.5 root 58: vt = gMPU->GetVirtTime();
1.1.1.2 root 59: len += snprintf(buf + len, sizeof(buf) - len, "%4d.%03d'%03d'%03d ",
1.1 root 60: (int)(vt / 1000 / 1000 / 1000),
61: (int)((vt / 1000 / 1000) % 1000),
62: (int)((vt / 1000) % 1000),
63: (int)(vt % 1000));
64:
1.1.1.2 root 65: len += snprintf(buf + len, sizeof(buf) - len, "%08x %s ",
1.1.1.3 root 66: gMPU->GetPPC(), devname.c_str());
1.1.1.6 ! root 67:
! 68: va_start(ap, fmt);
1.1.1.2 root 69: vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
1.1.1.6 ! root 70: va_end(ap);
1.1 root 71:
1.1.1.3 root 72: gLogger.Write(buf);
1.1 root 73: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.