Refactor the BIO2 code so that it can be used for additional games, see: iidxhook8 for example usage.
Specifically it addresses how other games (not IIDX) retrieve the port BIO2(VIDEO)(COM#) from device name instead of registry entry, and allows multiple ports to be opened (for DRS).
In GitLab by @xyen on Oct 12, 2019, 10:44
_Merges bio2-refactor -> master_
Refactor the BIO2 code so that it can be used for additional games, see: iidxhook8 for example usage.
Specifically it addresses how other games (not IIDX) retrieve the port `BIO2(VIDEO)(COM#)` from device name instead of registry entry, and allows multiple ports to be opened (for DRS).
In GitLab by @xyen on Oct 12, 2019, 11:28
added 1 commit
<ul><li>77211132 - bio2emu: Add missing CM hooks for device index retrieval</li></ul>
[Compare with previous version](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1049&start_sha=a492cee93e58da01189e767c15920238c46f17af)
In GitLab by @xyen on Oct 12, 2019, 11:37
added 1 commit
<ul><li>b6216c69 - bio2emu: Add missing CM hooks for device index retrieval</li></ul>
[Compare with previous version](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1050&start_sha=7721113208ba5a969d1657e30a88ab1ddf90a7b6)
Have all static (const) vars at the top of the file. Feel free to create multiple blocks with them to introduce grouping for stuff that kinda belongs together.
Have all static (const) vars at the top of the file. Feel free to create multiple blocks with them to introduce grouping for stuff that kinda belongs together.
I see the point for this start init, do some other init, end init block thing. However, I suggest merging them to a single call to avoid such state machines requiring a specific order (feels like a D3D API with BeginScene ... EndScene).
Suggestion (Note: not tested nor compiled, just a draft):
void bio2emu_port_init(struct bio2emu_port** bio2_emu, size_t num_bio2_emu)
{
array_init(&bio2_active_ports);
// BIO2 seems like ACIO with just 1 device
ac_io_emu_init(&bio2_emu->acio, bio2_emu->wport);
rs232_hook_add_fd(bio2_emu->acio.fd);
for (int i = 0; i < num_bio2_emu; i++) {
*array_append(struct bio2emu_port*, &bio2_active_ports) = bio2_emu[i];
}
bio2emu_setupapi_hook_init(&bio2_active_ports);
}
iohook is doing something similar with a list of IO hooks to insert on init.
I see the point for this start init, do some other init, end init block thing. However, I suggest merging them to a single call to avoid such state machines requiring a specific order (feels like a D3D API with BeginScene ... EndScene).
Suggestion (Note: not tested nor compiled, just a draft):
```
void bio2emu_port_init(struct bio2emu_port** bio2_emu, size_t num_bio2_emu)
{
array_init(&bio2_active_ports);
// BIO2 seems like ACIO with just 1 device
ac_io_emu_init(&bio2_emu->acio, bio2_emu->wport);
rs232_hook_add_fd(bio2_emu->acio.fd);
for (int i = 0; i < num_bio2_emu; i++) {
*array_append(struct bio2emu_port*, &bio2_active_ports) = bio2_emu[i];
}
bio2emu_setupapi_hook_init(&bio2_active_ports);
}
```
iohook is doing something similar with a list of IO hooks to insert on init.
In GitLab by @xyen on Oct 12, 2019, 19:49
Commented on [src/main/iidxhook8/dllmain.c line 152](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-2652fef86a3a811b7b9013de2364403dR152)
I prefer not to do it like this, the purpose of having it split up like this is to allow the end user to do something like this:
```cpp
bio2emu_init_start();
drs_bi2a_main_init(&bio2_emu1, iidxhook8_config_io.disable_poll_limiter);
drs_bi2a_lighting_init(&bio2_emu2);
bio2emu_init_end();
```
Ok, I see. Then, I would still just unwrap the setupapi call in bio2emu_init_end as it doesn't really do anything else. It makes it more clear when you can read it explicitly that you have to do the setupapi hook call at the end. Also, do you really have to do it at the end? I mean, does the order matter for the setupapi hook call?
Ok, I see. Then, I would still just unwrap the setupapi call in bio2emu_init_end as it doesn't really do anything else. It makes it more clear when you can read it explicitly that you have to do the setupapi hook call at the end. Also, do you really have to do it at the end? I mean, does the order matter for the setupapi hook call?
Technically, as soon as you hook setupapi, the array could potentially be used, and I'd prefer not to have to deal with locks inside of IO code. I suppose though at this point in init, the IO thread doesn't even exist yet, so it should be safe to move the setupapi call earlier.
In GitLab by @xyen on Oct 12, 2019, 20:00
Commented on [src/main/iidxhook8/dllmain.c line 152](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-2652fef86a3a811b7b9013de2364403dR152)
Technically, as soon as you hook setupapi, the array could potentially be used, and I'd prefer not to have to deal with locks inside of IO code. I suppose though at this point in init, the IO thread doesn't even exist yet, so it should be safe to move the setupapi call earlier.
You want to keep this calls close together for sure. However, the hook bootstrap has to ensure this code gets executed as early as possible to avoid such issues. I just want us to avoid introducing dependencies like call orders that are not required. Because when I look at your start-end block, I got the impression that end must always be at the end.
You want to keep this calls close together for sure. However, the hook bootstrap has to ensure this code gets executed as early as possible to avoid such issues. I just want us to avoid introducing dependencies like call orders that are not required. Because when I look at your start-end block, I got the impression that end must always be at the end.
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/bio2emu/setupapi.c line 206](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-3c217ff3b68d72db3dd5de0ab497212dR206)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#2ad46f6d320896c6603d86fbef106b1688595e73_206_237)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/bio2emu/setupapi.c line 209](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-3c217ff3b68d72db3dd5de0ab497212dR209)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#2ad46f6d320896c6603d86fbef106b1688595e73_209_237)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/iidxhook8/bi2a.h line 110](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-ac02ca76ecec73a09edecf98ad64ea9bR110)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#fcc7d8da37a41c5ea5f11a53cdda053c74ae9e2d_110_109)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/iidxhook8/bi2a.h line 93](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-ac02ca76ecec73a09edecf98ad64ea9bL93)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#fcc7d8da37a41c5ea5f11a53cdda053c74ae9e2d_93_93)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/iidxhook8/dllmain.c line 152](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-2652fef86a3a811b7b9013de2364403dR152)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#06b9ed9a6f9af2bd1cc0a7cf2e113e0e74d69f25_152_152)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/bio2emu/setupapi.c line 350](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-3c217ff3b68d72db3dd5de0ab497212dR350)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#2ad46f6d320896c6603d86fbef106b1688595e73_350_365)
In GitLab by @xyen on Oct 12, 2019, 20:17
added 3 commits
<ul><li>1c415eb2 - bio2emu: Remove requirement for bio2emu_init_end to be called</li><li>0c1bbe08 - iidxhook8: Rename bi2a structs to be more clear</li><li>0f04d5ef - bio2emu: cleanup setupapi code a bit</li></ul>
[Compare with previous version](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079)
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on [src/main/iidxhook8/bi2a.h line 113](https://github.com/djhackersdev/bemanitools/compare/073392407ad2a8b235f928a134f3a996e9bc8a14..b6216c696e7f0f7a87f1ef644d33a34401e7f079#diff-ac02ca76ecec73a09edecf98ad64ea9bR113)
changed this line in [version 4 of the diff](/djhackers/bemanitools/merge_requests/4/diffs?diff_id=1051&start_sha=b6216c696e7f0f7a87f1ef644d33a34401e7f079#fcc7d8da37a41c5ea5f11a53cdda053c74ae9e2d_113_113)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In GitLab by @xyen on Oct 12, 2019, 10:44
Merges bio2-refactor -> master
Refactor the BIO2 code so that it can be used for additional games, see: iidxhook8 for example usage.
Specifically it addresses how other games (not IIDX) retrieve the port
BIO2(VIDEO)(COM#)from device name instead of registry entry, and allows multiple ports to be opened (for DRS).In GitLab by @xyen on Oct 12, 2019, 11:28
added 1 commit
Compare with previous version
In GitLab by @xyen on Oct 12, 2019, 11:37
added 1 commit
b6216c69- bio2emu: Add missing CM hooks for device index retrievalCompare with previous version
Nit: Empty line between control block and other control blocks or lines.
Nit: Empty line between control block and other control blocks or lines.
Have all static (const) vars at the top of the file. Feel free to create multiple blocks with them to introduce grouping for stuff that kinda belongs together.
I see the point for this start init, do some other init, end init block thing. However, I suggest merging them to a single call to avoid such state machines requiring a specific order (feels like a D3D API with BeginScene ... EndScene).
Suggestion (Note: not tested nor compiled, just a draft):
iohook is doing something similar with a list of IO hooks to insert on init.
Please fix the naming with proper namespacing: iidxhook8_bi2a_light
Also consider all structs above this one.
That's good to have. We should use this more often, especially on packed structs.
Forward declaration?
Good comment to have.
Please use the PR template as it provides good guidance for providing information on what needs to be done (also as checkboxes).
In GitLab by @xyen on Oct 12, 2019, 19:49
Commented on src/main/iidxhook8/dllmain.c line 152
I prefer not to do it like this, the purpose of having it split up like this is to allow the end user to do something like this:
Ok, I see. Then, I would still just unwrap the setupapi call in bio2emu_init_end as it doesn't really do anything else. It makes it more clear when you can read it explicitly that you have to do the setupapi hook call at the end. Also, do you really have to do it at the end? I mean, does the order matter for the setupapi hook call?
In GitLab by @xyen on Oct 12, 2019, 20:00
Commented on src/main/iidxhook8/dllmain.c line 152
Technically, as soon as you hook setupapi, the array could potentially be used, and I'd prefer not to have to deal with locks inside of IO code. I suppose though at this point in init, the IO thread doesn't even exist yet, so it should be safe to move the setupapi call earlier.
You want to keep this calls close together for sure. However, the hook bootstrap has to ensure this code gets executed as early as possible to avoid such issues. I just want us to avoid introducing dependencies like call orders that are not required. Because when I look at your start-end block, I got the impression that end must always be at the end.
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/bio2emu/setupapi.c line 206
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/bio2emu/setupapi.c line 209
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/iidxhook8/bi2a.h line 110
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/iidxhook8/bi2a.h line 93
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/iidxhook8/dllmain.c line 152
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/bio2emu/setupapi.c line 350
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
added 3 commits
1c415eb2- bio2emu: Remove requirement for bio2emu_init_end to be called0c1bbe08- iidxhook8: Rename bi2a structs to be more clear0f04d5ef- bio2emu: cleanup setupapi code a bitCompare with previous version
In GitLab by @xyen on Oct 12, 2019, 20:17
Commented on src/main/iidxhook8/bi2a.h line 113
changed this line in version 4 of the diff
In GitLab by @xyen on Oct 12, 2019, 20:17
resolved all threads
All right, lgtm now.
merged