Core
V9_SetPort
void V9_SetPort(
u8 port,
u8 value
) __PRESERVES(b, d, e, h, iyl, iyh)

Set port value.

Parameters
port
u8

Port address (V9990 is plug to ports 60h~6Fh).

value
u8

Value to write to the port.

V9_GetPort
u8 V9_GetPort(
u8 port
) __PRESERVES(b, d, e, h, l, iyl, iyh)

Get port value.

Parameters
port
u8

Port address (V9990 is plug to ports 60h~6Fh).

Return

Value read from the givem port.

V9_SetRegister
void V9_SetRegister(
u8 reg,
u8 val
) __PRESERVES(b, c, d, e, h, iyl, iyh)

Set register value.  This function as no effect if register is read-only.

Parameters
reg
u8

V9990 register number.

val
u8

Value to write to the register.

V9_SetRegister16
void V9_SetRegister16(
u8 reg,
u16 val
) __PRESERVES(b, h, l, iyl, iyh)

Set register value.  This function as no effect if register is read-only.

Parameters
reg
u8

V9990 register number (LSB will be write to this register and MSB to the next).

val
u16

16-bits value to write to the registers.

V9_GetRegister
u8 V9_GetRegister(
u8 reg
) __PRESERVES(b, c, d, e, h, l, iyl, iyh)

Get register value.

Parameters
reg
u8

V9990 register number.

Return

Value read from the register (FFh is returned if register is write only).

V9_SetFlag
inline void V9_SetFlag(
u8 reg,
u8 mask,
u8 flag
)

Helper function to change some bits in a given register.  The function get a register value, apply a mask, 'or' the new value, than set the register.

Parameters
reg
u8

V9990 register number.

mask
u8

Bits to be cleared.

flag
u8

Bits to be set.

VRAM access
V9_SetWriteAddress
void V9_SetWriteAddress(
u32 addr
) __PRESERVES(b, iyl, iyh)

Initialize VRAM address for writing.

Parameters
addr
u32

Address to be setup for write access.

V9_SetReadAddress
void V9_SetReadAddress(
u32 addr
) __PRESERVES(b, iyl, iyh)

Initialize VRAM address for reading.

Parameters
addr
u32

Address to be setup for read access.

V9_FillVRAM_CurrentAddr
void V9_FillVRAM_CurrentAddr(
u8 value,
u16 count
)

Fill VRAM with 8-bits value from the previously setup write VRAM address.  V9_SetWriteAddress have to be called first.

Parameters
value
u8

8-bits value to be set.

count
u16

Size of the filled space in VRAM.

V9_FillVRAM16_CurrentAddr
void V9_FillVRAM16_CurrentAddr(
u16 value,
u16 count
)

Fill VRAM with 16-bits value from the previously setup write VRAM address.  V9_SetWriteAddress have to be called first.

Parameters
value
u16

16-bits value to be set.

count
u16

Size of the filled space in VRAM (size in bytes is 'count * 2').

V9_WriteVRAM_CurrentAddr
void V9_WriteVRAM_CurrentAddr(
const u8* src,
u16 count
)

Copy data from RAM buffer to the previously setup write VRAM address.  V9_SetWriteAddress have to be called first.

Parameters
src
const u8*

Pointer to the source data buffer to be copied in VRAM.

count
u16

Size of the data to be copied in VRAM.

V9_ReadVRAM_CurrentAddr
void V9_ReadVRAM_CurrentAddr(
const u8* dest,
u16 count
)

Copy data from the previously setup read VRAM address to a RAM buffer.  V9_SetReadAddress have to be called first.

Parameters
dst

Pointer to the destination data buffer.

count
u16

Size of the data to be copied in VRAM.

V9_Poke_CurrentAddr
void V9_Poke_CurrentAddr(
u8 val
) __PRESERVES(b, c, d, e, h, l, iyl, iyh)

Write a 8-bits value to the previously setup write VRAM address.  V9_SetWriteAddress have to be called first.

Parameters
val
u8

The value to be write.

V9_Poke16_CurrentAddr
void V9_Poke16_CurrentAddr(
u16 val
) __PRESERVES(b, c, d, e, iyl, iyh)

Write a 16-bits value to the previously setup write VRAM address.  V9_SetWriteAddress have to be called first.

Parameters
val
u16

The value to be write.

