Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tostring #15

Open
shakna-israel opened this issue Jul 14, 2024 · 3 comments
Open

tostring #15

shakna-israel opened this issue Jul 14, 2024 · 3 comments

Comments

@shakna-israel
Copy link

I'm honestly just sort of fishing here.

It works in mGBA, so the problem might not be in BPCore-Engine.

However, on my GB300, I get a crash if I either call tostring or string.format. The overlay turns blue, and processing freezes.

I have no real idea where or why this happens. Because I do think both of those are included in BPCE, because it does work under an emulator. I do know the GB300's emulators are not well respected, because they do have faults.

Kinda hard to output a highscore, and I don't particularly want to rewrite tostring in Lua.

@shakna-israel
Copy link
Author

I think it's a memory problem. Probably?

I managed to stop the crashes with this insane little bit o' code:

do
	local std_tostring = tostring
	tostring = function(i)
		 if i == 0 then
			return "0"
		 elseif i < 0 then
			return "-" .. tostring(-i)
		 else
			local str = ""
			while i > 0 do
				local digit = i % 10
				str = std_tostring(digit) .. str
				i = math.floor(i / 10)
			end
			return str
		 end
	end
end

@evanbowman
Copy link
Owner

Hi! I could try to debug it if you have some sample code, and do you know what emulator that the GB300 uses? If I can run the code (or a minimal subset of it that reproduces the problem), along with a copy of the emulator, I may be able to resolve the problem. Unfortunately, without either the GB300 or the emulator that the GB300 uses to run GBA games, it could be difficult for me to diagnose the issue. tostring and string.format are both built into the Lua runtime, for it to be a software issue, I would think that these functions would need to be bugged in the Lua implementation, which is unlikely, although there may be a problem elsewhere in the engine code that results in a memory fault downstream. All of this is a bit speculative on my part.

@shakna-israel
Copy link
Author

Afraid the only real thing I know about the GB300's GBA is it uses this. It is a bit hacky.

I did actually use Lua's tostring - just sharded the value so it was smaller, so I'm assuming it was some sort of memory fault in the GB300's implementation. Maybe it has some sort of limit on the size that can be allocated at any one time?

Anyways, it's probably way out of scope for BPCore-Engine. Just me fooling around to get stuff on a physical device, because that's fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants