home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / STE_ADRE.LZH / STEPROGR.DOC
Text File  |  1991-02-15  |  16KB  |  363 lines

  1. Newsgroups: comp.sys.atari.st.tech
  2. Subject: STe Programming info (long)
  3. Date: 13 Feb 91 10:52:16 GMT
  4. Organization: Computing Laboratory, U of Newcastle upon Tyne, UK NE17RU
  5.  
  6. I notice that alot of people have been clammering for information on the
  7. STe recently. Some time ago a Mathew Lodge of ST world (UK mag) wrote
  8. the following. This information has appeared here before in 3 parts and
  9. has been published by various people in various magazines.
  10.  
  11. It should be noted that you should not hold this information to be
  12. gosble and if you wan't to be sure of correct information get the
  13. Developers kit. So if there are any errors don't blame Atari or Mathew
  14. lodge but yourself.
  15.  
  16. Now there is no excuse for not writing STe specific SW so how about some
  17. nice Demos.
  18.  
  19. Dave Halliday
  20. (D.C.Halliday@newcastle.ac.uk)
  21.  
  22. ---------------- Mathew Lodge's Original Posts Follow -------------
  23.  
  24. OK, here is the documentation for STE DMA sound output. More documentation
  25. when I've typed it in. Screen blanker postings when I've got a copy of uuencode
  26. ... please be patient
  27.  
  28.  
  29. ----------------------- cut here ----------------------------------
  30.  
  31.  
  32. Information from "Atari STE Developer Information Addendum"
  33.  
  34. STE DMA Sound registers
  35.  
  36. Register    Access      Description
  37. FF8900      R/W      00 - sound disabled (reset state)
  38.                      01 - sound enabled, disable at end of frame
  39.                      11 - sound enabled, repeat forever
  40.  
  41. FF8902      R/W      Frame base address (high)
  42. FF8904      R/W      Frame base address (middle)
  43. FF8906      R/W      Frame base address (low)
  44.  
  45. FF8908      RO       Frame address counter (high)
  46. FF890A      RO       Frame address counter (middle)
  47. FF890C      RO       Frame address counter (low)
  48.  
  49. FF890E      R/W      Frame end address (high)
  50. FF8910      R/W      Frame end address (middle)
  51. FF8912      R/W      Frame end address (low)
  52.  
  53. FF8920      R/W      Sound mode control:
  54.                      xxxx xxxx m000 00rr
  55.                      Where for m:
  56.                        0 Stereo mode
  57.                        1 Monophonic mode
  58.                      Where for rr:
  59.                        00  6258 Hz sample rate (reset state)
  60.                        01 12517 Hz sample rate
  61.                        10 25033 Hz sample rate
  62.                        11 50066 Hz sample rate
  63.  
  64. FF8922      R/W      MICROWIRE data register
  65. FF8924      R/W      MICROWIRE mask register
  66.  
  67. Volume/controller commands (device address is always 10)
  68. --------------------------------------------------------
  69.  
  70. 011 DDD DDD Set master volume
  71.     000 000 -80 dB
  72.     010 100 -40 dB
  73.     101 XXX   0 dB
  74.  
  75. 101 xDD DDD Set left channel volume
  76.      00 000 -40 dB
  77.      01 010 -20 dB
  78.      10 1xx   0 dB
  79.  
  80. 100 xDD DDD Set right channel volume
  81.      00 000 -40 dB
  82.      01 010 -20 dB
  83.      10 1xx   0 dB
  84.  
  85. 010 xxD DDD Set treble
  86.       0 000 -12 dB
  87.       0 110   0 dB
  88.       1 100 +12 dB
  89.  
  90. 001 xxD DDD Set bass
  91.       0 000 -12 dB
  92.       0 110   0 dB
  93.       1 100 +12 dB
  94.  
  95. 000 xxx xDD Set mix
  96.          00 -12 dB
  97.          01 Mix GI sound output (ST sound chip)
  98.          10 Do not mix GI sound output
  99.          11 Reserved
  100. ----------------------------------------------------------
  101.  
  102.  
  103. Sampled sound data is stored in memory as a series of bytes, which
  104. represent a speaker displacement from -128 to +127. Zero represents the
  105. neutral or middle speaker position. Playback is programmable at one of
  106. four rates : 50kHz, 25kHz, 12.5kHz or 6.25kHz.
  107.  
  108. During the horizontal blanking phase, samples are fetched from memory by
  109. the DMA sound chip, and fed into a Digital to Analogue Converter (DAC).
  110. The output of the DAC is then filtered by a four-pole low pass filter to
  111. a frequency equal to around 40% of the sample frequency. The signal then
  112. passes through a two pole 16kHz low-pass filter, and fed into the
  113. National Semiconductor Volume/Tone controller (LMC1992). The final
  114. output is available from the RCA jacks on the back of the STE, which can
  115. be fed into an amplifier and hence to speakers, headphones etc.
  116.  
  117. Both stereo and mono sample replay is provided, but both stereo channels
  118. are mixed along with the ST's sound chip output for monitor speaker
  119. output. Sound chip output can also be sent to the stereo output jacks as
  120. well.
  121.  
  122. In stereo playback mode, the same data is regarded as words, with the
  123. high byte of the word being the sample for the left channel, and the low
  124. byte the right channel sample. In mono mode, each byte is output to both
  125. left and right stereo channels, but data is still fetched one word at a
  126. time. This means that mono sample data must always be an even number of
  127. bytes.
  128.  
  129. Samples are grouped together in frames. Each frame can be played once,
  130. or repeated automatically forever (until stopped). Two registers are
  131. loaded with the frame start and end address - the end address is
  132. actually the first byte beyond the end of the sample. Thus a 512 byte
  133. sample with a frame start address of 101024 would have a frame end
  134. address of 101536. Table One gives the location and description of each
  135. DMA sound register.
  136.  
  137. Actually playing a sample is really quite straightforward. Simply
  138. assemble the data in memory, load the start and end addresses, set
  139. stereo or mono mode and the playback frequency. Finally, write a one to
  140. the sound control register, and the sample will play once.
  141.  
  142. Producing continuous sound and linking frames together are the next
  143. steps, and hardware support is provided for these processes. The DMA
  144. sound chip produces a 'DMA sound active' signal which is connected to
  145. the external input of MFP Timer A. This signal is a one when samples are
  146. being played, and zero otherwise. At the end of a repeated frame, this
  147. line goes from one to zero, and then back to one again. Thus setting
  148. Timer A into event countdown mode allows you to generate an interrupt
  149. when a frame has been played a set number of times.
  150.  
  151. Frame repetition is seamless - there is no time delay between the end of
  152. a sample, and the start of it's replay, because the frame start and end
  153. registers are double buffered. Writing to these registers actually
  154. places the data into a holding area, and the contents of the holding
  155. area actually go into the true registers when the chip is idle (at the
  156. end of the frame, if one is currently being played).
  157.  
  158. Thus, if you wanted to play two consecutive frames, you would write the
  159. start and end addresses, and set the control register to three. The
  160. first frame will start playing, and you can immediately write the start
  161. and end addresses of the next frame, without waiting for the first frame
  162. to finish. There will still be an interrupt from Timer A at the end of
  163. the first frame, and you could use that to load the address of a further
  164. frame, and so on.
  165.  
  166. One further thing to note is that the 'DMA sound active' signal is also
  167. exclusive-ORed with the 'monochrome monitor detect' signal, and fed into
  168. the GPIP I7 input of the MFP. This was provided to enable interrupt
  169. driven sound without using the last free timer of the MFP. It is a
  170. little more difficult to use, since you will get a different signal edge
  171. depending on whether a mono or colour monitor is attached, as well as an
  172. interrupt at the end of every frame.
  173.  
  174. Monochrome monitors ground the 'mono detect' line, resulting in a zero
  175. when the bit is read from the MFP. Colour monitors don't ground the line
  176. (it is left floating), and the bit reads one. When DMA sound is active,
  177. this situation is inverted (because of the XOR with the 'DMA sound
  178. active line'). TOS actually looks at this bit during vertical blank
  179. time, to see if the monitor has been changed, but TOS on any machine
  180. with the DMA sound chip has been appropriately modified to avoid
  181. problems.
  182.  
  183. Finally, the 'DMA sound active' line goes from active to idle (one to
  184. zero) after the last sample has been fetched. There is a four-word FIFO
  185. (First In, First Out) buffer inside the chip, so it will be eight sample
  186. times (in stereo mode) before the sound actually finishes. If you do not
  187. reload the frame registers in this time, then the join between samples
  188. will not be seamless.
  189.  
  190.  
  191. The volume and tone controller of the STE is connected via a MICROWIRE
  192. bus interface. The idea behind this is that further devices can be added
  193. to the bus in the future. The MICROWIRE bus is a simple three wire
  194. serial connection, with a protocol to allow multiple devices to be
  195. controlled individually.
  196.  
  197. In the general case, the data stream consists of N address bits,
  198. followed by zero or more don't care bits, and then M bits of data. The
  199. actual hardware interface in the STE consists of two 16 bit read/write
  200. registers, one for the data to be shifted out, and a mask indicating
  201. which bits are valid.
  202.  
  203. A one in any bit of the mask indicates that the corresponding bit in the
  204. data register is valid. Data transmission starts as soon as the data
  205. register has been written to, so the mask register must be loaded first.
  206. Sending takes approximately sixteen micro-seconds, and if the data
  207. register is read during this time, a 'snap-shot' of the data being
  208. shifted out will be obtained. This means that if you wait for either
  209. register to return to its original state, you can be sure that sending
  210. has been completed.
  211.  
  212. The volume/tone controller is addressed by a two bit address field of
  213. %10 (binary) and a nine bit data field. Table One details the commands
  214. that can be sent to the device, and the addresses of the MICROWIRE
  215. registers in the STEs memory map. Actually sending these commands is
  216. easier than it looks. Simply set the mask register to $07FF, and place
  217. the data in the lower nine bits with %10 in the upper two bits.
  218.  
  219. For example, setting the mask to $07FF and the data register to $04C4
  220. will set the master volume to $14. That's all there is to it!
  221.  
  222.  
  223. Regards,
  224.  
  225. Mathew Lodge
  226. ***********************************************************************
  227. * c/o Dept. Computer Science  * "Baldrick, fetch me a turkey _so    *
  228. * University of York    * big_, you'd have thought its mother *
  229. * Heslington         * had been rodgered by an Omnibus"    *
  230. * York, UK        *                 *
  231. * YO1 5DD         * JANET : SOCS18@uk.ac.york.vaxa      *
  232. ***********************************************************************
  233.  
  234.  
  235.  
  236. Video Harware Modifications
  237. ===========================
  238.  
  239. Addr     Access Size    Use
  240. ======   ====== ====    =================================================
  241. FF8204    R/W    6      Video address counter (high)
  242. FF8206    R/W    8      Video address counter (middle)
  243. FF8208    R/W    8      Video address counter (low)
  244.                         The change here is that these registers are now
  245.                         read and write, allowing the programmer to
  246.                         update the video refresh address to any word
  247.                         boundary _at any time_.
  248.  
  249. FF820C    R/W    8      Video base address (low) (VBASELO) This register
  250.                         didn't exist on the ST, but on the STE it allows
  251.                         the positioning of the screen base address on
  252.                         any _WORD_ boundary
  253.  
  254. FF820E    ??     8      Line offset (LINEWID) - the number of extra words
  255.                         added to the address counter at the end of each
  256.                         line, _MINUS ONE DATA FETCH_. This allows for
  257.                         virtual screens that are wider than the actual
  258.                         screen display. Clearing this register means the
  259.                         STE acts like an ordinary ST.
  260.  
  261. FF8240 to FF825E        Colour palette
  262.                         There are now four bits for each of the red,
  263.                         green and blue components. To give backward
  264.                         compatibility with the ST, the least significant
  265.                         bit is above the most significant bit. Thus the
  266.                         register layout is as follows:
  267.  
  268.                         xxxx 0321 0321 0321;  x=don't care
  269.                              RED  GRN  BLUE
  270.  
  271. FF8264    ??    4       Horizontal bit-wise scroll (HSCROLL). Allows the
  272.                         start of each line to be delayed by 0-15 bits,
  273.                         thus giving instant horizontal scrolling.
  274.  
  275.  
  276. Horizontal fine scrolling isn't quite as trivial as it looks. The pixel offset
  277. is loaded into HSCROLL, and the documentation then says the following about
  278. the LINEWID register :
  279.  
  280. "If you are actively scrolling (HSCROLL<>0), this register should
  281. contain the additional width of the display line _minus one data fetch_
  282. (in low resolution one data fetch would be four words, one word for
  283. monchrome etc.)"
  284.  
  285. The reason for the extra data fetch becomes clearer if you think about
  286. what is actually happening. If you fine scroll by n bits, then n bits
  287. are effectively missed off the left hand edge of the screen. But to get
  288. a complete line of pixels, n bits must be added to the right hand side
  289. of the screen. This constitues one extra data fetch for the display
  290. processor beyond the usual requirement.
  291.  
  292. For example, if you had three low resolution pictures side by side in
  293. memory, and you wanted to scroll across them, you would set LINEWID to
  294. 160 when HSCROLL=0 (no extra data fetch). When HSCROLL<>0, LINEWID would
  295. be set to 156 (four less due to the extra data fetch done automatically
  296. by the display processor).
  297.  
  298. Vertical scrolling is trivial - simply set the video address base to the
  299. required address at horizontal blanking time.
  300.  
  301. That's all folks - for now - more info on the new controller ports soon.
  302. Regards,
  303.  
  304. Mathew Lodge
  305. ***********************************************************************
  306. * c/o Dept. Computer Science  * "Baldrick, fetch me a turkey _so    *
  307. * University of York    * big_, you'd have thought its mother *
  308. * Heslington         * had been rodgered by an Omnibus"    *
  309. * York, UK        *                 *
  310. * YO1 5DD         * JANET : SOCS18@uk.ac.york.vaxa      *
  311. ***********************************************************************
  312.  
  313.  
  314.  
  315.  
  316.  
  317. STE CONTROLLER PORTS
  318.  
  319. Address Usage                Description
  320. =================================================
  321. FF9200  xxxx xxxx xxxx 3210  Fire buttons
  322. FF9202  UDLR UDLR UDLR UDLR  Joystick directions
  323.         Joy3 Joy2 Joy1 Joy0
  324.  
  325. FF9210  xxxx xxxx NNNN NNNN  Paddle 0 X
  326. FF9212  xxxx xxxx NNNN NNNN  Paddle 0 Y
  327. FF9214  xxxx xxxx NNNN NNNN  Paddle 1 X
  328. FF9216  xxxx xxxx NNNN NNNN  Paddle 1 Y
  329.  
  330. FF9220  xxxx xxNN NNNN NNNN  Light pen/gun X
  331. FF9222  xxxx xxNN NNNN NNNN  Light pen/gun Y
  332.  
  333. Four new joystick ports were added, directly interfaced to the 68000
  334. bus, rather than using another IKBD controller. The table above gives the
  335. locations of the hardware registers for the joysticks, paddles and light
  336. gun/pen inputs. Note that the joystick registers are bidirectional, and
  337. can therefore be written as well as read. If the registers are  written,
  338. then the outputs are driven until the registers are read again.
  339.  
  340. Two paddle controllers can be connected with eight bit resolution on
  341. each axis, and the current position of each of the four paddles are
  342. reported in the registers shown in the table. No information is given in
  343. the data sheets as to the voltage range that the A/D converters function
  344. in, but I would guess that it is 0-5V. The triggers on the paddles are
  345. bits zero and one of $FF9202 (Joystick 0 left and right.)
  346.  
  347. The light gun/pen position is reported in $FF9220 and $FF9222. The
  348. x-axis accuracy is four pixels in low resolution, eight pixels in medium
  349. res., and sixteen pixels in high resolution. The y-axis position is
  350. accurate to within one pixel in all modes. The x position only ranges
  351. from 0 to 319, and therefore must be left shifted for other screen
  352. modes. Again, no electrical information is provided on how to
  353. implement a light gun/pen.
  354. Regards,
  355.  
  356. Mathew Lodge
  357. ***********************************************************************
  358. * c/o Dept. Computer Science  * "Baldrick, fetch me a turkey _so    *
  359. * University of York    * big_, you'd have thought its mother *
  360. * Heslington         * had been rodgered by an Omnibus"    *
  361. * York, UK        *                 *
  362. * YO1 5DD         * JANET : SOCS18@uk.ac.york.vaxa      *
  363. ***********************************************************************