21 2 / 2014
Code: Helpful Libraries
Last time I lied, there’s a bit more stuff before the tutorial. I thought I’d post some useful library files, because we’ll be needing them soon.
◆ Memory Routines: filling a memory area with a common value, copying data from one memory location to another
◆ Hardware Defines: useful constants and hardware registers for Game Boy, Game Boy Color, and Super Game Boy hardware.
I’ll explain these a little bit:
Memory Routines
Include this library in the code area of your ROM to get two useful memory routines: filling a memory area with a common value, copying data from one memory location to another.
In Wiz:
include 'memory.wiz'
In RGBDS:
INCLUDE "memory.z80"
Here’s the documentation for these functions:
— memset —
Fills a range in memory, starting at hl and spanning bc bytes, with a specified byte value a.
Arguments
hl = destination address
bc = byte count
a = value
— memcpy —
Copies bc bytes from the source at hl to the destination at de.
Arguments
de = destination address
hl = source address
bc = byte count
Hardware Defines
Include this library anywhere to get a bunch of useful constants and hardware registers for the Game Boy, Game Boy Color, and Super Game Boy.
In Wiz:
include 'gameboy.wiz'
In RGBDS:
INCLUDE "gameboy.z80"
Please open the file in a text editor to see what constants are defined exactly, but here’s a quick list of stuff it has constants for:
◆ Boot-header Constants
◆ LCD Controller - for configuring basic screen settings.
◆ LCD Status - for managing status interrupts and detecting current LCD state.
◆ LCD OAM DMA - for copying all sprites’ Object Attribute Memory to the screen.
◆ RAM areas for tile memory, bg maps, object attribute memory, and wavetable for audio.
◆ Background Scroll Registers
◆ Scanline State and Interrupt Management
◆ Window Positioning
◆ GB Monochrome Palette
◆ GBC Color Palette
◆ GBC Bank Selection (for extra Video RAM and Work RAM banks)
◆ GBC Speed Settings
◆ GBC Infrared Communication
◆ GBC DMA Transfer
◆ Super Game Boy Packets
◆ Audio Settings
◆ Tone, Tone 2, Wave, and Noise
◆ Joypad
◆ Link Cable
◆ Timer
◆ Interrupt Configuration
It’s recommended that you also read the “Pan Docs” for some relevant information: http://nocash.emubase.de/pandocs.htm – These roughly correspond to the stuff mentioned in there.
Alternatively there’s the GBDev wiki which contains a lot of similar info: http://gbdev.gg8.se/wiki/articles/Main_Page
Later!
If you want to check them out, you can download these libraries.
You can also view the source on Github.
Catch you later!
- kikiwunder liked this
- superrobotpowerhour liked this
- assemblydigest posted this