Functions for working with the idealized calendar of Planet Xhilr
Revisão | cadfda1113be8e550b5feee4253a90589c6ff7f4 (tree) |
---|---|
Hora | 2017-06-13 18:16:48 |
Autor | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
Fixing errors, a little code cleanup
@@ -343,12 +343,12 @@ CELLBITS CELLWIDTH /MOD CONSTANT BYTEBITS CONSTANT LEFTOVERBITS | ||
343 | 343 | ( Just best to do in assembler, along with UD* and UQD/MOD . ) |
344 | 344 | |
345 | 345 | ( Do it in assembler instead! Hundreds of times as slow!!!! ) |
346 | -: DIV2/ ( u1 --- u2 : Halve the top cell. REALLY SLOW! ) | |
346 | +: DIV-2/ ( u1 --- u2 : Halve the top cell. REALLY SLOW! ) | |
347 | 347 | S>D 2 UM/MOD SWAP DROP ; |
348 | 348 | |
349 | 349 | ( Do it in assembler instead! Hundreds of times as slow!!!! ) |
350 | -: DIVD2/ ( ud1 --- ud2 : Halve the top double cell. REALLY SLOW! ) | |
351 | - 2 UM/MOD ROT DROP ; | |
350 | +: DIV-D2/ ( ud1 --- ud2 : Halve the top double cell. REALLY SLOW! ) | |
351 | + 2 JM/MOD ROT DROP ; | |
352 | 352 | |
353 | 353 | ( Scaling, to keep the steps time-bounded, ) |
354 | 354 | ( is going to leave me at the binary long division ) |
@@ -755,7 +755,7 @@ CELLWIDTH NEGATE ALLOT ( Back up to store values. ) | ||
755 | 755 | |
756 | 756 | |
757 | 757 | ( Modern Forths will leave the initialization 0 behind. ) |
758 | -0 CONSTANT WKDAYOFFSET ( Weekday corresponding to day zero of year zero. ) | |
758 | +6 CONSTANT WKDAYOFFSET ( Weekday corresponding to day zero of year zero. ) | |
759 | 759 | 0 VARIABLE 1STDAYOFWEEK ( Weekday corresponding to first day of week. ) |
760 | 760 | 0 1STDAYOFWEEK ! |
761 | 761 |
@@ -783,9 +783,6 @@ RD2LCYCLE 16 * CONSTANT NUCYCLE ( numerator: 7760 ) | ||
783 | 783 | : SMPERIOD10976 [ SMPERIODINT DECYCLE UM* SMPERIODFRAC10976 0 D+ SWAP ] LITERAL LITERAL ; |
784 | 784 | ( 28 9645 / 10976 == 316973 / 10976 ) |
785 | 785 | |
786 | -0 CONSTANT SMOFFINT ( Slow moon offset at year 0 day 0, integer part. ) | |
787 | -0 CONSTANT SMOFFFRAC10976 ( Fractional part. ) | |
788 | - | |
789 | 786 | ( Modern Forths will leave the initialization 0 behind. ) |
790 | 787 | 0 VARIABLE SMSTATEINT ( Slow moon state integer part. ) |
791 | 788 | 0 SMSTATEINT ! 0 , ( Initialize cleared, make double variable. ) |
@@ -796,6 +793,27 @@ RD2LCYCLE 16 * CONSTANT NUCYCLE ( numerator: 7760 ) | ||
796 | 793 | : SM16THPERIOD10976 [ SMPERIOD10976 8. D+ 16 JM/MOD ROT DROP SWAP ] LITERAL LITERAL ; |
797 | 794 | : SM32NDPERIOD10976 [ SMPERIOD10976 16. D+ 32 JM/MOD ROT DROP SWAP ] LITERAL LITERAL ; |
798 | 795 | |
796 | +( start + mt = 1/2, start + gt = 3/4 => t * { g - m } = 1/4 => t = 1 / 4 * { g - m } ) | |
797 | +( g = 1 rot/day, m = 10976 / 316973 rev/day => t = 1 / { 4 * [ 316973 - 10976 ] / 316973 } ) | |
798 | +( s + gt = 3/4 => s = 3/4 - t; s = 3/4 - 1 / { 4 * [ 316973 - 10976 ] / 316973 } ) | |
799 | +( s + mt = 1/2 => s = 1/2 - mt; s = 1/2 - 10976 / [ 4 * { 316973 - 10976 } ] ) | |
800 | +( s = [ 2 * 316973 - 3 * 10976 ] / [ 4 * { 316973 - 10976 } ] ) | |
801 | +( s = 601018 / 1223988 ) | |
802 | +: SMTARGET | |
803 | + [ 2. SMPERIOD10976 UMD* 2DROP 3 DECYCLE UM* D- | |
804 | + SMPERIOD10976 UMD* ( Scale it py period and keep high double word. ) | |
805 | + 4. SMPERIOD10976 DECYCLE 0 D- UMD* 2DROP | |
806 | + SLOW-UMD/MOD 2SWAP 2DROP SWAP | |
807 | + ] LITERAL LITERAL ; | |
808 | +( Used SMTARGET like this with SMOFFFRAC10976 set to 0.: ) | |
809 | +( 34 3 STYCYCLES 5 DMADJUST SMSTATEFRAC10976 D@ SMTARGET D- D. 76151 ) | |
810 | +0 CONSTANT SMOFFINT ( Slow moon offset at year 0 day 0, integer part. ) | |
811 | +: SMOFFFRAC10976 ( Fractional part. ) [ 76151. SWAP ] LITERAL LITERAL ; | |
812 | + | |
813 | +( Below was guessing wrong: ) | |
814 | +( [ SM32NDPERIOD10976 28 UDS* DROP ) | |
815 | +( SM32NDPERIOD10976 DIV-D2/ D+ 4 JM/MOD ROT DROP SWAP ] ) | |
816 | + | |
799 | 817 | ( Could pre-divide the period into 16ths but this is an output function, ) |
800 | 818 | ( can be a little slow. ) |
801 | 819 | : SMSHOWPHASE ( --- ) ( --- ) ( Show the Slowmoon phase with no spacing. ) |
@@ -912,7 +930,7 @@ RD2LCYCLE 16 * CONSTANT NUCYCLE ( numerator: 7760 ) | ||
912 | 930 | ( Intended to be called from STYCYCLES. Other use will leave things out of sync. ) |
913 | 931 | : SLOMSTCYCLES ( ddays --- ) |
914 | 932 | DECYCLE S>D UMD* SMPERIOD10976 SLOW-UMD/MOD |
915 | - 2SWAP SMOFFFRAC10976 S>D D+ | |
933 | + 2SWAP SMOFFFRAC10976 D+ | |
916 | 934 | 2DUP SMPERIOD10976 D< 0= IF |
917 | 935 | SMPERIOD10976 D- 2SWAP 1. D+ 2SWAP |
918 | 936 | THEN |