\section{gb.h File Reference}
\label{gb.h}\index{gb.h@{gb.h}}
Gameboy specific functions. 


\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf J\_\-START}
\begin{CompactList}\small\item\em Joypad bits.\item\end{CompactList}

\item 
\#define {\bf M\_\-DRAWING}
\begin{CompactList}\small\item\em Screen modes.\item\end{CompactList}

\item 
\label{gb.h_a11}
\index{M_NO_SCROLL@{M\_\-NO\_\-SCROLL}!gb.h@{gb.h}}\index{gb.h@{gb.h}!M_NO_SCROLL@{M\_\-NO\_\-SCROLL}}
\#define {\bf M\_\-NO\_\-SCROLL}
\begin{CompactList}\small\item\em Set this in addition to the others to disable scrolling If scrolling is disabled, the cursor returns to (0,0).\item\end{CompactList}

\item 
\label{gb.h_a12}
\index{M_NO_INTERP@{M\_\-NO\_\-INTERP}!gb.h@{gb.h}}\index{gb.h@{gb.h}!M_NO_INTERP@{M\_\-NO\_\-INTERP}}
\#define {\bf M\_\-NO\_\-INTERP}
\begin{CompactList}\small\item\em Set this to disable $\backslash$n interpretation.\item\end{CompactList}

\item 
\#define {\bf S\_\-PALETTE}
\begin{CompactList}\small\item\em If this is set, sprite colours come from OBJ1PAL.\item\end{CompactList}

\item 
\label{gb.h_a14}
\index{S_FLIPX@{S\_\-FLIPX}!gb.h@{gb.h}}\index{gb.h@{gb.h}!S_FLIPX@{S\_\-FLIPX}}
\#define {\bf S\_\-FLIPX}
\begin{CompactList}\small\item\em If set the sprite will be flipped horizontally.\item\end{CompactList}

\item 
\label{gb.h_a15}
\index{S_FLIPY@{S\_\-FLIPY}!gb.h@{gb.h}}\index{gb.h@{gb.h}!S_FLIPY@{S\_\-FLIPY}}
\#define {\bf S\_\-FLIPY}
\begin{CompactList}\small\item\em If set the sprite will be flipped vertically.\item\end{CompactList}

\item 
\label{gb.h_a16}
\index{S_PRIORITY@{S\_\-PRIORITY}!gb.h@{gb.h}}\index{gb.h@{gb.h}!S_PRIORITY@{S\_\-PRIORITY}}
\#define {\bf S\_\-PRIORITY}
\begin{CompactList}\small\item\em If this bit is clear, then the sprite will be displayed ontop of the background and window.\item\end{CompactList}

\item 
\#define {\bf VBL\_\-IFLAG}
\begin{CompactList}\small\item\em Vertical blank interrupt.\item\end{CompactList}

\item 
\#define {\bf LCD\_\-IFLAG}
\begin{CompactList}\small\item\em Interrupt when triggered by the STAT register.\item\end{CompactList}

\item 
\label{gb.h_a19}
\index{TIM_IFLAG@{TIM\_\-IFLAG}!gb.h@{gb.h}}\index{gb.h@{gb.h}!TIM_IFLAG@{TIM\_\-IFLAG}}
\#define {\bf TIM\_\-IFLAG}
\begin{CompactList}\small\item\em Interrupt when the timer TIMA overflows.\item\end{CompactList}

\item 
\label{gb.h_a20}
\index{SIO_IFLAG@{SIO\_\-IFLAG}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SIO_IFLAG@{SIO\_\-IFLAG}}
\#define {\bf SIO\_\-IFLAG}
\begin{CompactList}\small\item\em Occurs when the serial transfer has completed.\item\end{CompactList}

\item 
\label{gb.h_a21}
\index{JOY_IFLAG@{JOY\_\-IFLAG}!gb.h@{gb.h}}\index{gb.h@{gb.h}!JOY_IFLAG@{JOY\_\-IFLAG}}
\#define {\bf JOY\_\-IFLAG}
\begin{CompactList}\small\item\em Occurs on a transition of the keypad.\item\end{CompactList}

\item 
\label{gb.h_a22}
\index{SCREENWIDTH@{SCREENWIDTH}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SCREENWIDTH@{SCREENWIDTH}}
\#define {\bf SCREENWIDTH}
\begin{CompactList}\small\item\em Width of the visible screen in pixels.\item\end{CompactList}

\item 
\label{gb.h_a23}
\index{SCREENHEIGHT@{SCREENHEIGHT}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SCREENHEIGHT@{SCREENHEIGHT}}
\#define {\bf SCREENHEIGHT}
\begin{CompactList}\small\item\em Height of the visible screen in pixels.\item\end{CompactList}

\item 
\label{gb.h_a28}
\index{DMG_TYPE@{DMG\_\-TYPE}!gb.h@{gb.h}}\index{gb.h@{gb.h}!DMG_TYPE@{DMG\_\-TYPE}}
\#define {\bf DMG\_\-TYPE}
\begin{CompactList}\small\item\em Original GB or Super GB.\item\end{CompactList}

\item 
\label{gb.h_a29}
\index{MGB_TYPE@{MGB\_\-TYPE}!gb.h@{gb.h}}\index{gb.h@{gb.h}!MGB_TYPE@{MGB\_\-TYPE}}
\#define {\bf MGB\_\-TYPE}
\begin{CompactList}\small\item\em Pocket GB or Super GB 2.\item\end{CompactList}

\item 
\label{gb.h_a30}
\index{CGB_TYPE@{CGB\_\-TYPE}!gb.h@{gb.h}}\index{gb.h@{gb.h}!CGB_TYPE@{CGB\_\-TYPE}}
\#define {\bf CGB\_\-TYPE}
\begin{CompactList}\small\item\em Color GB.\item\end{CompactList}

\item 
\label{gb.h_a31}
\index{IO_IDLE@{IO\_\-IDLE}!gb.h@{gb.h}}\index{gb.h@{gb.h}!IO_IDLE@{IO\_\-IDLE}}
\#define {\bf IO\_\-IDLE}
\begin{CompactList}\small\item\em IO is completed.\item\end{CompactList}

