
; This is the header for the Stasis module.  You should be able to gleen
; what information you need from this.  Note that stasisform illustrates
; the Stasis sample format.

#set Service_PsychoStarting=&80300
#set Service_PsychoDying   =&80301
#set Service_UKStasisFormat=&80310
#set Service_StasisSave    =&80311
#set Service_StasisIdentify=&80312
#set Service_StasisRate    =&80313
#set Service_Amnesia=&80320
#set stasis_alien          =1

; The variable block in the modules workspace

struct v {
  .linktab	DBB 8  ; variables
  .slot		DCD 0
  .mastertune	DCD 0
  .samprate	DCD 0
  .newrate	DCD 0
  .oldchan	DCD 0
  .realtune	DCD 0
  .timer	DCD 0
  .logampadr	DCD 0
  .filetype	DCD 0
  .saveslot	DCD 0
  .savename	DCD 0
  .callbacks	DCD 0
  .received	DCD 0
  .textbuf	DBB 16
  .contab   	DBB 8*con.sizeof    ; contains the con structures
  .slottab	DBB entries*s.sizeof; contains the slot table
  .sizeof
}

; a slot table entry

struct s {             ;data structure for slot table
  .addr         DCD 0
  .length       DCD 0
  .type		DCD 0
  .format	DCD 0
  .alien        DCD 0
  .spare	DBD 3
  .sizeof
}

; the format of the sccb

struct sccb {
  .volume	DCB 0
  .index	DCB 0
  .instance	DCB 0
  .control	DCB 0
  .pitch	DCD 0
  .timbre	DCD 0
  .duration	DCD 0
  .sizeof
}

; the id block format for an alien format handler

struct alien {
  .id		DCD 0
  .getinfo	DCD 0
  .putinfo	DCD 0
  .release	DCD 0
  .zero		DCD 0
  .reserved1	DCD 0
  .reserved2	DCD 0
  .name		DCD 0
  .formatname	DCD 0
  .filetype	DCD 0
  .modname	DCD 0
  .sizeof
  
}

; the structure of the control block used by the fill code

struct con {       
  .buf1		DCD 0;don't touch the first few
  .buf2		DCD 0;they're loaded by an LDM
  .addr		DCD 0
  .length	DCD 0
  .acc		DCD 0
  .replen	DCD 0
  .pitch	DCD 0
  .status	DCD 0
  .repofs	DCD 0
  .slot		DCD 0
  .volume	DCD 0
  .finetune	DCD 0
  .lastbuf	DCD 0
  .rawpitch	DCD 0
  .logampadr    DCD 0
  .slowbufs 	DCD 0
  .fastbufs	DCD 0
  .flashbufs	DCD 0
  .fixedbufs    DCD 0
  .flushes	DCD 0
  .kicks	DCD 0;intentional gap below
  .slides
  .volslide	DCD 0
  .volrate	DCD 0
  .pitchslide	DCD 0
  .pitchrate	DCD 0
  .ratechange	DCD 0
  .states	DCD 0
  .prevstate	DCD 0
  .laststate	DCD 0
  .samprate	DCD 0
  .spare	DBD 2
  .sizeof
}
#set stac_shift=7    ;con_shift

#set s_shift=5

; flags in the con.status word

#set status_gated = 1<<0

#set status_q1    = 1<<3
#set status_q2    = 1<<4
#set status_live  = 1<<5
#set status_escape= 1<<6
#set status_kick  = 1<<7
#set status_off   = 1<<8
#set status_fresh = 1<<9
#set status_slide	= 1<<10
#set status_volslide	= 1<<10
#set status_pitchslide 	= 1<<11
#set status_resslide 	= 1<<12
#set status_resslide 	= 1<<13
#set status_safe	= 1<<14
#set status_attached	= 1<<15
#set status_qshift = 3

; flags passed to Stasis_Sound in R4
; ie the ignore value

#set ig_slot	= 1<<0 ; ignore slot paseed to Stasis_Sound SWI
#set ig_volume	= 1<<1 ; ignore volume
#set ig_pitch	= 1<<2
#set ig_update  = 1<<3 
#set ig_rawpitch= 1<<4 ; don't convert pitch
#set ig_escape  = 1<<5 ; internal signal - escape pressed - kills channel
#set ig_retrig	= 1<<6 ; don't retrigger
#set ig_fromgate= 1<<31; for internal use

struct stasisform {    ;stasis format
  .id           DCD 0  ; the Stasis ID "Sta1"
  .name		DBB 20 ; zero terminated name string
  .len		DCD 0  ; length of data
  .repofs	DCD 0  ; repeat offset from start of data

  .replen	DCD 0  ; repeat length
  .finetune     DCD 0  ; finetune value, default &4000
  .dataofs	DCD 0  ; offset to data - normally 44
  .sizeof
}

struct tffstart {   ; TFF (tracker) format
  		DCD 0; "SAMP"
  .blocklen	DCD 0
		DCD 0; "SNAM"
  .namelen	DCD 20
  .name		DBB 20;"Name of the voice   "
  .sizeof
}
struct tffend {
 		DCD 0; "SVOL"
		DCD 4
  .finetune	DCD 255
		DCD 0; "SLEN"
		DCD 4
  .len		DCD 0
		DCD 0; "ROFS"
		DCD 4
  .repofs	DCD 0
		DCD 0; "RLEN"
		DCD 4
  .replen	DCD 2
		DCD 0;"SDAT"
  .dataofs	DCD 0
  .sizeof
}

struct userform {   ;user format
  .id		DCB "User"
  .addr		DCD 0
  .len		DCD 0
  .repofs	DCD 0
  .replen	DCD 0
  .sizeof
}
  
; Sundry internal variables  
  
#set finetune_default=&4000
#set finetune_shift=14
#set tune_default=&4000
#set tune_shift=12

#set entryshift=7
#set entries=128
#set namelen=20
#set type_empty=0
#set type_rma=1
#set type_user=2
#set type_amnesia=3
#set type_link=4
#set type_safelink=5

#set format_unknown=0
#set format_stasis=1
#set format_tracker=2
#set format_user=3
#set format_alien=4

#set filetype_stasis=&112
#set filetype_tracker=&CB5
