How can I plot a sine wave with a flat top and dotted part of it?

I'm looking for a way to plot the waveform with a flat top and dotted line of a sine as in the second or third curves.
How can I do it?  gap = 1/4;

pw0 = Piecewise[{{ 2/3 Sin[ x], 0 <= x <= 2 π}}, Undefined];

pw1 = Piecewise[{{gap + Sin[ x - π/2], 2 π + π/2 <= x <= 4 π + π /2},
{-gap + Sin[ x - π], 5 π <= x <= 7 π}}, Undefined];

Text, line and arrow primitives to annotate the plot:

annotations = {Text[Style["0", 14], Offset[{-15, 0}, {0, 0}], {1, 0}],
Text[Style["+Vcc", 14], Offset[{-10, 10}, {0, 1}], {1, 0}],
Text[Style["-Vcc", 14], Offset[{-10, -10}, {0, -1}], {1, 0}],
Text[Style["Input\nSignal", 14], Offset[{0, -10}, {π/2, 0}], {0, 1}],
Text[Style["ωt", 14], Offset[{-15, 15}, {2 π, 0}], {1, -1}],
Text[Style["Bias level\nto High", 14], Offset[{0, 5}, {4 π, gap}], {0, -1}],
Text[Style["Bias level\nto Low", 14], Offset[{0, -5}, {5 π + π/2, -gap}], {0, 1}],
Text[Style["Positive\nHalf Clipped", 14],
Offset[{-10, 2}, {3 π + π/2, 1}], {-1, -1}],
Text[Style["Negative\nHalf Clipped", 14], Offset[{10, -2}, {6 π, -1}], {1, 1}],
Text[Style["Distorted Output\nSignal", 14], {6 π, 2/3}, {-1, 0}],
Text[Style["0v", 14], {7 π, 0}, {1, -1}],
Arrow[{Offset[{-30, 10}, {2 π, 0}], Offset[{10, 10}, {2 π, 0}]}],
Arrowheads[{-.02, .02}], Arrow[{{4 π, 0}, {4 π, gap}}],
Arrow[{{5 π + π/2, 0}, {5 π + π/2, -gap}}],
Line[{Offset[{-20, 0}, {2 π + π/2, gap}], Offset[{20, 0}, {4 π + π/2, gap}]}],
Line[{Offset[{-20, 0}, {5 π, -gap}], Offset[{20, 0}, {7 π, -gap}]}]};

Plot[{pw0, pw1, Clip[pw1, {-1, 1}]}, {x, 0, 7 π + π/2},
PlotStyle -> {Directive[CapForm["Round"], AbsoluteThickness],
Directive[Gray, Dashed],
Directive[CapForm["Round"], AbsoluteThickness, RGBColor[0.2, 0.4, 0.2]]},
GridLines -> {None, {-1, 1}},
GridLinesStyle -> Directive[Gray, Dashing[Large]],
ImageSize -> 700,
Ticks -> False,
Epilog -> annotations,
PlotRangeClipping -> False,
ImagePadding -> {{50, 10}, {10, 10}}]

picture above

• really impressive! Other people also gave nice answers which is simple too.
– hana
Jan 10 at 1:50
Plot[{#, Clip[#, {-0.8, 0.8}]}
, {x, 0, 2 \[Pi]}
, PlotStyle -> {{Dashed, Gray}, {Opacity, Thick, Darker@Cyan}}
] &@Sin[x] You can change opacity to make the other dotted waveform more visible.

EDIT-1

The Clip function has a third argument that makes it more versatile for plotting waveforms for clipping and clamping circuits. You can choose another function during clipped phases. As a simpler demonstration:

Plot[{#, Clip[#, {-0.8, 0.8}, {-0.3, 0.5}]}
, {x, 0, 2 \[Pi]}
, Exclusions -> None
, PlotStyle -> {{Dashed, Gray}, {Opacity, Thick, Darker@Cyan}}
] &@Sin[x] Edit

Plot[Sin[2 x], {x, 0, 2 Pi}, Mesh -> {{-.8, .8}},
MeshFunctions -> {#2 &},
Directive[AbsoluteThickness, Darker@Cyan]},
MeshStyle -> Directive[PointSize[Tiny], Blue]] /. {Dotted,
Line[a_]} :> {{Dotted, Line[a]}, {Red, Line[{First[a], Last[a]}]}} Original

Show[Plot[Sin[2 x], {x, 0, 2 Pi}, PlotRange -> {{-.8, .8}},
ClippingStyle -> {Red, Brown}, PlotStyle -> Green],
Plot[Sin[2 x], {x, 0, 2 Pi},
RegionFunction -> Function[{x, y}, Abs@y > .8],
PlotStyle -> {Gray, Dotted}], PlotRange -> All]

Some ideas

Show[
Plot[Min[Sin[x], 0.8], {x, 0, Pi}, PlotStyle -> Thick],
Plot[Sin[x], {x, ArcSin[0.8], Pi - ArcSin[0.8]}, PlotStyle -> Dashed],
PlotRange -> All]
• Couldn't you repeat the trick in the first line? Plot Min[Sin[x], 0.8] with Thick and Max[Sin[x], 0.8] with Dashed. Then you could do everything in one Plot call if you want Jan 9 at 20:15
• @AccidentalTaylorExpansion With Plot[{Min[Sin[x], 0.8], Sin[x]}, {x, 0, Pi}, PlotStyle -> {Thick, Dashed}] I see the dashes are visible throughout the plot, so the second plot in my answer only plots dashes where they should be seen. Jan 9 at 20:25