-
Notifications
You must be signed in to change notification settings - Fork 9
Xband MK2 Sync Method
Remember, all calculations are based on a 2400 baud modem…
syncJitter equ $3
; acceptable synchronization jitter
; one bit is 1/2400 sec or 417 ?sec.
; each VCnt is 170.7 ?sec, so there are
; about 2.5 VCnts per bit. A sync jitter of 3
; should be achievable. It also leaves room for
; the 1/2 line variation between interlaced and
; non-interlaced frames (1/2 line = 32 ?sec.
; 32/171 = 0.19 Vcnts) and margin for
; clock differential between the 2 machines.
;===============
; Vbl Synchronization (SyncOTron)
; Vbls are synchronized each time vbl interrupts are enabled (except in local mode
; when vbl interrupts free run)
; Syncotron matches Vbls within syncJitter tolerance. This constraint is actually
; unnecessary for reliable operation, but it is a simplification during development.
; eventually, we could eliminate it for faster average sync-up time (albeit same
; worst-case).
;
; Sync is maintained during runMode to withih 2 x SyncJitter tolerance.
;
; The current protocol works as follows:
;
; EstablishSyncMode:
;
; Initially establishes a connection between both machines. Uses GTEstablishSynch. Goes
; to SyncMasterMode if Master, to SyncSlaveMode if Slave. Note that throughout EstablishSyncMode
; and SyncMasterMode/SyncSlaveMode control is never returned to the mainline code. Vbls
; during these modes are either ignored or handled by slewMode. The mainline wakes up again
; in RunMode.
;
; SyncMasterMode:
;
; Master side SyncOTron.
;
; 1. The master sends a echoByte to the slave. It waits for a reply, sampling every
; VCnt. The second byte of the echoByte is used to send syncOTxByte to the slave.
;
; 2. Upon receiving an echo from the slave followed by the VCnt of the master’s echo
; arriving to the slave, the master counts the number of VCnts that have elapsed
; (to compute the latency) and determines whether it would be faster for itself or the slave to
; switch to interlace mode for their respective Vbls to slew together. It also
; computes how many Vbls it will take for them to be slewed together. It sends a
; message to the slave to that effect, placing one of them in interlace mode, and
; the other in non-int. They both then count the number Vbls as they slew into sync.
;
; 3. The master waits for an echo from the slave to be certain that the slave is listening
; when it sends the timing-critical syncLock. The echo is followed by syncORxByte.
;
; 4. The master sends a syncLock to the slave. It then waits latency frames for the slave to
; receive the data. If the refVCnt is within deferEarly of Vbl the master waits an extra
; frame. The master then goes into RunMode, jsr’s to the SyncOCompletion routine, and
; RTE’s to the mainline code.
;
;
; Slave side SyncOTron
;
; 1. The slave waits for an echoByte, sampling every VCnt. The second byte is syncORxByte.
; The slave responds with an echoByte followed by the VCnt at which the master’s echoByte
; arrived.
;
; 2. The slave waits for a intMessage that says whether to go into interlaced or non-int
; mode and the number of frames to slew fors.
;
; 3. After slewing the slave sends an echoByte to the master. The second byte is syncOTxByte.
;
; 4. The slave waits for a syncLock. The syncLock is followed by a refVCnt. If the refVCnt
; falls within deferEarly of Vbl, and the current VCnt is in the second half of the frame
; (i.e. it is not early in the frame), the slave waits an additional frame. The slave then
; goes into runMode, jsr’s to the SyncOCompletion routine, and RTE’s to the mainline code.
;
; RunMode (-1):
; rx Data
; compare arrival VCnt to refTimeStamp
; call syncOTron to determine if going into interlace mode will seek toward refTimeStamp
;
; if rxdata is not noData
; put into rxFifo
;
; if rxFifo is empty
; send noData
; skip this vbl
; else
; if syncFlag is zero (i.e. the game loop completed by vbl)
; read controllers
; tx read data
; set syncFlag
; do the Vbl
; else
; send noData
; skip this vbl
;
;===============