\* Before loading the other files that define the display routines, we define the global variables that these routines may need to refer to. *\ 0 constant logmag \ log of pixel magnification (can be negative) : cell-zoom (s -- zoom.factor ) 1 logmag 0 max 31 min << ; : cell-shrink (s -- shrink.factor ) 1 logmag negate 0 max 31 min << ; \* Now we define the display state information that controls whether or not to spread the pixels, use a display function, or render 3D systems, and some buffers used for saving state before display. *\ variable sp-flag variable fn-flag variable regenerate-display? 0 constant rendering-type 1 constant render-single 2 constant render-double 512 constant video-max-width 512 constant video-max-height 64 K create-buffer display-table 64 K create-buffer display-save-table 64 K create-buffer display-save-table' \* We will spread the pixels if the "spread-flag" is set, and if we're zoomed in far enough for the pixel to be spread. We will use the display function to show the pixels if the "function-flag" is set, and if the pixels are not being spread. We will show a rendered image if the "rendering-type" is non-zero, and if the scene is 3 dimensional. *\ : showing-spread? (s -- flag ) sp-flag @ cell-zoom 4 >= and ; : showing-rendered? (s -- flag ) #dim @ 3 = rendering-type 0<> and ; : showing-function? (s -- flag ) fn-flag @ showing-rendered? not and ; : UVsubsector (s U V -- ) #dim @ rot by dup 2 < abort" Space displayed must be at least 2 dimensional!" 1 ?do i limit 1- <> if by 1 else subsector then loop ; 0 create-buffer save-show-area 0 create-buffer source-buf : display-width (s -- n ) X cell-zoom cell-shrink */ max-width min ; : display-height (s -- n ) Y cell-zoom cell-shrink */ max-height min ; : source-width (s -- n ) display-width cell-shrink cell-zoom */ ; : source-height (s -- n ) display-height cell-shrink cell-zoom */ ; : read-source source-width source-height * ['] source-buf change-reglen site-src site scan-index kick source-width V source-height min UVsubsector #dim @ 0 ?do 0 loop select-subsector source-height V / 1 max 0 ?do select i module scan-io source-buf i limit part read loop ; : transfer-to-one-module select all source-width by source-height sector source-width source-height * ['] save-show-area change-reglen site-src site display site select 0 module scan-io save-show-area read site-src host scan-io source-buf ; : undo-transfer source-width by source-height sector site-src host select 0 module scan-io save-show-area ; : all-in-1? (s -- flag ) source-height Y #modules/y / <= ; : ?read-source all-in-1? not if read-source then ; : ?transfer-to-one-module all-in-1? not if transfer-to-one-module then ; : ?undo-transfer all-in-1? not if undo-transfer then ; load step-sprd.fth : ts (s logmag -- ) U log 1- min is logmag save-defaults save-sector-dims save-user-regs display site generate-spread select all display 0 map! restore-user-regs restore-sector-dims restore-defaults *step* ; : update-cmap ?send-smap ?palette>display ; : regen regenerate-display? on ; : show-spread sp-flag @ 0= if sp-flag on update-cmap regen then ; : show-unspread sp-flag @ 0<> if sp-flag off update-cmap regen then ; \* Initialization. "new-experiment" could reset flags and display parameters to a standard state, but no "display-step" can be generated until "space" has been executed, setting the dimensions of the space. We will have "new-experiment" call "init-display" to set the deferred word "show" to be a noop. "space" can then redefine "show", once the size of the space has been set. *\ : init-display regenerate-display? on sp-flag off fn-flag off centering-hd off spread-mask on 0 is rendering-type 0 is logmag reset-xmon zero-display-offset fill-display-hi \ optimized fill-display-lo \ optimized ['] noop ['] display-table table! ['] cboard-smap is smap ; permanent new-experiment init-display 512 by 512 space : cm cell >gray ; colormap cm random>cam xvds show-spread