Video

Technical appendix · Home · Français

Mostly verified from disassembly. Adapter routines beyond their entry code are not fully read.

Buffers

Global DS offset Role
wPageSeg (IDA wConStagingSeg) 494 320×200, 1 byte per pixel page: the target of Vid_PagePtr and Img_Decode
wPage2Seg (IDA word_1CC2B) 280B second page, wPageSeg - 0x1444
wScratchSeg DA compressed-file buffer, wPage2Seg - 0xC74
wSheetSeg:wSheetOfs (IDA wVidCanvas*) BA:B8 20,496 B block, used as a 320×64 sprite sheet

The sheet is written by Ui_CaptureSpriteSheet EA 0x1428C (service 0x17), which copies the top 64 rows of the page to it at 0x142C3. Vid_BlitTile reads from ES:DI, so the callers Ui_DrawBar EA 0x116EB and Ui_DrawWidget EA 0x11A20 use it as a source. Offsets such as +0x1E00 and +0x90 are byte offsets into the sheet. "Sprite sheet" is inferred from that use.

Vid_ArenaAlloc EA 0x1135D (service 0x1C) frees the earlier big block, allocates 0x501 paragraphs for the sheet and 0x220 for a second block, then checks the remaining memory against 0x3737 paragraphs. Too little memory leads to the MANQUE DE MEMOIRE path (the message path is unverified). Font_SelectDescriptor is called from here.

Drawing primitives

  • Vid_PagePtr EA 0x117A8: SI = y*320 + x, DS = wPageSeg.
  • Vid_BlitTile EA 0x117C1: CH = width, CL = height; source pitch 320; colour 2 is transparent. Adds the width to wCanvasX. EA 0x117BF sets CL = 12 first.
  • Vid_DrawGlyph EA 0x11590: see Text and fonts.
  • bBlitViaPutPixel (DS:48E): 1 selects Vid_PutPixel (direct to video memory); otherwise pixels are stored in the page. Con_PromptDisk sets it to 1 at 0x12903.

Vid_PutPixel EA 0x129AD

Branches on wVideoMode. Callers: 0x1168B and 0x1181F.

  • Mode 5: byte store at A000h.
  • Mode 2: ofs = y*80 + (2x)/8, with mask from 2x & 7, using write mode 2 through graphics port 3CEh, so a logical pixel spans 2 screen pixels on a 640-wide mode.

Video modes

Sys_ParseAdapterArg EA 0x109F2 matches the first argument against the 3-byte names at DS:405: AMS, CGA, EGA, HER, TAN, VGA → wVideoMode 0..5.

Vid_SpriteDispatch EA 0x12DBA (IDA Vid_FlushCanvas_Mono) jumps on the mode:

Mode Target EA Name Buffer
0 AMS 0x12F80 Vid_SpriteAmstrad (IDA ..._CGA16) B800h
1 CGA 0x12DE7 Vid_SpriteCga
2 EGA 0x12E8C Vid_SpriteEga A000h
3 HER 0x12F21 Vid_SpriteHerc
4 TAN 0x13113 Vid_SpriteTandy
5 VGA 0x13184 Vid_SpriteVga

These read from the sprite sheet, using a position derived from DS:94. Their full role, and the page-to-screen copy path, still need reading (Open questions).

Runtime dumps

Earlier work captured two pages (S8C76.BIN, S7832.BIN). Those files aren't in this repo. 8C76h - 1444h = 7832h matches wPage2Seg, which supports those segment values for that session.

Previous: The compression codec · Next: Text and fonts · Technical appendix · Home