Log In  
Follow
auxeras
[ :: Read More :: ]

Hi,

I noticed something strange while writing a function that dumps the content of a memory segment (in the case the spritesheet).

After importing it properly (and checking it in the p8 file through an external editor), I noticed that the last pixel of the spritesheet was always 0. I thought it was a bug (and maybe it is, I'm not 100% sure), but the code seems to be working right for other sections of memory. Here is what I am using :

function rle_comp(addr, ending)
 byte = 0x0
 pixel_index = 0
 local comp = ""

 function read_pixel()
  if pixel_index > 4 then
   addr += 0x0001
   pixel_index = 0
  end

  byte = peek(addr)
  print("addr : " .. tostr(addr, true) .. ' byte : ' .. tostr(byte, true))

  local pixel = band(byte, shl(0x000f, pixel_index))
  if pixel_index > 0 then
   pixel = lshr(pixel, pixel_index)
  end

  pixel_index += 4
  return pixel
 end

 while addr < ending do
  read_pixel()
 end

 return comp
end

function rle_decomp(ci, addr)
end

function _init()
 compressed_img = rle_comp(0x0000, 0x2000)
 rle_decomp(compressed_img, 0x6000)
 --printh(compressed_img, "compressed_img.txt", true)
end

Is it normal to have this trailing 0? Is it a bug in my code? It's late here and I can't tell anymore

P#56544 2018-09-11 18:10 ( Edited 2018-09-12 11:59)