TL;DR: the syscall names in libfxcg really need to be revised, even if at the expense of breaking backwards compatibility.
---
Recently I was showing some C code I had written for the Prizm to a friend, and he asked me "what strange function names are these". I explained that they were syscalls ("like library functions") and I could not change their name at whim. Obviously, the issue was that some of the names were really bad, and definitely not obvious, even for simpler syscalls.
I told him how most names came to be, that is, based on what was used in legacy SDKs and Simon Lothar's documentation. He pointed out that with these names it must be horrible to code for the Prizm, and I have to agree.
Let me point out the main issues I found with the current syscall names.
1. Many don't succinctly describe the function of the syscall, and a minority even gives wrong hints.
Some names don't mean much and are extremely ambiguous, while others are excessively verbose. Some examples:
- Box (what does this do? does it draw a rectangle on screen? just the outline of a rectangle? does it draw the 3D shape of a box? a decorated window? Looking on the Wiki it seems it's related to message boxes. We won't really know without testing it, because the name is all we know from Simon's docs).
- DisplayMainMenu (one could think this opens the proper Main Menu, but it appears to only draw it to screen - no interactivity. A better name could be DrawMainMenu).
- GetGetkeyToMainFunctionReturnFlag (this one could have a much shorter name, like GetMainMenuAvailability or GetMainMenuFlag).
- Bdisp_EnableColor (it turns out that when this function is not called, color is still enabled, it's just not full color! Why not call it Bdisp_FullColor or Bdisp_DisableIndexed, etc.)
2. Many of the names have strange or inconsistent suffixes and prefixes.
While the idea of adding prefixes to names to make it more clear what category they belong in (poor man's version of namespaces) isn't bad in itself, the way it's implemented leaves much to be desired.
Some prefixes don't make much sense, often things in the same category have different ones and some lack prefixes. Some examples:
- Bdisp AllClr VRAM (not that bad; it appears most display functions use Bdisp, and the suffix VRAM to indicate they operate in the VRAM...)
- Bdisp ShapeToVRAM16C (OK, it's a display function, operates in the VRAM... what is the 16C? 16 colors, maybe...)
- Bdisp HeaderText (is it in VRAM? DD? how many colors?)
- PrintXY (VRAM? DD? why doesn't it have Bdisp in front?...)
One could think that Bdisp is only for lower-level functions and not for text drawing, so here's one for you: Bdisp_WriteSystemMessage.
Also note the random "OS" designation:
- Bfile_GetFileSize_OS, but Bfile_DeleteEntry has no OS
- Print_OS and PrintXY (does that mean PrintXY is not implemented by the OS, since it has no OS suffix?...)
- GlibGetOSVersionInfo (what exactly is this Glib I don't see anywhere else?)
- Bkey GetAllFlags (hmm, a keyboard function... is it implemented by the OS?)
- GetKeyWait_OS (wait, turns out this is a keyboard function too... why doesn't it have a prefix then?)
(note that personally, I'm not a fan of the whole Bdisp / Bkey / Bfile... thing)
3. Overloaded variants of syscalls have strange names
It's not unusual to find syscalls that have multiple versions, with different number of parameters or slightly different meaning. But the names are awkward. For instance:
- ProgressBar (ok, it's a progress bar)
- ProgressBar2 (hmm, another version of the progress bar. Turns out this one allows for a custom caption, why not call it ProgressBarCaption or something instead?)
- ProgressBar0 (zero? a overloaded function of ProgressBar, oh well... but zero?)
- SaveVRAM_1 (where's SaveVRAM_2? I mean, it's good to account for yet-to-be-found syscalls, but so far none have appeared and it's been, like, three years...)
4. Naming conventions are not consistent
The way functions are named doesn't seem to adhere to any common standard, and doesn't appear to be consistent within libfxcg either. Some examples that clearly show why my friend called libfxcg "The International Festival of Naming Conventions":
- App_InitDlgDescriptor
- APP_FINANCE
- App_LINK_Send_ST9_Packet
- APP_SYSTEM_LANGUAGE
- App_Optimize
- APP_EACT_StatusIcon
- SMEM_MapIconToExt
My proposal is to just rename everything using a single set of rules (to be discussed), and to make things easy, not caring about backwards compatibility (it's not like people couldn't always check out an old version of libfxcg to be able to build old code trees, and in fact they'd need to do it anyway, because there are always things changing), and make sure that syscalls added from then on follow that set of rules.
The way things are now, it's a nightmare for new developers to understand anything, and it's very hard even for seasoned Prizm programmers to know the name of a certain syscall off the top of their head (was that in all caps? with underscores maybe? perhaps it doesn't start with Bdisp?...).
Discuss.
---
Recently I was showing some C code I had written for the Prizm to a friend, and he asked me "what strange function names are these". I explained that they were syscalls ("like library functions") and I could not change their name at whim. Obviously, the issue was that some of the names were really bad, and definitely not obvious, even for simpler syscalls.
I told him how most names came to be, that is, based on what was used in legacy SDKs and Simon Lothar's documentation. He pointed out that with these names it must be horrible to code for the Prizm, and I have to agree.
Let me point out the main issues I found with the current syscall names.
1. Many don't succinctly describe the function of the syscall, and a minority even gives wrong hints.
Some names don't mean much and are extremely ambiguous, while others are excessively verbose. Some examples:
- Box (what does this do? does it draw a rectangle on screen? just the outline of a rectangle? does it draw the 3D shape of a box? a decorated window? Looking on the Wiki it seems it's related to message boxes. We won't really know without testing it, because the name is all we know from Simon's docs).
- DisplayMainMenu (one could think this opens the proper Main Menu, but it appears to only draw it to screen - no interactivity. A better name could be DrawMainMenu).
- GetGetkeyToMainFunctionReturnFlag (this one could have a much shorter name, like GetMainMenuAvailability or GetMainMenuFlag).
- Bdisp_EnableColor (it turns out that when this function is not called, color is still enabled, it's just not full color! Why not call it Bdisp_FullColor or Bdisp_DisableIndexed, etc.)
2. Many of the names have strange or inconsistent suffixes and prefixes.
While the idea of adding prefixes to names to make it more clear what category they belong in (poor man's version of namespaces) isn't bad in itself, the way it's implemented leaves much to be desired.
Some prefixes don't make much sense, often things in the same category have different ones and some lack prefixes. Some examples:
- Bdisp AllClr VRAM (not that bad; it appears most display functions use Bdisp, and the suffix VRAM to indicate they operate in the VRAM...)
- Bdisp ShapeToVRAM16C (OK, it's a display function, operates in the VRAM... what is the 16C? 16 colors, maybe...)
- Bdisp HeaderText (is it in VRAM? DD? how many colors?)
- PrintXY (VRAM? DD? why doesn't it have Bdisp in front?...)
One could think that Bdisp is only for lower-level functions and not for text drawing, so here's one for you: Bdisp_WriteSystemMessage.
Also note the random "OS" designation:
- Bfile_GetFileSize_OS, but Bfile_DeleteEntry has no OS
- Print_OS and PrintXY (does that mean PrintXY is not implemented by the OS, since it has no OS suffix?...)
- GlibGetOSVersionInfo (what exactly is this Glib I don't see anywhere else?)
- Bkey GetAllFlags (hmm, a keyboard function... is it implemented by the OS?)
- GetKeyWait_OS (wait, turns out this is a keyboard function too... why doesn't it have a prefix then?)
(note that personally, I'm not a fan of the whole Bdisp / Bkey / Bfile... thing)
3. Overloaded variants of syscalls have strange names
It's not unusual to find syscalls that have multiple versions, with different number of parameters or slightly different meaning. But the names are awkward. For instance:
- ProgressBar (ok, it's a progress bar)
- ProgressBar2 (hmm, another version of the progress bar. Turns out this one allows for a custom caption, why not call it ProgressBarCaption or something instead?)
- ProgressBar0 (zero? a overloaded function of ProgressBar, oh well... but zero?)
- SaveVRAM_1 (where's SaveVRAM_2? I mean, it's good to account for yet-to-be-found syscalls, but so far none have appeared and it's been, like, three years...)
4. Naming conventions are not consistent
The way functions are named doesn't seem to adhere to any common standard, and doesn't appear to be consistent within libfxcg either. Some examples that clearly show why my friend called libfxcg "The International Festival of Naming Conventions":
- App_InitDlgDescriptor
- APP_FINANCE
- App_LINK_Send_ST9_Packet
- APP_SYSTEM_LANGUAGE
- App_Optimize
- APP_EACT_StatusIcon
- SMEM_MapIconToExt
My proposal is to just rename everything using a single set of rules (to be discussed), and to make things easy, not caring about backwards compatibility (it's not like people couldn't always check out an old version of libfxcg to be able to build old code trees, and in fact they'd need to do it anyway, because there are always things changing), and make sure that syscalls added from then on follow that set of rules.
The way things are now, it's a nightmare for new developers to understand anything, and it's very hard even for seasoned Prizm programmers to know the name of a certain syscall off the top of their head (was that in all caps? with underscores maybe? perhaps it doesn't start with Bdisp?...).
Discuss.