\ Spiral Demo by Don Colburn \ Amigaization by David Butler 3-27-86 \ Permission to use granted when authorship is provided \ This example demonstrates custom screens, graphics, \ and primitive event handling anew DemoMarker \ define a custom screen with 4 bit planes struct NewScreen spiscreen \ make a name in dictionary, access Symbol table spiscreen InitScreen \ copy default values to new screen 4 spiscreen +nsDepth w! ( # bit planes ) CUSTOMSCREEN spiscreen +nsType w! structend \ define window for spirals struct NewWindow spiwindow \ make a name in dictionary, access Symbol table spiwindow InitWindow \ copy default value to new window 20 spiwindow +nwLeftEdge w! 20 spiwindow +nwTopEdge w! 620 spiwindow +nwWidth w! 180 spiwindow +nwHeight w! WINDOWSIZING WINDOWDRAG | Smart_Refresh | WINDOWCLOSE | ACTIVATE | GIMMEZEROZERO | spiwindow +nwFlags ! \ gimme00 protects borders... fCLOSEWINDOW NEWSIZE | MOUSEBUTTONS | spiwindow +nwIDCMPFlags ! CUSTOMSCREEN spiwindow +nwType w! \ intend to open on a custom screen structend : CleanupSpiral ( -- ) \ do when fCLOSEWINDOW detected CurrentWindow @ CloseWindow CurrentScreen @ CloseScreen ginit ; : goodbye ( -- ) \ bye if executing turnkey, abort if not ?turnkey if bye else abort then ; : SpiralEvents ( -- ) \ process IDCMP events GetEvent case fCLOSEWINDOW of CleanUpSpiral goodbye endof endcase ; : chords ( angle -- ) \ draw cords at angle for 36000 degrees max.x 2/ max.y 2/ rot over 3 * \ scale factor locals| size angle | xyoffset 0 0 MoveTo 32001 angle 32 * do i max.y w/ dup 2/ xyscale \ expand i xyangle i size w/ dup DrawTo \ to next point) rport i 1+ SetAPen angle +loop pause ; \ only pause once per cycle for fast demo... : center ( -- ) \ move to center max.x 2/ max.y 2/ MoveTo ; : spiral ( -- ) \ generate geometric spirals clr.window 270 90 do clr.window center i chords SpiralEvents loop ginit ; : dospiral ( -- ) \ this becomes the turnkey token 0" Spirals " spiscreen +nsDefaultTitle ! \ give window a title spiscreen OpenScreen verifyscreen \ open the screen CurrentScreen @ spiwindow +nwScreen ! \ store screen ptr in window spiwindow OpenWindow verifywindow \ open the window ginit \ must initialize csigraphics begin spiral again ; \ do it "forever" cr ." Enter dospiral" \ run the example