Peek & poke

Functions to read and write memory

Poke
inline void Poke(
u16 addr,
u8 val
)

Set a 8-bit value at the given address

Parameters
addr
u16

Address to set

val
u8

8-bit value to set

Poke16
inline void Poke16(
u16 addr,
u16 val
)

Set a 16-bit value at the given address

Parameters
addr
u16

Address to set

val
u16

16-bit value to set

Peek
inline u8 Peek(
u16 addr
)

Get the 8-bit value at the given address

Parameters
addr
u16

Address to get

Return

8-bit value stored at the given address

Peek16
inline u16 Peek16(
u16 addr
)

Get the 16-bit value at the given address

Parameters
addr
u16

Address to get

Return

16-bit value stored at the given address

Low level

Functions to access low level functions

EnableInterrupt
inline void EnableInterrupt()

Enable interruption

DisableInterrupt
inline void DisableInterrupt()

Disable interruption

Halt
inline void Halt()

Pause the CPU until a new interruption occured

Information

Functions to get information from the system

Sys_GetBIOSInfo
inline u8 Sys_GetBIOSInfo()

Get BIOS information (frequency, keyboard type, etc.)

Return

The BIOS information

Sys_GetMSXVersion
inline u8 Sys_GetMSXVersion()

Get the MSX version

Return

The MSX version (0: MSX1, 1: MSX2, 2: MSX2+, 3: MSX turbo R)

Sys_GetFrequency
inline u8 Sys_GetFrequency()

Get the system frequency (from BIOS)

Return

SYS_FERQ_50HZ or SYS_FERQ_60HZ

Sys_Is60Hz
inline bool Sys_Is60Hz()

Get the system frequency (from BIOS)

Return

TRUE if the BIOS is 60 Hz

Sys_Is50Hz
inline bool Sys_Is50Hz()

Get the system frequency (from BIOS)

Return

TRUE if the BIOS is 50 Hz

Call

Functions to call routines

Call
inline void Call(
u16 addr
)

Direct call a routine at a given address (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

CallToA
inline u8 CallToA(
u16 addr
)

Direct call a routine at a given address (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

Return

Value stored in register A

CallA
inline void CallA(
u16 addr,
u8 a
)

Direct call a routine at a given address with a 8-bits parameter in register A (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

a
u8

Function parameter to put in register A

CallAToA
inline u8 CallAToA(
u16 addr,
u8 a
)

Direct call a routine at a given address with a 8-bits parameter in register A (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

a
u8

Function parameter to put in register A

Return

Value stored in register A

CallL
inline void CallL(
u16 addr,
u8 l
)

Direct call a routine at a given address with a 8-bits parameter in register L (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

l
u8

Function parameter to put in register L

CallLToA
inline u8 CallLToA(
u16 addr,
u8 l
)

Direct call a routine at a given address with a 8-bits parameter in register L (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

l
u8

Function parameter to put in register L

Return

Value stored in register A

CallHL
inline void CallHL(
u16 addr,
u16 hl
)

Direct call a routine at a given address with a 16-bits parameter in register HL (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

val

Function parameter to put in register HL

CallHLToA
inline u8 CallHLToA(
u16 addr,
u16 hl
)

Direct call a routine at a given address with a 16-bits parameter in register HL (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address to call

val

Function parameter to put in register HL

Return

Value stored in register A

CallDriver
inline u8 CallDriver(
u16 addr,
u8 val
)

Direct call a routine at a given address with a 8-bits parameter in register A (generate ASM code: "call XXXX") No extra cost due to calling a C function.

Parameters
addr
u16

Address of the driver

val
u8

8-bit value to transfer to driver's main function

Return

Value returned by the driver

Slot

Slot handling functions

Sys_GetPageSlot
u8 Sys_GetPageSlot(
u8 page
)

Get the slot ID of a given page

Parameters
page
u8

The page to ckeck

Return

The slot ID

Sys_SetPageSlot
void Sys_SetPageSlot(
u8 page,
u8 slotId
)

Select a slot in a given page

Parameters
page
u8

The page to change

slotId
u8

The slot ID to select

Sys_IsSlotExpanded
inline bool Sys_IsSlotExpanded(
u8 slot
)

Check if slot is expanded

Parameters
slot
u8

The slot to check

Return

FALSE if the slot is not expanded

Sys_SetPage0Slot
void Sys_SetPage0Slot(
u8 slotId
)

Select a given slot in page 0

Parameters
slotId
u8

The slot to select

Sys_SlotIsExpended
inline bool Sys_SlotIsExpended(
u8 slotId
)

Check expended flag from slot ID

Parameters
slotId
u8

The slot ID

Return

FALSE if the slot is not expended

Sys_SlotGetPrimary
inline u8 Sys_SlotGetPrimary(
u8 slotId
)

Get primary slot from slot ID

Parameters
slotId
u8

The slot ID

Return

The primary slot of the slot ID

Sys_SlotGetSecondary
inline u8 Sys_SlotGetSecondary(
u8 slotId
)

Get secondary slot from slot ID

Parameters
slotId
u8

The slot ID

Return

The secondary slot of the slot ID

Sys_CheckSlot
u8 Sys_CheckSlot(
CheckSlotCallback cb
)

Check all slots with a given callback function

Parameters
cb
CheckSlotCallback

Callback function to call for each slot

Return

The slot ID that match the callback function

Address

Binary address functions

Sys_GetFirstAddr
inline u16 Sys_GetFirstAddr()

Get first address of program binary

Return

The first address of the program binary

Sys_GetHeaderAddr
inline u16 Sys_GetHeaderAddr()

Get address of program header (if any)

Return

The address of the program header

Sys_GetLastAddr
inline u16 Sys_GetLastAddr()

Get last address of program binary

Return

The last address of the program binary

Misc

Miscellaneous helper functions

Sys_PlayClickSound
inline void Sys_PlayClickSound()

Play the click sound

Sys_StopClickSound
inline void Sys_StopClickSound()

Stop the click sound