WonderWitch/FreyaBIOS/Timer

From WSdev Wiki
Revision as of 11:19, 19 October 2024 by Asie (talk | contribs) (Created page with "The Timer interrupt provides an abstraction layer for the WonderSwan's timers, as well as the on-cartridge RTC. == Types == === RTC fields === The RTC field indexes match the order of fields returned by the RTC chip. Note that FreyaBIOS transparently converts the values to and from BCD. {| class="wikitable" |- ! Index !! Data !! Format |- | 0 || Year || 0 - 99; 0 is assumed to be the year 2000. |- | 1 || Month || 1 - 12 |- | 2 || Date...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The Timer interrupt provides an abstraction layer for the WonderSwan's timers, as well as the on-cartridge RTC.

Types

RTC fields

The RTC field indexes match the order of fields returned by the RTC chip.

Note that FreyaBIOS transparently converts the values to and from BCD.

Index Data Format
0 Year 0 - 99; 0 is assumed to be the year 2000.
1 Month 1 - 12
2 Date (day of month) 1 - 31
3 Day of week 0 - 6; 0 = Sunday, 1 = Monday, ..., 6 = Saturday
4 Hour 0 - 23
5 Minute 0 - 59
6 Second 0 - 59

RTC struct

The RTC struct is a seven-byte memory structure, containing all RTC fields consecutively, taking up one unsinged byte each.

Interrupts

INT $16/AH=$00 - rtc_reset

  • AH = $00

INT $16/AH=$01 - rtc_set_datetime

  • AH = $01
  • BX = Field
  • CX = Value of field

INT $16/AH=$02 - rtc_get_datetime

  • AH = $02
  • BX = Field

Return:

  • AX = Value of field

INT $16/AH=$03 - rtc_set_datetime_struct

  • AH = $03
  • DS:DX = Pointer to RTC struct

INT $16/AH=$04 - rtc_get_datetime_struct

  • AH = $04
  • DS:DX = Pointer to RTC struct

INT $16/AH=$05 - rtc_enable_alarm

  • AH = $05
  • BL = Hour
  • BH = Minute

INT $16/AH=$06 - rtc_disable_alarm

  • AH = $06

INT $16/AH=$07 - timer_enable

  • AH = $07
  • AL = Type (0 = HBlank, 1 = VBlank)
  • BL = Reload mode (0 = one-shot, 1 = repeating)
  • CX = Time, in lines or frames, to wait.

INT $16/AH=$08 - timer_disable

  • AH = $08
  • AL = Type (0 = HBlank, 1 = VBlank)

INT $16/AH=$09 - timer_get_count

  • AH = $09
  • AL = Type (0 = HBlank, 1 = VBlank)

Return:

  • AX = The current counter value, from the time set in timer_enable down.