Skip to content

Commit

Permalink
Update crt_core.c
Browse files Browse the repository at this point in the history
  • Loading branch information
LMP88959 authored May 13, 2023
1 parent 58da350 commit 60b0083
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,26 @@ crt_demodulate(struct CRT *v, int noise)
huecs >>= 11;

rn = v->rn;
#if (CRT_SYSTEM == CRT_SYSTEM_NTSCVHS)
line = ((rand() % 8) - 4) + 14;
#endif
for (i = 0; i < CRT_INPUT_SIZE; i++) {
int nn = noise;
#if (CRT_SYSTEM == CRT_SYSTEM_NTSCVHS)
rn = rand();
if (i > (CRT_INPUT_SIZE - CRT_HRES * (16 + ((rand() % 20) - 10))) &&
i < (CRT_INPUT_SIZE - CRT_HRES * (5 + ((rand() % 8) - 4)))) {
int ln, sn, cs;

ln = (i * line) / CRT_HRES;
crt_sincos14(&sn, &cs, ln * 8192 / 180);
nn = cs >> 8;
}
#else
rn = (214019 * rn + 140327895);

#endif
/* signal + noise */
s = v->analog[i] + (((((rn >> 16) & 0xff) - 0x7f) * noise) >> 8);
s = v->analog[i] + (((((rn >> 16) & 0xff) - 0x7f) * nn) >> 8);
if (s > 127) { s = 127; }
if (s < -127) { s = -127; }
v->inp[i] = s;
Expand Down

0 comments on commit 60b0083

Please sign in to comment.