diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-07-30 00:53:31 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-07-30 00:53:31 +0200 |
| commit | 073a859acf16ccbc0f49364e38126bf2bf03aa3d (patch) | |
| tree | 90fac6072c5fe3ccee0505c881f89aa262d4eed7 /libpsn00b/psxgpu | |
| parent | 0e755e9801a2dcf7b9827c90cc38e9f532d06393 (diff) | |
| download | psn00bsdk-073a859acf16ccbc0f49364e38126bf2bf03aa3d.tar.gz | |
Deprecate u_short, u_int and u_long types in libpsn00b
Diffstat (limited to 'libpsn00b/psxgpu')
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 23 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/env.c | 13 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/font.c | 27 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 33 |
4 files changed, 46 insertions, 50 deletions
diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index ee90225..bf115a1 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -4,7 +4,6 @@ */ #include <stdint.h> -#include <sys/types.h> #include <stdio.h> #include <psxetc.h> #include <psxapi.h> @@ -17,12 +16,12 @@ /* Internal globals */ -VIDEO_MODE _gpu_video_mode; +GPU_VideoMode _gpu_video_mode; static void (*_vsync_callback)(void); static void (*_drawsync_callback)(void); -static const u_long *volatile _draw_queue[QUEUE_LENGTH]; +static const uint32_t *volatile _draw_queue[QUEUE_LENGTH]; static volatile uint8_t _queue_head, _queue_tail, _queue_length; static volatile uint32_t _vblank_counter, _last_hblank; @@ -194,7 +193,7 @@ void *DrawSyncCallback(void (*func)(void)) { /* OT and primitive drawing API */ -void ClearOTagR(u_long *ot, size_t length) { +void ClearOTagR(uint32_t *ot, size_t length) { DMA_MADR(6) = (uint32_t) &ot[length - 1]; DMA_BCR(6) = length & 0xffff; DMA_CHCR(6) = 0x11000002; @@ -203,18 +202,18 @@ void ClearOTagR(u_long *ot, size_t length) { //__asm__ volatile(""); } -void ClearOTag(u_long *ot, size_t length) { +void ClearOTag(uint32_t *ot, size_t length) { // DMA6 only supports writing to RAM in reverse order (last to first), so // the OT has to be cleared in software here. This function is thus much // slower than ClearOTagR(). // https://problemkaputt.de/psx-spx.htm#dmachannels for (int i = 0; i < (length - 1); i++) - ot[i] = (u_long) &ot[i + 1] & 0x00ffffff; + ot[i] = (uint32_t) &ot[i + 1] & 0x00ffffff; ot[length - 1] = 0x00ffffff; } -void DrawOTag(const u_long *ot) { +void DrawOTag(const uint32_t *ot) { // If GPU DMA is currently busy, append the OT to the queue instead of // drawing it immediately. if (DMA_CHCR(2) & (1 << 24)) { @@ -232,7 +231,7 @@ void DrawOTag(const u_long *ot) { DrawOTag2(ot); } -void DrawOTag2(const u_long *ot) { +void DrawOTag2(const uint32_t *ot) { GPU_GP1 = 0x04000002; while (!(GPU_GP1 & (1 << 26))) @@ -243,7 +242,7 @@ void DrawOTag2(const u_long *ot) { DMA_CHCR(2) = 0x01000401; } -void DrawPrim(const u_long *pri) { +void DrawPrim(const uint32_t *pri) { size_t length = getlen(pri); DrawSync(0); @@ -261,17 +260,17 @@ void DrawPrim(const u_long *pri) { DMA_CHCR(2) = 0x01000201; } -void AddPrim(u_long *ot, const void *pri) { +void AddPrim(uint32_t *ot, const void *pri) { addPrim(ot, pri); } /* Misc. functions */ -VIDEO_MODE GetVideoMode(void) { +GPU_VideoMode GetVideoMode(void) { return _gpu_video_mode; } -void SetVideoMode(VIDEO_MODE mode) { +void SetVideoMode(GPU_VideoMode mode) { uint32_t _mode, stat = GPU_GP1; _gpu_video_mode = mode & 1; diff --git a/libpsn00b/psxgpu/env.c b/libpsn00b/psxgpu/env.c index 8a74b7e..5642ad4 100644 --- a/libpsn00b/psxgpu/env.c +++ b/libpsn00b/psxgpu/env.c @@ -4,13 +4,12 @@ */ #include <stdint.h> -#include <sys/types.h> #include <psxgpu.h> #include <hwregs_c.h> #define _min(x, y) (((x) < (y)) ? (x) : (y)) -extern VIDEO_MODE _gpu_video_mode; +extern GPU_VideoMode _gpu_video_mode; /* Drawing API */ @@ -38,7 +37,7 @@ DRAWENV *SetDefDrawEnv(DRAWENV *env, int x, int y, int w, int h) { return env; } -void DrawOTagEnv(const u_long *ot, DRAWENV *env) { +void DrawOTagEnv(const uint32_t *ot, DRAWENV *env) { DR_ENV *prim = &(env->dr_env); // All commands are grouped into a single display list packet for @@ -86,11 +85,11 @@ void DrawOTagEnv(const u_long *ot, DRAWENV *env) { //while (!(GPU_GP1 & (1 << 26))) //__asm__ volatile(""); - DrawOTag(prim); + DrawOTag((const uint32_t *) prim); } void PutDrawEnv(DRAWENV *env) { - DrawOTagEnv((const u_long *) 0x00ffffff, env); + DrawOTagEnv((const uint32_t *) 0x00ffffff, env); } // This function skips rebuilding the cached packet whenever possible and is @@ -98,11 +97,11 @@ void PutDrawEnv(DRAWENV *env) { // the time). void PutDrawEnvFast(DRAWENV *env) { if (!(env->dr_env.tag)) { - DrawOTagEnv((const u_long *) 0x00ffffff, env); + DrawOTagEnv((const uint32_t *) 0x00ffffff, env); return; } - DrawOTag(&(env->dr_env)); + DrawOTag((const uint32_t *) &(env->dr_env)); } /* Display API */ diff --git a/libpsn00b/psxgpu/font.c b/libpsn00b/psxgpu/font.c index 7a8137c..2d4105f 100644 --- a/libpsn00b/psxgpu/font.c +++ b/libpsn00b/psxgpu/font.c @@ -1,4 +1,4 @@ -#include <sys/types.h> +#include <stdint.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -6,29 +6,28 @@ #include <psxgpu.h> typedef struct _fnt_stream { - char *txtbuff; - char *txtnext; - char *pribuff; - short x,y; - short w,h; - int bg; - int maxchars; + char *txtbuff; + char *txtnext; + char *pribuff; + int16_t x, y; + int16_t w, h; + int bg, maxchars; } _fnt_stream; static _fnt_stream _stream[8]; static int _nstreams = 0; -u_short _font_tpage; -u_short _font_clut; +uint16_t _font_tpage; +uint16_t _font_clut; -extern u_char _gpu_debug_font[]; +extern uint8_t _gpu_debug_font[]; void FntLoad(int x, int y) { RECT pos; TIM_IMAGE tim; - GetTimInfo( (const u_long *) _gpu_debug_font, &tim ); + GetTimInfo( (const uint32_t *) _gpu_debug_font, &tim ); // Load font image pos = *tim.prect; @@ -215,7 +214,7 @@ char *FntFlush(int id) { // Draw the primitives DrawSync(0); - DrawOTag((u_long*)_stream[id].pribuff); + DrawOTag((uint32_t*)_stream[id].pribuff); DrawSync(0); _stream[id].txtnext = _stream[id].txtbuff; @@ -225,7 +224,7 @@ char *FntFlush(int id) { } -char *FntSort(u_long *ot, char *pri, int x, int y, const char *text) { +char *FntSort(uint32_t *ot, char *pri, int x, int y, const char *text) { DR_TPAGE *tpage; SPRT_8 *sprt = (SPRT_8*)pri; diff --git a/libpsn00b/psxgpu/image.c b/libpsn00b/psxgpu/image.c index 3633c7c..b3e5678 100644 --- a/libpsn00b/psxgpu/image.c +++ b/libpsn00b/psxgpu/image.c @@ -4,7 +4,6 @@ */ #include <stdint.h> -#include <sys/types.h> #include <stdio.h> #include <psxgpu.h> #include <hwregs_c.h> @@ -51,11 +50,11 @@ static void _load_store_image( /* Public VRAM API */ -void LoadImage(const RECT *rect, const u_long *data) { +void LoadImage(const RECT *rect, const uint32_t *data) { _load_store_image(0xa0000000, 2, rect, (uint32_t *) data); } -void StoreImage(const RECT *rect, u_long *data) { +void StoreImage(const RECT *rect, uint32_t *data) { _load_store_image(0xc0000000, 3, rect, (uint32_t *) data); } @@ -65,18 +64,18 @@ void StoreImage(const RECT *rect, u_long *data) { // difference from GetTimInfo() is that it copies RECTs rather than merely // returning pointers to them, which become useless once the .TIM file is // unloaded from main RAM. -int GsGetTimInfo(const u_long *tim, GsIMAGE *info) { +int GsGetTimInfo(const uint32_t *tim, GsIMAGE *info) { if ((*(tim++) & 0xffff) != 0x0010) return 1; info->pmode = *(tim++); if (info->pmode & 8) { - const u_long *palette_end = tim; + const uint32_t *palette_end = tim; palette_end += *(tim++) / 4; - *((u_long *) &(info->cx)) = *(tim++); - *((u_long *) &(info->cw)) = *(tim++); - info->clut = (u_long *) tim; + *((uint32_t *) &(info->cx)) = *(tim++); + *((uint32_t *) &(info->cw)) = *(tim++); + info->clut = (uint32_t *) tim; tim = palette_end; } else { @@ -84,24 +83,24 @@ int GsGetTimInfo(const u_long *tim, GsIMAGE *info) { } tim++; - *((u_long *) &(info->px)) = *(tim++); - *((u_long *) &(info->pw)) = *(tim++); - info->pixel = (u_long *) tim; + *((uint32_t *) &(info->px)) = *(tim++); + *((uint32_t *) &(info->pw)) = *(tim++); + info->pixel = (uint32_t *) tim; return 0; } -int GetTimInfo(const u_long *tim, TIM_IMAGE *info) { +int GetTimInfo(const uint32_t *tim, TIM_IMAGE *info) { if ((*(tim++) & 0xffff) != 0x0010) return 1; info->mode = *(tim++); if (info->mode & 8) { - const u_long *palette_end = tim; + const uint32_t *palette_end = tim; palette_end += *(tim++) / 4; - info->crect = (RECT *) tim; - info->caddr = (u_long *) &tim[2]; + info->crect = (RECT *) tim; + info->caddr = (uint32_t *) &tim[2]; tim = palette_end; } else { @@ -109,8 +108,8 @@ int GetTimInfo(const u_long *tim, TIM_IMAGE *info) { } tim++; - info->prect = (RECT *) tim; - info->paddr = (u_long *) &tim[2]; + info->prect = (RECT *) tim; + info->paddr = (uint32_t *) &tim[2]; return 0; } |