V9_Peek_CurrentAddr
u8 V9_Peek_CurrentAddr() __PRESERVES(b, c, d, e, h, l, iyl, iyh)

Read a 8-bits value from the previously setup write VRAM address.  V9_SetReadAddress have to be called first.

Return

The value at the given address.

V9_Peek16_CurrentAddr
u16 V9_Peek16_CurrentAddr() __PRESERVES(b, c, h, l, iyl, iyh)

Read a 16-bits value from the previously setup write VRAM address.  V9_SetReadAddress have to be called first.

Return

The value at the given address.

V9_FillVRAM
inline void V9_FillVRAM(
u32 addr,
u8 value,
u16 count
)

Fill VRAM with 8-bits value start to a given VRAM address.

Parameters
addr
u32

Destinaton VRAM address.

value
u8

8-bits value to be set.

count
u16

Size of the filled space in VRAM.

V9_FillVRAM16
inline void V9_FillVRAM16(
u32 addr,
u16 value,
u16 count
)

Fill VRAM with 16-bits value start to the given VRAM address.

Parameters
addr
u32

Destination VRAM address.

value
u16

16-bits value to be set.

count
u16

Size of the filled space in VRAM (size in bytes is 'count * 2').

V9_WriteVRAM
inline void V9_WriteVRAM(
u32 addr,
const u8* src,
u16 count
)

Copy data from a RAM buffer to the given VRAM address.

Parameters
addr
u32

Destination VRAM address.

src
const u8*

Pointer to the source data buffer to be copied in VRAM.

count
u16

Size of the data to be copied in VRAM.

V9_ReadVRAM
inline void V9_ReadVRAM(
u32 addr,
const u8* dest,
u16 count
)

Copy data from a given VRAM address to a RAM buffer.

Parameters
dst

Source VRAM address.

dst

Pointer to the destination data buffer.

count
u16

Size of the data to be copied in VRAM.

V9_Poke
inline void V9_Poke(
u32 addr,
u8 val
)

Write a 8-bits value to the given VRAM address.

Parameters
addr
u32

Destination VRAM address.

val
u8

The value to be write.

V9_Poke16
inline void V9_Poke16(
u32 addr,
u16 val
)

Write a 16-bits value to the given VRAM address.

Parameters
addr
u32

Destination VRAM address.

val
u16

The value to be write.

V9_Peek
inline u8 V9_Peek(
u32 addr
)

Read a 8-bits value from at the given VRAM address.

Parameters
addr
u32

Source VRAM address.

Return

The value at the given address.

V9_Peek16
inline u16 V9_Peek16(
u32 addr
)

Read a 16-bits value from at the given VRAM address.

Parameters
addr
u32

Source VRAM address.

Return

The value at the given address.

Setting
V9_SetScreenMode
void V9_SetScreenMode(
u8 mode
)

Set the current screen mode.

Parameters
mode
u8

Screen mode ID (see <V9_SCREEN_MODE>).

V9_SetBPP
inline void V9_SetBPP(
u8 bpp
)

Set bitmap bit-per-pixel value.

Parameters
bpp
u8

New bits per pixel to set. Can be: <V9_R06_BPP_2>, <V9_R06_BPP_4>, <V9_R06_BPP_8> or <V9_R06_BPP_16>.

V9_SetColorMode
void V9_SetColorMode(
u8 mode
)

Set bitmap color mode.

Parameters
mode
u8

New color mode to set. Can be any of the bitmap modes of <V9_COLOR_MODE> enum.

V9_GetBPP
inline u8 V9_GetBPP()

Get bit number per pixel.

Return

Current bits per pixel. Can be: <V9_R06_BPP_2>, <V9_R06_BPP_4>, <V9_R06_BPP_8> or <V9_R06_BPP_16>.

V9_SetImageSpaceWidth
inline void V9_SetImageSpaceWidth(
u8 width
)

Set number of pixels in X direction of image space.

Parameters
width
u8

New image space width to set. Can be: <V9_R06_WIDH_256>, <V9_R06_WIDH_512>, <V9_R06_WIDH_1024> or <V9_R06_WIDH_2048>.

V9_GetImageSpaceWidth
inline u8 V9_GetImageSpaceWidth()

Get number of pixels in X direction of image space.

Return

Current image space width. Can be: <V9_R06_WIDH_256>, <V9_R06_WIDH_512>, <V9_R06_WIDH_1024> or <V9_R06_WIDH_2048>.