\item 
\label{gb.h_a32}
\index{IO_SENDING@{IO\_\-SENDING}!gb.h@{gb.h}}\index{gb.h@{gb.h}!IO_SENDING@{IO\_\-SENDING}}
\#define {\bf IO\_\-SENDING}
\begin{CompactList}\small\item\em Sending data.\item\end{CompactList}

\item 
\label{gb.h_a33}
\index{IO_RECEIVING@{IO\_\-RECEIVING}!gb.h@{gb.h}}\index{gb.h@{gb.h}!IO_RECEIVING@{IO\_\-RECEIVING}}
\#define {\bf IO\_\-RECEIVING}
\begin{CompactList}\small\item\em Receiving data.\item\end{CompactList}

\item 
\label{gb.h_a34}
\index{IO_ERROR@{IO\_\-ERROR}!gb.h@{gb.h}}\index{gb.h@{gb.h}!IO_ERROR@{IO\_\-ERROR}}
\#define {\bf IO\_\-ERROR}
\begin{CompactList}\small\item\em Error.\item\end{CompactList}

\item 
\#define {\bf SWITCH\_\-ROM\_\-MBC1} (b) 
\begin{CompactList}\small\item\em Switches the upper 16k bank of the 32k rom to bank rombank using the MBC1 controller.\item\end{CompactList}

\item 
\label{gb.h_a36}
\index{SWITCH_RAM_MBC1@{SWITCH\_\-RAM\_\-MBC1}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SWITCH_RAM_MBC1@{SWITCH\_\-RAM\_\-MBC1}}
\#define {\bf SWITCH\_\-RAM\_\-MBC1} (b) 
\item 
\label{gb.h_a39}
\index{SWITCH_ROM_MBC5@{SWITCH\_\-ROM\_\-MBC5}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SWITCH_ROM_MBC5@{SWITCH\_\-ROM\_\-MBC5}}
\#define {\bf SWITCH\_\-ROM\_\-MBC5} (b) 
\begin{CompactList}\small\item\em MBC5.\item\end{CompactList}

\item 
\label{gb.h_a40}
\index{SWITCH_RAM_MBC5@{SWITCH\_\-RAM\_\-MBC5}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SWITCH_RAM_MBC5@{SWITCH\_\-RAM\_\-MBC5}}
\#define {\bf SWITCH\_\-RAM\_\-MBC5} (b) 
\item 
\#define {\bf DISPLAY\_\-ON}
\begin{CompactList}\small\item\em Turns the display back on.\item\end{CompactList}

\item 
\#define {\bf DISPLAY\_\-OFF}
\begin{CompactList}\small\item\em Turns the display off immediatly.\item\end{CompactList}

\item 
\#define {\bf SHOW\_\-BKG}
\begin{CompactList}\small\item\em Turns on the background layer.\item\end{CompactList}

\item 
\#define {\bf HIDE\_\-BKG}
\begin{CompactList}\small\item\em Turns off the background layer.\item\end{CompactList}

\item 
\label{gb.h_a47}
\index{SHOW_WIN@{SHOW\_\-WIN}!gb.h@{gb.h}}\index{gb.h@{gb.h}!SHOW_WIN@{SHOW\_\-WIN}}
\#define {\bf SHOW\_\-WIN}
\begin{CompactList}\small\item\em Turns on the window layer Sets bit 5 of the LCDC register to 1.\item\end{CompactList}

\item 
\#define {\bf HIDE\_\-WIN}
\begin{CompactList}\small\item\em Turns off the window layer.\item\end{CompactList}

\item 
\#define {\bf SHOW\_\-SPRITES}
\begin{CompactList}\small\item\em Turns on the sprites layer.\item\end{CompactList}

\item 
\#define {\bf HIDE\_\-SPRITES}
\begin{CompactList}\small\item\em Turns off the sprites layer.\item\end{CompactList}

\item 
\#define {\bf SPRITES\_\-8x16}
\begin{CompactList}\small\item\em Sets sprite size to 8x16 pixels, two tiles one above the other.\item\end{CompactList}

\item 
\#define {\bf SPRITES\_\-8x8}
\begin{CompactList}\small\item\em Sets sprite size to 8x8 pixels, one tile.\item\end{CompactList}

\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\label{gb.h_a100}
\index{int_handler@{int\_\-handler}!gb.h@{gb.h}}\index{gb.h@{gb.h}!int_handler@{int\_\-handler}}
typedef void ($\ast$ {\bf int\_\-handler} )(void) NONBANKED
\begin{CompactList}\small\item\em Interrupt handlers.\item\end{CompactList}

\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf remove\_\-VBL} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em The remove functions will remove any interrupt handler.\item\end{CompactList}

\item 
\label{gb.h_a54}
\index{remove_LCD@{remove\_\-LCD}!gb.h@{gb.h}}\index{gb.h@{gb.h}!remove_LCD@{remove\_\-LCD}}
void {\bf remove\_\-LCD} ({\bf int\_\-handler} h) NONBANKED
\item 
\label{gb.h_a55}
\index{remove_TIM@{remove\_\-TIM}!gb.h@{gb.h}}\index{gb.h@{gb.h}!remove_TIM@{remove\_\-TIM}}
void {\bf remove\_\-TIM} ({\bf int\_\-handler} h) NONBANKED
\item 
\label{gb.h_a56}
\index{remove_SIO@{remove\_\-SIO}!gb.h@{gb.h}}\index{gb.h@{gb.h}!remove_SIO@{remove\_\-SIO}}
void {\bf remove\_\-SIO} ({\bf int\_\-handler} h) NONBANKED
\item 
\label{gb.h_a57}
\index{remove_JOY@{remove\_\-JOY}!gb.h@{gb.h}}\index{gb.h@{gb.h}!remove_JOY@{remove\_\-JOY}}
void {\bf remove\_\-JOY} ({\bf int\_\-handler} h) NONBANKED
\item 
void {\bf add\_\-VBL} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em Adds a V-blank interrupt handler.\item\end{CompactList}

