| 1 | /* |
| 2 | * (C) GraÅžvydas "notaz" Ignotas, 2011 |
| 3 | * |
| 4 | * This work is licensed under the terms of any of these licenses |
| 5 | * (at your option): |
| 6 | * - GNU GPL, version 2 or later. |
| 7 | * - GNU LGPL, version 2.1 or later. |
| 8 | * See the COPYING file in the top-level directory. |
| 9 | */ |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | |
| 13 | #define CMD_BUFFER_LEN 1024 |
| 14 | |
| 15 | struct psx_gpu { |
| 16 | uint16_t vram[1024 * 512]; |
| 17 | uint16_t guard[1024 * 512]; // overdraw guard |
| 18 | uint32_t cmd_buffer[CMD_BUFFER_LEN]; |
| 19 | uint32_t regs[16]; |
| 20 | union { |
| 21 | uint32_t reg; |
| 22 | struct { |
| 23 | uint32_t tx:4; // 0 texture page |
| 24 | uint32_t ty:1; |
| 25 | uint32_t abr:2; |
| 26 | uint32_t tp:2; // 7 t.p. mode (4,8,15bpp) |
| 27 | uint32_t dtd:1; // 9 dither |
| 28 | uint32_t dfe:1; |
| 29 | uint32_t md:1; // 11 set mask bit when drawing |
| 30 | uint32_t me:1; // 12 no draw on mask |
| 31 | uint32_t unkn:3; |
| 32 | uint32_t width1:1; // 16 |
| 33 | uint32_t width0:2; |
| 34 | uint32_t dheight:1; // 19 double height |
| 35 | uint32_t video:1; // 20 NTSC,PAL |
| 36 | uint32_t rgb24:1; |
| 37 | uint32_t interlace:1; // 22 interlace on |
| 38 | uint32_t blanking:1; // 23 display not enabled |
| 39 | uint32_t unkn2:2; |
| 40 | uint32_t busy:1; // 26 !busy drawing |
| 41 | uint32_t img:1; // 27 ready to DMA image data |
| 42 | uint32_t com:1; // 28 ready for commands |
| 43 | uint32_t dma:2; // 29 off, ?, to vram, from vram |
| 44 | uint32_t lcf:1; // 31 |
| 45 | }; |
| 46 | } status; |
| 47 | struct { |
| 48 | int x, y, w, h; |
| 49 | int y1, y2; |
| 50 | } screen; |
| 51 | struct { |
| 52 | int x, y, w, h; |
| 53 | int offset; |
| 54 | } dma; |
| 55 | int cmd_len; |
| 56 | const uint32_t *lcf_hc; |
| 57 | uint32_t zero; |
| 58 | }; |
| 59 | |
| 60 | extern struct psx_gpu gpu; |
| 61 | |
| 62 | extern const unsigned char cmd_lengths[256]; |
| 63 | |
| 64 | void do_cmd_list(uint32_t *list, int count); |
| 65 | |
| 66 | int vout_init(void); |
| 67 | int vout_finish(void); |