Skip to content

Commit

Permalink
Adding latest APIs documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Feb 23, 2024
1 parent 69818be commit df959fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Lua/file-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The `:open` method has some magic built-in. The size argument is optional, and i

The resulting File object will cache a single full sector in memory, meaning that small sequential reads won't read the same sector over and over from the disk.

The resulting File object will be writable, which will temporarily patch the CD-Rom image file in memory. It is possible to flush the patches to a PPF file by calling the `:savePPF()` method of the corresponding Iso object. When writing to one of these files, the filesystem metadata information will not be updated, meaning that the size of the file on the filesystem will not change, despite it being possible to write past the end of it and overflow on the next sectors. Note that while the virtual File object will enlarge to accommodate the writes, it will not be filled with zeroes as with typical filesystem operations, but instead will be filled with the existing data from the iso image.
The resulting File object will be writable, which will temporarily patch the CD-Rom image file in memory. It is possible to flush the patches to a PPF file by calling the `:savePPF()` method of the corresponding Iso object. When writing to one of these files, the filesystem metadata information will not be updated, meaning that the size of the file on the filesystem will not change, despite it being possible to write past the end of it and overflow on the next sectors. Note that while the virtual File object will enlarge to accommodate the writes, it will not be filled with zeroes as with typical filesystem operations, but instead will be filled with the existing data from the iso image. When applicable, sync headers, location, MODE2 subheaders will be added, and ECC and EDC will be recalculated on the fly, and the resulting data will be written to the virtual file, except for files opened in `'RAW'` mode. The `'M1'` mode cannot be written to, and will throw an error if attempted.

The ISOReader object has the following methods:

Expand Down
11 changes: 11 additions & 0 deletions docs/Lua/redux-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,14 @@ This allows distributing complex "mods" as zip files, which can be loaded and ex
## Miscellaneous

- `PCSX.quit([code])` schedules the emulator to quit. It's not instantaneous, and will only quit after the current block of Lua code has finished executing, which will be before the next main loop iteration. The `code` parameter is optional, and will be the exit code of the emulator. If not specified, it'll default to 0.

- `PCSX.Adpcm.NewEncoder` will return an Adpcm encoder object. The object has the following methods:
- `:reset([mode])` will reset the encoder, and set the mode to the given mode. The mode can be `'Normal'`, `'XA'`, `'High'`, `'Low'`, `'FourBits'`. The default mode is `'Normal'`, which enables all the filters available in the SPU. The `'XA'` mode limits the encoder to the filters available in the XA ADPCM format. The `'High'` mode uses the high-pass filter, and the `'Low'` mode uses the low-pass filter. The `'FourBits'` mode forces plain 4-bit Adpcm encoding.
- `:processBlock(inData, [outData], [channels])` will encode the given ffi input buffer, and write the result to the given ffi output buffer. The input buffer should be a buffer of 16-bit signed integers, and the output buffer should be a buffer of 16-bit signed integers. The channels parameter is optional, and will default to 2. The input buffer should contain exactly 28 samples, and so does the output buffer. If the output buffer is not given, the function will return a new buffer with the result. LuaBuffers are also accepted as input and output buffers. The function will return three values: the output buffer, the filter index used, and the shifting used. The function is intended to be used as an intermediate computation step, and the output still needs to be processed into 4 bits or 8 bits samples.
- `:processSPUBlock(inData, [outData], [blockAttribute])` will encode the given ffi input buffer, and write the result to the given ffi output buffer. The input buffer should be a buffer of 16-bit signed integers, and the output buffer should be a buffer which is at least 16 bytes large. The blockAttribute parameter is optional, and will default to `'OneShot'`. The input buffer should contain exactly 28 samples. If the output buffer is not given, the function will return a new buffer with the result. LuaBuffers are also accepted as input and output buffers. The function will return the encoded block, suitable for SPU usage. The `blockAttribute` parameter can be one of the following strings: `'OneShot'`, `'OneShotEnd'`, `'LoopStart'`, `'LoopBody'`, `'LoopEnd'`.
- `:finishSPU([outData])` will write the opinionated end of sample looping block, as prescribed by the original Sony API. The output buffer should be a buffer which is at least 16 bytes large. If the output buffer is not given, the function will return a new buffer with the result. LuaBuffers are also accepted as output buffers. The function will return the encoded block, suitable for SPU usage.
- `:processXABlock(inData, [outData], [xaMode], [channels])` will encode the given ffi input buffer, and write the result to the given ffi output buffer. The input buffer should be a buffer of 16-bit signed integers, and the output buffer should be a buffer which is at least 128 bytes large. Note that a MODE2 FORM2 XA sector requires subheaders and 18 of these blocks. The xaMode parameter is optional, and will default to `'XAFourBits'`. The other valid value is `'XAEightBits'`. It will defines the encoding output between either 4-bit and 8-bit. The channels parameter is optional, and will default to 1. If the output buffer is not given, the function will return a new buffer with the result. LuaBuffers are also accepted as input and output buffers. The function will return the encoded block, suitable for XA usage. The amount of required input samples varies depending of the number of channels and the encoding mode:
- 4-bit mono: 224 samples aka 448 bytes
- 4-bit stereo: 112 samples aka 448 bytes
- 8-bit mono: 112 samples aka 224 bytes
- 8-bit stereo: 56 samples aka 224 bytes
9 changes: 9 additions & 0 deletions docs/Lua/rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ Some extra functions are bound to Lua beyond the API listed above:
`imgui::InputTextWithHint` C++ function. The function will return a boolean
indicating if the text has changed or not, and the new text.

- `imgui.extra.logText(text)` will call the `imgui::LogText` C++ function,
which will add the given text to current log buffer.

- `PCSX.GUI.useMainFont()` will call the `imgui::PushFont` C++ function with
the proportional font. It will need to be followed by a call to `imgui.PopFont()`.

- `PCSX.GUI.useMonoFont()` will call the `imgui::PushFont` C++ function with
the monospace font. It will need to be followed by a call to `imgui.PopFont()`.

### Safety

The ImGui API will frequently assert and crash the process if the API calls
Expand Down

0 comments on commit df959fa

Please sign in to comment.