\item 
void {\bf add\_\-LCD} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em Adds a LCD interrupt handler.\item\end{CompactList}

\item 
void {\bf add\_\-TIM} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em Adds a timer interrupt handler.\item\end{CompactList}

\item 
void {\bf add\_\-SIO} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em Adds a serial transmit complete interrupt handler.\item\end{CompactList}

\item 
void {\bf add\_\-JOY} ({\bf int\_\-handler} h) NONBANKED
\begin{CompactList}\small\item\em Adds a pad tranisition interrupt handler.\item\end{CompactList}

\item 
\label{gb.h_a63}
\index{mode@{mode}!gb.h@{gb.h}}\index{gb.h@{gb.h}!mode@{mode}}
void {\bf mode} ({\bf UINT8} m) NONBANKED
\begin{CompactList}\small\item\em Set the current mode - one of M\_\-$\ast$ defined above.\item\end{CompactList}

\item 
\label{gb.h_a64}
\index{get_mode@{get\_\-mode}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_mode@{get\_\-mode}}
{\bf UINT8} {\bf get\_\-mode} (void) NONBANKED
\begin{CompactList}\small\item\em Returns the current mode.\item\end{CompactList}

\item 
\label{gb.h_a65}
\index{send_byte@{send\_\-byte}!gb.h@{gb.h}}\index{gb.h@{gb.h}!send_byte@{send\_\-byte}}
void {\bf send\_\-byte} (void)
\begin{CompactList}\small\item\em Send byte in \_\-io\_\-out to the serial port.\item\end{CompactList}

\item 
\label{gb.h_a66}
\index{receive_byte@{receive\_\-byte}!gb.h@{gb.h}}\index{gb.h@{gb.h}!receive_byte@{receive\_\-byte}}
void {\bf receive\_\-byte} (void)
\begin{CompactList}\small\item\em Receive byte from the serial port in \_\-io\_\-in.\item\end{CompactList}

\item 
void {\bf delay} ({\bf UINT16} d) NONBANKED
\begin{CompactList}\small\item\em Delays the given number of milliseconds.\item\end{CompactList}

\item 
{\bf UINT8} {\bf joypad} (void) NONBANKED
\begin{CompactList}\small\item\em Reads and returns the current state of the joypad.\item\end{CompactList}

\item 
{\bf UINT8} {\bf waitpad} ({\bf UINT8} mask) NONBANKED
\begin{CompactList}\small\item\em Waits until all the keys given in mask are pressed.\item\end{CompactList}

\item 
\label{gb.h_a70}
\index{waitpadup@{waitpadup}!gb.h@{gb.h}}\index{gb.h@{gb.h}!waitpadup@{waitpadup}}
void {\bf waitpadup} (void) NONBANKED
\begin{CompactList}\small\item\em Waits for the pad and all buttons to be released.\item\end{CompactList}

\item 
void {\bf enable\_\-interrupts} (void) NONBANKED
\begin{CompactList}\small\item\em Enables unmasked interrupts.\item\end{CompactList}

\item 
void {\bf disable\_\-interrupts} (void) NONBANKED
\begin{CompactList}\small\item\em Disables interrupts.\item\end{CompactList}

\item 
void {\bf set\_\-interrupts} ({\bf UINT8} flags) NONBANKED
\begin{CompactList}\small\item\em Clears any pending interrupts and sets the interrupt mask register IO to flags.\item\end{CompactList}

\item 
\label{gb.h_a74}
\index{reset@{reset}!gb.h@{gb.h}}\index{gb.h@{gb.h}!reset@{reset}}
void {\bf reset} (void) NONBANKED
\begin{CompactList}\small\item\em Performs a warm reset by reloading the CPU value then jumping to the start of crt0 (0x0150).\item\end{CompactList}

\item 
void {\bf wait\_\-vbl\_\-done} (void) NONBANKED
\begin{CompactList}\small\item\em Waits for the vertical blank interrupt (VBL) to finish.\item\end{CompactList}

\item 
void {\bf display\_\-off} (void) NONBANKED
\begin{CompactList}\small\item\em Turns the display off.\item\end{CompactList}

\item 
void {\bf hiramcpy} ({\bf UINT8} dst, const void $\ast$src, {\bf UINT8} n) NONBANKED
\begin{CompactList}\small\item\em Copies data from somewhere in the lower address space to part of hi-ram.\item\end{CompactList}

\item 
void {\bf set\_\-bkg\_\-data} ({\bf UINT8} first\_\-tile, {\bf UINT8} nb\_\-tiles, unsigned char $\ast$data) NONBANKED
\begin{CompactList}\small\item\em Sets the tile patterns in the Background Tile Pattern table.\item\end{CompactList}

\item 
void {\bf set\_\-bkg\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$tiles) NONBANKED
\begin{CompactList}\small\item\em Sets the tiles in the background tile table.\item\end{CompactList}

\item 
\label{gb.h_a80}
\index{get_bkg_tiles@{get\_\-bkg\_\-tiles}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_bkg_tiles@{get\_\-bkg\_\-tiles}}
void {\bf get\_\-bkg\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$tiles) NONBANKED
\item 
void {\bf move\_\-bkg} ({\bf UINT8} x, {\bf UINT8} y) NONBANKED
\begin{CompactList}\small\item\em Moves the background layer to the position specified in x and y in pixels.\item\end{CompactList}

\item 
void {\bf scroll\_\-bkg} ({\bf INT8} x, {\bf INT8} y) NONBANKED
\begin{CompactList}\small\item\em Moves the background relative to it's current position.\item\end{CompactList}

\item 
void {\bf set\_\-win\_\-data} ({\bf UINT8} first\_\-tile, {\bf UINT8} nb\_\-tiles, unsigned char $\ast$data) NONBANKED
\begin{CompactList}\small\item\em Sets the window tile data.\item\end{CompactList}

\item 
void {\bf set\_\-win\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$tiles) NONBANKED
\begin{CompactList}\small\item\em Sets the tiles in the win tile table.\item\end{CompactList}

