;******************************************************************************
;            (C) Copyright 1992-1995, Radius, Inc. and Atari Corp.
; Secret and confidential                                   All rights reserved
;******************************************************************************
; This source code and any compilation or derivative thereof is the joint
; property of Radius, Inc. and Atari Corp.  This code is provided pursuant
; to a Software License Agreement and/or Software Development Contract.  This
; code is the proprietary information of Radius, Inc. and Atari Corp. and is
; confidential in nature.  Its use and dissemination by any party other than
; Atari Corp. are strictly limited by the confidential information provisions
; of the Agreement or Contract referenced above.
;******************************************************************************
; Revision 1.22 08/01/94  23:14:00  nbk
; Increased buffer size for circular buffer depending on setting
; of USE_CDROM, so you can see a 13 chunks version of the ESCAPE
; sequence from starwars
;
; Revision 1.21 07/09/94  00:22:00  nbk
; Minimal changes to be surely to run even on outer rim of CD Rev. 2
; development systems and some more commets where to modify MEDIA_BASE
; to start reading film data other than at the beginning of the disk
;  
; Revision 1.2  04/27/94  16:09:35  jpe
; CD-BIOS changes incorporated.
;
; Revision 1.1  04/25/94  16:56:30  jpe
; Increased NLINES from 200 to 216.
; Increased SAMP_RATE from 22100 to 22252.
; Added definition of DRIFT_RATE.
;
; Revision 1.0  04/08/94  13:52:35  jpe
; Initial revision.
;******************************************************************************
; 200 23 May 95 JPE     Reconciled differences with older 'cinepak.inc' file.
;                       Incorporated equ's previously defined in 'startup.s'.
; 201 24 May 95 JPE     Added tag definitions for subtitle atom and audio
;                       description field.
; 202 31 May 95 JPE     HEAD_START parameter reduced from 0xc0000 to 0xa0000
;                       to accommodate short movies (less than ~2 sec).
; 203 07 Jun 95 JPE     Eliminated CBUF_END.
; 204 20 Jun 95 JPE     Reduced LEADER to zero. Reduced AUD_CHUNK to $1168
;                       (0.2 seconds).
; 205 23 Aug 95 JPE     Reduced HEAD_START to $6000 (was hacked in loader.s).
;                       Added support for voiceover. LEADER restored to 28
;                       blocks. Equates for CD tracks added.
; 206 25 Aug 95 JPE     Screen object size reduced from 240 to 216 lines.
; 207 14 Sep 95 JPE     Added constants for manipulation of GPU RGB tables.
; 208 08 Nov 95 JPE     Official legal banner added (no other changes).
; 209 29 Nov 95 JPE     Removed tags for subtitle and voiceover atoms. Added
;                       tags for auxiliary atom and text slides.
; 210 02 Feb 96 JPE     Incorporated CD and DEMO assembly switches.
; 211 16 Feb 96 JPE     Eliminated DEMO switch.
;******************************************************************************

NPIXELS     	equ     320             ; Display pixels per line
NLINES      	equ     216             ; Display lines per screen
ROWBYTES        equ     2*NPIXELS       ; Bytes per line (16-bit pixels)

HEAD_START      equ     $6000           ; Initial space between R/W pointers
			
GPU_OFFSET      equ     $200            ; Start of Cinepak GPU Code

INDX_SYNC       equ     'INDX'          ; Sync for index table
AUXL_TAG        equ     'AUXL'          ; Auxiliary atom tag
FILM_TAG        equ     'FILM'          ; Film header tag
TXTS_TAG        equ     'TXTS'          ; Text slide tag
ADSC_TAG        equ     'ADSC'          ; Audio description tag
ADS2_TAG        equ     'ADS2'          ; Audio description tag (slides)
SAMP_TAG        equ     'STAB'          ; Sample table tag

NORMAL_END      equ     $00000000      	; Normal end to program
SYNC_FAIL       equ     $11111111      	; Failed in sync search
BOGUS_FILM      equ     $22222222      	; Tag not found in film header
BOGUS_SAMP      equ     $33333333      	; Tag not found in sample table
PREDEC_ERR      equ     $44444444      	; Pre-decompress failed
DECOMP_ERR      equ     $55555555      	; Decompress failed

TICK_RATE       equ     600             ; PIT rate
AUD_CHUNK       equ     $1168           ; Audio chunk size
SAMP_RATE       equ     22252           ; Audio sample rate

; The input sample rate is 22.252 kHz; the output rate is 21.867 kHz. The
; ratio of these values is 1.017606439. A correction must periodically be
; made to  prevent audio drift.

DRIFT_RATE  	equ     $481db08        ; 0.017606439 * (65536)^2 in Q32

AUDIO_LAG       set     (AUD_CHUNK<<16)/SAMP_RATE   ; Q16 value
AUDIO_LAG       set     AUDIO_LAG+(AUDIO_LAG>>1)    ; Multiply by 1.5

MAX_DELAY       set     8               ; Reciprocal of video-audio delay
MAX_DELAY       set     (1<<16)/MAX_DELAY       ; Q16 value

; Time code parameters.

BLK_SIZE        equ     2352            ; CD block (sector) size in bytes
BLK_RATE        equ     75              ; 75 blocks/second @ 1X
LEADER          equ     28              ; Number of blocks in leader

; This can be changed to make things work if you get sync problems all the time.

MARGIN          equ     7               ; Safety margin was 6 before DMS edit

; Data synchronization parameters.

SYNC_SIZE       equ     64              ; Number of bytes in sync
SRCH_WIN    	equ     (BLK_SIZE*31) 	; Search window (31 blocks)

; CD session and track parameters.

GAME_SESSION    equ     1               ; Recording session for game

BOOT_TRACK      equ     0               ; Bootable track
INDEX_TRACK     equ     1               ; Film index track
FILM_TRACK      equ     2               ; Film data track

; Parameters for fudging RGB tables in GPU.

RGB_OFFSET      equ     $4d8            ; Table offset from origin
RGB_SIZE        equ     768             ; Table size (192 longs)

; Conditional assembly switches.

CD              equ     0               ; 0 shortens playlist

; Object List Equates

USESCALED	equ     1               ; Set to use SCALED OBJECT w/RELEASE
					; for better bus sharing.

    .if (USESCALED)
LISTSIZE	equ     8
    .else
LISTSIZE	equ     7
    .endif

BMP_PHRASES	equ     (NPIXELS/4)
BITMAP_OFF      equ     (5*8)
