Professional Documents
Culture Documents
syscall 13 to open file. Flags: 0 for read-only, 1 for write-only with create, and
9 for write-only with create and append
_______________________________________________
Reading Procedure:
0) Read how many words the file has by reading byte by byte the number of ";" the
program finds and save it to a WORD. Call it NLINES
if the first byte of the file is "\0" then it's 0 lines, then NLINES=0. In this
case the program must end.
Start reading the file byte by byte and each time it encounters "\n" it means a new
word os goint to start in the next byte of the file. Do this until the before
picked number is equal to the line+1 (because we read line 0 and it contains word
1).
3) Check if from that pointer's position, there are atleast 5 bytes before another
";" and no more than 10 bytes before the next ";".
When the file ends there's going to be an "\0" but that's only going to happen when
the picked number is equal or greater than NLINES
5) Print a '-' for each character and add each to a playWordBuffer, wich is the one
that contains the word that shows how many letters are right.
12)
Pick random word from dataBase and move it to wordBuffer
GAME LOOP:
Check if win:
write message of win
j END
Print used Characters
Print playWord
Ask for a letter
Check if that letter is not used:
Check if that letter is in the wordBuffer:
Add that letter to the usedCharIndex
Add that letter to the playWordBuffer where it should be->
To do it while char!=\0 in wordBuffer, if
wordBuffer[i]==letter; then put it in that position to playWordBuffer
5) If (3) then we should read that word and use it for the game.
NOTE: The file descriptor should be saved just before (3) because in (4) we have to
read that line
_______________________________________________