# Only the top portion of the screen become black when any key is pressed

6 messages
Open this post in threaded view
|

## Only the top portion of the screen become black when any key is pressed

 I have run the code as described in the book. However, when I press a key only a portion (approx 1/15) of the screen blackens. I tried to figure it out but failed. Here is the pseudo-code:   scradr = SCREEN   row = 256   col = 32 INFINITE_LOOP:   i = 0   k = KBD   if k == 0 goto NOT_PRESSED   PRESSED:     if i >= row goto INFINITE_LOOP     j = 0     PRESSED_INNER_LOOP:       if j >= col goto BREAK_INNER_LOOP       RAM[scradr+i+j] = -1       j = j + 1       goto PRESSED_INNER_LOOP     BREAK_INNER_LOOP:       i = i + 1       goto PRESSED   NOT_PRESSED:     if i >= row goto INFINITE_LOOP     j = 0     NOT_PRESSED_INNER_LOOP:       if j >= col goto BREAK_INNER_LOOP_2       RAM[scradr+i+j] = 0       j = j + 1       goto NOT_PRESSED_INNER_LOOP     BREAK_INNER_LOOP_2:       i = i + 1       goto NOT_PRESSED Can someone please say how can this be solved?
Open this post in threaded view
|

## Re: Only the top portion of the screen become black when any key is pressed

 I have been able to solve it so no need to bother. There was a logical error in the pseudo-code.
Open this post in threaded view
|

## Re: Only the top portion of the screen become black when any key is pressed

 Administrator Glad you found it. Was the error neglecting to multiply the row index by the number of words in a row?
Open this post in threaded view
|

## Re: Only the top portion of the screen become black when any key is pressed

 Administrator Look at the difference between your code segments for pressed and unpressed. What do they differ by? What would it take to combine them into a single code segment? There are a couple of ways to do it.