Integration into emulator.
punesemu opened this issue · 11 comments
Hi LMP88959, first of all congratulations on your project, fantastic. I would like to integrate it into my emulator (https://github.com/punesemu/puNES) among the video filters. I have already seen the license and I know I could already do it, but I prefer to ask your permission, it seems more correct to me.
Hi, thank you for the kind words! Of course you can use it in your emulator, feel free to reach out if you run into any issues!
Another person integrated it into their emulator (https://github.com/L-Spiro/BeesNES), it could be helpful to see how they did it and what settings they used.
Thank you for your availability. I started the implementation and while compiling the project I saw these warnings, could they be a problem?
====================[ Build | punes | debug ]===================================
/home/sviluppo/clion-2022.2.4/bin/cmake/linux/x64/bin/cmake --build /home/sviluppo/personale/punes/build/clion/debug --target punes -j 14
[2/3] Building C object src/CMakeFiles/punes.dir/extra/NTSC-CRT/crt_core.c.o
/home/sviluppo/personale/punes/src/extra/NTSC-CRT/crt_core.c: In function ‘init_eq’:
/home/sviluppo/personale/punes/src/extra/NTSC-CRT/crt_core.c:188:25: warning: right shift count is negative [-Wshift-count-negative]
188 | f->lf = 2 * (sn >> (15 - EQ_P));
| ^~
/home/sviluppo/personale/punes/src/extra/NTSC-CRT/crt_core.c:194:25: warning: right shift count is negative [-Wshift-count-negative]
194 | f->hf = 2 * (sn >> (15 - EQ_P));
| ^~
/home/sviluppo/personale/punes/src/extra/NTSC-CRT/crt_core.c: In function ‘crt_demodulate’:
/home/sviluppo/personale/punes/src/extra/NTSC-CRT/crt_core.c:536:31: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
536 | for (pos = scanL; pos < scanR && cL < cR; pos += dx) {
Furthermore, since I would like to make it customizable, I wanted to ask you what the limits (minimum and maximum) are for each of the following parameters:
hue, brightness, contrast, saturation and black_point, white_point and noise.
Thank you for sending this, I just fixed those warnings and created a new patch/release v.2.2.2 for you:
https://github.com/LMP88959/NTSC-CRT/releases/tag/v.2.2.2
Regarding the minimums and maximums for the parameters, a user named binji made a simple web demo for the old first version of the program and they found decent limits for the parameters:
https://binji.github.io/NTSC-CRT/
You can try the demo out by dragging a .ppm file into the black region of the web page.
Thank you for sending this, I just fixed those warnings and created a new patch/release v.2.2.2 for you:
Many thx, the warnings are gone.
Regarding the minimums and maximums for the parameters, a user named binji made a simple web demo for the old first version of the program and they found decent limits for the parameters:
Okay, I based it on the limits set by Binji, even though I reduced the maximum value for the brightness to 100.
I implemented the filter but I noticed something strange, when I start the filter and the scanlines are active everything works fine
then I disable the scanlines and everything is okay
but when I enable them again the screen remains dirty from one of the old frames.
Know that every time I modify a parameter I reinitialize the struct CRT and the struct NTSC_SETTINGS ntsc, and I run a crt_init(). Any idea what the problem might be?
You need to clear the whole image when you change from no scanlines to scanlines because if scanlines are enabled then those rows of pixels (the gaps between the lines) will not get touched so it will just display whatever was there before.
Thanks so much for the tip, I solved it as you suggested only that I noticed something else, with the scanline enabled and with a noise value greater than or equal to 15 (the higher the more the defect is evident), the screen gets dirty (same problem as scanlines). Doing some tests I saw that this happens when the noise causes the screen to "jump" above and below. By cleaning the output surface at each frame the problem does not arise but I noticed that by enabling blending the image is much darker than when I do not clean the surface. Is there no other way?
If you want I can give you a compiled version to help you better understand what happens, you just have to tell me which Windows you use (although working under Linux I haven't yet tested the implementation on other operating systems but I think it should work without problems).
Oh I forgot, check out crt_main.c:
https://github.com/LMP88959/NTSC-CRT/blob/main/crt_main.c#L436
This function fades the image to black over time to act like the phosphors fading. Use this every frame after displaying the output. You can see how and where it is used in crt_main.c.
I think this will more or less solve your problems.
Yes, this solve the problem. 👍
Thx again.
Committed (punesemu/puNES@2f1aee8).
That's so cool! Thank you so much. By the way I have a PAL version of this filter as well: https://github.com/LMP88959/PAL-CRT