home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK3 / DFUE_100 / FAMITXT.ZIP / SNES.DOC < prev    next >
Text File  |  1994-02-07  |  36KB  |  971 lines

  1. =-=-=
  2. SNES Documentation v1.3: Written by Yoshi of Digital Exodus. 
  3. =-=-=
  4. 1)    Memory Map.
  5.      i) "Main" memory map.
  6.     ii) Additional info.
  7. 2)    SNES Color explaination.
  8. 3)    SNES DMA Memory Map and explaination.
  9. 4)    SNES Graphics (tiles) explaination.
  10. 5)    SNES Screen mode definitions.
  11. 6)    SNES OAM/Sprite explaination.
  12. 7)    Magicom Disk registers and Memory controller locations.
  13. 69)   About the author...
  14. FF)   Greetings, Thanx, etc...
  15. =-=-=
  16. 1)    Memory Map.
  17.      i) "Main" memory map.
  18. -----------                              
  19.     Just so you know... the R and/or W's on the left side before the             
  20.     memory location mean [R]eadable and/or [W]riteable. I don't know
  21.     what happens if you try to read from the write-only registers:
  22.     I think you get bogus data, but that's about it.
  23. -----------                              
  24.  W   |$2100: Screen display register.
  25.             x000bbbb
  26.                     x: 0 = Screen on.
  27.                        1 = Screen off.
  28.                    bbbb: 0-$F = Brightness of screen.
  29.  
  30.             *** If you increment $2100 so the register goes up
  31.                 to $xF (x being whatever), you can make the
  32.                 screen "fade in". Make -SURE- you do this only
  33.                 during the VBlank period! If you don't, the screen
  34.                 goes totally wacko! The 'GS programmers like myself
  35.                 call it "Syncing to the VBL". 
  36. -----------                              
  37.  W   |$2101: OAM (Sprite) sizes.
  38.             sssnnbbb
  39.                     s: Size. 
  40.                     n: Name selection (upper 4k word address).
  41.                     b: Base selection (8k word segment address).
  42.  
  43.             *** The sizes are defined as follows:
  44.                     000: 8x8 or 16x16
  45.                     001: 8x8 or 32x32
  46.  
  47.             *** I've never used this register, nor sprites.
  48.                 Check Section 6 for information
  49.                 which was not done by me: If you understand
  50.                 it better than I do, good deal.
  51. -----------                              
  52.  W   |$2102: Address of OAM (Sprites).
  53.             ???????? | ????????  
  54.             
  55.             *** This register i've never used. All I know is
  56.                 that it's a -WORD- in length, not a byte.
  57. -----------                              
  58.  W   |$2104: Data for OAM (Sprites).
  59.             ????????
  60.  
  61.             *** I've never used this register. It's like $210D:
  62.                 You have to store a value in it twice.
  63. -----------                              
  64.  W   |$2105: Screen mode.
  65.             abcdfeee
  66.                     a: Plane 3 tile size.
  67.                     b: Plane 2 tile size.
  68.                     c: Plane 1 tile size.
  69.                     d: Plane 0 tile size.
  70.                         0 = 8x8 tiles.
  71.                         1 = 16x16 tiles.
  72.                     e: MODE definition. 
  73.                     f: Make Plane 2 take highest priority.
  74. -----------                              
  75.  W   |$2106: Screen pixelation (aka. MOSAIC) register.
  76.             xxxxabcd
  77.                     x: 0-$F = Pixel size.
  78.                     a: Affect plane 3.
  79.                     b: Affect plane 2.
  80.                     c: Affect plane 1.
  81.                     d: Affect plane 0.
  82.  
  83.             *** Just like $2100, this only works during VBlank.
  84.                 I recommend you setup what planes you want to
  85.                 affect at the start of the program, then to
  86.                 make them change, do the following:
  87.                     LDA #$03    ; Affect planes 0 and 1.
  88.                     STA TempReg1
  89.                     STA $2106
  90.                     JSR WaitVBlank
  91.                     LDA TempReg1
  92.                  Loop STA $2106
  93.                     CLC
  94.                     ADC #$10
  95.                     CMP #$F3
  96.                     BNE Loop
  97. -----------                              
  98.  W   |$2107: Plane 0 VRAM location register.
  99.             xxxxxxab
  100.                     x: Address of VRAM location.
  101.                      ab: Virtual screen size selection.
  102.  
  103.           *** The virtual screen size dealy goes like this:
  104.             32x32 to 32x64 to 64x32 to 64x64. Visually,
  105.             you only see 32x32(x25) at once unless you
  106.             change the ACTUAL screen size.
  107.  
  108.             *** The way I use this register is pretty simple.
  109.                 Lets say the VRAM is in $2000... Therefore,
  110.                 we'd go like this:
  111.                     LDA #$20
  112.                     STA $2107
  113. -----------                              
  114.  W   |$2108: Plane 1 VRAM location register.
  115.  W   |$2109: Plane 2 VRAM location register.
  116.  W   |$210A: Plane 3 VRAM location register.
  117.             *** All of these follow the same definition as $2107.
  118. -----------                              
  119.  W   |$210B: Tile VRAM location register.
  120.             aaaabbbb
  121.                     a: Location of tiles for Plane 1.
  122.                     b: Location of tiles for Plane 0.
  123.  
  124.             ***  The way you use this register is fairly neat.
  125.                  Since you only have a nybble to work with (which
  126.                  ranges from $0-F only) your Tile location can
  127.                  only be $0000 to $F000. You can't have an address
  128.                  such as $5F91 or $1C4A which holds your tile
  129.                  data. You just can't have it. :-)
  130.  
  131. -----------                              
  132.  W   |$210C: Tile VRAM location register.
  133.             ccccdddd
  134.                     c: Location of tiles for Plane 3.
  135.                     d: Location of tiles for Plane 2.
  136.  
  137.             *** Same stats for $210B go for this one; 'cept the
  138.                 plane registers are different.
  139. -----------                              
  140.  W   |$210D: Plane 0 X-scroll register.
  141.             *** This register is really funky. You have to write
  142.                 to it twice in a row (each piece of data being
  143.                 1 byte). The register is setup as the following:
  144.                 - You store the first 8 bits (the first byte) which
  145.                 ranges from $00 to $FF. After you store this
  146.                 value, you have to store the next 3 bits in the
  147.                 same register.
  148.             *** The following code demonstrates how to move plane 0
  149.                 left:
  150.                     LDA Plane0X
  151.                     DEC
  152.                     STA Plane0X
  153.                     STA $210D
  154.                     STZ $210D
  155.                 If you make that into a loop by itself, the result
  156.                 is the plane keeps scrolling left forever; it even
  157.                 wraps around back to the start.
  158.  
  159.           *** Note: I've been told this is a nasty way to do it
  160.                 because MODE 7 uses 13 bits of the above,
  161.                 while the rest use 10. I'm not taking care of
  162.                 the MSB. :-(
  163.  
  164. -----------                              
  165.  W   |$210E: Plane 0 Y-Scroll register.
  166.  W   |$210F: Plane 1 X-Scroll register.
  167.  W   |$2110: Plane 1 Y-Scroll register.
  168.  W   |$2111: Plane 2 X-Scroll register.
  169.  W   |$2112: Plane 2 Y-Scroll register.
  170.  W   |$2113: Plane 3 X-Scroll register.
  171.  W   |$2114: Plane 3 Y-Scroll register.
  172.             *** All of these follow the same definition as $210D.
  173. -----------                              
  174.  W   |$2115: Video port control.
  175.           *** If you store the following listed values in this register,
  176.             the following happens:
  177.  
  178.         $80: H/L increment which determines if the address will be
  179.              incremented after it reads/writes to/from $2118 and
  180.              $2139, or $2119 and $213A.
  181.  
  182.  W   |$2116: Video port address. 
  183.             *** 16 bit VRAM address.
  184.     $2117: Video port address (continued, due to 16 bits).
  185.  W   |$2118: Video port data. 
  186.             *** Data register for writing VRAM data.
  187.     $2119: Video port data.
  188.           *** Same as above.
  189. -----------                              
  190.  W   |$211A: MODE 7 Information register.
  191.             xy????ab
  192.                     a: Horizontal or Vertical flip. 
  193.                     b: Horizontal or Vertical flip.
  194.                     x: Landscape repeat type.
  195.                     y: Landscape repeat type.
  196.  
  197.             *** I have not the SLIGHTEST idea what the hell
  198.                 the original author means by this. If someone
  199.                 can explain it, tell me.
  200. -----------                              
  201.  W   |$211B: COS (COSIN) rotate angle / X Expansion.
  202.  W   |$211C: SIN (SIN) rotate angle / X Expansion.
  203.  W   |$211D: SIN (SIN) rotate angle / Y Expansion.
  204.  W   |$211E: COS (COSIN) rotate angle / Y Expansion.
  205.  W   |$211F: 13 bit address for the center of Rotate X.
  206.  W   |$2120: 13 bit address for the center of Rotate Y.
  207.  
  208.             *** All above things i've never used, nor do I
  209.                 have any explainations on them. Use them at
  210.                 your own risk, or until I get info on 'em.
  211.  
  212.             *** $211F and $2120 are like $210D: You have to
  213.                 write a byte to them twice.
  214. -----------                              
  215.  W   |$2121: Color # (or pallete) selection register.
  216.             xxxxxxxx
  217.                     x: Color # ($00-$FF).
  218.  
  219.             *** This register is probably one of the most simple
  220.                 registers I know of to use. You simply store the
  221.                 # of the color you want to modify before writing
  222.                 to $2122. This register is autoincrementing, so
  223.                 you don't have to "LDA #$01, STA $2121, LDA #$02,
  224.                 STA $2121, LDA #$03..." and so on...
  225.                 Code is as follows:
  226.                     STZ $2121   ; Start at color 0.
  227.                     STZ $2122   ; Color #0 = 00 00
  228.                     STZ $2122
  229.                     LDA #$FF    ; Color #1 = 7F FF (white).
  230.                     STA $2122
  231.                     LDA #$7F
  232.                     STA $2122
  233.                     LDA #$1F    ; Color #2 = 00 1F (red).
  234.                     STA $2122
  235.                     STZ $2122
  236. -----------                              
  237.  W   |$2122: Color data register.
  238.             xxxxxxxx
  239.                     x: Value of color.
  240.  
  241.             *** Color on the SNES is trippy; it's 15 bit. Check
  242.                 Section 2 on how the SNES colors are setup. Some
  243.                 example code I listed for $2121... Anyways, this
  244.                 register is like $210D (plane X-scroll) and those
  245.                 types: You have to store the value in it twice.
  246.                 For instance: If you wanted the color white (which
  247.                 is $7FFF in SNES-color), you would have to do the
  248.                 following:
  249.                     LDA [whatever color #]
  250.                     STA $2121
  251.                     LDA #$FF    ; We first store the "lower half"
  252.                     STA $2122
  253.                     LDA #$7F    ; Then the upper...
  254.                     STA $2122
  255.                 It's really not that hard, but it'll take some
  256.                 getting used to :-) Remember, check Section 2 on
  257.                 how the SNES does it's color, and for tile-setup,
  258.                 check Section 4.
  259. -----------                              
  260.  W   |$212C: Playfield/Sprite-enable register.
  261.             abcdefgh
  262.                     a: Plane 3 enable (for Sprites).
  263.                     b: Plane 2 enable (for Sprites).
  264.                     c: Plane 1 enable (for Sprites).
  265.                     d: Plane 0 enable (for Sprites).
  266.                     e: Enable plane 3.
  267.                     f: Enable plane 2.
  268.                     g: Enable plane 1.
  269.                     h: Enable plane 0.
  270.             *** This register allows you to enable which planes
  271.                 you want to put sprites on (to move or etc.) and
  272.                 to scroll, or other neato things. If you wanna
  273.                 use all 4 planes, but no sprites, shove $0F into
  274.                 this register. If you want to use all the planes,
  275.                 but want sprites on planes 1 and 3, you would shove
  276.                 $AF into this register. It's very easy to do.
  277. -----------                              
  278.  W   |$2133: Screen mode register. 
  279.             ????ab?c
  280.                     a: Interlace Y.
  281.                     b: Overscan.
  282.                     c: Interlace X.
  283.  
  284.             *** To be blatently honest, I have -NO IDEA- what
  285.                 this register does; I don't understand what
  286.                 Corsair & Dax meant by Interlace and Overscan.
  287.                 If someone can explain this register to me, i'd
  288.                 be very grateful :-).
  289. -----------                              
  290.  R   |$2139: VRAM port data (reading).
  291.     $213A: "                       "
  292. ----------- 
  293. ??   |$2140       *** These are the audio registers. 'never used 'em.
  294. ??   |$2141           Try shoving data into them; who knows, if you get
  295. ??   |$2142           music sometime, then you know you're on the right
  296. ??   |$2143           track. :-)
  297. -----------                              
  298. ??   |$4200: Counter Enable.
  299.             ??yx???a
  300.                     a: Joypad-read Enable (1 = Readable).
  301.                     x: Horizontal Counter Enable.
  302.                     y: Vertical Counter Enable.
  303. -----------                              
  304. ??   |$4201: 8 bit parallel data.
  305.  
  306.             *** This is the expansion bus for the Famicom.
  307. -----------                              
  308. RW   |$420B: DMA enable register.
  309.             abcdefgh
  310.                     a: DMA #7.
  311.                     b: DMA #6.
  312.                     c: DMA #5.
  313.                     d: DMA #4.
  314.                     e: DMA #3.
  315.                     f: DMA #2.
  316.                     g: DMA #1.
  317.                     h: DMA #0.
  318.  
  319.             *** I've personally never used DMA for anything. I hope
  320.                 someone out there has, and can tell me how to use
  321.                 it. :-)
  322. -----------                              
  323. ??   |$420D: Memory select.
  324.             ???????x
  325.                     x: Fast/Normal ROM flip.
  326.                   0 = Normal.
  327.                   1 = Fast.
  328. -----------
  329. R    |$4210: VBL register.
  330.             x???????
  331.                     x: VBlank period
  332.                        1 = On.
  333.                        0 = Off.
  334.  
  335.             *** This is probably the most important register
  336.                 you should work with. Without it, you die,
  337.                 and other things happen. :-) The following
  338.                 routine allows you to sync to the VBL/wait
  339.                 for the VBL to pass by so you can do your work:
  340.                 -       LDA $4210
  341.                     AND #$80
  342.                         BEQ -
  343.                     LDA $4210
  344.  
  345.                 From a programmers' standpoint, the following
  346.                 code should do the EXACT SAME as the above,
  347.                 but faster. NOTE thou, that it doesn't. I
  348.                 think the timing is off, that's why it doesn't
  349.                 work right. But, here-goes:
  350.  
  351.                 -       LDA $4210
  352.                     BPL -
  353.                     LDA $4210
  354. -----------                              
  355. ??   |$4211: ?????.
  356.             x???????
  357.                     x: IRQ Enable flag (1: Enabled).
  358.  
  359.             *** I don't even know the DESCRIPTION of the reg-
  360.                 ister! :-)
  361. -----------                              
  362. RW   |$4212: Joypad-ready register.
  363.             ???????x
  364.                     x: Ready-state bit (1: Ready).
  365.  
  366.             *** I'm not sure how this register is setup; all I know
  367.                 is how to use it. Code is as follows:
  368.                     PadLoop LDA $4212
  369.                           AND #$01
  370.                           BNE PadLoop
  371.                 This waits for the joypad to become ready to read.
  372. -----------                              
  373. RW   |$4218: Joypad #0 register (1 out of 2).
  374.             abcd0000
  375.                     a:    0 = A button not pressed.
  376.                         1 = A button pressed.
  377.                     b:    0 = X button not pressed.
  378.                         1 = X button pressed.
  379.                     c:    0 = Top-left button not pressed.
  380.                         1 = Top-left button pressed.
  381.                     d:    0 = Top-right button not pressed.
  382.                         1 = Top-right button pressed.
  383.             *** These are self-explainitory. To find out the
  384.                 status of each bit, just AND #$ for that bit...
  385.                 The code for checking is the following:
  386.                     LDA $4218
  387.                     AND #$80    ; Is the A button pressed?
  388.                     BNE YesA    ; Button pressed (bit is 1).
  389.                     LDA $4218
  390.                     AND #$40    ; Is button X pressed?
  391.                     BNE YesX    ; Button pressed (bit is 1).
  392.                     LDA $4218
  393.                     AND #$10    ; Is the top-right button pressed?
  394.                     BNE YesTopR ; Button pressed (bit is 1).
  395.                 ...and so on. It's very simple.
  396.             *** Note: The Corsair & Dax document was -WRONG-.
  397.                     It took me a good hour or two to find this
  398.                     out, so I decided i'd better write down the
  399.                     CORRECT way to do things).
  400. -----------                              
  401. RW   |$4219: Joypad #0 register (2 out of 2).
  402.             abcdefgh
  403.                     a:    0 = B button not pressed.
  404.                         1 = B button pressed.
  405.                     b:    0 = Y button not pressed.
  406.                         1 = Y button pressed.
  407.                     c:    0 = Select button not pressed.
  408.                         1 = Select button pressed.
  409.                     d:    0 = Start button not pressed.
  410.                         1 = Start button pressed.
  411.                     e:    0 = Up not pressed.
  412.                         1 = Up pressed.
  413.                     f:    0 = Down not pressed.
  414.                         1 = Down pressed.
  415.                     g:    0 = Left not pressed.
  416.                         1 = Left pressed.
  417.                     h:    0 = Right not pressed.
  418.                         1 = Right pressed.
  419.             *** Same as $4218... Some demo code follows:
  420.                     LDA $4219
  421.                     AND #$80    ; Is the B button pressed?
  422.                     BNE YesB    ; Button pressed (bit is 1).
  423.                     LDA $4219
  424.                     AND #$04    ; Is Down pressed?
  425.                     BNE YesDown ; Button pressed (bit is 1).
  426.                     LDA $4219
  427.                     AND #$02    ; Is Left pressed?
  428.                     BNE YesLeft ; Button pressed (bit is 1).
  429. -----------                              
  430. RW   |$421A: Joypad #1 register (1 out of 2).
  431. RW   |$421B: Joypad #1 register (2 out of 2).
  432. RW   |$421C: Joypad #2 register (1 out of 2).
  433. RW   |$421D: Joypad #2 register (2 out of 2).
  434. RW   |$421E: Joypad #3 register (2 out of 2).
  435. RW   |$421F: Joypad #3 register (2 out of 2).
  436.                 *** Setup is the same as $4218 and $4219.
  437. =-=-=
  438. 1)    Memory Map
  439.     ii) Additional info.
  440. -----------                              
  441. RW   |$FFC0: Cartridge title.
  442. RW   |$FFD6: ROM/RAM Info on cart..
  443. RW   |$FFD7: ROM Size.
  444. RW   |$FFD8: RAM Size.
  445. RW   |$FFD9: Maker ID Code.
  446. RW   |$FFDB: Version #.
  447. RW   |$FFDC: Checksum complement.
  448. RW   |$FFDE: Checksum.
  449. RW   |$FFEA: NMI vector/VBL Interrupt.
  450. RW   |$FFEC: Reset vector.
  451.  
  452.             *** With SMC (Magicom) files the offset is $7e00 less
  453.                 than above.
  454.             *** I've never actually used this information before:
  455.                 This could be SMC header only; but then why would
  456.                 there be memory locations for such? Strange. I'll
  457.                 leave the information I put in up to SNESASM v1.05.
  458.                 I use the psuedo-ops NAM, VER, and other things.
  459.  
  460. =-=-=
  461. 2)    SNES Color explaination.
  462. -----------                              
  463.     Oh BOY! So you're interested in finding out how the SNES does
  464.     it's color (via $2122), right? Well here ya go...
  465.  
  466.     The SNES has a strange way of doing color (atleast that i've
  467.     seen in my lifetime). Color is 15 bit; each "RGB" value (red,
  468.     green, and blue) has 5 bits a piece.
  469.  
  470.     When it comes to putting data into $2122, the format (in binary)
  471.     is the following (I put them into each byte):
  472.                 0bbbbbgg gggrrrrr
  473.                 |
  474.                 |_ Someone needs to tell me what this bit
  475.                    -REALLY- is. I've just been told to set
  476.                    it to 0...
  477.     We guess that the Japanese didn't like the idea of putting them
  478.     in the "standard" order of R, G, then B: but instead wanted them
  479.     in alphabetical order. Silly! :-).
  480.  
  481.     The way -I- do my color conversions is on a calculator... Just
  482.     plug in the bits you want to set in binary, then let the calc.
  483.     convert it into hexadecimal. It's pretty easy; or you can be
  484.     a Studly Programmer (hehehe) and do it in your head.
  485.  
  486.     A quick color chart:          $7FFF: White  (0111 1111 1111 1111)
  487.                         $001F: Red    (0000 0000 0001 1111)
  488.                         $03E0: Green  (0000 0011 1110 0000)
  489.                         $7C00: Blue   (0111 1100 0000 0000)
  490.                         $7C1F: Purple (0111 1100 0001 1111)
  491.                         $7FE0: Aqua   (0111 1111 1110 0000)
  492.                         $03FF: Yellow (0000 0011 1111 1111);
  493.     Well there you have it. It's pretty simple after you get the hang
  494.     of it; when using the SNES, you get REALLY good with binary math:
  495.     You'll find this out after working with the machine for awhile.
  496.  
  497. =-=-=
  498. 3)    DMA Memory Map and explaination.
  499. -----------                              
  500. ??   |$43x0: DMA Control register (??? Not sure ???).
  501.  W   |$43x1: DMA Destination register.
  502.             $18 = Video Port access.
  503.             $22 = Color pallete access.
  504.  
  505.             *** This gives access to only some of the video chip.
  506.                 registers. Hell if I know which ones.
  507. -----------                              
  508.  W   |$43x2: Source address.
  509.             *** THIS REGISTER IS A WORD IN LENGTH ***
  510.             *** The document I have says:
  511.                 "lo-hi  16 lowest bits". Who knows... 
  512. -----------                              
  513.  W   |$43x4: Source bank address.
  514.             *** The document I have says:
  515.                 "8 highest bits". 
  516. -----------                              
  517.  W   |$43x5: Transfer size register.
  518.             *** Same as above:
  519.                 "lo-hi". 
  520. -----------                              
  521.     All the "x"s represent the DMA # (ranging from 0 to 7).
  522.     DMA #0: $4300-$4305.
  523.     DMA #1: $4310-$4315.
  524.     ......
  525.     DMA #7: $4370-$4375.
  526. =-=-=
  527. 4)    SNES Graphics (tiles) explaination.
  528. -----------                              
  529.     This is probably the most requested section of the document for
  530.     people whom are starting out on the SNES and want to learn just
  531.     how in the hell the SNES -DOES- do it's graphics.
  532.  
  533.     There's so much to explain!!!
  534.  
  535.     The SNES does it's graphics in tiles (surprise surprise!).
  536.  
  537.     There are different MODEs on the SNES; the most famous being
  538.     is MODE 7. Alas: Most people think using $2106 is MODE 7 ($2106
  539.     is for screen pixelation: Where the pixels get "larger". Look 
  540.     in Section 1 for an explaination of this register).
  541.                 *** THIS IS NOT MODE 7!!! ***. 
  542.     So the next time the pixels get really "big" (almost making them
  543.     look like IBM PC 320x200x256 mode :-)), and your friend says "WOW!
  544.     MODE 7 is COOL," punch 'em in the nose for me. Just kidding.
  545.  
  546.     Also, another thing I should mention: Bitplanes are NOT THE SAME
  547.     AS PLANES. Planes are like "screens." You can scroll a plane, but
  548.     not a bitplane. Bitplanes are put ONTO a plane, which can be
  549.     scrolled any direction.
  550.  
  551.     I'll be explaining MODE 1. MODE 7 is too tough for me to
  552.     explain, since you end up losing colors and other screwy things...
  553.     Check Section-5 for a mode-# list.
  554.     
  555. MODE   #/Playfields    MaxColor/Tile   Palettes        Colors
  556. ---------------------------------------------------------------------------
  557. 0      4               4               8               16
  558. 1      3               16/16/4 (HUH?)  8               128
  559.     
  560.     MODE 0 is good for geometric shapes (if you were going to rotate
  561.     a wireframe cube), basic star scrolls, or a very "bland" text
  562.     scroller.
  563.  
  564.     Let's start with MODE 1.
  565.  
  566.     MODE 1 is best for really basic things: Star scrollers, text
  567.     scrolls, geometric (non detailed) art, or line drawings; it's
  568.     only 16 colors/bitplane, and there's only 4 bitplanes to play
  569.     with.
  570.  
  571.     What you need is 4 bitplanes of data. You don't -HAVE- to
  572.     use 4 bitplanes... You can use 1 bitplane if you want, but
  573.     you only get 16 colors (NO!!! :-)).
  574.  
  575.     You also need a plane map: You can't just have the predefined
  576.     graphics data and thats it: You have to "setup the plane" to
  577.     tell it what tile goes where.
  578.     
  579.     For demonstration purposes, i'll use code to explain it.
  580.  
  581. -----------                              
  582.     The "lda #$0000" "tcd" transfers the DP location pointer to
  583.     where the scratchpad RAM is. This makes things go much faster,
  584.     because DP is always faster than normal RAM (yay for DP!!!)
  585.     
  586.     The other part puts where the location of the data in the
  587.     binary/image is into two DP locations: font and font2.
  588.  
  589. font  equ $00     ; Direct page equates.
  590. font2 equ font+1
  591.     
  592.     sei
  593.     phk          
  594.     plb          
  595.     clc
  596.     xce
  597.     rep #$30     
  598.     lda #$0000   
  599.     tcd
  600.     lda #charset
  601.     sta font
  602.     lda #charset2
  603.     sta font2
  604. -----------                              
  605.     The following code tells the SNES where the actual data
  606.     is in VRAM memory.
  607.                      
  608.     lda #$10                ; Plane 0 text @ VRAM $1000. 
  609.     sta $2107               
  610.     
  611.     lda #$02                ; Tiles for Plane 0 @ VRAM $2000.
  612.     sta $210b               
  613. -----------                              
  614.     The following code actually MOVES the data in the binary/image
  615.     into the SNES's VRAM.
  616.  
  617.     sep #$20
  618.     ldx #$2000              ; This puts the data sent thru $2118 and 
  619.                     ; $2119 into VRAM $2000.
  620.     stx $2116
  621.     ldy #$0000
  622. -     lda (font),y            ; Get bitplane 0 data (font)
  623.     sta $2118               ; ... and store it in bitplane 0.
  624.     lda (font2),y           ; Get bitplane 1 data (font2)
  625.     sta $2119               ; ... and store it in bitplane 1...
  626.     stz $2118               ; I don't want to use bitplane 2 and 3,
  627.     stz $2119               ; so I store zeros here. You could put
  628.                     ; more font data in there if you wanted.
  629.     iny
  630.     cpy #$0200        
  631.     bne -
  632.     
  633.     ldx #$1000              ; This puts the data sent thru $2118 and              
  634.     stx $2116               ; $2119 into VRAM $1000.
  635.     ldx #$0000
  636. -     lda TEXT,x              ; Get the character from TEXT...
  637.     and #$3f                ; AND #$3F because we only want the first
  638.                     ; 64 characters in the font.
  639.     sta $2118               ; 
  640.     stz $2119               ; Check near the end of this Section for
  641.                     ; an explaination on what the actual bits
  642.                     ; do instead of just storing 0 there all
  643.                     ; the time.
  644.     inx
  645.     cpx #$0400
  646.     bne -            
  647. -----------                              
  648.     Here's the actual data names (charset, charset2, and TEXT).
  649.     My new source has them in dcb % statements to make the font
  650.     more readable: The first time I did this, I had to convert
  651.     the binary stuff I wrote on paper into hex, then put them
  652.     into decent hex statements in an orderly fashion.
  653.  
  654. charset 
  655.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'@'  
  656.     dcb     $00,$3c,$66,$7e,$66,$66,$66,$00 ;'A'
  657.     dcb     $00,$7c,$66,$7c,$66,$66,$7c,$00 ;'B'
  658.     dcb     $00,$3c,$66,$60,$60,$66,$3c,$00 ;'C'
  659.     dcb     $00,$78,$6c,$66,$66,$6c,$78,$00 ;'D'
  660.     dcb     $00,$7e,$60,$78,$60,$60,$7e,$00 ;'E'
  661.     dcb     $00,$7e,$60,$78,$60,$60,$60,$00 ;'F'
  662.     dcb     $00,$3c,$66,$60,$6e,$66,$3c,$00 ;'G'
  663.     dcb     $00,$66,$66,$7e,$66,$66,$66,$00 ;'H'
  664.     dcb     $00,$3c,$18,$18,$18,$18,$3c,$00 ;'I'
  665.     dcb     $00,$1e,$0c,$0c,$0c,$6c,$38,$00 ;'J'
  666.     dcb     $00,$6c,$78,$70,$78,$6c,$66,$00 ;'K'
  667.     dcb     $00,$60,$60,$60,$60,$60,$7e,$00 ;'L'
  668.     dcb     $00,$63,$77,$7f,$6b,$63,$63,$00 ;'M'
  669.     dcb     $00,$66,$76,$7e,$7e,$6e,$66,$00 ;'N'
  670.     dcb     $00,$3c,$66,$66,$66,$66,$3c,$00 ;'O'
  671.     dcb     $00,$7c,$66,$66,$7c,$60,$60,$00 ;'P'
  672.     dcb     $00,$3c,$66,$66,$66,$3c,$0e,$00 ;'Q'
  673.     dcb     $00,$7c,$66,$66,$7c,$6c,$66,$00 ;'R'
  674.     dcb     $00,$3e,$60,$3c,$06,$66,$3c,$00 ;'S'
  675.     dcb     $00,$7e,$18,$18,$18,$18,$18,$00 ;'T'
  676.     dcb     $00,$66,$66,$66,$66,$66,$3c,$00 ;'U'
  677.     dcb     $00,$66,$66,$66,$66,$3c,$18,$00 ;'V'
  678.     dcb     $00,$63,$63,$6b,$7f,$77,$63,$00 ;'W'
  679.     dcb     $00,$66,$3c,$18,$3c,$66,$66,$00 ;'X'
  680.     dcb     $00,$66,$66,$3c,$18,$18,$18,$00 ;'Y'
  681.     dcb     $00,$7e,$0c,$18,$30,$60,$7e,$00 ;'Z'
  682.     dcb     $08,$00,$00,$00,$00,$00,$00,$00 ;'['    
  683.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'\'
  684.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;']'
  685.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'^'
  686.     dcb     $00,$08,$00,$00,$00,$00,$00,$00 ;'_'  
  687.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;' '  
  688.     dcb     $00,$7E,$7E,$3C,$18,$00,$18,$00 ;'!'
  689.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'"'
  690.     dcb     $80,$80,$80,$80,$80,$80,$80,$80 ;'#'
  691.     dcb     $FC,$FE,$FF,$F7,$F7,$FF,$FE,$FC ;'$'
  692.     dcb     $3E,$42,$4E,$5C,$5C,$4E,$42,$3E ;'%'
  693.     dcb     $00,$00,$00,$00,$00,$00,$00,$01 ;'&'
  694.     dcb     $00,$00,$00,$07,$00,$00,$00,$00 ;'''
  695.     dcb     $00,$04,$08,$08,$08,$08,$04,$00 ;'('
  696.     dcb     $00,$20,$10,$10,$10,$10,$20,$00 ;')'
  697.     dcb     $08,$08,$08,$F8,$08,$08,$08,$08 ;'*'
  698.     dcb     $10,$10,$10,$1F,$10,$10,$10,$10 ;'+'
  699.     dcb     $10,$10,$20,$C0,$00,$00,$00,$00 ;','
  700.     dcb     $00,$00,$00,$FF,$00,$00,$00,$00 ;'-'
  701.     dcb     $00,$00,$00,$00,$00,$18,$18,$00 ;'.'
  702.     dcb     $00,$00,$00,$FF,$80,$80,$80,$80 ;'/'  
  703.     dcb     $00,$3c,$66,$6e,$76,$66,$3c,$00 ;'0'
  704.     dcb     $00,$18,$38,$18,$18,$18,$7e,$00 ;'1'
  705.     dcb     $00,$7c,$06,$0c,$30,$60,$7e,$00 ;'2'
  706.     dcb     $00,$7e,$06,$1c,$06,$66,$3c,$00 ;'3'
  707.     dcb     $00,$0e,$1e,$36,$7f,$06,$06,$00 ;'4'
  708.     dcb     $00,$7e,$60,$7c,$06,$66,$3c,$00 ;'5'
  709.     dcb     $00,$3e,$60,$7c,$66,$66,$3c,$00 ;'6'
  710.     dcb     $00,$7e,$06,$0c,$0c,$0c,$0c,$00 ;'7'
  711.     dcb     $00,$3c,$66,$3c,$66,$66,$3c,$00 ;'8'
  712.     dcb     $00,$3c,$66,$3e,$06,$66,$3c,$00 ;'9'
  713.     dcb     $00,$00,$00,$03,$04,$08,$08,$08 ;':' 
  714.     dcb     $00,$80,$80,$F0,$80,$80,$00,$00 ;';'
  715.     dcb     $80,$80,$80,$FF,$00,$00,$00,$00 ;'<'
  716.     dcb     $00,$00,$00,$C0,$20,$10,$10,$10 ;'='
  717.     dcb     $08,$08,$04,$03,$00,$00,$00,$00 ;'>'
  718.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'?'
  719.  
  720. charset2 
  721.     dcb     $00,$3C,$4E,$5E,$5E,$40,$3C,$00 ;'@'  
  722.     dcb     $00,$3c,$66,$7e,$66,$66,$66,$00 ;'A'
  723.     dcb     $00,$7c,$66,$7c,$66,$66,$7c,$00 ;'B'
  724.     dcb     $00,$3c,$66,$60,$60,$66,$3c,$00 ;'C'
  725.     dcb     $00,$78,$6c,$66,$66,$6c,$78,$00 ;'D'
  726.     dcb     $00,$7e,$60,$78,$60,$60,$7e,$00 ;'E'
  727.     dcb     $00,$7e,$60,$78,$60,$60,$60,$00 ;'F'
  728.     dcb     $00,$3c,$66,$60,$6e,$66,$3c,$00 ;'G'
  729.     dcb     $00,$66,$66,$7e,$66,$66,$66,$00 ;'H'
  730.     dcb     $00,$3c,$18,$18,$18,$18,$3c,$00 ;'I'
  731.     dcb     $00,$1e,$0c,$0c,$0c,$6c,$38,$00 ;'J'
  732.     dcb     $00,$6c,$78,$70,$78,$6c,$66,$00 ;'K'
  733.     dcb     $00,$60,$60,$60,$60,$60,$7e,$00 ;'L'
  734.     dcb     $00,$63,$77,$7f,$6b,$63,$63,$00 ;'M'
  735.     dcb     $00,$66,$76,$7e,$7e,$6e,$66,$00 ;'N'
  736.     dcb     $00,$3c,$66,$66,$66,$66,$3c,$00 ;'O'
  737.     dcb     $00,$7c,$66,$66,$7c,$60,$60,$00 ;'P'
  738.     dcb     $00,$3c,$66,$66,$66,$3c,$0e,$00 ;'Q'
  739.     dcb     $00,$7c,$66,$66,$7c,$6c,$66,$00 ;'R'
  740.     dcb     $00,$3e,$60,$3c,$06,$66,$3c,$00 ;'S'
  741.     dcb     $00,$7e,$18,$18,$18,$18,$18,$00 ;'T'
  742.     dcb     $00,$66,$66,$66,$66,$66,$3c,$00 ;'U'
  743.     dcb     $00,$66,$66,$66,$66,$3c,$18,$00 ;'V'
  744.     dcb     $00,$63,$63,$6b,$7f,$77,$63,$00 ;'W'
  745.     dcb     $00,$66,$3c,$18,$3c,$66,$66,$00 ;'X'
  746.     dcb     $00,$66,$66,$3c,$18,$18,$18,$00 ;'Y'
  747.     dcb     $00,$7e,$0c,$18,$30,$60,$7e,$00 ;'Z'
  748.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'[' 
  749.     dcb     $09,$09,$00,$00,$00,$00,$00,$00 ;'\'
  750.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;']'
  751.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'^'
  752.     dcb     $00,$08,$00,$00,$00,$00,$00,$00 ;'_'  
  753.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;' '  
  754.     dcb     $00,$7E,$7E,$3C,$18,$00,$18,$00 ;'!'
  755.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'"'
  756.     dcb     $80,$80,$80,$80,$80,$80,$80,$80 ;'#'
  757.     dcb     $FC,$FE,$FF,$F7,$F7,$FF,$FE,$FC ;'$'
  758.     dcb     $3E,$42,$4E,$5C,$5C,$4E,$42,$3E ;'%'
  759.     dcb     $00,$00,$00,$00,$00,$00,$00,$01 ;'&'
  760.     dcb     $00,$00,$00,$07,$00,$00,$00,$00 ;'''
  761.     dcb     $00,$04,$08,$08,$08,$08,$04,$00 ;'('
  762.     dcb     $00,$20,$10,$10,$10,$10,$20,$00 ;')'
  763.     dcb     $08,$08,$08,$F8,$08,$08,$08,$08 ;'*'
  764.     dcb     $10,$10,$10,$1F,$10,$10,$10,$10 ;'+'
  765.     dcb     $10,$10,$20,$C0,$00,$00,$00,$00 ;','
  766.     dcb     $00,$00,$00,$FF,$00,$00,$00,$00 ;'-'
  767.     dcb     $00,$00,$00,$00,$00,$18,$18,$00 ;'.'
  768.     dcb     $00,$00,$00,$FF,$80,$80,$80,$80 ;'/'  
  769.     dcb     $00,$3c,$66,$6e,$76,$66,$3c,$00 ;'0'
  770.     dcb     $00,$18,$38,$18,$18,$18,$7e,$00 ;'1'
  771.     dcb     $00,$7c,$06,$0c,$30,$60,$7e,$00 ;'2'
  772.     dcb     $00,$7e,$06,$1c,$06,$66,$3c,$00 ;'3'
  773.     dcb     $00,$0e,$1e,$36,$7f,$06,$06,$00 ;'4'
  774.     dcb     $00,$7e,$60,$7c,$06,$66,$3c,$00 ;'5'
  775.     dcb     $00,$3e,$60,$7c,$66,$66,$3c,$00 ;'6'
  776.     dcb     $00,$7e,$06,$0c,$0c,$0c,$0c,$00 ;'7'
  777.     dcb     $00,$3c,$66,$3c,$66,$66,$3c,$00 ;'8'
  778.     dcb     $00,$3c,$66,$3e,$06,$66,$3c,$00 ;'9'
  779.     dcb     $00,$00,$00,$03,$04,$08,$08,$08 ;':' 
  780.     dcb     $00,$80,$80,$F0,$80,$80,$00,$00 ;';'
  781.     dcb     $80,$80,$80,$FF,$00,$00,$00,$00 ;'<'
  782.     dcb     $00,$00,$00,$C0,$20,$10,$10,$10 ;'='
  783.     dcb     $08,$08,$04,$03,$00,$00,$00,$00 ;'>'
  784.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'?'
  785.  
  786. TEXT  dcb     " THIS IS YOUR ENTIRE SCREEN     "
  787.     dcb     " HERE... IF YOU REMOVE ONE OF   "
  788.     dcb     " THE LINES WHICH IS BLANK, THE  "
  789.     dcb     " SCREEN ENDS UP BEING FUNKY     "
  790.     dcb     " DOWN AT THE BOTTOM OF THE      "
  791.     dcb     " SCREEN.                        "
  792.     dcb     "                                "
  793.     dcb     " SO MAKE SURE YOU ALWAYS LEAVE  "
  794.     dcb     " ALL OF THIS TEXT THINGS IN!    "
  795.     dcb     "                                "
  796.     dcb     "                                "
  797.     dcb     "                                "
  798.     dcb     "         YOSHI THE DINO         "
  799.     dcb     "                                "
  800.     dcb     "                                "
  801.     dcb     "                                "
  802.     dcb     "                                "
  803.     dcb     "                                "
  804.     dcb     "                                "
  805.     dcb     "                                "
  806.     dcb     "                                "
  807.     dcb     "                                "
  808.     dcb     "                                "
  809.     dcb     "                                "
  810.     dcb     "                                "
  811.     dcb     "                                "
  812.     dcb     "                                "
  813.     dcb     "                                "
  814.     dcb     "                                "
  815.     dcb     "********************************"
  816.     dcb     "                                "
  817.     dcb     "                                "
  818. -----------                              
  819.     Well there's some code for those whom want to rip it :-).
  820.     
  821.     I hope I haven't confused you yet: If I have, go back and re-read
  822.     the code. I've been working with the SNES for awhile, so I under-
  823.     stand a little more than a beginner.
  824.  
  825.     You're probably wondering how the heck the following line ends
  826.     up being an "@" on your TV, or whatever you have your SNES
  827.     hooked up to.
  828.  
  829.     Lets look at charset and charset2.
  830.  
  831. charset 
  832.     dcb     $00,$00,$00,$00,$00,$00,$00,$00 ;'@'  
  833.  
  834. charset2 
  835.     dcb     $00,$3C,$4E,$5E,$5E,$40,$3C,$00 ;'@'  
  836.  
  837.     Convert charsets hex-statements into binary. Consider each
  838.     new "$xx" statement a new pixel line. Tile size is 8x8.
  839.  
  840.     00000000          = $00
  841.     00000000          = $00
  842.     00000000          = $00
  843.     00000000          = $00
  844.     00000000          = $00
  845.     00000000          = $00
  846.     00000000          = $00
  847.     00000000          = $00
  848.  
  849.     Convert charset2s hex-statements into binary. 
  850.  
  851.     00000000          = $00
  852.     00111100          = $3C
  853.     01001110          = $4E
  854.     01011110          = $5E
  855.     01011110          = $5E
  856.     01000000          = $40
  857.     00111100          = $3C
  858.     00000000          = $00
  859.  
  860.     *NOW* do you see the at-symbol? (and yes, I -DID- draw all
  861.     of the font by hand. It took me HOURS, but I did it).
  862.  
  863.     You're probably now asking: "Well, that tells me how to define
  864.     where a pixel IS: but how do I define it's color?"
  865.  
  866.     This is the fun part. It's sort-of hard to explain:
  867.     If you have a 0 for bitplane 0, a 0 for bitplane 1, a 0 for
  868.     bitplane 2, and a 0 for bitplane 3, you get the color 0.
  869.         i.e.: 0000 = Color #0
  870.             ||||___________Bitplane 0
  871.             |||__________Bitplane 1
  872.             ||_________Bitplane 2
  873.             |________Bitplane 3
  874.  
  875.     So, think about a 0 for bitplane 0, a 1 for bitplane 1 & 2
  876.     and a 0 for bitplane 3.
  877.         i.e.: 0110 = Color #6
  878.             ||||___________Bitplane 0
  879.             |||__________Bitplane 1
  880.             ||_________Bitplane 2
  881.             |________Bitplane 3
  882.  
  883.     This is probably the best explaination i've ever seen done about
  884.     SNES pixel-color definition, so don't plan on seeing one any
  885.     better anytime soon :-).
  886.  
  887.     Anyway, the result above gives you the color # per pixel; it's
  888.     fairly interesting... it's like an "overlay" type of method.
  889.  
  890.     I mentioned in the source above that you should check near the
  891.     end of the Section for info on why I "stz $2119". Well, here's
  892.     why: The bits in the tile-data are fairly "silly": The tile
  893.     "character" itself is 10 bits, while the other 6 are "fun bits,"
  894.     as I call them. Here's the explaination:
  895.             yx?cccNN | NNNNNNNN
  896.                         y: Flip the tile vertically.
  897.                         x: Flip the tile horiztonally.
  898.                         ?: Dunno! Set it to 1 and find out. 
  899.                         c: Pallete # (0-7).
  900.                         N: Character itself.
  901.                         
  902.     So, I STZ there: Yes, I leave the top bits "unset," which means
  903.     you could get messed up data, but as far as I have checked, the
  904.     SNES has "clear memory" when you start it up: So the bits I don't
  905.     zero-out should be zeros anyways! :-) If you want to set them,
  906.     feel free to do so! The results of flipping Y and X are sortof
  907.     fun to play with. "To read this scrolly, you must stand on your
  908.     head" :-)
  909. =-=-=
  910. 5)    SNES Screen mode definitions.
  911. -----------                              
  912. MODE   # of bitplanes  Colors per plane  Palletes      Max. # of colors
  913. ---------------------------------------------------------------------------
  914. 0      2               4               8               32
  915. 1      4               16              8               128
  916. 2      ?               ???             ?               ??? 
  917. 3      8               256             1               256
  918. 4      ?               ???             ?               ??? 
  919. 5      ?               ???             ?               ??? 
  920. 6      ?               16              8               128 (Interlaced mode)
  921. 7      ?               256             1               256 (Yes, MODE 7)
  922. ---------------------------------------------------------------------------
  923.  
  924.     The parms which have "?" or "???" mean I don't know what they REALLY
  925.     are: I got a document which explained them, but it was bogus: It
  926.     said a 16 color mode had -1- bitplane. Weird... I'm not even sure
  927.     about MODE 6. But, we know what MODE 7 is, even if I'm not sure how
  928.     many bitplanes it DOES use (the doc says 1, I say 8).
  929.  
  930.     I've tested MODE 0 and 1 myself. MODE 3 I might test in the future,
  931.     but i've never had the desire to draw up 8 bitplanes of data by
  932.     hand ( I don't have a SNES-graphics-generator for the PC! :-( ).
  933. =-=-=
  934. 6)    SNES OAM/Sprite explaination.
  935. -----------                              
  936.     The sprites use a lookup table that contains info on their X and
  937.     Y position on the screen, their size, if they're flipped horizontally
  938.     or vertically, their color, and the actual character.
  939.  
  940.     The format you need to make the table in is as follows:
  941.  
  942. Size  Address/Offset          Explaination
  943. ---------------------------------------------------------------------------
  944. *** SPRITE 0 ***
  945. BYTE  0                      
  946.                     xxxxxxxx
  947.                             x: X location.
  948. BYTE  1                       
  949.                     yyyyyyyy
  950.                             y: Y location.
  951. WORD  2+3         
  952.                   abcdeeex | xxxxxxxx
  953.                             a: Vertical flip.
  954.                             b: Horizontal flip.
  955.                             c: Playfield priority.
  956.                             d: Playfield priority.
  957.                             e: Pallete #.
  958.                             x: Character #.
  959. *** SPRITE 0 ***
  960. BYTE  4                       
  961.                     xxxxxxxx
  962.                             x: X location.
  963. BYTE  5                       
  964.                     yyyyyyyy
  965.                             y: Y location.
  966. ....... and so on .......
  967. ---------------------------------------------------------------------------
  968.     Continue this table all the way down to sprite #127 (the 128th
  969.     sprite).
  970.     
  971.     Don't think you're