84PCSE:BCALLs:5509

From WikiTI
Jump to: navigation, search

Synopsis

Unofficial Name: GetBatteryLevel

BCALL Address: 5509h

Measures the current battery level by writing and reading several ports and using lots of delay loops.

Inputs

None.

Outputs

  • A = 0 if the battery is fully dead. Do a hard power off fast or you risk damaging the lithium battery.
  • A = 4 if the battery is fully charged, or at least about 70 or 80 percent charged.
  • A = 1-3 for intermediate charge levels.

Destroys

  • AF, BC

Comments

There isn't any particular code in here to test whether the battery is currently charging as far as I can tell. Contains a delay loop that overwrites 9F02h. Screws with IY+16h. Uses ports 3A and 04.