|
@@ -10,8 +10,8 @@ import (
|
|
|
|
|
|
No More Secrets - from "Sneakers"
|
|
|
https:
|
|
|
-
|
|
|
*/
|
|
|
+const NORANDOM bool = false
|
|
|
|
|
|
type NoMoreSecretsConfig struct {
|
|
|
Jumble_Sec int
|
|
@@ -46,49 +46,66 @@ func getRandom() byte {
|
|
|
return rb
|
|
|
}
|
|
|
|
|
|
+var rb byte
|
|
|
+
|
|
|
+func nonRandom() byte {
|
|
|
+ if rb == 0 {
|
|
|
+ rb = 0x21
|
|
|
+ return rb
|
|
|
+ }
|
|
|
+ rb++
|
|
|
+ if rb == 0x7f {
|
|
|
+ rb++
|
|
|
+ }
|
|
|
+ if rb >= 0xdf {
|
|
|
+ rb = 0x21
|
|
|
+ }
|
|
|
+ return rb
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
NoMoreSecrets - render output as random, then fade in the original text.
|
|
|
|
|
|
Example:
|
|
|
|
|
|
-func About_Example_NoMoreSecrets(d *door.Door) {
|
|
|
- W := 60
|
|
|
- center_x := (door.Width - W) / 2
|
|
|
- center_y := (door.Height - 16) / 2
|
|
|
- about := door.Panel{X: center_x,
|
|
|
- Y: center_y,
|
|
|
- Width: W,
|
|
|
- Style: door.SINGLE_DOUBLE,
|
|
|
- BorderColor: door.ColorText("BOLD YELLOW ON BLUE"),
|
|
|
- }
|
|
|
- about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "About This Door"),
|
|
|
- DefaultColor: door.ColorText("BOLD CYAN ON BLUE")})
|
|
|
- about.Lines = append(about.Lines, about.Spacer())
|
|
|
+ func About_Example_NoMoreSecrets(d *door.Door) {
|
|
|
+ W := 60
|
|
|
+ center_x := (door.Width - W) / 2
|
|
|
+ center_y := (door.Height - 16) / 2
|
|
|
+ about := door.Panel{X: center_x,
|
|
|
+ Y: center_y,
|
|
|
+ Width: W,
|
|
|
+ Style: door.SINGLE_DOUBLE,
|
|
|
+ BorderColor: door.ColorText("BOLD YELLOW ON BLUE"),
|
|
|
+ }
|
|
|
+ about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "About This Door"),
|
|
|
+ DefaultColor: door.ColorText("BOLD CYAN ON BLUE")})
|
|
|
+ about.Lines = append(about.Lines, about.Spacer())
|
|
|
|
|
|
- about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")})
|
|
|
- var copyright string = "(C) 2022 Bugz, Red Green Software"
|
|
|
+ about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")})
|
|
|
+ var copyright string = "(C) 2022 Bugz, Red Green Software"
|
|
|
|
|
|
- if door.Unicode {
|
|
|
- copyright = strings.Replace(copyright, "(C)", "\u00a9", -1)
|
|
|
- }
|
|
|
+ if door.Unicode {
|
|
|
+ copyright = strings.Replace(copyright, "(C)", "\u00a9", -1)
|
|
|
+ }
|
|
|
|
|
|
- about.Lines = append(about.Lines,
|
|
|
- door.Line{Text: fmt.Sprintf("%*s", -W, copyright),
|
|
|
- DefaultColor: door.ColorText("BOLD WHITE ON BLUE")})
|
|
|
- for _, text := range []string{"",
|
|
|
- "This door was written by Bugz.",
|
|
|
- "",
|
|
|
- "It is written in Go, understands CP437 and unicode, adapts",
|
|
|
- "to screen sizes, uses door32.sys, supports TheDraw Fonts,",
|
|
|
- "and runs on Linux and Windows."} {
|
|
|
- about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
|
|
|
- }
|
|
|
+ about.Lines = append(about.Lines,
|
|
|
+ door.Line{Text: fmt.Sprintf("%*s", -W, copyright),
|
|
|
+ DefaultColor: door.ColorText("BOLD WHITE ON BLUE")})
|
|
|
+ for _, text := range []string{"",
|
|
|
+ "This door was written by Bugz.",
|
|
|
+ "",
|
|
|
+ "It is written in Go, understands CP437 and unicode, adapts",
|
|
|
+ "to screen sizes, uses door32.sys, supports TheDraw Fonts,",
|
|
|
+ "and runs on Linux and Windows."} {
|
|
|
+ about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
|
|
|
+ }
|
|
|
|
|
|
- better := door.NoMoreSecretsDefault
|
|
|
- better.Color = door.ColorText("BOLD CYAN ON BLUE")
|
|
|
+ better := door.NoMoreSecretsDefault
|
|
|
+ better.Color = door.ColorText("BOLD CYAN ON BLUE")
|
|
|
|
|
|
- door.NoMoreSecrets(about.Output(), d, &better)
|
|
|
-}
|
|
|
+ door.NoMoreSecrets(about.Output(), d, &better)
|
|
|
+ }
|
|
|
*/
|
|
|
func NoMoreSecrets(output string, Door *Door, config *NoMoreSecretsConfig) {
|
|
|
|
|
@@ -225,7 +242,12 @@ func NoMoreSecrets(output string, Door *Door, config *NoMoreSecretsConfig) {
|
|
|
if work[pos] != ' ' {
|
|
|
|
|
|
|
|
|
- var rb byte = getRandom()
|
|
|
+ var rb byte
|
|
|
+ if NORANDOM {
|
|
|
+ rb = nonRandom()
|
|
|
+ } else {
|
|
|
+ rb = getRandom()
|
|
|
+ }
|
|
|
var safe []byte = []byte{rb}
|
|
|
var rndchar string = CP437_to_Unicode(string(safe))
|
|
|
work[pos] = []rune(rndchar)[0]
|
|
@@ -245,14 +267,27 @@ func NoMoreSecrets(output string, Door *Door, config *NoMoreSecretsConfig) {
|
|
|
if chartime[idx] > 0 {
|
|
|
if chartime[idx] < 500 {
|
|
|
if rand.Intn(3) == 0 {
|
|
|
- var safe []byte = []byte{getRandom()}
|
|
|
- var rndchar string = CP437_to_Unicode(string(safe))
|
|
|
+ var safe [1]byte
|
|
|
+
|
|
|
+ if NORANDOM {
|
|
|
+ safe[0] = nonRandom()
|
|
|
+ } else {
|
|
|
+ safe[0] = getRandom()
|
|
|
+ }
|
|
|
+
|
|
|
+ var rndchar string = CP437_to_Unicode(string(safe[:]))
|
|
|
work[pos] = []rune(rndchar)[0]
|
|
|
}
|
|
|
} else {
|
|
|
if rand.Intn(10) == 0 {
|
|
|
- var safe []byte = []byte{getRandom()}
|
|
|
- var rndchar string = CP437_to_Unicode(string(safe))
|
|
|
+ var safe [1]byte
|
|
|
+ if NORANDOM {
|
|
|
+ safe[0] = nonRandom()
|
|
|
+ } else {
|
|
|
+ safe[0] = getRandom()
|
|
|
+ }
|
|
|
+
|
|
|
+ var rndchar string = CP437_to_Unicode(string(safe[:]))
|
|
|
work[pos] = []rune(rndchar)[0]
|
|
|
}
|
|
|
}
|
|
@@ -403,7 +438,11 @@ func NoMoreSecrets(output string, Door *Door, config *NoMoreSecretsConfig) {
|
|
|
for i := 0; i < (config.Jumble_Sec*1000)/config.Jumble_Loop_Speed; i++ {
|
|
|
for _, pos := range charpos {
|
|
|
if work[pos] != ' ' {
|
|
|
- work[pos] = getRandom()
|
|
|
+ if NORANDOM {
|
|
|
+ work[pos] = nonRandom()
|
|
|
+ } else {
|
|
|
+ work[pos] = getRandom()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Door.Write(renderF())
|
|
@@ -420,11 +459,19 @@ func NoMoreSecrets(output string, Door *Door, config *NoMoreSecretsConfig) {
|
|
|
if chartime[idx] > 0 {
|
|
|
if chartime[idx] < 500 {
|
|
|
if rand.Intn(3) == 0 {
|
|
|
- work[pos] = getRandom()
|
|
|
+ if NORANDOM {
|
|
|
+ work[pos] = nonRandom()
|
|
|
+ } else {
|
|
|
+ work[pos] = getRandom()
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
if rand.Intn(10) == 0 {
|
|
|
- work[pos] = getRandom()
|
|
|
+ if NORANDOM {
|
|
|
+ work[pos] = nonRandom()
|
|
|
+ } else {
|
|
|
+ work[pos] = getRandom()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|