Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | import glob from "glob"; import { promisify } from "util"; import { pathExists, readFile, writeFile } from "fs-extra"; import Path from "path"; import l10n from "shared/lib/lang/l10n"; const globAsync = promisify(glob); type BuildOptions = { colorEnabled: boolean; sgb: boolean; musicDriver: string; debug: boolean; platform: string; batteryless: boolean; targetPlatform: "gb" | "pocket"; cartType: "mbc3" | "mbc5"; compilerPreset: number; }; export const getBuildCommands = async ( buildRoot: string, { colorEnabled, sgb, musicDriver, debug, platform, batteryless, targetPlatform, cartType, compilerPreset, }: BuildOptions ) => { const srcRoot = `${buildRoot}/src/**/*.@(c|s)`; const buildFiles = await globAsync(srcRoot); const output = []; const CC = platform === "win32" ? `..\\_gbstools\\gbdk\\bin\\lcc` : `../_gbstools/gbdk/bin/lcc`; for (const file of buildFiles) { Iif (musicDriver === "huge" && file.indexOf("GBT_PLAYER") !== -1) { continue; } Iif (musicDriver !== "huge" && file.indexOf("HUGE_TRACKER") !== -1) { continue; } const objFile = `${file .replace(/src.*\//, "obj/") .replace(/\.[cs]$/, "")}.o`; Iif (!(await pathExists(objFile))) { const buildArgs = [ `-Iinclude`, `-Wa-Iinclude`, `-Wa-I../_gbstools/gbdk/lib/small/asxxxx`, `-Wl-a`, `-Wf-MMD`, `-c`, ]; buildArgs.push(`-Wf"--max-allocs-per-node ${compilerPreset ?? 3000}"`); Iif (colorEnabled) { buildArgs.push("-DCGB"); } Iif (sgb) { buildArgs.push("-DSGB"); } if (musicDriver === "huge") { buildArgs.push("-DHUGE_TRACKER"); } else { buildArgs.push("-DGBT_PLAYER"); } Iif (batteryless) { buildArgs.push("-DBATTERYLESS"); } const rumbleBit = cartType === "mbc3" ? "0x20u" : "0x08u"; buildArgs.push(`-DRUMBLE_ENABLE=${rumbleBit}`); Iif (debug) { buildArgs.push("-Wf--fverbose-asm"); buildArgs.push("-Wf--debug"); buildArgs.push("-Wl-m"); buildArgs.push("-Wl-w"); buildArgs.push("-Wl-y"); buildArgs.push("-DVM_DEBUG_OUTPUT"); buildArgs.push("-Wf--nolospre"); buildArgs.push("-Wf--nogcse"); } Iif (targetPlatform === "pocket") { buildArgs.push("-msm83:ap"); } buildArgs.push( "-c", "-o", Path.relative(buildRoot, objFile), Path.relative(buildRoot, file) ); output.push({ label: `${l10n("COMPILER_COMPILING")}: ${Path.relative( buildRoot, file )}`, command: CC, args: buildArgs, }); } } return output; }; export const buildPackFile = async (buildRoot: string) => { const output = []; const srcRoot = `${buildRoot}/src/**/*.@(c|s)`; const buildFiles = await globAsync(srcRoot); for (const file of buildFiles) { const objFile = `${file .replace(/src.*\//, "obj/") .replace(/\.[cs]$/, "")}.o`; output.push(objFile); } return output.join("\n"); }; export const getPackFiles = async (buildRoot: string) => { const output = []; const srcRoot = `${buildRoot}/src/**/*.@(c|s)`; const buildFiles = await globAsync(srcRoot); for (const file of buildFiles) { const objFile = `${file .replace(/src.*\//, "obj/") .replace(/\.[cs]$/, "")}.o`; output.push(objFile); } return output; }; export const buildLinkFile = async (buildRoot: string, cartSize: number) => { const output = [`-g __start_save=${cartSize - 4}`]; const srcRoot = `${buildRoot}/src/**/*.@(c|s)`; const buildFiles = await globAsync(srcRoot); for (const file of buildFiles) { const objFile = `${file .replace(/src.*\//, "obj/") .replace(/\.[cs]$/, "")}.rel`; output.push(objFile); } return output.join("\n"); }; export const buildPackFlags = (packFilePath: string, batteryless = false) => { return ([] as Array<string | number>).concat( // General ["-b", 5, "-f", 255, "-e", "rel", "-c"], // Batteryless batteryless ? ["-a 4"] : [], // Input ["-i", packFilePath] ); }; export const buildLinkFlags = ( linkFile: string, name = "GBSTUDIO", cartType: string, color = false, sgb = false, colorOnly = false, musicDriver = "gbtplayer", debug = false, targetPlatform = "gb" ) => { const validName = name .toUpperCase() .replace(/[^A-Z]*/g, "") .substring(0, 15) || "GBSTUDIO"; const cart = cartType === "mbc3" ? "0x10" : "0x1E"; const gameFile = colorOnly ? "game.gbc" : "game.gb"; return ([] as Array<string>).concat( // General [ `-Wm-yt${cart}`, "-Wm-yoA", "-Wm-ya4", "-Wl-j", "-Wl-m", "-Wl-w", "-Wm-yS", "-Wl-klib", "-Wl-g.STACK=0xDF00", "-Wi-e", `-Wm-yn"${validName}"`, ], // Color color ? ["-Wm-yC"] : [], // SGB sgb ? ["-Wm-ys"] : [], // Pocket targetPlatform === "pocket" ? ["-msm83:ap"] : [], // Debug emulicious debug ? ["-Wf--debug", "-Wl-m", "-Wl-w", "-Wl-y"] : [], // Music Driver musicDriver === "huge" ? // hugetracker ["-Wl-lhUGEDriver.lib"] : // gbtplayer ["-Wl-lgbt_player.lib"], // Output targetPlatform === "gb" ? ["-o", `build/rom/${gameFile}`] : [], targetPlatform === "pocket" ? ["-o", "build/rom/game.pocket"] : [], [`-Wl-f${linkFile}`] ); }; export const makefileInjectToolsPath = async ( filename: string, buildToolsPath: string ) => { const makefile = await readFile(filename, "utf8"); const updatedMakefile = makefile.replace( /GBSTOOLS_DIR =.*/, `GBSTOOLS_DIR = ${Path.normalize(buildToolsPath)}` ); await writeFile(filename, updatedMakefile); }; export const buildMakeDotBuildFile = ({ cartType = "mbc5", color = false, sgb = false, batteryless = false, musicDriver = "gbtplayer", }) => { return ( `settings: ` + ([] as Array<string>) .concat( color ? ["CGB"] : ["DMG"], sgb ? ["SGB"] : [], musicDriver === "huge" ? ["hUGE"] : ["GBT"], cartType === "mbc3" ? ["MBC3"] : ["MBC5"], batteryless ? ["batteryless"] : [] ) .join(" ") ); }; |