summaryrefslogtreecommitdiff
path: root/src/screen.h
blob: 075d45a888cd37aa4fbaa4b3f76ec159bd502f16 (plain)
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
#pragma once

#include "raylib.h"

#define MODE_CHIP8 0 // Chip-8 64x32
#define MODE_SCHIP 1 // Super-Chip 128x64 (not supported yet)

typedef struct SCREEN_DATA {
  int width, height;
  int originX;
  int originY;
  int pixel;
  char pixels[64*32];
} SCREEN_DATA;

/**
 * @brief Must be called first!
 * 
 * @param width 
 * @param height 
 */
void ScreenInit(int width, int height);

/**
 * @brief Clear the entire simulated screen
 * 
 */
void ScreenClear();

/**
 * @brief Set the pixel's state of the simulated screen (follow the chip-8 specification)
 * 
 * @param x 
 * @param y 
 * @param state 
 * @return char 1 if pixel was already on and 0 otherwise
 */
char ScreenPixelApply(int x, int y, unsigned char state);

/**
 * @brief Get simulated screen dimensions
 * 
 * @param width 
 * @param height 
 */
void ScreenWH(int *width, int *height);

/**
 * @brief Draw simulated screen instantly
 * 
 */
void ScreenUpdate();

/**
 * @brief Close screen (must be called before quit)
 * 
 */
void ScreenClose();