aboutsummaryrefslogtreecommitdiff
path: root/src/gfx/ps1
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-02-24 21:12:18 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-03-30 08:20:21 +0200
commitb925e5e156db07494b338e7c130b72f8e3a7725e (patch)
tree771e581beaadb5e1ece158ee40e4251a61b7873b /src/gfx/ps1
parent669045df00302d7c4df861c4c21cac1efdb54048 (diff)
downloadjancity-b925e5e156db07494b338e7c130b72f8e3a7725e.tar.gz
gfx: separate port-specific interfaces
Diffstat (limited to 'src/gfx/ps1')
-rw-r--r--src/gfx/ps1/inc/gfx/port.h9
-rw-r--r--src/gfx/ps1/privinc/ps1/gfx_private.h2
-rw-r--r--src/gfx/ps1/src/4line.c1
-rw-r--r--src/gfx/ps1/src/env.c6
-rw-r--r--src/gfx/ps1/src/quad.c1
-rw-r--r--src/gfx/ps1/src/rect.c2
-rw-r--r--src/gfx/ps1/src/sort.c32
-rw-r--r--src/gfx/ps1/src/sprite.c1
8 files changed, 37 insertions, 17 deletions
diff --git a/src/gfx/ps1/inc/gfx/port.h b/src/gfx/ps1/inc/gfx/port.h
index dec00c3..9aed9fd 100644
--- a/src/gfx/ps1/inc/gfx/port.h
+++ b/src/gfx/ps1/inc/gfx/port.h
@@ -129,7 +129,14 @@ struct stp_4line
uint32_t end;
};
-enum {DRAW_MODE = 0xE1};
+#define common_get_or_ret(t, x, ret) \
+ struct t *x = t##_get(); \
+ if (!x) return ret
+
+struct sprite *sprite_get(void);
+struct quad *quad_get(void);
+struct rect *rect_get(void);
+struct stp_4line *stp_4line_get(void);
int sprite_from_file_ex(const char *path, struct sprite *s);
diff --git a/src/gfx/ps1/privinc/ps1/gfx_private.h b/src/gfx/ps1/privinc/ps1/gfx_private.h
index fd5a790..651ee40 100644
--- a/src/gfx/ps1/privinc/ps1/gfx_private.h
+++ b/src/gfx/ps1/privinc/ps1/gfx_private.h
@@ -8,6 +8,8 @@ extern "C"
{
#endif
+enum {DRAW_MODE = 0xE1};
+
enum
{
SCREEN_W = 368,
diff --git a/src/gfx/ps1/src/4line.c b/src/gfx/ps1/src/4line.c
index 955277e..ead1ad6 100644
--- a/src/gfx/ps1/src/4line.c
+++ b/src/gfx/ps1/src/4line.c
@@ -1,4 +1,5 @@
#include <gfx.h>
+#include <ps1/gfx_private.h>
#include <psxgpu.h>
#include <stdint.h>
#include <string.h>
diff --git a/src/gfx/ps1/src/env.c b/src/gfx/ps1/src/env.c
index c12002b..e18eda8 100644
--- a/src/gfx/ps1/src/env.c
+++ b/src/gfx/ps1/src/env.c
@@ -32,6 +32,12 @@ void gfx_initenvs(void)
GsSetDispEnv(&dispenv);
}
+int gfx_toggle_fullscreen(void)
+{
+ /* Not supported. */
+ return -1;
+}
+
bool gfx_inside_drawenv(const short x, const short y, const short w,
const short h)
{
diff --git a/src/gfx/ps1/src/quad.c b/src/gfx/ps1/src/quad.c
index 649426f..4b65b90 100644
--- a/src/gfx/ps1/src/quad.c
+++ b/src/gfx/ps1/src/quad.c
@@ -1,4 +1,5 @@
#include <gfx.h>
+#include <ps1/gfx_private.h>
#include <gfx/port.h>
#include <stdint.h>
#include <string.h>
diff --git a/src/gfx/ps1/src/rect.c b/src/gfx/ps1/src/rect.c
index 7e593b7..ff70b95 100644
--- a/src/gfx/ps1/src/rect.c
+++ b/src/gfx/ps1/src/rect.c
@@ -1,5 +1,7 @@
#include <gfx.h>
+#include <ps1/gfx_private.h>
#include <psxgpu.h>
+#include <stdbool.h>
#include <stdint.h>
#include <string.h>
diff --git a/src/gfx/ps1/src/sort.c b/src/gfx/ps1/src/sort.c
index 03449fc..1c61d12 100644
--- a/src/gfx/ps1/src/sort.c
+++ b/src/gfx/ps1/src/sort.c
@@ -39,6 +39,22 @@ void stp_4line_sort(struct stp_4line *const l)
add_to_list(&l->sznext);
}
+static void gfx_sync(void)
+{
+ /* Wait for the GPU to finish drawing primitives. */
+ while (!(GPU_CONTROL_PORT & (1 << 0x1a)))
+ ;
+
+ /* Wait for the GPU to be free. */
+ while (!(GPU_CONTROL_PORT & (1 << 0x1c)))
+ ;
+
+ while (!vblank_set)
+ ;
+
+ vblank_set = false;
+}
+
void gfx_draw(void)
{
static union gfx_sznext term = {.cmd_next = 0xffffff};
@@ -56,19 +72,3 @@ void gfx_draw(void)
D2_CHCR = (1 << 0xa) | 1 | (1 << 0x18);
first = NULL;
}
-
-void gfx_sync(void)
-{
- /* Wait for the GPU to finish drawing primitives. */
- while (!(GPU_CONTROL_PORT & (1 << 0x1a)))
- ;
-
- /* Wait for the GPU to be free. */
- while (!(GPU_CONTROL_PORT & (1 << 0x1c)))
- ;
-
- while (!vblank_set)
- ;
-
- vblank_set = false;
-}
diff --git a/src/gfx/ps1/src/sprite.c b/src/gfx/ps1/src/sprite.c
index 3e35a70..b94bf65 100644
--- a/src/gfx/ps1/src/sprite.c
+++ b/src/gfx/ps1/src/sprite.c
@@ -1,4 +1,5 @@
#include <gfx.h>
+#include <ps1/gfx_private.h>
#include <psxgpu.h>
#include <errno.h>
#include <inttypes.h>