cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

Video.h (2518B)


      1/*
      2 * Gearboy - Nintendo Game Boy Emulator
      3 * Copyright (C) 2012  Ignacio Sanchez
      4
      5 * This program is free software: you can redistribute it and/or modify
      6 * it under the terms of the GNU General Public License as published by
      7 * the Free Software Foundation, either version 3 of the License, or
      8 * any later version.
      9
     10 * This program is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13 * GNU General Public License for more details.
     14
     15 * You should have received a copy of the GNU General Public License
     16 * along with this program.  If not, see http://www.gnu.org/licenses/
     17 *
     18 */
     19
     20#ifndef VIDEO_H
     21#define	VIDEO_H
     22
     23#include "definitions.h"
     24
     25class Memory;
     26class Processor;
     27
     28typedef u16 (*PaletteMatrix)[8][4][2];
     29
     30class Video
     31{
     32public:
     33    Video(Memory* pMemory, Processor* pProcessor);
     34    ~Video();
     35    void Init();
     36    void Reset(bool bCGB);
     37    bool Tick(unsigned int &clockCycles, u16* pColorFrameBuffer, GB_Color_Format pixelFormat);
     38    void EnableScreen();
     39    void DisableScreen();
     40    bool IsScreenEnabled() const;
     41    const u8* GetFrameBuffer() const;
     42    void UpdatePaletteToSpecification(bool background, u8 value);
     43    void SetColorPalette(bool background, u8 value);
     44    int GetCurrentStatusMode() const;
     45    void ResetWindowLine();
     46    void CompareLYToLYC();
     47    u8 GetIRQ48Signal() const;
     48    void SetIRQ48Signal(u8 signal);
     49    void SaveState(std::ostream& stream);
     50    void LoadState(std::istream& stream);
     51    PaletteMatrix GetCGBBackgroundPalettes();
     52    PaletteMatrix GetCGBSpritePalettes();
     53
     54private:
     55    void ScanLine(int line);
     56    void RenderBG(int line, int pixel);
     57    void RenderWindow(int line);
     58    void RenderSprites(int line);
     59    void UpdateStatRegister();
     60
     61private:
     62    Memory* m_pMemory;
     63    Processor* m_pProcessor;
     64    u8* m_pFrameBuffer;
     65    u16* m_pColorFrameBuffer;
     66    int* m_pSpriteXCacheBuffer;
     67    u8* m_pColorCacheBuffer;
     68    int m_iStatusMode;
     69    int m_iStatusModeCounter;
     70    int m_iStatusModeCounterAux;
     71    int m_iStatusModeLYCounter;
     72    int m_iScreenEnableDelayCycles;
     73    int m_iStatusVBlankLine;
     74    int m_iPixelCounter;
     75    int m_iTileCycleCounter;
     76    bool m_bScreenEnabled;
     77    bool m_bCGB;
     78    u16 m_CGBSpritePalettes[8][4][2];
     79    u16 m_CGBBackgroundPalettes[8][4][2];
     80    bool m_bScanLineTransfered;
     81    int m_iWindowLine;
     82    int m_iHideFrames;
     83    u8 m_IRQ48Signal;
     84    GB_Color_Format m_pixelFormat;
     85};
     86
     87#endif	/* VIDEO_H */