The code below works perfectly. No jittering and the lock works like a charm:
sync on
sync rate 0
autocam off
make object plain 1,20,20
xrotate object 1,90
position camera 0,0,3,0
do
ymove=mousemovey()
REM allow user to look if look is unlocked
if lock=0 then inc xangle#,ymove
REM lock look and set angle to max
if xangle#<-20
lock=1
xangle#=-20
endif
if xangle#>20
lock=2
xangle#=20
endif
REM unlock look if user begins to look the other direction
if lock=1 and ymove>0 then lock=0
if lock=2 and ymove<0 then lock=0
REM rotate camera
xrotate camera xangle#
sync
loop
As I have, make sure that you use a mousemove command only once per loop. Record its value in a variable at the start of your main loop. Otherwise you'll run into some weird bugs, due to the way the command stores data per each call.