# Remapping the "b" key in list.com

## Introduction

I use list.com as my pager in FreeDOS.

The "B" and "b" keys skip to the end of the file, which annoys me.
My muscle memory is accustomed to using those keys to go a page back
in several Unix programs.  I wish to remap these keys in list.com to
do the same.

I have multiple versions of list.com.
I have list.doc version 9.1.

## The WHAT table

The documentation describes the WHAT table as being 259 records long,
each record being one byte large.  The record index corresponds to a
keyboard combination.  The record value corresponds to an internal
function number.  The lowercase and uppercase keys are mapped
separately to the same function number.

The documentation describes function 9 as "Up to previous line".  This
is wrong.  A more correct description would be "Display previous page"
or "Page Up".

## Finding the WHAT table offset

Version 9.0c is the last shareware version that can access network shares.
In version 9.0c the WHAT table is at memory offset 0x404

Version 9.6x is the newest version, and it has LFN support.
In version 9.6x the WHAT table is at memory offset 0x470

The documentation describes the WHAT table for key mapping at file
offset 0x36C.  The actual offset varies between different versions of
list.com.  Also, as a .COM file, it gets loaded into a memory offset
plus 0x100.  You can use debug.com to find the actual memory offset.

C:\LIST-BEN>debug orig\listp96x.com
-s 100 l 1024 'WHAT'
0C60:046C
-h 046C 4
0470 0468
-q

The actual memory offset in this example is 0x470.
* The file offset is indeed 0x36C.
* DOS loads a .COM file at offset 0x100.
* This makes the memory offset 0x46C.
* However, the WHAT table begins with the 4-byte header 'WHAT'.
* Skipping the header, the records begin at memory offset 0x470.

## The key offsets and functions

B = ASCII 66 (0x42)
b = ASCII 98 (0x63)

I expect the values at these offsets to be function 10 (0x0A).
I would like to change them to function 9 (0x09).
I verified the expected values using debug.com.

C:\LIST-BEN>debug orig\listp96x.com
-h 470 42
04B2  042E
-h 470 62
04D2  040E
-d 4B2 l 1
0C60:04B0        0A               -                          .
-d 4D2 l 1
0C60:04D0        0A               -                          .
-q

## Back up the original program

C:\LIST-BEN>copy orig\listp96x.com fixed\listp96x.com
 LISTP96X.COM
   1 File(s) copied.

## Preview the changes

C:\LIST-BEN>type listp96x.dbg
e 4B2 9
e 4D2 9
w
q

## Remap the keys using debug.com

C:\LIST-BEN>debug fixed\listp96x.com <listp96x.dbg
...
Writing 6C89 bytes

## Verify the changes

Finally, i tested listp96x.com and when i press the "b" or "B" keys,
it displays the previous page. For the record, the MD5 hashes are
shown below.

Original:

C:\LIST-BEN>md5sum orig\*.com
1c72191997dbb6a7cbaea66c7f07e10c *C:\LIST-BEN\ORIG\LIST90C.COM
39717316e149c0626dba7c35aee6eb37 *C:\LIST-BEN\ORIG\LISTP96X.COM

Result:

C:\LIST-BEN>md5sum fixed\*.com
b7ded6697888fcb5d1cf8607e9f70918 *C:\LIST-BEN\FIXED\LIST90C.COM
d1810b28e9ec7a71a82564a2cb036424 *C:\LIST-BEN\FIXED\LISTP96X.COM
