16 #if defined(__TARGET_ap)
17 #define ANALOGUEPOCKET
18 #elif defined(__TARGET_gb)
20 #elif defined(__TARGET_duck)
44 #define J_SELECT 0x40U
51 #define M_DRAWING 0x01U
52 #define M_TEXT_OUT 0x02U
53 #define M_TEXT_INOUT 0x03U
59 #define M_NO_SCROLL 0x04U
63 #define M_NO_INTERP 0x08U
69 #define S_PALETTE 0x10U
82 #define S_PRIORITY 0x80U
91 #define EMPTY_IFLAG 0x00U
97 #define VBL_IFLAG 0x01U
101 #define LCD_IFLAG 0x02U
105 #define TIM_IFLAG 0x04U
109 #define SIO_IFLAG 0x08U
113 #define JOY_IFLAG 0x10U
117 #define DMG_BLACK 0x03
118 #define DMG_DARK_GRAY 0x02
119 #define DMG_LITE_GRAY 0x01
120 #define DMG_WHITE 0x00
140 #define DMG_PALETTE(C0, C1, C2, C3) ((uint8_t)((((C3) & 0x03) << 6) | (((C2) & 0x03) << 4) | (((C1) & 0x03) << 2) | ((C0) & 0x03)))
145 #define SCREENWIDTH DEVICE_SCREEN_PX_WIDTH
148 #define SCREENHEIGHT DEVICE_SCREEN_PX_HEIGHT
151 #define MINWNDPOSX 0x07U
154 #define MINWNDPOSY 0x00U
157 #define MAXWNDPOSX 0xA6U
160 #define MAXWNDPOSY 0x8FU
388 #define DMG_TYPE 0x01
391 #define MGB_TYPE 0xFF
394 #define CGB_TYPE 0x11
404 #define GBA_NOT_DETECTED 0x00
407 #define GBA_DETECTED 0x01
411 #define DEVICE_SUPPORTS_COLOR (_cpu == CGB_TYPE)
454 #define IO_IDLE 0x00U
456 #define IO_SENDING 0x01U
458 #define IO_RECEIVING 0x02U
460 #define IO_ERROR 0x04U
475 #define CURRENT_BANK _current_bank
487 #define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
502 #define BANKREF(VARNAME) void __func_ ## VARNAME(void) __banked __naked { \
504 .local b___func_ ## VARNAME \
505 ___bank_ ## VARNAME = b___func_ ## VARNAME \
506 .globl ___bank_ ## VARNAME \
519 #define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
536 #define SWITCH_ROM(b) (_current_bank = (b), rROMB0 = (b))
538 #define SWITCH_RAM(b) (rRAMB = (b))
540 #define ENABLE_RAM (rRAMG = 0x0A)
542 #define DISABLE_RAM (rRAMG = 0x00)
547 #define SWITCH_ROM_MEGADUCK(b) SWITCH_ROM(b)
557 #define SWITCH_ROM_MBC1(b) SWITCH_ROM(b)
562 #define SWITCH_RAM_MBC1(b) SWITCH_RAM(b)
572 #define ENABLE_RAM_MBC1 ENABLE_RAM
576 #define DISABLE_RAM_MBC1 DISABLE_RAM
578 #define SWITCH_16_8_MODE_MBC1 (*(volatile uint8_t *)0x6000 = 0x00)
580 #define SWITCH_4_32_MODE_MBC1 (*(volatile uint8_t *)0x6000 = 0x01)
594 #define SWITCH_ROM_MBC5(b) (_current_bank = (b), rROMB1 = 0, rROMB0 = (b))
609 #define SWITCH_ROM_MBC5_8M(b) (rROMB1 = ((uint16_t)(b) >> 8), rROMB0 = (b))
614 #define SWITCH_RAM_MBC5(b) SWITCH_RAM(b)
618 #define ENABLE_RAM_MBC5 ENABLE_RAM
622 #define DISABLE_RAM_MBC5 DISABLE_RAM
795 #define DISPLAY_OFF \
800 #define HIDE_LEFT_COLUMN
804 #define SHOW_LEFT_COLUMN
816 LCDC_REG&=~LCDCF_BGON
828 LCDC_REG|=LCDCF_WINON
834 LCDC_REG&=~LCDCF_WINON
839 #define SHOW_SPRITES \
840 LCDC_REG|=LCDCF_OBJON
847 #define HIDE_SPRITES \
848 LCDC_REG&=~LCDCF_OBJON
853 #define SPRITES_8x16 \
854 LCDC_REG|=LCDCF_OBJ16
859 #define SPRITES_8x8 \
860 LCDC_REG&=~LCDCF_OBJ16
886 #define COMPAT_PALETTE(C0,C1,C2,C3) ((uint8_t)(((C3) << 6) | ((C2) << 4) | ((C1) << 2) | (C0)))
946 #define set_bkg_2bpp_data set_bkg_data
1038 #define set_tile_map set_bkg_tiles
1168 #define set_tile_submap set_bkg_submap
1281 #define set_tile_xy set_bkg_tile_xy
1601 #define set_sprite_2bpp_data set_sprite_data
1659 #define DISABLE_OAM_DMA \
1660 _shadow_OAM_base = 0
1664 #define DISABLE_VBL_TRANSFER DISABLE_OAM_DMA
1666 #define ENABLE_OAM_DMA \
1667 _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8)
1671 #define ENABLE_VBL_TRANSFER ENABLE_OAM_DMA
1675 #define MAX_HARDWARE_SPRITES 40
1679 #define HARDWARE_SPRITE_CAN_FLIP_X 1
1683 #define HARDWARE_SPRITE_CAN_FLIP_Y 1
1798 itm->
y+=
y, itm->
x+=
x;
1941 if (first_tile < 256) {
1983 #define fill_rect fill_bkg_rect
#define OLDCALL
Definition: types.h:21
#define NONBANKED
Definition: types.h:38
#define PRESERVES_REGS(...)
Definition: types.h:31
#define __REG
Definition: hardware.h:14
__REG WY_REG
Definition: hardware.h:301
__REG SCY_REG
Definition: hardware.h:285
__REG WX_REG
Definition: hardware.h:303
#define VBK_ATTRIBUTES
Definition: hardware.h:318
__REG IF_REG
Definition: hardware.h:84
__REG VBK_REG
Definition: hardware.h:312
#define VBK_TILES
Definition: hardware.h:316
__REG SCX_REG
Definition: hardware.h:287
void set_sprite_tile(uint8_t nb, uint8_t tile)
Definition: gb.h:1707
void d
Definition: gb.h:665
uint8_t c
Definition: gb.h:378
void set_bkg_attributes(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles)
Definition: gb.h:1114
uint8_t * set_win_tile_xy(uint8_t x, uint8_t y, uint8_t t) OLDCALL PRESERVES_REGS(b
void scroll_win(int8_t x, int8_t y)
Definition: gb.h:1579
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:1508
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:1244
void set_1bpp_colors_ex(uint8_t fgcolor, uint8_t bgcolor, uint8_t mode) OLDCALL
uint8_t h
Definition: gb.h:644
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:1319
uint16_t _current_1bpp_colors
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[]
void mode(uint8_t m) OLDCALL
uint8_t joypad(void) PRESERVES_REGS(b
void init_bkg(uint8_t c) OLDCALL PRESERVES_REGS(b
void b
Definition: gb.h:665
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:1305
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:1940
uint8_t get_sprite_prop(uint8_t nb)
Definition: gb.h:1763
void scroll_sprite(uint8_t nb, int8_t x, int8_t y)
Definition: gb.h:1796
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_vram_byte(uint8_t *addr, uint8_t v) 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:1433
void fill_bkg_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile) OLDCALL PRESERVES_REGS(b
uint8_t * set_bkg_tile_xy(uint8_t x, uint8_t y, uint8_t t) 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:1657
uint8_t get_mode(void) OLDCALL PRESERVES_REGS(b
void SET_SHADOW_OAM_ADDRESS(void *address)
Definition: gb.h:1687
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:1061
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:165
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:474
void set_sprite_prop(uint8_t nb, uint8_t prop)
Definition: gb.h:1753
void add_TIM(int_handler h)
void set_2bpp_palette(uint16_t palette)
Definition: gb.h:890
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 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:1780
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 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:1192
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
void remove_VBL(int_handler h)
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:1808
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:554
void set_1bpp_colors(uint8_t fgcolor, uint8_t bgcolor)
Definition: gb.h:924
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:362
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
void e
Definition: gb.h:665
void move_win(uint8_t x, uint8_t y)
Definition: gb.h:1565
void vsync(void) PRESERVES_REGS(b
uint8_t get_sprite_tile(uint8_t nb)
Definition: gb.h:1718
void init_win(uint8_t c) OLDCALL PRESERVES_REGS(b
void l
Definition: gb.h:630
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:557
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:1645
uint8_t prop
Definition: gb.h:1647
uint8_t tile
Definition: gb.h:1646
uint8_t y
Definition: gb.h:1645
uint8_t joy0
Definition: gb.h:676
uint8_t npads
Definition: gb.h:673