gb

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCREENWIDTH  = 0xA0
	SCREENHEIGHT = 0x90
	MINWNDPOSX   = 0x07
	MINWNDPOSY   = 0x00
	MAXWNDPOSX   = 0xA6
	MAXWNDPOSY   = 0x8F
)
View Source
const (
	VBL_IFLAG = 0x01
	LCD_IFLAG = 0x02
	TIM_IFLAG = 0x04
	SIO_IFLAG = 0x08
	JOY_IFLAG = 0x10
)
View Source
const (
	J_START  = 0x80
	J_SELECT = 0x40
	J_B      = 0x20
	J_A      = 0x10
	J_DOWN   = 0x08
	J_UP     = 0x04
	J_LEFT   = 0x02
	J_RIGHT  = 0x01
)
View Source
const (
	M_DRAWING    = 0x01
	M_TEXT_OUT   = 0x02
	M_TEXT_INOUT = 0x03
	M_NO_SCROLL  = 0x04
	M_NO_INTERP  = 0x08
	S_PALETTE    = 0x10
	S_FLIPX      = 0x20
	S_FLIPY      = 0x40
	S_PRIORITY   = 0x80
)

Variables

View Source
var (
	P1_REG    = 0xff00 /* Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
	SB_REG    = 0xff01 /* Serial IO data buffer */
	SC_REG    = 0xff02 /* Serial IO control register */
	DIV_REG   = 0xff04 /* Divider register */
	TIMA_REG  = 0xff05 /* Timer counter */
	TMA_REG   = 0xff06 /* Timer modulo */
	TAC_REG   = 0xff07 /* Timer control */
	IF_REG    = 0xff0f /* Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL */
	NR10_REG  = 0xff10 /* Sound register */
	NR11_REG  = 0xff11 /* Sound register */
	NR12_REG  = 0xff12 /* Sound register */
	NR13_REG  = 0xff13 /* Sound register */
	NR14_REG  = 0xff14 /* Sound register */
	NR21_REG  = 0xff16 /* Sound register */
	NR22_REG  = 0xff17 /* Sound register */
	NR23_REG  = 0xff18 /* Sound register */
	NR24_REG  = 0xff19 /* Sound register */
	NR30_REG  = 0xff1a /* Sound register */
	NR31_REG  = 0xff1b /* Sound register */
	NR32_REG  = 0xff1c /* Sound register */
	NR33_REG  = 0xff1d /* Sound register */
	NR34_REG  = 0xff1e /* Sound register */
	NR41_REG  = 0xff20 /* Sound register */
	NR42_REG  = 0xff21 /* Sound register */
	NR43_REG  = 0xff22 /* Sound register */
	NR44_REG  = 0xff23 /* Sound register */
	NR50_REG  = 0xff24 /* Sound register */
	NR51_REG  = 0xff25 /* Sound register */
	NR52_REG  = 0xff26 /* Sound register */
	LCDC_REG  = 0xff40 /* LCD control */
	STAT_REG  = 0xff41 /* LCD status */
	SCY_REG   = 0xff42 /* Scroll Y */
	SCX_REG   = 0xff43 /* Scroll X */
	LY_REG    = 0xff44 /* LCDC Y-coordinate */
	LYC_REG   = 0xff45 /* LY compare */
	DMA_REG   = 0xff46 /* DMA transfer */
	BGP_REG   = 0xff47 /* BG palette data */
	OBP0_REG  = 0xff48 /* OBJ palette 0 data */
	OBP1_REG  = 0xff49 /* OBJ palette 1 data */
	WY_REG    = 0xff4a /* Window Y coordinate */
	WX_REG    = 0xff4b /* Window X coordinate */
	KEY1_REG  = 0xff4d /* CPU speed */
	VBK_REG   = 0xff4f /* VRAM bank */
	HDMA1_REG = 0xff51 /* DMA control 1 */
	HDMA2_REG = 0xff52 /* DMA control 2 */
	HDMA3_REG = 0xff53 /* DMA control 3 */
	HDMA4_REG = 0xff54 /* DMA control 4 */
	HDMA5_REG = 0xff55 /* DMA control 5 */
	RP_REG    = 0xff56 /* IR port */
	BCPS_REG  = 0xff68 /* BG color palette specification */
	BCPD_REG  = 0xff69 /* BG color palette data */
	OCPS_REG  = 0xff6a /* OBJ color palette specification */
	OCPD_REG  = 0xff6b /* OBJ color palette data */
	SVBK_REG  = 0xff70 /* WRAM bank */
	IE_REG    = 0xffff /* Interrupt enable */
)

Functions

func AddJOY

