Log In  

I am finding another problem.

Try out this program:

cls()
poke(0x8000,5)
?peek(0x8000)
memset(0x8000,0,0x8000)
?peek(0x8000)

You get back 5 each time, which is incorrect as we just cleared memory.

Apparently 0x8000 is being misread as zero when used as a hexadecimal argument for a command.

P#106341 2022-02-04 21:58

Yeah, it does look like memset does nothing when its third argument is negative, but that also seems like it might be intended behavior?

P#106347 2022-02-04 22:31

Well how do you clear out the top memory ? :) No I'm pretty sure it needs to read back internally 32768. If it can read that high with 0x8000 it should be able to count that high too if only in this instance.

Currently I am using memset() at 0x7FFF length and then POKE() the last value which is clumsy to say the least.

P#106348 2022-02-04 22:32
1

I agree that the third argument should really be treated as unsigned, where 0x8000..0xffff are 32768..65535.

For the moment you could bodge it with something like this, so your outer source code doesn't look ugly:

_memset,memset=memset,function(d,v,l)
  while(l<0) _memset(d,v,32767) d+=32767 l-=32767
  return _memset(d,v,l)
end

-- probably need memcpy too
_memcpy,memcpy=memcpy,function(d,s,l)
  while(l<0) _memcpy(d,s,32767) d+=32767 s+=32767 l-=32767
  return _memcpy(d,s,l)
end

With that, you could even clear vram + upper ram, e.g. memset(0x6000,0,0xa000). Basically, it'd work the way you expect, except it's a bodge.

P#106353 2022-02-04 23:22 ( Edited 2022-02-05 02:28)

Ah, ooh ... Not quite so busy for me, @Felice. I am just using this:

memset(0x8000,0,0x7fff)
poke(0xffff,0)
P#106357 2022-02-04 23:50

Right, I was just offering a bodge so you could write it the way it ought to be, and then if zep fixes memset() and memcpy(), then you just delete the bodge and your code is good to go.

P#106371 2022-02-05 02:24 ( Edited 2022-02-05 02:29)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 13:20:50 | 0.022s | Q:18