Skip to content

Commit ee208d2

Browse files
authored
Merge pull request #286 from fjtrujy/sceGuFinalChanges
Another `scegu` improvement
2 parents e4831cf + 5571492 commit ee208d2

17 files changed

+104
-73
lines changed

src/debug/scr_printf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void pspDebugScreenInitEx(void *vram_base, int mode, int setup)
144144
g_vram_mode = mode;
145145
if(setup)
146146
{
147-
sceDisplaySetMode(0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
147+
sceDisplaySetMode(PSP_DISPLAY_MODE_LCD, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
148148
sceDisplaySetFrameBuf((void *) g_vram_base, PSP_LINE_SIZE, mode, 1);
149149
}
150150
clear_screen(bg_col);

src/display/pspdisplay.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ enum PspDisplaySetBufSync {
4141
#define PSP_DISPLAY_SETBUF_IMMEDIATE PSP_DISPLAY_SETBUF_NEXTHSYNC
4242
#define PSP_DISPLAY_SETBUF_NEXTFRAME PSP_DISPLAY_SETBUF_NEXTVSYNC
4343

44+
enum PspDisplayMode
45+
{
46+
/** LCD MAX 480x272 at 59.94005995 Hz */
47+
PSP_DISPLAY_MODE_LCD = 0,
48+
/** VESA VGA MAX 640x480 at 59.94047618Hz */
49+
PSP_DISPLAY_MODE_VESA1A = 0x1A,
50+
/** PSEUDO VGA MAX 640x480 at 59.94005995Hz*/
51+
PSP_DISPLAY_MODE_PSEUDO_VGA = 0x60
52+
};
4453
enum PspDisplayErrorCodes
4554
{
4655
SCE_DISPLAY_ERROR_OK = 0,
@@ -54,13 +63,17 @@ enum PspDisplayErrorCodes
5463
*
5564
* @par Example1:
5665
* @code
66+
* int mode = PSP_DISPLAY_MODE_LCD;
67+
* int width = 480;
68+
* int height = 272;
69+
* sceDisplaySetMode(mode, width, height);
5770
* @endcode
5871
*
59-
* @param mode - Display mode, normally 0.
72+
* @param mode - One of ::PspDisplayMode
6073
* @param width - Width of screen in pixels.
6174
* @param height - Height of screen in pixels.
6275
*
63-
* @return ???
76+
* @return when error, a negative value is returned.
6477
*/
6578
int sceDisplaySetMode(int mode, int width, int height);
6679

src/gu/guInternal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "guInternal.h"
1010

11-
unsigned int gu_current_frame;
1211
GuContext gu_contexts[3];
1312
int ge_list_executed[2];
1413
void* ge_edram_address;

src/gu/guInternal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ typedef struct
9696
unsigned char cutoff; // Light cutoff
9797
} GuLightSettings;
9898

99-
extern unsigned int gu_current_frame;
10099
extern GuContext gu_contexts[3];
101100
extern int ge_list_executed[2];
102101
extern void *ge_edram_address;

src/gu/pspgu.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ extern "C" {
115115
#define GU_TRANSFORM_BITS GU_TRANSFORM_SHIFT(1)
116116
/* Vertex Declarations End */
117117

118+
/* display ON/OFF switch */
119+
#define GU_DISPLAY_OFF 0
120+
#define GU_DISPLAY_ON 1
121+
122+
/* screen size */
123+
#define GU_SCR_WIDTH 480
124+
#define GU_SCR_HEIGHT 272
125+
#define GU_SCR_ASPECT ((float)GU_SCR_WIDTH / (float)GU_SCR_HEIGHT)
126+
#define GU_SCR_OFFSETX ((4096 - GU_SCR_WIDTH) / 2)
127+
#define GU_SCR_OFFSETY ((4096 - GU_SCR_HEIGHT) / 2)
128+
129+
/* Frame buffer */
130+
#define GU_VRAM_TOP 0x00000000
131+
#define GU_VRAM_WIDTH 512
132+
/* 16bit mode */
133+
#define GU_VRAM_BUFSIZE (GU_VRAM_WIDTH*GU_SCR_HEIGHT*2)
134+
#define GU_VRAM_BP_0 (void *)(GU_VRAM_TOP)
135+
#define GU_VRAM_BP_1 (void *)(GU_VRAM_TOP+GU_VRAM_BUFSIZE)
136+
#define GU_VRAM_BP_2 (void *)(GU_VRAM_TOP+(GU_VRAM_BUFSIZE*2))
137+
/* 32bit mode */
138+
#define GU_VRAM_BUFSIZE32 (GU_VRAM_WIDTH*GU_SCR_HEIGHT*4)
139+
#define GU_VRAM_BP32_0 (void *)(GU_VRAM_TOP)
140+
#define GU_VRAM_BP32_1 (void *)(GU_VRAM_TOP+GU_VRAM_BUFSIZE32)
141+
#define GU_VRAM_BP32_2 (void *)(GU_VRAM_TOP+(GU_VRAM_BUFSIZE32*2))
142+
118143
/* Pixel Formats */
119144
#define GU_PSM_5650 (0) /* Display, Texture, Palette */
120145
#define GU_PSM_5551 (1) /* Display, Texture, Palette */
@@ -378,8 +403,8 @@ void sceGuDrawBufferList(int psm, void* fbp, int fbw);
378403
* Turn display on or off
379404
*
380405
* Available states are:
381-
* - GU_TRUE (1) - Turns display on
382-
* - GU_FALSE (0) - Turns display off
406+
* - GU_DISPLAY_ON (1) - Turns display on
407+
* - GU_DISPLAY_OFF (0) - Turns display off
383408
*
384409
* @param state - Turn display on or off
385410
* @return State of the display prior to this call
@@ -536,8 +561,9 @@ void* sceGuGetMemory(int size);
536561
*
537562
* @param ctype - Context Type
538563
* @param list - Pointer to display-list (16 byte aligned)
564+
* @return 0 for success, < 0 for failure
539565
**/
540-
void sceGuStart(int ctype, void* list);
566+
int sceGuStart(int ctype, void* list);
541567

542568
/**
543569
* Finish current display list and go back to the parent context

src/gu/resetValues.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ void _sceGuResetGlobalVariables()
1515
gu_init = 0;
1616

1717
gu_states = 0;
18-
gu_current_frame = 0;
1918
gu_object_stack_depth = 0;
2019

21-
gu_display_on = GU_FALSE;
20+
gu_display_on = GU_DISPLAY_OFF;
2221
gu_call_mode = GU_CALL_NORMAL;
2322

24-
gu_draw_buffer.pixel_size = 1;
25-
gu_draw_buffer.frame_width = 0;
23+
gu_draw_buffer.pixel_size = GU_PSM_5551;
24+
gu_draw_buffer.frame_width = GU_SCR_WIDTH;
2625
gu_draw_buffer.frame_buffer = 0;
2726
gu_draw_buffer.disp_buffer = 0;
2827
gu_draw_buffer.depth_buffer = 0;
2928
gu_draw_buffer.depth_width = 0;
30-
gu_draw_buffer.width = 480;
31-
gu_draw_buffer.height = 272;
29+
gu_draw_buffer.width = GU_SCR_WIDTH;
30+
gu_draw_buffer.height = GU_SCR_HEIGHT;
3231

3332
for (i = 0; i < 3; ++i)
3433
{
@@ -58,6 +57,6 @@ void _sceGuResetGlobalVariables()
5857
context->texture_mode = 0;
5958
}
6059

61-
gu_settings.sig = 0;
62-
gu_settings.fin = 0;
60+
gu_settings.sig = NULL;
61+
gu_settings.fin = NULL;
6362
}

src/gu/sceGuCallList.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ int sceGuCallList(const void *list)
2525
}
2626

2727
res = _sceGuUpdateStallAddr();
28-
if (res < 0) {
28+
if (res < 0)
29+
{
2930
return res;
3031
}
3132
return 0;

src/gu/sceGuDepthBuffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
void sceGuDepthBuffer(void *zbp, int zbw)
1212
{
13+
sendCommandi(Z_BUF_PTR, ((unsigned int)zbp));
14+
sendCommandi(Z_BUF_WIDTH, ((((unsigned int)zbp) & 0xff000000) >> 8) | zbw);
15+
1316
gu_draw_buffer.depth_buffer = zbp;
1417

1518
if (!gu_draw_buffer.depth_width || (gu_draw_buffer.depth_width != zbw))
1619
gu_draw_buffer.depth_width = zbw;
17-
18-
sendCommandi(Z_BUF_PTR, ((unsigned int)zbp));
19-
sendCommandi(Z_BUF_WIDTH, ((((unsigned int)zbp) & 0xff000000) >> 8) | zbw);
2020
}

src/gu/sceGuDispBuffer.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
#include <pspkernel.h>
1212
#include <pspdisplay.h>
1313

14-
static inline void drawRegion(int x, int y, int width, int height)
15-
{
16-
sendCommandi(REGION1, (y << 10) | x);
17-
sendCommandi(REGION2, (((y + height) - 1) << 10) | ((x + width) - 1));
18-
}
19-
2014
void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw)
2115
{
2216
gu_draw_buffer.width = width;
@@ -26,9 +20,8 @@ void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw)
2620
if (!gu_draw_buffer.frame_width || (gu_draw_buffer.frame_width != dispbw))
2721
gu_draw_buffer.frame_width = dispbw;
2822

29-
drawRegion(0, 0, gu_draw_buffer.width, gu_draw_buffer.height);
30-
sceDisplaySetMode(0, gu_draw_buffer.width, gu_draw_buffer.height);
23+
sceDisplaySetMode(PSP_DISPLAY_MODE_LCD, gu_draw_buffer.width, gu_draw_buffer.height);
3124

32-
if (gu_display_on)
25+
if (gu_display_on == GU_DISPLAY_ON)
3326
sceDisplaySetFrameBuf((void *)(((unsigned int)ge_edram_address) + ((unsigned int)gu_draw_buffer.disp_buffer)), dispbw, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTVSYNC);
3427
}

src/gu/sceGuGetMemory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <pspkernel.h>
1212
#include <pspge.h>
1313

14-
void* sceGuGetMemory(int size)
14+
void *sceGuGetMemory(int size)
1515
{
1616
// some kind of 4-byte alignment?
1717
size += 3;

0 commit comments

Comments
 (0)