feat(rtc): implement sceRtcGetDosTime and sceRtcSetDosTime #803

Merged
adriadam10 merged 2 commits from upstream-pr/803 into main 2026-10-07 16:07:21 +00:00
adriadam10 commented 2026-10-06 05:23:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T05:23:10Z.


What

Adds sceRtcGetDosTime and sceRtcSetDosTime to libSceRtc. Neither was declared on main.

  • The bit layout comes from shadPS4 (rtc.cpp), the only reference with a body. It is the standard FAT date/time: seconds/2, minutes, hours, day, month, and years since 1980, in bits 0-4, 5-10, 11-15, 16-20, 21-24 and 25-31.
  • GetDosTime: a null output, or a date that fails sceRtcCheckValid, returns the same errors as the other Get* converters. One difference from shadPS4: it ORs the fields into *dosTime without clearing it first, so the result depends on the old value. Here the output is assigned.
  • SetDosTime: a null pointer returns INVALID_POINTER. As in shadPS4, the fields are not validated, microsecond is set to 0 and seconds are doubled.
  • Cases that throw, because no reference says what the library returns for them:
    • GetDosTime for years outside 1980-2107. shadPS4 masks them, so they wrap around.
    • SetDosTime with a year field above 63. shadPS4 reads the date half as int16_t, so 2044 and later become years before 1980.
  • Both are listed under "Unknown function info" in TechnicalDebt.

Tested

Linux, guest test (guest_rtc). The expected values were computed by a separate Python model of the FAT layout, not taken from this code. Cases covered:

  • 2024-02-29 12:34:57.789, with an odd second and microseconds that get dropped
  • the bounds 1980-01-01 and 2107-12-31 23:59:59
  • the round trip back, including year field 63 and the all-zero value (month and day 0 are not validated)
  • null pointers, an invalid month, and both throwing cases

Negative checks: 12 mutations, 11 caught. The one left (masking the year field with 0x3f) changes nothing once fields above 63 throw. On main the test fails to link, because the functions don't exist. Full Release build (GCC) passes, as does ctest -R guest_.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4754515841 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-06T05:23:10Z. --- ### What Adds `sceRtcGetDosTime` and `sceRtcSetDosTime` to libSceRtc. Neither was declared on `main`. - The bit layout comes from shadPS4 (`rtc.cpp`), the only reference with a body. It is the standard FAT date/time: seconds/2, minutes, hours, day, month, and years since 1980, in bits 0-4, 5-10, 11-15, 16-20, 21-24 and 25-31. - `GetDosTime`: a null output, or a date that fails `sceRtcCheckValid`, returns the same errors as the other `Get*` converters. One difference from shadPS4: it ORs the fields into `*dosTime` without clearing it first, so the result depends on the old value. Here the output is assigned. - `SetDosTime`: a null pointer returns `INVALID_POINTER`. As in shadPS4, the fields are not validated, `microsecond` is set to 0 and seconds are doubled. - Cases that throw, because no reference says what the library returns for them: - `GetDosTime` for years outside 1980-2107. shadPS4 masks them, so they wrap around. - `SetDosTime` with a year field above 63. shadPS4 reads the date half as `int16_t`, so 2044 and later become years before 1980. - Both are listed under "Unknown function info" in TechnicalDebt. ### Tested Linux, guest test (`guest_rtc`). The expected values were computed by a separate Python model of the FAT layout, not taken from this code. Cases covered: - 2024-02-29 12:34:57.789, with an odd second and microseconds that get dropped - the bounds 1980-01-01 and 2107-12-31 23:59:59 - the round trip back, including year field 63 and the all-zero value (month and day 0 are not validated) - null pointers, an invalid month, and both throwing cases Negative checks: 12 mutations, 11 caught. The one left (masking the year field with `0x3f`) changes nothing once fields above 63 throw. On `main` the test fails to link, because the functions don't exist. Full Release build (GCC) passes, as does `ctest -R guest_`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-06 05:23:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T05:23:30Z.


Progress report (def8119 → 0781225)

📉 System libraries: 85.99% (-0.02%, +1 implemented, +1 declared functions)

