Oh, found some funky functions from bsnes...
[lsnes.git] / src / emulation / make-slots.lua
blobb0b0e132c4fa1a03f0b350f4b94ae7de8acb8f38
1 nextsym = 0;
3 makesymbol = function()
4 nextsym = nextsym + 1;
5 return "X"..nextsym;
6 end
8 if not arg[1] then
9 error("Expected input file");
10 end
11 dofile(arg[1]);
13 for i = 1,#slots do
14 local slot = slots[i];
15 print("namespace slotdefs");
16 print("{");
17 ssyms = {};
18 for j=1,#(slot.slots) do
19 local xslot = slot.slots[j];
20 local ssym = makesymbol();
21 local ssym2 = makesymbol();
22 table.insert(ssyms, ssym2);
23 local s;
24 s = "\tstruct core_romimage_info_params "..ssym.." = {";
25 s = s .. "\"" .. xslot.iname .. "\", ";
26 s = s .. "\"" .. xslot.hname .. "\", ";
27 s = s .. xslot.mandatory .. ", ";
28 s = s .. xslot.mode .. ", ";
29 s = s .. xslot.header;
30 s = s .. "};";
31 print(s);
32 print("\tcore_romimage_info "..ssym2.."("..ssym..");");
33 end
34 print("}");
35 local s;
36 s = "core_romimage_info* "..slot.symbol.."[] = {";
37 for j = 1,#ssyms do
38 s = s .. "&slotdefs::" .. ssyms[j] .. ",";
39 end
40 s = s .. "NULL};";
41 print(s);
42 end