diff --git a/compiler/res/prog8lib/cx16/palette.p8 b/compiler/res/prog8lib/cx16/palette.p8 index b2a1a5dd9..ce3e5a8e3 100644 --- a/compiler/res/prog8lib/cx16/palette.p8 +++ b/compiler/res/prog8lib/cx16/palette.p8 @@ -13,20 +13,20 @@ palette { cx16.vpoke(1, vera_palette_ptr, msb(color)) } - sub set_rgb4(uword palette_bytes_ptr, uword num_colors) { - ; 2 bytes per color entry, the Vera uses this, but the R/GB bytes order is swapped + sub set_rgb_be(uword palette_ptr, uword num_colors) { + ; 1 word per color entry, $0rgb in big endian format vera_palette_ptr = $fa00 repeat num_colors { - cx16.vpoke(1, vera_palette_ptr+1, @(palette_bytes_ptr)) - palette_bytes_ptr++ - cx16.vpoke(1, vera_palette_ptr, @(palette_bytes_ptr)) - palette_bytes_ptr++ + cx16.vpoke(1, vera_palette_ptr+1, @(palette_ptr)) + palette_ptr++ + cx16.vpoke(1, vera_palette_ptr, @(palette_ptr)) + palette_ptr++ vera_palette_ptr+=2 } } sub set_rgb(uword palette_words_ptr, uword num_colors) { - ; 1 word per color entry (in little endian format so $gb0r) + ; 1 word per color entry (in little endian format as layed out in video memory, so $gb0r) vera_palette_ptr = $fa00 repeat num_colors*2 { cx16.vpoke(1, vera_palette_ptr, @(palette_words_ptr)) diff --git a/compiler/res/prog8lib/diskio.p8 b/compiler/res/prog8lib/diskio.p8 index b7a1adb5b..26a968dc1 100644 --- a/compiler/res/prog8lib/diskio.p8 +++ b/compiler/res/prog8lib/diskio.p8 @@ -261,13 +261,15 @@ m_in_buffer sta $ffff if cx16.r5==$0d { ; chance on I/o error status? first_byte = c64.READST() - if first_byte & $40 + if first_byte & $40 { f_close() ; end of file, close it + list_blocks-- ; don't count that last CHRIN read + } if first_byte - return list_blocks + return list_blocks ; number of bytes read } } - return list_blocks + return list_blocks ; number of bytes read } sub f_read_all(uword bufferpointer) -> uword { @@ -275,19 +277,20 @@ m_in_buffer sta $ffff if not iteration_in_progress return 0 - list_blocks = 0 ; we reuse this variable for the total number of bytes read + uword total_read = 0 if have_first_byte { have_first_byte=false @(bufferpointer) = first_byte bufferpointer++ - list_blocks++ + total_read = 1 } while not c64.READST() { - list_blocks += f_read(bufferpointer, 256) - bufferpointer += 256 + uword size = f_read(bufferpointer, 256) + total_read += size + bufferpointer += size } - return list_blocks + return total_read } asmsub f_readline(uword bufptr @AY) clobbers(X) -> ubyte @Y {