break monster VM into small pieces :D
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
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),
|
||||
0x2001 => Some(Self::InputGetPad),
|
||||
0x2002 => Some(Self::InputGetPadPressed),
|
||||
0x2003 => Some(Self::InputGetPadReleased),
|
||||
0x2004 => Some(Self::InputGetPadHold),
|
||||
0x2010 => Some(Self::InputPadSnapshot),
|
||||
0x2011 => Some(Self::InputTouchSnapshot),
|
||||
0x2101 => Some(Self::TouchGetX),
|
||||
0x2102 => Some(Self::TouchGetY),
|
||||
0x2103 => Some(Self::TouchIsDown),
|
||||
0x2104 => Some(Self::TouchIsPressed),
|
||||
0x2105 => Some(Self::TouchIsReleased),
|
||||
0x2106 => Some(Self::TouchGetHold),
|
||||
0x2107 => Some(Self::TouchGetFinger),
|
||||
0x2200 => Some(Self::PadGetUp),
|
||||
0x2201 => Some(Self::PadGetDown),
|
||||
0x2202 => Some(Self::PadGetLeft),
|
||||
0x2203 => Some(Self::PadGetRight),
|
||||
0x2204 => Some(Self::PadGetA),
|
||||
0x2205 => Some(Self::PadGetB),
|
||||
0x2206 => Some(Self::PadGetX),
|
||||
0x2207 => Some(Self::PadGetY),
|
||||
0x2208 => Some(Self::PadGetL),
|
||||
0x2209 => Some(Self::PadGetR),
|
||||
0x220A => Some(Self::PadGetStart),
|
||||
0x220B => Some(Self::PadGetSelect),
|
||||
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::InputGetPad => "InputGetPad",
|
||||
Self::InputGetPadPressed => "InputGetPadPressed",
|
||||
Self::InputGetPadReleased => "InputGetPadReleased",
|
||||
Self::InputGetPadHold => "InputGetPadHold",
|
||||
Self::InputPadSnapshot => "InputPadSnapshot",
|
||||
Self::InputTouchSnapshot => "InputTouchSnapshot",
|
||||
Self::TouchGetX => "TouchGetX",
|
||||
Self::TouchGetY => "TouchGetY",
|
||||
Self::TouchIsDown => "TouchIsDown",
|
||||
Self::TouchIsPressed => "TouchIsPressed",
|
||||
Self::TouchIsReleased => "TouchIsReleased",
|
||||
Self::TouchGetHold => "TouchGetHold",
|
||||
Self::TouchGetFinger => "TouchGetFinger",
|
||||
Self::PadGetUp => "PadGetUp",
|
||||
Self::PadGetDown => "PadGetDown",
|
||||
Self::PadGetLeft => "PadGetLeft",
|
||||
Self::PadGetRight => "PadGetRight",
|
||||
Self::PadGetA => "PadGetA",
|
||||
Self::PadGetB => "PadGetB",
|
||||
Self::PadGetX => "PadGetX",
|
||||
Self::PadGetY => "PadGetY",
|
||||
Self::PadGetL => "PadGetL",
|
||||
Self::PadGetR => "PadGetR",
|
||||
Self::PadGetStart => "PadGetStart",
|
||||
Self::PadGetSelect => "PadGetSelect",
|
||||
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",
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user