Each of the 128 rows must be refreshed every 2ms by changing the VRAM addresses and taking -RAS low. (2ms = ~31 scanlines) The DMA page is set to 0 so the CGA RAM won't be refreshed the same way as system RAM (luckily, because that would slow down some of the refresh cycles) The CRTC must be continuing to generate addresses even when the display is disabled. It must be programmed to access every combination of the low 7 bits of CRTC address in 31 scanlines This is normally the case, but reprogramming can cause this to fail to happen. Can we take advantage of this? Is this a pitfall of some of the modes? Can we use this an an effect? Probably not reliable enough. In -HRES mode, the spans covered are: 0-56 40-96 80-127 and 0-8 In +HRES mode: 0-113 80-193 Memory layouts: In graphics modes (4096 characters e.g. 102 rows of 40): CPU address 0x0000 = 0000000 0000000 = CRTC address 0x0000 even rows -HCLK=0 CPU address 0x0001 = 0100000 0000000 = CRTC address 0x0000 even rows -HCLK=1 CPU address 0x0002 = 0000000 0000001 = CRTC address 0x0001 even rows -HCLK=0 CPU address 0x0003 = 0100000 0000001 = CRTC address 0x0001 even rows -HCLK=1 ... CPU address 0x1fff = 0111111 1111111 = CRTC address 0x0fff even rows -HCLK=1 CPU address 0x2000 = 1000000 0000000 = CRTC address 0x0000 odd rows -HCLK=0 CPU address 0x2001 = 1100000 0000000 = CRTC address 0x0000 odd rows -HCLK=1 CPU address 0x2002 = 1000000 0000001 = CRTC address 0x0001 odd rows -HCLK=0 CPU address 0x2003 = 1100000 0000001 = CRTC address 0x0001 odd rows -HCLK=1 ... CPU address 0x3fff = 1111111 1111111 = CRTC address 0x0fff odd rows -HCLK=1 In text modes (8192 characters e.g. 102 rows of 80 or 204 rows of 40): CPU address 0x0000 = 0000000 0000000 = CRTC address 0x0000 -HCLK=0 CPU address 0x0001 = 0100000 0000000 = CRTC address 0x0000 -HCLK=1 CPU address 0x0002 = 0000000 0000001 = CRTC address 0x0001 -HCLK=0 CPU address 0x0003 = 0100000 0000001 = CRTC address 0x0001 -HCLK=1 ... CPU address 0x1fff = 0111111 1111111 = CRTC address 0x0fff -HCLK=1 CPU address 0x2000 = 1000000 0000000 = CRTC address 0x1000 -HCLK=0 CPU address 0x2001 = 1100000 0000000 = CRTC address 0x1000 -HCLK=1 CPU address 0x2002 = 1000000 0000001 = CRTC address 0x1001 -HCLK=0 CPU address 0x2003 = 1100000 0000001 = CRTC address 0x1001 -HCLK=1 ... CPU address 0x3fff = 1111111 1111111 = CRTC address 0x1fff -HCLK=1 i.e. in text mode, the high 8Kb works as expected, in graphics modes the high 8Kb is only visible via odd rows. So, using: 40-column text mode 1-scanline characters (implies a restart in the middle of the screen) the vertical half block blinking off We can do an 80x200 16-colour mode. The memory layout and restart make it awkward for a rotozoomer, but good for effects where we're doing restarts anyway. Using the timer interrupt to do the restart here might be useful. +ALPHA DOTS: This is responsible for blinking and cursor in text mode. if (cursor visible && cursor blink cycle on) dots high else if (character attribute blink bit set && blink enabled && blick cycle high && !cursor visible) dots low else dots from character generator This means that blinking is suppressed under the cursor (not the entire character, only the part under the cursor). +ALPHA DOTS = (-CURSOR BLINK NOR -CURSOR DLY) OR (+CHG DOTS AND (-BLINK OR 3NAND(-CURSOR DLY, +ENABLE BLINK, +AT7))) (((NOT (AT7 & ENABLE_BLINK & -CURSOR_DLY)) OR -BLINK) AND +CHG_DOTS) OR (NOT (-CURSOR_BLINK OR -CURSOR_DLY)) ((-AT7 | -ENABLE_BLINK | CURSOR_DLY | -BLINK) AND +CHG_DOTS) OR (CURSOR_BLINK AND CURSOR_DLY) Blinking and cursor: Blinking: 16 frames on, 16 frames off Cursor: 8 frames on, 8 frames off Assuming a frame rate of 60Hz (+VSYNC DLY): Cursor: 3.75Hz Blinking: 1.875Hz 1 hdot 640 912 width of a pixel in 80x25 text mode and 640x200 graphics mode. (70ns) 2 hdots = 1 ldot 320 456 width of a pixel in 40x25 text mode and 320x200 graphics mode. (140ns) 3 hdots = 1 cycle 304 width of a CPU cycle (210ns) 4 hdots = 1 ccycle 160 228 width of a pixel in 160x100x16 mode. One color-carrier cycle. (279ns) 8 hdots = 1 hchar 80 114 width of a character in 80x25 text mode, or a byte in graphics modes. (559ns) 12 hdots = 1 tcycle 76 width of an IO cycle or a PIT cycle (838ns) 16 hdots = 1 lchar 40 57 width of a character in 40x25 text mode, or a CRTC scrolling unit in graphics modes. (1.12us) hdot [---] ldot [-------] ccycle [---------------] hchar [-------------------------------] lchar [---------------------------------------------------------------] +---------------------------------------------------------------------------------------------------------------------------------- -RESET | --+ -+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +- +14 MHZ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ -14MHZ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +- +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +- +Q4' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ ---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ -7MHZ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +- +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +- +3.58 MHZ | | | | | | | | | | | | | | | | | ---+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +Q6' | | | | | | | | | | | | | | | | -------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +----- +-------------------------------+ +-------------------------------+ +- -LCLK | | | | | ---+ +-------------------------------+ +-------------------------------+ +-------------------------------+ +-------------------------------+ +Q2 | | | | -------+ +-------------------------------+ +----------------------------- +-------------------------------+ +-------------------------------+ +Q3 | | | | -----------+ +-------------------------------+ +------------------------- +-------------------------------+ +-------------------------------+ +Q4 | | | | ---------------+ +-------------------------------+ +--------------------- +-------------------------------+ +-------------------------------+ +Q5 | | | | -------------------+ +-------------------------------+ +----------------- +-------------------------------+ +-------------------------------+ +Q6 | | | | -----------------------+ +-------------------------------+ +------------- +-------------------------------+ +-------------------------------+ +Q1' | | | | ---------------------------+ +-------------------------------+ +--------- +-------------------------------+ +-------------------------------+ +Q2' | | | | -------------------------------+ +-------------------------------+ +----- ---+ +-------------------------------+ +-------------------------------+ +LCLK | | | | | +-------------------------------+ +-------------------------------+ +- +---------------+ +---------------+ +---------------+ +---------------+ + +HCLK | | | | | | | | | ---+ +---------------+ +---------------+ +---------------+ +---------------+ ---+ +---------------+ +---------------+ +---------------+ +---------------+ -HCLK | | | | | | | | | +---------------+ +---------------+ +---------------+ +---------------+ + -------------------------------+ +-------------------------------+ +----- -Q2' | | | | +-------------------------------+ +-------------------------------+ +-------+ +-------+ +-------+ +-------+ +CAS CC | | | | | | | | -------+ +-----------------------+ +-----------------------+ +-----------------------+ +--------------------- +-------------------------------+ +-------------------------------+ U1Q | | | | ---------------------+ +-------------------------------+ +--------------- +---+ +-----+ +---+ +-----+ +---+ +-----+ +---+ +-----+ +- -CAS | | | | | | | | | | | | | | | | | ---+ +-------+ +-------------+ +-------+ +-------------+ +-------+ +-------------+ +-------+ +-------------+ +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ +- +RAS | | | | | | | | | ---+ +-------+ +-------+ +-------+ +-------+ ---+ +-------+ +-------+ +-------+ +-------+ -RAS | | | | | | | | | +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ +- +---------------------------+ +---------------------------+ +---------------------------+ +---------------------------+ +- +S/L' (hi) | | | | | | | | | ---+ +---+ +---+ +---+ +---+ +-----------------------------------------------------------+ +-----------------------------------------------------------+ +- +S/L' (lo) | | | | | ---+ +---+ +---+ +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ +EN CAS | | | | | | | | ADDR -----+ +-------+ +-------+ +-------+ +------- -----+ +-------+ +-------+ +-------+ +------- +EN RAS | | | | | | | | ADDR +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ YELLOW | | | | | | | | | | | | | | | | (OR +BW) BURST -------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +----- +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ GREEN | | | | | | | | | | | | | | | | (OR +BW) -----+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +------- +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +- RED [sic] | | | | | | | | | | | | | | | | | (OR +BW) ---+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ -------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +----- BLUE | | | | | | | | | | | | | | | | (OR +BW) +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ -----+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +------- MAGENTA | | | | | | | | | | | | | | | | (OR +BW) +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ ---+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ CYAN [sic] | | | | | | | | | | | | | | | | | (OR +BW) +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +- -EN CPU ---------------------------+ +-------+ +-------------------------------+ +-------+ +--------- CAS ADDR | | | | | | | | (lo) +-+ +---------------------+ +-+ +---------------------+ -EN CPU -----------------------------+ +-------------------------------------------------------+ +------------------------------- RAS ADDR | | | | (lo) +-------+ +-------+ -EN CRT -----+ +-------------------------------+ +-------+ +-------------------------------+ +------- CAS ADDR | | | | | | | | (lo) +---------------------+ +-+ +---------------------+ +-+ -EN CRT +-------------------------------------------------------+ +-------------------------------------------------------+ RAS ADDR | | | | (lo) -----+ +-------+ +------- -EN CRT -----+ +-------+ +-------+ +-------+ +------- CAS ADDR | | | | | | | | (hi, n/s) +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ -EN CRT +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ RAS ADDR | | | | | | | | (hi, n/s) -----+ +-------+ +-------+ +-------+ +------- +-----------+ +-----------+ +WR CLK | | | | ---------------------------------------------------+ +---------------------------------------------------+ +----- U2/1: (D) --------------------+ +------------------------------------------------------------- -CPU MEM | | SEL +--------------------------------------------------+ (CLK) +-------------------------------+ +-------------------------------+ +Q1' | | | | ---------------------------+ +-------------------------------+ +--------- (CLR) ------------------------------------------------------------------------------------------------------------------------------------- +5V (PR) ------------------------------------------------------------+ +------------------------------------------------------------ -XACK' | | +-----------+ (Q) ---------------------------+ +----------------------------------------------------------------------- -CPU MEM \ / SEL DLY +-------------------------------+ (-Q) +-------------------------------+ +CPU MEM / \ SEL DLY ---------------------------+ +----------------------------------------------------------------------- U2/2: (PR) +--------------------------------------------------+ +CPU MEM | | SEL --------------------+ +------------------------------------------------------------- (D) ----------------------------+ +----------------------------------------------------------------------- -CPU MEM | | SEL DLY +--------------------------------+ (CLK) ---+ +-------+ +-------+ +-------+ +-------+ -RAS | | | | | | | | | +-----------------------+ +-----------------------+ +-----------------------+ +-----------------------+ +- (CLR) -----------------------------------------------------------+ +------------------------------------------------------------ -XACK' \ / (Q) +----------+ +-----------+ +XACK / \ (-Q) -----------------------------------------------------------+ +----------------------------------------------------------- So, wait time (between -CPU MEM SEL going low to +XACK going high) is to the next +Q1' rising (0-1 lchar or 0-6 cycles), then one hchar, so total 0.5-1.5 lchar or 3-8 cycles. => to get full lcokstep, first do a CGA read or write, then restart timer 1. Am I right about the 1 hchar? If not, we might be able to do wait-free CGA writes by timing correctly: 3 lchars = 48 hdots = 16 cycles Otherwise the best we can do is 3 wait states: 9 hdots + 13 cycles = 3 lchars Or if we stick to tcycles, 4 wait states: 12 hdots + 12 cycles = 3 lchars Snow happens because: When we have +HRES, we always latch the character (+CC LATCH == +CAS CC) even on cycles when the CGA's memory address comes from the CPU. In +HRES, +EN CPU ADDR is only high when we have +CPU MEM SEL DLY instead of every +Q1' so there isn't snow on every character. The reason we can't use +GRPH and +HRES is that in +GRPH, we only have -AT LATCH every -Q2' instead of every -CCLK as in -GRPH. -+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +- +HCLK | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +- +LCLK | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +-------------------------------------------------------------------------------+ +HSYNC DLY | | ---+ +------------------------------------------------- The following might be 1 lchar later: +-----------------------------------------------------------------------+ U64-QB | | -----------+ +------------------------------------------------- +---------------------------------------+ U64-QF | | -------------------------------------------+ +------------------------------------------------- +-------------------------------+ U64-QG | | ---------------------------------------------------+ +------------------------------------------------- +-----------------------+ U64-QH | | -----------------------------------------------------------+ +------------------------------------------------- +---------------+ U43-Q1 | | -------------------------------------------------------------------+ +------------------------------------------------- +-------------------------------+ HSYNC OUT | | -----------+ +----------------------------------------------------------------------------------------- ---------------------------------------------------+ +----------------------------------------------------------------- -BURST | | +---------------+ On a 1501981: (might be wrong) +-----------------------+ +-------+ U64-QB | | | | -----------+ +-----------------------+ +----------------------------------------------------------------- +-----------------------+ +-------+ U64-QD | | | | ---------------------------+ +-----------------------+ +------------------------------------------------- +-----------------------+ U64-QG | | ---------------------------------------------------+ +--------------------------------------------------------- +-----------------------+ U64-QH | | -----------------------------------------------------------+ +------------------------------------------------- +---------------+ U43-Q1 | | -------------------------------------------------------------------+ +------------------------------------------------- ---------------------------+ +-------+ +--------------------------------------------------------- U64-A2 | | | | +-----------------------+ +---------------+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ + | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HSYNC OUT --+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +-------------------------------------------------------------------------------+ +VSYNC DLY | | -----+ +----------------------------------------------- +-----------------------------------------------------------------------------+ U63+Q1 | | -------+ +----------------------------------------------- +------------------------------------------------------------------------+ U63+Q2 | | ------------+ +----------------------------------------------- +-------------------------------------------------------------------+ U63+Q3 | | -----------------+ +----------------------------------------------- ----------------------+ +----------------------------------------------- U63-Q4 | | +--------------------------------------------------------------+ +--------------+ VSYNC OUT | | -------+ +-------------------------------------------------------------------------------------------------------------- Address line A14 is unused, which means that the CGA memory b8000-bbfff is duplicated at bc000-bffff The 2118-4 has a maximum access time of 120ns (1 ldot) and a "Read/Write" cycle time of 270ns (1 ccycle). RAS minimum pulse width = 140ns actual = 140ns CAS pulse width = 65ns mov al,01 ; 2 0 8 4 stosb ; 1 1 8 11 TODO: Check actual wait states for various intervals between CGA accesses Check for snow on read (should be there) NTSC standard: Blanking: 9.75 lclks Sync: 4.21 lclks Burst: 2.24 lclks CGA: Blanking: 10 lclks Sync: 4 lclks Burst: 2 lclks NTSC: Sync: -40 -0.286V Blank: 0 0V Black: 7.5 0.054V White: 100 0.714V Max: 131 0.935V CGA: Sync: 0 -0.292V 0 -0.379 -0.286 Blank: 0.292 0 0.379 0 0 Black: 0.416 0.124V 0.121V 0.416 0.037 0.028 D.Grey: 0.709 0.417V 0.408V 0.709 0.33 0.249 Grey: 1.16 0.868V 0.850V 1.16 0.781 0.589 White: 1.46 1.17V 1.15V 1.46 1.081 0.816 Burst high: 109 Burst low: 24 7: 124 0: 39 15: 161 8: 72 Burst range: 85 Chroma range: 85 0x08 -HRES, -GRPH, -1BPP - proper 40x25 text 0x09 +HRES, -GRPH, -1BPP - proper 80x25 text 0x0a -HRES, +GRPH, -1BPP - proper 320x200 graphics 0x0b +HRES, +GRPH, -1BPP - improper 1 (640-column 2bpp) 0x18 -HRES, -GRPH, +1BPP - improper 2 (40-column text + 1bpp) 0x19 +HRES, -GRPH, +1BPP - improper 3 (80-column text + 1bpp) 0x1a -HRES, +GRPH, +1BPP - proper 640x200 graphics 0x1b +HRES, +GRPH, +1BPP - improper 4 (1280-column 1bpp) 1: Bytes repeated ABCB, reducing effective horizontal resolution to 40? That's one of the CRTC phases. What about the other? Probably no difference 256 colours. 64 different palettes. No snow? 2: 1bpp pattern masks text with black. 65536 bit patterns, not sure how many of them work out as pure colours. 3: 1bpp pattern masks text with black. 65536 bit patterns, not sure how many of them work out as pure colours. 4: No advantage over 0x1a +STR handles blanking (in all modes), black overscan (+1BPP mode) and +1BPP dots. It is used to inhibit the RGBI multiplexers RGBI multiplexer inputs are: 0 = AT0-3 = text foreground 1 = AT4-7 = text background 2 = +C0/+C1/+SEL_BLUE/+BACKGROUND_I = 2bpp dots 3 = overscan colour from palette register +MUX_A = -DISPEN_DLY | ((-GRPH & +ALPHA_DOTS) NOR (+GRPH & ~+1BPP & (+C0 | +C1))) +MUX_B = -DISPEN_DLY | +GRPH +SEL_BLUE = ~((+COLOR_SEL & -BW) | (+C0 & +BW)) +CC_LATCH = loads character from memory bus on rising edge = (+HRES | -CCLK) NAND +CAS_CC +AT_LATCH = loads attribute from memory bus on rising edge = (+GRPH & -Q2') NOR (-CCLK & -GRPH) -CCLK = (+HRES & +HCLK) NOR (-HRES & +LCLK) -HRES -GRPH -------+ +-------------------------------------------------------+ +----------------------------------------------------- +CC_LATCH | | | | +-------+ +-------+ ---+ +------------------------------+ +-------------------------------+ +AT_LATCH | | | | | +-------------------------------+ +--------------------------------+ +- C A C A -HRES +GRPH -------+ +-------------------------------------------------------+ +----------------------------------------------------- +CC_LATCH | | | | +-------+ +-------+ +-------------------------------+ +-------------------------------+ +AT_LATCH | | | | -------------------------------+ +-------------------------------+ +----- C A C A +HRES -GRPH -------+ +-----------------------+ +-----------------------+ +-----------------------+ +--------------------- +CC_LATCH | | | | | | | | +-------+ +-------+ +-------+ +-------+ +---------------+ +---------------+ +---------------+ +---------------+ + +AT_LATCH | | | | | | | | | ---+ +---------------+ +---------------+ +---------------+ +---------------+ A C A C A C A C +HRES +GRPH -------+ +-----------------------+ +-----------------------+ +-----------------------+ +--------------------- +CC_LATCH | | | | | | | | +-------+ +-------+ +-------+ +-------+ +-------------------------------+ +-------------------------------+ +AT_LATCH | | | | -------------------------------+ +-------------------------------+ +----- C A C C A C +S/L' = (-LCLK XOR U5.Q2.5=+Q2') | (U4.Q2.5=+Q2 NOR +HRES) +-------------------------------+ +-------------------------------+ +Q2 | | | | -------+ +-------------------------------+ +----------------------------- +---------------------------+ +---------------------------+ +---------------------------+ +---------------------------+ +- | | | | | | | | | ---+ +---+ +---+ +---+ +---+ -HRES -------------------------------+ +-----------------------------------------------------------+ +--------------------------------- +S/L' | | | | +---+ +---+ +HRES +---------------------------+ +---------------------------+ +---------------------------+ +---------------------------+ +- +S/L' | | | | | | | | | ---+ +---+ +---+ +---+ +---+ In +GRPH modes "input" can just be the latch contents - deal with latching-old-value in the calling code In +1BPP-GRPH-HRES mode, we can separate the 1bpp and text data That leaves +1BPP-GRPH+HRES Text is CcDd (C, D = character; c, d = attribute) Graphics is CbDc So we need 40 bits of data to describe 16 hdots Pass in old value of attribute latch, return new value How do we determine phase for +HRES+GRPH? Let's just use the phase which makes the screen position the same as for -HRES. That is phase 1. So we only need to use the old latch for -GRPH+1BPP List of modes and which data bits are used (memory layout bCcDd) char attr apa (4 hdots per column) 0x08 -HRES-GRPH-1BPP CCCC cccc 0x09 +HRES-GRPH-1BPP CCDD ccdd 0x0a -HRES+GRPH-1BPP CCcc 0x0b +HRES+GRPH-1BPP 0 CbDd problem 1 0x0b +HRES+GRPH-1BPP 1 CcDc problem 1 0x18 -HRES-GRPH+1BPP CCCC cccc CCbb problem 2 0x19 +HRES-GRPH+1BPP CCDD ccdd CbDc problem 2 0x1a -HRES+GRPH+1BPP CCcc 0x1b +HRES+GRPH+1BPP 0 CbDd problem 1 0x1b +HRES+GRPH+1BPP 1 CcDc problem 1 We don't want to just pass in a pointer to memory data as it's the previous value in the latch and/or SR that's important, not previous in RAM So before character 0 is character -40-1+57 or -80-1+113 or -1+57 or -1+113 depending on +HRES and scanline? No; attribute latch is cleared when display disabled, so we always get 0 pixels The problem in +GRPH+HRES (problem 1) is that the attribute latch value is stale The problem in -GRPH+1BPP (problem 2) is that the SR is loaded from the attribute latch before the attribute latch is loaded from VRAM Can both of these happen at once? No, because the first only happens with +GRPH and the second only happens with -GRPH Problem 1: affects 4 hdots out of 16. Each byte affects 4-12 hdots (less bad than -LRES text) Problem 2 -HRES: Each byte affects 16-32 hdots Problem 2 +HRES: Each byte affects 8-16 hdots U1 74S112PC 1 2 3 4 5 6 9 10 11 12 13 14 15 Dual J-K Negative-edge-triggered flip-flops with preset and clear RAS/CAS computation U2 SN74LS74AN 1 2 3 4 5 6 8 9 10 11 12 13 Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs +XACK computation U3 DM74S86N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input Exclusive-OR Gate U4 SN74S174N 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear Clock generator U5 SN74S174N 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear Clock generator U6 DM74LS04N 1 2 3 4 5 6 8 9 10 11 12 13 Hex Inverting Gates U7 SN74LS166NS all 8-BIT SHIFT REGISTERS low/right bits shift register U8 SN74LS166NS all 8-BIT SHIFT REGISTERS high/left bits shift register U9 DM74153N all Dual 1-of-4 Line Data Selectors/Multiplexers Red/Green multiplexer (0 = text foreground, 1 = text background, 2 = 2bpp, 3 = overscan) U10 DM74153N all Dual 1-of-4 Line Data Selectors/Multiplexers Blue/Intense multiplexer (0 = text foreground, 1 = text background, 2 = 2bpp, 3 = overscan) U11 SN74LS74AN 1 2 3 4 5 9 10 11 12 13 Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs CRTC port enable and light pen input latch U12 SN74LS393ND 1 2 6 11 12 13 Dual 4-Bit Binary Counter Blink generator U13 74HC08N no 1 2 3 8 9 10 11 12 13 1 Quad 2-Input AND Gates U14 SN74LS32N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input OR Gate U15 SN74LS00N 1 2 3 8 9 10 ? 12 13 1 Quad 2-Input NAND Gate U16 DM74LS04N 1 2 3 4 5 6 8 9 10 11 12 13 Hex Inverting Gates U17 SN74LS138N 1 2 3 4 5 6 11 12 13 14 15 Decoder/Demultiplexer Register selector U18 SN74LS138N 1 2 3 4 5 6 7 Decoder/Demultiplexer 3d8 port select U19 SN74LS138N 1 2 3 4 5 6 7 Decoder/Demultiplexer b8000 memory select U20 DM74LS04N 1 2 3 4 5 6 8 9 10 11 12 13 Hex Inverting Gates U21 SH74LS174N 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear CRTC output hclk delay U22 SN74LS51N 1 2 3 4 5 6 8 9 10 11 12 13 Dual 2-Wide 2-Input, 2-Wide 3-Input AND-OR-INVERT Gate +MUX_A and +SEL_BLUE computation U23 SN74LS32N 1 2 3 4 5 ? 8 9 10 11 12 13 Quad 2-Input OR Gate U24 DM74LS244N 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 Octal 3-STATE Buffer/Line Driver/Line Receiver status register, composite output driver U25 SN74LS00N 1 2 3 8 9 10 11 12 13 1 Quad 2-Input NAND Gate U26 74S04PC 1 2 3 4 5 6 8 9 10 11 12 13 Hex Inverting Gates U27 SN74LS51N 1 2 3 4 5 6 8 9 10 11 12 13 Dual 2-Wide 2-Input, 2-Wide 3-Input AND-OR-INVERT Gate dot and character clock select U28 74LS10PC 1 2 3 4 5 6 8 9 10 11 12 13 Triple 3-Input NAND Gate U29 74S04PC 1 2 3 4 5 6 8 9 10 11 12 13 Hex Inverting Gates U30 SN74LS32N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input OR Gate (1 2 3 shown as AND in schematic) U31 74S08PC 1 2 3 8 9 10 2 Quad 2-Input AND Gates U32 74HC166N no all 8-BIT SHIFT REGISTERS character shift register U33 5788005 all ROM character ROM U34 74LS273PC all 8-Bit Register with Clear character latch U35 74LS273PC all 8-Bit Register with Clear attribute latch U36 DM74LS244N all Octal 3-STATE Buffer/Line Driver/Line Receiver CPU write latch U37 74LS374DC all 3-STATE Octal D-Type Edge-Triggered Flip-Flops CPU read latch U38 MC6845P all CRTC CRTC U39 SN74LS174P 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear palette register U40 DM74LS174N 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear mode register U41 74LS08PC 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input AND Gates U42 SN74LS86N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input Exclusive-OR Gate U43 DM74S74N 1 2 3 4 5 8 9 10 11 12 13 Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs Yellow/blue generator U44 DM74S74N 1 2 3 4 5 6 8 9 10 11 12 13 Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs Red/cyan/magenta/green generator U45 74LS151PC all 1-of-8 Line Data Selector/Multiplexer Chroma multiplexer U46 SN74LS00N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input NAND Gate U47 74LS51PC 1 2 3 4 5 6 8 9 10 11 12 13 Dual 2-Wide 2-Input, 2-Wide 3-Input AND-OR-INVERT Gate snow select and +AT_LATCH computation U48 74LS51PC 1 2 3 4 5 6 8 9 10 11 12 13 Dual 2-Wide 2-Input, 2-Wide 3-Input AND-OR-INVERT Gate MA12 select and +1BPP dots U49 74HC02N no 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input NOR Gate U50 MK4516N-12 all DRAM (120ns access, 250ns cycle, 2ms refresh) DRAM bit 7 U51 MCM4517P12 all DRAM (120ns access DRAM bit 6 U52 MK4516N-12 all DRAM DRAM bit 5 U53 MCM4517P12 all DRAM DRAM bit 4 U54 MK4516N-12 all DRAM DRAM bit 3 U55 MCM4517P12 all DRAM DRAM bit 2 U56 MK4516N-12 all DRAM DRAM bit 1 U57 MCM4517P12 all DRAM DRAM bit 0 U58 74LS374DC all 3-STATE Octal D-Type Edge-Triggered Flip-Flops CRT high latch U59 74LS374DC all 3-STATE Octal D-Type Edge-Triggered Flip-Flops CRT low latch U60 74LS374DC all 3-STATE Octal D-Type Edge-Triggered Flip-Flops CPU low latch U61 74LS374DC all 3-STATE Octal D-Type Edge-Triggered Flip-Flops CPU high latch U62 74LS125APC 1 2 3 4 5 6 8 9 10 11 12 13 Quad 3-STATE Buffer shifter load delay, ram low bit driver, +IO_READY driver U63 74LS175PC 1 2 4 5 7 9 10 12 13 14 Quad D Flip-Flops with Clear vsync count-to-3 U64 DM74LS164N 1 2 4 8 9 11 12 13 8-Bit Serial In/Parallel Out Shift Register sync/burst sequencing U65 74LS02PC 1 2 3 4 5 6 8 9 10 1 Quad 2-Input NOR Gate U66 DM74LS245N all 3-STATE Octal Bus Transceiver ISA bus data lines driver U67 DM74LS244N 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 1 Octal 3-STATE Buffer/Line Driver/Line Receiver RGBI output driver, ISA bus A0 driver U68 SN74LS86N 1 2 3 4 5 6 8 9 10 11 12 13 Quad 2-Input Exclusive-OR Gate U100 empty 16-pin U101 SN74S174N 1 2 3 4 5 6 7 9 10 11 12 13 14 15 Hex D-Type Flip-Flops with Clear Pixel latch Spare: 2 NAND gates, 1 NOR gate, 3 AND gates, 1 spare driver might be able to simplify clock generation/sequencing BOM: 3 7400 Quad 2-Input NAND Gate 2 7402 Quad 2-Input NOR Gate 5 7404 Hex Inverting Gates 3 7408 Quad 2-Input AND Gates 1 7410 Triple 3-Input NAND Gate 3 7432 Quad 2-Input OR Gate 4 7451 Dual 2-Wide 2-Input, 2-Wide 3-Input AND-OR-INVERT Gate 4 7474 Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs 3 7486 Quad 2-Input Exclusive-OR Gate 1 74112 Dual J-K Negative-edge-triggered flip-flops with preset and clear 1 74125 Quad 3-STATE Buffer 3 74138 Decoder/Demultiplexer 1 74151 1-of-8 Line Data Selector/Multiplexer 2 74153 Dual 1-of-4 Line Data Selectors/Multiplexers 1 74164 8-Bit Serial In/Parallel Out Shift Register 3 74166 8-BIT SHIFT REGISTERS 6 74174 Hex D-Type Flip-Flops with Clear 1 74175 Quad D Flip-Flops with Clear 3 74244 Octal 3-STATE Buffer/Line Driver/Line Receiver 1 74245 3-STATE Octal Bus Transceiver 2 74273 8-Bit Register with Clear 5 74374 3-STATE Octal D-Type Edge-Triggered Flip-Flops 1 74393 Dual 4-Bit Binary Counter 1 3904 1 33R 1 51R 1 100R 1 3K3 1 13K 1 5K6 2 2K2 U4.Q1 +Q1 -LCLK U4.D1 == NOT +Q2' U4.Q2 +Q2 U4.D2 == +Q1 U4.Q3 +Q3 U4.D3 == +Q2 U4.Q4 +Q4 U4.D4 == +Q3 U4.Q5 +Q5 U4.D5 == +Q4 U4.Q6 +Q6 U4.D6 == +Q5 U5.Q1 +Q1' U5.D1 == +Q6 U5.Q2 +Q2' U5.D2 == +Q1' U5.Q3 +Q3' == +HCLK U5.D3 == (+Q4 XOR NOT +Q2') U5.Q4 +Q4' == (NOT Q4') delayed by 1 hdot == (NOT -7MHZ) U5.Q5 +Q5' == +3.58MHZ U5.Q6 +Q6' == NOT (Q6' delayed by 2 hdots) U6.D6 is U5.Q5 is (U5.D5 delayed by 1 hdot) is (NOT(U5.Q6) delayed by 1 hdot) later times further down: +LCLK -LCLK +Q2 +Q3 +Q4 +Q5 +Q6 +Q1' +Q2' U5.D3 +HCLK 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 (+COLOR_SEL AND +C0) OR (+C1 AND +BW) +BW +COLOR_SEL 0 0 green/red/yellow cyan/magenta/white 1 0 +C1 green/magenta/white cyan/red/yellow 0 1 +C0 cyan/red/white green/magenta/yellow 1 1 +C0 OR +C1 cyan/magenta/white green/red/yellow (+COLOR_SEL AND -C0) OR (+C1 AND +BW) +BW +COLOR_SEL 0 0 green/red/yellow cyan/magenta/white 1 0 +C1 green/magenta/white cyan/red/yellow 0 1 -C0 green/magenta/yellow cyan/red/white 1 1 -C0 OR +C1 green/magenta/white cyan/red/yellow (+COLOR_SEL AND +C0) OR (-C1 AND +BW) +BW +COLOR_SEL 0 0 green/red/yellow cyan/magneta/white 1 0 -C1 cyan/red/yellow green/magenta/white 0 1 +C0 cyan/red/white green/magenta/yellow 1 1 +C0 OR -C1 cyan/red/white green/magenta/yellow (+COLOR_SEL AND -C0) OR (-C1 AND +BW) +BW +COLOR_SEL 0 0 green/red/yellow cyan/magenta/white 1 0 -C1 cyan/red/yellow green/magenta/white 0 1 -C0 green/magenta/yellow cyan/red/white 1 1 -C0 OR -C1 cyan/magenta/yellow green/red/white Ok, I think what I was thinking of was changing SEL_BLUE from NOT ((+COLOR_SEL AND -BW) OR (+BW AND +C0)) to (+COLOR_SEL AND +C0) OR (+C1 AND -BW) which gives green/red/yellow and cyan/red/white for +BW and green/magenta/white or cyan/magenta/white for -BW. So the available palettes on colour composite wouldn't be the same... There are some other possibilities like cyan/red/yellow and green/magenta/yellow too. It'd be nice to be able to use the BLINK_ENABLE bit as another input to the palette but that requires a spare gate and I'm not sure offhand if there are any. +C0 is green bit green/yellow +C1 is red bit red/yellow NOT +C0 red NOT +C1 green 0 green/red/yellow +C0 OR +C1 cyan/magenta/white +C0 cyan/red/white +C1 green/magenta/white -C0 green/magenta/yellow -C1 cyan/red/yellow +C0 OR -C1 cyan/red/white -C0 OR +C1 green/magenta/white -C0 OR -C1 cyan/magenta/yellow Inputs: (13) +C0 +C1 +COLOR_SEL +BACKGROUND_I + Outputs: +SEL RED +SEL GREEN +SEL BLUE +SEL INTENSITY 2^13 = 8192 16*15*14 = 3360 - need 12 bits 16*15*14*13 = 43680 - need 16 bits