|
6 | 6 | #include "assembleblock.h"
|
7 | 7 | #include "asar_math.h"
|
8 | 8 | #include "unicode.h"
|
| 9 | +#include "platform/thread-helpers.h" |
9 | 10 |
|
10 | 11 | #if defined(windows)
|
11 | 12 | # define NOMINMAX
|
@@ -541,18 +542,29 @@ int main(int argc, const char * argv[])
|
541 | 542 | string stddefinespath = STR dir(argv[0]) + "stddefines.txt";
|
542 | 543 | parse_std_defines(stddefinespath);
|
543 | 544 |
|
544 |
| - for (pass=0;pass<3;pass++) |
| 545 | + auto execute_patch = [&]() |
545 | 546 | {
|
546 |
| - //pass 1: find which bank all labels are in, for label optimizations |
547 |
| - // freespaces are listed as above 0xFFFFFF, to find if it's in the ROM or if it's dynamic |
548 |
| - //pass 2: find where exactly all labels are |
549 |
| - //pass 3: assemble it all |
550 |
| - initstuff(); |
551 |
| - assemblefile(asmname); |
552 |
| - // RPG Hacker: Necessary, because finishpass() can throws warning and errors. |
553 |
| - callstack_push cs_push(callstack_entry_type::FILE, filesystem->create_absolute_path(nullptr, asmname)); |
554 |
| - finishpass(); |
555 |
| - } |
| 547 | + for (pass=0;pass<3;pass++) |
| 548 | + { |
| 549 | + //pass 1: find which bank all labels are in, for label optimizations |
| 550 | + // freespaces are listed as above 0xFFFFFF, to find if it's in the ROM or if it's dynamic |
| 551 | + //pass 2: find where exactly all labels are |
| 552 | + //pass 3: assemble it all |
| 553 | + initstuff(); |
| 554 | + assemblefile(asmname); |
| 555 | + // RPG Hacker: Necessary, because finishpass() can throws warning and errors. |
| 556 | + callstack_push cs_push(callstack_entry_type::FILE, filesystem->create_absolute_path(nullptr, asmname)); |
| 557 | + finishpass(); |
| 558 | + } |
| 559 | + return true; |
| 560 | + }; |
| 561 | +#if defined(RUN_VIA_FIBER) |
| 562 | + run_as_fiber(execute_patch); |
| 563 | +#elif defined(RUN_VIA_THREAD) |
| 564 | + run_as_thread(execute_patch); |
| 565 | +#else |
| 566 | + execute_patch(); |
| 567 | +#endif |
556 | 568 |
|
557 | 569 | new_filesystem.destroy();
|
558 | 570 | filesystem = nullptr;
|
|
0 commit comments