Shop OBEX P1 Docs P2 Docs Learn Events
P2 Graphic Demo a la C64 — Parallax Forums

P2 Graphic Demo a la C64

ReinhardReinhard Posts: 489
edited 2020-06-08 08:56 in Propeller 2
I use a cinch cable from the AV accessory board (socket B ) to the monitor to transmit a composite video signal.
The Mandelbrot set is calculated once and placed in a local buffer. It is relatively slow.
Then it can quickly switch between 2 pictures.

Comments

  • Ok it will be a few days time, but really looking forward to running this!
  • another demo:
    a periodic structure is created, loaded into the video buffer and displayed for approx. 10 seconds.
    Then in a loop the video buffer aes128 encrypted , waited for 1 sec and decrypted again.
    fastspin -2b frame.c aes128.cpp
    Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
    Version 4.2.0 Compiled on: Jun  5 2020
    frame.c
    |-NTSC_Frame.spin2
    aes128.cpp
    memcpy.c
    sleep.c
    frame.p2asm
    Done.
    Program size is 11472 bytes
    
    
  • Inspired and guided by ersmith's excellent mandelbrot.c demo, I also ventured to a vga object. My favorite unit is the Cordic unit, so I combined the two to visually show the strength of the Cordic unit and the fastspin tool.
    //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    // main program
    //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    int main()
    {
        int phi,i,x,y,c;
         
        Setup_Video();
    
        _setbaud(_BAUD);
    
    	clearscreen();
    	
    	// plot a white cross to screen
    	line(0,SCRN_HEIGHT/2,SCRN_WIDTH,SCRN_HEIGHT/2,0b111_11111);
    	line(SCRN_WIDTH/2,0,SCRN_WIDTH/2,SCRN_HEIGHT, 0b111_11111);
    	
    	// use CORDIC to plot vectors around a circle
    	// and the components x=cos,y=sin
    	phi = 0;	
    	for(int n = 0; n < N; n++)
    	{			
    		toCartesian(&x, &y, 100, phi);
    		plot(n + SCRN_WIDTH/2 - 32, SCRN_HEIGHT/4 - 50 - y/2,0b100_11111);
    		plot(n + SCRN_WIDTH/2 + 150, SCRN_HEIGHT/2 - x/2,0b110_11111);
    		line(SCRN_WIDTH/2,SCRN_HEIGHT/2,
    			 SCRN_WIDTH/2 + x, SCRN_HEIGHT/2 + y,0b010_11111);
    		phi += dphi;		
    	}  
    
    }
    
    1024 x 683 - 366K
    c
    c
    3K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-07-01 12:14
    How long is it taking to draw?
    When I first did a Mandelbrot in Forth this time last year it took quite a few seconds to do a full 640x480 screen, especially with far more zoom. Then when I wrote the inline assembler I was able to code a few routines and that made it a lot faster.

    After I took these screen shots I decided to write a screenshot routine that would save it as a bmp on the card.
    1472 x 1306 - 211K
    747 x 913 - 83K
  • ReinhardReinhard Posts: 489
    edited 2020-07-01 12:53
    @"Peter Jakacki"
    in the demo from @ersmith are working up to 6 cogs for render the mandelbrot set.
    This is very fast.
    You find it in the newest FLEXGUI - zipfile.

    https://github.com/totalspectrum/flexgui/releases/download/v4.2.3/flexgui.zip
  • I was using the same cog as TAQOZ but I was wondering how long the demo took to render (without loading it up myself).
  • hmm, tachyon means faster than the speed of light.
    Sorry, but this joke must have been. :-)

    Do we speak about the demo flexgui/samples/Multi-Language/mandelbrot.c ?
    Do you have all 6 cogs running?
    This can be set at runtime via the terminal connection.
    The demo default is only one cog.


    Probably Forth is faster, but I have no comparison and skills in order to it.
    Best Regards, Reinhard
  • Here's the most recent mandelbrot I have (with a few bug fixes and optimizations). It takes about 4 seconds to render the initial 640x480 screen with 1 cog, 0.67 seconds with 6 cogs. That's using only 32 iterations to test for mandelbrot set membership, which is low (but matches the number of distinct intensity levels in RGBI8). Increasing it to 128 iterations slows it down to about 12 seconds.

    I suspect you could get fairly similar numbers with FORTH or any language really, if you use assembly language for the inner loop. The time is heavily dominated by the multiplication. Reducing the accuracy (using only 16 bit multiplies instead of 32 bit multiplies) would give about a 3x speedup as well.
Sign In or Register to comment.