Philips VP406 LaserDisc Player Repair/Check VR Timing Function Execution
Jump to navigation
Jump to search
An annotated check_vr_timing function from the ROM, using two values, 20ms and 18.25ms, which is what should be present vs what we are seeing for the VR timings. This helped confirm our suspicions that there is an issue with the vertical reference timing.
/* WARNING: Removing unreachable block (CODE,0x0755) */
/* WARNING: Removing unreachable block (CODE,0x075c) */
/* WARNING: Removing unreachable block (CODE,0x075f) */
/* this is the failing func in trace 3 and the one that causes a reset to main()
seems to start by lookig for VR changing
not yet worked out what it does if VR has good timing
bails out in trace3 by seding "025" to the display */
void check_vr_timings_and_?(void)
{
char cVar1;
bool bVar2;
byte counter_3;
char loops;
byte bVar3;
byte vr_time_low_byte;
byte vr_time_high_byte;
window_pulse_short();
27.7 = false;
loops = 10;
counter_3 = 3;
TL1 = 0;
TH1 = 0;
TR1 = true;
do {
bVar2 = INT0;
} while (bVar2 != false);
do {
bVar2 = INT0;
} while (bVar2 != true);
TL1 = 0;
TH1 = 0;
do {
window_pulse_short();
do {
bVar2 = INT0;
} while (bVar2 != false);
do {
bVar2 = INT0;
} while (bVar2 != true);
/* save the time it took to go high / low
two bytes (high bits and low bits)
our VR signal is 18.25ms (0.01825 seconds)
as far as i understand from the cpu:
two bytes 2^16 = 65536
(18.25e-3 * 12e6) / 12 = 18250 ticks
TH TL
0100 0111 0100 1010
47 4A
if it was actually 20ms
(20e-3 * 12e6) / 12 = 20000
0100 1110 0010 0000
4e 20
*/
vr_time_low_byte = TL1;
vr_time_high_byte = TH1;
TL1 = 0;
TH1 = 0;
/* is it less than 64?
shift that bit to to the most significant bit of the byte (i.e. 128) */
cVar1 = (vr_time_high_byte < 64) << 7;
if (cVar1 < '\0') {
LAB_CODE_07b2:
counter_3 = counter_3 + 2;
}
else {
/* shift cVar back for some reason, so (12 - 1), if the high byte was less than
64. this would set bVar2 to 11.
if ((high_byte - 64) < 11)
cVar1 = 128
---- for the example above of 20ms, 0x4e-64 would mean cVar1 is 128
----- for 18.25ms, 0x47 - 64, would also mean cVar1 is 128
bVar2 = high_byte - 64 - 11
----- for 20ms, bVar2 would be 3
----- for 18.25ms, bVar2 would be 0 */
bVar3 = 12 - (cVar1 >> 7);
cVar1 = (vr_time_high_byte - 64 < bVar3) << 7;
bVar3 = (vr_time_high_byte - 64) - bVar3;
/* if cVar1 < 0
if cVar1 < bVar2
cVar1 = 128
tmp = (cVar1 >> 7) <= (low_byte + 2)
if cVar1 < 0 or (bVar2 == 246 and (112-tmp))
goto 07b2
---- in both cases (20ms and 18.25ms) cVar1 is greater than bVar2 , so we can
skip */
if (cVar1 < '\0') {
cVar1 = (246 < bVar3) << 7;
if ((cVar1 < '\0') || ((bVar3 == 0xf6 && (0x70U - (cVar1 >> 7) <= vr_time_low_byte + 2))))
goto LAB_CODE_07b2;
2b.5 = false;
}
else {
/*
-- in our case both (cVar1 >> 7) is 1
so, 4 (unsigned) - 1, so 3, if 3 is less than or equal to bVar2 (20ms=3,
18.25ms=0)
so in the case of 18ms, we would jump to 07b2
for 20ms we would continue to 07c7 */
if (4U - (cVar1 >> 7) <= bVar3) goto LAB_CODE_07b2;
2b.5 = true;
}
counter_3 = counter_3 - 1;
if (counter_3 == 0) goto LAB_CODE_07c7;
}
loops = loops + -1;
} while (loops != 0);
DAT_INTMEM_54_error_code? = 27;
LAB_CODE_07c7:
/* this is where we want to end up if the vr signal is ok */
if (DAT_INTMEM_54_error_code? == 255) {
TR1 = false;
TL1 = 0;
TH1 = 0;
27.7 = true;
window_pulse_short();
return;
}
send_video_insert_display_data_as_dec(0xb1,DAT_INTMEM_54_error_code?);
window_pulse_short();
main();
return;
}