\item 
\label{gb.h_a85}
\index{get_win_tiles@{get\_\-win\_\-tiles}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_win_tiles@{get\_\-win\_\-tiles}}
void {\bf get\_\-win\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$tiles) NONBANKED
\item 
void {\bf move\_\-win} ({\bf UINT8} x, {\bf UINT8} y) NONBANKED
\begin{CompactList}\small\item\em Moves the window layer to the position specified in x and y in pixels.\item\end{CompactList}

\item 
void {\bf scroll\_\-win} ({\bf INT8} x, {\bf INT8} y) NONBANKED
\begin{CompactList}\small\item\em Move the window relative to its current position.\item\end{CompactList}

\item 
void {\bf set\_\-sprite\_\-data} ({\bf UINT8} first\_\-tile, {\bf UINT8} nb\_\-tiles, unsigned char $\ast$data) NONBANKED
\begin{CompactList}\small\item\em Sets the tile patterns in the Sprite Tile Pattern table.\item\end{CompactList}

\item 
\label{gb.h_a89}
\index{get_sprite_data@{get\_\-sprite\_\-data}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_sprite_data@{get\_\-sprite\_\-data}}
void {\bf get\_\-sprite\_\-data} ({\bf UINT8} first\_\-tile, {\bf UINT8} nb\_\-tiles, unsigned char $\ast$data) NONBANKED
\item 
void {\bf set\_\-sprite\_\-tile} ({\bf UINT8} nb, {\bf UINT8} tile) NONBANKED
\begin{CompactList}\small\item\em Sets sprite n to display tile number t, from the sprite tile data.\item\end{CompactList}

\item 
\label{gb.h_a91}
\index{get_sprite_tile@{get\_\-sprite\_\-tile}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_sprite_tile@{get\_\-sprite\_\-tile}}
{\bf UINT8} {\bf get\_\-sprite\_\-tile} ({\bf UINT8} nb) NONBANKED
\item 
void {\bf set\_\-sprite\_\-prop} ({\bf UINT8} nb, {\bf UINT8} prop) NONBANKED
\begin{CompactList}\small\item\em Sets the property of sprite n to those defined in p.\item\end{CompactList}

\item 
\label{gb.h_a93}
\index{get_sprite_prop@{get\_\-sprite\_\-prop}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_sprite_prop@{get\_\-sprite\_\-prop}}
{\bf UINT8} {\bf get\_\-sprite\_\-prop} ({\bf UINT8} nb) NONBANKED
\item 
void {\bf move\_\-sprite} ({\bf UINT8} nb, {\bf UINT8} x, {\bf UINT8} y) NONBANKED
\begin{CompactList}\small\item\em Moves the given sprite to the given position on the screen.\item\end{CompactList}

\item 
\label{gb.h_a95}
\index{scroll_sprite@{scroll\_\-sprite}!gb.h@{gb.h}}\index{gb.h@{gb.h}!scroll_sprite@{scroll\_\-sprite}}
void {\bf scroll\_\-sprite} ({\bf INT8} nb, {\bf INT8} x, {\bf INT8} y) NONBANKED
\begin{CompactList}\small\item\em Moves the given sprite relative to its current position.\item\end{CompactList}

\item 
\label{gb.h_a96}
\index{set_data@{set\_\-data}!gb.h@{gb.h}}\index{gb.h@{gb.h}!set_data@{set\_\-data}}
void {\bf set\_\-data} (unsigned char $\ast$vram\_\-addr, unsigned char $\ast$data, {\bf UINT16} len) NONBANKED
\item 
\label{gb.h_a97}
\index{get_data@{get\_\-data}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_data@{get\_\-data}}
void {\bf get\_\-data} (unsigned char $\ast$data, unsigned char $\ast$vram\_\-addr, {\bf UINT16} len) NONBANKED
\item 
\label{gb.h_a98}
\index{set_tiles@{set\_\-tiles}!gb.h@{gb.h}}\index{gb.h@{gb.h}!set_tiles@{set\_\-tiles}}
void {\bf set\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$vram\_\-addr, unsigned char $\ast$tiles) NONBANKED
\item 
\label{gb.h_a99}
\index{get_tiles@{get\_\-tiles}!gb.h@{gb.h}}\index{gb.h@{gb.h}!get_tiles@{get\_\-tiles}}
void {\bf get\_\-tiles} ({\bf UINT8} x, {\bf UINT8} y, {\bf UINT8} w, {\bf UINT8} h, unsigned char $\ast$tiles, unsigned char $\ast$vram\_\-addr) NONBANKED
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
\label{gb.h_a101}
\index{_cpu@{\_\-cpu}!gb.h@{gb.h}}\index{gb.h@{gb.h}!_cpu@{\_\-cpu}}
{\bf UINT8} {\bf \_\-cpu}
\begin{CompactList}\small\item\em GB type (GB, PGB, CGB).\item\end{CompactList}

\item 
\label{gb.h_a102}
\index{sys_time@{sys\_\-time}!gb.h@{gb.h}}\index{gb.h@{gb.h}!sys_time@{sys\_\-time}}
{\bf UINT16} {\bf sys\_\-time}
\begin{CompactList}\small\item\em Time in VBL periods (60Hz).\item\end{CompactList}

\item 
\label{gb.h_a103}
\index{_io_status@{\_\-io\_\-status}!gb.h@{gb.h}}\index{gb.h@{gb.h}!_io_status@{\_\-io\_\-status}}
{\bf UINT8} {\bf \_\-io\_\-status}
\begin{CompactList}\small\item\em An OR of IO\_\-$\ast$.\item\end{CompactList}

\item 
\label{gb.h_a104}
\index{_io_in@{\_\-io\_\-in}!gb.h@{gb.h}}\index{gb.h@{gb.h}!_io_in@{\_\-io\_\-in}}
{\bf UINT8} {\bf \_\-io\_\-in}
\begin{CompactList}\small\item\em Byte just read.\item\end{CompactList}

\item 
{\bf UINT8} {\bf \_\-io\_\-out}
\begin{CompactList}\small\item\em Write the byte to send here before calling {\bf send\_\-byte}() {\rm (p.~\pageref{gb.h_a65})}.\item\end{CompactList}

