// SimpleDisplayTest.bcpl
// Last modified April 13, 1982  10:59 AM by Taft

// Bldr SimpleDisplayTest SimpleDisplayStream Gacha10Strike

get "AltoDefs.d"
get "Streams.d"

external
[
CreateSimpleDspStream; SimpleDspDCB; Gacha10
SimpleDspSetLMarg; SimpleDspSetRMarg; SimpleDspSetLinePos; SimpleDspResetLine
SimpleDspGetBitPos; SimpleDspEraseBits; SimpleDspCharWidth
Gets; Puts; Closes
dsp; keys
]


let Test() be
[
manifest width = 38
manifest height = 400
let bitmap = vec width*height; bitmap = (bitmap+1) & -2
let sds = CreateSimpleDspStream(bitmap, width, height, Gacha10)
SimpleDspSetLMarg(sds, 10)
SimpleDspSetRMarg(sds, 16*width - 20)
SimpleDspSetLinePos(sds, 0)
dsp>>DS.ldcb>>DCB.next = SimpleDspDCB(sds)

   [ // repeat
   let char = Gets(keys)
   switchon char into
      [
      case 33B:
         break

      case 01B: case 10B:
         if SimpleDspGetBitPos(sds) gr 10 then
            SimpleDspEraseBits(sds, -SimpleDspCharWidth(sds, $*s))
         endcase

      case $0 to $9:
         if (@177037B & 4B) eq 0 then
            [
            SimpleDspSetLinePos(sds, char-$0)
            SimpleDspResetLine(sds)
            endcase
            ]
         // fall into default case

      default:
         Puts(sds, char)
      ]
   ] repeat

Closes(sds)
]