printChar dosnt print on the screen

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

printChar dosnt print on the screen

karam
anyone can tell me what im doing wrong in my code
im trying to implement printChar(char)
im already wasted 2 day on this function to find what i did wrong
the code work but when im trying to print
on the screen  a small line on the top right
of the screen is shown

my code:
 function void moveCursor(int i, int j) {
        let row=i;
        let col=j;
        return;
    }

    /** Displays the given character at the cursor location,
     *  and advances the cursor one column forward. */
    function void printChar(char c) {
        var Array fontmap;
        var int adress;
        var int rowcounter,colcounter;
        let rowcounter=0;
        let colcounter=0;
        let fontmap=Output.getMap(c);
        let adress=(row*32)+(col/2);
        while(rowcounter<11){
          while(colcounter<8){
             let screen[adress]=twoToThe[colcounter] & fontmap[rowcounter] | screen[adress];
             let colcounter=colcounter+1;
           }
   let adress=adress+1;
          let rowcounter=rowcounter+1;
         
        }
         if( col = 63 ) {
            do Output.println();
        }
        else{
          do Output.moveCursor(col+1,row);
        }
        return;
               
    }
Reply | Threaded
Open this post in threaded view
|

Re: printChar dosnt print on the screen

WBahn
Administrator
What do you mean that the code is working? It sounds like it isn't working, which is why you are asking about it.

It looks like you have a few problems. But the first one that jumps out (based on looking at the code, not running it, so I might easily miss something) is what the value in "address" is as your function proceeds.

Look at that carefully and see if it is really doing what you want it to do, especially as you go from one row to the next.
Reply | Threaded
Open this post in threaded view
|

Re: printChar dosnt print on the screen

karam
yes i debuged my code manualy
the code screen[adress]=twoToThe[colcounter] & fontmap[rowcounter] | screen[adress]; turn on the places where
bits are one acoording to the font number in fontmap[row] of the charachter
for each font ther is 11 pix row and 8 pix column
after evry 11 pix i advance my column

for example a=(0,0,0,14,24,30,27,27,54,0,0)
fontmap[row]=14
14 and 2^1 turn col bit in the index 1
14 and 2^2 turn col bit in the index 2
and i conect the previouse result in scree[addres] with the current result with or


Reply | Threaded
Open this post in threaded view
|

Re: printChar dosnt print on the screen

WBahn
Administrator
Again, focus on what the value of "adress" (it probably should be "address") as you go from one row to the next.

If the top row of a character is located in the screen memory map at address 16384, at what address is the second row located? At what address does your code place it?

Focus on what your code actually does, not what you want it to do.
Reply | Threaded
Open this post in threaded view
|

Re: printChar dosnt print on the screen

karam
ther was a mistake in the row movement i moved the row to much
that it reached beyond the screen
anyway the problem was solved
thanks for the help