V9_SetDisplayEnable
inline void V9_SetDisplayEnable(
bool enable
)

Enalbe or disable the screen display.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetBackgroundColor
inline void V9_SetBackgroundColor(
u8 color
)

Set background color.

Parameters
color
u8

New background color.

V9_GetBackgroundColor
inline u8 V9_GetBackgroundColor()

Get background color.

Return

Current background color.

V9_SetAdjustOffset
inline void V9_SetAdjustOffset(
u8 offset
)

Adjustment of the display location on the screen.

Parameters
offset
u8

Screen display position offset (MSB 4-bits: vertical offset, LSB 4-bits: horizontal offset).

V9_SetAdjustOffsetXY
inline void V9_SetAdjustOffsetXY(
i8 x,
i8 y
)

Adjustment of the display location on the screen.

Parameters
x
i8

Horizontal screen display position offset [-7:+8].

y
i8

Vertical screen display position offset [-7:+8].

V9_SetLayerPriority
inline void V9_SetLayerPriority(
u8 x,
u8 y
)

Set layer priority for P1 mode.

Parameters
x
u8

X coordinate where priority apply (2-bits value x 64 pixel).

y
u8

Y coordinate where priority apply (2-bits value x 64 pixel).

Status
V9_GetStatus
inline u8 V9_GetStatus()

Get status port value.

Return

Value of the status port (include various flags about frame rendering events).

V9_IsVBlank
inline bool V9_IsVBlank()

Is vertical non-display period.

Return

FALSE if not in vertical non-display period.

V9_IsHBlank
inline bool V9_IsHBlank()

Is horizontal non-display period.

Return

FALSE if not in horizontal non-display period.

V9_IsCmdDataReady
inline bool V9_IsCmdDataReady()

Check if command data transfer ready.

Return

FALSE if command data transfer not ready.

V9_IsCmdRunning
inline bool V9_IsCmdRunning()

Check if a command is in process.

Return

TRUE if command still running.

V9_IsCmdComplete
inline bool V9_IsCmdComplete()

Check if a no command is in process.

Return

TRUE if command finished.

V9_IsSecondField
inline bool V9_IsSecondField()

Check if render is in the second field period during interlace.

Return

FALSE if not in the second field period during interlace.

Interrupt
V9_SetInterrupt
inline void V9_SetInterrupt(
u8 flags
)

Set interruption flags.

Parameters
flags
u8

Can be a combination of <V9_INT_VBLANK>, <V9_INT_HBLANK> or <V9_INT_CMDEND>.

V9_DisableInterrupt
inline void V9_DisableInterrupt()

Disable all interruptions.

V9_SetVBlankInterrupt
inline void V9_SetVBlankInterrupt(
bool enable
)

Set vertical blank interruption.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetHBlankInterrupt
inline void V9_SetHBlankInterrupt(
bool enable
)

Set horizontal blank interruption.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetCmdEndInterrupt
inline void V9_SetCmdEndInterrupt(
bool enable
)

Set command end interruption.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetInterruptLine
inline void V9_SetInterruptLine(
u16 line
)

Specification of vertical position where display position interrupt occurs.

Parameters
line
u16

Line where h-blank interruption will occur (Specified by means of line No. with the display start line as "0").

V9_SetInterruptEveryLine
inline void V9_SetInterruptEveryLine()

Set line interrupt on every line.

V9_SetInterruptX
inline void V9_SetInterruptX(
u8 x
)

Specification of horizontal position where display position interrupt occurs.

Parameters
x
u8

Horizontal position where h-blank interruption will occur (Specified by unit of 64 master clock with the display start position as "0").

Scrolling
V9_SetScrollingX
void V9_SetScrollingX(
u16 x
)

Set horizontal scrolling value.

Parameters
x
u16

Scrolling value (between 0 and image space width-1).

V9_SetScrollingY
void V9_SetScrollingY(
u16 y
)

Set vertical scrolling value.

Parameters
y
u16

Scrolling value (between 0 and image space height-1).

V9_SetScrolling
inline void V9_SetScrolling(
u16 x,
u16 y
)

Set horizontal and vertical scrolling values.

Parameters
x
u16

Scrolling value (between 0 and image space width-1).

y
u16

Scrolling value (between 0 and image space height-1).

V9_SetScrollingBX
void V9_SetScrollingBX(
u16 x
)

