[stella] Closed Captioning

Subject: [stella] Closed Captioning
From: "Eric Ball" <ericball@xxxxxxxxxxxx>
Date: Sun, 10 Nov 2002 21:49:24 -0500
Finally took the time to try out my CC encoder.  Unfortunately, the TV
didn't do anything, so I'm going to turn my efforts back to game
programming.  But for those interested, here is the code required to produce
a mostly CC compliant signal.

LINE1 STA WSYNC
 LDA INTIM
 BNE VWAIT
 LDY #$02
 STY VSYNC
 STA WSYNC
 LDY #14*76/64+1
 STA WSYNC
 STY TIM64T
 STA VSYNC

 LDY CCINDX
 LDX CCDATA,Y
 LDA CCX,X
 TAX
 LDA CCDATA+1,Y
 TAY
 LDA CCY,Y
 TAY
 INC CCINDX
 INC CCINDX

 STA HMCLR
LINE17 STA WSYNC
 LDA INTIM
 BNE LINE17

 LDA #$20
 STA CTRLPF
 STA NUSIZ0
 STA NUSIZ1

 LDA #$10
 STA HMM0

 LDA #$08

 STA RESP0

 STA COLUPF
 STA COLUP0
 STA COLUP1

 STA RESP1

 TXA
 AND #$A8
 STA PF2

 STA RESM0

 LDA #$F0
 STA GRP0
 STA GRP1

 STA RESM1

 LDA #$E0
 STA HMM1

 LDA #$A0

 STA RESBL

 STA PF0
LINE18 STA HMOVE
 STA VBLANK

 LDA #$28
 STA PF1

 TXA
 STA ENAM0

 TXA
 ROR
 ROR
 ROR
 AND #$40
 STA CXCLR
 STA PF0

 TYA
 ROL
 STA ENAM1
 TXA
 ROL
 AND #$A9
 STA PF1

 TYA
 LSR
 STA ENABL

 TYA
 AND #$4A
 STA PF2

 LDY #21*76/64+1
 LDX #$02
 STA WSYNC
 STY TIM64T
 STX VBLANK

CCX HEX 0408202C808CA4A8020E262A868AA2AE
 HEX 010D25298589A1AD070B232F838FA7AB
 HEX 404C6468C4C8E0EC464A626EC2CEE6EA
 HEX 4549616DC1CDE5E9434F676BC7CBE3EF
 HEX 101C34389498B0BC161A323E929EB6BA
 HEX 1519313D919DB5B9131F373B979BB3BF
 HEX 5458707CD0DCF4F8525E767AD6DAF2FE
 HEX 515D7579D5D9F1FD575B737FD3DFF7FB

CCY HEX 0001808102038283080988890A0B8A8B
 HEX 04058485060786870C0D8C8D0E0F8E8F
 HEX 4041C0C14243C2C34849C8C94A4BCACB
 HEX 4445C4C54647C6C74C4DCCCD4E4FCECF

A few notes:
1. As per my earlier notes, some of the normal CC signal falls outside the
2600 visible line: 2 cycles of the run-in and the most significant bit and
the parity bit of the second byte.  This implementation also loses 2 more
cycles of run-in to the HMOVE blank (although the suspicion was that most
modern decoders didn't require the run-in anyway).  The lack of MSB & parity
for the second byte has a significant impact on the characters & control
codes which may be used.
2. The CCX table translates the first byte to the bit order required by the
display routine and adds the parity bit.  The CCY table does the same for
the second byte.  The sample code uses a table and an index (not included).
3. I have assumed that the 2600 VSYNC produces NTSC syncronization pulses
(NTSC lines 4-6), which means the 2600 should create the CC signal (which
appears on NTSC line 21)  on line 18.
4. If you want to use this code, you will need a CC codebook for the
required control codes.
5. I'm really quite proud of my Line 17/18 code.  Getting the cycles to work
out correctly for the required strobes was tricky.  I also learned that
HMOVE before cycle 0 has some very strange side effects.


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread