2015-07-01 23:17:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
#include "stdafx.h"
|
2014-06-19 17:06:00 -04:00
|
|
|
#include "../Core/IVideoDevice.h"
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "../Core/IMessageManager.h"
|
2014-07-10 21:17:37 -04:00
|
|
|
#include "../Utilities/FolderUtilities.h"
|
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-07-14 21:51:39 -04:00
|
|
|
#include "../Utilities/Timer.h"
|
2014-06-12 21:48:04 -04:00
|
|
|
|
|
|
|
using namespace DirectX;
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
namespace DirectX {
|
|
|
|
class SpriteBatch;
|
|
|
|
class SpriteFont;
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
namespace NES {
|
2014-07-06 19:54:47 -04:00
|
|
|
class Renderer : public IVideoDevice, public IMessageManager
|
2014-06-12 21:48:04 -04:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
HWND _hWnd = nullptr;
|
|
|
|
|
|
|
|
D3D_DRIVER_TYPE _driverType = D3D_DRIVER_TYPE_NULL;
|
|
|
|
D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
|
|
|
|
ID3D11Device* _pd3dDevice = nullptr;
|
|
|
|
ID3D11Device1* _pd3dDevice1 = nullptr;
|
2014-06-23 20:00:51 -04:00
|
|
|
ID3D11DeviceContext* _pDeviceContext = nullptr;
|
|
|
|
ID3D11DeviceContext1* _pDeviceContext1 = nullptr;
|
2014-06-12 21:48:04 -04:00
|
|
|
IDXGISwapChain* _pSwapChain = nullptr;
|
|
|
|
ID3D11RenderTargetView* _pRenderTargetView = nullptr;
|
2015-07-01 23:17:14 -04:00
|
|
|
ID3D11DepthStencilState* _pDepthDisabledStencilState = nullptr;
|
|
|
|
ID3D11BlendState* _pAlphaEnableBlendingState = nullptr;
|
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
ID3D11SamplerState* _samplerState = nullptr;
|
|
|
|
|
|
|
|
ID3D11Texture2D* _pTexture = nullptr;
|
2015-07-23 23:16:31 -04:00
|
|
|
uint32_t* _videoRAM = nullptr;
|
2014-06-28 22:52:49 -04:00
|
|
|
|
|
|
|
bool _frameChanged = true;
|
2015-07-22 22:08:28 -04:00
|
|
|
uint16_t* _ppuOutputBuffer = nullptr;
|
|
|
|
uint16_t* _ppuOutputSecondaryBuffer = nullptr;
|
2014-07-10 21:17:37 -04:00
|
|
|
SimpleLock _frameLock;
|
|
|
|
|
2015-08-14 21:50:14 -04:00
|
|
|
bool _isHD = false;
|
|
|
|
|
2015-07-14 21:51:39 -04:00
|
|
|
Timer _fpsTimer;
|
|
|
|
uint32_t _frameCount = 0;
|
|
|
|
uint32_t _lastFrameCount = 0;
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t _renderedFrameCount = 0;
|
|
|
|
uint32_t _lastRenderedFrameCount = 0;
|
2015-07-14 21:51:39 -04:00
|
|
|
uint32_t _currentFPS = 0;
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t _currentRenderedFPS = 0;
|
2014-06-13 23:12:56 -04:00
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
unique_ptr<SpriteFont> _font;
|
2015-07-01 23:17:14 -04:00
|
|
|
unique_ptr<SpriteFont> _smallFont;
|
2014-06-23 16:38:01 -04:00
|
|
|
ID3D11Texture2D* _overlayTexture = nullptr;
|
2014-06-26 16:24:15 -04:00
|
|
|
byte* _overlayBuffer = nullptr;
|
2014-07-01 12:44:01 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
unique_ptr<SpriteBatch> _spriteBatch;
|
2014-07-06 19:54:47 -04:00
|
|
|
//ID3D11PixelShader* _pixelShader = nullptr;
|
2014-06-23 16:38:01 -04:00
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
const uint32_t _bytesPerPixel = 4;
|
|
|
|
uint32_t _hdScreenWidth = 0;
|
|
|
|
uint32_t _hdScreenHeight = 0;
|
|
|
|
uint32_t _hdScreenBufferSize = 0;
|
2015-08-14 21:50:14 -04:00
|
|
|
HdPpuPixelInfo *_hdScreenTiles = nullptr;
|
|
|
|
HdPpuPixelInfo *_secondaryHdScreenTiles = nullptr;
|
2014-06-12 21:48:04 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
list<shared_ptr<ToastInfo>> _toasts;
|
2015-07-23 23:16:31 -04:00
|
|
|
ID3D11ShaderResourceView* _toastTexture = nullptr;
|
2014-06-25 21:52:37 -04:00
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
HRESULT InitDevice();
|
|
|
|
void CleanupDevice();
|
2014-06-23 20:00:51 -04:00
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
void SetScreenSize();
|
2014-06-26 11:32:09 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
ID3D11Texture2D* CreateTexture(uint32_t width, uint32_t height);
|
2014-06-23 20:00:51 -04:00
|
|
|
ID3D11ShaderResourceView* GetShaderResourceView(ID3D11Texture2D* texture);
|
|
|
|
void DrawNESScreen();
|
|
|
|
void DrawPauseScreen();
|
2014-06-12 21:48:04 -04:00
|
|
|
|
2015-07-11 08:27:22 -04:00
|
|
|
std::wstring WrapText(string text, SpriteFont* font, float maxLineWidth);
|
|
|
|
void DrawOutlinedString(string message, float x, float y, DirectX::FXMVECTOR color, float scale);
|
2014-07-09 21:11:02 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
void DrawToasts();
|
|
|
|
void DrawToast(shared_ptr<ToastInfo> toast, int posIndex);
|
|
|
|
void RemoveOldToasts();
|
2015-07-14 21:51:39 -04:00
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
public:
|
2014-06-23 19:02:09 -04:00
|
|
|
Renderer(HWND hWnd);
|
|
|
|
~Renderer();
|
2014-06-23 16:38:01 -04:00
|
|
|
|
2015-08-14 21:50:14 -04:00
|
|
|
bool Render();
|
2015-07-11 08:27:22 -04:00
|
|
|
void DisplayMessage(string title, string message);
|
2015-07-21 18:18:20 -04:00
|
|
|
void UpdateFrame(void* frameBuffer);
|
2015-08-14 21:50:14 -04:00
|
|
|
void UpdateHdFrame(void *frameBuffer, HdPpuPixelInfo *screenTiles);
|
2015-07-01 23:17:14 -04:00
|
|
|
void DisplayToast(shared_ptr<ToastInfo> toast);
|
2014-06-12 21:48:04 -04:00
|
|
|
};
|
|
|
|
}
|