$MLC F 100 10 3000
300 INPUT "How many runs : ":N
310 CALL LINK("TEST",N)
320 END
$TEST
    GETPARAM 1 N                ; how many rectangles said the user
    XREGENABLE                  ; access enabled to extended registers
    STARTDATA
        byte &hE3               ; BML def bloc, first byte is flags with palette 3
        byte &h40               ; then address (here 64*64 = 4096)
        bytes 96,64,64,64       ; then x,y,w,h
    ENDDATA E
    BMLSET 0 E                  ; set my BML without display
    BMLPLOT 0 0 0               ; upper corner
    BMLFILLRECT 64 64           ; clear all
    BMLSET 1 E                  ; and display the BML
    LET C 3                     ; color
    NDO I N
        LET Z 63
        FOR X 0 63
            BMLPLOT X 0 C
            BMLDRAWTO Z 63 C
            DEC Z
        NEXT
        LET Z 62
        FOR Y 1 62
            BMLPLOT 63 Y C
            BMLDRAWTO 0 Z C
            DEC Z
        NEXT
        DEC C                   ; previous color
        AND C 3                 ; limited to 0-3
    NLOOP
    PUTTABLE E(0) &h63          ; else, change flags to "BML disabled"
    BMLSET 1 E                  ; and set new parameters
$$
$END