-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbake_rom.lua
46 lines (33 loc) · 1.23 KB
/
bake_rom.lua
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
util = require "util"
rom = {}
directory =
"/home/kitten/プロジェクト/Gameboy/Badboy/tests/blargg/cpu_instrs/"
rom.filename = "cpu_instrs.gb"
rom.file = io.open(directory .. rom.filename, "r")
rom.data = {}
util.file_to_bytes(rom.file, rom.data, 0x0000)
rom.directory =
"/home/kitten/.minecraft/saves/GB Emulator 1_18_2/datapacks/CraftBoyDatapack/data/craftboy/functions/banks/"
local file
for i = 0, math.floor(#rom.data / 0x4000) do
if i % 32 == 0 then
file = io.open(rom.directory .. "rom0_bank_" .. i .. ".mcfunction", "w")
-- file:write("say ROM0 BANK " .. i .. "\n")
pcall(function()
for j = 0x4000, 0x7FFF do
file:write("scoreboard players set " .. j - 0x4000 .. " rom " ..
rom.data[i * 0x4000 + j - 0x4000] .. "\n")
end
end)
file:close()
end
file = io.open(rom.directory .. "rom1_bank_" .. i .. ".mcfunction", "w")
-- file:write("say ROM1 BANK " .. i .. "\n")
pcall(function()
for j = 0x4000, 0x7FFF do
file:write("scoreboard players set " .. j .. " rom " ..
rom.data[i * 0x4000 + j - 0x4000] .. "\n")
end
end)
file:close()
end