func AddJOY(h IntHandler)

AddJOY NONBANKED

func AddLCD

func AddLCD(h IntHandler)

AddLCD NONBANKED

func AddSIO

func AddSIO(h IntHandler)

AddSIO NONBANKED

func AddTIM

func AddTIM(h IntHandler)

AddTIM NONBANKED

func AddVBL

func AddVBL(h IntHandler)

AddVBL NONBANKED

func CGBCompatibility

func CGBCompatibility()

CGBCompatibility Set defaults compatible with normal GameBoy.

func CPUFast

func CPUFast()

CPUFast Set CPU speed to fast operation. Make sure interrupts are disabled before call.

func CPUSlow

func CPUSlow()

CPUSlow Set CPU speed to slow operation. Make sure interrupts are disabled before call.

func DISABLE_RAM_MBC1

func DISABLE_RAM_MBC1()

func DISABLE_RAM_MBC5

func DISABLE_RAM_MBC5()

func DISPLAY_OFF

func DISPLAY_OFF()

func DISPLAY_ON

func DISPLAY_ON()

func Delay

func Delay(duration UINT16)

Delay NONBANKED

Delays the given number of milliseconds. Uses no timers or interrupts, and can be called with interrupts disabled (why nobody knows :)

func DisableInterrupts

func DisableInterrupts()

DisableInterrupts NONBANKED

This function may be called as many times as you like; however the first call to enable_interrupts will re-enable them. @see enable_interrupts

func DisplayOff

func DisplayOff()

DisplayOff NONBANKED

Turns the display off. Waits until the VBL interrupt before turning the display off.

@see DISPLAY_ON

func ENABLE_RAM_MBC1

func ENABLE_RAM_MBC1()

func ENABLE_RAM_MBC5

func ENABLE_RAM_MBC5()

func EnableInterrupts

func EnableInterrupts()

EnableInterrupts NONBANKED

Enables unmasked interrupts @see disable_interrupts

func GetBkgData

func GetBkgData(firstTile, nbTiles UINT8, data []UINT8)

func GetBkgTiles

func GetBkgTiles(x, y, w, h UINT8, tiles []UINT8)

func GetSpriteData

func GetSpriteData(firstTile, nbTiles UINT8, data []UINT8)

func GetSpriteProp

func GetSpriteProp(nb UINT8)

func GetSpriteTile

func GetSpriteTile(nb UINT8)

func GetWinData

func GetWinData(firstTile, nbTiles UINT8, data []UINT8)

func GetWinTiles

func GetWinTiles(x, y, w, h UINT8, tiles []UINT8)

func Gotoxy

func Gotoxy(x, y UINT8)

func HIDE_BKG

func HIDE_BKG()

func HIDE_SPRITES

func HIDE_SPRITES()

func HIDE_WIN

func HIDE_WIN()

func MoveBkg

func MoveBkg(x, y UINT8)

func MoveSprite

func MoveSprite(nb, x, y UINT8)

func MoveWin

func MoveWin(x, y UINT8)

func NowaitIntHandler

func NowaitIntHandler()

NowaitIntHandler NONBANKED

Interrupt handler chain terminator that don't wait for .STAT

You must add this handler the last in every interrupt handler chain if you want to change the default interrupt handler behaviour that waits for LCD controller mode to become 1 or 0 before return from the interrupt.

func RemoveJOY

func RemoveJOY(h IntHandler)

RemoveJOY NONBANKED

The remove functions will remove any interrupt handler. A handler of NULL will cause bad things to happen.

func RemoveLCD

func RemoveLCD(h IntHandler)

RemoveLCD NONBANKED

The remove functions will remove any interrupt handler. A handler of NULL will cause bad things to happen.

func RemoveSIO

func RemoveSIO(h IntHandler)

RemoveSIO NONBANKED

The remove functions will remove any interrupt handler. A handler of NULL will cause bad things to happen.

func RemoveTIM

func RemoveTIM(h IntHandler)

RemoveTIM NONBANKED

The remove functions will remove any interrupt handler. A handler of NULL will cause bad things to happen.

func RemoveVBL

func RemoveVBL(h IntHandler)

RemoveVBL NONBANKED

The remove functions will remove any interrupt handler. A handler of NULL will cause bad things to happen.

func Reset

func Reset()

Reset NONBANKED

Performs a warm reset by reloading the CPU value then jumping to the start of crt0 (0x0150)

func SHOW_BKG

func SHOW_BKG()

func SHOW_SPRITES

func SHOW_SPRITES()

func SHOW_WIN

func SHOW_WIN()

func SPRITES_8x8

func SPRITES_8x8()

func SPRITES_8x16

