summaryrefslogtreecommitdiff
path: root/src/devices
Commit message (Collapse)AuthorAge
* Update phosphor dependency to v3.2.1Ben Bridle2024-12-16
| | | | | This includes a fix to prevent the cursor from being marked as inactive while at least one mouse button is still being held.
* Update metadata and parser to match current specificationBen Bridle2024-12-16
| | | | | | | The metadata specification has changed to use '/' as the separator between the program name and program version in the name string, and each author line is now no longer followed by the year in which the author last contributed to the program.
* Fix file device cached child issueBen Bridle2024-11-24
| | | | | | | | | | When opening the previously-visited directory in the file device, the directory data is read from a cache, preventing the need to have it regenerated from scratch. The directory data includes the selected child, which meant that instead of child 0 being selected as per the specification, the previously-selected child was selected instead. To fix this, the child is deselected as the directory data is cached.
* Increase default page limit in memory deviceBen Bridle2024-11-20
| | | | | This was erroneously set to 0 from before the memory device was implemented.
* Cache transformed sprite dataBen Bridle2024-11-20
| | | | | | | | In programs where the same sprite is drawn many times repeatedly, a lot of time is saved by caching the transformed sprite data instead of having to recalculate it for every draw operation. No testing has been done on the efficiency improvements this offers, but it doesn't seem like it could have any downsides.
* Fix file device cached write issueBen Bridle2024-11-13
| | | | | Writing a value to the pointer and length ports wasn't working, because the cached write was never getting committed.
* Fix line drawing issueBen Bridle2024-11-13
| | | | | | | | | | | An overflow error was causing the line drawing method to loop forever any time a line of length 0x4000 (16384) or longer was drawn. The issue was occurring because both e1 and dx (or dy) would have a value of at least 0x4000, and so on lines 291/292 the sum would exceed 0x8000, the maximum value of an i16. The value would then wrap and break the assumptions of the line drawing algorithm, causing it to loop forever. This was fixed by increasing the size of the affected types.
* Fix issue when drawing textured shapes off-screenBen Bridle2024-11-04
| | | | | | | | | | | | When determining whether or not to draw each pixel of a textured line or rectangle, the modulo-by-eight operation was being performed on a signed value, which was returning a negative value when the pixel being drawn was off-screen. When the negative value was then converted to an unsigned value, the result was close to usize::MAX, and was causing an out-of-bounds array access. To fix this, the value is converted to an unsigned value before taking the modulo.
* Suppress errors when flushing file and stream dataBen Bridle2024-10-31
| | | | | | | | File and stream data is flushed on drop, and if flushing fails a panic is thrown, which prints a crash message to the terminal. Since we can't do anything if the write fails, and because file and stream writes are approached with a best-effort attitude, we suppress the errors to prevent the user from seeing them and getting concerned.
* Don't clear input stream queue when starting transmissionBen Bridle2024-10-31
| | | | | | Writing to the input transmission port of the standard input stream no longer clears the input queue. The only way to clear an input queue is to write to the associated queue port.
* Fix issue with clock device returning UTC time instead of local timeBen Bridle2024-10-31
| | | | | | | | | | | | | | | | The project previously used the `time` crate for getting the current time in the local timezone. It was discovered that the time crate would fail to return the local time when the program used multiple threads, because of concerns that the other threads could modify timezone-related environment variables while the timezone was being read from the system and create a soundness issue. A second program thread was introduced recently by commit 1a830a3 to provide non-blocking reads of standard input for the local stream device, and so the time returned by the clock device was falling back to UTC. To fix this, the `time` crate has been replaced by the `chrono` crate which does not suffer from this restriction, and in any case seems to be the more popular of the two anyway.
* Rename --encode-stdin option to --decode-stdinBen Bridle2024-10-29
| | | | This more accurately reflects its function.
* Rewrite emulatorv1.0.0-alpha1Ben Bridle2024-10-28
| | | | | | | | | | | | | | | This is a complete rewrite and restructure of the entire emulator project, as part of the effort in locking down the Bedrock specification and in creating much better tooling for creating and using Bedrock programs. This commit adds a command-line argument scheme, an embedded assembler, a headless emulator for use in non-graphical environments, deferred window creation for programs that do not access the screen device, and new versions of phosphor and bedrock-core. The new version of phosphor supports multi-window programs, which will make it possible to implement program forking in the system device later on, and the new version of bedrock-core implements the final core specification.
* Fix mapping of draw operations in screen deviceBen Bridle2024-09-10
| | | | | The mapping of draw codes to draw operations didn't match the screen device specification. This error was introduced in commit 6b3796c.
* Improve performance of hierarchical file navigationBen Bridle2024-08-13
| | | | | | | | The most recently closed directory listing is cached instead of being discarded. The next time a directory is to be opened, if the file path is the same as the cached directory, the cached directory listing is used in order to save the entire listing from having to be regenerated. This is expected to result in performance gains on Windows.
* Prevent unused variable warning on LinuxBen Bridle2024-08-11
| | | | | The base variable is only used when compiling on Windows, so an unused variable warning is raised when compiling on Linux.
* Fix panic in ReadOnlyTextBufferBen Bridle2024-08-10
| | | | | | | | | Previously when reading from a ReadOnlyTextBuffer the pointer would fall off the end and crash the emulator. This commit also makes the ReadOnlyTextBuffer Unicode-compatible, rather than the previous behaviour of clamping every character into the ASCII range.
* Fix ascend-to-parent behaviour of file deviceBen Bridle2024-08-10
| | | | | | | We were finding the parent of the relative path and then passing this to the BedrockFilePath::from_path constructor, but this constructor expects to be passed an absolute path and so was unconditionally returning None.
* Refactor the file deviceBen Bridle2024-08-07
| | | | | | | | This is the Windows side of the refactoring job. The windows crate has been added as a dependency in order to get a list of available drives by drive letter, and a virtual top-level root directory has been implemented in the Windows code to make it possible for programs to hierarchically navigate between available drives.
* Refactor the file deviceBen Bridle2024-08-06
| | | | | | | | | | | | | | | | The major feature of this refactor is the creation of BedrockFilePath, a type which can be losslessly converted into an operating-system specific path or a Bedrock-style byte path. It also prevents file paths which can't be represented as Bedrock-style byte paths from being constructed, and allows the use of a base directory which acts as an inescapable sandbox. BedrockFilePath will support the creation of a virtual root directory on Windows which will allow navigation between drive letters via the standard hierarchical navigation ports. This commit has been tested on Linux, but not yet Windows. Further work is expected before the new code will work on Windows.
* Set error flag when file device cannot ascend to parent directoryBen Bridle2024-08-04
| | | | This should have been happening previously, but was missed.
* Fix compilation on LinuxBen Bridle2024-08-04
| | | | | Some Windows-only library functions were added in during a previous commit while I was developing on Windows.
* Update file device to compile on WindowsBen Bridle2024-07-30
| | | | | | | | Construction of OsStrings is handled differently between Windows and Unix, using platform-specific APIs. The method OsStr::as_bytes was also changed to OsStr::as_encoded_bytes at some point between Rust versions 1.69 and 1.80.
* Fix crash when loading a directory containing weird entriesBen Bridle2024-06-30
| | | | | | | It was previously assumed that every entry in a directory would be either a file or a directory, but a non-file and non-directory entry has been encountered in the wild. In this case, just ignore the file, leaving it out of the directory listing.
* Set file operation success flag when ascending and descendingBen Bridle2024-06-30
| | | | | This is to allow the program to detect whether the previous ascend or descend operation succeeded.
* Improve error messageBen Bridle2024-06-09
|
* Hide all dot-prefixed files from directory listingsBen Bridle2024-06-09
| | | | | | This is a temporary fix to make directories more navigable. This will be removed when Cobalt can hide dot-prefixed filenames from directory listings by itself.
* Update file device for releaseBen Bridle2024-06-09
| | | | | | | | | | | | | | Removed the sandbox directory of the file device, so the file device is now sandboxed to the root directory. The sandboxing code has been left intact for future use. Permission flags have been added to the file device to allow each category of file operation to be enabled or disabled in the emulator. The default directory is set to be the current working directory from when the emulator boots. This is the directory which is used when the program attempts to ascend to the parent directory when no entry is currently open.
* Simplify scroll value access codeBen Bridle2024-06-01
|
* Sort directory children in case-agnostic alphabetic orderBen Bridle2024-05-30
|
* Simplify file device debug messagesBen Bridle2024-04-24
|
* Flush file contents each frame and when closing the fileBen Bridle2024-04-24
|
* Remove unused constantsBen Bridle2024-04-22
|
* Fix memory deviceBen Bridle2024-04-22
| | | | | | | | | | | There was confusion between the role of the page_limit variable in the memory device, where it was being used to mean both the absolute upper limit of pages that are allowed to be allocated, but also to mean the number of pages that the program would like to be allocated when needed. To fix this, the program is now just told the full number of pages that it is allowed to use, without first requiring that the program request a particular number of pages.
* Fix memory, input, screen, and file devicesBen Bridle2024-04-16
| | | | | | | The memory device was never being allocated any memory, the input device wasn't scrolling correctly, the screen device was rendering sprites incorrectly, and the device ID of the file device had not been changed over from 0xA to 0x9.
* Update devices to match new specificationsBen Bridle2024-04-16
|
* Implement new file device interfaceBen Bridle2024-01-31
| | | | | This is a complete redesign of the file device. The most notable addition is the ability to ascend and descend the file tree.
* Prevent overflow errors on stream device pointersBen Bridle2024-01-31
| | | | | The stream device pointers now use wrapping semantics in order to prevent overflow errors.
* Change stream device to use buffered streamsBen Bridle2024-01-31
| | | | | | | | Wrapping stdin and stdout with BufReader and BufWriter makes reads and writes more efficient by bundling multiple characters into a single read or write operation. In practice, this hasn't made a difference to running the numbers demo, but that demo spends the majority of processor time converting values to decimal strings.
* Refactor code without changing functionalityBen Bridle2024-01-31
| | | | | An effort to make the code shorter and more readable. This mostly affects the code for the clock device.
* Change clock cumulative timer to use 256th ticks instead of secondsBen Bridle2024-01-31
| | | | | | The "Cumulative seconds" port of the CLOCK device has been changed to be called "Cumulative timer", with the units changing from seconds to 1/256 second ticks.
* Make orthogonal line drawing operations work with signed coordinatesBen Bridle2024-01-06
| | | | | | | | | | | | | | | | | | The vector line drawing operation of the screen device uses optimised methods when drawing horizontal and vertical lines. The emulator now interprets the coordinates of these lines as signed values, to allow for the correct rendering of orthogonal lines where the coordinates of the left or top edges are off-screen. Diagonal lines are yet to be tackled. The bounding-box calculations shared by the rectangle and orthogonal line drawing methods have also been split off into their own method, significantly reducing the code duplication between all four of the methods which require this functionality. This commit also makes aesthetic changes to the code in the draw_diagonal_line method to improve readability and brevity, as a part of the changes made to the draw_line method when the points parameter was removed from each of the three lower line-drawing methods.
* Reduce width of ScreenDevice::draw_sprite methodBen Bridle2024-01-06
| | | | | This method was exceeding the 80-character line limit, which was interfering with the centering behaviour of my text editor.
* Move ScreenDevice::fill_layer methodBen Bridle2024-01-06
| | | | | The method was between the two draw_sprite methods, but it fits better just after draw_pixel.
* Make rectangle drawing operations work with signed valuesBen Bridle2024-01-05
| | | | | | | The vector+size draw operations of the screen device draw textured and untextured rectangles. The emulator now interprets the coordinates of a rectangle as signed values, to allow for the correct rendering of rectangles where the coordinates of the left or top edges are off-screen.
* Update screen device code to reflect specification changesBen Bridle2024-01-05
| | | | | | | The vector+size+sprite draw operation of the screen device has been changed in the specification from drawing a 1-bit textured triangle to drawing a 1-bit textured line. This draw operation had not yet been implemented, so this commit does not affect emulator functionality.
* Fix multiplication error in math deviceBen Bridle2023-12-28
| | | | | | The order of the two result values from the widening multiply operation in Rust was reversed, leading to incorrect multiplication results when using the math device.
* First commitv0.1.0Ben Bridle2023-12-24