|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // LUNA LCD パネル
9: //
10:
11: #include "wxlcdwindow.h"
12: #include "wxcolor.h"
1.1.1.4 root 13: #include "wxuimessage.h"
1.1 root 14: #include "lcd.h"
15:
16: // パネルの大きさ (定数)
17: // N はとりあえずの倍率。
18: #define N (2)
19: #define PANEL_WIDTH ((N) * (5 + 1) * 16 + 1)
20: #define PANEL_HEIGHT ((N) * (8 + 1) * 2 + 1)
21:
22: //
23: // LUNA LCD パネル
24: //
25:
26: // コンストラクタ
27: WXLCDPanel::WXLCDPanel(wxWindow *parent)
1.1.1.5 root 28: : inherited(parent, wxSize(PANEL_WIDTH, PANEL_HEIGHT))
1.1 root 29: {
30: ddram = gLCD->GetDDRAM();
31:
1.1.1.4 root 32: // VM からの通知を受け取る
33: WXUIMessage::Connect(UIMessage::LCD, this,
34: wxCommandEventHandler(WXLCDPanel::OnLCDChanged));
1.1.1.5 root 35:
36: SetBitmapBGColor(UD_CREAM);
1.1 root 37: }
38:
39: // デストラクタ
40: WXLCDPanel::~WXLCDPanel()
41: {
1.1.1.4 root 42: WXUIMessage::Disconnect(UIMessage::LCD,
43: wxCommandEventHandler(WXLCDPanel::OnLCDChanged));
1.1 root 44: }
45:
1.1.1.4 root 46: // LCD 状態変更イベント (UIMessage)
1.1 root 47: void
1.1.1.4 root 48: WXLCDPanel::OnLCDChanged(wxCommandEvent& event)
1.1 root 49: {
1.1.1.4 root 50: Refresh();
1.1 root 51: }
52:
53: // バックグラウンドバッファに描画
54: void
1.1.1.5 root 55: WXLCDPanel::Draw()
1.1 root 56: {
57: for (int y = 0; y < 2; y++) {
58: for (int x = 0; x < 16; x++) {
59: uint8 ch = ddram[0x40 * y + x];
1.1.1.5 root 60: DrawChar(x, y, ch);
1.1 root 61: }
62: }
63: }
64:
65: // 1文字描画
66: void
1.1.1.5 root 67: WXLCDPanel::DrawChar(int x, int y, uint8 ch)
1.1 root 68: {
1.1.1.5 root 69: const Color pal[2] = { UD_YELLOW_GREEN, UD_BROWN };
1.1 root 70: const uint8 *font;
71:
72: font = gLCD->GetFont(ch);
1.1.1.5 root 73: BitmapI1 src(font, 5, 8);
1.1 root 74:
1.1.1.5 root 75: bitmap.DrawScaleUp((1 + x * 6) * N, (1 + y * 9) * N, N, src, pal);
1.1 root 76: }
77:
1.1.1.5 root 78:
1.1 root 79: //
80: // LCD ウィンドウ
81: //
82:
83: // コンストラクタ
1.1.1.3 root 84: WXLCDWindow::WXLCDWindow(wxWindow *parent)
85: : inherited(parent, wxID_ANY, _("Front LCD"))
1.1 root 86: {
87: panel = new WXLCDPanel(this);
88:
1.1.1.5 root 89: DoSize();
1.1 root 90: }
91:
92: // デストラクタ
93: WXLCDWindow::~WXLCDWindow()
94: {
95: }
96:
1.1.1.5 root 97:
1.1 root 98: //
99: // LCD キャラクタパネル
100: //
101:
1.1.1.5 root 102: #define PAD (1)
103: #define CP_WIDTH (N * (PAD + 6 * (16 + 1 + 16) + PAD))
104: #define CP_HEIGHT (N * (PAD + 9 * 8 + PAD))
1.1 root 105:
106: // コンストラクタ
107: WXLCDCharPanel::WXLCDCharPanel(wxWindow *parent)
1.1.1.2 root 108: : inherited(parent, wxSize(CP_WIDTH, CP_HEIGHT))
1.1 root 109: {
110: }
111:
112: // デストラクタ
113: WXLCDCharPanel::~WXLCDCharPanel()
114: {
115: }
116:
117: // バックグラウンドバッファに描画
118: void
1.1.1.5 root 119: WXLCDCharPanel::Draw()
1.1 root 120: {
1.1.1.5 root 121: const Color pal[2] = { UD_WHITE, UD_BLACK };
1.1 root 122:
123: // フォントは 5x8 (最下行はカーソル用に空けてあるので実際は 5x7)。
124: // 実際には 0xe0 以降には 5x10 フォントが混在しているのだが、その
125: // モードはサポートしていないので今の所全部 5x8 としてある。
126:
1.1.1.2 root 127: // cx, cy はこの文字の左上座標 (スケール前)
1.1.1.5 root 128: int cx = PAD;
129: int cy = PAD;
1.1.1.2 root 130: for (int ch = 0; ch < 256; ch++) {
1.1 root 131: const uint8 *font = gLCD->GetFont(ch);
1.1.1.5 root 132: BitmapI1 src(font, 5, 8);
133: bitmap.DrawScaleUp(cx * N, cy * N, N, src, pal);
1.1.1.2 root 134:
135: cx += 6;
136: if (ch % 16 == 15) {
137: // 行折り返し
138: cx -= 6 * 16;
139: cy += 9;
140: // 0x80 以降は右側に作る
141: if (ch == 127) {
142: cx += 6 * (16 + 1/*中央の余白*/);
143: cy = 1;
144: }
145: }
1.1 root 146: }
147: }
148:
1.1.1.5 root 149:
1.1 root 150: //
151: // LCD モニタウィンドウ
152: //
153:
154: // コンストラクタ
1.1.1.3 root 155: WXLCDMonitor::WXLCDMonitor(wxWindow *parent)
156: : inherited(parent, wxID_ANY, _("LCD"))
1.1 root 157: {
1.1.1.5 root 158: // +------------+
159: // | TextScreen |
160: // +------------+
161: // | CharPanel |
162: // +------------+
163: auto *topsizer = new wxBoxSizer(wxVERTICAL);
164:
165: // 上段、テキストスクリーン
1.1.1.6 ! root 166: monpanel = new WXMonitorPanel(this, gMonitorManager->Get(ID_MONITOR_LCD));
1.1.1.5 root 167: // 下辺は CharPanel の上余白が隣接しているため、自分のほうは付けない。
168: monpanel->SetPadding(-1, -1, -1, 0);
169: topsizer->Add(monpanel, 0, wxEXPAND);
1.1 root 170:
1.1.1.5 root 171: // 下段、キャラクタパネル
1.1 root 172: chrpanel = new WXLCDCharPanel(this);
1.1.1.5 root 173: topsizer->Add(chrpanel, 0, wxEXPAND);
1.1 root 174:
175: SetSizer(topsizer);
176:
177: // 大きさをそれに固定
1.1.1.5 root 178: SetClientSize(GetSizer()->GetMinSize());
1.1 root 179: }
180:
181: // デストラクタ
182: WXLCDMonitor::~WXLCDMonitor()
183: {
184: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.