Set horizontal scrolling value for layer B (P1 mode only).

Parameters
x
u16

Scrolling value (between 0 and image space width-1).

V9_SetScrollingBY
void V9_SetScrollingBY(
u16 y
)

Set vertical scrolling value for layer B (P1 mode only).

Parameters
y
u16

Scrolling value (between 0 and image space height-1).

V9_SetScrollingB
inline void V9_SetScrollingB(
u16 x,
u16 y
)

Set horizontal and vertical scrolling values for layer B (P1 mode only).

Parameters
x
u16

Scrolling value (between 0 and image space width-1).

y
u16

Scrolling value (between 0 and image space height-1).

Cursor
V9_SetCursorEnable
inline void V9_SetCursorEnable(
bool enable
)

Enable/disable all cursor display.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetCursorAttribute
void V9_SetCursorAttribute(
u8 id,
u16 x,
u16 y,
u8 color
)

Set the given cursor atribute (for bitmap modes).

Parameters
id
u8

Cursor index (0 or 1).

x
u16

Cursor X coordinate (from 0 to 1023 regardless of the screen mode).

y
u16

Cursor Y coordinate (from 0 to 511 regardless of the screen mode).

color
u8

Cursor color (2 bits: 0 to 3).

V9_SetCursorDisplay
void V9_SetCursorDisplay(
u8 id,
bool enable
)

Display/hide the given cursor

Parameters
id
u8

Cursor index (0 or 1).

enable
bool

TRUE to display or FALSE to hide.

V9_SetCursorPattern
inline void V9_SetCursorPattern(
u8 id,
const u8* data
)

Set the given cursor pattern.

Parameters
id
u8

Cursor index (0 or 1).

data
const u8*

128 bytes pattern buffer (32 x 32 binary data, 4 bytes per line).

V9_SetCursorPalette
inline void V9_SetCursorPalette(
u8 offset
)

Set cursor palette offset.

Parameters
offset
u8

Palette offset (4 bits: 0 to 15).

Sprite
V9_SetSpriteEnable
inline void V9_SetSpriteEnable(
bool enable
)

Enable/disable all sprites display.

Parameters
enable
bool

TRUE to enable or FALSE to disable.

V9_SetSpritePatternAddr
inline void V9_SetSpritePatternAddr(
u8 addr
)

Set sprite patterns VRAM address.

Parameters
addr
u8

Sprite pattern table address in VRAM.  P1 mode: V9_P1_SGT_00000 to V9_P1_SGT_38000 with 8000 step P2 mode: V9_P2_SGT_00000 to V9_P2_SGT_78000 with 8000 step

V9_SetSpritePalette
inline void V9_SetSpritePaletteOffset(
u8 offset
)

Set sprite palette offset.

Parameters
offset
u8

Palette offset (4 bits: 0 to 15).

V9_SetSpriteP1
inline void V9_SetSpriteP1(
u8 id,
const struct V9_Sprite* attr
)

Set sprite attribute for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

attr
const struct V9_Sprite*

Pointer to sprite structure.

V9_SetSpritePatternP1
inline void V9_SetSpritePatternP1(
u8 id,
u8 pat
)

Set sprite pattern for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

pat
u8

Pattern index (0 to 255).

V9_SetSpritePositionP1
inline void V9_SetSpritePositionP1(
u8 id,
u8 x,
u8 y
)

Set sprite position for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

x
u8

Sprite X coordinate.

y
u8

Sprite Y coordinate.

V9_SetSpriteInfoP1
inline void V9_SetSpriteInfoP1(
u8 id,
u8 info
)

Set sprite additionnal information for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

info
u8

Sprite additionnal information.

7   6   5   4   3   2   1   0
SC5 SC4 PR1 PR0 - - X9 X8
│ │ │ │ └───┴── X-coordinate (bits 8:9)
│ │ │ └────────────────── Disable flag (0: Enable, 1: Disable)
│ │ └────────────────────── Priority flag (0: Front, 1: Between layers)
└───┴────────────────────────── Color palette base (0-3)

Can be any combination of: <V9_SPAT_INFO_ENABLE> or <V9_SPAT_INFO_DISABLE> + <V9_SPAT_INFO_PRIO_FRONT> or <V9_SPAT_INFO_PRIO_BETWEEN> + <V9_SPAT_INFO_PALETTE>

