home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / E / Demos / IntMandel.e next >
Encoding:
Text File  |  1997-01-29  |  1.5 KB  |  64 lines

  1. -> This is a Mandel generator from the Amiga E archive (which was converted
  2. -> from Oberon) and is now converted to work with GMS.
  3.  
  4. MODULE 'games','games/games'
  5.  
  6. CONST ITERDEPTH=50 ->This constant defines the detail of the mandel.
  7.  
  8. /*=========================================================================*/
  9.  
  10. PROC main()
  11.  
  12. DEF screen:PTR TO gamescreen,zr,zi,ar,ai,dr,di,sr,si,st,x,y,i
  13.  
  14.  IF gmsbase := OpenLibrary('games.library',0)
  15.   SetUserPrefs('Mandel Generator v1.0')
  16.   IF (screen := AddScreen([TAGS,0,
  17.      GSA_SCRWIDTH,640,
  18.      GSA_SCRHEIGHT,512,
  19.      GSA_AMTCOLOURS,16,
  20.      GSA_SCRMODE,HIRES OR COL12BIT OR LACED,
  21.      TAGEND]))
  22.  
  23.    x:=256/screen.amtcolours*2
  24.    FOR i:=0 TO screen.amtcolours-1 DO UpdateRGB12(screen,i,(Shr(i*x,4) OR (i*x)))
  25.  
  26.    sr := $400000/screen.scrwidth  -> shrink horiz
  27.    si := $300000/screen.scrheight -> shrink vert
  28.    st := $140000*-2               -> move side
  29.    zi := $160000                  -> move up
  30.  
  31.    ShowScreen(screen)
  32.  
  33.    FOR y:=screen.scrheight-1 TO 0 STEP -1
  34.     IF (ReadMouse(JPORT1) AND MB_LMB) THEN JUMP end
  35.     zi := zi-si
  36.     zr := st
  37.     FOR x:=0 TO screen.scrwidth-1
  38.       i := 0
  39.       ar := zr
  40.       ai := zi
  41.       REPEAT
  42.         dr := Shr(ar,10)
  43.         di := Shr(ai,10)
  44.         ai := dr*2*di+zi
  45.         dr := dr*dr
  46.         di := di*di
  47.         ar := dr-di+zr
  48.         i++
  49.       UNTIL (i>ITERDEPTH) OR (dr+di>$400000)
  50.       DrawPixel(screen,BUFFER1,x,y,Mod(i,screen.amtcolours))
  51.       zr:=zr+sr
  52.     ENDFOR
  53.    AutoSwitch()
  54.    ENDFOR
  55.    WaitLMB()
  56.  
  57. end:
  58.   DeleteScreen(screen)        
  59.   ENDIF
  60.  CloseLibrary(gmsbase)
  61.  ENDIF
  62. ENDPROC
  63.  
  64.