27 #define SYSTEM_60HZ 0x00
28 #define SYSTEM_50HZ 0x01
30 #if defined(__TARGET_ap)
31 #define ANALOGUEPOCKET
32 #elif defined(__TARGET_gb)
34 #elif defined(__TARGET_duck)
58 #define J_SELECT 0x40U
65 #define M_DRAWING 0x01U
66 #define M_TEXT_OUT 0x02U
67 #define M_TEXT_INOUT 0x03U
73 #define M_NO_SCROLL 0x04U
77 #define M_NO_INTERP 0x08U
88 #define S_PALETTE 0x10U
101 #define S_PRIORITY 0x80U
110 #define EMPTY_IFLAG 0x00U
116 #define VBL_IFLAG 0x01U
120 #define LCD_IFLAG 0x02U
124 #define TIM_IFLAG 0x04U
128 #define SIO_IFLAG 0x08U
132 #define JOY_IFLAG 0x10U
136 #define DMG_BLACK 0x03
137 #define DMG_DARK_GRAY 0x02
138 #define DMG_LITE_GRAY 0x01
139 #define DMG_WHITE 0x00
159 #define DMG_PALETTE(C0, C1, C2, C3) ((uint8_t)((((C3) & 0x03) << 6) | (((C2) & 0x03) << 4) | (((C1) & 0x03) << 2) | ((C0) & 0x03)))
164 #define SCREENWIDTH DEVICE_SCREEN_PX_WIDTH
167 #define SCREENHEIGHT DEVICE_SCREEN_PX_HEIGHT
170 #define MINWNDPOSX DEVICE_WINDOW_PX_OFFSET_X
173 #define MINWNDPOSY DEVICE_WINDOW_PX_OFFSET_Y
176 #define MAXWNDPOSX (DEVICE_WINDOW_PX_OFFSET_X + DEVICE_SCREEN_PX_WIDTH - 1)
179 #define MAXWNDPOSY (DEVICE_WINDOW_PX_OFFSET_Y + DEVICE_SCREEN_PX_HEIGHT - 1)
433 #define DMG_TYPE 0x01
436 #define MGB_TYPE 0xFF
439 #define CGB_TYPE 0x11
449 #define GBA_NOT_DETECTED 0x00
452 #define GBA_DETECTED 0x01
456 #define DEVICE_SUPPORTS_COLOR (_cpu == CGB_TYPE)
499 #define IO_IDLE 0x00U
501 #define IO_SENDING 0x01U
503 #define IO_RECEIVING 0x02U
505 #define IO_ERROR 0x04U
523 #define CURRENT_BANK _current_bank
535 #define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
550 #define BANKREF(VARNAME) void __func_ ## VARNAME(void) __banked __naked { \
552 .local b___func_ ## VARNAME \
553 ___bank_ ## VARNAME = b___func_ ## VARNAME \
554 .globl ___bank_ ## VARNAME \
567 #define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
584 #define SWITCH_ROM(b) (_current_bank = (b), rROMB0 = (b))
586 #if defined(__TARGET_duck)
588 #define SWITCH_RAM(b) (0)
603 #define SWITCH_RAM(b) (rRAMB = (b))
607 #define ENABLE_RAM (rRAMG = 0x0A)
611 #define DISABLE_RAM (rRAMG = 0x00)
618 #define SWITCH_ROM_MEGADUCK(b) SWITCH_ROM(b)
628 #define SWITCH_ROM_MBC1(b) SWITCH_ROM(b)
637 #define SWITCH_RAM_MBC1(b) SWITCH_RAM(b)
641 #define ENABLE_RAM_MBC1 ENABLE_RAM
645 #define DISABLE_RAM_MBC1 DISABLE_RAM
647 #define SWITCH_16_8_MODE_MBC1 (*(volatile uint8_t *)0x6000 = 0x00)
649 #define SWITCH_4_32_MODE_MBC1 (*(volatile uint8_t *)0x6000 = 0x01)
663 #define SWITCH_ROM_MBC5(b) (_current_bank = (b), rROMB1 = 0, rROMB0 = (b))
678 #define SWITCH_ROM_MBC5_8M(b) (rROMB1 = ((uint16_t)(b) >> 8), rROMB0 = (b))
685 #define SWITCH_RAM_MBC5(b) SWITCH_RAM(b)
689 #define ENABLE_RAM_MBC5 ENABLE_RAM
693 #define DISABLE_RAM_MBC5 DISABLE_RAM
876 #define DISPLAY_OFF \
881 #define HIDE_LEFT_COLUMN
885 #define SHOW_LEFT_COLUMN
889 #define SET_BORDER_COLOR(C)
913 LCDC_REG&=~LCDCF_BGON
925 LCDC_REG|=LCDCF_WINON
931 LCDC_REG&=~LCDCF_WINON
936 #define SHOW_SPRITES \
937 LCDC_REG|=LCDCF_OBJON
944 #define HIDE_SPRITES \
945 LCDC_REG&=~LCDCF_OBJON
950 #define SPRITES_8x16 \
951 LCDC_REG|=LCDCF_OBJ16
956 #define SPRITES_8x8 \
957 LCDC_REG&=~LCDCF_OBJ16
988 #define COMPAT_PALETTE(C0,C1,C2,C3) ((uint8_t)(((C3) << 6) | ((C2) << 4) | ((C1) << 2) | (C0)))
1048 #define set_bkg_2bpp_data set_bkg_data
1146 #define set_tile_map set_bkg_tiles
1278 #define set_tile_submap set_bkg_submap
1398 #define set_tile_xy set_bkg_tile_xy
1416 #define set_attribute_xy set_bkg_attribute_xy
1762 #define set_sprite_2bpp_data set_sprite_data
1826 #define DISABLE_OAM_DMA \
1827 _shadow_OAM_base = 0
1831 #define DISABLE_VBL_TRANSFER DISABLE_OAM_DMA
1833 #define ENABLE_OAM_DMA \
1834 _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8)
1838 #define ENABLE_VBL_TRANSFER ENABLE_OAM_DMA
1842 #define MAX_HARDWARE_SPRITES 40
1846 #define HARDWARE_SPRITE_CAN_FLIP_X 1
1850 #define HARDWARE_SPRITE_CAN_FLIP_Y 1
1978 itm->
y+=
y, itm->
x+=
x;
2133 if (first_tile < 256) {
2210 #define fill_rect fill_bkg_rect
#define OLDCALL
Definition: types.h:21
#define NONBANKED
Definition: types.h:40
#define PRESERVES_REGS(...)
Definition: types.h:32
#define __REG
Definition: hardware.h:14
__REG WY_REG
Definition: hardware.h:305
__REG SCY_REG
Definition: hardware.h:289
__REG WX_REG
Definition: hardware.h:307
#define VBK_ATTRIBUTES
Definition: hardware.h:322
__REG IF_REG
Definition: hardware.h:88
__REG VBK_REG
Definition: hardware.h:316
#define VBK_TILES
Definition: hardware.h:320
__REG SCX_REG
Definition: hardware.h:291
void set_sprite_tile(uint8_t nb, uint8_t tile)
Definition: gb.h:1874
uint8_t d
Definition: gb.h:414
uint8_t c
Definition: gb.h:414
void set_bkg_attributes(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles)
Definition: gb.h:1224
void scroll_win(int8_t x, int8_t y)
Definition: gb.h:1740
void refresh_OAM(void) PRESERVES_REGS(b
void set_win_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile)
Definition: gb.h:1657
void set_bkg_submap_attributes(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w)
Definition: gb.h:1356
void set_1bpp_colors_ex(uint8_t fgcolor, uint8_t bgcolor, uint8_t mode) OLDCALL
void set_bkg_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
void scroll_bkg(int8_t x, int8_t y)
Definition: gb.h:1462
uint16_t _current_1bpp_colors
void set_vram_byte(uint8_t *addr, uint8_t v) PRESERVES_REGS(b
void vmemcpy(uint8_t *dest, uint8_t *sour, uint16_t len)
uint8_t get_win_tile_xy(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b
volatile uint8_t _io_status
void remove_SIO(int_handler h)
volatile struct OAM_item_t shadow_OAM[]
uint8_t * set_bkg_attribute_xy(uint8_t x, uint8_t y, uint8_t a)
Definition: gb.h:1408
uint8_t get_system(void)
Definition: gb.h:421
uint8_t joypad(void) PRESERVES_REGS(b
void init_bkg(uint8_t c) OLDCALL PRESERVES_REGS(b
void b
Definition: gb.h:736
void wait_int_handler(void)
void nowait_int_handler(void)
uint8_t get_bkg_tile_xy(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b
void get_bkg_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b
void set_win_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) OLDCALL PRESERVES_REGS(b
void set_data(uint8_t *vram_addr, const uint8_t *data, uint16_t len)
void add_low_priority_TIM(int_handler h)
void set_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, const uint8_t *tiles) OLDCALL
void remove_TIM(int_handler h)
void move_bkg(uint8_t x, uint8_t y)
Definition: gb.h:1448
void remove_JOY(int_handler h)
void remove_LCD(int_handler h)
void set_native_tile_data(uint16_t first_tile, uint8_t nb_tiles, const uint8_t *data)
Definition: gb.h:2132
uint8_t get_sprite_prop(uint8_t nb)
Definition: gb.h:1943
void scroll_sprite(uint8_t nb, int8_t x, int8_t y)
Definition: gb.h:1976
void set_bkg_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) OLDCALL PRESERVES_REGS(b
void set_bkg_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
void set_win_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile)
Definition: gb.h:1582
void fill_bkg_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile) OLDCALL PRESERVES_REGS(b
void get_data(uint8_t *data, uint8_t *vram_addr, uint16_t len)
volatile uint16_t sys_time
void delay(uint16_t d) PRESERVES_REGS(h
__REG _shadow_OAM_base
Definition: gb.h:1824
void SET_SHADOW_OAM_ADDRESS(void *address)
Definition: gb.h:1854
void get_win_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b
void set_bkg_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile)
Definition: gb.h:1169
void wait_vbl_done(void) PRESERVES_REGS(b
void add_VBL(int_handler h)
void get_win_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *tiles) OLDCALL PRESERVES_REGS(b
struct OAM_item_t OAM_item_t
uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b
void(* int_handler)(void) NONBANKED
Definition: gb.h:184
void hiramcpy(uint8_t dst, const void *src, uint8_t n) OLDCALL PRESERVES_REGS(b
void vmemset(void *s, uint8_t c, size_t n) OLDCALL PRESERVES_REGS(b
__REG _current_bank
Definition: gb.h:522
#define SYSTEM_60HZ
Definition: gb.h:27
void set_sprite_prop(uint8_t nb, uint8_t prop)
Definition: gb.h:1933
void add_TIM(int_handler h)
uint8_t get_mode(void) PRESERVES_REGS(b
void set_2bpp_palette(uint16_t palette)
Definition: gb.h:992
void get_bkg_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *tiles) OLDCALL PRESERVES_REGS(b
uint8_t * get_win_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b
void set_sprite_native_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data)
Definition: gb.h:2172
uint8_t * set_bkg_tile_xy(uint8_t x, uint8_t y, uint8_t t)
void enable_interrupts(void) PRESERVES_REGS(a
void display_off(void) PRESERVES_REGS(b
void set_sprite_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
void move_sprite(uint8_t nb, uint8_t x, uint8_t y)
Definition: gb.h:1960
uint8_t _submap_tile_offset
void joypad_ex(joypads_t *joypads) PRESERVES_REGS(b
uint8_t joypad_init(uint8_t npads, joypads_t *joypads) OLDCALL
uint8_t h
Definition: gb.h:414
uint8_t waitpad(uint8_t mask) PRESERVES_REGS(b
void set_bkg_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile)
Definition: gb.h:1302
void set_tile_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data, uint8_t base) OLDCALL PRESERVES_REGS(b
void set_win_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
uint8_t * set_win_tile_xy(uint8_t x, uint8_t y, uint8_t t)
void remove_VBL(int_handler h)
void set_bkg_native_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data)
Definition: gb.h:2155
void set_win_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
void hide_sprite(uint8_t nb)
Definition: gb.h:1988
void fill_win_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile) OLDCALL PRESERVES_REGS(b
void waitpadup(void) PRESERVES_REGS(a
void set_bkg_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) OLDCALL
Definition: msx.h:619
void set_1bpp_colors(uint8_t fgcolor, uint8_t bgcolor)
Definition: gb.h:1026
void get_sprite_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b
uint8_t cancel_pending_interrupts(void)
Definition: gb.h:398
void add_LCD(int_handler h)
uint8_t get_vram_byte(uint8_t *addr) PRESERVES_REGS(b
void add_JOY(int_handler h)
void disable_interrupts(void) PRESERVES_REGS(a
void set_sprite_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b
void add_SIO(int_handler h)
void set_interrupts(uint8_t flags) PRESERVES_REGS(b
uint8_t e
Definition: gb.h:414
void move_win(uint8_t x, uint8_t y)
Definition: gb.h:1726
void vsync(void) PRESERVES_REGS(b
uint8_t get_sprite_tile(uint8_t nb)
Definition: gb.h:1885
void init_win(uint8_t c) OLDCALL PRESERVES_REGS(b
uint8_t l
Definition: gb.h:414
void set_win_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) OLDCALL
Definition: msx.h:622
void get_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, uint8_t *tiles) OLDCALL
unsigned char uint8_t
Definition: stdint.h:51
unsigned short int uint16_t
Definition: stdint.h:52
signed char int8_t
Definition: stdint.h:43
uint8_t x
Definition: gb.h:1812
uint8_t prop
Definition: gb.h:1814
uint8_t tile
Definition: gb.h:1813
uint8_t y
Definition: gb.h:1812
uint8_t joy0
Definition: gb.h:747
uint8_t npads
Definition: gb.h:744