V9_SetSpriteDisableP1
inline void V9_SetSpriteDisableP1(
u8 id,
bool disable
)

Set sprite disable flag for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

disable
bool

Is sprite display is disable?

V9_SetSpritePriorityP1
inline void V9_SetSpritePriorityP1(
u8 id,
u8 prio
)

Set sprite priority for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

prio
u8

Priority flag (0: Front, 1: Between layers).

V9_SetSpritePaletteP1
inline void V9_SetSpritePaletteP1(
u8 id,
u8 pal
)

Set sprite palette for P1 mode.

Parameters
id
u8

Sprite index (0 to 124).

info

Sprite additionnal information.

V9_SetSpriteP2
inline void V9_SetSpriteP2(
u8 id,
const struct V9_Sprite* attr
)

Set sprite attribute for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

attr
const struct V9_Sprite*

Pointer to sprite structure.

V9_SetSpritePatternP2
inline void V9_SetSpritePatternP2(
u8 id,
u8 pat
)

Set sprite pattern for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

pat
u8

Pattern index (0 to 255).

V9_SetSpritePositionP2
inline void V9_SetSpritePositionP2(
u8 id,
u8 x,
u8 y
)

Set sprite position for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

x
u8

Sprite X coordinate.

y
u8

Sprite Y coordinate.

V9_SetSpriteInfoP2
inline void V9_SetSpriteInfoP2(
u8 id,
u8 info
)

Set sprite additionnal information for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

info
u8

Sprite additionnal information.

7   6   5   4   3   2   1   0
SC5 SC4 PR1 PR0 - - X9 X8
│ │ │ │ └───┴── X-coordinate (bits 8:9)
│ │ │ └────────────────── Disable flag (0: Enable, 1: Disable)
│ │ └────────────────────── Priority flag (0: Front, 1: Between layers)
└───┴────────────────────────── Color palette base (0-3)

Can be any combination of: <V9_SPAT_INFO_ENABLE> or <V9_SPAT_INFO_DISABLE> + <V9_SPAT_INFO_PRIO_FRONT> or <V9_SPAT_INFO_PRIO_BETWEEN> + <V9_SPAT_INFO_PALETTE>

V9_SetSpriteDisableP2
inline void V9_SetSpriteDisableP2(
u8 id,
bool disable
)

Set sprite disable flag for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

disable
bool

Is sprite display is disable?

V9_SetSpritePriorityP2
inline void V9_SetSpritePriorityP2(
u8 id,
u8 prio
)

Set sprite priority for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

prio
u8

Priority flag (0: Front, 1: Between layers).

V9_SetSpritePaletteP2
inline void V9_SetSpritePaletteP2(
u8 id,
u8 pal
)

Set sprite palette for P2 mode.

Parameters
id
u8

Sprite index (0 to 124).

info

Sprite additionnal information.

Palette
V9_SetPaletteEntry
void V9_SetPaletteEntry(
u8 index,
u16 color
) __PRESERVES(h, l, iyl, iyh)

Set the color of a given palette entry.

Parameters
index
u8

Index of the palette entry (0-63).

color
u16

16 bits color value.  Format: [Ys:1|green:5|red:5|blue:5]

V9_SetPalette
inline void V9_SetPalette(
u8 first,
u8 num,
const u16* table
)

Set the colors of a given palette entries.

Parameters
first
u8

Index of the first entry to set (0-63).

num
u8

Numer of entries to set (1-64).

table
const u16*

16 bits color table.  Format: [Ys:1|green:5|red:5|blue:5]

V9_SetPaletteAll
inline void V9_SetPaletteAll(
const u16* table
)

Set the colors of all the palette 64 entries.

Parameters
table
const u16*

16 bits color table.  Format: [Ys:1|green:5|red:5|blue:5]

V9_SelectPaletteP1
inline void V9_SelectPaletteP1(
u8 a,
u8 b
)

Set the P1 mode palette offset.

Parameters
a
u8

Layer A palette index (2 bits).

b
u8

Layer B palette index (2 bits).

V9_SelectPaletteP2
inline void V9_SelectPaletteP2(
u8 a
)

Set the P2 mode palette offset.

Parameters
a
u8

Palette index (2 bits).

V9_SelectPaletteBP2
inline void V9_SelectPaletteBP2(
u8 a
)

