Skip to content

Commit

Permalink
Comment cosmetic ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Jun 7, 2021
1 parent 9dcfc23 commit d81a010
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions targets/mega65/vic4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,11 @@ static void vic4_render_char_raster ( void )
color_data = (color_data << 8) | (*(colour_ram_current_ptr++));
char_value = char_value | (*(screen_ram_current_ptr++) << 8);
if (XEMU_UNLIKELY(SXA_GOTO_X(color_data))) {
// Start of the GOTOX functionality implementation, tricky one.
// Start of the GOTOX re-positioning functionality implementation, tricky one.
xcounter = (char_value & 0x3FF); // first, extract the goto to X value as an usigned number
if (REG_H640) {
// Interpret as a "negative" value compared to xcounter_start if it would fit into the real range of 0-xcounter_start,
// otherwise interpret that as a positive offset compared to xcounter_start
if (0x3FF - xcounter < xcounter_start)
xcounter = xcounter_start - (0x3FF - xcounter);
else
Expand All @@ -1185,12 +1187,15 @@ static void vic4_render_char_raster ( void )
else
xcounter += xcounter_start;
}
// The ugly: too large goto X values may cause out-of-bound access on eg is_fg buffer. Thus, if the result is larger than
// the width of the SDL texture, it won't be seen anyway, so we "clamp" it for the NEXT raster as an ugly solution, which
// will be overwritten anyway on rendering in the next raster. This way we don't need checking of out-of-bound access (faster
// code).
if (xcounter > TEXTURE_WIDTH)
xcounter = TEXTURE_WIDTH;
//// FIXME: I am not sure if it cannot cause out-of-bound access later in some cases, somewhere, caused by GOTOX stuff before
//xcounter = xcounter_start + ((char_value & 0x3FF) << (REG_H640 ? 0 : 1));
//DEBUGPRINT("xcounter_start = %d" NL, xcounter_start);
// Align current_pixel pointer according the calculated xcounter "horror show" above
current_pixel = pixel_raster_start + xcounter;
// End of the GOTOX re-positioning functionality implementation
line_char_index++;
char_fetch_offset = char_value >> 13;
if (SXA_VERTICAL_FLIP(color_data))
Expand Down

1 comment on commit d81a010

@lgblgblgb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log to #29 too

Please sign in to comment.