With hsync width 0, htotal = 0x66, get an active area with: hsync position = 0x53 yes 0x56 yes 0x57 yes 0x58 no hsync position = 0x5a no With hsync width 0xf, htotal = 0x66, get an active area with: 0x58 yes 0x59 no if hsync_position + hsync_width > htotal + 1 then we don't get an active area if the hsync never starts, then this isn't an issue With horizontal_sync_position = 0x73, horizontal_total = 0x66 (103 characters) horizontal_displayed = 0x66 start address latches horizontal_displayed = 0x67 start address doesn't latch So, plan is: horizontal_total = 80 and 32 (81 and 33, totalling 114) horizontal_displayed = 80 (80 columns in active scanline) horizontal_sync_position = 90 and 9 (no hsync in active, hsync at CRT char 90 in inactive) horizontal_sync_width = 0 or 15 (doesn't matter) vertical_total = 1 (2 rows per CRTC frame) vertical_total_adjust = 0 (0 extra scanlines) vertical_displayed = 1 (the active scanline forms the active width, the inactive scanline forms the overscan) vertical_sync_position = 25 (doesn't matter for now) interlace_mode = 0 (non-interlaced) max_scan_line_address = 0 (1 scanline per row) Sequence: CRT char CRTC char raster CPU 0 0 active start Set horizontal_sync_position to 90 9 9 Set horizontal_total to 80 32 32 Set start address 80 80 inactive start 81 0 second CRTC frame Set horizontal_sync_position to 9 90 9 hsync start Set horizontal_total to 32 106 25 hsync end 114 = 0 33 = 0 active start Distance from palette change to hsync start = 144 cycles Palette write is at char 36 == cycle 96 palette write is at cycle 1420, first write at cycle 1299, so first write is at -25, which is 37 cycles too early Distance from palette change to hsync start = 120 cycles Palette write is at char 45 == cycle 120 What is the latency of waitForDisplayEnable? Something like 39.25 cycles - too many to be able to avoid cycle counting Presumably it takes 39 cycles when there's no refresh 2 scanlines is 1824 hdots 39 cycles is 117 hdots 1824 % 117 == 69 117 % 69 == 48 69 % 48 == 21 48 % 21 == 6 21 % 6 == 3 so gcd(1824, 117) == 3 == 1 CPU cycle 40 cycles is 120 hdots 1824 % 120 == 24 so gcd(1824, 120) == 24 == 8 CPU cycles, this could miss the pulse Set horizontal_total to 32 0:80 - 1:00 34 a 1301 0 0 1299 0 0 Set horizontal_displayed to 32 0:80 - 1:00 34 b 1329 28 11 1319 20 8 Set horizontal_sync_position to 90 0:90 - 1:09 33 c 1357 56 21 1339 40 15 Set horizontal_displayed to 80 0:00 - 0:32 32 d 1390 89 33 1399 100 38 Set horizontal_total to 80 0:00 - 0:32 80 e 1418 117 44 1419 120 45 Set horizontal_sync_position to 9 0:09 - 0:90 81 f 1451 150 56 1439 140 53 Set start_address_high 1480 181 68 Set start_address_low 1508 209 78 0 10 20 30 40 50 60 70 80 90 100 110 0 10 20 30 40 50 60 70 80 90 100 110 | | | | | | | | | | | | | | | | | | | | | | | | ******************************************************************************** * ******************************************************************************** * Ssssssssssssssss Ssssssssssssssss aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ccccccccc ccccccccccccccccccccccccccccccccc cccccccccccccccccccccccc dddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff a b c d e f H L x x x x x x x x x x x x a b c d e f H L a b c d e f H L Actual b a d c e f H L 1301 0 1329 11 1357 21 1395 35 1423 46 1454 58 1482 68 1510 78 In 1spf_intermittent, when it's working, why are there only a few initial phases where it works? There should be about 8. How sure are we that the CRTC works by counting up and comparing rather than by loading and counting down? Pretty sure - counting down would require more transistors and horizontal probably works the same way as vertical There is something wrong with my model of how the CRTC works. Possible problems: Counting down instead of up How could we test this? Change horizontal displayed etc during active time and see what happens Plan: Display lockstep_visible and see if the CRTC copes with a 1-column screen It does, but the column could still be free-running Will need to have refresh off "in al,dx ; stosb" is 21 cycles == 63 hdots 4*8 == 32 hdots gcd(63, 32) = 1 waitForDisplayEnable == 37 cycles with refresh off VMX, VSX, -misel Figure out why 1spf_intermittent is doing differenet things despite being in lockstep Try modifying values slightly to see how it affects number of working nop-counts With refresh disabled, "readPIT16 0 / stosw" is 83 cycles (20.75 IOs) Phase 2 - worked with initial=70 (twice) but then not in 1spf_intermittent.bin ? Did I change something between them? No Try 66 Try 61, 63, 66, 69, 71 Phase 4 - worked with initial=21 then worked in 1spf_intermittent.bin as well 13 NOPs before refresh set This doesn't work phase 2 New version (with "initCGA 1" and safeRefresh in place again) Phase 2, 1spf2_intermittent.bin In all our experiments, we seem to get overscan and active swapped much more often than correct This suggests there is some problem with having a scanline that has active data but no hsync Plan: Try with 1 row of 2 scanlines That will put things in overscan though Try having vertical_displayed == 2 and setting horizonta_displayed == 1 in the overscan - then both scanlines are active and there's no asymmetry problem Then increase htotal for active scanline to push the extra column under the bezel Can we make do without moving hsync? That implies having hsync in the long scanline Suppose we want 15 characters for hsync (90-105) - then we have 9 characters Suppose our two horizontal totals are tl and tr, tl+tr == 114, tl>tr. Left scanline is 0 to tl, right scanline is tl to tl+tr e: Set ht=tl between 0 and tr (width tr) a: Set ht=tr between tl and tl+tr (width tr) Suppose our two horizontal displayed values are dl and dr. dl>dr. dl<=tl. dr<=tr. dl=80. Want to minimize dr. d: Set hd=dl between tl+dr and dr (width (tl+tr+dr)-(tl+dr) == tr) b: Set hd=dr between dl and tl+dr (width dr+tl-dl). So we can have dr=1 safely Suppose our two horizontal sync positions are sl and sr. sl > tl to suppress sync. sr < tr-sw (sw = sync width) c: Set hs=sl between tl+sr and sr (width (tl+tr+sr)-(tl+sr) == tr) f: Set hs=sr between sr and tl+sr (width tl) Worked example: active_left(80) overscan_left(N) active_right(1) overscan_right(1) sync(15) overscan_final(17-N) Want the sync to be at 90, which gives N=8 tl = 80+N = 88 (program 0x57) tr = 1+1+15+17-N = 26 (program 0x19) dl = 80 dr = 1 sl = 90 sr = 2 a width = tr = 26 b width = dr+tl-dl = 1+88-80 = 9 characters = 72 hdots = 24 cycles = 6 IOs c width = tl = 26 d width = tr = 26 e width = tr = 26 f width = tl = 88 0 10 20 30 40 50 60 70 80 90 100 110 0 10 20 30 40 50 60 70 80 90 100 110 | | | | | | | | | | | | | | | | | | | | | | | | Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X Sssssssssssssss Sssssssssssssss aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbb bbbbbbbbb cc cccccccccccccccccccccccccc cccccccccccccccccccccccc d dddddddddddddddddddddddddd ddddddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeeeee eeeeeeeeeeeeeeeeeeeeeeeee fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff b a d c e f b Horizontal Displayed right 0x0101 1 a Horizontal Total right 0x1900 26 d Horizontal Displayed left 0x5001 80 c Horizontal Sync Position left 0x5702 88 e Horizontal Total left 0x5700 88 f Horizontal Sync Position right 0x0202 2 Suppose we have a 34-character wide initial state So, order is badcefHLPS 45-48 46,48 4: 46,48,49 With 34-character initial state and one "times 6 nop" block: phase2: 2, 4, 5 phase4: 2, 5 Then with 1spf4_single, 2 works with phase2 but not phase4. 2 not reliable? Same story with 5 - works (phase4) with 1spf4 but not 1spf4_single. Works with both in phase2 With 34-character initial state and two "times 6 nop" blocks, no usable values at all in phase4 With 34-character initial state and three "times 6 nop" blocks: phase2: 0, 3 Neither reliable in both phases with 1spf4_single With 34-character initial state and four "times 6 nop" blocks: phase2: 1 With 34-character initial state, one "times 6 nop" block and 15 sync width phase4: 2, 4, 5 With 34-character initial state, one "times 6 nop" block and 10 sync width phase4: 2, 3, 5 With 34-character initial state, one "times 6 nop" block and 10 sync width, later capture phase4: 3 With 34-character initial state, one "times 6 nop" block and 15 sync width, later capture phase4: 1, 4 phase4: 3 With 34-character initial state, one "times 6 nop" block and 15 sync width and lockstep phase2: 1, 2, 4 phase2: 1, 2, 4 phase2: 1, 2, 4 phase4: 2, 4, 5 phase2: 1, 2, 4 1spf4_single: 2, 2, 2, 4, 2, 4, 2, 2, 4, 4 None of these are reliable. Can we make it reliable with a smaller hsync width? If so, try increasing overscan_final so that we can use width 15 Try increasing one of the 1-character spans to 2 ax = port value bx = temp cx = spare dx = port address si = sound di = spare sp = start addresses bp = rasters Phase 0 11111111 00000000 00000000 00000000 11111111 00000000 00000000 00000000 11111111 00000000 00000000 00000000 CRTC I I I I I I I I Phase 0 I I I I I I I I Phase 1 I I I I I I I I Phase 2 I I I I I I I I Phase 3 CGA clock is 16 hdots PIT clock is 12 hdots 100000000000000010000000000000001000000000000000 CGA 100000000000100000000000100000000000100000000000 Phase 0 010000000000010000000000010000000000010000000000 Phase 1 001000000000001000000000001000000000001000000000 Phase 2 000100000000000100000000000100000000000100000000 Phase 3 100000001000000010000000 HRES CRTC 1sof4 with es and 5702 optimizations: phase2: 0-3 phase4: 0-1 1sof4 with es and 5702 optimizations, 46 steps: phase2: 22, 24, 25, 26 phase4: 20, 22, 23, 24 1spf_unrolled: phase2: 2, 3, 4, 5 phase4: 1, 2, 3, 4, 5 CRTC-scanline 0 is long and CRTC-scanline 1 is short: Scanline 0: 0 1 ... Scanline 199: 0 1 Scanline 200: 2 Scanline 261: 63 1spf_newstart sequence: CRTC CPU Scanline -1 starts Before column 80 Start address set for line 0 Scanline 0 starts After column 0 Horizontal Total set to 88 After column 2 Horizontal Sync position set to 2 Before column 80 Start address set for line 1 Before column 89 Vertical total set to 2 Scanline 199 starts After column 0 Horizontal Total set to 88 After column 2 Horizontal Sync position set to 2 Before column 80 Vertical total set to 64 Scanline 200 starts After column 0 Horizontal Total set to 114 Before column 87 Horizontal Sync Position set to 90 What's actually happening? phase4, 1296-129a The first displayed line has start address 2 Therefore, the code is running 2 scanlines too early However, if vertical total was set to 2 early then we'd get an extra ~64 CRTC scanlines of vertical overscan The first palette port write sets the overscan colour to 2. This is because there are two lodsbs before the first palette set Palette set is skipped on scanline 0 to set vertical total So scanline 0 is empty and the first visible scanline is scanline 1 Why is scanline 0 empty? Two possibilities: One: Some signal is missing that is preventing enabling the display at the CRTC origin Seems unlikely - the long frame is clearly hitting vertical displayed, vertical sync start and vertical sync end Are we missing a horizontal signal? Would that matter? Two: During scanline 0 we're actually displaying scanline 63 of the long CRTC frame How can we distinguish between these two possibilities? What happens if we set vertical displayed to 64? Then scanline 0 displays long-frame data, which also suggests scenario Two Assume scenario Two for now. If long-frame is ending too late, it must also be starting too late What's going on at the end? Scanline 199 starts correctly Nothing appears in extra column of scanline 199 Why? Trace says: Port e0 writes at 420, 722 (302), 1020 (298) Time from 0202 CRTC write to e0 write, 926->1020 == 94 (scanline 199), 622->722 == 100 Scanline 200 repeats data from scanline 199 CRTC-scanline 0 is short and CRTC-scanline 1 is long: Scanline 260: 62 Scanline 261: 63 VT 0 Scanline 0: 1 0 ... Scanline 198: 1 VT 0 Scanline 199: 1 VT Scanline 200: 2 ... 1spf_newstart2 sequence: CRTC CPU Interrupt happens Scanline -1 starts Horizontal total initially 114 0 <= column < 88 Horizontal total set to 88 2 < column Horizontal sync position set to 2 Start Address set for line 0 Scanline 198a (1) starts Horizontal Total = 88 Horizontal Sync Position = 2 Start address set for scanline 199 Horizontal Displayed = 1 Scanline 198b (0) starts Scanline 198b display end Scanline 198b sync start Set horizontal total to 26 Set horizontal displayed to 80 Set horizontal sync position to 88 Scanline 199a (1) starts Set horizontal total to 114 Set horizontal sync position to 90 Set vertical total to 64 Column 80, VT latched (?) Are the vertical total changes happening at the right times? Vertical Total <- 2 Earliest is scanline 261a (63) column 80 Latest is scanline 0a (1) column 80 If it was too early or too late we'd have too much overscan Vertical Total <- 64 If it was too early or too late we'd have 2 extra or 2 few scanlines, and the other VT would be in the wrong place (unless both are wrong by the same amount) Vsync occurs on scanline 225. Programmed value = 25 so long frame starts on scanline 200 instead of 198. Therefore, setting vertical total to 64 is happening too late Need a better way to tell when vertical total is latched and if it depends on each CRTC-scanline having an hsync start_address_latch: vsync is on scanline 50 of 87 - as expected. Question: is long scanline firstVisible-1 the last scanline of the long frame or the second scanline of the first short frame? If the latter, why does display not get enabled? Terminology: firstVisible is the first scanline that actually shows active VRAM data scanline 0 is the second instantiation of the scanline macro in the code - it's supposed to be firstVisible, but in fact is firstVisible-1 1spf_newstart2 behavior (designed for CRTC-scanline 0 being short): phase4, 1341-1345, extra column is duplicate of column 1 13d9-13dd - same So, what must be happening is this: CRTC-scanline 0 is long. When column passes 1, horizontal displayed is still 1 so next-row-start-address is latched 1spf_newstart behavior (designed for CRTC-scanline 0 being short): phase4, 1287-128b, extra column is duplicate of column 1 Check where start address is latched. May be a row or a scanline before CRTC origin Seems like start address is latched at display end of last scanline Seems like vertical total is latched at the same place Fixing up last scanline Currently, CRTC-scanline 0 is short and CRTC-scanline 1 is long Is this is unavoidable or just a consequence of how it self-synchronizes? Does not seem to be unavoidable - it's the other way around on VWytseIj0XwW8P4623.png.raw (1spf4) However, changing ES to 5702 (so that no sync pulses are skipped) yields a large chunk of overscan at the top Assume CRTC-scanline 0 is short and CRTC-scanline 1 is long: Scanline -1: Left half is last of the overscan CRTC-scanlines Set horizontal total and horizontal sync position as if it's a normal scanline Can't set vertical total yet, so set start address for scanline 0 Could set palette register but the effect would persist for two scanlines Right half is CRTC-scanline 0 as normal Scanline 0: Left half: Need to set vertical total. Do this instead of setting the palette Scanline 199: Left half Set vertical total instead of start address set horizontal total and horizontal sync position Right half: CRTC scanline 2 Scanline 200: CRTC scanline 3 Scanline 261 == -1 CRTC scanline 64 With last-scanline fix: phase2: 28, 29, 30, 31, 32 With both VT sets in main loop: phase4: 1341-1345 every other scanline phase2: 138d-1391 every other scanline So these are a scanline apart - we've got a phase dependence for initial scanline somehow With initial VT of 64: phase2: 1425-1429, 14bd-14c1, 138d-1391 every other scanline phase4: 13ca-13ce every other scanline - still not reliable With VT moved: phase4: 13f5-13f9 phase2: 13b8-13bc With VT moved all the way to before start address set phase4: 13f5-13f9 phase2: 13b8-13bc With VT on lines -1 and 198: phase2: 13b8-13bc phase4: 13f5-13f9 With 3 nops on the VT sets: phase4: 13f5-13f9 phase2: 13b8-13bc With waitForNoVerticalSync: phase4: 13d2-13d6 phase2: 13d2-13d6 With PIT restart fixed: phase2: 142c-142e, 14c4-14c6, every other scanline phase4: 142c-142e, 14c4-14c6, every other scanline 1spf_horizontal with lockstep fix: phase4: 1448, 14a4, 14e0 with 5a02 fix: phase8: 1448, 14a2, 14a3, phase8: cgaCrtcPhase1: 1426: 40-41, 4b xx x 1427: 49-4b, 52 xxx x 1428: 49-4b, 51-52 xxx xx 1429: 48-4b, 4f-52 xxxx xxxx 142a: 48-4b, 4f-52 xxxx xxxx 142b: 48-4b, 4f-52 xxxx xxxx 142c: 44-47, 4c-50 xxxx xxxxx 142d: 44-47, 4c-50 xxxx xxXxx 142e: 44-47, 4c-50 xxxx xxxxx 142f: 42-44, 4c xxx x 1430: 42-44, 4c xxx x 1431: 4c x 1432: 4c x 1433: 4c x 1434: 4c x cgaCrtcPhase0: 1425: 47, 50 x x 1426: 46-47, 4f-50 xx xx 1427: 45-47, 4d-4e xxx xx 1428: 44-47, 4d-4e xxxx xx 1429: 43-47, 4b-4e xxxxx xxxx 142a: 43-47, 4a-4e xxxxx xxxxx 142b: 43-47, 4a-4e xxxxx xxxxx 142c: 40-43, 48-4b, 52 xxxx xxxx x 142d: 40-43, 48-4b, 52 xxxx xxxx x 142e: 40-43, 48-4b, 52 xxxx xxxx x 142f: 40, 48, 51-52 x x xx 1430: 40, 48, 51-52 x x xx 1431: 48 x phase4: cgaCrtcPhase1: 1425: 4b x 1426: 40-41, 4a-4b xx xx 1427: 49-4b, 52 xxx x 1428: 49-4b, 51-52 xxx xx 1429: 48-4b, 4f-52 xxxx xxxx 142a: 48-4b, 4f-52 xxxx xxxx 142b: 48-4b, 4f-52 xxxx xxxx 142c: 43-47, 4c-50 xxxxx xxxxx 142d: 43-47, 4c-50 xxxxx xxxxx 142e: 43-47, 4c-50 xxxxx xxxxx 142f: 42-44, 4c xxx x 1430: 42-44, 4c xxx x 1431: 4c x cgaCrtcPhase0: 1425: 50 x 1426: 46, 4e-50 x xxx 1427: 44-46, 4d xxx x 1428: 44-46, 4c-4d xxx xx 1429: 43-46, 4a-4d xxxx xxxx 142a: 43-46, 4a-4d xxxx xxxx 142b: 43-46, 4a-4d xxxx xxxx 142c: 40-42, 47-4b, 52 xxx xxxxx x 142d: 40-42, 47-4b, 52 xxx xxXxx x 142e: 40-42, 47-4b, 52 xxx xxxxx x 142f: 47, 51-52 x xx 1430: 47, 51-52 x xx 1431: 47 x 1432: 47 x 1433: 47 x 1434: 47 x Getting bottom-left and top scanline correct: phase4: cgaCrtcPhase0: 1426: 46, 4e-50 x xxx 1427: 44-46, 4d xxx x 1428: 44-46, 4c-4d xxx xx 1429: 43-46, 4a-4d xxxx xxxx 142a: 43-46, 4a-4d xxXx xxxx 142b: 43-46, 4a-4d xxxx xxxx 142c: 40-41, 47-4a xx xxxx 142d: 40-41, 47-4a, 52 xx xxxx x 142e: 40-41, 47-4a, 52 xx xxxx x 142f: 47, 51-52 x xx 1430: 47, 51-52 x xx 1431: 47 x cgaCrtcPhase1: 1425: 4b x 1426: 40-41, 4a-4b xx xx 1427: 49-4b, 52 xxx x 1428: 49-4b, 51-52 xxx xx 1429: 48-4b, 4f-52 xxxx xxxx 142a: 48-4b, 4f-52 xxxx xxxx 142b: 48-4b, 4e-52 xxxx xxxxx 142c: 44-45, 4c-4f xx xxxx 142d: 43-45, 4c-4f xxx xxxx 142e: 43-45, 4c-4f xxx xxxx 142f: 42-44 xxx 1430: 42-44 xxx phase8: cgaCrtcPhase0: 1424: 47 x 1425: 47 x 1426: 46-47, 4f-50 xx xx 1427: 44-47, 4d xxxx x 1428: 44-47, 4d xxxx x 1429: 43-46, 4b-4d xxxx xxx 142a: 43-46, 4a-4d xxXx xxxx 142b: 43-46, 4a-4d xxxx xxxx 142c: 40-41. 48-4a xx xxx 142d: 40-41. 48-4a, 52 xx xxx x 142e: 40-41. 48-4a, 52 xx xxx x 142f: 40, 52 x x 1430: 51-52 xx cgaCrtcPhase1: 1426: 40-41, 4b xx x 1427: 48-4b, 52 xxxx x 1428: 49-4b, 51-52 xxx xx 1429: 48-4b, 4f-52 xxxx xxxx 142a: 48-4b, 4f-52 xxxx xxxx 142b: 48-4b, 4f-52 xxxx xxxx 142c: 45-46, 4c-4f xx xxxx 142d: 44-46, 4c-4f xxx xxxx 142e: 44-46, 4c-4f xxx xxxx 142f: 43-44, 4c xx x 1440: 42-44, 4c xxx x 1431: 4c x trace results scanline 5700 0202 xx0c xx0d e0 0104 0101 1900 5001 5702 -1 201/ 206 234/ 239 278/ 283 312/ 317 340 363/ 368 408 428 455 483 68 305 306 306 305 305 305 305 305 305 0 507 540 584 617/ 622 645 686 713/ 718 733/ 738 760/ 765 788/ 793 68 305 305 305 305 305 304 304 304 304 304 1 812/ 817 845/ 850 889/ 894 922/ 927 950 990 1017/1022 1037/1042 1064/1069 1092/1097 67 304 304 304 304 304 304 304 304 304 304 2 1116/1121 1149/1154 1193/1198 1226/1231 1254 1294 1321 1341 1368 1396 67 304 304 304 304 304 304 304 304 304 304 3 1420 1453 1497 1530 1558 1598 1625 1645 1672 1700 67 304 304 304 304 304 305 305 308 308 198 1724 1757 1801 1834 1862 1885/ 1930 1950 1980 2008 68 Address for short scanline is immediately before the long scanline to the right, and is the programmed start address This implies the short scanline is scanline 0 TODO: Fix the problem on glitchy machines See what we need to change to put a VRAM access in the loop Get a better understanding of how 1spf works: Use rgbi_capture to see size and position of hsync and active areas relative to where 0x3d9 write happens Use trace to see where port writes occur 19 possibilities if CPU code is synchronised to PIT, 76 if we delay by 0-3 CPU cycles Want to annotate the traces with how they look on screen Integrate trace into 1spf? How does trace work? Output character 6, 16*(trigger trace, capture, 425 CPU cycles/byte flush), output character 7 - can capture 2048 cycles about every 4 frames, so a full capture takes a bit over a second LRES example: 640 hdots active - palette change on hdot 577 64 hdots primary right overscan 8 hdots secondary active 23 hdots secondary right overscan (blanking) 64 hdots hsync 73 hdots left blanking 40 hdots left overscan HRES example: 640 hdots active - palette change on hdot 562 (phase 0, offset 142a) 64 hdots primary right overscan 8 hdots secondary active 31 hdots secondary right overscan 64 hdots hsync 25 hdots left blanking 80 hdots left overscan 640 hdots active - palette change on hdot 557 (phase 1, offset 142c) 64 hdots primary right overscan 8 hdots secondary active 23 hdots secondary right overscan 64 hdots hsync 33 hdots left blanking 80 hdots left overscan Done: Test 1spf4.bin with new optimizations (es and 5702) Before the critical loop starts, need to: Wait for scanline 0 to start Set r0=0x57, r2=0x57, (r6=0x02), r4=0x01, r12=high(1), r13=low(1) At the end of the critical loop, need to: Wait for scanline 199 to start Set r0=0x71, r2=0x5a, (r6=0x01), r4=0x40, r12=high(next 0), r13=low(next 0) Try a port access to get 304 cycles for start-of-frame in trace Get 304 cycles in trace for first scanline Realign loop to scanline edge Refactor in macro to avoid duplication Set up data structures to display something Animation of rose Create table of start address for y position Does old restarts have 256 possible y positions? Set CRTC to normal frame Align CPU with CRTC top-left to display-enable-polling precision (using display-enable polling) Align PIT with CRTC by starting it at period 19912 Realign to IO precision by using display-enable polling and a PIT period of 19911 Add adjustment parameter by having one PIT frame longer or shorter than 19912 PIT cycles stable: nop-slide for DRAM refresh 1spf_newstart and 1spf_newstart2: Check whether long scanline is 0 or 1. Both have short scanline being 0 Try moving the VT set instructions slightly Fix problem that causes loss of sync unless exact to the cycle. Fixing this should also fix the phase dependence and occasional failure to start when moving up/down Figure out possible relationships between CRTC and PIT - it's just the 4 CGA/PIT startup phases times the two CGA/CRTC phases 100000000000100000000000100000000000100000000000 PIT 10001000 100000001000000010000000100000001000000010000000 CRTC phase 0 010000000100000001000000010000000100000001000000 CRTC phase 1 001000000010000000100000001000000010000000100000 CRTC phase 2 000100000001000000010000000100000001000000010000 CRTC phase 3 Program for checking wait states of each segment Remove lockstep Set up a horizontal-only screen Wait for it to stabilize Turn off refresh Add possibility of moving the refresh (presumably refresh phase is why adding "out dx,al" to the beginning of the interrupt routine causes only a single position to work) Sync to CRTC horizontally using PIT wait for N cycles Turn on refresh with period 19 Check if routine is self-synchronizing or has slop Add "out dx,al" to start of interrupt routine Set up dx and al before hlt Add another palette change after critical part Check that DRAM won't decay With refresh off, waitForDisplayEnable loop is 37 cycles or 9.25 IOs, so we might be waiting for 10 scanlines But add 15 IOs for writePIT16, plus an interrupt latency Refresh safety is 1.5ms which is ~23 scanlines so we could hit issues Need an extra step to move the first test point left to undo the time of writePIT16 and interrupt latency Fix up lockstep Get 1spf_horizontal working consistently Try updated lockstep Figure out how many DRAM refresh phases work for each initial delay (slop pattern) See if changing left horizontal sync from 0x57 to 0x5a improves slop Move current setup back to horizontal-only program and see if that has the same problem (and, if not, what the slop is there) try moving VT set back to 0 and 198 New startup Figure out if changing address 200 fixes it, or if it's a real problem with the routine - it's a real problem with the routine Display numbers on MDA CGA/PIT phase refresh phase CGA/CRTC phase startup time Add a key to switch to numbers display on CGA Add control to switch phases Test both CRTC phases in both startup phases Update stability.com: Same startup and other features as rose Fix static last line Switch to mode 0x0b so we can see where palette change is happening Bisect to figure out what's different between rose and nolockstep Switch to nolockstep's startaddress pattern Switch to nolockstep's data Figure out what address it's fixed as (not constant offset from correct or previous address!) Update rose.com: Check that initial values that work for both phases Test from a real floppy In waitstate_test, add option to disable extender card Send out updated binaries Last scanline is repeated Start address array is becoming corrupted