2019-04-25 05:19:47 +00:00
|
|
|
#ifndef _LCD_H
|
|
|
|
#define _LCD_H
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#define LCD_WIDTH 160
|
|
|
|
#define LCD_HEIGHT 144
|
|
|
|
|
2019-10-22 06:30:19 +00:00
|
|
|
#define REG_LCD_BASE 0xff40
|
|
|
|
|
|
|
|
#define REG_LCDC 0xff40
|
|
|
|
#define REG_STAT 0xff41
|
|
|
|
#define REG_SCY 0xff42
|
|
|
|
#define REG_SCX 0xff43
|
|
|
|
#define REG_LY 0xff44
|
|
|
|
#define REG_LYC 0xff45
|
|
|
|
#define REG_DMA 0xff46
|
|
|
|
#define REG_BGP 0xff47
|
|
|
|
#define REG_OBP0 0xff48
|
|
|
|
#define REG_OBP1 0xff49
|
|
|
|
#define REG_WY 0xff4a
|
|
|
|
#define REG_WX 0xff4b
|
|
|
|
|
|
|
|
#define REG_LCD_LAST REG_WX
|
|
|
|
|
|
|
|
#define STAT_FLAG_MATCH 2
|
|
|
|
|
2022-06-29 03:41:26 +00:00
|
|
|
#define LCDC_ENABLE_BG (1 << 0)
|
|
|
|
#define LCDC_ENABLE_OBJ (1 << 1)
|
|
|
|
#define LCDC_OBJ_SIZE (1 << 2)
|
|
|
|
#define LCDC_BG_TILE_MAP (1 << 3)
|
|
|
|
#define LCDC_BG_TILE_DATA (1 << 4)
|
|
|
|
#define LCDC_ENABLE_WINDOW (1 << 5)
|
|
|
|
#define LCDC_WINDOW_TILE_MAP (1 << 6)
|
|
|
|
#define LCDC_ENABLE (1 << 7)
|
|
|
|
|
2019-04-25 05:19:47 +00:00
|
|
|
struct lcd {
|
2022-06-29 03:41:26 +00:00
|
|
|
u8 oam[0xa0];
|
2019-10-22 06:30:19 +00:00
|
|
|
u8 regs[0x0c];
|
2022-06-29 03:41:26 +00:00
|
|
|
u8 *buf; // 256x256
|
|
|
|
u8 *pixels; // the actual 160x144 visible area
|
2019-04-25 05:19:47 +00:00
|
|
|
};
|
|
|
|
|
2022-06-21 00:52:54 +00:00
|
|
|
void lcd_new(struct lcd *lcd);
|
2019-10-22 06:30:19 +00:00
|
|
|
u8 lcd_is_valid_addr(u16 addr);
|
|
|
|
u8 lcd_read(struct lcd *lcd, u16 addr);
|
|
|
|
void lcd_write(struct lcd *lcd, u16 addr, u8 value);
|
|
|
|
|
2019-04-25 05:19:47 +00:00
|
|
|
void lcd_put_pixel(struct lcd *lcd, u8 x, u8 y, u8 value);
|
|
|
|
|
2019-10-22 06:30:19 +00:00
|
|
|
// i feel like i'm going to need to call this every cycle and update regs
|
2022-06-29 03:41:26 +00:00
|
|
|
int lcd_step(struct lcd *lcd);
|
|
|
|
void lcd_copy(struct lcd *lcd);
|
2019-10-22 06:30:19 +00:00
|
|
|
|
2022-06-29 03:41:26 +00:00
|
|
|
// output the pixels to the screen
|
2022-06-29 02:49:10 +00:00
|
|
|
void lcd_draw(struct lcd *lcd);
|
|
|
|
|
2019-04-25 05:19:47 +00:00
|
|
|
#endif
|