So how does the track data work exactly?

There's special byte patterns that get interpreted as a finish line, a slick, a checkpoint and a score/time display.

We can see this better if we rewrite the prtbyte function to label the bits on the printout and to show byte boundaries:

Code
function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write(i) else io.write (" ") end end io.write("|") end

fnamestable = {"/mnt/z/mame/roms/lemans/005837.n5","/mnt/z/mame/roms/lemans/005838.n4","/mnt/z/mame/roms/lemans/005839.n6"} for fni,fn in pairs(fnamestable) do f = io.open(fn,"r") a = f:read("*a") for z = 0,0x7ff,0x200 do print(fn, z) for y=0,31 do for x=0,15 do adr = (x | (y<<4)) + z b = a:byte(1+adr) if x==0 then io.write("adr:"..string.format("%3x",adr)) end if x~=7 then prtbyte(b) end end print() end print(fn,z,"end") end end  fn = "/mnt/z/mame/roms/lemans/005837.n5" f = io.open(fn,"r") a = f:read("*a")  for x = 0,31 do print(fn,x) for y=0,7 do adr = (y | (((x & 0x10)>>4) << 3) | ((x & 0xf)<<5)) | (2^9) | (2^10) io.write(string.format("%2x",adr).." ") b = a:byte(1+adr) prtbyte(b) adr = adr | (2^4) b= a:byte(1+adr) prtbyte(b) print("  "..string.format("%2x",adr)) end print("------") end




/mnt/z/mame/roms/lemans/005837.n5	0
adr:  0 6  3210| 6      | 6 4    | 6 4   0| 6 4  1 | 65   1 | 654  1 |7     10|7  4  10|7  4  1 |7 5   1 |7 54  1 |7 54   0|7 54    |76      |
adr: 1076  3210|76  321 |7 54321 |7 5432 0|7 5432  |7 5 32  |7  432  |7   3 10| 6543 10| 65432  | 65 32  | 6 432  | 6 432 0| 6 4321 | 6  321 |
adr: 207   3210|        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5     |        |        |        |        |        |
adr: 30        |        |  5     |        |        | 6543  0|        |        |        |    3   |        |        |        |        |        |
adr: 40        |        | 6      |        | 65 32 0| 6543  0|        |        |        |      1 |        |        |        |        |        |
adr: 50        |        | 6      |        |        | 6543  0|        |        | 65 32 0|        |7       |        |        |        |        |
adr: 60        |        | 6      |        |        | 6543  0| 65 32 0|        |        |        |  5     |        |        |        |        |
adr: 70        |        | 6      |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7       |    3   |        |        |        |        |
adr: 80        |        | 6      |   4    |  543  0|        |   4   0|        |        |  5     |      1 |        |        |        |        |
adr: 90        |        | 6      |   4    |  543  0|        |    3 1 |        |        |    3   |        |7       |        |        |        |
adr: a0        |        | 6      |   4    |   4 2 0| 6 4 2  |     2  |     2 0| 6 4    |      1 |        |  5     |        |        |        |
adr: b0        |        | 6      |   4    |        |       0|        |   4    |     2  |        |7       |    3   |        |        |        |
adr: c0        |        | 6      |   4    |        |        |7       |   4    |       0|        | 65     |     2  |        |        |        |
adr: d0        |        |  5     |    3 1 |7 5 3 1 |7       |  5     |   4    |        |7       | 6  3   |     2  |        |        |        |
adr: e0        |        |   4    |     2  |  5     |  5     |    3 1 |7 5     | 6      |7       | 6   2  |     2  |        |        |        |
adr: f0        |        |     2  |       0| 6      |    3   |        |        | 6      |7       | 65  2  |     2  |        |        |        |
adr:100        |        |       0| 65 32 0| 6      |      1 |        |        |7       |7       | 6   2  |     2  |        |        |        |
adr:110        |        |       0| 65 32 0| 6      |7       |7 5 3 1 |7 5 3 1 |       0| 6      |  5 3   |     2  |        |        |        |
adr:120        |        |     2  |       0|       0|  5     |        |        |      1 |  5     | 6 43  0|     2  |        |        |        |
adr:130        |        |   4    |     2  |      1 |    3   |        |        |    3   |    3   | 6 43  0|    3   |        |        |        |
adr:140        |        |  5     |    3   |     2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4    |        |        |        |
adr:150        |        | 6      |   4    |   4    |        |        |   43  0| 65 32 0|        |        |    3   |        |        |        |
adr:160        |        | 6      |   4    |  5     |        |        |   43  0| 65 32 0|        |        |     2  |        |        |        |
adr:170        |        | 6      |   4    |  5     |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:180        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:190        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:1a0        |        | 6      |    3 1 |7 5 3 1 |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:1b0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1c0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1d0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1e0        |        |  5     |        | 65432 0|        |        |        |        |        |        |    3   |        |        |        |
adr:1f0        |        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5     |        |        |        |
/mnt/z/mame/roms/lemans/005837.n5	0	end
[Linked Image from i.imgur.com]



So all data coming from the roms is inverted.
And different bit patterns will do different items:
Code
65 32 0 is a slick       pattern 01 (24)  not 2 4 reversed = not 4 2
65432 0 is finish line   pattern 00 (24)  not 2 not 4 reversed = 4 2
6543  0 is checkpoint   65 is checkpoint 1
6 43  0 is checkpoint   6  is checkpoint 2
 543  0 is checkpoint    5 is checkpoint 3
  43  0 is checkpoint      is checkpoint 4

checkpoint is pattern 10 (24) 2 not 4 reversed = 4 not 2 and 65 determine checkpoint number

   3  0 is score   pattern 11 (24) 2 4  reversed is not 4 not 2

=========================

0 3 not 1 is special data  (that is one of the finish,slick,checkpoint or score)

Bits 0 1 and 3 determine special data:

[Linked Image from i.imgur.com]

bits 2 and 4 get put into a 9321 decoder to determine the special item to display

bits 5 and 6 determine the checkpoint number

[Linked Image from i.imgur.com]