Set the BP2 mode palette offset (R#13 PLTO5-2).

Parameters
a
u8

Palette index (4 bits).

V9_SelectPaletteBP4
inline void V9_SelectPaletteBP4(
u8 a
)

Set the BP4 mode palette offset (R#13 PLTO5-4).

Parameters
a
u8

Palette index (2 bits).

Command helper
V9_SetCommandSX
inline void V9_SetCommandSX(
u16 sx
)

Set source X-coordinate.

Parameters
sx
u16

Specified with the X-coordinate of the image coordinate space (by pixels) and rolling to "0" occurs when a larger value than the image size is used for setting. (When in P1 mode, layer "A" is selected at SX9=0 and layer "B" at SX9=1.)

V9_SetCommandSY
inline void V9_SetCommandSY(
u16 sy
)

Set source Y-coordinate.

Parameters
sy
u16

Specified with the Y-coordinate of the image coordinate space (by pixels) and rolling to "0" occurs when a larger value than the image size is used for setting.

V9_SetCommandSA
inline void V9_SetCommandSA(
u32 sa
)

Set source VRAM address.

Parameters
sa
u32

Specified with the address on the VRAM map (by bytes).

V9_SetCommandDX
inline void V9_SetCommandDX(
u16 dx
)

Set destination X-coordinate.

Parameters
dx
u16

Specified with the X-coordinate of the image coordinate space (by pixels) and rolling to "0" occurs when a larger value than the image size is used for setting. (When in P1 mode, layer "A" is selected at DX9=0 and layer "B" at DX9=1.)

V9_SetCommandDY
inline void V9_SetCommandDY(
u16 dy
)

Set destination Y-coordinate.

Parameters
dy
u16

Specified with the Y-coordinate of the image coordinate space (by pixels) and rolling to "0" occurs when a larger value than the image size is used for setting.

V9_SetCommandDA
inline void V9_SetCommandDA(
u32 da
)

Set destination VRAM address.

Parameters
da
u32

Specified with the address on the VRAM map (by bytes).

V9_SetCommandNX
inline void V9_SetCommandNX(
u16 nx
)

Set the number of pixels in X direction.

Parameters
nx
u16

The number of pixels in X direction of the image coordinate space is specified and rolling to "0" occurs when the specified range exceeds the image size. (Maximum value is 2048 pixels when all "0".)

V9_SetCommandNY
inline void V9_SetCommandNY(
u16 ny
)

Set the number of pixels in Y direction.

Parameters
ny
u16

The number of pixels in Y direction of the image coordinate space is specified and rolling to "0" occurs when the specified range exceeds the image size. (Maximum value is 4096 pixels when all "0".)

V9_SetCommandMJ
inline void V9_SetCommandMJ(
u16 mj
)

Set the length of the longer side of the rectangle.

Parameters
mj
u16

The length of the longer side of the rectangle whose diagonal line is the same as the drawn line is specified by pixels. When the specified range exceeds the image size, rolling to "0" occurs.

V9_SetCommandMI
inline void V9_SetCommandMI(
u16 mi
)

Set the length of the shorter side of the rectangle.

Parameters
mi
u16

The length of the shorter side of the rectangle whose diagonal line is the same as the drawn line is specified by pixels. When the specified range exceeds the image size, rolling to "0" occurs.

V9_SetCommandNA
inline void V9_SetCommandNA(
u32 na
)

Set the number of bytes.

Parameters
na
u32

The number of bytes on the VRAM map is specified and rolling to address "0" occurs when the specified range exceeds the VRAM capacity. (Maximum value is 512K bytes when all "0".)  Note) 256 bytes when NA bit 7-0 are all "0".

V9_SetCommandArgument
inline void V9_SetCommandArgument(
u8 arg
)

Set command argument.

Parameters
arg
u8

Argument.  7 6 5 4 3 2 1 0 0 0 0 0 DIY DIX NEQ MAJ │ │ │ └── In the line inclination specification for LINE, X is the longer side and Y the shorter side at "0" while Y is the longer side and X the shorter side at "1".  │ │ └────── In the border color specification for SEARCH, "0" is for specified color detection and "1" is for non-specified color detection.  └───┴────────── The transfer direction (plus direction at "0" and minus direction at "1") from the base coordinates is specified. With BMXL and BMLX, however, the linear address specified side is fixed to "plus" and with BMLL, both X and Y are specified to the same direction.

V9_SetCommandLogicalOp
inline void V9_SetCommandLogicalOp(
u8 lop
)

Set command logical operation.

Parameters
lop
u8

Logical operation.  7 6 5 4 3 2 1 0 0 0 0 TP L11 L10 L01 L00 │ │ │ │ └── WC value for the bit with SC=0 and DC=0.  │ │ │ └────── WC value for the bit with SC=0 and DC=1.  │ │ └────────── WC value for the bit with SC=1 and DC=0.  │ └────────────── WC value for the bit with SC=1 and DC=1.  └────────────────── When this bit is "1", the data with SC as all "0" (by pixel for the X/Y-coordinates and by byte for the linear address) is not transferred.

V9_SetCommandWriteMask
inline void V9_SetCommandWriteMask(
u16 wm
)

Set command write mask.

Parameters
wm
u16

Write mask.

V9_SetCommandFC
inline void V9_SetCommandFC(
u16 fc
)

Set color code of font data "1".

Parameters
fc
u16

Forground color.

V9_SetCommandBC
inline void V9_SetCommandBC(
u16 bc
)

Set color code of font data "0".

Parameters
bc
u16

Background color.

V9_ExecCommand
inline void V9_ExecCommand(
u8 op
)

Set operation code.

Parameters
op
u8

Operation code.  V9_CMD_STOP, V9_CMD_LMMC, V9_CMD_LMMV, V9_CMD_LMCM, V9_CMD_LMMM, V9_CMD_CMMC, V9_CMD_CMMM, V9_CMD_BMXL, V9_CMD_BMLX, V9_CMD_BMLL, V9_CMD_LINE, V9_CMD_SEARCH, V9_CMD_POINT, V9_CMD_PSET, V9_CMD_ADVANCE

GetCommandBX
inline u16 GetCommandBX()

Set search command border coordinate.

Return

Command border coordinate.

Command
V9_CommandSTOP
inline void V9_CommandSTOP()

Command being executed is stopped.

V9_CommandLMMC

Data is transferred from CPU to VRAM rectangle area.  Note: Infinished function; don't use it.

Parameters
src

Source buffer in RAM.

dx

Destination X-coordinate.

dy

Destination Y-coordinate.

nx

Number of pixels in X direction.

ny

Number of pixels in Y direction.

arg

Command argument.  inline void V9_CommandLMMC(const u8* src, u16 dx, u16 dy, u16 nx, u16 ny, u8 arg) { V9_SetCommandDX(dx); V9_SetCommandDY(dy); V9_SetCommandNX(nx); V9_SetCommandNY(ny); V9_SetCommandArgument(arg); V9_ExecCommand(V9_CMD_LMMC); }

V9_CommandLMMV
inline void V9_CommandLMMV(
u16 dx,
u16 dy,
u16 nx,
u16 ny,
u8 arg,
u16 fc
)

VRAM rectangle area is painted out.

Parameters
dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

fc
u16

Forground color.

V9_CommandLMCM

VRAM rectangle area data is transferred to CPU.  Note: Infinished function; don't use it.

Parameters
sx

Source X-coordinate.

sy

Source Y-coordinate.

dx

Destination X-coordinate.

dy

Destination Y-coordinate.

nx

Number of pixels in X direction.

ny

Number of pixels in Y direction.

arg

Command argument.

dest

Destination buffer in RAM.  inline void V9_CommandLMCM(u16 sx, u16 sy, u16 nx, u16 ny, u8 arg, u8* dest) { V9_SetCommandSX(sx); V9_SetCommandSY(sy); V9_SetCommandNX(nx); V9_SetCommandNY(ny); V9_SetCommandArgument(arg); V9_ExecCommand(V9_CMD_LMCM); }

V9_CommandLMMM
inline void V9_CommandLMMM(
u16 sx,
u16 sy,
u16 dx,
u16 dy,
u16 nx,
u16 ny,
u8 arg
)

Rectangle area data is transferred from VRAM to VRAM.

Parameters
sx
u16

Source X-coordinate.

sy
u16

Source Y-coordinate.

dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

V9_CommandCMMC
inline void V9_CommandCMMC(
u16 dx,
u16 dy,
u16 nx,
u16 ny,
u8 arg,
u16 fc,
u16 bc
)

CPU character data is color-developed and transferred to VRAM rectangle area.

Parameters
dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

fc
u16

Forground color.

bc
u16

Background color.

V9_CommandCMMM
inline void V9_CommandCMMM(
u32 sa,
u16 dx,
u16 dy,
u16 nx,
u16 ny,
u8 arg,
u16 fc,
u16 bc
)

VRAM character data is color-developed and transferred to VRAM rectangle area.

Parameters
sa
u32

Source address.

dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

fc
u16

Forground color.

bc
u16

Background color.

V9_CommandBMXL
inline void V9_CommandBMXL(
u32 sa,
u16 dx,
u16 dy,
u16 nx,
u16 ny,
u8 arg
)

Data on VRAM linear address is transferred to VRAM rectangle area.

Parameters
sa
u32

Source address.

dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

V9_CommandBMLX
inline void V9_CommandBMLX(
u16 sx,
u16 sy,
u32 da,
u16 nx,
u16 ny,
u8 arg
)

VRAM rectangle area data is transferred onto VRAM linear address.

Parameters
sx
u16

Source X-coordinate.

sy
u16

Source Y-coordinate.

da
u32

Destination address.

nx
u16

Number of pixels in X direction.

ny
u16

Number of pixels in Y direction.

arg
u8

Command argument.

V9_CommandBMLL
inline void V9_CommandBMLL(
u32 sa,
u32 da,
u32 na,
u8 arg
)

Data on VRAM linear address is transferred onto VRAM linear address.

Parameters
sa
u32

Source address.

da
u32

Destination address.

na
u32

Number of bytes.

arg
u8

Command argument.

V9_CommandLINE
inline void V9_CommandLINE(
u16 dx,
u16 dy,
u16 mj,
u16 mi,
u8 arg,
u16 fc
)

Straight line is drawn on X/Y-coordinates.

Parameters
dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

mj
u16

Shorter side of the rectangle.

mi
u16

Longer side of the rectangle.

arg
u8

Command argument.

fc
u16

Forground color.

V9_CommandSEARCH
inline void V9_CommandSEARCH(
u16 sx,
u16 sy,
u8 arg,
u16 fc
)

Border color coordinates on X/Y space are detected.

Parameters
sx
u16

Source X-coordinate.

sy
u16

Source Y-coordinate.

arg
u8

Command argument.

fc
u16

Forground color.

V9_CommandPOINT
inline void V9_CommandPOINT(
u16 sx,
u16 sy
)

Color code of specified point on X/Y-coordinates is read out.

Parameters
sx
u16

Source X-coordinate.

sy
u16

Source Y-coordinate.

V9_CommandPSET
inline void V9_CommandPSET(
u16 dx,
u16 dy,
u16 fc,
u8 shift
)

Drawing is executed at drawing point on X/Y-coordinates.

Parameters
dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

fc
u16

Forground color.

shift
u8

Pointer shift.

V9_CommandADVANCE
inline void V9_CommandADVANCE(
u16 dx,
u16 dy,
u8 shift
)

Drawing point on X/Y-coordinates is shifted.

Parameters
dx
u16

Destination X-coordinate.

dy
u16

Destination Y-coordinate.

shift
u8

Pointer shift.

Helper
V9_Detect
bool V9_Detect()

Detecting the presence of a V9990 card

Return

TRUE if V9990 video chip is detected.

V9_ClearVRAM
void V9_ClearVRAM() __PRESERVES(d, e, h, l, iyl, iyh)

Clear the whole 512 KB of VRAM with zero

V9_WaitCmdEnd
inline void V9_WaitCmdEnd()

Wait for current command completion

V9_CellAddrP1A
inline u32 V9_CellAddrP1A(
u8 x,
u8 y
)

Get address fo the given X/Y cell coordiante for player A of P1 mode.

Parameters
x
u8

Cell X-coordinate.

y
u8

Cell Y-coordinate.

Return

VRAM address of the given cell.

V9_CellAddrP1B
inline u32 V9_CellAddrP1B(
u8 x,
u8 y
)

Get address fo the given X/Y cell coordiante for player B of P1 mode.

Parameters
x
u8

Cell X-coordinate.

y
u8

Cell Y-coordinate.

Return

VRAM address of the given cell.

V9_CellAddrP2
inline u32 V9_CellAddrP2(
u8 x,
u8 y
)

Get address fo the given X/Y cell coordiante for P2 mode.

Parameters
x
u8

Cell X-coordinate.

y
u8

Cell Y-coordinate.

Return

VRAM address of the given cell.