V-Gears 0
Free Final Fantasy VII engine.
Vram.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears 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
16#pragma once
17
18#include <memory>
19#include "common/TypeDefine.h"
21
27class Vram{
28
29 public:
30
36 static std::unique_ptr<Vram> MakeInstance(){return std::unique_ptr<Vram>(new Vram());}
37
41 virtual ~Vram();
42
48 u16 GetWidth() const;
49
55 u16 GetHeight() const;
56
62 void Save(const Ogre::String& file);
63
64 // TODO: Where is this implemented?:
74 void AddImageBuffer(u16 x, u16 y, u16 width, u16 height, u8* buffer);
75
83 void PutU8(u16 x, u16 y, u8 byte);
84
92 u8 GetU8(u16 x, u16 y) const;
93
101 void PutU16(u16 x, u16 y, u16 bytes);
102
110 u16 GetU16(u16 x, u16 y) const;
111
112 private:
113
117 Vram();
118
122 u8 vram_[2048 * 512];
123
128
133};
Ogre::uint16 u16
Definition: TypeDefine.h:22
Ogre::uint8 u8
Definition: TypeDefine.h:21
Emulates a VRAM block.
Definition: Vram.h:27
void AddImageBuffer(u16 x, u16 y, u16 width, u16 height, u8 *buffer)
Adds an image buffer to an existing buffer.
u16 height_
The VRAM block height.
Definition: Vram.h:132
static std::unique_ptr< Vram > MakeInstance()
Creates a VRAM block.
Definition: Vram.h:36
void PutU8(u16 x, u16 y, u8 byte)
Writes 8 bytes to the VRAM block.
Definition: Vram.cpp:54
u8 vram_[2048 *512]
The data block.
Definition: Vram.h:122
void Save(const Ogre::String &file)
Saves the contents of the VRAM block to a file.
Definition: Vram.cpp:29
u16 width_
The VRAM block width.
Definition: Vram.h:127
void PutU16(u16 x, u16 y, u16 bytes)
Writes 16 bytes to the VRAM block.
Definition: Vram.cpp:76
Vram()
Constructor.
Definition: Vram.cpp:21
u16 GetU16(u16 x, u16 y) const
Reads 16 bytes from the VRAM block.
Definition: Vram.cpp:89
u16 GetHeight() const
Retrieves the block width.
Definition: Vram.cpp:27
u16 GetWidth() const
Retrieves the block width.
Definition: Vram.cpp:25
u8 GetU8(u16 x, u16 y) const
Reads 8 bytes from the VRAM block.
Definition: Vram.cpp:65
virtual ~Vram()
Destructor.
Definition: Vram.cpp:23
Ogre::String String
Definition: TypeDefine.h:37