Path: blob/master/libmeteor/include/ameteor/graphics/screen.hpp
2 views
// Meteor - A Nintendo Gameboy Advance emulator1// Copyright (C) 2009-2011 Philippe Daouadi2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// This program is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program. If not, see <http://www.gnu.org/licenses/>.1516#ifndef __GRAPHICS_SCREEN_H__17#define __GRAPHICS_SCREEN_H__1819#include "bglayer.hpp"20#include "objects.hpp"21#include "renderer.hpp"2223#include <stdint.h>24#include <istream>25#include <ostream>2627namespace AMeteor28{29namespace Graphics30{31class Screen32{33public :34static const uint8_t WIDTH = 240;35static const uint8_t HEIGHT = 160;3637// we skip x frames every FRMSKIP_TOTAL frames38static const uint8_t FRMSKIP_TOTAL = 10;3940Screen (Memory& memory, Io& io);41~Screen ();4243Renderer& GetRenderer()44{45return m_renderer;46}47const Renderer& GetRenderer() const48{49return m_renderer;50}5152const uint16_t* GetSurface () const53{54return m_surface;55}5657void SetFrameskip (uint8_t skip)58{59m_frameskip = skip;60m_curframe = 0;61}6263void DrawLine (uint8_t line);6465void UpdateDispCnt (uint16_t dispcnt)66{67m_dispcnt = dispcnt;68}6970#define UPDATE_BG_CNT(num) \71void UpdateBg##num##Cnt (uint16_t cnt) \72{ \73m_bgLayer##num.UpdateCnt(cnt); \74}75UPDATE_BG_CNT(0)76UPDATE_BG_CNT(1)77UPDATE_BG_CNT(2)78UPDATE_BG_CNT(3)79#undef UPDATE_BG_CNT8081#define UPDATE_BG_OFF(num, coord) \82void UpdateBg##num##coord##Off (uint16_t off) \83{ \84m_bgLayer##num.Update##coord##Off(off); \85}86UPDATE_BG_OFF(0, X)87UPDATE_BG_OFF(0, Y)88UPDATE_BG_OFF(1, X)89UPDATE_BG_OFF(1, Y)90UPDATE_BG_OFF(2, X)91UPDATE_BG_OFF(2, Y)92UPDATE_BG_OFF(3, X)93UPDATE_BG_OFF(3, Y)94#undef UPDATE_BG_OFF9596#define UPDATE_BG_REF(num, coord) \97void UpdateBg##num##Ref##coord(int32_t x) \98{ \99m_ref##coord##num = (x & (0x1 << 27)) ? x | 0xF0000000 : x & 0x07FFFFFF; \100}101UPDATE_BG_REF(2, X)102UPDATE_BG_REF(2, Y)103UPDATE_BG_REF(3, X)104UPDATE_BG_REF(3, Y)105#undef UPDATE_BG_REF106107void OamWrite (uint32_t begin, uint32_t end)108{109m_objs.OamWrite (begin, end);110}111void OamWrite16 (uint32_t add)112{113m_objs.OamWrite16 (add);114}115void OamWrite32 (uint32_t add)116{117m_objs.OamWrite32 (add);118}119120bool SaveState (std::ostream& stream);121bool LoadState (std::istream& stream);122123private :124Io& m_io;125126uint16_t* m_surface;127128Renderer m_renderer;129130uint8_t m_frameskip, m_curframe;131132uint16_t m_dispcnt;133int32_t m_refX2, m_refY2, m_refX3, m_refY3;134uint16_t* m_pPalette;135136// FIXME is this REALLY useful ?137static BgLayer Screen::* const BgLayers [4];138BgLayer m_bgLayer0, m_bgLayer1, m_bgLayer2, m_bgLayer3;139Objects m_objs;140141void DrawWindow (uint8_t line, uint8_t* surface,142uint16_t win0v, uint16_t win0h, uint8_t mask);143};144}145}146147#endif148149150