home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / DOCS / STEINFO.ZIP / STEINFO.DOC
Encoding:
Text File  |  1990-02-01  |  30.7 KB  |  635 lines

  1. ①Atari STE Hardware documentation, taken from the developer information, and
  2. altered to correspond more to observed facts than the original documentation.
  3.  
  4.                        INTRODUCTION TO THE STE
  5.  
  6. The Atari STE is an enhanced version of the ST with the following changes:
  7.  
  8.                                GRAPHICS
  9.  
  10. The colour pallete has been expanded to 4096 colours from 512.  Support for
  11. Vertical and Horizontal scrolling has been added to the hardware.
  12.  
  13.                                 SOUND
  14.  
  15. Stereo 8-bit DMA sound has been added to the system along with volume and tone
  16. control.
  17.  
  18.                              CONTROLLERS
  19.  
  20. New controllers ports have been added to allow keypad type joysticks, analog
  21. paddies and a light pen.
  22.  
  23.                          GENLOCK AND THE STE
  24.  
  25. The ST (and STE) chip set have the ability to accept external sync.  This is
  26. controlled by bit 0 at FF820A, as documented in the ST Hardware Specification.
  27. This was done to allow the synchronization èof the ST video with an external
  28. source (a process usually known as GENLOCK).  However, in order to do this
  29. reliably the system clock must also be phase-locked (or synchonized in some
  30. other way) to the imput sync signals.  No way to do this was provided in the
  31. ST, as a result the only GENLOCKs available are internal modifications (usually
  32. for the MEGA).
  33.  
  34. The STE allows this to be done without opening the case.  To inject a system
  35. clock ground pin three (GPO) on the monitor connector and then inject the clock
  36. into pin 4 (mono direct).  The internal frequency of this clock is 32.215905 MHz
  37. (NTSC) and 31.922046 MHz (PAL).
  38.  
  39. Note:  DO NOT SWITCH CLOCK SOURCE WHILE THE SYSTEM IS ACTIVE.
  40.        (As a result of this GPO is no longer available).
  41.  
  42.                               JOY STICKS
  43.  
  44. Four new joystick ports are added.  These ports are controlled èdirectly by the
  45. 68000.  The current state may be sampled at any time by reading the locations.
  46. Joystick 0 and Joystick 2 direction bits are read/write.  If written to they
  47. will be driven until a read is performed.  Similarly, they will not be driven
  48. after a read until a write is performed.
  49.  
  50.                                PADDLES
  51.  
  52. One pair of paddles can be plugged into Joystick 0 (Paddle 0).  A second set
  53. can be plugged into Joystick 1 (Paddle 1).  The current position of each of the
  54. four paddles is reported at these locations.  The fire buttons are the same as
  55. for the respective joystick.  The triggers for the paddles are read as bits one
  56. and two of FF9202 (JOY 0 Left and Right).
  57.  
  58.                            LIGHT GUN / PEN
  59.  
  60. A light gun or pen can be plugged into Joystick 0.  The current position that
  61. the gun or pen is pointing to is reported by these registers.  The position is
  62. accurate to within (X direction only):
  63.  
  64.                         4 Pixels in 320*200 Mode
  65.                         8 Pixels in 640*200 Mode
  66.                        16 Pixels in 640*400 Mode
  67.  
  68. Accurate to 1 pixel in the Y direction in all modes.  Accuracies do not account
  69. for the quality of the light gun or pen.  Note that the X position is given in
  70. pixels for 320*200 only.  In order to get correct results in 640*200 mode this
  71. number needs to be shifted left one bit and in 640*400 mode this number needs to
  72. be shifted left two bits.
  73.  
  74.              HOW TO IMPLEMENT FINE SCROLLING ON THE STE.
  75.  
  76. Three new registers are provided to implement fine-scrolling and split screen
  77. displays:
  78.  
  79. 1) HSCROLL - This register contains the pixel scroll offset.  If it is zero,
  80.    this is the same as an ordinary ST.  If it is non-zero, it indicates which
  81.    data bits constitute the first pixel from the first data word(S) of a given
  82.    line by this register.
  83.  
  84. 2) LINEWID - This register indicates the number of extra words of data (beyond
  85.    that required by an ordinary ST at the same resolution) which represents a
  86.    single display line.  If it is zero, this is the same as an ordinary ST.  If
  87.    it is non-zero, that many additional words of data will constitute a single
  88.    video line (thus allowing virtual screens wider than the displayed screen).
  89.    CAUTION: In fact, this register contains the word offset which the display
  90.    processor will add to the video display address to point to the next line.
  91.    If you are actively scrolling (HSCROLL <> 0), this register should contain
  92.    the additional width of a display line minus one data fetch (in low
  93.    resolution one data fetch would be four words, one word for monochrome, etc).
  94.  
  95. 3) VBASELO - This register contains the low-order byte of the video display base
  96.    address.  It can be altered at any time and will not affect the display until
  97.    the next vertical blank interrupt.
  98.  
  99. The following registers have been changed on the STE to allow greater control
  100. over the display:
  101.  
  102. 1) VIDEO ADDRESS COUNTER - Now read/write.  Allows update of the video refresh
  103. address during the frame.  The effect is immediate, therefore it should be
  104. reloaded carefully (or during blanking) to provide reliable results.
  105.  
  106. 2) COLOUR PALLETE - A fourth bit of resolution is added to each colour.  Note
  107. that the least significant bit is added above the old most significant bit to
  108. remain compatible with the ST.
  109.  
  110. These registers, when used in combination, can provide several video effects.
  111. In this document we will discuss only fine-scrolling and split-scrolling 
  112. displays.
  113.  
  114. FINE SCROLLING:
  115. Many games use horizontal and vertical scrolling techniques to provide virtual
  116. playfields which are larger than a single screen.  We will first discuss
  117. vertical scrolling (line-wise), then horizontal scrolling (pixel-wise) and
  118. finally the example program "neowall.s" which combines both.
  119.  
  120. VERTICAL SCROLLING:
  121. To scroll line-wise, we simply alter the video display address by one line each
  122. time we wish to scroll one line.  This is done at vertical blank interrupt time
  123. by writing to the three eight-bit video display address registers to define
  124. a twenty-four bit pointer to memory.  Naturally, additional data must be 
  125. available to be displayed.  We might imagine this as a tall, skinny screen
  126. which we are opening onto for the user. The video display address registers
  127. define where this window will start.
  128.  
  129. HORIZONTAL SCROLLING: 
  130. To scroll horizontally we might also adjust the video display address. If that
  131. was all we did, we would find that the screen would jump sideways in sixteen
  132. pixel incements.  To achieve smooth pixel-wise scrolling we must use the HSCROLL
  133. register to select where within each sixteen pixel block we wish to start 
  134. displaying data to the screen.  Finally, we must adjust the LINEWID register to
  135. reflect both the fact that each line of video data is wider than a single 
  136. display line and any display processor fetch incurred by a non-zero value of
  137. HSCROLL.  All this is done at vertical blank interrupt time.  Naturally,
  138. additional data must be available to be displayed.  We might imagine this is
  139. an extremely wide screen which we are opening a window onto for the user.
  140. These registers define where this window will start.
  141.  
  142. FOR EXAMPLE:
  143. The program "neowall.s" reads in nine NEOchrome picture files, organizes them
  144. into a three by three grid and allows the user to scroll both horizontally and
  145. vertically over the images.  The heart of this program (the only interesting
  146. thing about it actually) is the vertical blank interrupt server.  This routine
  147. first determines the pixel offset and loads it into HSCROLL.  The LINEWID
  148. register is now set to indicate that each virtual line is three times longer
  149. than the actual display width.  If we are now actively scrolling, this amount
  150. is reduced to reflect the additional four-plane data fetch which will be 
  151. caused by the scrolling.  Finally the video display address is computed to
  152. designate a window onto the grid of pictures.  This twenty-four-bit address
  153. determines where the upper left corner of the displayed region begins in
  154. memory.  Thus, every frame an arbitrary portion of the total image is selected
  155. for display.  The speed and resolution of this scrolling technique is limited
  156. only by the dexterity of the user.
  157.  
  158.  
  159. SPLIT SCREEN:
  160. In many applications it is desirable to subdivide the screen into several
  161. independent regions.  On the STE you may reload some video registers on a 
  162. line-by-line besis (using horizontal blanking interrupts) to split the screen
  163. vertically into multiple independent regions.  A single screen no longer need
  164. be a contiguous block of storage, but could be composed of dozens of strips
  165. which might reside in memory in any other.  The same data could be repeated on
  166. one or more display lines.  Individual regions might each have their own 
  167. individual data and scrolling directions.
  168.  
  169. FOR EXAMPLE:
  170. The program "hscroll.s" reads in a NEOchrome picture file and duplicates each
  171. line of the image.  This, combined with the proper use of LINWID, effectively
  172. places two copies of the same picture side-by-side.  Next, both vertical and 
  173. horizontal blanking interrupt vectors are captured and the horizontal blanking
  174. interrupt is enabled in counter mode.  To prevent flicker caused by keyboard
  175. input, the IKBD/MIDI interrupt priority is lowered below that of the HBL 
  176. interrupt.  Note that the program 'main loop' doesn't even call the BIOS to
  177. check the keyboard, since the BIOS sets the IPL up causes flicker by locking
  178. out horizontal interrupts - this may cause trouble for programs in the real
  179. world.  The screen is effectively divided into ten regions which scroll
  180. independently of one another.  There are two ten-element arrays which contain
  181. the base address of each region and its current scroll offset.  At vertical
  182. blank interrupt time we compute the final display values for each region in
  183. advance and store them into a third array.  We then initialize the display
  184. processor for the first region and request an interrupt every twenty lines 
  185. (actually every twenty horizontal blankings).  During each horizontal interrupt
  186. service, we quickly reload the video display address registers and the HSCROLL
  187. register.  This must be done immediately - before the display processor has
  188. time to start the current line or garbage may result.  Note that horizontal
  189. blank interrupts are triggered by the display processor having finished reading
  190. the previous data line.  You have approximately 144 machine cycles to reload
  191. the HSCROLL and video display registers before they will be used again by the
  192. display processor finishes reading the data for the current display line.  We
  193. then pre-compute the data we will need for the next horizontal interrupt to
  194. shave few more cycles off the critical path and exit.
  195.  
  196. -------------------------------------------------------------------------------
  197.  
  198.                       STE DIGITIZED SOUND OVERVIEW
  199.  
  200. Sound  is stored in memory as digitized samples.  Each sample is a number, 
  201. from -128 to +127, which represents displacement of the speaker from the
  202. "neutral" or middle possition.  During horizontal blanking (transparent
  203. to the processor) the DMA sound chip fetches samples from memory and provides
  204. them to a digital-to-analog canverter (DCA) at one of several constant
  205. rates, programmable as (approximately) 50KHz (kilohertz), 25 Khz, 12.5KHz,
  206. and 6.25KHz.  This rate is called the sample frequency.
  207.  
  208. The output of the DAC is then filtered to a frequency equal to 40% of the
  209. sample frequency by a four-pole switched low-pass filter.  This program
  210. "anti-aliasing" of the sound data in a sample- frequency-sensitive way.
  211. The signal is further filtered by a two-pole fixed frequency (16KHz)
  212. low-pass filter and provided to a National LMC1992 Volume/Tone Controller.
  213. Finally, the output is available at an RCA-style output jack on the back 
  214. of the computer.  This can be fed into an amplifier, and then to speakers,
  215. headphones, or tape recorders.
  216.  
  217. There are two channels which behave as described above; they are intended
  218. to be used as the left and right channels of a stereo system when using the
  219. audio outputs of the machine.  A monophonic mode is provided which will 
  220. send the same sample data to each channel.
  221.  
  222. The stereo sound output is also mixed onto the standard ST audio output
  223. sent to the monitor's speaker.  The ST's GI sound chip output can be mixed
  224. to the monitor and to both stereo output jacks as well.
  225.  
  226.  
  227.                             DATA FORMAT
  228.  
  229. Each sample is stored as a signed eight-bit quantity, where - 128 (80 hex) 
  230. means full negative displacement of the speaker, and 127 (7F hex) means full
  231. positive displacement.  In some stereo mode, each word represents two
  232. samples: the upper byte is the sample for the left channel, and the lower 
  233. byte is the sample for the right channel.  In mono mode each byte is one
  234. sample.  However, the samples are always fetched a word at a time, so only
  235. an even number of mono samples can be played.
  236.  
  237. A group of samples is called a "frame".  A frame may be played once or can
  238. automatically be repeated forever (until sotpped).  A frame is described by
  239. its start and end addresses.  The end address of a frame is actually the
  240. address of the first byte in memory beyond the frame; a frame starting at
  241. address 21100 which is 10 bytes long has an end address of 21110.
  242.  
  243. Note:  a zero can be written to the DMA sound control register at any
  244. time to stop playback immediately.
  245.  
  246.                         PROGRAMMING CONSIDERATIONS
  247.  
  248. The simplest way to produce a sound is to assemble a frame in memory,
  249. write the start address of the frame into the Frame Start Address register,
  250. and the end address of the frame into the Frame End address register, set
  251. the Mode register appropriately (set stereo to mono, and the sample 
  252. frequency), and write a one into the Sound DMA Control register.  The frame
  253. will play once, then stop.
  254.  
  255. To produce continuous sound, and link frames together, more elaborate 
  256. techniques are required.
  257.  
  258. The DMA sound chip produces a signal called "DMA sound active" which is one
  259. when the chip is playing sounds, and a zero when it's not.  When a frame ends 
  260. in the repeat mode (mode 3), there is a transition from "active" to "idle"
  261. and back again on this signal.  The signal is presented as the external input
  262. to MFP Timer A.  You can put Timer A into Event Count mode and use it to 
  263. generate an interrupt, for example when a frame has played a given number
  264. of timees.  Because of the design of the MFP, the active edge for this signal
  265. must be the same as the input on GPIP 14, which is the interrupt line from
  266. the keyboard and MIDI interfaces.  It is, and the Active Edge Register is 
  267. already programmed for that, so you need not worry about that if you use 
  268. Timer A to count frames.
  269.  
  270. The DMA Sound Chip's mode 3 (repeat mode) ensures seamless linkage of frames, 
  271. because the start and end registers are actually double-buffered.  When you
  272. write to these resisters, what you write really goes into a "holding area".
  273. The contents of the holding area go into the true registers at the end of the
  274. current frame.  (Actually, they go in when the chip is idle, which means right
  275. away if the chip was idle to begin with.)
  276.  
  277. If you have two frames which you want played in succession, you can write the 
  278. start and end address of the first frame into the chip, then set its control 
  279. register to 3.  The first frame will begin playing.  You can then immediately
  280. write the start and end addresses of the second frame into the chip: they will
  281. be held in the holding area until the first frame finishes, then they'll be
  282. copied into the true registers and the second frame will play.  The interrupt
  283. between frames will still happen, so you can tell when the first frame has
  284. finished.  Then, for instance, you can write the start and end registers for
  285. the start of the third frame, knowing that it will begin as soon as the second 
  286. frame has finished.  You could even write new data into the first frame and
  287. write its start and end address into the chip; this kind of ping-pong
  288. effect is rather like double-buffering of a graphics display.
  289.  
  290. Here is an example of using Timer A in Event Count mode to play a controlled
  291. series of frames.  Suppose you have three frames, A, B and C, and you want to
  292. play frame A three times, then frame B five times, and finally frame C twice.
  293. The sequence of steps below will accomplish this.  Numbered steps are carried
  294. out by your program; the bracketed descriptions are of things which are
  295. happening as a result.
  296.  
  297.         1.  Set Timer A to event count mode, and its counter to 2 (not 3)
  298.  
  299.         2.  Write Frame A's start and end addresses into the registers.
  300.  
  301.         3.  Write a 3 to the sound DMA control register.  [Play begins.]  Go
  302.             do something else until interrupted.
  303.  
  304.             [At the end of the sound repition of Frame A, the timer's 
  305.             interrupt fires.  At the same time, frame A begins its third
  306.             repetition.]
  307.  
  308.         4.  Write Frame B's start and end addresses into the DMA sound chip.
  309.             These values will be held until the third repetition of Frame A
  310.             finishes.
  311.  
  312.         5.  Set Timer A's count register to 5, then go away until 
  313.             interrupted.
  314.  
  315.             [When the current repetition finishes, the start and end
  316.             registers are loaded fron the holding area, and Frame B will
  317.             begin playing.  The end of play signal will cause Timer A to 
  318.             count from 5 to 4.  At the end of Frame B's fourth repetition,
  319.             its fifth will start, the timer will count down from 1 to 0,
  320.             and the interrupt will occur.]
  321.  
  322.         6.  Write frame C's start and end addresses into the registers, and
  323.             program Timer A to count to 2.  Go away until interrupted.
  324.  
  325.             [When the current repetition (B's fifth) finishes, the start
  326.             and end registers are loaded from the holding area, and Frame C
  327.             will begin playing.  The end-of-frame signal causes Timer A to
  328.             count down from 2 to 1.  When Frame C finishes its first
  329.             repetition, Timer A counts down from 1 to 0 and interrupts.]
  330.  
  331.         7.  Write a 1 to the DMA Sound Control Register to play the current
  332.             frame, then stop.  Disable TimerA and mask its interrupt.
  333.             You're done.
  334.  
  335. As you can see you program the timer to interrupt after one repetition less
  336. than the number of times you want a frame to play.  That is so you can set up
  337. the next frame while the DMA sound chip is playing the last repetition of the 
  338. current frame.  This ensures seamless linkage of frames.
  339.  
  340.  
  341.                     INTERRUPTS WITHOUT TIMER A
  342.         
  343. Besides going to the external input signal of Timer A, the DMA-sound-active
  344. signal, true high, is exclusive-ORed with the monochrome-detect signal, and
  345. together they form the GPIP 17 input to the M68901 MFP.  The intent of this 
  346. is to provide for interrupt-driven sound drivers without using up the last
  347. general-purpose timer in the MFP.  It is a little trickier to use, however.
  348. For one thing, it causes the interrupt at the end of every frame, not after
  349. a specified number of frames.  For another, the "interesting" edge on this
  350. signal depends on what kind of monitor you have.
  351.  
  352. On an ST, monochrme monitors ground the mono-detect signal, so when you read
  353. the bit in the MFP you get a zero.  Colour monitors do not ground it, so it
  354. reads as a one.  When the DMA sound is idle (0), this is still the case.
  355. However, when the sound is active (1), the mono-detect signal is inverted by
  356. the XOR, so the bit in the MFP reads the opposite way.  (the one place where
  357. the OS reads this bit as at VBLANK time, to see if you've changed monitors.
  358. The ROMs on any machine with DMA sound are approprietely modified, so you
  359. need not worry about this.)
  360.  
  361. If you want to use the mono-detect / DMA interrupt signal, you have to set up 
  362. the active-edge register in the MFP to cause the interrupt at the right time.
  363. The interesting edge on the DMA signal is the falling edge, that is, from 
  364. active to idle; this happens when a frame finishes.  If you have a monochrome
  365. monitor, this edge is seen as a transition from 1 to 0 on MFP bit 17.
  366. However, with a colour monitor, the edge will be seen as a transition from
  367. 0 to 1.  Therefore, you have to program the MFP's active-edge regisrer
  368. differently depending on which monitor you have.  Make sure the DMA sound is 
  369. idle (write a zero to the control register), then check MFP 17: if it's one,
  370. you have a colour monitor, and you need to see the rising edge.  If it's
  371. zreo, you have a monochrome monitor, and you need to see the falling edge.
  372.  
  373. The DMA sound active signal goes from "active" to "idle" when a frame 
  374. finishes.  If it was playing in mode one, it stays "idle" and the control
  375. register reverts to zero.  If it was playing in mode 3 the signal goes
  376. back to "active" as the next frame begins.  In this case, the signal is
  377. actually in the "idle" state for a very short time, but the MFP catches it
  378. and causes the interrupt, so don't worry.
  379.  
  380.  
  381.                       ADDITIONAL CONSIDERATIONS
  382.  
  383. Regardless of how you manage your interrupts, there is more you should know:
  384. the signal goes from "active" to "idle" when the DMA sound chip has fetched
  385. the last sample in the frame.  There is a four-word FIFO in the chip,
  386. however, so it will be eight sample-times (four in stereo mode) before the
  387. sound actually finishes.  If you are using mode 1, you can use this time to
  388. set up the chip with the start and end addresses of the next frame, so it 
  389. will start as soon as the current one ends.  However, if the interrupt
  390. should be postponed for four or eight sample-times, you could miss your 
  391. chance to start the sound seamlessly.  Therefore, for seamless linkage,
  392. use the pre-loading technique described above.
  393.  
  394.  
  395.                           MICROWIRE INTERFACE
  396.  
  397. The MICROWIRE interface provided to talk to the national LMC1992 Computer
  398. Controlled Volume / Tone Control is a general purpose MICROWIRE interface
  399. to allow the future addition of other MICROWIRE devices.  For this reason,
  400. the following description of its use will make no assumptions about the 
  401. device being addressed.
  402.  
  403. The MICROWIRE bus is a three wire serial connection and protocol designed to
  404. allow multiple devices to be individually addresses by the controller. The
  405. lengh of the serial data straem depends on the destination device.  In 
  406. general, the stream consists of N bits of address, followed by zero or more 
  407. don't care bits, followed by M bits of data.  The hardware interface
  408. provided consists of two 16 bit read/write registers: one data register
  409. which contains the actual bit stream to be shifted out, and one mask register
  410. which indicates which bits are valid.
  411.  
  412. Let's consider a mythical device which requires two address bits and one data 
  413. bit.  For this device the total bit stream is three bits (minimum).  Any 
  414. three bits of the register pair may be used.  However, since the most 
  415. significant bit is shifted first, the commanmd will be received by the device
  416. soonest if the three most if the three most significant bits are used.  Let's
  417. assume: 01 is the devise's address, D is the data to be written, and X's are
  418. don't cares.  Then all of the following register combinations will provide 
  419. the same information to the device.
  420.  
  421. 1110 0000 0000 0000 Mask
  422. 01DX XXXX XXXX XXXX Data
  423.  
  424. 0000 0000 0000 0111 Mask
  425. XXXX XXXX XXXX X01D Data
  426.  
  427. 0000 0001 1100 0000 Mask
  428. XXXX XXX0 1DXX XXXX Data
  429.  
  430. 0000 1100 0001 0000 Mask
  431. XXXX 01XX XXXD XXXX Data
  432.  
  433. 1100 0000 0000 0001 Mask
  434. 01XX XXXX XXXX XXXD Data
  435.  
  436. As you can see, the address bits must be contigious, and so must the data
  437. bits, but they don't have to be contiguous with each other.
  438.  
  439. The mask register must be written before the data register.  Sending
  440. commences when the data register is written and takes approximately 16usec.
  441. Subsequent writes to the data and mask registers are blocked until sending
  442. is complete.  Reading the registers while sending is in progress will
  443. return a snapshot of the shift register shifting the data and mask out.
  444. This means that you know it is safe to send the next command when these
  445. registers (or either one) return to thier original state.  Note that the
  446. mask register does not need to be rewritten if it is already correct.  
  447. That is, when sending a series of commands the mask register only needs
  448. to be written once.
  449.  
  450.  
  451.                        VOLUME AND TONE CONTROL
  452.  
  453. The LMC1992 is used to provide volume and tone control.  Before you go and
  454. find a data sheet for this part, be warned that we do not use all of its 
  455. features.  Commands for the features we do use are listed below.
  456.  
  457. Communication with this device is achieved using the MICROWIRE interface.
  458. See MICROWIRE INTERFACE the section for details.  The device has a two
  459. bit address field, address = 10, and a nine bit data field.  There is no
  460. way to reading the current setting.
  461.  
  462.                     VOLUME / TONE CONTROLLER COMMANDS
  463.  
  464. Device address = 10 (Address precedes command)
  465.  
  466. Data field
  467.  
  468. 001 DDD DDD Set Master Volume
  469.     000 000 -80 dB
  470.     010 100 -40 dB
  471.     101 XXX  0 dB
  472.  
  473. 101 XDD DDD Set Left Channel Volume
  474.      00 000 -40 dB
  475.      01 010 -20 dB
  476.      10 1XX  0 dB
  477.  
  478. 100 XDD DDD Set Right Channel Volume
  479.      00 000 -40 dB
  480.      01 010 -20 dB
  481.      10 1XX  0 dB
  482.  
  483. 010 XXD DDD Set Treble
  484.       0 000 -12 dB
  485.       0 100  0 dB (Flat)
  486.       1 100 =12 dB
  487.  
  488. 001 XXD DDD Set Base
  489.       0 000 -12 dB
  490.       0 110  0 dB (Flat)
  491.       1 100 +12 dB
  492.  
  493. 000 XXX XDD Set Mix
  494.          00 -12 dB
  495.          01 Mix GI sound chip output
  496.          10 Do not mix GI sound chip output
  497.          11 reserved
  498.  
  499. Note: The volume controls attenuate in 2 dB streps.  The tone controls
  500. attenuate in 2 dB steps at 50 kHz (Note that these frequencies may change).
  501.  
  502.       USING THE MICROWIRE INTERFACE AND THE VOLUME/TONE CONTROL CHIP
  503.  
  504. The MICROWIRE interface is not hard to use: once you get it right, you'll 
  505. never have to figure it out again.
  506.  
  507. The easiest way to use it is to ignore the flexibility, and just use one
  508. form for all commands.  Since the Volume/Tone chip is the only device, and 
  509. it has a total of 11 bits of address and data, your mask should be $07ff.
  510. If you're picky, you can use $ffe0, because the high-order bits are shifted
  511. out first, but it adds conceptual complexity.  With a mask of $07ff, the
  512. lower 9 bits of the data register are used for the data, and the next higher
  513. two bits are for the address:
  514.  
  515.         Mask:   %0000 0111 1111 1111
  516.         Data:   %xxxx x10d dddd dddd
  517.  
  518. Replace the d's with the command code and its data.  For example, this
  519. combination sets the master volume to $14:
  520.  
  521.         Mask:   %0000 0111 1111 1111
  522.         Data:   %xxxx x100 1101 0100
  523.  
  524. The other important concept you must understand is that the bits shift out
  525. of these registers as soon as you write the data, and it takes an appreciable
  526. time (16 usec) to finish.  You can't attempt another write until the first 
  527. one is finished.  If you read either register while it's being shifted out,
  528. you will see a "snapshot" of the data being shifted.  You know the shifting
  529. is complete when the mask returns to its original value.  (This theory is
  530. wrong if you use a mask which equals its original value sometime during the
  531. shifting, but $07ff never does.)
  532.  
  533. Assuming you write $07ff into the mask register ahead of time, the following
  534. routine can be used to write new data from the D0 register to the volume/tone
  535. control chip.
  536.  
  537.         MWMASK  equ $ffff8924
  538.         MWDATA  equ $ffff8922
  539.         
  540.         mwwrite:
  541.              cmp.w      #$07ff,MWMASK  ; wait for prev to finish
  542.              bne.s      mwwrite        ; loop until equal
  543.              move.w     d0,MWDATA      ; write the data
  544.              rts                       ; and return
  545.  
  546. The purpose of the loop at the beginning is to wait until previous write
  547. completes.
  548.  
  549. This loop is at the beginning of the routine, not at the end because waiting
  550. at the end would always force a sixteen usec delay.  Even if it has been longer
  551. than that since the last write.
  552.  
  553. -------------------------------------------------------------------------------
  554.  
  555.                         NEW CONTROLLER PINOUT
  556.  
  557. Arrangement (Looking towards STE):
  558.                                                
  559.                              5  4  3  2  1  
  560.                             10  9  8  7  6                                   
  561.                             15 14 13 12 11  
  562.                                                
  563. Connections (PORT A):
  564.  
  565. 1:  UP 0    5:  PAD 0Y    9:  GND           13:  LT 2
  566. 2:  DN 0    6:  FIRE 0     10:  FIRE 2     14:  RT 2
  567. 3:  LT 0        7:  +5v        11:  UP 2       15:  PAD 0X
  568. 4:  RT 0        8:  n/c        12:  DN 2      
  569.  
  570. Connections (PORT B):
  571.  
  572. 1:  UP 1    5:  PAD 1Y    9:  GND           13:  LT 3
  573. 2:  DN 1    6:  FIRE 1     10:  FIRE 3     14:  RT 3
  574. 3:  LT 1        7:  +5v        11:  UP 3       15:  PAD 1X
  575. 4:  RT 1        8:  n/c        12:  DN 3      
  576.  
  577.  
  578.                      CONTROLLER MEMORY LOCATIONS
  579.  
  580. FF9201             ---- 3120  RO  Fire Buttons
  581. FF9202   UDLR UDLR UDLR UDLR  RW  Joystick 3/2/1/0 Directions
  582. FF9211             xxxx xxxx  RO  X-Paddle 0
  583. FF9213             xxxx xxxx  RO  Y-Paddle 0
  584. FF9215             xxxx xxxx  RO  X-Paddle 1
  585. FF9217             xxxx xxxx  RO  Y-Paddle 1
  586. FF9220   ---- --xx xxxx xxxx  RO  Light Gun X-Pos
  587. FF9222   ---- --xx xxxx xxxx  RO  Light Gun Y-Pos
  588.  
  589.                      VIDEO REGISTER MODIFICATIONS
  590.  
  591. FF8205             --xx xxxx  RW  Video Address High
  592. FF8207             xxxx xxxx  RW  Video Address Mid
  593. FF8209             xxxx xxx-  RW  Video Address Low
  594.  
  595. FF820D             xxxx xxx-  RW  Video Base Address Low
  596. FF820F             xxxx xxxx  RW  Over-Length Line Width
  597. FF8264             ---- xxxx  RW  Undocumented HSCROLL register: no extra fetch
  598. FF8265             ---- xxxx  RW  Documented HSCROLL register
  599.  
  600. FF8240+  ---- 0321 0321 0321  RW  Red/Green/Blue Colour settings
  601.  
  602.                              DMA SOUND REGISTERS
  603.  
  604. FF8901             ---- --cc  RW  Sound DMA Control
  605.  
  606.      cc:
  607.      00   Sound DMA disabled (reset state).
  608.      01   Sound DMA enabled, disable at end of frame.
  609.      11   Sound DMA enabled, repeat frame forever.
  610.  
  611. FF8903             --xx xxxx  RW  Frame Base Address (high)
  612. FF8905             xxxx xxxx  RW  Frame Base Address (middle)
  613. FF8907             xxxx xxx-  RW  Frame Base Address (low)
  614.  
  615. FF8909             --xx xxxx  RO  Frame Address Counter (high)
  616. FF890B             xxxx xxxx  RO  Frame Address Counter (middle)
  617. FF890D             xxxx xxx-  RO  Frame Address Counter (low)
  618.  
  619. FF890F             --xx xxxx  RW  Frame End Address (high)
  620. FF8911             xxxx xxxx  RW  Frame End Address (middle)
  621. FF8913             xxxx xxx-  RW  Frame End Address (low)
  622. FF8921             m--- --rr  RW  Sound Mode Control
  623.  
  624.      rr:
  625.      00   6258 Hz sample rate (reset state)
  626.      01  12517 Hz sample rate
  627.      10  25033 Hz sample rate
  628.      11  50066 Hz sample rate
  629.      m:
  630.      0    Stereo Mode (reset state)
  631.      1    Mono Mode
  632.  
  633. FF8922  xxxx xxxx xxxx xxxx  RW  MICROWIRE Data register
  634. FF8924  xxxx xxxx xxxx xxxx  RW  MICROWIRE Mask register
  635.