|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
1.1.1.7 root 7: //
8: // ビデオコントローラ
9: //
10:
1.1 root 11: #pragma once
12:
13: #include "device.h"
1.1.1.9 root 14: #include "bitmap.h"
1.1.1.7 root 15: #include "color.h"
1.1.1.9 root 16: #include "event.h"
1.1.1.10! root 17: #include "renderer.h"
1.1.1.8 root 18: #include <array>
19:
1.1.1.10! root 20: class PlaneVRAMDevice;
1.1 root 21:
1.1.1.6 root 22: class VideoCtlrDevice : public IODevice
1.1 root 23: {
24: using inherited = IODevice;
1.1.1.7 root 25:
1.1.1.8 root 26: static const uint32 baseaddr = 0xe82000;
1.1 root 27:
28: public:
29: VideoCtlrDevice();
1.1.1.9 root 30: ~VideoCtlrDevice() override;
1.1 root 31:
1.1.1.8 root 32: bool Init() override;
1.1.1.7 root 33: void ResetHard(bool poweron) override;
1.1.1.3 root 34:
1.1.1.10! root 35: busdata Read(busaddr addr) override;
! 36: busdata Write(busaddr addr, uint32 data) override;
! 37: busdata Peek1(uint32 addr) override;
! 38: bool Poke1(uint32 addr, uint32 data) override;
1.1.1.9 root 39:
40: // コントラストを取得 (Peek() からも呼ぶので副作用を起こしてはいけない)
1.1.1.10! root 41: uint GetContrast() const { return target_contrast / 0x11; }
1.1.1.9 root 42: // コントラストを設定
1.1.1.10! root 43: void SetContrast(uint);
1.1.1.9 root 44:
45: // 画面合成
1.1.1.10! root 46: bool Render(BitmapRGBX& dst, const ModifyInfo&);
1.1.1.9 root 47:
1.1.1.2 root 48: // 加工済みテキストパレットの先頭アドレスを取得
49: // レンダラとかからの参照用
1.1.1.10! root 50: const std::vector<Color>& GetHostPalette() const { return hostcolor; }
1.1.1.8 root 51:
52: // 生パレットを uint32 形式にしたものを返す (GUI 用)
53: const std::vector<uint32> GetIntPalette() const;
1.1 root 54:
55: private:
1.1.1.10! root 56: static inline uint32 Decoder(uint32 addr);
! 57: static inline uint Offset2Rn(uint32 offset);
! 58:
! 59: uint32 Get16(uint32 offset) const;
! 60: void Set8(uint32 offset, uint32 data);
! 61: void Set16(uint32 offset, uint32 data);
1.1.1.8 root 62:
1.1.1.2 root 63: void MakePalette();
1.1.1.9 root 64: void RenderContrast(BitmapRGBX& dst, const BitmapRGBX& src);
65: static void RenderContrast_gen(BitmapRGBX&, const BitmapRGBX&, uint32);
66: #if defined(HAVE_AVX2)
67: static void RenderContrast_avx2(BitmapRGBX&, const BitmapRGBX&, uint32);
68: bool enable_avx2 {};
69: #endif
1.1.1.10! root 70: #if defined(HAVE_NEON)
! 71: static void RenderContrast_neon(BitmapRGBX&, const BitmapRGBX&, uint32);
! 72: bool enable_neon {};
! 73: #endif
1.1.1.9 root 74:
75: void ContrastCallback(Event& ev);
1.1 root 76:
1.1.1.10! root 77: // ワードレジスタ R0, R1, R2
! 78: std::array<uint16, 3> reg {};
1.1.1.8 root 79:
1.1.1.9 root 80: // テキスト画面
81: BitmapRGBX textbmp {};
82:
1.1.1.10! root 83: // パレット (ホストバイトオーダー)
! 84: std::array<uint16, 512> palette {};
1.1.1.2 root 85:
1.1.1.7 root 86: // ホスト形式のテキストパレット (レンダラ用に加工したもの)
1.1.1.10! root 87: std::vector<Color> hostcolor {};
1.1.1.8 root 88:
1.1.1.9 root 89: // 設定したコントラスト値 (0-255)
90: uint32 target_contrast {};
91: // 現在の (遷移中かもしれない) コントラスト値 (0-255)
92: uint32 running_contrast {};
93: // 設定を変える時の初期値 (0-255)
94: uint32 initial_contrast {};
95: // 設定を変える時の起点
96: uint64 contrast_time0 {};
97:
98: // レンダリングに使っているコントラスト値 (0-255)
99: uint32 rendering_contrast {};
100:
101: Event contrast_event { this };
102:
103: PlaneVRAMDevice *planevram {};
1.1.1.8 root 104: Renderer *renderer {};
1.1 root 105: };
106:
1.1.1.8 root 107: static inline VideoCtlrDevice *GetVideoCtlrDevice() {
108: return Object::GetObject<VideoCtlrDevice>(OBJ_VIDEOCTLR);
109: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.