Annotation of nono/vm/gvram.h, revision 1.1.1.11

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: 
1.1.1.6   root        7: //
                      8: // GVRAM
                      9: //
                     10: 
1.1       root       11: #pragma once
                     12: 
                     13: #include "device.h"
1.1.1.11! root       14: #include "bitmap.h"
        !            15: #include <bitset>
        !            16: #include <mutex>
        !            17: 
        !            18: class VideoCtlrDevice;
1.1       root       19: 
1.1.1.5   root       20: class GVRAMDevice : public IODevice
1.1       root       21: {
1.1.1.3   root       22:        using inherited = IODevice;
1.1.1.11! root       23: 
        !            24:        using bitset1024 = std::bitset<1024>;
        !            25: 
1.1.1.9   root       26:        static const uint32 baseaddr = 0xc0'0000;
1.1.1.11! root       27: 
        !            28:        // 更新情報。
        !            29:        struct ModifyInfo
        !            30:        {
        !            31:                // 1ライン単位の更新フラグ。
        !            32:                bitset1024 line {};
        !            33: 
        !            34:                // パレットを更新した場合やスクロールした場合のように、
        !            35:                // composite に変更がなくても bitmap を更新する必要がある場合は true。
        !            36:                bool invalidate2 {};
        !            37:        };
        !            38: 
1.1       root       39:  public:
                     40:        GVRAMDevice();
1.1.1.8   root       41:        ~GVRAMDevice() override;
1.1       root       42: 
1.1.1.10  root       43:        bool Init() override;
1.1.1.11! root       44:        void ResetHard(bool poweron) override;
1.1.1.10  root       45: 
1.1.1.9   root       46:        busdata Read(busaddr addr) override;
                     47:        busdata Write(busaddr addr, uint32 data) override;
                     48:        busdata Peek1(uint32 addr) override;
1.1.1.11! root       49:        bool Poke1(uint32 addr, uint32 data) override;
        !            50: 
        !            51:        bool Snap();
        !            52:        bool Render(BitmapRGBX& dst);
        !            53: 
        !            54:        // インデックスカラーのビットマップを取得する。(モニタ用)
        !            55:        const BitmapI8& GetComposite() const { return composite; }
        !            56: 
        !            57:        // グラフィック画面の座標位置の情報を出力 (GUI 用)
        !            58:        void UpdateInfo(TextScreen& screen, int x, int y) const;
1.1       root       59: 
                     60:  private:
1.1.1.9   root       61:        inline uint32 Decoder(uint32 addr) const;
                     62: 
1.1.1.11! root       63:        void Invalidate();
        !            64:        inline void SetDirty(uint32 offset);
        !            65: 
        !            66:        void Render1024ToComposite(const bitset1024& modified);
        !            67:        void RenderCompositeToRGBX(BitmapRGBX& dst, const ModifyInfo& modified);
        !            68: 
        !            69:        // メモリを確保する時のサイズ計算のため型を uint8 にしているが、
        !            70:        // 運用はワードでホストバイトオーダー。
1.1.1.2   root       71:        std::unique_ptr<uint8[]> mem {};
1.1.1.11! root       72: 
        !            73:        // グラフィック画面(1024x1024, 16色)のビットマップ。
        !            74:        BitmapI8 composite {};
        !            75: 
        !            76:        // VM スレッド内での仮想画面の更新フラグ。
        !            77:        ModifyInfo dirty {};
        !            78: 
        !            79:        // レンダラスレッドで未処理の行。
        !            80:        // VM スレッドからレンダラスレッドへの連絡用なので mtx で保護する。
        !            81:        ModifyInfo pending {};
        !            82:        std::mutex mtx {};
        !            83: 
        !            84:        // ホストパレット
        !            85:        const Color *palette {};
        !            86: 
        !            87:        VideoCtlrDevice *videoctlr {};
        !            88: 
        !            89:        static const busdata wait;
1.1       root       90: };
1.1.1.11! root       91: 
        !            92: static inline GVRAMDevice *GetGVRAMDevice() {
        !            93:        return Object::GetObject<GVRAMDevice>(OBJ_GVRAM);
        !            94: }

unix.superglobalmegacorp.com

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