home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff239.lzh
/
JGoodies
/
Mandelbrot
/
mandelevmenus.jf
< prev
next >
Wrap
Text File
|
1989-08-21
|
12KB
|
397 lines
\ Copyright 1989 NerveWare
\ No portion of this code may used for commercial purposes,
\ nor may any executable version of this code be disributed for
\ commercial purposes without the author's express written permission.
\ This code is shareware, all rights reserved.
\ Nick Didkovsky Oct. 6, 1988
\ MandelEvMenus.JF
\ This file sets the menu events.
\ MOD: added custom screen. ND 12/16/88
\ MOD: added ezmenus for restart, color cycle, and quit. ND 12/17/88
\ MOD: added region selection/calculation/gr.highlight ND 12/18/88
\ MOD: added FastWritePixel, 3drop, skip Mandelbrot point plot ND 12/18/88
\ MOD: added support for IFF Mandelbrot image, restores on restart. ND 12/20/88
\ MOD: Changed scaling from 10000 to 16384. Superduper speed! ND 12/20/88
\ MOD: Changed MandelMax from 35 to 100 ND 12/21/88
\ MOD: Added "Title?" choice to menu, hides titlebar ND 12/21/88
\ MOD: Full borderless drawing screen ND 12/21/88
\ MOD: Title hides automatically on new region, shows on restart ND 12/22/88
\ MOD: New IFF image ... full screen, no title bar! ND 12/22/88
\ MOD: Max iterations changed from 100 to 254 ND 12/21/88
\ Speed note: full startup image takes 6:02 min to generate point by point
\ MOD: put gr.highlight in "PlotOne" so it flashes once when black. ND 1/26/89
\ MOD: using PICTURE structures now, from JForth v.omega1 ND 2/4/89
\ MOD: forget it. Using pure bitmaps again, and they work great. ND 2/5/89
\ MOD: include variable resolution screens now ND 2/8/89
\ MOD: calc.new.values uses screen resolutions ND 2/9/89
\ MOD: moved MandelMax out of here and into MandelShift2.ASM,
\ MandelMax is now 350 ND 2/11/89
\ MOD: free mandelbrot-menu in cleanup ND 2/14/89
\ MOD: added Mandelbrot-Menu-2 for various screen resolutions ND 2/16/89
\ MOD: reorganized menus for coherence ND 2/17/89
\ MOD: added 3rd menu to change color cycle speed ND 2/18/89
\ MOD: Adjusted menu widths with menuitem-defwidth. ND 3/24/89
\ MOD: using ILBM_WRITE.ND2 to save IFF, uses small buffer ND 3/28/89
\ MOD: added wait.for.click 6/11/89
\ MOD: removed gr.move from handle.mandelbrot.event 6/11/89
decimal
getmodule includes
include? gr.init ju:amiga_graph
include? ev.getclass ju:amiga_events
include? ezmenu ju:amiga_menus
include? quick.guts MandelShift2.ASM ( uses 16384 scaling, not 10000!!!)
include? open.mandelscreen VariScreen.JF
include? load.bm.to.screen MandelBitMap.JF
include? FastWritePixel FastWritePixel.JF
include? make.next.filename $filenext.JF
include? $screen>iff.ND ILBM_WRITE.ND2
include? wait.pointer MandelMouse.JF
anew task_Mandel_menus_events
decimal
ezmenu Mandelbrot-Menu-1
ezmenu Mandelbrot-Menu-2
ezmenu Mandelbrot-Menu-3
variable cycle?
variable quit?
variable restart?
variable new-values? ( true when mousedown events block off new region)
variable only-a-single-click? ( protect against accidental new region)
variable image-loaded?
variable show-title?
variable new-screen?
image-loaded? off
USER IF-DOWN ( Keep track of whether mouse button is down. )
variable top-x
variable top-y
variable bot-x
variable bot-y
variable real-lower-right
variable imag-lower-right
\ Infinitesimally faster than drop 2drop. ND
ASM 3drop
addq.l #$8,dsp
move.l (dsp)+,tos
end-code
\ Reset the region to cover entire mandelset
\ note: integer values scaled by 16384
\ ... represent -2.125, 1.1972, 0.0101, and 0.0120
: INIT.MANDELBROT ( -- )
-34816 acorner ! ( -2.125)
19615 bcorner ! ( 1.1972)
165 xgap ! ( 0.0101 )
197 ygap ! ( 0.0120 )
." re-initialized values, Mandelbrot restarting" cr
;
: INFORM.THE.CUSTOMER ( -- )
cr
." ********************** USER SELECTED NEW REGION *************************"
cr cr
." VALUES RESCALED TO LOOK NICE ( 1.0000 = 10000)" cr
." acorner =" space acorner @ 10000 16384 */ . space
." bcorner =" space bcorner @ 10000 16384 */ . cr
." xgap =" space xgap @ 10000 16384 */ 1 max . space ." ten-thousandths" cr
." ygap =" space ygap @ 10000 16384 */ 1 max . space ." ten-thousandths" cr cr
." *************************************************************************"
cr
;
: SAVE.OLD.VALUES ( -- )
acorner @ xgap @ mandel-width @ * + real-lower-right !
bcorner @ ygap @ mandel-height @ * - imag-lower-right !
;
: CALC.NEW.VALUES ( -- )
top-x @ bot-x @ 2sort bot-x ! top-x !
top-y @ bot-y @ 2sort bot-y ! top-y !
top-x @ xgap @ * acorner @ + acorner !
bcorner @ top-y @ ygap @ * - bcorner !
bot-x @ xgap @ * top-x @ xgap @ * - mandel-width @ / 1 max xgap !
bot-y @ ygap @ * top-y @ ygap @ * - mandel-height @ / 1 max ygap !
inform.the.customer
;
: RECALCULATE.VALUES ( -- )
real-lower-right @ acorner @ - mandel-width @ / 1 max xgap !
bcorner @ imag-lower-right @ - mandel-height @ / 1 max ygap !
;
\ *************************** PROJECT MENU-1 **********************************
defer ..toggle.title
: QUIT.MANDEL
Quit? on
;
: SAVE.IFF ( -- )
wait.pointer
Show-title? @ if ..toggle.title then ( make sure no title bar showing)
." SAVING SCREEN TO" space ( your workbench screen back )
make.next.filename ." ..." flushemit
new mscreen-ptr @ curr-filename @ $screen>iff.nd
." ... saved!" cr
crosshairs.pointer
;
: CLEANUP
restore.color.table
close.mandelscreen
free.mandelbitmap
Mandelbrot-Menu-1 ezmenu.free
Mandelbrot-Menu-2 ezmenu.free
Mandelbrot-Menu-3 ezmenu.free
cr ." closed screen, freed bitmap and menus ... bye bye" cr
;
: RESTART.MANDEL
init.mandelbrot
restart? on
;
: STARTING.IMAGE
gr.clear
show-title? @ IF ..toggle.title THEN ( hide title)
restore.mandel
..toggle.title ( show title)
;
: Mandelbrot-Menu-1.INIT
150 menuitem-defwidth !
3 Mandelbrot-Menu-1 ezmenu.alloc
0" project" 0 Mandelbrot-Menu-1 ezmenu.setup
\ define text
0" Restart" 0 Mandelbrot-Menu-1 ezmenu.text!
0" Save IFF" 1 Mandelbrot-Menu-1 ezmenu.text!
0" Quit" 2 Mandelbrot-Menu-1 ezmenu.text!
\ load stack with cfa's
' quit.mandel ' save.IFF ' restart.mandel
3 0 do i Mandelbrot-Menu-1 ezmenu.cfa[] ! loop ( unload stack)
ascii R 0 Mandelbrot-Menu-1 ezmenu.commseq!
ascii S 1 Mandelbrot-Menu-1 ezmenu.commseq!
ascii Q 2 Mandelbrot-Menu-1 ezmenu.commseq!
quit? off
cycle? off
restart? on
new-values? off
only-a-single-click? off
show-title? on
;
\ ******************************** SCREEN MENU 2 ******************************
: TOGGLE.TITLE
Show-title? @ not Show-title? !
Mscreen-ptr @ Show-title? @ Showtitle()
;
' toggle.title IS ..toggle.title
: CHOOSE.640x400 ( -- )
." User selected 640x400 interlace, 16 colors" cr
save.old.values
set.640x400
recalculate.values
new-screen? on
;
: CHOOSE.320x200 ( -- )
." User selected 320x200, 32 colors" cr
save.old.values
set.320x200
recalculate.values
new-screen? on
;
: CHOOSE.320x400 ( -- )
." User selected 320x400 interlace, 32 colors" cr
save.old.values
set.320x400
recalculate.values
new-screen? on
;
: MANDELBROT-MENU-2.INIT
4 Mandelbrot-Menu-2 ezmenu.alloc
0" screen" 1 Mandelbrot-Menu-2 ezmenu.setup
\ define text
0" 320x200" 0 Mandelbrot-Menu-2 ezmenu.text!
0" 320x400" 1 Mandelbrot-Menu-2 ezmenu.text!
0" 640x400" 2 Mandelbrot-Menu-2 ezmenu.text!
0" Title Bar?" 3 Mandelbrot-Menu-2 ezmenu.text!
\ load stack with cfa's
' toggle.title ' choose.640x400 ' choose.320x400 ' choose.320x200
4 0 do i Mandelbrot-Menu-2 ezmenu.cfa[] ! loop ( unload stack)
$ 06 0 Mandelbrot-Menu-2 ezmenu.exclude!
$ 05 1 Mandelbrot-Menu-2 ezmenu.exclude!
$ 03 2 Mandelbrot-Menu-2 ezmenu.exclude!
ascii L 0 Mandelbrot-Menu-2 ezmenu.commseq!
ascii M 1 Mandelbrot-Menu-2 ezmenu.commseq!
ascii H 2 Mandelbrot-Menu-2 ezmenu.commseq!
ascii T 3 Mandelbrot-Menu-2 ezmenu.commseq!
CHECKED 0 Mandelbrot-Menu-2 ezmenu.set.flag
;
\ **************************** CYCLE MENU 3 *******************************
: TOGGLE.CYCLE.FLAG ( -- )
Cycle? @ not cycle? !
cycle? @ not if restore.color.table then
;
: CYCLE.FAST ( -- )
0 cycle-speed !
;
: CYCLE.MEDIUM ( -- )
25 cycle-speed !
;
: CYCLE.SLOW ( -- )
50 cycle-speed !
;
: MANDELBROT-MENU-3.INIT
90 menuitem-defwidth !
4 Mandelbrot-Menu-3 ezmenu.alloc
0" cycle" 2 Mandelbrot-Menu-3 ezmenu.setup
\ define text
0" cycle" 0 Mandelbrot-Menu-3 ezmenu.text!
0" slow" 1 Mandelbrot-Menu-3 ezmenu.text!
0" med" 2 Mandelbrot-Menu-3 ezmenu.text!
0" fast" 3 Mandelbrot-Menu-3 ezmenu.text!
\ load stack with cfa's
' cycle.fast ' cycle.medium ' cycle.slow ' toggle.cycle.flag
4 0 do i Mandelbrot-Menu-3 ezmenu.cfa[] ! loop ( unload stack)
$ 01 0 Mandelbrot-Menu-3 ezmenu.exclude!
$ 0C 1 Mandelbrot-Menu-3 ezmenu.exclude!
$ 0A 2 Mandelbrot-Menu-3 ezmenu.exclude!
$ 06 3 Mandelbrot-Menu-3 ezmenu.exclude!
ascii C 0 Mandelbrot-Menu-3 ezmenu.commseq!
CHECKED 3 Mandelbrot-Menu-3 ezmenu.set.flag
0 cycle-speed ! ( default to fast)
;
\ ****************************** init **************************************
: INIT.LINK.MENUS ( -- )
Mandelbrot-Menu-1.init
Mandelbrot-Menu-2.init
Mandelbrot-Menu-3.init
Mandelbrot-Menu-1 Mandelbrot-Menu-2 menu.linkto
Mandelbrot-Menu-2 Mandelbrot-Menu-3 menu.linkto
;
\ ******************************** EVENTS **********************************
: HANDLE.MANDELBROT.EVENT ( ev -- )
CASE
MOUSEBUTTONS OF ( check for up or down )
ev-last-code @ SELECTDOWN =
IF if-down on
only-a-single-click? on
ev.getxy00
11 + ( adjust y, no title bar anymore)
swap 4 + swap ( adjust x too)
\ 2dup gr.move ( DON'T WANT THIS!)
2dup top-y ! top-x ! bot-y ! bot-x !
top-x @ top-y @ bot-x @ bot-y @ gr.highlight
ELSE if-down off ( released button!)
only-a-single-click? @
NOT IF new-values? on
ELSE top-x @ top-y @ bot-x @ bot-y @ gr.dehighlight
new-values? off ( redundant but safe)
THEN
THEN
ENDOF
MOUSEMOVE OF if-down @
IF
only-a-single-click? off
top-x @ bot-x @ 2sort
top-y @ bot-y @ 2sort
>r swap r> gr.dehighlight
ev.getxy00
11 + bot-y ! ( offsets for mouse position)
4 + bot-x !
top-x @ bot-x @ 2sort
top-y @ bot-y @ 2sort
>r swap r> gr.highlight
THEN
ENDOF
MENUPICK
OF ev-last-code @ Mandelbrot-Menu-1 ezmenu.exec
ENDOF
CLOSEWINDOW ( take this out, or get the closebox happening!)
OF Quit? on
ENDOF
ENDCASE
;
\ When one screen is generated, keep checking for menu events!
: MANDELBROT.EV.LOOP
BEGIN
cycle? @ if Cycle.Colors.Once then
gr-curwindow @ ev.getclass ?dup
IF handle.mandelbrot.event
THEN
new-values? @ quit? @ OR restart? @ OR new-screen? @ OR
UNTIL
;
\ hang until mouse button clicked
: WAIT.FOR.CLICK ( -- )
BEGIN
gr-curwindow @ ev.getclass ?dup
IF
MOUSEBUTTONS =
IF ev-last-code @ SELECTDOWN =
ELSE false
THEN
ELSE false
THEN
UNTIL
;
: TEST.CLICK ( -- )
open.mandelscreen
wait.for.click
." got the first one" cr
wait.for.click
." got the second one" cr
close.mandelscreen
;