Question:
Skin2code.txt shows, to me, the routine for drawing the entire screen. I don't understand how skin2code works if there is only one cell in the viewport that is of skin2, and the rest are of skin0.
Answer:
Here is a long story of how the skin business is implemented.
When the viewport is about to be drawn, the following things happen:

- The original DM ceiling, floor, and black middle backgrounds are drawn.
- A summary is created for each of the 21 cells that can be seen by the party. Information about each of the 21 cells is gathered into 21 'Room Summay' packets. Each packet contains the cell type (stone, pit, teleporter, etc.), the decoration and text to be displayed on the nearest three walls of the cell, the decoration to be displayed on the floor of the cell, the list of the cell's contents, the relative position of the cell, the cell's x- and y-coordinates, the skin number for that cell, etc.
- The packets are examined in order starting with relative cell 0. If it has a non-zero skin then we look for user code for that skin. At the end of the user code for that skin is a table that contains 21*8 entries. 168 entries. Each entry tells how to draw one of the eight cell types at one of the 21 relative cell locations. So, in your example, if relative cell 7 is a pit and has skin type 2 ( and all the other cells are skin type 0) then, when we examine relative cell 7 we will find code for skin type 2. At the end of Skin2Code we look in the table at the end of the code and execute ONLY the function that draws pits in relative cell 7. None of the other functions will be called. Just the one. For all the other cells, the (internal) functions for Skin0 will be called.
- The user code can gather information from the 'Room Summary' packet to influence how it draws that single cell type in that single relative cell location.

Note that in this example, the function for pits at relative cell 7 gets executed. But there is nothing that prevents that code from drawing whatever it pleases. If it wants to black out the screen and draw a picture of a Bald Eagle filling the entire viewport, there is nothing to stop it. So you could, in principle, provide a SINGLE function that gets called for all cell types and all relative cell numbers and sort it all out yourself as to what should be drawn in the entire viewport. But using the built-in 'CASE-LIKE' capability makes things easier to manage, IMHO.