BBC BASIC for Windows
« "Munching squares" »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:09pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: "Munching squares"  (Read 311 times)
David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx "Munching squares"
« Thread started on: Nov 2nd, 2016, 12:14am »

Code:
      REM Munching squares (slow version)

      W% = 512
      VDU 23,22,W%;W%;8,16,16,0 : OFF

      FOR X% = 0 TO W%-1
        FOR Y% = 0 TO W%-1
          B% = (X% EOR Y%) AND 255
          COLOUR 7, B%, B%>>1, 255-B%
          PLOT 2*X%, 2*Y%
        NEXT
      NEXT

      REPEAT UNTIL INKEY(1)=0
      END
 



Code:
      REM Munching squares (fast version)

      SetPixel% = FNSYS_NameToAddress("SetPixel")
      H% = @memhdc%

      W% = 512
      VDU 23,22,W%;W%;8,16,16,0 : OFF

      FOR X% = 0 TO W%-1
        FOR Y% = 0 TO W%-1
          B% = (X% EOR Y%) AND 255
          C% = &10000*(255-B%) OR &100*(B%>>1) OR B%
          SYS SetPixel%, H%, X%, W%-Y%-1, C%
        NEXT
      NEXT

      SYS "InvalidateRect", @hwnd%, 0, 0

      REPEAT UNTIL INKEY(1)=0
      END

      DEFFNSYS_NameToAddress(f$):LOCALP%:DIMP%LOCAL5:[OPT 0:call f$:]:=P%!-4+P%
 



Based on the Liberty BASIC program listed at Rosetta Code:

http://rosettacode.org/wiki/Munching_squares


David.
--
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: "Munching squares"
« Reply #1 on: Nov 2nd, 2016, 02:43am »

Big speed difference.
User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls