Re: [stella] Overscan

Subject: Re: [stella] Overscan
From: Mark De Smet <de-smet@xxxxxxxxxxxxxxx>
Date: Wed, 21 Jun 2000 21:57:11 -0500 (CDT)
> >The 2600 (as with most game systems until recently) fool the TV into 
> >displaying full-width fields instead of true interlacing.  This results in 
> >half the effective vertical resolution but without the interlace 
> >flicker.  It doesn't really just display duplicate fields becaue the net 
> >effect is no black space inbetween fields.  It's turned into 60fps 
> >progressive scan.

Fascinating, never knew that.  So the lines it draws are effectively
double the width(spaced out that way)?

Why then is flicker appear so bad in this double width progressive mode?  
A regular NTSC signal flickers between frames because it is interlaced,
the only difference between that and frame flicker on the atari is that
the lines are double width, so the flickered objects are twice as big,
correct?  I am curious why vcs flicker is completely obvious, yet a
regular NTSC signal shows zero flicker.

> Somebody explained it a while back (loooong time ago) as such:
> Interlaced NTSC is actually 525.5 lines for two fields.  The extra 0.5
> line is what causes the TV to move the next field down 0.5 scanlines,
> which generates the interlace.  If somebody can figure out a way to make

This makes sense from what I have read about NTSC and how a screen
displays.

> the TIA generate half a scanline (by which I mean count 114 color clocks
> after WSYNC and then start generating another horizontal sync), and do

>From what I have read, it seems the half line should be half of the video
line, not half of the entire line time(meaning half of the 160 clocks,
after the first 68.

> that every other field, you should get a true 30fps interlaced display.
> The only possible mechanism would be RSYNC, which still nobody has gone
> to experiment with (don't look at me, I haven't the time or interest
> currently).

Good call!  I agree, RSYNC should cut a line in half, effectively doing
the timing right.

Here is my attempt, note that it does not work.  I wouldn't bother trying
it on an emulator, as the results would probably have nothing to do with
reality; I would only try it on a vcs/tv.  My TV(actually a studio
monitor), is unable to hold vertically to it, and looses the color.  It is
supposed to draw the rainbow, with a line count being displayed with a
quad wide player.  The different frames put the player in different
positions.  I put it into my code framework, which I wrote a while back,
but forgot to post, I'll send the original in another message.

I am quite interested in getting this to work if we can, so if anyone else
wants look at this, try it out, and help figure it out that would be cool!

> Anyway, this noninterlaced signal is not standard broadcast NTSC.  
> You can't (or shouldn't be able to) directly record this to tape or
> broadcast it.  It needs to go through a frame synchronizer or a time

FYI, I was able to do both.  Don't tell the FCC, but I connected the VCS
output to a directional VHF antenna, and pointed it at my tv's rabbit
ears, and was able to get reasonable image quality transmitting 3 feet.(a
little static)  I've also recorded it on video, although it didn't work
100%.  The resulting recording scrolled, but it mostly held, so it served
the purpose of recording in 'stone' my high score on music machine(I
wrapped the scoreboard after over an hour of play.  BTW, if you have never
played it on a real vcs, it is worth getting a copy from hozervideo
because it is like kaboom, but better!)



Mark



;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; Basic game framework
; by Mark De Smet 9/9/99
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;This file is intended to be used as a basic framework for implementing 
;a game.  All it does is display the scrolling rainbow and the binary
;values of those colors.  To remove the rainbow display, remove the lines 
;with markers "REMOVE".  You will then want to add in your own display 
;kernal/s and your game logic.  Game logic can be placed into GameCalc and 
;GameCalc2
;


;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                         CODE CONFIG
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;stuff to setup dasm, and compile for atari.

	processor 6502
	include vcs.h

;Your variables and constants:
	seg.u ramspace
	org $80		;ram space
;REMOVE this next line for your game
linecolor	ds 1  ;a variable for the first line color.
framenum	ds 1 ;stores which frame we are on.


;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                        CODE
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;start program at beginning of ROM space
	seg romspace
	org $F000
Start

;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                        INIT
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;Initialise your game here.

	SEI  ; Disable interrupts, if there are any.
	CLD  ; Clear BCD math bit.
;Setup the stack
	LDX  #$FF
	TXS  ; Set stack to beginning.

; Since X is already loaded to 0xFF, our task becomes simply to ocunt
; everything off.

	LDA #0
B1      STA 0,X
	DEX
	BNE B1

;REMOVE the next 2 lines for your game
	LDA #$07
	STA NUSIZ0

;load up the timer, not to use, but because we don't start the vertical 
;sync until the timer is zero.  Additionally, if the timer is counting
;down by ones, it is possible that the timer wait loop will never exit
;otherwise.
	LDA #10		;load it with just some small number.
			;actual wait time is irrelevant because
			;we've already wasted a bunch of lines doing that
			;memory blank.
	STA TIM8T

;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                          MAIN LOOP
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;add any more subroutines that you may wish.
;
;to save both rom(use less code) and ram(use less stack) space, you
;can remove this entire loop, and simply jmp between each routine(because
;they are only ever called in the same order) such that at the end of
;VerticalBlank, instead of a JSR, put a JMP GameCalc.  And so on.  At the
;end of Overscan, then you would replace RTS with JMP VerticalBlank
MainLoop
	JSR VerticalSync	;start up the vertical blank counter and
				;do vertical sync.
	JSR GameCalc		;Do calculations during Vblank
	LDA framenum
	BNE alabela	;branch for odd/even frames
	JSR DrawScreen		;Draw the screen
	JMP alabelb
alabela
	JSR DrawScreen2		;Draw the screen
alabelb
	JSR OverScan		;start up the overscan counter
	JSR GameCalc2		;Do More calculations during overscan.
	JMP MainLoop		;Continue forever.


;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                Vertical Sync
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;This routine does the three lines of VSYNC, and sets up the timer for
;counting the length of the vertical blanking interval.
;
;Note that there are 3 STA WSYNC's in a row.  Between each, you can add
;extra instructions etc as long as the entire length of the instructions
;between WSYNC's is less than 76 processor cycles.
;However, you would only bother doing this if you ran out of time 
;during the vertical blanking and overscan intervals, or if you had some 
;small bit of code you wanted to take care of, but don't want to fit in 
;elsewhere.
;

VerticalSync

endoverscan
	LDA INTIM
	BNE endoverscan
	LDA  #2
	STA WSYNC
;wrong?:
	STA  WSYNC  
;wrong?:
	STA  WSYNC
;wrong?:
	STA  WSYNC
	STA  VSYNC	;Begin vertical sync.

;clear the graphics registers incase we forget to reset them before the
;first line of our kernal.
	LDA #0
	STA PF0
	STA PF1
	STA PF1
	STA GRP0
	STA GRP1
	STA ENAM0
	STA ENAM1
	STA ENABL

	STA  WSYNC	; First line of VSYNC
	STA  WSYNC	; Second line of VSYNC.
	LDA  #44	;setup the timer for vertical blank.
	STA  TIM64T
	STA  WSYNC	; Third line of VSYNC.
	STA  VSYNC	; (0)

	RTS  



;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                   game calculations
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;This routine takes place in the vertical blank period.
;This and everything called from this must be completed in about 2800 cycles.
;If we assume that every instruction is 3 cycles, then that is about 900
;instructions.
;If you add a routine to the main loop that is also in the vertical blank, 
;then that routine, plus this one must fit in the 2800 cycles.
;
GameCalc





;You may wish to clear the collision register before the screen is drawn.
	LDA #0
	STA CXCLR
	RTS




;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                  Draw the screen
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
;
DrawScreen
;wait for end of the vertical blank
	LDA INTIM
	BNE DrawScreen
	STA WSYNC	;start at the beginning of next line.
	STA VBLANK	;End the VBLANK period with a zero.


;REMOVE the next 4 instructions for your game.
;make the rainbow.
;	DEC linecolor	;scroll the color.
;	DEC linecolor	;lower bit of color register not really used, so 
			;let's up it by two so it will scroll really fast!
	LDX linecolor	;load up the line color.
	STX COLUBK



	LDY #191	;the number of lines in this kernal.
;REMOVE the next line for your game.
	STA RESP0
ScanLoop
	STA WSYNC	;wait for beginning of next line.
;draw this line:


;REMOVE the next 4 instructions for your game.
	INX		;change line color for next line.
	INX		;change color everyline, not everyother.
	STX COLUBK	;set line color

	STY GRP0	;display line number

	DEY		;move counter to next line
	BNE ScanLoop	;if not done w/ this kernal, do another line.

	LDA #1	;goto odd frame
	STA framenum

	LDA #2
	STA WSYNC  ;Finish this scanline.
;begin line '196'
	STA VBLANK ; Make TIA output invisible,
	RTS







DrawScreen2
;wait for end of the vertical blank
	LDA INTIM
	BNE DrawScreen2
	STA WSYNC	;start at the beginning of next line.

	NOP
	NOP
	NOP
	NOP
	NOP ;5
	NOP
	NOP
	NOP
	NOP
	NOP ;10
	NOP
	NOP
	NOP
	NOP
	NOP ;15
	NOP
	NOP
	NOP ;18
	NOP
	NOP ;20
	NOP
	NOP ;22
;	NOP ;23
	STA NUSIZ1	;need an odd number of cycles

	STA RSYNC


	STA VBLANK	;End the VBLANK period with a zero.

	STA WSYNC	;waste this 1/2 line, don't want to deal with it!

;REMOVE the next 4 instructions for your game.
;make the rainbow.
;	DEC linecolor	;scroll the color.
;	DEC linecolor	;lower bit of color register not really used, so 
			;let's up it by two so it will scroll really fast!
	LDX linecolor	;load up the line color.
	STX COLUBK



;	LDY #191	;the number of lines in this kernal.
	LDY #190	;the number of lines in this kernal.
;REMOVE the next line for your game.
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	STA RESP0
ScanLoop2
	STA WSYNC	;wait for beginning of next line.
;draw this line:


;REMOVE the next 4 instructions for your game.
	INX		;change line color for next line.
	INX		;change color everyline, not everyother.
	STX COLUBK	;set line color

	STY GRP0	;display line number

	DEY		;move counter to next line
	BNE ScanLoop2	;if not done w/ this kernal, do another line.

	LDA #0	;goto odd frame
	STA framenum

	LDA #2
	STA WSYNC  ;Finish this scanline.
;begin line '196'
	STA VBLANK ; Make TIA output invisible,
	RTS





;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                      overscan
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;start up the timer for counting the length of the overscan.
;
;
OverScan
	STA WSYNC
	LDA #34
	STA TIM64T



	RTS


;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;                                   game calculations, part 2
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;This routine takes place in the overscan period.
;
;This and everything called from this must be completed in about 2100 cycles.
;If we assume that every instruction is 3 cycles, then that is about 700
;instructions.
;If you add a routine to the main loop that is also in the overscan, 
;then that routine, plus this one must fit in the 2100 cycles.
;
GameCalc2


	RTS





	org $FFFC
	.word Start	;power up vector
	.word Start	;interrupt vector
			;The data for this vector is not needed, but you
			;need to add two more bytes here if you want to
			;make it compile to an even 4096 bytes(4K)




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

Current Thread