func SPRITES_8x16()

func SWITCH_4_32_MODE_MBC1

func SWITCH_4_32_MODE_MBC1()

func SWITCH_16_8_MODE_MBC1

func SWITCH_16_8_MODE_MBC1()

func SWITCH_RAM_MBC1

func SWITCH_RAM_MBC1(b BYTE)

func SWITCH_RAM_MBC5

func SWITCH_RAM_MBC5(b BYTE)

func SWITCH_ROM_MBC1

func SWITCH_ROM_MBC1(b BYTE)

func SWITCH_ROM_MBC5

func SWITCH_ROM_MBC5(b BYTE)

func ScrollBkg

func ScrollBkg(x, y INT8)

func ScrollSprite

func ScrollSprite(nb, x, y UINT8)

func ScrollWin

func ScrollWin(x, y INT8)

func SetBkgData

func SetBkgData(firstTile, nbTiles UINT8, data []UINT8)

func SetBkgPalette

func SetBkgPalette(firstPalette, nbPalettes UINT8, rgbData []UINT16)

SetBkgPalette Set bkg palette(s).

func SetBkgPaletteEntry

func SetBkgPaletteEntry(palette, entry UINT8, rgbData UINT16)

SetBkgPaletteEntry Set a bkg palette entry.

func SetBkgTiles

func SetBkgTiles(x, y, w, h UINT8, tiles []UINT8)

func SetInterrupts

func SetInterrupts(flags UINT8)

SetInterrupts NONBANKED

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

@see VBL_IFLAG

@param flags A logical OR of *_IFLAGS

func SetMode

func SetMode(m UINT8)

SetMode NONBANKED

gbdk: void mode(UINT8 m) NONBANKED;

Set the current mode - one of M_* defined above

func SetSpriteData

func SetSpriteData(firstTile, nbTiles UINT8, data []UINT8)

func SetSpritePalette

func SetSpritePalette(firstPalette, nbPalettes UINT8, rgbData []UINT16)

SetSpritePalette Set sprite palette(s).

func SetSpritePaletteEntry

func SetSpritePaletteEntry(palette, entry UINT8, rgbData UINT16)

SetSpritePaletteEntry Set a sprite palette entry.

func SetSpriteProp

func SetSpriteProp(nb, prop UINT8)

func SetSpriteTile

func SetSpriteTile(nb, tile UINT8)

func SetWinData

func SetWinData(firstTile, nbTiles UINT8, data []UINT8)

func SetWinTiles

func SetWinTiles(x, y, w, h UINT8, tiles []UINT8)

func Setchar

func Setchar(r rune)

func WaitIntHandler

func WaitIntHandler()

WaitIntHandler NONBANKED

Interrupt handler chain terminator that waits for .STAT and returns in the BEGINNING of mode0 or mode1 ONLY

func WaitVBLDone

func WaitVBLDone()

WaitVBLDone NONBANKED

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 immediately.

func Waitpadup

func Waitpadup()

Waitpadup Waits for the pad and all buttons to be released.

Types

type BOOLEAN

type BOOLEAN bool

type BYTE

type BYTE uint8

type DWORD

type DWORD uint32

type INT8

type INT8 int8

type IntHandler

type IntHandler func()

IntHandler NONBANKED

Interrupt handlers

type UINT8

type UINT8 uint8

func Joypad

func Joypad() UINT8

Joypad Reads and returns the current state of the joypad. Follows Nintendo's guidelines for reading the pad. Return value is an OR of J_*

@see J_START

func Mode

func Mode() UINT8

Mode NONBANKED

gbdk: UINT8 get_mode(void) NONBANKED;

Mode Returns the current mode

func Posx

func Posx() UINT8

func Posy

func Posy() UINT8

func Waitpad

func Waitpad(mask UINT8) UINT8

Waitpad 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 :)

@see joypad, J_START

type UINT16

type UINT16 uint16
const (
	RGB_RED UINT16 = iota
	RGB_DARKRED
	RGB_GREEN
	RGB_DARKGREEN
	RGB_BLUE
	RGB_DARKBLUE
	RGB_YELLOW
	RGB_DARKYELLOW
	RGB_CYAN
	RGB_AQUA
	RGB_PINK
	RGB_PURPLE
	RGB_BLACK
	RGB_DARKGRAY
	RGB_LIGHTGRAY
	RGB_WHITE
	RGB_LIGHTFLESH
	RGB_BROWN
	RGB_ORANGE
	RGB_TEAL
)

func RGB

func RGB(r, g, b UINT8) UINT16

type UINT32

type UINT32 uint32

type WORD

type WORD uint16

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL