Nugget
Loading...
Searching...
No Matches
gpu.h
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2021 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdint.h>
30
31#include "common/hardware/gpu.h"
33#include "shell/math.h"
34
35#define WIDTH 640
36#define HEIGHT 480
37
38union GPUPoint {
40 struct {
41 int16_t x, y;
42 };
43};
44
45void initGPU(int isPAL);
46void flip(int doubleBuffer, const union Color bg);
47void waitVSync(int interlaced, void (*idle)());
48
49// we shift by 17 instead of 24 to do a scaling of 128
50// therefore a typical square of (-1,-1)-(1,1) would
51// end up as a 256x256 pixels one
52static inline void sendGPUVertex(struct Vertex2D *v) {
53 union GPUPoint p;
54 int32_t x = v->x >> 17;
55 int32_t y = v->y >> 17;
56 // adjust ratio for proper 4:3 output view
57 y = y * HEIGHT * 4 / (WIDTH * 3);
58 p.x = x + WIDTH / 2;
59 p.y = y + HEIGHT / 2;
60 GPU_DATA = p.packed;
61}
#define GPU_DATA
Definition hwregs.h:65
void waitVSync(int interlaced, void(*idle)())
Definition gpu.c:62
void flip(int doubleBuffer, const union Color bg)
Definition gpu.c:36
#define WIDTH
Definition gpu.h:35
void initGPU(int isPAL)
Definition gpu.c:85
#define HEIGHT
Definition gpu.h:36
Definition math.h:43
int32_t y
Definition math.h:44
int32_t x
Definition math.h:44
void uint32_t(classId, spec)
Definition gpu.h:109
Definition gpu.h:38
uint32_t packed
Definition gpu.h:39
int16_t x
Definition gpu.h:41
int16_t y
Definition gpu.h:41