23#ifndef __WF_LIBWS_DISPLAY_H__
24#define __WF_LIBWS_DISPLAY_H__
34#define DISPLAY_WIDTH 28
35#define DISPLAY_HEIGHT 18
36#define DISPLAY_WIDTH_PX (DISPLAY_WIDTH * TILE_WIDTH)
37#define DISPLAY_HEIGHT_PX (DISPLAY_HEIGHT * TILE_HEIGHT)
42#define TILE_4BPP_LENGTH 32
52#define SCR_ATTR_TILE(x) (x)
53#define SCR_ATTR_TILE_MASK (0x1FF)
54#define SCR_ATTR_PALETTE(x) ((x) << 9)
55#define SCR_ATTR_PALETTE_MASK (0xF << 9)
56#define SCR_ATTR_BANK(x) ((x) << 13)
57#define SCR_ATTR_BANK_MASK (0x2000)
58#define SCR_ATTR_TILE_EX(x) (((x) & 0x1FF) | (((x) >> 13) << 13))
59#define SCR_ATTR_TILE_EX_MASK (0x21FF)
60#define SCR_ATTR_TILE_BANK_MASK (SCR_ATTR_TILE_MASK | SCR_ATTR_BANK_MASK)
62#define SCR_ATTR_FLIP_H 0x4000
63#define SCR_ATTR_FLIP_V 0x8000
64#define SCR_ATTR_FLIP 0xC000
65#define SCR_ATTR_FLIP_MASK 0xC000
82#define SCR_WIDTH_PX (SCR_WIDTH * TILE_WIDTH)
83#define SCR_HEIGHT_PX (SCR_HEIGHT * TILE_HEIGHT)
101#define SPR_ATTR_PALETTE(x) ((x) << 9)
102#define SPR_ATTR_PALETTE_MASK (0x7 << 9)
103#define SPR_ATTR_INSIDE 0x1000
104#define SPR_ATTR_PRIORITY 0x2000
105#define SPR_ATTR_FLIP_H 0x4000
106#define SPR_ATTR_FLIP_V 0x8000
108#define SPR_MAX_COUNT 128
112#define SCR_ENTRY_TILE(x) (x)
113#define SCR_ENTRY_TILE_MASK (0x1FF)
114#define SCR_ENTRY_PALETTE(x) ((x) << 9)
115#define SCR_ENTRY_PALETTE_MASK (0xF << 9)
116#define SCR_ENTRY_BANK(x) ((x) << 13)
117#define SCR_ENTRY_BANK_MASK (0x2000)
118#define SCR_ENTRY_TILE_EX(x) (((x) & 0x1FF) | (((x) >> 13) << 13))
119#define SCR_ENTRY_TILE_EX_MASK (0x21FF)
120#define SCR_ENTRY_TILE_BANK_MASK (SCR_ENTRY_TILE_MASK | SCR_ENTRY_BANK_MASK)
122#define SCR_ENTRY_FLIP_H 0x4000
123#define SCR_ENTRY_FLIP_V 0x8000
124#define SCR_ENTRY_FLIP 0xC000
125#define SCR_ENTRY_FLIP_MASK 0xC000
127#define ws_scr_entry_t ws_screen_cell_t
129#define SPR_ENTRY_PALETTE(x) ((x) << 9)
130#define SPR_ENTRY_PALETTE_MASK (0x7 << 9)
131#define SPR_ENTRY_INSIDE 0x1000
132#define SPR_ENTRY_PRIORITY 0x2000
133#define SPR_ENTRY_FLIP_H 0x4000
134#define SPR_ENTRY_FLIP_V 0x8000
146#define MEM_TILE(i) ((uint8_t __wf_iram*) (0x2000 + ((i) << 4)))
153#define MEM_TILE_4BPP(i) MEM_TILE_4BPP_BANK0(i)
160#define MEM_TILE_4BPP_BANK0(i) ((uint8_t __wf_iram*) (0x4000 + ((i) << 5)))
167#define MEM_TILE_4BPP_BANK1(i) ((uint8_t __wf_iram*) (0x8000 + ((i) << 5)))
174#define MEM_COLOR_PALETTE(i) ((uint16_t __wf_iram*) (0xFE00 + ((i) << 5)))
181#define MEM_SCR_PALETTE MEM_COLOR_PALETTE
188#define MEM_SPR_PALETTE(i) ((uint16_t __wf_iram*) (0xFF00 + ((i) << 5)))
192#define SHADE_LUT(c0, c1, c2, c3, c4, c5, c6, c7) \
193 (((uint32_t)(c0)) | (((uint32_t)(c1)) << 4) | (((uint32_t)(c2)) << 8) | (((uint32_t)(c3)) << 12) | \
194 (((uint32_t)(c4)) << 16) | (((uint32_t)(c5)) << 20) | (((uint32_t)(c6)) << 24) | (((uint32_t)(c7)) << 28))
195#define SHADE_LUT_DEFAULT SHADE_LUT(0, 2, 4, 6, 9, 11, 13, 15)
209#define RGB(r, g, b) (((r) << 8) | ((g) << 4) | (b))
219void ws_display_set_shade_lut(uint32_t lut);
231static inline void ws_screen_put_tiles(
void __wf_iram* dest,
const void __far* src, uint16_t x, uint16_t y, uint16_t width, uint16_t height) {
232 void __libws_screen_put_tiles(
void __wf_iram* dest,
const void __far* src, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t pitch);
233 __libws_screen_put_tiles(dest, src, x, y, width, height, width);
250static inline void ws_screen_put_tiles_ex(
void __wf_iram* dest,
const void __far* src, uint16_t sx, uint16_t sy, uint16_t pitch, uint16_t dx, uint16_t dy, uint16_t width, uint16_t height) {
251 void __libws_screen_put_tiles(
void __wf_iram* dest,
const void __far* src, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t pitch);
252 __libws_screen_put_tiles(dest, ((
const uint16_t __far*) src) + (sy * pitch) + sx, dx, dy, width, height, pitch);
265void ws_screen_get_tiles(
void __far* dest,
const void __wf_iram* src, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
277void ws_screen_fill_tiles(
void __wf_iram* dest, uint16_t src, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
290void ws_screen_modify_tiles(
void __wf_iram* dest, uint16_t mask, uint16_t value, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
301 ((uint16_t __wf_iram*) dest)[((y & 0x1F) << 5) | (x & 0x1F)] = src;
312 return ((uint16_t __wf_iram*) src)[((y & 0x1F) << 5) | (x & 0x1F)];
void ws_screen_fill_tiles(void __wf_iram *dest, uint16_t src, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
Fill an area on the screen with a given tile.
__attribute__((no_assume_ds_data, no_assume_ss_data, save_all)) void ws_display_set_shade_lut(uint32_t lut)
Configure the shade LUT.
static void ws_screen_put_tile(void __wf_iram *dest, uint16_t src, uint16_t x, uint16_t y)
Put a tile on the screen.
void ws_screen_get_tiles(void __far *dest, const void __wf_iram *src, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
Copy a map of tiles from the screen.
void ws_screen_modify_tiles(void __wf_iram *dest, uint16_t mask, uint16_t value, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
Modify an area on the screen with given data.
static uint16_t ws_screen_get_tile(void __wf_iram *src, uint16_t x, uint16_t y)
Get a tile on the screen.
static void ws_screen_put_tiles(void __wf_iram *dest, const void __far *src, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
Place a map of tiles on the screen.
static void ws_screen_put_tiles_ex(void __wf_iram *dest, const void __far *src, uint16_t sx, uint16_t sy, uint16_t pitch, uint16_t dx, uint16_t dy, uint16_t width, uint16_t height)
Place a map of tiles on the screen. This varianta llows specifying the source X position,...