summaryrefslogtreecommitdiff
path: root/src/gfx/inc/gfx.h
blob: 849fc8ed86af974d0a21c771c52d109fdb9461d8 (plain) (blame)
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
#ifndef GFX_H
#define GFX_H

#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

enum
{
    SCREEN_X = 368,
    SCREEN_Y = 240
};

/*   0-3   Texture page X Base   (N*64) (ie. in 64-halfword steps)    ;GPUSTAT.0-3
  4     Texture page Y Base   (N*256) (ie. 0 or 256)               ;GPUSTAT.4
  5-6   Semi Transparency     (0=B/2+F/2, 1=B+F, 2=B-F, 3=B+F/4)   ;GPUSTAT.5-6
  7-8   Texture page colors   (0=4bit, 1=8bit, 2=15bit, 3=Reserved);GPUSTAT.7-8
  9     Dither 24bit to 15bit (0=Off/strip LSBs, 1=Dither Enabled) ;GPUSTAT.9
  10    Drawing to display area (0=Prohibited, 1=Allowed)          ;GPUSTAT.10
  11    Texture Disable (0=Normal, 1=Disable if GP1(09h).Bit0=1)   ;GPUSTAT.15
          (Above might be chipselect for (absent) second VRAM chip?)
  12    Textured Rectangle X-Flip   (BIOS does set this bit on power-up...?)
  13    Textured Rectangle Y-Flip   (BIOS does set it equal to GPUSTAT.13...?)
  14-23 Not used (should be 0)
  24-31 Command  (E1h)*/
union gfx_common
{
    struct
    {
        uint32_t tpagex :4;
        uint32_t tpagey :1;
        uint32_t stp :2;
        uint32_t bpp :2;
        uint32_t dither :1;
        uint32_t draw_to_disp :1;
        uint32_t disable :1;
        uint32_t xflip :1;
        uint32_t yflip :1;
        uint32_t :10;
        uint8_t cmd;
    };

    uint32_t mask;
};

union gfx_sznext
{
    struct
    {
        uint32_t next :24;
        uint32_t sz :8;
    };

    uint32_t cmd_next;
};

struct gfx_sprite
{
    union gfx_sznext sznext;
    union gfx_common common;
    uint8_t r, g, b;
    uint8_t cmd;
    uint16_t x, y;
    uint16_t clutid;
    uint8_t u, v;
    uint16_t w, h;
};

int gfx_init(void);
void gfx_draw(void);
void gfx_sprite_init(struct gfx_sprite *s);
void gfx_sprite_sort(struct gfx_sprite *s);
int gfx_sprite_from_file(const char *path, struct gfx_sprite *s);

#ifdef __cplusplus
}
#endif

#endif /* GFX_H */