git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/include/gb/sgb.h

      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-zero value if running on a Super GameBoy
     40 
     41     Since sgb_check() uses @ref sgb_transfer(), the same
     42     delay at startup requirement applies to ensure correct
     43     operation on PAL SNES. See @ref sgb_transfer() for details.
     44  * */
     45 uint8_t sgb_check(void) OLDCALL PRESERVES_REGS(b, c);
     46 
     47 /** Transfer a SGB packet
     48 
     49     @param packet    Pointer to buffer with SGB packet data.
     50 
     51     The first byte of __packet__ should be a SGB command,
     52     then up to 15 bytes of command parameter data.
     53 
     54     See the `sgb_border` GBDK example project for a
     55     demo of how to use these the sgb functions.
     56 
     57     When using the SGB with a PAL SNES, a delay should be added
     58     just after program startup such as:
     59 
     60     \code{.c}
     61     // Wait 4 frames
     62     // For PAL SNES this delay is required on startup
     63     for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
     64     \endcode
     65 
     66     @see sgb_check()
     67 */
     68 void sgb_transfer(uint8_t * packet) OLDCALL PRESERVES_REGS(b, c);
     69 
     70 #endif /* _SGB_H */

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.