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