\end{CompactItemize}
\vspace{0.4cm}\hrule\vspace{0.2cm}
\subsection*{Detailed Description}
Gameboy specific functions.\vspace{0.4cm}\hrule\vspace{0.2cm}
\subsection*{Define Documentation}
\label{gb.h_a0}
\index{gb.h@{gb.h}!J_START@{J\_\-START}}
\index{J_START@{J\_\-START}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define J\_\-START ()}

Joypad bits.

A logical OR of these is used in the wait\_\-pad and joypad functions. For example, to see if the B button is pressed try

UINT8 keys; keys = {\bf joypad}() {\rm (p.~\pageref{gb.h_a68})}; if (keys \& J\_\-B) \{ ... \}

\begin{Desc}
\item[{\bf See also: }]\par
{\bf joypad}() {\rm (p.~\pageref{gb.h_a68})} \end{Desc}
\label{gb.h_a8}
\index{gb.h@{gb.h}!M_DRAWING@{M\_\-DRAWING}}
\index{M_DRAWING@{M\_\-DRAWING}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define M\_\-DRAWING ()}

Screen modes.

Normally used by internal functions only. \label{gb.h_a13}
\index{gb.h@{gb.h}!S_PALETTE@{S\_\-PALETTE}}
\index{S_PALETTE@{S\_\-PALETTE}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define S\_\-PALETTE ()}

If this is set, sprite colours come from OBJ1PAL.

Else they come from OBJ0PAL. \label{gb.h_a17}
\index{gb.h@{gb.h}!VBL_IFLAG@{VBL\_\-IFLAG}}
\index{VBL_IFLAG@{VBL\_\-IFLAG}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define VBL\_\-IFLAG ()}

Vertical blank interrupt.

Occurs at the start of the vertical blank. During this period the video ram may be freely accessed. \label{gb.h_a18}
\index{gb.h@{gb.h}!LCD_IFLAG@{LCD\_\-IFLAG}}
\index{LCD_IFLAG@{LCD\_\-IFLAG}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define LCD\_\-IFLAG ()}

Interrupt when triggered by the STAT register.

See the Pan doc. \label{gb.h_a35}
\index{gb.h@{gb.h}!SWITCH_ROM_MBC1@{SWITCH\_\-ROM\_\-MBC1}}
\index{SWITCH_ROM_MBC1@{SWITCH\_\-ROM\_\-MBC1}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define SWITCH\_\-ROM\_\-MBC1 (b)}

Switches the upper 16k bank of the 32k rom to bank rombank using the MBC1 controller.

By default the upper 16k bank is 1. Make sure the rom you compile has more than just bank 0 and bank 1, a 32k rom. This is done by feeding lcc.exe the following switches:

-Wl-yt\# where \# is the type of cartridge. 1 for ROM+MBC1.

-Wl-yo\# where \# is the number of rom banks. 2,4,8,16,32. \label{gb.h_a43}
\index{gb.h@{gb.h}!DISPLAY_ON@{DISPLAY\_\-ON}}
\index{DISPLAY_ON@{DISPLAY\_\-ON}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define DISPLAY\_\-ON ()}

Turns the display back on.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf display\_\-off}() {\rm (p.~\pageref{gb.h_a76})}, {\bf DISPLAY\_\-OFF}() {\rm (p.~\pageref{gb.h_a44})} \end{Desc}
\label{gb.h_a44}
\index{gb.h@{gb.h}!DISPLAY_OFF@{DISPLAY\_\-OFF}}
\index{DISPLAY_OFF@{DISPLAY\_\-OFF}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define DISPLAY\_\-OFF ()}

Turns the display off immediatly.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf display\_\-off}() {\rm (p.~\pageref{gb.h_a76})}, {\bf DISPLAY\_\-ON}() {\rm (p.~\pageref{gb.h_a43})} \end{Desc}
\label{gb.h_a45}
\index{gb.h@{gb.h}!SHOW_BKG@{SHOW\_\-BKG}}
\index{SHOW_BKG@{SHOW\_\-BKG}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define SHOW\_\-BKG ()}

Turns on the background layer.

Sets bit 0 of the LCDC register to 1. \label{gb.h_a46}
\index{gb.h@{gb.h}!HIDE_BKG@{HIDE\_\-BKG}}
\index{HIDE_BKG@{HIDE\_\-BKG}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define HIDE\_\-BKG ()}

Turns off the background layer.

Sets bit 0 of the LCDC register to 0. \label{gb.h_a48}
\index{gb.h@{gb.h}!HIDE_WIN@{HIDE\_\-WIN}}
\index{HIDE_WIN@{HIDE\_\-WIN}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define HIDE\_\-WIN ()}

Turns off the window layer.

Clears bit 5 of the LCDC register to 0. \label{gb.h_a49}
\index{gb.h@{gb.h}!SHOW_SPRITES@{SHOW\_\-SPRITES}}
\index{SHOW_SPRITES@{SHOW\_\-SPRITES}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define SHOW\_\-SPRITES ()}

Turns on the sprites layer.

Sets bit 1 of the LCDC register to 1. \label{gb.h_a50}
\index{gb.h@{gb.h}!HIDE_SPRITES@{HIDE\_\-SPRITES}}
\index{HIDE_SPRITES@{HIDE\_\-SPRITES}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define HIDE\_\-SPRITES ()}

Turns off the sprites layer.

Clears bit 1 of the LCDC register to 0. \label{gb.h_a51}
\index{gb.h@{gb.h}!SPRITES_8x16@{SPRITES\_\-8x16}}
\index{SPRITES_8x16@{SPRITES\_\-8x16}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define SPRITES\_\-8x16 ()}

Sets sprite size to 8x16 pixels, two tiles one above the other.

Sets bit 2 of the LCDC register to 1. \label{gb.h_a52}
\index{gb.h@{gb.h}!SPRITES_8x8@{SPRITES\_\-8x8}}
\index{SPRITES_8x8@{SPRITES\_\-8x8}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}\#define SPRITES\_\-8x8 ()}

