2009-11-21 Robert Millan <rmh.grub@aybabtu.com>

* maintainance/gentrigtables.py: Avoid duplicate hardcoding of
        integer constants.
This commit is contained in:
Robert Millan 2009-11-21 20:59:48 +00:00
parent 87efa251d5
commit f5b23252e2
2 changed files with 14 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2009-11-21 Robert Millan <rmh.grub@aybabtu.com>
* maintainance/gentrigtables.py: Avoid duplicate hardcoding of
integer constants.
2009-11-14 Colin D Bennet <colin@gibibit.com> 2009-11-14 Colin D Bennet <colin@gibibit.com>
Trigonometry support. Trigonometry support.

View file

@ -2,7 +2,7 @@
# Script to generate trigonometric function tables. # Script to generate trigonometric function tables.
# #
# GRUB -- GRand Unified Bootloader # GRUB -- GRand Unified Bootloader
# Copyright (C) 2008 Free Software Foundation, Inc. # Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# #
# GRUB is free software: you can redistribute it and/or modify # GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -41,14 +41,16 @@ def writeTable(arr, name):
def main(): def main():
sintab = [] sintab = []
costab = [] costab = []
for i in range(256): angle_max = 256
fraction_scale = 16384
for i in range(angle_max):
# Convert to an angle in 1/256 of a circle. # Convert to an angle in 1/256 of a circle.
x = i * 2 * pi / 256 x = i * 2 * pi / angle_max
sintab.append(int(round(sin(x) * 16384))) sintab.append(int(round(sin(x) * fraction_scale)))
costab.append(int(round(cos(x) * 16384))) costab.append(int(round(cos(x) * fraction_scale)))
write("#define TRIG_ANGLE_MAX 256\n") write("#define TRIG_ANGLE_MAX " + str (angle_max) + "\n")
write("#define TRIG_FRACTION_SCALE 16384\n") write("#define TRIG_FRACTION_SCALE " + str (fraction_scale) + "\n")
writeTable(sintab, "sintab") writeTable(sintab, "sintab")
writeTable(costab, "costab") writeTable(costab, "costab")