✅ 1 implemented
Library Name
libSceRtc sceRtcSetDosTime
🆕 1 declared as stubs
Library Name
libSceRtc sceRtcGetDosTime
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6009939626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803#issuecomment-6009939626). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-06T05:23:30Z. --- <!-- progress-report --> ### Progress report (def8119 → 0781225) 📉 **System libraries**: 85.99% (-0.02%, +1 implemented, +1 declared functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceRtc | `sceRtcSetDosTime` | </details> <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libSceRtc | `sceRtcGetDosTime` | </details>
oneandonlydean commented 2026-10-06 09:27:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T09:27:47Z.


The encoding checks out. I recomputed 0x585d645c and 0xff9fbf7d by hand, and the null and validation order matches the other Get* converters.

There's one fix:

  • The TechnicalDebt line ended up under "Silent stubs" (line 23 of the file at this head), not "Unknown function info" as the description says. These functions aren't silent stubs, so it belongs in the later section.

And one optional point:

  • SetDosTime throws for year fields 64-127. FAT defines the year as an unsigned 7-bit field (1980-2107), and GetDosTime here produces those values for 2044-2107. So a title that round-trips a date after 2043 would hit the throw. shadPS4's int16_t could just be a decompiler type. I'd decode the field as unsigned unless there's a reason to think the library sign-extends it. Throwing is within the rules, though, so this is your call.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6013353629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803#issuecomment-6013353629). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T09:27:47Z. --- The encoding checks out. I recomputed `0x585d645c` and `0xff9fbf7d` by hand, and the null and validation order matches the other `Get*` converters. There's one fix: - The TechnicalDebt line ended up under "Silent stubs" (line 23 of the file at this head), not "Unknown function info" as the description says. These functions aren't silent stubs, so it belongs in the later section. And one optional point: - `SetDosTime` throws for year fields 64-127. FAT defines the year as an unsigned 7-bit field (1980-2107), and `GetDosTime` here produces those values for 2044-2107. So a title that round-trips a date after 2043 would hit the throw. shadPS4's `int16_t` could just be a decompiler type. I'd decode the field as unsigned unless there's a reason to think the library sign-extends it. Throwing is within the rules, though, so this is your call.
adriadam10 commented 2026-10-06 09:52:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T09:52:04Z.


Rebased on main and fixed:

  • The TechnicalDebt line is now under "Unknown function info".
  • SetDosTime decodes the year as the unsigned 7-bit FAT field (1980-2107), so every value GetDosTime produces round-trips. The test pins 0xff9fbf7d → 2107-12-31 and 0x80210000 → 2044-01-01, and the TechnicalDebt line notes that shadPS4 sign-extends.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6013737517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803#issuecomment-6013737517). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-06T09:52:04Z. --- Rebased on main and fixed: - The TechnicalDebt line is now under "Unknown function info". - `SetDosTime` decodes the year as the unsigned 7-bit FAT field (1980-2107), so every value `GetDosTime` produces round-trips. The test pins `0xff9fbf7d` → 2107-12-31 and `0x80210000` → 2044-01-01, and the TechnicalDebt line notes that shadPS4 sign-extends.
oneandonlydean commented 2026-10-06 21:24:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T21:24:13Z.


Thanks, this is ready to merge, but it now conflicts with main in docs/dev/TechnicalDebt.md after the last batch landed. Could you rebase onto main? I'll merge once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6025725717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803#issuecomment-6025725717). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T21:24:13Z. --- Thanks, this is ready to merge, but it now conflicts with main in `docs/dev/TechnicalDebt.md` after the last batch landed. Could you rebase onto main? I'll merge once CI is green.
adriadam10 commented 2026-10-07 15:55:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T15:55:49Z.


Rebased onto main (f71bf7fd4). The only conflict was in docs/dev/TechnicalDebt.md. The line stays under "Unknown function info", now in the middle of the section rather than at its end. Build and full ctest pass, including guest_rtc.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6041615611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/803#issuecomment-6041615611). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T15:55:49Z. --- Rebased onto main (f71bf7fd4). The only conflict was in `docs/dev/TechnicalDebt.md`. The line stays under "Unknown function info", now in the middle of the section rather than at its end. Build and full ctest pass, including `guest_rtc`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!803
No description provided.