Annotation of nono/vm/videoctlr.h, revision 1.1.1.9

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"
        !            17: #include "planevram.h"
1.1.1.8   root       18: #include <array>
                     19: 
                     20: class Renderer;
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.9 ! root       35:        busdata Read8(uint32 addr) override;
        !            36:        busdata Read16(uint32 addr) override;
        !            37:        busdata Write8(uint32 addr, uint32 data) override;
        !            38:        busdata Write16(uint32 addr, uint32 data) override;
        !            39:        busdata Peek8(uint32 addr) override;
        !            40:        bool Poke8(uint32 addr, uint32 data) override;
        !            41: 
        !            42:        // コントラストを取得 (Peek() からも呼ぶので副作用を起こしてはいけない)
        !            43:        int GetContrast() const { return (int)(target_contrast / 0x11); }
        !            44:        // コントラストを設定
        !            45:        void SetContrast(int);
        !            46: 
        !            47:        // 画面合成
        !            48:        bool Render(BitmapRGBX& dst, ModifyInfo&);
        !            49: 
1.1.1.2   root       50:        // 加工済みテキストパレットの先頭アドレスを取得
                     51:        // レンダラとかからの参照用
1.1.1.8   root       52:        const std::vector<ColorXBGR>& GetHostPalette() const { return hostcolor; }
                     53: 
                     54:        // 生パレットを uint32 形式にしたものを返す (GUI 用)
                     55:        const std::vector<uint32> GetIntPalette() const;
1.1       root       56: 
                     57:  private:
1.1.1.8   root       58:        inline uint32 Decoder(uint32 addr) const;
                     59:        inline uint Offset2NR(uint32 offset) const;
                     60: 
                     61:        uint32 GetNR(uint reg) const;
                     62:        void SetNR(uint reg, uint32 data);
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
        !            70: 
        !            71:        void ContrastCallback(Event& ev);
1.1       root       72: 
1.1.1.8   root       73:        // ワードレジスタ R0, R1, R2 は内部では nr0 .. nr5 というバイトレジスタ
                     74:        // として扱う。
                     75:        std::array<uint8, 6> nreg {};
                     76: 
1.1.1.9 ! root       77:        // テキスト画面
        !            78:        BitmapRGBX textbmp {};
        !            79: 
1.1.1.8   root       80:        // メモリを確保する時のサイズ計算のため型を uint8 にしているが、
                     81:        // 運用はワードでホストバイトオーダー。
                     82:        std::array<uint8, 1024> palette {};
1.1.1.2   root       83: 
1.1.1.7   root       84:        // ホスト形式のテキストパレット (レンダラ用に加工したもの)
1.1.1.8   root       85:        std::vector<ColorXBGR> hostcolor {};
                     86: 
1.1.1.9 ! root       87:        // 設定したコントラスト値 (0-255)
        !            88:        uint32 target_contrast {};
        !            89:        // 現在の (遷移中かもしれない) コントラスト値 (0-255)
        !            90:        uint32 running_contrast {};
        !            91:        // 設定を変える時の初期値 (0-255)
        !            92:        uint32 initial_contrast {};
        !            93:        // 設定を変える時の起点
        !            94:        uint64 contrast_time0 {};
        !            95: 
        !            96:        // レンダリングに使っているコントラスト値 (0-255)
        !            97:        uint32 rendering_contrast {};
        !            98: 
        !            99:        Event contrast_event { this };
        !           100: 
        !           101:        PlaneVRAMDevice *planevram {};
1.1.1.8   root      102:        Renderer *renderer {};
1.1       root      103: };
                    104: 
1.1.1.8   root      105: static inline VideoCtlrDevice *GetVideoCtlrDevice() {
                    106:        return Object::GetObject<VideoCtlrDevice>(OBJ_VIDEOCTLR);
                    107: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.