shithub: pt2-clone

Download patch

ref: 1e0ed4cfef0787d6d538e72cf587e4bf5e8d1da2
parent: 5d295f00480a1531839272f737869f87afad93e2
author: Olav Sørensen <olav.sorensen@live.no>
date: Sun Mar 20 15:44:20 EDT 2022

Update pt2_tables.c

--- a/src/pt2_tables.c
+++ b/src/pt2_tables.c
@@ -86,64 +86,94 @@
 	0xB4, 0xA1, 0x8D, 0x78, 0x61, 0x4A, 0x31, 0x18
 };
 
-const int16_t periodTable[(37*16)+15] =
+const int16_t periodTable[(37*16)+15] = // contains 16 finetuned period sections
 {
+	// finetune 0 (no finetuning)
 	856,808,762,720,678,640,604,570,538,508,480,453,
 	428,404,381,360,339,320,302,285,269,254,240,226,
 	214,202,190,180,170,160,151,143,135,127,120,113,0,
+	
+	// finetune +1
 	850,802,757,715,674,637,601,567,535,505,477,450,
 	425,401,379,357,337,318,300,284,268,253,239,225,
 	213,201,189,179,169,159,150,142,134,126,119,113,0,
+
+	// finetune +2
 	844,796,752,709,670,632,597,563,532,502,474,447,
 	422,398,376,355,335,316,298,282,266,251,237,224,
 	211,199,188,177,167,158,149,141,133,125,118,112,0,
+
+	// finetune +3
 	838,791,746,704,665,628,592,559,528,498,470,444,
 	419,395,373,352,332,314,296,280,264,249,235,222,
 	209,198,187,176,166,157,148,140,132,125,118,111,0,
+
+	// finetune +4
 	832,785,741,699,660,623,588,555,524,495,467,441,
 	416,392,370,350,330,312,294,278,262,247,233,220,
 	208,196,185,175,165,156,147,139,131,124,117,110,0,
+
+	// finetune +5
 	826,779,736,694,655,619,584,551,520,491,463,437,
 	413,390,368,347,328,309,292,276,260,245,232,219,
 	206,195,184,174,164,155,146,138,130,123,116,109,0,
+
+	// finetune +6
 	820,774,730,689,651,614,580,547,516,487,460,434,
 	410,387,365,345,325,307,290,274,258,244,230,217,
 	205,193,183,172,163,154,145,137,129,122,115,109,0,
+
+	// finetune +7
 	814,768,725,684,646,610,575,543,513,484,457,431,
 	407,384,363,342,323,305,288,272,256,242,228,216,
 	204,192,181,171,161,152,144,136,128,121,114,108,0,
+
+	// finetune -8
 	907,856,808,762,720,678,640,604,570,538,508,480,
 	453,428,404,381,360,339,320,302,285,269,254,240,
 	226,214,202,190,180,170,160,151,143,135,127,120,0,
+
+	// finetune -7
 	900,850,802,757,715,675,636,601,567,535,505,477,
 	450,425,401,379,357,337,318,300,284,268,253,238,
 	225,212,200,189,179,169,159,150,142,134,126,119,0,
+
+	// finetune -6
 	894,844,796,752,709,670,632,597,563,532,502,474,
 	447,422,398,376,355,335,316,298,282,266,251,237,
 	223,211,199,188,177,167,158,149,141,133,125,118,0,
+
+	// finetune -5
 	887,838,791,746,704,665,628,592,559,528,498,470,
 	444,419,395,373,352,332,314,296,280,264,249,235,
 	222,209,198,187,176,166,157,148,140,132,125,118,0,
+
+	// finetune -4
 	881,832,785,741,699,660,623,588,555,524,494,467,
 	441,416,392,370,350,330,312,294,278,262,247,233,
 	220,208,196,185,175,165,156,147,139,131,123,117,0,
+
+	// finetune -3
 	875,826,779,736,694,655,619,584,551,520,491,463,
 	437,413,390,368,347,328,309,292,276,260,245,232,
 	219,206,195,184,174,164,155,146,138,130,123,116,0,
+
+	// finetune -2
 	868,820,774,730,689,651,614,580,547,516,487,460,
 	434,410,387,365,345,325,307,290,274,258,244,230,
 	217,205,193,183,172,163,154,145,137,129,122,115,0,
+
+	// finetune -1
 	862,814,768,725,684,646,610,575,543,513,484,457,
 	431,407,384,363,342,323,305,288,272,256,242,228,
 	216,203,192,181,171,161,152,144,136,128,121,114,0,
 
-	/* Arpeggio on -1 finetuned samples can do an overflown read from
-	** the period table. Here's the correct overflow values from the
-	** "CursorPosTable" and "UnshiftedKeymap" table, which are located
-	** right after the period table. These tables and their order didn't
-	** seem to change in the different PT1.x/PT2.x versions (I checked
-	** the source codes).
-	** PS: This is not a guess, these values *are* correct!
+	/* Arpeggio on -1 finetuned samples can do an out-of-bounds read from
+	** this table. Here's the correct overflow values from the
+	** "CursorPosTable" and "UnshiftedKeymap" table in the PTcode, which are
+	** located right after the period table. These tables and their order didn't
+	** seem to change in the different PT1.x/PT2.x versions (I checked the
+	** source codes).
 	*/
 	774,1800,2314,3087,4113,4627,5400,6426,6940,7713,
 	8739,9253,24625,12851,13365