Answers for Simple Input/Output

Topic questions

1. ASCII is the American Standard Code for Information Interchange. Though TI uses a different standard than the currently accepted computer standard, it functions in a similar function: data represented by numbers point to an offset that holds a representation of the character.
2. GetKey will wait for a key to be pressed to return a value, and GetCSC will check to see if a key has been pressed, and if so, return that value. Also, GetKey utilizes the shift operators ([2nd] and [Alpha]) while getCSC returns a scan code for those two keys.

Code Fragments

3. Write a short program to display "HELLO WORLD" diagonally

;here's one that looks decent
 ld hl,0
 ld (pencol),hl
 ld hl,txt
loop:
 ld a,(hl)
 or a
 jr z,stop
 bcall(_vPutmap)
 inc hl
 push hl
 ld hl,(pencol)
 inc h
 inc h
 inc h
 ld (pencol),hl
 pop hl
 jr loop
stop:
 bcall(_GetKey)
 ret
txt:
 .db "HELLO WORLD",0

4. Write a program that moves a dot around the screen when the user presses an arrow key. (hint: Use the _IPoint, or see sprites for a better method)
;sorry, no comments
 bcall(_ClrLCDFull)
 set fullScrnDraw, (IY + apiFlg4)
 bcall(_runindicoff)
 ld bc,$3232
 ld d,1
 push bc
 bcall(_IPoint)
keyloop:
 bcall(_GetCSC)
 cp skup
 jr z,moveUp
 cp skdown
 jr z,movedown
 cp skleft
 jr z,moveleft
 cp skright
 jr z,moveright
 cp skclear
 jr z,quit
 jr keyloop

quit:
 pop bc
 bcall(_ClrLCDFull)
 ret

movedown:
 ld d,0
 pop bc
 push bc
 bcall(_IPoint)
 pop bc
 ld a,c
 or a
 jr z,$+3
 dec a
 ld c,a
 push bc
 ld d,1
 bcall(_IPoint)
 jr keyloop

moveup:
 ld d,0
 pop bc
 push bc
 bcall(_IPoint)
 pop bc
 ld a,c
 cp 63
 jr z,$+3
 inc a
 ld c,a
 push bc
 ld d,1
 bcall(_IPoint)
 jr keyloop

moveleft:
 ld d,0
 pop bc
 push bc
 bcall(_IPoint)
 pop bc
 ld a,b
 or a
 jr z,$+3
 dec a
 ld b,a
 push bc
 ld d,1
 bcall(_IPoint)
 jr keyloop

moveright:
 ld d,0
 pop bc
 push bc
 bcall(_IPoint)
 pop bc
 ld a,b
 cp 95
 jr z,$+3
 inc a
 ld b,a
 push bc
 ld d,1
 bcall(_IPoint)
 jr keyloop

Programming Errors

5. Completely correct
6. Two errors: First of all, ionfastcopy uses plotsscreen instead of appbackupscreen, and the way it defines the buffer is running through the rows, as opposed to the columns. Even if plotsscreen was used, you would have an interesting line pattern drawn instead of an 8*8 box (feel free to try it).

Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.