Sets sprite size to 8x8 pixels, one tile.

Clears bit 2 of the LCDC register to 0. \vspace{0.4cm}\hrule\vspace{0.2cm}
\subsection*{Function Documentation}
\label{gb.h_a53}
\index{gb.h@{gb.h}!remove_VBL@{remove\_\-VBL}}
\index{remove_VBL@{remove\_\-VBL}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void remove\_\-VBL ({\bf int\_\-handler} {\em h})}

The remove functions will remove any interrupt handler.

A handler of NULL will cause bad things to happen. \label{gb.h_a58}
\index{gb.h@{gb.h}!add_VBL@{add\_\-VBL}}
\index{add_VBL@{add\_\-VBL}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void add\_\-VBL ({\bf int\_\-handler} {\em h})}

Adds a V-blank interrupt handler.

The handler 'h' will be called whenever a V-blank interrupt occurs. Up to 4 handlers may be added, with the last added being called last. If the remove\_\-VBL function is to be called, only three may be added. \begin{Desc}
\item[{\bf See also: }]\par
{\bf remove\_\-VBL}() {\rm (p.~\pageref{gb.h_a53})} \end{Desc}
\label{gb.h_a59}
\index{gb.h@{gb.h}!add_LCD@{add\_\-LCD}}
\index{add_LCD@{add\_\-LCD}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void add\_\-LCD ({\bf int\_\-handler} {\em h})}

Adds a LCD interrupt handler.

Called when the LCD interrupt occurs, which is normally when LY\_\-REG == LYC\_\-REG.

From pan/k0Pa: There are various reasons for this interrupt to occur as described by the STAT register (\$FF40). One very popular reason is to indicate to the user when the video hardware is about to redraw a given LCD line. This can be useful for dynamically controlling the SCX/ SCY registers (\$FF43/\$FF42) to perform special video effects.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf add\_\-VBL}() {\rm (p.~\pageref{gb.h_a58})} \end{Desc}
\label{gb.h_a60}
\index{gb.h@{gb.h}!add_TIM@{add\_\-TIM}}
\index{add_TIM@{add\_\-TIM}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void add\_\-TIM ({\bf int\_\-handler} {\em h})}

Adds a timer interrupt handler.

From pan/k0Pa: This interrupt occurs when the TIMA register (\$FF05) changes from \$FF to \$00.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf add\_\-VBL}() {\rm (p.~\pageref{gb.h_a58})} \end{Desc}
\label{gb.h_a61}
\index{gb.h@{gb.h}!add_SIO@{add\_\-SIO}}
\index{add_SIO@{add\_\-SIO}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void add\_\-SIO ({\bf int\_\-handler} {\em h})}

Adds a serial transmit complete interrupt handler.

From pan/k0Pa: This interrupt occurs when a serial transfer has completed on the game link port.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf send\_\-byte}() {\rm (p.~\pageref{gb.h_a65})}, {\bf receive\_\-byte}() {\rm (p.~\pageref{gb.h_a66})}, {\bf add\_\-VBL}() {\rm (p.~\pageref{gb.h_a58})} \end{Desc}
\label{gb.h_a62}
\index{gb.h@{gb.h}!add_JOY@{add\_\-JOY}}
\index{add_JOY@{add\_\-JOY}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void add\_\-JOY ({\bf int\_\-handler} {\em h})}

Adds a pad tranisition interrupt handler.

From pan/k0Pa: This interrupt occurs on a transition of any of the keypad input lines from high to low. Due to the fact that keypad "bounce" is virtually always present, software should expect this interrupt to occur one or more times for every button press and one or more times for every button release.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf joypad}() {\rm (p.~\pageref{gb.h_a68})} \end{Desc}
\label{gb.h_a67}
\index{gb.h@{gb.h}!delay@{delay}}
\index{delay@{delay}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void delay ({\bf UINT16} {\em d})}

Delays the given number of milliseconds.

Uses no timers or interrupts, and can be called with interrupts disabled (why nobody knows :) \label{gb.h_a68}
\index{gb.h@{gb.h}!joypad@{joypad}}
\index{joypad@{joypad}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}{\bf UINT8} joypad (void)}

Reads and returns the current state of the joypad.

Follows Nintendo's guidelines for reading the pad. Return value is an OR of J\_\-$\ast$ \begin{Desc}
\item[{\bf See also: }]\par
{\bf J\_\-START}() {\rm (p.~\pageref{gb.h_a0})} \end{Desc}
\label{gb.h_a69}
\index{gb.h@{gb.h}!waitpad@{waitpad}}
\index{waitpad@{waitpad}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}{\bf UINT8} waitpad ({\bf UINT8} {\em mask})}

Waits until all the keys given in mask are pressed.

Normally only used for checking one key, but it will support many, even J\_\-LEFT at the same time as J\_\-RIGHT :) \begin{Desc}
\item[{\bf See also: }]\par
{\bf joypad}() {\rm (p.~\pageref{gb.h_a68})}, {\bf J\_\-START}() {\rm (p.~\pageref{gb.h_a0})} \end{Desc}
\label{gb.h_a71}
\index{gb.h@{gb.h}!enable_interrupts@{enable\_\-interrupts}}
\index{enable_interrupts@{enable\_\-interrupts}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void enable\_\-interrupts (void)}

Enables unmasked interrupts.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf disable\_\-interrupts}() {\rm (p.~\pageref{gb.h_a72})} \end{Desc}
\label{gb.h_a72}
\index{gb.h@{gb.h}!disable_interrupts@{disable\_\-interrupts}}
\index{disable_interrupts@{disable\_\-interrupts}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void disable\_\-interrupts (void)}

Disables interrupts.

This function may be called as many times as you like; however the first call to enable\_\-interrupts will re-enable them. \begin{Desc}
\item[{\bf See also: }]\par
{\bf enable\_\-interrupts}() {\rm (p.~\pageref{gb.h_a71})} \end{Desc}
\label{gb.h_a73}
\index{gb.h@{gb.h}!set_interrupts@{set\_\-interrupts}}
\index{set_interrupts@{set\_\-interrupts}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-interrupts ({\bf UINT8} {\em flags})}

