Let's Make Robots!

IRIS System - update 2

 I've worked on this alot latley. It's an improved version of my text editor. Basically, it was made to test the keyboard input and TV output for the propeller, but ended up being alot more work than it was worth. In the end, I just realized that I only needed to use the ending string (13, 10). Only some minor problems remain: no tv objects will work unless the prop. is plugged into the computer and no spaces show up when using the read method. Here's the code:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

CON

 _clkmode = xtal1 + pll16x

 _xinfreq = 5_000_000

 

 DO  = 0

 CLK = 1

 DI  = 2

 CS  = 3

 

VAR

 byte text

 byte str[1000]

 byte txtnum

 byte tvx

 byte tvy

 byte end

 

OBJ

 sdfat : "fsrw"

 kb    : "keyboard"

 tv    : "aigeneric_driver_g"

 

PUB Initiate  | mount

 tv.start(13)

 tvx := 0

 tvy := 0

 

 mount := \sdfat.mount_explicit(DO, CLK, DI, CS)

 if mount < 0

    tv.pokechar(tvx, tvy, 7, "N")

    tvx++

    tv.pokechar(tvx, tvy, 7, "o")

    tvx++

    tv.pokechar(tvx, tvy, 7, " ")

    tvx++

    tv.pokechar(tvx, tvy, 7, "S")

    tvx++

    tv.pokechar(tvx, tvy, 7, "D")

    tvx++

    tv.pokechar(tvx, tvy, 7, " ")

    tvx++

    tv.pokechar(tvx, tvy, 7, "c")

    tvx++

    tv.pokechar(tvx, tvy, 7, "a")

    tvx++

    tv.pokechar(tvx, tvy, 7, "r")

    tvx++

    tv.pokechar(tvx, tvy, 7, "d")

    tvx++

    tv.pokechar(tvx, tvy, 7, " ")

    tvx++

    tv.pokechar(tvx, tvy, 7, "f")

    tvx++

    tv.pokechar(tvx, tvy, 7, "o")

    tvx++

    tv.pokechar(tvx, tvy, 7, "u")

    tvx++

    tv.pokechar(tvx, tvy, 7, "n")

    tvx++

    tv.pokechar(tvx, tvy, 7, "d")

    tv.updatescreen

    waitcnt(cnt + clkfreq*4)

    abort

 

 kb.start(4, 5)

write

 

PUB write  | i

 repeat i from 0 to 39

   text := \kb.getkey

   if text == $C8

     backspace

   if text == $D0

     save

   if text == $D1

     read

   tv.pokechar(tvx, tvy, 7, text)

   tv.updatescreen

   str[txtnum] := text

   tvx++

   txtnum++

 tvy++

 tvx := 0

write

 

PUB read  | i, j

 tvx :=0

 tvy := 0

 txtnum := 0

 bytefill(@str, 0, 1000)

 tv.cls

 tv.updatescreen

 sdfat.popen(string("test.txt"), "r")

 repeat

   text := \sdfat.pgetc

   if text == 13

     text := \sdfat.pgetc

     if text == 10 

       quit

     tv.pokechar(tvx, tvy, 7, 13)

     tvx++    

   if text > 44

     str[txtnum] := text

     txtnum++

     tv.pokechar(tvx, tvy, 7, text)

     tvx++

   tv.updatescreen

 sdfat.pclose

write

 

PUB save  | i, j

 sdfat.popen(string("test.txt"), "w")

 sdfat.pputs(@str)

 sdfat.pputs(string(13, 10))

 sdfat.pclose

read

 

PUB backspace

 tvx--

 tv.pokechar(tvx, tvy, 7, " ")

 tv.updatescreen

 str[txtnum] := 0

 txtnum--

write

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------