11
2+ #include <stdint.h>
23#include <stdlib.h>
34#include <string.h>
45#include <reent.h>
@@ -296,7 +297,7 @@ static void __console_clear_line(int line, int from, int to )
296297 if ( !(con = currentConsole ) ) return ;
297298
298299 // Each character is FONT_XSIZE * VI_DISPLAY_PIX_SZ wide
299- const u32 line_width = (to - from + 1 ) * ( FONT_XSIZE * VI_DISPLAY_PIX_SZ ) ;
300+ const u32 line_width = (to - from + 1 ) * FONT_XSIZE * VI_DISPLAY_PIX_SZ ;
300301
301302 unsigned int bgcolor = con -> bg ;
302303
@@ -307,15 +308,15 @@ static void __console_clear_line(int line, int from, int to )
307308 //add the given row & column to the offset & assign the pointer
308309 const u32 offset = __console_get_offset () \
309310 + ((line - 1 + con -> windowY - 1 ) * con -> con_stride * FONT_YSIZE ) \
310- + (( from - 1 + con -> windowX - 1 ) * FONT_XSIZE * VI_DISPLAY_PIX_SZ ) ;
311+ + (from - 1 + con -> windowX - 1 ) * FONT_XSIZE * VI_DISPLAY_PIX_SZ ;
311312
312- p = (u8 * )((u32 )con -> destbuffer + offset );
313+ p = (u8 * )((uintptr_t )con -> destbuffer + offset );
313314
314315 // Clears 1 line of pixels at a time
315316 for (u16 ycnt = 0 ; ycnt < FONT_YSIZE ; ycnt ++ )
316317 {
317318 for (u32 xcnt = 0 ; xcnt < line_width ; xcnt += 4 )
318- * (u32 * )((u32 )p + xcnt ) = bgcolor ;
319+ * (u32 * )((uintptr_t )p + xcnt ) = bgcolor ;
319320
320321 p += con -> con_stride ;
321322 }
@@ -334,13 +335,14 @@ static void __console_clear(void)
334335 }
335336
336337 //get console pointer
337- p = (u8 * )((u32 )con -> destbuffer + __console_get_offset ()) + ((con -> windowY - 1 ) * con -> con_stride * FONT_YSIZE );
338+ p = (u8 * )((uintptr_t )con -> destbuffer + __console_get_offset ()) \
339+ + ((con -> windowY - 1 ) * con -> con_stride * FONT_YSIZE );
338340
339341 // Clears 1 line of pixels at a time
340- for (u16 ycnt = con -> windowY * 16 ; ycnt < ( con -> windowHeight + con -> windowY ) * 16 ; ycnt ++ )
342+ for (u16 ycnt = 0 ; ycnt < con -> windowHeight * 16 ; ycnt ++ )
341343 {
342344 for (u32 xcnt = (con -> windowX - 1 ) * 8 * VI_DISPLAY_PIX_SZ ; xcnt < (con -> windowWidth + con -> windowX - 1 ) * 8 * VI_DISPLAY_PIX_SZ ; xcnt += 4 )
343- * (u32 * )((u32 )p + xcnt ) = bgcolor ;
345+ * (u32 * )((uintptr_t )p + xcnt ) = bgcolor ;
344346
345347 p += con -> con_stride ;
346348 }
@@ -407,7 +409,7 @@ static void __set_default_console(void *destbuffer,int xstart,int ystart, int tg
407409 con -> bg = CONSOLE_COLOR_BLACK ;
408410
409411 con -> flags = 0 ;
410- con -> tabSize = 4 ;
412+ con -> tabSize = 3 ;
411413
412414 currentConsole = con ;
413415
@@ -750,11 +752,10 @@ void newRow()
750752 /* if bottom border reached, scroll */
751753 if ( currentConsole -> cursorY > currentConsole -> windowHeight )
752754 {
753- const u8 * console = (u8 * )((u32 )currentConsole -> destbuffer + __console_get_offset ()) \
755+ u8 * ptr = (u8 * )((u32 )currentConsole -> destbuffer + __console_get_offset ()) \
756+ + (currentConsole -> windowX - 1 ) * FONT_XSIZE * VI_DISPLAY_PIX_SZ \
754757 + ((currentConsole -> windowY - 1 ) * currentConsole -> con_stride * FONT_YSIZE );
755758
756- //copy lines upwards
757- u8 * ptr = (u8 * )console ;
758759 for (u32 ycnt = 0 ; ycnt < ((currentConsole -> windowHeight - 1 ) * FONT_YSIZE ); ycnt ++ )
759760 {
760761 memmove (ptr , ptr + currentConsole -> con_stride * FONT_YSIZE , currentConsole -> windowWidth * FONT_XSIZE * VI_DISPLAY_PIX_SZ );
0 commit comments