// XXX - there is a room for improvements due to change from "128 bytes per line" model
//       to more linear one - there is no needed to recalculate position of new lines
there is a room for improvements due to change from "128 bytes per line" model
to more linear one - there is no needed to recalculate position of new lines
// XXX - there is a room for improvements due to change from " 128 bytes per line " model // to more linear one - there is no needed to recalculate position of new lines
func (v *Vicky) RenderBitmapText() {
        var cursor_x, cursor_y uint32 
        var cursor_char uint32    
        var cursor_state byte     
        var text_x, text_y uint32 
        var text_row_pos uint32   
        var fb_row_pos uint32     
        var font_pos uint32       
        var font_line uint32      
        var font_row_pos uint32   
        var i uint32              
	var is_overlay bool	  
        var fnttmp [128]uint32    
        var fgctmp [128]uint32    
        var bgctmp [128]uint32    
        var dsttmp [128]uint32    
	cursor_state =        mem[0x00_0010]
	cursor_char  = uint32(mem[0x00_0012])
	cursor_x     = uint32(mem[0x00_0014])
	cursor_y     = uint32(mem[0x00_0016])
	if (mem[0x0000] & 0x02) == 0x02 {	
		is_overlay = true
	} else {
		is_overlay = false
	}
	fb_row_pos = v.starting_fb_row_pos
	for text_y = 0; text_y < v.text_rows; text_y += 1 { 
		text_row_pos = text_y * 80				
		for text_x = 0; text_x < v.text_cols; text_x += 1 { 
			fnttmp[text_x] = text[text_row_pos+text_x] * 64 
			dsttmp[text_x] = text_x * 8                     
			f := fg[text_row_pos+text_x] 
			b := bg[text_row_pos+text_x]
			if v.Cursor_visible && (cursor_y == text_y) && (cursor_x == text_x) && (cursor_state & 0x01 == 1) {
				f = uint32((mem[0x00_0013] & 0xf0) >> 4)
				b = uint32(mem[0x00_0013] & 0x0f)
				fnttmp[text_x] = cursor_char * 64
			}
			fgctmp[text_x] = binary.LittleEndian.Uint32(f_color_lut[f][:]) 
			if is_overlay == false {
				bgctmp[text_x] = binary.LittleEndian.Uint32(b_color_lut[b][:]) 
			} else {
				bgctmp[text_x] = 0x00FFFFFF			
			}
		}
		for font_line = 0; font_line < 8; font_line += 1 { 
			font_row_pos = font_line * 8
			for text_x = 0; text_x < v.text_cols; text_x += 1 { 
				font_pos = fnttmp[text_x] + font_row_pos
				for i = 0; i < 8; i += 1 { 
					if font[font_pos+i] == 0 {
						tfb[fb_row_pos+dsttmp[text_x]+i] = bgctmp[text_x]
					} else {
						tfb[fb_row_pos+dsttmp[text_x]+i] = fgctmp[text_x]
					}
				}
			}
			fb_row_pos += v.x_res
		}
	}
}
func ( v * Vicky ) RenderBitmapText ( ) { var cursor_x , cursor_y uint32 var cursor_char uint32 var cursor_state byte var text_x , text_y uint32 var text_row_pos uint32 var fb_row_pos uint32 var font_pos uint32 var font_line uint32 var font_row_pos uint32 var i uint32 var is_overlay bool var fnttmp [ 128 ] uint32 var fgctmp [ 128 ] uint32 var bgctmp [ 128 ] uint32 var dsttmp [ 128 ] uint32 cursor_state = mem [ 0x00_0010 ] cursor_char = uint32 ( mem [ 0x00_0012 ] ) cursor_x = uint32 ( mem [ 0x00_0014 ] ) cursor_y = uint32 ( mem [ 0x00_0016 ] ) if ( mem [ 0x0000 ] & 0x02 ) == 0x02 { is_overlay = true } else { is_overlay = false } fb_row_pos = v . starting_fb_row_pos for text_y = 0 ; text_y < v . text_rows ; text_y += 1 { text_row_pos = text_y * 80 for text_x = 0 ; text_x < v . text_cols ; text_x += 1 { fnttmp [ text_x ] = text [ text_row_pos + text_x ] * 64 dsttmp [ text_x ] = text_x * 8 f := fg [ text_row_pos + text_x ] b := bg [ text_row_pos + text_x ] if v . Cursor_visible && ( cursor_y == text_y ) && ( cursor_x == text_x ) && ( cursor_state & 0x01 == 1 ) { f = uint32 ( ( mem [ 0x00_0013 ] & 0xf0 ) >> 4 ) b = uint32 ( mem [ 0x00_0013 ] & 0x0f ) fnttmp [ text_x ] = cursor_char * 64 } fgctmp [ text_x ] = binary . LittleEndian . Uint32 ( f_color_lut [ f ] [ : ] ) if is_overlay == false { bgctmp [ text_x ] = binary . LittleEndian . Uint32 ( b_color_lut [ b ] [ : ] ) } else { bgctmp [ text_x ] = 0x00FFFFFF } } for font_line = 0 ; font_line < 8 ; font_line += 1 { font_row_pos = font_line * 8 for text_x = 0 ; text_x < v . text_cols ; text_x += 1 { font_pos = fnttmp [ text_x ] + font_row_pos for i = 0 ; i < 8 ; i += 1 { if font [ font_pos + i ] == 0 { tfb [ fb_row_pos + dsttmp [ text_x ] + i ] = bgctmp [ text_x ] } else { tfb [ fb_row_pos + dsttmp [ text_x ] + i ] = fgctmp [ text_x ] } } } fb_row_pos += v . x_res } } }
there is a room for improvements due to change from "128 bytes per line" model
to more linear one - there is no needed to recalculate position of new lines
there is a room for improvements due to change from " 128 bytes per line " model to more linear one - there is no needed to recalculate position of new lines
// row and column of cursor // cursor character // cursor register, various states // row and column of text // beginning of current text row in text memory // beginning of current FB   row in memory // position in font array (char * 64 + char_line * 8) // line in current font // position of line in current font (=font_line*8 because every line has 8 bytes) // counter // is overlay text over bm0 enabled? // placeholders recalculated per row of text, holds values for text_cols loop // current max size is 100 columns (800/8) // position in font array, from char value // foreground color cache (rgba) for one line // background color cache (rgba) for one line // position in destination memory array // MASTER_CTRL_REG_L // render text - start // I prefer to keep it because it allow to simply re-drawing single line in future, // by manupipulating starting point (now 0) and end clause (now <v.text_rows) // over lines of text // calculate from resolution / 8 ! // pre-calculate data for x-axis // position in font array // position of char in dest FB // fg and bg colors // text LUT - xxx: change name // text LUT // full alpha // for every line of text - over 8 lines of font // for each line iterate over columns of text // for every font iterate over 8 pixels of font // render text - end