// DiExPatt.bcpl
get "DiEx.defs"
static PattCnt
static [ @RandomNum = #123456; @PattHint=0 ] //local statics
let DisplayPatterns(Update) be
[ Active = false
let str = "This pattern will be complemented and shifted between passes"
PattHint = str
DisplayParam(PattR, 9, 4)
DisplayParam(PattA, 9, Tab1)
DisplayParam(Patt000, 9, Tab2)
DisplayParam(Patt001, 9, Tab3)
DisplayParam(Patt003, 9, Tab4)
DisplayParam(Patt007, 9, Tab5)
]
and PattR() be
[
if NewBoolian("Will generate a new 'Random' pattern for each pass.") then
T>>P.PattR = not T>>P.PattR
PrintParam("Random Patt: $S",T>>P.PattR?"Yes","No")
]
and PattA() be
[
if NewBoolian("Data word 0=0, 1=1, 2=2, etc.") then T>>P.PattA = not T>>P.PattA
PrintParam("Addr Patt: $S",T>>P.PattA?"Yes","No")
]
and Patt000() be
[
if NewBoolian(PattHint) then T>>P.Patt000 = not T>>P.Patt000
PrintParam("Wrd Patt=0: $S",T>>P.Patt000?"Yes","No")
]
and Patt001() be
[
if NewBoolian(PattHint) then T>>P.Patt001 = not T>>P.Patt001
PrintParam("Wrd Patt=1: $S",T>>P.Patt001?"Yes","No")
]
and Patt003() be
[
if NewBoolian(PattHint) then T>>P.Patt003 = not T>>P.Patt003
PrintParam("Wrd Patt=3: $S",T>>P.Patt003?"Yes","No")
]
and Patt007() be
[
if NewBoolian(PattHint) then T>>P.Patt007 = not T>>P.Patt007
PrintParam("Wrd Patt=7:$S",T>>P.Patt007?"Yes","No")
]
and makePattern(buff,count) be
[
let pattern,none = nil,0
LookPattern:
if none eq 2 then return; none = none+1
switchon PattCnt into
[
default:
case 1: PattCnt = 2; if T>>P.PattR then
[ RandomNum = MakeRandom(buff,count,RandomNum); return ]
case 2: PattCnt = 4; if T>>P.PattA then [ for i = 0 to count-1 do buff!i = i; return ]
case 4: PattCnt = #10; if T>>P.Patt000 then [ pattern=0;endcase ]
case #10: PattCnt = #20; if T>>P.Patt001 then [ pattern=1;endcase ]
case #20: PattCnt = #40; if T>>P.Patt003 then [ pattern=3;endcase ]
case #40: PattCnt = #1; if T>>P.Patt007 then [ pattern=7;endcase ]
goto LookPattern
]
let s = (pass%)-1
[ if s le 0 then break; s=s-2
pattern = pattern ls 0? (pattern lshift 1)+1,pattern lshift 1
] repeat
if (pass & 1) ne 0 then pattern = not pattern
SetBlock(buff,pattern,count)
]
and MakeRandom(block,count,Num) = valof
[ external RandomASM
let buff = vec 2
buff!0 = Num
buff!1 = count
buff!2 = block
resultis RandomASM(buff)
]