13B4: init_hamming_table: Create 256 byte look up table of Hamming 8/4 decoded bytes.
init_hamming_table |
13B4 |
XOR A |
|
13B5 |
LD (hamming_table_counter),A |
|
13B8 |
LD HL,(hamming_decode_table_pointer) |
hamming_table_loop |
13BB |
PUSH HL |
|
13BC |
PUSH AF |
|
13BD |
XOR A |
|
13BE |
LD (P1_flag),A |
|
13C1 |
LD (P2_flag),A |
|
13C4 |
LD (P3_flag),A |
|
13C7 |
LD (P4_flag),A |
|
13CA |
LD A,(hamming_table_counter) |
|
13CD |
AND $A3 |
|
13CF |
JP PE,skip_P1 |
|
13D2 |
LD A,$01 |
|
13D4 |
LD (P1_flag),A |
skip_P1 |
13D7 |
LD A,(hamming_table_counter) |
|
13DA |
AND $8E |
|
13DC |
JP PE,skip_P2 |
|
13DF |
LD A,$01 |
|
13E1 |
LD (P2_flag),A |
skip_P2 |
13E4 |
LD A,(hamming_table_counter) |
|
13E7 |
AND $3A |
|
13E9 |
JP PE,skip_P3 |
|
13EC |
LD A,$01 |
|
13EE |
LD (P3_flag),A |
skip_P3 |
13F1 |
LD A,(hamming_table_counter) |
|
13F4 |
AND A |
|
13F5 |
JP PE,skip_P4 |
|
13F8 |
LD A,$01 |
|
13FA |
LD (P4_flag),A |
skip_P4 |
13FD |
LD A,(P1_flag) |
|
1400 |
LD B,A |
|
1401 |
LD A,(P2_flag) |
|
1404 |
LD C,A |
|
1405 |
LD A,(P3_flag) |
|
1408 |
LD D,A |
|
1409 |
LD A,(P4_flag) |
|
140C |
ADD A,B |
|
140D |
ADD A,C |
|
140E |
ADD A,D |
|
140F |
CP $04 |
|
1411 |
JR NZ,hamming_errors |
|
1413 |
CALL store_hamming_nibble |
|
1416 |
JP next_hamming_byte |
hamming_errors |
1419 |
LD A,(P1_flag) |
|
141C |
LD B,A |
|
141D |
LD A,(P2_flag) |
|
1420 |
LD C,A |
|
1421 |
LD A,(P3_flag) |
|
1424 |
ADD A,C |
|
1425 |
ADD A,B |
|
1426 |
CP $03 |
|
1428 |
JR NZ,P4_error |
|
142A |
LD A,(P4_flag) |
|
142D |
AND A |
|
142E |
JR NZ,P4_error |
|
1430 |
CALL store_hamming_nibble |
|
1433 |
JP next_hamming_byte |
P4_error |
1436 |
LD A,(P1_flag) |
|
1439 |
LD B,A |
|
143A |
LD A,(P2_flag) |
|
143D |
LD C,A |
|
143E |
LD A,(P3_flag) |
|
1441 |
ADD A,B |
|
1442 |
ADD A,C |
|
1443 |
CP $03 |
|
1445 |
JR Z,P1_error |
|
1447 |
LD A,(P4_flag) |
|
144A |
AND A |
|
144B |
JR Z,P1_error |
|
144D |
CALL store_hamming_error |
|
1450 |
JP next_hamming_byte |
P1_error |
1453 |
LD A,(P1_flag) |
|
1456 |
LD B,$00 |
|
1458 |
AND A |
|
1459 |
JR Z,P2_error |
|
145B |
INC B |
P2_error |
145C |
LD A,(P2_flag) |
|
145F |
AND A |
|
1460 |
JR Z,P3_error |
|
1462 |
SET 1,B |
P3_error |
1464 |
LD A,(P3_flag) |
|
1467 |
AND A |
|
1468 |
JR Z,correct_errors |
|
146A |
SET 2,B |
correct_errors |
146C |
LD C,B |
|
146D |
PUSH BC |
|
146E |
CALL store_hamming_nibble |
|
1471 |
POP BC |
|
1472 |
CALL correct_and_store_nibble |
next_hamming_byte |
1475 |
POP AF |
|
1476 |
POP HL |
|
1477 |
INC HL |
|
1478 |
INC A |
|
1479 |
LD (hamming_table_counter),A |
|
147C |
AND A |
|
147D |
JP NZ,hamming_table_loop |
|
1480 |
RET |