RGBGrafx>Functions |
Waits for the beginning of vblank and turns of the screen. This functions complies with Nintendo's guidlines, and should pass lot check.
Input | |
none |
no input |
Loads tiles from memory into video RAM
Input | |
BC |
Pointer to the Source tileset |
D |
Number of tile to copy |
E |
First destination tile |
High byte of tileset to write to ($88 or $88) |
Rotates one tile to the right. Usefull creating paralax backgrounds.
Input | |
A |
Tile to rotate |
High byte of tileset that contains the tile ($88 or $88) |
Converts a color from the GBC's 15-bit standard (xbbbbbgggggrrrrr) to a 24-bit color, with one byte per component.
Input | |
D |
High byte of color |
E |
Low byte of color |
Outuut | |
H |
Blue component |
L |
Green component |
A |
Red component |
Converts a color from 24-bit color, byte per component format to the GBC's 15-bit standard (xbbbbbgggggrrrrr).
Input | |
H |
Blue component |
L |
Green component |
A |
Red component |
Output | |
D |
High byte of color |
E |
Low byte of color |
Sets all of the the Gameboy Color and Monochrome Gameboy palettes to a plain grayscale
Input | |
none |
no input |
Sets a range of colors in the GameBoy Color palettes based on colors stored in memory. Uses colors stored in 15-bit Gameboy Color format.
Input | |
A |
0 (or RGBG_BKG_PALS) for bakground palettes |
B |
First color (first palette*4 + first color in that palette) |
C |
Number of colors to set |
HL |
Pointer to source colors |
Fills all of the GameBoy Color palettes with a single color. Uses a color stored in 15-bit Gameboy Color format.
Input | |
HL |
Color to fill the paletts with |
Inverts colors stored in memory, and stores the new colors into memory. Uses a color stored in 15-bit Gameboy Color format.
Input | |
B |
Number of colors to invert |
DE |
Pointer to input colors. |
HL |
Pointer to output colors. (may be the same as DE) |
Grayscales colors stored in memory, and stores the new colors into memory. Uses a color stored in 15-bit Gameboy Color format.
Input | |
B |
Number of colors to invert |
DE |
Pointer to input colors. |
HL |
Pointer to output colors. (may be the same as DE) |
Sets an area of a tilemap in VRAM based on a map in memory.
Input | |
BC |
Pointer to source tilemap |
H |
Y-coordinate of upper left corner of the area to set in VRAM |
L |
X-coordinate of upper left corner of the area to set in VRAM |
D |
Height of area in VRAM to set |
E |
Width of area in VRAM to set |
High byte of the destination tilemap ($98 or $9C) |
|
Added to each byte of the source tilemap before it is copied to VRAM |
Fills an area of a tilemap in VRAM with a given value.
Input | |
B |
Tile to fill the area of the map with. |
H |
Y-coordinate of upper left corner of the area to set in VRAM |
L |
X-coordinate of upper left corner of the area to set in VRAM |
D |
Height of area in VRAM to set |
E |
Width of area in VRAM to set |
High byte of the destination tilemap ($98 or $9C) |
Set a single location in a tilemap in VRAM to a given value.
Input | |
A |
Value to set the location in VRAM to |
H |
Y-coordinate of the location in VRAM |
L |
X-coordinate of the location in VRAM |
High byte of the destination tilemap ($98 or $9C) |
Creates a pointer to a given location in a tilemap in VRAM.
Input | |
H |
Y-coordinate of the location in VRAM |
L |
X-coordinate of the location in VRAM |
High byte of the destination tilemap ($98 or $9C) |
|
Output | |
HL |
Points to the location in VRAM |
Sets which tile is used for a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to affect |
B |
New tile number for the sprite |
Output | |
TRUE (non-zero number) |
Set the property byte for a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to affect |
B |
New property byte for the sprite |
Output | |
TRUE (non-zero number) |
Set the postition of a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to affect |
B |
New X-coordinate for the sprite |
C |
New Y-coordinate for the sprite |
Output | |
TRUE (non-zero number) |
Returns the tile number used by a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to obtain tile number from |
Output | |
A |
Tile number used by the sprite |
Returns the property byte for a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to obtain the property byte from |
Output | |
A |
Property byte used by the sprite |
Retutrns the postition of a given sprite in RGBG's echo OAM.
Input | |
A |
Which sprite to affect |
Output | |
B |
X-coordinate of the sprite |
C |
Y-coordinate of the sprite |
Moves a sprite in RGBDS's echjo OAM based on a signed X and Y delta.
Input | |
A |
Which sprite to affect |
B |
X-Delta |
C |
Y-Delta |
Copies RGBG's sprite DMA routine into a reserved space (16 bytes) in high RAM.
Input | |
none |
no input |
Copies the data from RGBG's OAM echo into the real OAM. If this functions is called before RGBG_CopyDMARoutine, your ROM will almost certainly crash. Interupts must be disabled when you call this function. It is recomended you call this function from the vertical blank interupt
Input | |
none |
no input |
Output | |
FALSE (0) |
Example Code |
SECTION "VBL_INT", HOME[$0040] vbl_int:: push AF ;update our sprites if need be ld A,[RGBG_update_sprites] and A jp z, .bail call RGBG_DoDMA .bail pop AF reti |
Fill's RGBG's echo OAM with 0's.
Input | |
none |
no input |
Darkens (decrements) three color components (R,G,B), but does not allow any component to go below 0. Usefull for custom fade routines.
Input | |
H |
Component #1 |
L |
Component #2 |
A |
Component #3 |
Output | |
H |
Darkened component #1 |
L |
Darkened component #2 |
A |
Darkened component #3 |
Lightens (increments) three color components (R,G,B), but does not allow any component to go over 31. Usefull for custom fade routines.
Input | |
H |
Component #1 |
L |
Component #2 |
A |
Component #3 |
Output | |
H |
Lightened component #1 |
L |
Lightened component #2 |
A |
Lightened component #3 |
Fades every palette (both background and sprite) to either white or black over a period of about half of a second
Input | |
RGBG_WHITE (1) to fade to white |
Sets up a complex fade that involves a range of Background palettes. Complex fades will fade from a range of the current palettes to a range of palettes stored in memory. Complex fades can be run in the background, while you run other tasks in the foreground. The palettes are faded over 128 steps.
Input | |
HL |
Pointer to the palettes to fade to. Palettes ared stored in the Gameboy Color's 15-bit standard |
First palette to fade |
|
Number of palettes to fade |
|
Output | |
128 (it takes 128 steps to complete a complex fade) |
Example Code |
ld A,0 ;start fading from the first (0th) palette ld [RGBG_first_pal_to_fade_bkg],A ;fade 4 palettes ld A,4 ld [RGBG_pals_to_fade_bkg],A ;fade to the palettes stored at BkgFader ld HL, BkgFader ;set up the fade call RGBG_InitComplexFadeBkg .loop .waitnvbl ldh a,[$41] and 3 cp 1 jr z, .waitnvbl ;we're not it VBL now, so do non-video dependant stuff ;we can call this fuction as many times as we want ;at a time (has no effect if the fade is done) call RGBG_RunComplexFadeStepBkg call RGBG_RunComplexFadeStepBkg call RGBG_RunComplexFadeStepBkg ;we only need to call this once fore every ;RGBG_Upgade ComplexFadePals we plan to do ;(we may want to skip this if [RGBG_fade_steps_left_bkg]=0) call RGBG_DecodeComplexFadePals ;other code can be run here! ;huzzah! .waitvbl ldh a,[$41] and 3 cp 1 jr nz, .waitvbl ;now we're in VBL, so do video dependant stuff ;(we may want to skip this if [RGBG_fade_steps_left]=0) call RGBG_UpdateComplexFadePalsBkg jp .loop |
Runs a step in the complex fade. If [RGBG_fade_steps_left_bkg] is 0, the function will bail (returns without effecting the (finished) fade). Running a fade step does not actually update the palettes, it simply updates the fade work RAM, so it can be run when VRAM is not accesable.
See code example for RGBG_InitComplexFadeBkg
Input | |
First palette that's being faded |
|
Number of palettes that are being faded |
|
Output | |
The number of fade steps that still must be run before the fade is complete. |
Decodes the complex fade's work RAM, and translates it into a set of GameBoy Color standard 15-bit palettes. This functions does not require VRAM, and can be run when VRAM is not accesable..
See code example for RGBG_InitComplexFadeBkg
Input | |
First palette that's being faded |
|
Number of palettes that are being faded |
Sets the GameBoy Color's palettes in VRAM based on the palettes decoded by RGBG_DecodeComplexFadePalsBkg. This function requires acess to VRAM, and should be run during the vertical blank period.
See code example for RGBG_InitComplexFadeBkg
Input | |
First palette that's being faded |
|
Number of palettes that are being faded |
Self contained function to run a complex fade from start to finish. As this function runs 'in the foreground', the the rest of program will be paused while it is running (you may still use interupts, but I won't guarantee stability!).
Input | |
HL |
Pointer to the palettes to fade to. Palettes ared stored in the Gameboy Color's 15-bit standard |
B & C |
Thus function will run 'C' many steps every 'B' vblanks (to control timing). |
First palette that's being faded |
|
Number of palettes that are being faded |
Each object (sprite) pallete complex fade function (complex fade functions with an 'Obj' suffix) is functionally equivalent to it background palette complex fade function (complex fade functions with an 'Bkg' suffix). The object palette fades use a seperate area in RAM, so both background and object palette fades can be run simutaneously.
See: RGBG_InitComplexFadeBkg, RGBG_RunComplexFadeStepBkg, RGBG_DecodeComplexFadePalsBkg, RGBG_UpdateComplexFadePalsBkg
Copyright 2000 Aaron St.John