Somebody has pointed out elsewhere that it's very slow in
BBC BASIC for Windows. This is because plotting individual pixels using the VDU-stream-based graphics is inefficient: for example it involves sending 6 bytes to the VDU stream for each pixel, which then have to be decoded (the same was true on the
BBC Micro, incidentally).
If you want it to run in BB4W at a speed comparable with how it runs in BBCSDL you must abandon the native graphics and instead write directly to an in-memory bitmap:
Code: Select all
10 VDU 23,22,640;640;8,8,16,128
20 DIM BMP{bfType{l&,h&}, bfSize%, bfReserved%, bfOffBits%, \
30 \ biSize%, biWidth%, biHeight%, biPlanes{l&,h&}, biBitCount{l&,h&}, \
40 \ biCompression%, biSizeImage%, biXPelsPerMeter%, biYPelsPerMeter%, \
50 \ biClrUsed%, biClrImportant%, palette%(255), p&(639, 639)}
60
70 BMP.bfType.l& = ASC"B"
80 BMP.bfType.h& = ASC"M"
90 BMP.bfSize% = DIM(BMP{})
100 BMP.bfOffBits% = ^BMP.p&(0,0) - BMP{}
110 BMP.biSize% = 40
120 BMP.biWidth% = 640
130 BMP.biHeight% = 640
140 BMP.biPlanes.l& = 1
150 BMP.biBitCount.l& = 8
160 BMP.palette%(0) = &FFFFFFFF
170 BMP.palette%(1) = &FFC00000
180
190 FOR t = -8 TO +8 STEP 0.0001
200 x = SIN(9.52 * t) + 1
210 y = COS(9.52 * t) ^ 4 * SIN(SIN(4.8 * t))
220 BMP.p&(320+160*x,320+160*y) = 1 : BMP.p&(320-160*x,320-160*y) = 1
230 BMP.p&(320+160*y,320+160*x) = 1 : BMP.p&(320-160*y,320-160*x) = 1
240 NEXT
250 *HEX 64
260 OSCLI "MDISPLAY " + STR$~BMP{}
This could no doubt be optimised further .