forked from MERLev/remaPSV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.c
75 lines (63 loc) · 2.58 KB
/
renderer.c
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
/*
* This File is Part Of :
* ___ ___ ___ ___ ___ ___
* / /\ ___ /__/\ / /\ /__/\ / /\ / /\ ___
* / /::\ / /\ \ \:\ / /:/ \ \:\ / /:/_ / /::\ / /\
* / /:/\:\ / /:/ \ \:\ / /:/ \__\:\ / /:/ /\ / /:/\:\ / /:/
* / /:/~/:/ /__/::\ _____\__\:\ / /:/ ___ ___ / /::\ / /:/ /:/_ / /:/~/::\ / /:/
* /__/:/ /:/___ \__\/\:\__ /__/::::::::\ /__/:/ / /\ /__/\ /:/\:\ /__/:/ /:/ /\ /__/:/ /:/\:\ / /::\
* \ \:\/:::::/ \ \:\/\ \ \:\~~\~~\/ \ \:\ / /:/ \ \:\/:/__\/ \ \:\/:/ /:/ \ \:\/:/__\/ /__/:/\:\
* \ \::/~~~~ \__\::/ \ \:\ ~~~ \ \:\ /:/ \ \::/ \ \::/ /:/ \ \::/ \__\/ \:\
* \ \:\ /__/:/ \ \:\ \ \:\/:/ \ \:\ \ \:\/:/ \ \:\ \ \:\
* \ \:\ \__\/ \ \:\ \ \::/ \ \:\ \ \::/ \ \:\ \__\/
* \__\/ \__\/ \__\/ \__\/ \__\/ \__\/
*
* Copyright (c) Rinnegatamante <[email protected]>
*
*/
#include <psp2/types.h>
#include <psp2/display.h>
#include <libk/stdio.h>
#include <libk/stdarg.h>
#include <libk/string.h>
#include "font.h"
unsigned int* vram32;
int pwidth, pheight, bufferwidth;
uint32_t color;
void updateFramebuf(const SceDisplayFrameBuf *param){
pwidth = param->width;
pheight = param->height;
vram32 = param->base;
bufferwidth = param->pitch;
}
void setTextColor(uint32_t clr){
color = clr;
}
void drawCharacter(int character, int x, int y){
for (int yy = 0; yy < 10; yy++) {
int xDisplacement = x;
int yDisplacement = (y + (yy<<1)) * bufferwidth;
uint32_t* screenPos = vram32 + xDisplacement + yDisplacement;
uint8_t charPos = font[character * 10 + yy];
for (int xx = 7; xx >= 2; xx--) {
uint32_t clr = ((charPos >> xx) & 1) ? color : 0xFF000000;
*(screenPos) = clr;
*(screenPos+1) = clr;
*(screenPos+bufferwidth) = clr;
*(screenPos+bufferwidth+1) = clr;
screenPos += 2;
}
}
}
void drawString(int x, int y, const char *str){
for (size_t i = 0; i < strlen(str); i++)
drawCharacter(str[i], x + i * 12, y);
}
void drawStringF(int x, int y, const char *format, ...){
char str[512] = { 0 };
va_list va;
va_start(va, format);
vsnprintf(str, 512, format, va);
va_end(va);
drawString(x, y, str);
}