mm/tools/timeconv.py
kyleburnette e1219e7351
en_invadepoh OK (#200)
* Applied changes to master on new branch

* some docs

* minor change

* Slight improvement to last draw func

* Got rid of all warnings

* Removed extra text file

* Readded warnings text file

* Fixed warnings text file

* Some cleanup, added engineer's new matched functions!

* Marked non-equivalent functions as such

* Improved last draw func (still non-equivalent)

* Made most of anghelo's suggested changes

* Slightly better code for func_80B4A350, though it's not matching still

* Engineer matched 2 funcs so I'm pushing those

* Added a function from engineer and one of my own

* Fixed warning

* Slightly better code for func_80B44C80

* Slightly better code for func_80B44C80

* Matched func_80B44C80

* Pushing engineer's matched draw func. All rodata funcs matched!

* Build NOT OK - rodata. Pushing anyway because I did a lot of work and it's close

* Build NOT OK (see previous commit) - func_80B440B8 matched

* Build NOT OK (see previous commit) - func_80B43BC8 matched

* All funcs matched! Build not OK still though

* almost ok

* OK now

* Fixed some warnings

* Fixed more warnings

* More warnings work

* Fixed all warnings (I think)

* Fixed all warnings (I think)

* Moderate amount of cleanup

* More cleanup

* More cleanup and some slight documentation

* Decent amount of documentation

* More documentation

* Fixed build (forgot to replace one struct member)

* More documentation and cleanup

* Fixed merge conflict, added binang_sub macro usages, and otherwise added most of the suggested changes f

git commit

* Organized things a bit, added a few more CLOCKTIME macros

* Added extra output to timeconvert.py

* Formatting

* Made all suggested changes

* 'Downgraded' timeconv script to version without seconds

* Added a macro for part of the params usages plus an enum

* Actually fixed header file (didn't save before)

* Renamed milk get item in enum

* Fixed GI enum update

Co-authored-by: Zelllll <56516451+Zelllll@users.noreply.github.com>
Co-authored-by: Zelllll <elilee968@gmail.com>
Co-authored-by: angie <angheloalf95@gmail.com>
2021-07-17 00:04:37 -04:00

25 lines
750 B
Python
Executable File

#!/usr/bin/env python3
#
# Convert time values such as 0x1AAA to their clock time, i.e. 2,30
# The time is output with a comma for easy copy-pasting into a macro
#
import sys
time = sys.argv[1]
time = int(time, 16 if time.startswith("0x") else 10)
minutes = round(((24 * 60) / 0x10000) * time)
hours = int(minutes // 60)
minutes = round(minutes - 60 * hours)
# Since multiple values are mapped to the same clock time, check that it
# still matches once converted. If it doesn't match as it is, print a warning.
macro_val = int((hours * 60 + minutes) * (0x10000 / (24 * 60)))
print(f"{hours},{minutes:02} -> 0x{macro_val:04X}")
print(f"CLOCK_TIME({hours}, {minutes})")
if time != macro_val:
print("Warning: Result does not match as-is")