88 lines
3.2 KiB
Rust
88 lines
3.2 KiB
Rust
use super::{Syscall, SyscallMeta, domains};
|
|
|
|
pub(crate) fn meta_for(syscall: Syscall) -> &'static SyscallMeta {
|
|
for entry in domains::all_entries() {
|
|
if entry.syscall == syscall {
|
|
return &entry.meta;
|
|
}
|
|
}
|
|
panic!("Missing SyscallMeta for {:?}", syscall);
|
|
}
|
|
|
|
impl Syscall {
|
|
pub fn from_u32(id: u32) -> Option<Self> {
|
|
match id {
|
|
0x0001 => Some(Self::SystemHasCart),
|
|
0x0002 => Some(Self::SystemRunCart),
|
|
0x1001 => Some(Self::GfxClear),
|
|
0x1002 => Some(Self::GfxFillRect),
|
|
0x1003 => Some(Self::GfxDrawLine),
|
|
0x1004 => Some(Self::GfxDrawCircle),
|
|
0x1005 => Some(Self::GfxDrawDisc),
|
|
0x1006 => Some(Self::GfxDrawSquare),
|
|
0x1007 => Some(Self::GfxSetSprite),
|
|
0x1008 => Some(Self::GfxDrawText),
|
|
0x1010 => Some(Self::GfxClear565),
|
|
0x3001 => Some(Self::AudioPlaySample),
|
|
0x3002 => Some(Self::AudioPlay),
|
|
0x4001 => Some(Self::FsOpen),
|
|
0x4002 => Some(Self::FsRead),
|
|
0x4003 => Some(Self::FsWrite),
|
|
0x4004 => Some(Self::FsClose),
|
|
0x4005 => Some(Self::FsListDir),
|
|
0x4006 => Some(Self::FsExists),
|
|
0x4007 => Some(Self::FsDelete),
|
|
0x5001 => Some(Self::LogWrite),
|
|
0x5002 => Some(Self::LogWriteTag),
|
|
0x6001 => Some(Self::AssetLoad),
|
|
0x6002 => Some(Self::AssetStatus),
|
|
0x6003 => Some(Self::AssetCommit),
|
|
0x6004 => Some(Self::AssetCancel),
|
|
0x6101 => Some(Self::BankInfo),
|
|
0x6102 => Some(Self::BankSlotInfo),
|
|
_ => None,
|
|
}
|
|
}
|
|
|
|
pub fn args_count(&self) -> usize {
|
|
super::meta_for(*self).arg_slots as usize
|
|
}
|
|
|
|
pub fn results_count(&self) -> usize {
|
|
super::meta_for(*self).ret_slots as usize
|
|
}
|
|
|
|
pub fn name(&self) -> &'static str {
|
|
match self {
|
|
Self::SystemHasCart => "SystemHasCart",
|
|
Self::SystemRunCart => "SystemRunCart",
|
|
Self::GfxClear => "GfxClear",
|
|
Self::GfxFillRect => "GfxFillRect",
|
|
Self::GfxDrawLine => "GfxDrawLine",
|
|
Self::GfxDrawCircle => "GfxDrawCircle",
|
|
Self::GfxDrawDisc => "GfxDrawDisc",
|
|
Self::GfxDrawSquare => "GfxDrawSquare",
|
|
Self::GfxSetSprite => "GfxSetSprite",
|
|
Self::GfxDrawText => "GfxDrawText",
|
|
Self::GfxClear565 => "GfxClear565",
|
|
Self::AudioPlaySample => "AudioPlaySample",
|
|
Self::AudioPlay => "AudioPlay",
|
|
Self::FsOpen => "FsOpen",
|
|
Self::FsRead => "FsRead",
|
|
Self::FsWrite => "FsWrite",
|
|
Self::FsClose => "FsClose",
|
|
Self::FsListDir => "FsListDir",
|
|
Self::FsExists => "FsExists",
|
|
Self::FsDelete => "FsDelete",
|
|
Self::LogWrite => "LogWrite",
|
|
Self::LogWriteTag => "LogWriteTag",
|
|
Self::AssetLoad => "AssetLoad",
|
|
Self::AssetStatus => "AssetStatus",
|
|
Self::AssetCommit => "AssetCommit",
|
|
Self::AssetCancel => "AssetCancel",
|
|
Self::BankInfo => "BankInfo",
|
|
Self::BankSlotInfo => "BankSlotInfo",
|
|
}
|
|
}
|
|
}
|