-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.h
91 lines (71 loc) · 4.36 KB
/
display.h
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
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#include <pspdisplay.h>
#include "common/datatype.h"
extern int DISP_FONTSIZE, DISP_BOOK_FONTSIZE, HRR, WRR;
extern byte disp_ewidth[0x80];
// R,G,B color to word value color
#ifdef COLOR16BIT
typedef word pixel;
#define PIXEL_BYTES 2
#define COLOR_MAX 31
#define COLOR_WHITE 0xFFFF
#define RGB(r,g,b) ((((pixel)(b)*31/255)<<10)|(((pixel)(g)*31/255)<<5)|((pixel)(r)*31/255)|0x8000)
#define RGB2(r,g,b) ((((pixel)(b))<<10)|(((pixel)(g))<<5)|((pixel)(r))|0x8000)
#define RGBA(r,g,b,a) ((((pixel)(b))<<10)|(((pixel)(g))<<5)|((pixel)(r))|((a)?0x8000:0))
#define RGB_R(c) ((c) & 0x1F)
#define RGB_G(c) (((c) >> 5) & 0x1F)
#define RGB_B(c) (((c) >> 10) & 0x1F)
#define RGB_16to32(c) (c)
#else
typedef dword pixel;
#define PIXEL_BYTES 4
#define COLOR_MAX 255
#define COLOR_WHITE 0xFFFFFFFF
#define RGB(r,g,b) ((((pixel)(b))<<16)|(((pixel)(g))<<8)|((pixel)(r))|0xFF000000)
#define RGB2(r,g,b) ((((pixel)(b))<<16)|(((pixel)(g))<<8)|((pixel)(r))|0xFF000000)
#define RGBA(r,g,b,a) ((((pixel)(b))<<16)|(((pixel)(g))<<8)|((pixel)(r))|(((pixel)(a))<<24))
#define RGB_R(c) ((c) & 0xFF)
#define RGB_G(c) (((c) >> 8) & 0xFF)
#define RGB_B(c) (((c) >> 16) & 0xFF)
#define RGB_16to32(c) RGBA((((c)&0x1F)*255/31),((((c)>>5)&0x1F)*255/31),((((c)>>10)&0x1F)*255/31),((c&0x8000)?0xFF:0))
#endif
#define disp_grayscale(c,r,g,b,gs) RGB2(((r)*(gs)+RGB_R(c)*(100-(gs)))/100,((g)*(gs)+RGB_G(c)*(100-(gs)))/100,((b)*(gs)+RGB_B(c)*(100-(gs)))/100)
extern pixel * vram_start;
// sceDisplayWaitVblankStart function alias name, define is faster than function call (even at most time this is inline linked)
#define disp_waitv() sceDisplayWaitVblankStart()
#define disp_get_vaddr(x, y) (vram_start + (x) + ((y) << 9))
#define disp_putpixel(x,y,c) *(pixel*)disp_get_vaddr((x),(y)) = (c)
extern void disp_init();
extern void disp_set_fontsize(int fontsize);
extern void disp_set_book_fontsize(int fontsize);
extern bool disp_has_zipped_font(const char * zipfile, const char * efont, const char * cfont);
extern bool disp_load_zipped_font(const char * zipfile, const char * efont, const char * cfont);
extern bool disp_load_zipped_book_font(const char * zipfile, const char * efont, const char * cfont);
extern bool disp_load_truetype_book_font(const char * ettffile, const char *cttffile, int size);
extern bool disp_load_zipped_truetype_book_font(const char * zipfile, const char * ettffile, const char *cttffile, int size);
extern bool disp_has_font(const char * efont, const char * cfont);
extern bool disp_load_font(const char * efont, const char * cfont);
extern bool disp_load_book_font(const char * efont, const char * cfont);
extern void disp_assign_book_font();
extern void disp_free_font();
extern void disp_flip();
extern void disp_getimage(dword x, dword y, dword w, dword h, pixel * buf);
extern void disp_putimage(dword x, dword y, dword w, dword h, dword startx, dword starty, pixel * buf);
extern void disp_duptocache();
extern void disp_duptocachealpha(int percent);
extern void disp_rectduptocache(dword x1, dword y1, dword x2, dword y2);
extern void disp_rectduptocachealpha(dword x1, dword y1, dword x2, dword y2, int percent);
extern void disp_putnstring(int x, int y, pixel color, const byte *str, int count, dword wordspace, int top, int height, int bot);
#define disp_putstring(x,y,color,str) disp_putnstring((x),(y),(color),(str),0x7FFFFFFF,0,0,DISP_FONTSIZE,0)
extern void disp_putnstringhorz(int x, int y, pixel color, const byte *str, int count, dword wordspace, int top, int height, int bot);
#define disp_putstringhorz(x,y,color,str) disp_putnstringhorz((x),(y),(color),(str),0x7FFFFFFF,0,0,DISP_BOOK_FONTSIZE,0)
extern void disp_putnstringlvert(int x, int y, pixel color, const byte *str, int count, dword wordspace, int top, int height, int bot);
#define disp_putstringlvert(x,y,color,str) disp_putnstringlvert((x),(y),(color),(str),0x7FFFFFFF,0,0,DISP_BOOK_FONTSIZE,0)
extern void disp_putnstringrvert(int x, int y, pixel color, const byte *str, int count, dword wordspace, int top, int height, int bot);
#define disp_putstringrvert(x,y,color,str) disp_putnstringrvert((x),(y),(color),(str),0x7FFFFFFF,0,0,DISP_BOOK_FONTSIZE,0)
extern void disp_fillvram(pixel color);
extern void disp_fillrect(dword x1, dword y1, dword x2, dword y2, pixel color);
extern void disp_rectangle(dword x1, dword y1, dword x2, dword y2, pixel color);
extern void disp_line(dword x1, dword y1, dword x2, dword y2, pixel color);
#endif