~groovestomp/gsnes

ref: 9de07668b1fbbdc9470247b82ffbe5e2d80330d8 gsnes/ppu.h -rw-r--r-- 2.0 KiB
9de07668 — GrooveStomp Foreground rendering works 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/******************************************************************************
  GrooveStomp's NES Emulator
  Copyright (c) 2019 Aaron Oman (GrooveStomp)

  File: ppu.h
  Created: 2019-11-03
  Updated: 2019-12-06
  Author: Aaron Oman
  Notice: GNU AGPLv3 License

  Based off of: One Lone Coder NES Emulator Copyright (C) 2019 Javidx9
  This program comes with ABSOLUTELY NO WARRANTY.
  This is free software, and you are welcome to redistribute it under certain
  conditions; See LICENSE for details.
 ******************************************************************************/
//! \file ppu.h
#ifndef PPU_VERSION
#define PPU_VERSION "0.1.0"

#include <stdint.h>
#include <stdbool.h>

struct ppu;
struct cart;
struct sprite;
struct color;

struct ppu *
PpuInit();

void
PpuDeinit(struct ppu *ppu);

void
PpuAttachCart(struct ppu *ppu, struct cart *cart);

void
PpuTick(struct ppu *ppu);

void
PpuReset(struct ppu *ppu);

int
PpuIsFrameComplete(struct ppu *ppu);

void
PpuResetFrameCompletion(struct ppu *ppu);

struct sprite *
PpuScreen(struct ppu *ppu);

//! \brief Draws CHR ROM for a given pattern table into a sprite
//!
//! \param[in,out] ppu
//! \param[in] i which pattern table to draw
//! \param[in] palette which palette to use
//! \return a sprite representing CHR ROM
struct sprite *
PpuGetPatternTable(struct ppu *ppu, uint8_t i, uint8_t palette);

//! \brief Get the specified color from palette memory
//!
//! \param[in,out] ppu
//! \param[in] palette which palette to use for color
//! \param[in] pixel 0, 1, 2 or 3
struct color *
PpuGetColorFromPaletteRam(struct ppu *ppu, uint8_t palette, uint8_t pixel);

uint8_t
PpuReadViaCpu(struct ppu *ppu, uint16_t addr, bool readOnly);

void
PpuWriteViaCpu(struct ppu *ppu, uint16_t addr, uint8_t data);

uint8_t
PpuRead(struct ppu *ppu, uint16_t addr);

void
PpuWrite(struct ppu *ppu, uint16_t addr, uint8_t data);

uint8_t
PpuGetNmi(struct ppu *ppu);

void
PpuSetNmi(struct ppu *ppu, uint8_t trueOrFalse);

struct sprite *
PpuGetNameTable(struct ppu *ppu, uint8_t i);

uint8_t *
PpuGetOam(struct ppu *ppu);

#endif // PPU_VERSION