cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

sgb.h (3516B)


      1/** @file gb/sgb.h
      2    Super Gameboy definitions.
      3
      4    See the example SGB project for additional details.
      5*/
      6#ifndef _SGB_H
      7#define _SGB_H
      8
      9#include <types.h>
     10#include <stdint.h>
     11
     12#define SGB_PAL_01 0x00U    /**< SGB Command: Set SGB Palettes 0 & 1 */
     13#define SGB_PAL_23 0x01U    /**< SGB Command: Set SGB Palettes 2 & 3 */
     14#define SGB_PAL_03 0x02U    /**< SGB Command: Set SGB Palettes 0 & 3 */
     15#define SGB_PAL_12 0x03U    /**< SGB Command: Set SGB Palettes 1 & 2 */
     16#define SGB_ATTR_BLK 0x04U  /**< SGB Command: Set color attributes for rectangular regions */
     17#define SGB_ATTR_LIN 0x05U  /**< SGB Command: Set color attributes for horizontal or vertical character lines */
     18#define SGB_ATTR_DIV 0x06U  /**< SGB Command: Split screen in half and assign separate color attribes to each side and the divider */
     19#define SGB_ATTR_CHR 0x07U  /**< SGB Command: Set color attributes for separate charactersSet SGB Palette 0,1 Data */
     20#define SGB_SOUND 0x08U     /**< SGB Command: Start and stop a internal sound effect, and sounds using internal tone data */
     21#define SGB_SOU_TRN 0x09U   /**< SGB Command: Transfer sound code or data to the SNES APU RAM */
     22#define SGB_PAL_SET 0x0AU   /**< SGB Command: Apply (previously transferred) SGB system color palettes to actual SNES palettes */
     23#define SGB_PAL_TRN 0x0BU   /**< SGB Command: Transfer palette data into SGB system color palettes */
     24#define SGB_ATRC_EN 0x0CU   /**< SGB Command: Enable/disable Attraction mode. It is enabled by default */
     25#define SGB_TEST_EN 0x0DU   /**< SGB Command: Enable/disable test mode for "SGB-CPU variable clock speed function" */
     26#define SGB_ICON_EN 0x0EU   /**< SGB Command: Enable/disable ICON functionality */
     27#define SGB_DATA_SND 0x0FU  /**< SGB Command: Write one or more bytes into SNES Work RAM */
     28#define SGB_DATA_TRN 0x10U  /**< SGB Command: Transfer code or data into SNES RAM */
     29#define SGB_MLT_REQ 0x11U   /**< SGB Command: Request multiplayer mode (input from more than one joypad) */
     30#define SGB_JUMP 0x12U      /**< SGB Command: Set the SNES program counter and NMI (vblank interrupt) handler to specific addresses */
     31#define SGB_CHR_TRN 0x13U   /**< SGB Command: Transfer tile data (characters) to SNES Tile memory */
     32#define SGB_PCT_TRN 0x14U   /**< SGB Command: Transfer tile map and palette data to SNES BG Map memory */
     33#define SGB_ATTR_TRN 0x15U  /**< SGB Command: Transfer data to (color) Attribute Files (ATFs) in SNES RAM */
     34#define SGB_ATTR_SET 0x16U  /**< SGB Command: Transfer attributes from (color) Attribute Files (ATF) to the Game Boy window */
     35#define SGB_MASK_EN 0x17U   /**< SGB Command: Modify Game Boy window mask settings */
     36#define SGB_OBJ_TRN 0x18U   /**< SGB Command: Transfer OBJ attributes to SNES OAM memory */
     37
     38
     39/** Returns a non-null value if running on Super GameBoy */
     40uint8_t sgb_check() OLDCALL PRESERVES_REGS(b, c);
     41
     42/** Transfer a SGB packet
     43
     44    @param packet    Pointer to buffer with SGB packet data.
     45
     46    The first byte of __packet__ should be a SGB command,
     47    then up to 15 bytes of command parameter data.
     48
     49    See the `sgb_border` GBDK example project for a
     50    demo of how to use these the sgb functions.
     51
     52    When using the SGB with a PAL SNES, a delay should be added
     53    just after program startup such as:
     54
     55    \code{.c}
     56    // Wait 4 frames
     57    // For PAL SNES this delay is required on startup
     58    for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
     59    \endcode
     60
     61    @see sgb_check()
     62*/
     63void sgb_transfer(uint8_t * packet) OLDCALL PRESERVES_REGS(b, c);
     64
     65#endif /* _SGB_H */