Log In  


When using multiscreen mode, the following function (which should print a scaled text) turned out to render only on the first screen:

function scale_text(str,x,y,c,scale)
    memcpy(0x4300,0x0,0x0200)
    memset(0x0,0,0x0200)

    -- draw to spr mem at 0x0000
    poke(0x5f55,0x00)
    print(str,0,0,7)
    -- draw to screen mem again
    poke(0x5f55,0x60)

    local w,h = #str*4,5
    pal(7,c)
    palt(0,true)
    sspr(0,0,w,h,x,y,w*scale,h*scale)
    pal()

    memcpy(0x0,0x4300,0x0200)
end

Just like normal printing, I expected this to work in multiscreen with the following calling code:

poke(0x5f36,1)
scrs_w, scrs_h = 3,1;
scr_ix = 0;

_camera = camera
function camera(x,y)
  x = x or 0
  y = y or 0
  local dx=flr(scr_ix % scrs_w)
  local dy=flr(scr_ix / scrs_w)
  _camera(x+128*dx, y+128*dy)
end

function _draw()
  scr_ix = stat(3)
  camera(0,0)
  cls(scr_ix+5)

  sspr(0,0,24,24,200,30,48,48)

  print("hello",120,80,8)
  scale_text("hello",110,60,12,1.5)

  return scr_ix < stat(11)-1
end

But the result is a cut-off scaled text, while the normal text and the other sspr() call work just fine.

I think this is a bug in PICO-8, with remapping gfx memory not properly working in multiscreen mode.

3


1

Ok, this turned out not to be a bug but simply a thing of using multiscreen correctly. Drawing to sprite mem also needs to be offset by 128*(screen index).

So the working code for a multiscreen general text scaling routine would be:

function prints(str,x,y,c,scale)
	memcpy(0x4300,0x0000,0x200)
	memset(0x0,0,0x0200)    
	poke(0x5f55,0x00)
	print(str,stat(3)*128,0,c)
	poke(0x5f55,0x60)
	local w,h = #str*4,5
	sspr(0,0,w,h,x,y,w*scale,h*scale)
	memcpy(0x0000,0x4300,0x200)
end


[Please log in to post a comment]