MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadCodeFromFile

Function loadCodeFromFile

Source/Node/TIC80Node.cpp:246–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246static bool loadCodeFromFile(String codeFile, tic_cartridge* cart) {
247 if (!cart) return false;
248
249 auto codeData = SharedContent.load(codeFile);
250 if (!codeData.first || codeData.second == 0) {
251 Error("TIC80Node: failed to load code file: {}", codeFile.toString());
252 return false;
253 }
254
255 s32 codeSize = s_cast<s32>(codeData.second);
256 if (codeSize > TIC_CODE_SIZE) {
257 Error("TIC80Node: failed to load code file: {}\ncode file size ({}) exceeds TIC_CODE_SIZE ({})", codeFile.toString(), codeSize, TIC_CODE_SIZE);
258 return false;
259 }
260
261 memcpy(cart->code.data, codeData.first.get(), codeSize);
262 if (codeSize < TIC_CODE_SIZE) {
263 cart->code.data[codeSize] = '\0';
264 }
265
266 return true;
267}
268
269static bool mergeCartResources(tic_cartridge* target, const tic_cartridge* source) {
270 if (!target || !source) return false;

Callers 3

initMethod · 0.85
mergeTicMethod · 0.85
mergePngMethod · 0.85

Calls 5

loadMethod · 0.65
toStringMethod · 0.65
getMethod · 0.65
ErrorEnum · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected