mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-05 20:33:14 +00:00
changed #incbin to #embed (loosely based on C23 standard)
This commit is contained in:
parent
73c7ac5941
commit
c9354a83ea
@ -13,14 +13,15 @@
|
||||
#include <lz4.h>
|
||||
|
||||
// include the LZ4 binary data -> image_c64_multi_lz4[]
|
||||
|
||||
//#incbin "image-c64.multi.lz4"
|
||||
const char image_c64_multi_lz4[] = {
|
||||
#embed "image-c64.multi.lz4"
|
||||
};
|
||||
|
||||
/*
|
||||
CharData equ .
|
||||
ScreenData equ CharData+8000
|
||||
ColorData equ ScreenData+1000
|
||||
XtraData equ ColorData+1000
|
||||
CharData 8000 bytes
|
||||
ScreenData 1000 bytes
|
||||
ColorData 1000 bytes
|
||||
XtraData 2 bytes
|
||||
*/
|
||||
|
||||
void main() {
|
||||
|
@ -189,12 +189,12 @@ export class CodeProject {
|
||||
} else {
|
||||
// for .asm -- [.%]include "file"
|
||||
// for .c -- #include "file"
|
||||
let re2 = /^\s*[.#%]?(include|incbin)\s+"(.+?)"/gmi;
|
||||
let re2 = /^\s*[.#%]?(include|incbin|embed)\s+"(.+?)"/gmi;
|
||||
while (m = re2.exec(text)) {
|
||||
this.pushAllFiles(files, m[2]);
|
||||
}
|
||||
// for .c -- //#resource "file" (or ;resource or #resource)
|
||||
let re3 = /^\s*([;']|[/][/])#(resource|incbin)\s+"(.+?)"/gm;
|
||||
let re3 = /^\s*([;']|[/][/])#(resource)\s+"(.+?)"/gm;
|
||||
while (m = re3.exec(text)) {
|
||||
this.pushAllFiles(files, m[3]);
|
||||
}
|
||||
|
@ -273,22 +273,17 @@ export function linkLD65(step: BuildStep): BuildStepResult {
|
||||
}
|
||||
|
||||
function processIncbin(code: string) {
|
||||
let re3 = /^\s*([;']|[/][/])#incbin\s+"(.+?)"/gm;
|
||||
// find #incbin "filename.bin" and replace with C array declaration
|
||||
return code.replace(re3, (m, m1, m2) => {
|
||||
let filename = m2;
|
||||
let re3 = /^\s*#embed\s+"(.+?)"/gm;
|
||||
// find #embed "filename.bin" and replace with C array data
|
||||
return code.replace(re3, (m, m1) => {
|
||||
let filename = m1;
|
||||
let filedata = store.getFileData(filename);
|
||||
let bytes = convertDataToUint8Array(filedata);
|
||||
if (!bytes) throw new Error('#incbin: file not found: "' + filename + '"');
|
||||
if (!bytes) throw new Error('#embed: file not found: "' + filename + '"');
|
||||
let out = '';
|
||||
let ident = safeident(filename);
|
||||
console.log('#incbin', filename, ident, bytes.length);
|
||||
out += 'const unsigned char ' + ident + '[' + bytes.length + '] = {';
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
out += bytes[i].toString() + ',';
|
||||
}
|
||||
out += '};';
|
||||
console.log('incbin', out);
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user