Clears any pending interrupts and sets the interrupt mask register IO to flags.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf VBL\_\-IFLAG}() {\rm (p.~\pageref{gb.h_a17})} \end{Desc}
\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em flags}] A logical OR of $\ast$\_\-IFLAGS \end{description}
\end{Desc}
\label{gb.h_a75}
\index{gb.h@{gb.h}!wait_vbl_done@{wait\_\-vbl\_\-done}}
\index{wait_vbl_done@{wait\_\-vbl\_\-done}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void wait\_\-vbl\_\-done (void)}

Waits for the vertical blank interrupt (VBL) to finish.

This can be used to sync animation with the screen re-draw. If VBL interrupt is disabled, this function will never return. If the screen is off this function returns immediatly. \label{gb.h_a76}
\index{gb.h@{gb.h}!display_off@{display\_\-off}}
\index{display_off@{display\_\-off}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void display\_\-off (void)}

Turns the display off.

Waits until the VBL interrupt before turning the display off. \begin{Desc}
\item[{\bf See also: }]\par
{\bf DISPLAY\_\-ON}() {\rm (p.~\pageref{gb.h_a43})} \end{Desc}
\label{gb.h_a77}
\index{gb.h@{gb.h}!hiramcpy@{hiramcpy}}
\index{hiramcpy@{hiramcpy}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void hiramcpy ({\bf UINT8} {\em dst}, const void $\ast$ {\em src}, {\bf UINT8} {\em n})}

Copies data from somewhere in the lower address space to part of hi-ram.

\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em dst}] Offset in high ram (0x\-FF00 and above) to copy to. \item[
{\em src}] Area to copy from \item[
{\em n}] Number of bytes to copy. \end{description}
\end{Desc}
\label{gb.h_a78}
\index{gb.h@{gb.h}!set_bkg_data@{set\_\-bkg\_\-data}}
\index{set_bkg_data@{set\_\-bkg\_\-data}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-bkg\_\-data ({\bf UINT8} {\em first\_\-tile}, {\bf UINT8} {\em nb\_\-tiles}, unsigned char $\ast$ {\em data})}

Sets the tile patterns in the Background Tile Pattern table.

Starting with the tile pattern x and carrying on for n number of tile patterns.Taking the values starting from the pointer data. Note that patterns 128-255 overlap with patterns 128-255 of the sprite Tile Pattern table.

GBC: Depending on the VBK\_\-REG this determines which bank of Background tile patterns are written to. VBK\_\-REG=0 indicates the first bank, and VBK\_\-REG=1 indicates the second.

\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em first\_\-tile}] Range 0 - 255 \item[
{\em nb\_\-tiles}] Range 0 - 255 \end{description}
\end{Desc}
\label{gb.h_a79}
\index{gb.h@{gb.h}!set_bkg_tiles@{set\_\-bkg\_\-tiles}}
\index{set_bkg_tiles@{set\_\-bkg\_\-tiles}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-bkg\_\-tiles ({\bf UINT8} {\em x}, {\bf UINT8} {\em y}, {\bf UINT8} {\em w}, {\bf UINT8} {\em h}, unsigned char $\ast$ {\em tiles})}

Sets the tiles in the background tile table.

Starting at position x,y in tiles and writing across for w tiles and down for h tiles. Taking the values starting from the pointer data.

For the GBC, also see the pan/k00Pa section on VBK\_\-REG.

\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em x}] Range 0 - 31 \item[
{\em y}] Range 0 - 31 \item[
{\em w}] Range 0 - 31 \item[
{\em h}] Range 0 - 31 \item[
{\em data}] Pointer to an unsigned char. Usually the first element in an array. \end{description}
\end{Desc}
\label{gb.h_a81}
\index{gb.h@{gb.h}!move_bkg@{move\_\-bkg}}
\index{move_bkg@{move\_\-bkg}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void move\_\-bkg ({\bf UINT8} {\em x}, {\bf UINT8} {\em y})}

Moves the background layer to the position specified in x and y in pixels.

Where 0,0 is the top left corner of the GB screen. You'll notice the screen wraps around in all 4 directions, and is always under the window layer. \label{gb.h_a82}
\index{gb.h@{gb.h}!scroll_bkg@{scroll\_\-bkg}}
\index{scroll_bkg@{scroll\_\-bkg}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void scroll\_\-bkg ({\bf INT8} {\em x}, {\bf INT8} {\em y})}

Moves the background relative to it's current position.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf move\_\-bkg}() {\rm (p.~\pageref{gb.h_a81})} \end{Desc}
\label{gb.h_a83}
\index{gb.h@{gb.h}!set_win_data@{set\_\-win\_\-data}}
\index{set_win_data@{set\_\-win\_\-data}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-win\_\-data ({\bf UINT8} {\em first\_\-tile}, {\bf UINT8} {\em nb\_\-tiles}, unsigned char $\ast$ {\em data})}

Sets the window tile data.

This is the same as set\_\-bkg\_\-data, as both the window layer and background layer share the same Tile Patterns. \begin{Desc}
\item[{\bf See also: }]\par
{\bf set\_\-bkg\_\-data}() {\rm (p.~\pageref{gb.h_a78})} \end{Desc}
\label{gb.h_a84}
\index{gb.h@{gb.h}!set_win_tiles@{set\_\-win\_\-tiles}}
\index{set_win_tiles@{set\_\-win\_\-tiles}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-win\_\-tiles ({\bf UINT8} {\em x}, {\bf UINT8} {\em y}, {\bf UINT8} {\em w}, {\bf UINT8} {\em h}, unsigned char $\ast$ {\em tiles})}

Sets the tiles in the win tile table.

Starting at position x,y in tiles and writing across for w tiles and down for h tiles. Taking the values starting from the pointer data. Note that patterns 128-255 overlap with patterns 128-255 of the sprite Tile Pattern table.

GBC only. Depending on the VBK\_\-REG this determines if you're setting the tile numbers VBK\_\-REG=0; or the attributes for those tiles VBK\_\-REG=1;. The bits in the attributes are defined as: Bit 7 - Priority flag. When this is set, it puts the tile above the sprites with colour 0 being transparent. 0: below sprites, 1: above sprites Note SHOW\_\-BKG needs to be set for these priorities to take place. Bit 6 - Vertical flip. Dictates which way up the tile is drawn vertically. 0: normal, 1: upside down. Bit 5 - Horizontal flip. Dictates which way up the tile is drawn horizontally. 0: normal, 1:back to front. Bit 4 - Not used. Bit 3 - Character Bank specification. Dictates from which bank of Background Tile Patterns the tile is taken. 0: Bank 0, 1: Bank 1 Bit 2 - See bit 0. Bit 1 - See bit 0. Bit 0 - Bits 0-2 indicate which of the 7 BKG colour palettes the tile is assigned.

\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em x}] Range 0 - 31 \item[
{\em y}] Range 0 - 31 \item[
{\em w}] Range 0 - 31 \item[
{\em h}] Range 0 - 31 \end{description}
\end{Desc}
\label{gb.h_a86}
\index{gb.h@{gb.h}!move_win@{move\_\-win}}
\index{move_win@{move\_\-win}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void move\_\-win ({\bf UINT8} {\em x}, {\bf UINT8} {\em y})}

Moves the window layer to the position specified in x and y in pixels.

Where 7,0 is the top left corner of the GB screen. The window is locked to the bottom right corner, and is always over the background layer. \begin{Desc}
\item[{\bf See also: }]\par
{\bf SHOW\_\-WIN}() {\rm (p.~\pageref{gb.h_a47})}, {\bf HIDE\_\-WIN}() {\rm (p.~\pageref{gb.h_a48})} \end{Desc}
\label{gb.h_a87}
\index{gb.h@{gb.h}!scroll_win@{scroll\_\-win}}
\index{scroll_win@{scroll\_\-win}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void scroll\_\-win ({\bf INT8} {\em x}, {\bf INT8} {\em y})}

Move the window relative to its current position.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf move\_\-win}() {\rm (p.~\pageref{gb.h_a86})} \end{Desc}
\label{gb.h_a88}
\index{gb.h@{gb.h}!set_sprite_data@{set\_\-sprite\_\-data}}
\index{set_sprite_data@{set\_\-sprite\_\-data}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-sprite\_\-data ({\bf UINT8} {\em first\_\-tile}, {\bf UINT8} {\em nb\_\-tiles}, unsigned char $\ast$ {\em data})}

Sets the tile patterns in the Sprite Tile Pattern table.

Starting with the tile pattern x and carrying on for n number of tile patterns.Taking the values starting from the pointer data. Note that patterns 128-255 overlap with patterns 128-255 of the Background Tile Pattern table.

GBC only. Depending on the VBK\_\-REG this determines which bank of Background tile patterns are written to. VBK\_\-REG=0 indicates the first bank, and VBK\_\-REG=1 indicates the second. \label{gb.h_a90}
\index{gb.h@{gb.h}!set_sprite_tile@{set\_\-sprite\_\-tile}}
\index{set_sprite_tile@{set\_\-sprite\_\-tile}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-sprite\_\-tile ({\bf UINT8} {\em nb}, {\bf UINT8} {\em tile})}

Sets sprite n to display tile number t, from the sprite tile data.

If the GB is in 8x16 sprite mode then it will display the next tile, t+1, below the first tile. \begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em nb}] Sprite number, range 0 - 39 \end{description}
\end{Desc}
\label{gb.h_a92}
\index{gb.h@{gb.h}!set_sprite_prop@{set\_\-sprite\_\-prop}}
\index{set_sprite_prop@{set\_\-sprite\_\-prop}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void set\_\-sprite\_\-prop ({\bf UINT8} {\em nb}, {\bf UINT8} {\em prop})}

Sets the property of sprite n to those defined in p.

Where the bits in p represent: Bit 7 - Priority flag. When this is set the sprites appear behind the background and window layer. 0: infront, 1: behind. Bit 6 - GBC only. Vertical flip. Dictates which way up the sprite is drawn vertically. 0: normal, 1:upside down. Bit 5 - GBC only. Horizontal flip. Dictates which way up the sprite is drawn horizontally. 0: normal, 1:back to front. Bit 4 - DMG only. Assigns either one of the two b/w palettes to the sprite. 0: OBJ palette 0, 1: OBJ palette 1. Bit 3 - GBC only. Dictates from which bank of Sprite Tile Patterns the tile is taken. 0: Bank 0, 1: Bank 1 Bit 2 - See bit 0. Bit 1 - See bit 0. Bit 0 - GBC only. Bits 0-2 indicate which of the 7 OBJ colour palettes the sprite is assigned.

\begin{Desc}
\item[{\bf Parameters: }]\par
\begin{description}
\item[
{\em nb}] Sprite number, range 0 - 39 \end{description}
\end{Desc}
\label{gb.h_a94}
\index{gb.h@{gb.h}!move_sprite@{move\_\-sprite}}
\index{move_sprite@{move\_\-sprite}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}void move\_\-sprite ({\bf UINT8} {\em nb}, {\bf UINT8} {\em x}, {\bf UINT8} {\em y})}

Moves the given sprite to the given position on the screen.

Dont forget that the top left visible pixel on the screen is at (8,16). To put sprite 0 at the top left, use move\_\-sprite(0, 8, 16); \vspace{0.4cm}\hrule\vspace{0.2cm}
\subsection*{Variable Documentation}
\label{gb.h_a105}
\index{gb.h@{gb.h}!_io_out@{\_\-io\_\-out}}
\index{_io_out@{\_\-io\_\-out}!gb.h@{gb.h}}
\subsection{\setlength{\rightskip}{0pt plus 5cm}{\bf UINT8} \_\-io\_\-out}

Write the byte to send here before calling {\bf send\_\-byte}() {\rm (p.~\pageref{gb.h_a65})}.

\begin{Desc}
\item[{\bf See also: }]\par
{\bf send\_\-byte}() {\rm (p.~\pageref{gb.h_a65})} \end{Desc}
