Functions for working with the idealized calendar of Planet Xhilr
Revisión | 6ec616a8a188099b49d272686d925d7be6c18549 (tree) |
---|---|
Tiempo | 2017-06-13 18:04:11 |
Autor | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
more on cycle counting for synthetic division
@@ -85,8 +85,8 @@ | ||
85 | 85 | ( : UM/MOD M/MOD DROP ; ( uddividend udivisor --- uremainder uquotient ) |
86 | 86 | |
87 | 87 | : S>D S->D ; ( n --- d : Modern name for single-to-double. ) |
88 | -: NEGATE MINUS ; ( n --- -n : Modern name for single-to-double. ) | |
89 | -: DNEGATE DMINUS ; ( d --- -d : Modern name for single-to-double. ) | |
88 | +: NEGATE MINUS ; ( n --- -n : Modern name for numeric negation. ) | |
89 | +: DNEGATE DMINUS ; ( d --- -d : Modern name for double number negation. ) | |
90 | 90 | |
91 | 91 | : 2DUP OVER OVER ; ( d --- d d : DUPlicate top double cell on stack. ) |
92 | 92 |
@@ -325,9 +325,6 @@ SP@ SP@ - ABS CONSTANT CELLWIDTH | ||
325 | 325 | ( THEN ) |
326 | 326 | ( ; ) |
327 | 327 | |
328 | -( : UMQ* ( uqdividend uddivisor --- udremainder uqquotient ) | |
329 | -( 0. 2SWAP ) | |
330 | - | |
331 | 328 | ( Make things easier to read. ) |
332 | 329 | ( Infix will be confusing here, too. ) |
333 | 330 |
@@ -675,15 +672,15 @@ RD2LCYCLE 16 * CONSTANT NUCYCLE ( numerator: 7760 ) | ||
675 | 672 | ( Fake DCONSTANT: ) |
676 | 673 | : SMPERIOD10976 [ SMPERIODINT DECYCLE UM* SMPERIODFRAC10976 0 D+ SWAP ] LITERAL LITERAL ; |
677 | 674 | ( 28 9645 / 10976 == 316973 / 10976 ) |
678 | -( | |
679 | 675 | |
680 | 676 | |
681 | 677 | 0 CONSTANT SMOFFINT ( Slow moon offset at year 0 day 0, integer part. ) |
682 | 678 | 0 CONSTANT SMOFFFRAC10976 ( Fractional part. ) |
683 | 679 | |
684 | -0 VARIABLE SMSTATEINT ( Slow moon state integer part. ) | |
685 | -0 SMSTATEINT ! ( Initialize cleared. Modern Forths leave a zero. ) | |
686 | -0 VARIABLE SMSTATEFRAC10976 ( Fractional part. ) | |
680 | +0 VARIABLE SMSTATEINT ( Slow moon state integer part. Modern Forths leave a zero. ) | |
681 | +0 SMSTATEINT ! 0 , ( Initialize cleared, make double variable. ) | |
682 | +0 VARIABLE SMSTATEFRAC10976 ( Fractional part. Modern Forths leave a zero. ) | |
683 | +0 SMSTATEFRAC10976 ! 0 , ( Initialize cleared, make double variable. ) | |
687 | 684 | |
688 | 685 | |
689 | 686 | ( The smaller moon orbits their world in just under seven and one eighth days, ) |
@@ -697,36 +694,42 @@ RD2LCYCLE 16 * CONSTANT NUCYCLE ( numerator: 7760 ) | ||
697 | 694 | 0 CONSTANT FMOFFINT ( Fast moon offset at year 0 day 0, integer part. ) |
698 | 695 | 0 CONSTANT FMOFFFRAC10976 ( Fractional part. ) |
699 | 696 | |
700 | -0 VARIABLE FMSTATEINT ( Fast moon state integer part. ) | |
701 | -0 FMSTATEINT ! ( Initialize cleared. Modern Forths leave a zero. ) | |
702 | -0 VARIABLE FMSTATEFRAC10976 ( Fractional part. ) | |
697 | +0 VARIABLE FMSTATEINT ( Fast moon state integer part. Modern Forths leave a zero. ) | |
698 | +0 FMSTATEINT ! 0 , ( Initialize cleared, make double variable. ) | |
699 | +0 VARIABLE FMSTATEFRAC10976 ( Fractional part. Modern Forths leave a zero. ) | |
700 | +0 FMSTATEFRAC10976 ! 0 , ( Initialize cleared, make double variable. ) | |
703 | 701 | |
704 | 702 | |
705 | -: WSTYCYCLES ( year --- ddays ) ( Start the weekday counter for the year, keep the days. ) | |
703 | +: WSTYCYCLES ( year --- ) ( Start the weekday counter for the year, keep the days. ) | |
706 | 704 | DTY 2DUP DAYCOUNT D! |
707 | - 2DUP WKDAYOFFSET 0 D- DPWK JM/MOD 2DROP DOWKSTATE ! | |
705 | + WKDAYOFFSET 0 D- DPWK JM/MOD 2DROP DOWKSTATE ! | |
708 | 706 | ; |
709 | 707 | |
710 | 708 | : SSTYCYCLES ( ddays --- ) ( Start the slowmoon cycle counter for the year. ) |
711 | - SMOFFINT SMSTATEINT ! | |
712 | - SMOFFFRAC10976 SMSTATEFRAC10976 ! | |
713 | - | |
714 | - 2DUP DECYCLE UDS* | |
715 | - | |
709 | + DECYCLE UDS* DROP SMPERIOD10976 DROP JM/MOD >R >R S>D R> R> ( 32-bit, 64-bit ) | |
710 | +( DECYCLE S>D UMD* SMPERIOD10976 UD/MOD ( 16-bit ) | |
711 | + 2SWAP SMOFFFRAC10976 S>D D+ | |
712 | + 2DUP SMPERIOD10976 D< 0= IF | |
713 | + SMPERIOD10976 D- 2SWAP 1. D+ 2SWAP | |
714 | + THEN | |
715 | + SMSTATEFRAC10976 D! | |
716 | + SMOFFINT S>D D+ SMSTATEINT D! | |
716 | 717 | ; |
717 | 718 | |
718 | -: FSTYCYCLES ( year --- ) ( Start the fastmoon cycle counter for the year. ) | |
719 | - FMOFFINT 0 FMSTATEINT ! | |
720 | - FMOFFFRAC10976 FMSTATEFRAC10976 ! | |
721 | - | |
722 | - 2DUP DECYCLE UDS* ( Have to dived by period, period is double. ) | |
723 | - | |
719 | +: FSTYCYCLES ( ddays --- ) ( Start the fastmoon cycle counter for the year. ) | |
720 | + DECYCLE UDS* DROP FMPERIOD10976 DROP JM/MOD >R >R S>D R> R> ( 32-bit, 64-bit ) | |
721 | +( DECYCLE S>D UMD* FMPERIOD10976 UD/MOD ( 16-bit ) | |
722 | + 2SWAP FMOFFFRAC10976 S>D D+ | |
723 | + 2DUP FMPERIOD10976 D< 0= IF | |
724 | + FMPERIOD10976 D- 2SWAP 1. D+ 2SWAP | |
725 | + THEN | |
726 | + FMSTATEFRAC10976 D! | |
727 | + FMOFFINT S>D D+ FMSTATEINT D! | |
724 | 728 | ; |
725 | 729 | |
726 | 730 | : STYCYCLES ( year --- ) ( Start the counters for the year. ) |
727 | - DUP WSTYCYCLES | |
728 | - DUP SSTYCYCLES | |
729 | - DUP FSTYCYCLES | |
731 | + WSTYCYCLES | |
732 | + DAYCOUNT D@ 2DUP SSTYCYCLES FSTYCYCLES | |
730 | 733 | ; |
731 | 734 | |
732 | 735 | : STMCYCLES ( year month --- ) ( The year is started, start the month. ) |