SoftCat wrote on 2025-12-25, 23:59:
Tell me, does the "Address Wrap" bit in the CRTC mode register (Index 0x17, bit 5) not work for me (in the word address mode)?
No, that bit does not seem to be helpful for infinite scrolling, for multiple purposes:
First, I assumed we are talking about 16-color modes. Those modes are not using word mode. The word mode is only used in text modes, CGA-compatible graphics modes, and the 4-color variant of mode 10h. As that bit only affects word mode, it is useless in mode 0Eh.
Second, the idea of this bit select where bit 0 comes from when converting from the CRTC address counter to RAM addresses. So in 64K mode 10h, the internal CRTC address counter is still counting up by one, but only every 16 pixels instead of every 8 pixels (3d4, Index 0x17, bit 3), and the sequencer only reads RAM every 16 pixels (3C4, index 1, bit 2). This makes the counter count from 0 to 0x36B0 during a frame. In word mode, the internal CRTC counter is shifted by one bit before being sent to the video RAM addressing part. This results in even addresses between 0 and 0x6D60, which obviously exceeds the maximum address of a 64K EGA, which is 0x3FFF. After shifting the complete 16-bit value, bit 0 is filled with either a copy of the counter bit 13 or 15. Looking at the quite comprehensive C&T CS8240 datasheet (a clone EGA chipset), they claim that you get bit 13 as A0 if one or both of these conditions is true: (a) the memory size in the Sequencer register is configured to 64K or (b) Index 0x17, bit 5 is clear, otherwise bit 15 is used.
In use-bit13-mode, you will get the sequence 3FFC, 3FFE, 4001, 4003 and so on, which will shift to the odd bytes after 8K character clocks. At this point, superfury is correct according to the C&T documentation:
superfury wrote on 2025-12-26, 00:17:Isn't 64K wrapping exactly what sequencer register 04h bit 1 does, when cleared? Disable A16 and higher, clearing them? Basically just ANDed with each of those bits?
The nomenclature in the datasheet is different, but you are generally correct. As the EGA card is meant to be thought of as 64K * 32, not 256K * 8, the address bits in most documentation about the EGA card are just numbered 0 to 15, so there is no A16 and higher. The bit you mean by "A16" is called A14 in that documentation, and indeed, in graphics mode, the sequencer disables A14 and A15 (or A16 and A17 according to your way of counting) in 64K mode. It's even more interesting in text mode: in text mode, the 32-bit memory is split into two 16-bit memory pieces that have separate address lines! Planes 0&1 use address line set A, while planes 2&3 use address line set B. This allows the EGA card to fetch a character and attribute byte combination from planes 0&1 while at the same time fetching font data for the character code previously loaded from plane 2. In text mode, the sequencer generates A14/A15 for planes 0&1 from the CRTC output (possibly masked in 64K mode), and generates A14/15 for planes 2&3 from the selected character map.
Note that with the original "4 banks of 16K x 32" design, there were no address bits A14 and A15 on that side anymore, but there were bank selects instead. In 64K mode, the Sequencer always enables bank 0, while in 256K mode, the selected bank depends on address bits A13 or A15 from the CRTC. So if you put the EGA card into 64K mode, the sequence 3FFC, 3FFE, 4001, 4003 generated by the CRTC will be masked to get 3FFC, 3FFE, 0001, 0003 for the video RAM, as required for 64K mode 10h. The combination of putting the sequencer in 256K mode (allowing multiple banks) and using "rotate using bit 13" seems pointless, because this will make the EGA card use the even bytes of the first bank, followed by the odd bytes of the second bank (according to the C&T documentation), which is practically useless, but likely implemented for compatibility with the IBM EGA implementation, which had the same practically useless behaviour for this setting combination that likely was never intended to be practically used.
Another interesting aspect in the C&T datasheet is how A0 to video RAM is generated for CPU cycles mode depending on the card configuration. As I'm not able to find the application notes for that chipset, I have some issues interpreting the table that describes the generation of CRTC A0. That table refers to three input pins. One is "CHAIN" which is driven by the odd/even mode setting as programmed in the graphics controller (3CE, index 6, bit 1), the second one is "MEMOPT", which is driven by the memory size bit already mentioned by superfury (3C4, index 4, bit 1), but the source of third one, called "SAM" is not described in the chipset datasheet. I have to assume that this bit is generated from the video memory address range selection bits (3CE, index 6, bits 2 and 3), and is set if the 128K mode (A000..BFFF) is selected. Given that interpretation:
- In byte mode, A0 is always passed through (obviously)
- If 128K address space is not enabled, A0 is generated from the inverted page bit in 3C2 in 256K mode, but from A14 in 64K mode. So you need to configure the card to 64K mode to get the 4-color mode 10h working.
- If 128K address space is enabled and the card is in 256K mode, CPU address bit A16 is used as A0. This means A000-AFFF provides access to the even addresses in video memory, and B000-BFFF provides access to the the add addresses in video memory, with planes 1 and 3 being visible at odd CPU addresses, and planes 0 and 2 being visible at even CPU addresses. The table indicates that if you configure 128K address space in 64K memory mode, A0 from the CPU is just passed through. This is either a misprint, or is an artifact because IBM did not intend that configuration to be used in practice. It makes no sense to pass through A0 in odd/even mode.