Shop OBEX P1 Docs P2 Docs Learn Events
VGA_Text.Out($08) not working?? — Parallax Forums

VGA_Text.Out($08) not working??

MacTuxLinMacTuxLin Posts: 821
edited 2011-02-15 18:17 in Propeller 1
Hello All,

I need to do up a mini station using PPB with VGA & PS2 KB/Mouse real quick but seems to hit a problem & its 2nd day now :frown: My code is:
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000                                          ' use 5MHz crystal

  _ConClkFreq = ((_clkmode - xtal1) >> 6) * _xinfreq
  _Ms_001   = _ConClkFreq / 1_000
  _Us_001   = _ConClkFreq / 1_000_000

OBJ
  KB  : "Keyboard"
  VGA : "VGA_Text"


PUB Main
  '--- --- --- --- --- --- --- --- ---
  '--- --- VGA Cog --- ---
  '--- --- --- --- --- --- --- --- ---
  ifnot(VGA.Start(16))
    reboot

  '--- --- --- --- --- --- --- --- ---
  '--- --- Keyboard Cog --- ---
  '--- --- --- --- --- --- --- --- ---
  ifnot(KB.start(26, 27))
    reboot


  VGA.Out($00)
  VGA.Str(String($C,6))
  repeat

    result := VGA.Out(KB.GetKey)
    if result == $C8
      VGA.Out($08)
    
    VGA.Str(13)

Instead of getting a backspace, I got a "E" with a comma on top? (picture). Am I overlooking something?

Thanks a lot!!
813 x 182 - 32K

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-02-15 00:22
    Well, result := VGA.Out(KB.GetKey) outputs whatever is returned from the keyboard. That includes $C8 which is your special E character. As the out method doesn't return anything (zero in fact) you never even send a back space to the device. Your filter logic needs more thought.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2011-02-15 00:38
    kuroneko wrote: »
    Well, result := VGA.Out(KB.GetKey) outputs whatever is returned from the keyboard. That includes $C8 which is your special E character. As the out method doesn't return anything (zero in fact) you never even send a back space to the device. Your filter logic needs more thought.

    (Slapping my forehead) >< Thanks Kuroneko. Thought could do this mini-guy within a few days ... OK, let me do a sanity-check.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2011-02-15 01:04
    OK, I think I'm exhausted but could anyone please help me so I could call it a day to see what I've boo-boo again as I could only erase (backspace) 1 character on screen but the actual value (backspaced) is correct. :innocent:
      repeat
        result := KB.GetKey
        if result == $C8
          result := $08
          Str.putCharacter(result)
          VGA.Out(result)
          VGA.Str(String($C,8))
          VGA.Out($20)
        else
          if result <> $D 
            VGA.Str(String($C,6))
            VGA.Out(result)
            Str.putCharacter(result)
          else  
            VGA.Str(String($C,8))
            VGA.Str(Str.trimString(Str.getCharacters(true)))
            quit
    

    Thanks a lot!!

    Added: I should not have added the space
    VGA.Out($20)
    
    . But hmm... how do I change the colour for those on the right of the "invisible" cursor??
  • MacTuxLinMacTuxLin Posts: 821
    edited 2011-02-15 02:08
    OK, I've found a way to do it but is this the best way ???
      xPtr := 0
      repeat
        result := KB.GetKey
        if result == $C8
          result := $08
          Str.putCharacter(result)
          VGA.Out(result)
          if xPtr
            xPtr--      
            VGA.Out($A)
            VGA.Out(xPtr)
            VGA.Out($B)
            VGA.Out($0)        
            VGA.Str(String($C,8))
            repeat i from 0 to 31-xPtr
              VGA.Out($20)
            VGA.Out($A)
            VGA.Out(xPtr)
            VGA.Out($B)
            VGA.Out($0)        
        else
          if result <> $D 
            VGA.Str(String($C,6))
            VGA.Out(result)
            Str.putCharacter(result)
            xPtr++
          else  
            VGA.Str(String($C,8))
            VGA.Str(Str.trimString(Str.getCharacters(true)))
            quit
    
    :innocent:
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-15 05:19
    Could you post the complete code? I'm not entirely sure as to why you need the Str object (which is what???). What are you trying to achieve?
  • MacTuxLinMacTuxLin Posts: 821
    edited 2011-02-15 10:57
    Thanks. Yes, attached. Basically, I needed the Backspace to look like a real backspace on the VGA screen (when user press the Backspace key once, the last digit entered should be deleted on screen). I used the Str to lineup the strings entered.

    I mean, the Backspacing portion doesn't seems to look efficient so may I know is there a better way to do this instead?

    Thanks a lot! :lol:
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-15 18:06
    One issue here is that the backspace code for the standard VGA driver only seems to work for the current line, i.e. multi-line edits are out of the question. Doing so will get your screen display out-of-sync with the string buffer. As for the visual back space effect, what about:
    if result == $C8
          Str.putCharacter([COLOR="blue"]8[/COLOR])
          VGA.str(string([COLOR="blue"]8[/COLOR],[COLOR="red"]12,8[/COLOR],[COLOR="blue"]32[/COLOR],[COLOR="red"]12,6[/COLOR],[COLOR="blue"]8[/COLOR]))
        else
          if result <> $D
    
    What this does is issue a backspace (8), print a space (32) in color 8 (12,8), change colour back to 6 (12,6) and finally issue another backspace to counter the effect of the space.

    Edit: Just re-checked, backspace only affects the current column, i.e. it is confined to the current row.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2011-02-15 18:17
    This is great!!! Thank you very much! :smile:
Sign In or Register to comment.