From: sl8nl@cc.usu.edu
Newsgroups: rec.games.programmer
Subject: Re: Synchronization with Refresh
Date: 28 Dec 92 22:01:09 MDT
Distribution: usa
Organization: Utah State University

> The actual code that synchronizes page display with video refresh.

Here it is:

(Originally based on code by Zax of the Phoney Coders)

Joshua Jensen

begin 750 retrace.asm
M:61E86P-"FQO8V%L<R!`0`T*#0IM;V1E;"!,87)G90T*#0IC;V1E<V5G#0H-
M"D]L9$EN=#`X"61D"3`-"E)E=')A8V5#;W5N=`ED8@DP#0H-"E1I;65R4W!E
M960@("`@(&5Q=2`Q-C4W,@D).R`Q+#$Y,RPQ.#(@9&EV(#<P("`H22!T:&EN
M:RD-"@T*<')O8PE->51I;65R#0H-"CM#86QL('1H92!O;&0@=&EM97(@:6YT
M97)R=7!T(')O=71I;F4@:&5R92XN+@T*#0H)<'5S:"!A>"!D>"!D<PT*"6EN
M8R`@6T)Y=&4@8W,Z4F5T<F%C94-O=6YT70T*#0H[5&AE('1I;65R(&ES(&YO
M="`Q,#`E(&%C8W5R871E+"!A9&IU<W0@=VET:"!V97)T:6-A;"!R971R86-E
M(&%G86EN#0H[5V%I="!F;W(@=F5R=&EC86P@<F5T<F%C90T*#0H);6]V("!D
M>"PP,T1!:`D)("`@("`@.T18(#T@0U)40R!3=&%T=7,@4&]R=`T*0$`Q.@T*
M"6EN("`@86PL9'@)"2`@("`@(#M296%D('1H92!P;W)T#0H)86YD("!A;"PX
M"0D@("`@("`[27,@82!V97)T:6-A;"!R971R86-E(&%C=&EV93\-"@EJ>B`@
M('-H;W)T($!`,0T*#0H[4F5S970@=&AE('1I;65R#0H);6]V("!A;"PS-&@-
M"@EO=70@(#0S:"QA;`T*.U=R:71E('1H92!N97<@<W!E960-"@EM;W8@(&%X
M+%1I;65R4W!E960-"@EO=70@(#0P:"QA;`T*"6UO=B`@86PL86@-"@EO=70@
M(#0P:"QA;`T*#0H[4VEG;F%L($5/22`H96YD+6]F+6EN=&5R<G5P="D-"@EM
M;W8@(&%L+#(P:`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