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
/
SNESDOC.TXT
< prev
next >
Wrap
Internet Message Format
|
1994-02-07
|
56KB
From: Jeremy Chadwick <yoshi@CSOS.ORST.EDU>
To: "Super Famicom Development Group" <famidev@busop.cit.wayne.edu>
Subject: SNES Document v1.0
Date: Thu, 11 Nov 1993 01:22:14 -0800
Reply-to: famidev@busop.cit.wayne.edu
Sender: Listserv@busop.cit.wayne.edu
X-Mailer: Mercury MTA v1.0.
The following file is written by yours-truly (!). I got sick of people writing
shit-fuck documentation, so I decided to write my own. I hope you enjoy it.
=-=-=
SNES Documentation v1.0: Written by Yoshi of Digital Exodus.
=-=-=
0) "Why write a document like this?" 'Why ask why, code 'till ya die'
1) Memory Map.
i) "Main" memory map.
ii) Etc...
2) SNES Color explaination.
3) SNES DMA Memory Map and explaination.
4) SNES Graphics (tiles) explaination.
5) SNES Screen mode definitions.
6) SNES OAM/Sprite explaination.
7) Magicom Disk registers and Memory controller locations.
69) About the author (ME! :-))...
FF) Greetings, Thanx, etc...
=-=-=
0) "Why write a document like this?" 'Why ask why, code 'till ya die'
-----------
I've been asked the same question over the last few weeks:
"Yoshi, why write a document on the Super Nintendo? I mean, it's
fucking impossible to program on such a lame machine," or "Why
waste your time?"
Simple. I'm really tired (yawn) of seeing people write documents
like their brain is more advanced than their English. I'm tired
of seeing bullshit documentation (someone on the InterNET supplied
me with a document they wrote from scratch before they checked
any of the locations, or even other documents: The document was
a fucking joke: Over 95% of the registers I list in the following
Sections were labelled "???"), and documentation which has MAJOR
bugs in it (like the Corsair & Dax document; the joypad-input
section. Jesus Christ, guys, atleast get the JOYPAD SHIT RIGHT!
Thou, the rest of the doc was great! Thanx!).
So, over the last few weeks, i've come up with this document by
skipping a few classes, missing my IRC-chats at night, staying
up until 6AM on the weekends to code 'n document, and even not
doing laundry for a good 3 or 4 days (gross huh?): But it's
here, and i'm glad I wrote something which can help out other
people. I'm just sad to say that I used most of the other
documents as references: I only tested a few of the registers
for this document: Otherwise I just code with the documents
which are available to me... and many of them i've cursed at
because they were wrong, which made me ending up spending an
hour or two trying to figure out what was wrong.
Anyways, enjoy the document. I hope it helps those out there
who keep asking me "How do I start? I know assembly, but I have
no documentation on the machine!!!". I even included some
demo code all over this document, 'pecially in Section 4.
*** NOTE *** All demo code is made for SNEASM v1.05. If you
have v1.01 or v1.02, then change all the "dcb" statements
to "dc.b"... also, anything I list in binary via "dcb %" can't
be done in SNESASM v1.01 or v1.02. v1.05 is the newest develop-
ment kit, and it's very cool: Thanx to Norman Yen for supplying
me with it!!! THANX NORM!!!
All typos in the document are my fault: I type fast, so typos
may be consistant in some parts (which are usually the parts
where I was up at 3AM typing this, my eyes barely open, and
my mind falling out of my skull). I'd assume 95% of the
information here is correct: *** IF YOU FIND SOMETHING WHICH
ISN'T, ---> TELL ME! <--- ***. I'll fix it ASAP, and put out
a new version of the document every 5 bug reports.
Give me feedback on what you think too... check Section 69
(heh heh heh) for an explaination about how to contact me
and the such. If you know something I don't, --TELL ME!--.
If you're looking for MODE 7 information, don't look at me:
I don't know how to use it, or sprites: So check someplace
else, like in the Corsair Document, or your library. Just ask
them for full documentation on SNES MODE 7 w/ 8 bitplane de-
finition, EXTBG mapping, and 256 colors: They'll probably end
up shitting their pants, but that's OK.
Yoshi of Digital Exodus.
November 5th, 1993.
=-=-=
1) Memory Map.
i) "Main" memory map.
-----------
Just so you know... the R and/or W's on the left side before the
memory location mean [R]eadable and/or [W]riteable. I don't know
what happens if you try to read from the write-only registers:
I think you get bogus data, but that's about it.
-----------
W |$2100: Screen display register.
Hi | Lo
x000 | bbbb
x: 0 = Screen off.
1 = Screen on.
bbbb: 0-$F = Brightness of screen.
*** If you increment $2100 so the register goes up
to $xF (x being whatever), you can make the
screen "fade in". Make -SURE- you do this only
during the VBlank period! If you don't, the screen
goes totally wacko! The 'GS programmers like myself
call it "Syncing to the VBL". Get used to the term.
-----------
W |$2101: OAM (Sprite) sizes.
Hi | Lo
aaab | bbbb
a: Sizes.
b: Address of OAM (Sprite).
*** The sizes are defined as follows:
000: 8x8 or 16x16
001: 8x8 or 32x32
*** I've never used this register, nor sprites.
Check Section 6 for information
which was not done by me: If you understand
it better than I do, good deal.
-----------
W |$2102: Address of OAM (Sprites).
Hi1 | Lo1 | Hi | Lo
???? | ???? | ???? | ????
*** This register i've never used. All I know is
that it's a -WORD- in length, not a byte.
-----------
W |$2104: Data for OAM (Sprites).
Hi | Lo
???? | ????
*** I've never used this register. It's like $210D:
You have to store a value in it twice.
-----------
W |$2105: Screen mode.
Hi | Lo
abcd | 0eee
a \
b \ Somehow "toggles" 8/16 (???) mode.
c /
d /
e: MODE definition. MODEs range from
0 to 7, therefore:
%000 for MODE 0, %001 for MODE 1,
%010 for MODE 2, %011 for MODE 3,
%100 for MODE 4, %101 for MODE 5,
%110 for MODE 6, and %111 for MODE 7.
-----------
W |$2106: Screen pixelation (aka. MOSAIC) register.
Hi | Lo
xxxx | abcd
x: 0-$F = Pixel size.
a: Affect plane 3.
b: Affect plane 2.
c: Affect plane 1.
d: Affect plane 0.
*** Just like $2100, this only works during VBlank.
I recommend you setup what planes you want to
affect at the start of the program, then to
make them change, do the following:
LDA #$03 ; Affect planes 0 and 1.
STA TempReg1
STA $2106
JSR WaitVBlank
LDA TempReg1
Loop STA $2106
CLC
ADC #$10
CMP #$F0
BNE Loop
-----------
W |$2107: Plane 0 VRAM location register.
Hi | Lo
xxxx | xxab
x: Address of VRAM location.
ab: Tile size (?) 32 or 64.
*** The way I use this register is pretty simple.
Lets say the VRAM is in $2000... Therefore,
we'd go like this:
LDA #$20
STA $2107
-----------
W |$2108: Plane 1 VRAM location register.
W |$2109: Plane 2 VRAM location register.
W |$210A: Plane 3 VRAM location register.
*** All of these follow the same definition as $2107.
-----------
W |$210B: Tile VRAM location register.
Hi | Lo
aaaa | bbbb
a: Location of tiles for Plane 1.
b: Location of tiles for Plane 0.
*** The way you use this register is fairly neat.
Since you only have a nybble to work with (which
ranges from $0-F only) your Tile location can
only be $0000 to $F000. You can't have an address
such as $5F91 or $1C4A which holds your tile
data. You just can't have it. :-)
-----------
W |$210C: Tile VRAM location register.
Hi | Lo
cccc | dddd
c: Location of tiles for Plane 3.
d: Location of tiles for Plane 2.
*** Same stats for $210B go for this one; 'cept the
plane registers are different.
-----------
W |$210D: Plane 0 X-scroll register.
*** This register is really funky. You have to write
to it twice in a row (each piece of data being
1 byte). The register is setup as the following:
- You store the first 8 bits (the first byte) which
ranges from $00 to $FF. After you store this
value, you have to store the next 3 bits in the
same register.
*** The following code demonstrates how to move plane 0
left:
LDA Plane0X
DEC
STA Plane0X
STA $210D
STZ $210D
If you make that into a loop by itself, the result
is the plane keeps scrolling left forever; it even
wraps around back to the start.
-----------
W |$210E: Plane 0 Y-Scroll register.
W |$210F: Plane 1 X-Scroll register.
W |$2110: Plane 1 Y-Scroll register.
W |$2111: Plane 2 X-Scroll register.
W |$2112: Plane 2 Y-Scroll register.
W |$2113: Plane 3 X-Scroll register.
W |$2114: Plane 3 Y-Scroll register.
*** All of these follow the same definition as $210D.
-----------
W |$2115: Video port control.
W |$2116: Video port address.
*** The doc I have says:
"(lo-hi)".
W |$2118: Video port data.
*** "(lo-hi) (address is incremented by 2)"
-----------
W |$211A: MODE 7 Information register.
Hi | Lo
xy?? | ??ab
a: Horizontal or Vertical flip.
b: Horizontal or Vertical flip.
x: Landscape repeat type.
y: Landscape repeat type.
*** I have not the SLIGHTEST idea what the hell
the original author means by this. If someone
can explain it, tell me.
-----------
W |$211B: COS (COSIN) rotate angle / X Expansion.
W |$211C: SIN (SIN) rotate angle / X Expansion.
W |$211D: SIN (SIN) rotate angle / Y Expansion.
W |$211E: COS (COSIN) rotate angle / Y Expansion.
W |$211F: 13 bit address for the center of Rotate X.
W |$2120: 13 bit address for the center of Rotate Y.
*** All above things i've never used, nor do I
have any explainations on them. Use them at
your own risk, or until I get info on 'em.
*** $211F and $2120 are like $210D: You have to
write a byte to them twice.
-----------
W |$2121: Color # (or pallete) selection register.
Hi | Lo
xxxx | xxxx
x: Color # ($00-$FF).
*** This register is probably one of the most simple
registers I know of to use. You simply store the
# of the color you want to modify before writing
to $2122. This register is autoincrementing, so
you don't have to "LDA #$01, STA $2121, LDA #$02,
STA $2121, LDA #$03..." and so on...
Code is as follows:
STZ $2121 ; Start at color 0.
STZ $2122 ; Color #0 = 00 00
STZ $2122
LDA #$FF ; Color #1 = 7F FF (white).
STA $2122
LDA #$7F
STA $2122
LDA #$1F ; Color #2 = 00 1F (red).
STA $2122
STZ $2122
-----------
W |$2122: Color data register.
Hi | Lo
xxxx | xxxx
x: Value of color.
*** Color on the SNES is trippy; it's 15 bit. Check
Section 2 on how the SNES colors are setup. Some
example code I listed for $2121... Anyways, this
register is like $210D (plane X-scroll) and those
types: You have to store the value in it twice.
For instance: If you wanted the color white (which
is $7FFF in SNES-color), you would have to do the
following:
LDA [whatever color #]
STA $2121
LDA #$FF ; We first store the "lower half"
STA $2122
LDA #$7F ; Then the upper...
STA $2122
It's really not that hard, but it'll take some
getting used to :-) Remember, check Section 2 on
how the SNES does it's color, and for tile-setup,
check Section 4.
-----------
W |$212C: Playfield/Sprite-enable register.
Hi | Lo
abcd | efgh
a: Plane 3 enable (for Sprites).
b: Plane 2 enable (for Sprites).
c: Plane 1 enable (for Sprites).
d: Plane 0 enable (for Sprites).
e: Enable plane 3.
f: Enable plane 2.
g: Enable plane 1.
h: Enable plane 0.
*** This register allows you to enable which planes
you want to put sprites on (to move or etc.) and
to scroll, or other neato things. If you wanna
use all 4 planes, but no sprites, shove $0F into
this register. If you want to use all the planes,
but want sprites on planes 1 and 3, you would shove
$AF into this register. It's very easy to do.
-----------
W |$2133: Screen mode register.
Hi | Lo
0000 | ab0c
a: Interlace Y.
b: Overscan.
c: Interlace X.
*** To be blatently honest, I have -NO FUCKING IDEA-
what this register does; I don't understand what
Corsair & Dax meant by Interlace and Overscan.
If someone can explain this register to me, i'd
be very grateful :-).
-----------
?? |$2140 *** These are the audio registers. 'never used 'em.
?? |$2141 Try shoving data into them; who knows, if you get
?? |$2142 music sometime, then you know you're on the right
?? |$2143 track. :-)
-----------
?? |$4200: Counter Enable.
Hi | Lo
??yx | ???a
a: Joypad-read Enable (1 = Readable).
x: Horizontal Counter Enable.
y: Vertical Counter Enable.
-----------
?? |$4201: 8 bit parallel data.
*** This is the expansion bus for the Famicom.
-----------
RW |$420B: DMA enable register.
Hi | Lo
abcd | efgh
a: DMA #7.
b: DMA #6.
c: DMA #5.
d: DMA #4.
e: DMA #3.
f: DMA #2.
g: DMA #1.
h: DMA #0.
*** I've personally never used DMA for anything. I hope
someone out there has, and can tell me how to use
it. :-)
-----------
?? |$420D: Memory select.
Hi | Lo
???? | ???x
x: Fast/Normal ROM flip.
*** I don't know if when bit 0 is set if it's Fast or
Normal. Someone find this out for me :-)
-----------
?? |$4211: ?????.
Hi | Lo
x??? | ????
x: IRQ Enable flag (1: Enabled).
*** Shit! I don't even know the DESCRIPTION of the
register! :-)
-----------
RW |$4212: Joypad-ready register.
Hi | Lo
???? | ???x
x: Ready-state bit (1: Ready).
*** I'm not sure how this register is setup; all I know
is how to use it. Code is as follows:
PadLoop LDA $4212
AND #$01
BNE PadLoop
This waits for the joypad to become ready to read.
-----------
RW |$4218: Joypad #0 register (1 out of 2).
Hi | Lo
abcd | 0000
a: 0 = A button not pressed.
1 = A button pressed.
b: 0 = X button not pressed.
1 = X button pressed.
c: 0 = Top-left button not pressed.
1 = Top-left button pressed.
d: 0 = Top-right button not pressed.
1 = Top-right button pressed.
*** These are self-explainitory. To find out the
status of each bit, just AND #$ for that bit...
The code for checking is the following:
LDA $4218
AND #$80 ; Is the A button pressed?
BNE YesA ; Button pressed (bit is 1).
LDA $4218
AND #$40 ; Is button X pressed?
BNE YesX ; Button pressed (bit is 1).
LDA $4218
AND #$10 ; Is the top-right button pressed?
BNE YesTopR ; Button pressed (bit is 1).
...and so on. It's very simple.
*** Note: The Corsair & Dax document was -WRONG-.
It took me a good hour or two to find this
out, so I decided i'd better write down the
CORRECT way to do things; damn you guys! :-)
-----------
RW |$4219: Joypad #0 register (2 out of 2).
Hi | Lo
abcd | efgh
a: 0 = B button not pressed.
1 = B button pressed.
b: 0 = Y button not pressed.
1 = Y button pressed.
c: 0 = Select button not pressed.
1 = Select button pressed.
d: 0 = Start button not pressed.
1 = Start button pressed.
e: 0 = Up not pressed.
1 = Up pressed.
f: 0 = Down not pressed.
1 = Down pressed.
g: 0 = Left not pressed.
1 = Left pressed.
h: 0 = Right not pressed.
1 = Right pressed.
*** Same as $4218... Some demo code follows:
LDA $4219
AND #$80 ; Is the B button pressed?
BNE YesB ; Button pressed (bit is 1).
LDA $4219
AND #$04 ; Is Down pressed?
BNE YesDown ; Button pressed (bit is 1).
LDA $4219
AND #$02 ; Is Left pressed?
BNE YesLeft ; Button pressed (bit is 1).
-----------
RW |$421A: Joypad #1 register (1 out of 2).
RW |$421B: Joypad #1 register (2 out of 2).
RW |$421C: Joypad #2 register (1 out of 2).
RW |$421D: Joypad #2 register (2 out of 2).
RW |$421E: Joypad #3 register (2 out of 2).
RW |$421F: Joypad #3 register (2 out of 2).
*** Setup is the same as $4218 and $4219.
=-=-=
1) Memory Map
ii) Etc...
-----------
RW |$FFC0: Cartridge title.
RW |$FFD6: ROM/RAM Info on cart..
RW |$FFD7: ROM Size.
RW |$FFD8: RAM Size.
RW |$FFD9: Maker ID Code.
RW |$FFDB: Version #.
RW |$FFDC: Checksum complement.
RW |$FFDE: Checksum.
RW |$FFEA: NMI vector/VBL Interrupt.
RW |$FFEC: Reset vector.
*** With SMC (Magicom) files the offset is $7e00 less
than above.
*** I've never actually used this information before:
This could be SMC header only; but then why would
there be memory locations for such? Strange. I'll
leave the information I put in up to SNESASM v1.05.
I use the psuedo-ops NAM, VER, and other things.
=-=-=
2) SNES Color explaination.
-----------
Oh BOY! So you're interested in finding out how the SNES does
it's color (via $2122), right? Well here ya go...
The SNES has a strange way of doing color (atleast that i've
seen in my lifetime). Color is 15 bit; each "RGB" value (red,
green, and blue) has 5 bits a piece.
When it comes to putting data into $2122, the format (in binary)
is the following (I put them into each nybble, just so you can
see what each hi and lo nybble looks like):
0bbb bbgg gggr rrrr
|
|_ Someone needs to tell me what this bit
-REALLY- is. I've just been told to set
it to 0...
We guess that the Japanese didn't like the idea of putting them
in the "standard" order of R, G, then B: but instead wanted them
in alphabetical order...
The way -I- do my color conversions is on a calculator... Just
plug in the bits you want to set in binary, then let the calc.
convert it into hexadecimal. It's pretty easy; or you can be
a Studly Programmer (hehehe) and do it in your head.
A quick color chart: $7FFF: White (0111 1111 1111 1111)
$001F: Red (0000 0000 0001 1111)
$03E0: Green (0000 0011 1110 0000)
$7C00: Blue (0111 1100 0000 0000)
$7C1F: Purple (0111 1100 0001 1111)
$7FE0: Aqua (0111 1111 1110 0000)
$03FF: Yellow (0000 0011 1111 1111);
Well there you have it. It's pretty simple after you get the hang
of it; when using the SNES, you get REALLY good with binary math:
You'll find this out after working with the machine for awhile.
=-=-=
3) DMA Memory Map and explaination.
-----------
?? |$43x0: DMA Control register (??? Not sure ???).
W |$43x1: DMA Destination register.
$18 = Video Port access.
$22 = Color pallete access.
*** This gives access to only some of the video chip.
registers. Hell if I know which ones.
-----------
W |$43x2: Source address.
*** THIS REGISTER IS A WORD IN LENGTH ***
*** The document I have says:
"lo-hi 16 lowest bits". Who knows what the
fuck the author meant by that...
-----------
W |$43x4: Source bank address.
*** The document I have says:
"8 highest bits". Just who in the hell wrote
this document on the DMA??? Some dumbass :-)
-----------
W |$43x5: Transfer size register.
*** Same as above:
"lo-hi". Gee, how specific can we get?
-----------
All the "x"s represent the DMA # (ranging from 0 to 7).
DMA #0: $4300-$4305.
DMA #1: $4310-$4315.
......
DMA #7: $4370-$4375.
=-=-=
4) SNES Graphics (tiles) explaination.
-----------
This is probably the most requested section of the document for
people whom are starting out on the SNES and want to learn just
how in the hell the SNES -DOES- do it's graphics.
There's so much to fucking explain!!!
The SNES does it's graphics in tiles (surprise surprise!).
There are different MODEs on the SNES; the most famous being
is MODE 7. Alas: Most people think using $2106 is MODE 7 ($2106
is for screen pixelation: Where the pixels get "larger". Look
in Section 1 for an explaination of this register).
*** THIS IS NOT MODE 7!!! ***.
So the next time the pixels get really "big" (almost making them
look like IBM PC 320x200x256 mode :-)), and your friend says "WOW!
MODE 7 is COOL," punch 'em in the nose for me.
Also, another thing I should mention: Bitplanes are NOT THE SAME
AS PLANES. Planes are like "screens." You can scroll a plane, but
not a bitplane. Bitplanes are put ONTO a plane, which can be
scrolled any direction.
I'll be explaining MODE 1. MODE 7 is too damn tough for me to
explain, since you end up losing colors and other screwy things...
Check Section-5 for a mode-# list.
MODE #/Playfields MaxColor/Tile Palettes Colors
---------------------------------------------------------------------------
0 4 4 8 16
1 3 16/16/4 (HUH?) 8 128
MODE 0 is good for geometric shapes (if you were going to rotate
a wireframe cube), basic star scrolls, or a very "bland" text
scroller.
Let's start with MODE 1.
MODE 1 is best for really basic things: Star scrollers, text
scrolls, geometric (non detailed) art, or line drawings; it's
only 16 colors/bitplane, and there's only 4 bitplanes to play
with.
What you need is 4 bitplanes of data. You don't -HAVE- to
use 4 bitplanes... You can use 1 bitplane if you want, but
you only get 16 colors (NO!!! :-)).
You also need a plane map: You can't just have the predefined
graphics data and thats it: You have to "setup the plane" to
tell it what tile goes where.
For demonstration purposes, i'll use code to explain it.
-----------
The "lda #$0000" "tcd" transfers the DP location pointer to
where the scratchpad RAM is. This makes things go much faster,
because DP is always faster than normal RAM (yay for DP!!!)
The other part puts where the location of the data in the
binary/image is into two DP locations: font and font2.
font equ $00 ; Direct page equates.
font2 equ font+1
sei
phk
plb
clc
xce
rep #$30
lda #$0000
tcd
lda #charset
sta font
lda #charset2
sta font2
-----------
The following code tells the SNES where the actual data
is in VRAM memory.
lda #$10 ; Plane 0 text @ VRAM $1000.
sta $2107
lda #$02 ; Tiles for Plane 0 @ VRAM $2000.
sta $210b
-----------
The following code actually MOVES the data in the binary/image
into the SNES's VRAM.
sep #$20
ldx #$2000 ; This puts the data sent thru $2118 and
; $2119 into VRAM $2000.
stx $2116
ldy #$0000
- lda (font),y ; Get bitplane 0 data (font)
sta $2118 ; ... and store it in bitplane 0.
lda (font2),y ; Get bitplane 1 data (font2)
sta $2119 ; ... and store it in bitplane 1...
stz $2118 ; I don't want to use bitplane 2 and 3,
stz $2119 ; so I store zeros here. You could put
; more font data in there if you wanted.
iny
cpy #$0200
bne -
ldx #$1000 ; This puts the data sent thru $2118 and
stx $2116 ; $2119 into VRAM $1000.
ldx #$0000
- lda TEXT,x ; Get the character from TEXT...
and #$3f ; AND #$3F because we only want the first
; 64 characters in the font.
sta $2118 ;
stz $2119 ; Check near the end of this Section for
; an explaination on what the actual bits
; do instead of just storing 0 there all
; the time.
inx
cpx #$0400
bne -
-----------
Here's the actual data names (charset, charset2, and TEXT).
My new source has them in dcb % statements to make the font
more readable: The first time I did this, I had to fucking
convert the binary stuff I wrote on paper into hex, then put
them into decent hex statements in an orderly fashion.
charset
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'@'
dcb $00,$3c,$66,$7e,$66,$66,$66,$00 ;'A'
dcb $00,$7c,$66,$7c,$66,$66,$7c,$00 ;'B'
dcb $00,$3c,$66,$60,$60,$66,$3c,$00 ;'C'
dcb $00,$78,$6c,$66,$66,$6c,$78,$00 ;'D'
dcb $00,$7e,$60,$78,$60,$60,$7e,$00 ;'E'
dcb $00,$7e,$60,$78,$60,$60,$60,$00 ;'F'
dcb $00,$3c,$66,$60,$6e,$66,$3c,$00 ;'G'
dcb $00,$66,$66,$7e,$66,$66,$66,$00 ;'H'
dcb $00,$3c,$18,$18,$18,$18,$3c,$00 ;'I'
dcb $00,$1e,$0c,$0c,$0c,$6c,$38,$00 ;'J'
dcb $00,$6c,$78,$70,$78,$6c,$66,$00 ;'K'
dcb $00,$60,$60,$60,$60,$60,$7e,$00 ;'L'
dcb $00,$63,$77,$7f,$6b,$63,$63,$00 ;'M'
dcb $00,$66,$76,$7e,$7e,$6e,$66,$00 ;'N'
dcb $00,$3c,$66,$66,$66,$66,$3c,$00 ;'O'
dcb $00,$7c,$66,$66,$7c,$60,$60,$00 ;'P'
dcb $00,$3c,$66,$66,$66,$3c,$0e,$00 ;'Q'
dcb $00,$7c,$66,$66,$7c,$6c,$66,$00 ;'R'
dcb $00,$3e,$60,$3c,$06,$66,$3c,$00 ;'S'
dcb $00,$7e,$18,$18,$18,$18,$18,$00 ;'T'
dcb $00,$66,$66,$66,$66,$66,$3c,$00 ;'U'
dcb $00,$66,$66,$66,$66,$3c,$18,$00 ;'V'
dcb $00,$63,$63,$6b,$7f,$77,$63,$00 ;'W'
dcb $00,$66,$3c,$18,$3c,$66,$66,$00 ;'X'
dcb $00,$66,$66,$3c,$18,$18,$18,$00 ;'Y'
dcb $00,$7e,$0c,$18,$30,$60,$7e,$00 ;'Z'
dcb $08,$00,$00,$00,$00,$00,$00,$00 ;'['
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'\'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;']'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'^'
dcb $00,$08,$00,$00,$00,$00,$00,$00 ;'_'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;' '
dcb $00,$7E,$7E,$3C,$18,$00,$18,$00 ;'!'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'"'
dcb $80,$80,$80,$80,$80,$80,$80,$80 ;'#'
dcb $FC,$FE,$FF,$F7,$F7,$FF,$FE,$FC ;'$'
dcb $3E,$42,$4E,$5C,$5C,$4E,$42,$3E ;'%'
dcb $00,$00,$00,$00,$00,$00,$00,$01 ;'&'
dcb $00,$00,$00,$07,$00,$00,$00,$00 ;'''
dcb $00,$04,$08,$08,$08,$08,$04,$00 ;'('
dcb $00,$20,$10,$10,$10,$10,$20,$00 ;')'
dcb $08,$08,$08,$F8,$08,$08,$08,$08 ;'*'
dcb $10,$10,$10,$1F,$10,$10,$10,$10 ;'+'
dcb $10,$10,$20,$C0,$00,$00,$00,$00 ;','
dcb $00,$00,$00,$FF,$00,$00,$00,$00 ;'-'
dcb $00,$00,$00,$00,$00,$18,$18,$00 ;'.'
dcb $00,$00,$00,$FF,$80,$80,$80,$80 ;'/'
dcb $00,$3c,$66,$6e,$76,$66,$3c,$00 ;'0'
dcb $00,$18,$38,$18,$18,$18,$7e,$00 ;'1'
dcb $00,$7c,$06,$0c,$30,$60,$7e,$00 ;'2'
dcb $00,$7e,$06,$1c,$06,$66,$3c,$00 ;'3'
dcb $00,$0e,$1e,$36,$7f,$06,$06,$00 ;'4'
dcb $00,$7e,$60,$7c,$06,$66,$3c,$00 ;'5'
dcb $00,$3e,$60,$7c,$66,$66,$3c,$00 ;'6'
dcb $00,$7e,$06,$0c,$0c,$0c,$0c,$00 ;'7'
dcb $00,$3c,$66,$3c,$66,$66,$3c,$00 ;'8'
dcb $00,$3c,$66,$3e,$06,$66,$3c,$00 ;'9'
dcb $00,$00,$00,$03,$04,$08,$08,$08 ;':'
dcb $00,$80,$80,$F0,$80,$80,$00,$00 ;';'
dcb $80,$80,$80,$FF,$00,$00,$00,$00 ;'<'
dcb $00,$00,$00,$C0,$20,$10,$10,$10 ;'='
dcb $08,$08,$04,$03,$00,$00,$00,$00 ;'>'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'?'
charset2
dcb $00,$3C,$4E,$5E,$5E,$40,$3C,$00 ;'@'
dcb $00,$3c,$66,$7e,$66,$66,$66,$00 ;'A'
dcb $00,$7c,$66,$7c,$66,$66,$7c,$00 ;'B'
dcb $00,$3c,$66,$60,$60,$66,$3c,$00 ;'C'
dcb $00,$78,$6c,$66,$66,$6c,$78,$00 ;'D'
dcb $00,$7e,$60,$78,$60,$60,$7e,$00 ;'E'
dcb $00,$7e,$60,$78,$60,$60,$60,$00 ;'F'
dcb $00,$3c,$66,$60,$6e,$66,$3c,$00 ;'G'
dcb $00,$66,$66,$7e,$66,$66,$66,$00 ;'H'
dcb $00,$3c,$18,$18,$18,$18,$3c,$00 ;'I'
dcb $00,$1e,$0c,$0c,$0c,$6c,$38,$00 ;'J'
dcb $00,$6c,$78,$70,$78,$6c,$66,$00 ;'K'
dcb $00,$60,$60,$60,$60,$60,$7e,$00 ;'L'
dcb $00,$63,$77,$7f,$6b,$63,$63,$00 ;'M'
dcb $00,$66,$76,$7e,$7e,$6e,$66,$00 ;'N'
dcb $00,$3c,$66,$66,$66,$66,$3c,$00 ;'O'
dcb $00,$7c,$66,$66,$7c,$60,$60,$00 ;'P'
dcb $00,$3c,$66,$66,$66,$3c,$0e,$00 ;'Q'
dcb $00,$7c,$66,$66,$7c,$6c,$66,$00 ;'R'
dcb $00,$3e,$60,$3c,$06,$66,$3c,$00 ;'S'
dcb $00,$7e,$18,$18,$18,$18,$18,$00 ;'T'
dcb $00,$66,$66,$66,$66,$66,$3c,$00 ;'U'
dcb $00,$66,$66,$66,$66,$3c,$18,$00 ;'V'
dcb $00,$63,$63,$6b,$7f,$77,$63,$00 ;'W'
dcb $00,$66,$3c,$18,$3c,$66,$66,$00 ;'X'
dcb $00,$66,$66,$3c,$18,$18,$18,$00 ;'Y'
dcb $00,$7e,$0c,$18,$30,$60,$7e,$00 ;'Z'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'['
dcb $09,$09,$00,$00,$00,$00,$00,$00 ;'\'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;']'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'^'
dcb $00,$08,$00,$00,$00,$00,$00,$00 ;'_'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;' '
dcb $00,$7E,$7E,$3C,$18,$00,$18,$00 ;'!'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'"'
dcb $80,$80,$80,$80,$80,$80,$80,$80 ;'#'
dcb $FC,$FE,$FF,$F7,$F7,$FF,$FE,$FC ;'$'
dcb $3E,$42,$4E,$5C,$5C,$4E,$42,$3E ;'%'
dcb $00,$00,$00,$00,$00,$00,$00,$01 ;'&'
dcb $00,$00,$00,$07,$00,$00,$00,$00 ;'''
dcb $00,$04,$08,$08,$08,$08,$04,$00 ;'('
dcb $00,$20,$10,$10,$10,$10,$20,$00 ;')'
dcb $08,$08,$08,$F8,$08,$08,$08,$08 ;'*'
dcb $10,$10,$10,$1F,$10,$10,$10,$10 ;'+'
dcb $10,$10,$20,$C0,$00,$00,$00,$00 ;','
dcb $00,$00,$00,$FF,$00,$00,$00,$00 ;'-'
dcb $00,$00,$00,$00,$00,$18,$18,$00 ;'.'
dcb $00,$00,$00,$FF,$80,$80,$80,$80 ;'/'
dcb $00,$3c,$66,$6e,$76,$66,$3c,$00 ;'0'
dcb $00,$18,$38,$18,$18,$18,$7e,$00 ;'1'
dcb $00,$7c,$06,$0c,$30,$60,$7e,$00 ;'2'
dcb $00,$7e,$06,$1c,$06,$66,$3c,$00 ;'3'
dcb $00,$0e,$1e,$36,$7f,$06,$06,$00 ;'4'
dcb $00,$7e,$60,$7c,$06,$66,$3c,$00 ;'5'
dcb $00,$3e,$60,$7c,$66,$66,$3c,$00 ;'6'
dcb $00,$7e,$06,$0c,$0c,$0c,$0c,$00 ;'7'
dcb $00,$3c,$66,$3c,$66,$66,$3c,$00 ;'8'
dcb $00,$3c,$66,$3e,$06,$66,$3c,$00 ;'9'
dcb $00,$00,$00,$03,$04,$08,$08,$08 ;':'
dcb $00,$80,$80,$F0,$80,$80,$00,$00 ;';'
dcb $80,$80,$80,$FF,$00,$00,$00,$00 ;'<'
dcb $00,$00,$00,$C0,$20,$10,$10,$10 ;'='
dcb $08,$08,$04,$03,$00,$00,$00,$00 ;'>'
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'?'
TEXT dcb " THIS IS YOUR ENTIRE SCREEN "
dcb " HERE... IF YOU REMOVE ONE OF "
dcb " THE LINES WHICH IS BLANK, THE "
dcb " SCREEN ENDS UP BEING FUNKY "
dcb " DOWN AT THE BOTTOM OF THE "
dcb " SCREEN. "
dcb " "
dcb " SO MAKE SURE YOU ALWAYS LEAVE "
dcb " ALL OF THIS TEXT THINGS IN! "
dcb " "
dcb " "
dcb " "
dcb " YOSHI THE DINO "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb " "
dcb "********************************"
dcb " "
dcb " "
-----------
Well there's some code for those whom want to rip it :-).
I hope I haven't confused you yet: If I have, go back and re-read
the code. I've been working with the SNES for awhile, so I under-
stand a little more than a beginner.
You're probably wondering how the heck the following line ends
up being an "@" on your TV, or whatever you have your SNES
hooked up to.
Lets look at charset and charset2.
charset
dcb $00,$00,$00,$00,$00,$00,$00,$00 ;'@'
charset2
dcb $00,$3C,$4E,$5E,$5E,$40,$3C,$00 ;'@'
Convert charsets hex-statements into binary. Consider each
new "$xx" statement a new pixel line. Tile size is 8x8.
00000000 = $00
00000000 = $00
00000000 = $00
00000000 = $00
00000000 = $00
00000000 = $00
00000000 = $00
00000000 = $00
Convert charset2s hex-statements into binary.
00000000 = $00
00111100 = $3C
01001110 = $4E
01011110 = $5E
01011110 = $5E
01000000 = $40
00111100 = $3C
00000000 = $00
*NOW* do you see the at-symbol? (and yes, I -DID- draw all
of the font by hand. It took me HOURS, but I did it).
You're probably now asking: "Well, that tells me how to define
where a pixel IS: but how do I define it's color?"
This is the fun part. It's sort-of hard to explain:
If you have a 0 for bitplane 0, a 0 for bitplane 1, a 0 for
bitplane 2, and a 0 for bitplane 3, you get the color 0.
i.e.: 0000 = Color #0
||||___________Bitplane 0
|||__________Bitplane 1
||_________Bitplane 2
|________Bitplane 3
So, think about a 0 for bitplane 0, a 1 for bitplane 1 & 2
and a 0 for bitplane 3.
i.e.: 0110 = Color #6
||||___________Bitplane 0
|||__________Bitplane 1
||_________Bitplane 2
|________Bitplane 3
This is probably the best explaination i've ever seen done about
SNES pixel-color definition, so don't plan on seeing one any
better anytime soon :-).
Anyway, the result above gives you the color # per pixel; it's
fairly interesting... it's like an "overlay" type of method.
I mentioned in the source above that you should check near the
end of the Section for info on why I "stz $2119". Well, here's
why: The bits in the tile-data are fairly "silly": The tile
"character" itself is 10 bits, while the other 6 are "fun bits,"
as I call them. Here's the explaination:
Hi1 | Lo1 | Hi | Lo
yx?c | ccNN | NNNN | NNNN
y: Flip the tile vertically.
x: Flip the tile horiztonally.
?: Dunno! Set it to 1 and find out.
c: Pallete # (0-7).
N: Character itself.
So, I STZ there: Yes, I leave the top bits "unset," which means
you could get fucked up data, but as far as I have checked, the
SNES has "clear memory" when you start it up: So the bits I don't
zero-out should be zeros anyways! :-) If you want to set them,
feel free to do so! The results of flipping Y and X are sortof
fun to play with. "To read this scrolly, you must stand on your
head" :-)
=-=-=
5) SNES Screen mode definitions.
-----------
MODE # of bitplanes Colors per plane Palletes Max. # of colors
---------------------------------------------------------------------------
0 2 4 8 32
1 4 16 8 128
2 ? ??? ? ???
3 8 256 1 256
4 ? ??? ? ???
5 ? ??? ? ???
6 ? 16 8 128 (Interlaced mode)
7 ? 256 1 256 (Yes, MODE 7)
---------------------------------------------------------------------------
The parms which have "?" or "???" mean I don't know what they REALLY
are: I got a document which explained them, but it was bogus: It
said a 16 color mode had -1- bitplane. Weird... I'm not even sure
about MODE 6. But, we know what MODE 7 is, even if I'm not sure how
many bitplanes it DOES use (the doc says 1, I say 8).
I've tested MODE 0 and 1 myself. MODE 3 I might test in the future,
but i've never had the desire to draw up 8 bitplanes of data by
hand ( I don't have a SNES-graphics-generator for the PC! :-( ).
=-=-=
6) SNES OAM/Sprite explaination.
-----------
The sprites use a lookup table that contains info on their X and
Y position on the screen, their size, if they're flipped horizontally
or vertically, their color, and the actual character.
The format you need to make the table in is as follows:
Size Address/Offset Explaination
---------------------------------------------------------------------------
*** SPRITE 0 ***
BYTE 0 Hi | Lo
xxxx | xxxx
x: X location.
BYTE 1 Hi | Lo
yyyy | yyyy
y: Y location.
WORD 2+3 Hi1 | Lo1 | Hi | Lo
abcd | eeex | xxxx | xxxx
a: Vertical flip.
b: Horizontal flip.
c: Playfield priority.
d: Playfield priority.
e: Pallete #.
x: Character #.
*** SPRITE 0 ***
BYTE 4 Hi | Lo
xxxx | xxxx
x: X location.
BYTE 5 Hi | Lo
yyyy | yyyy
y: Y location.
....... and so on .......
---------------------------------------------------------------------------
Continue this table all the way down to sprite #127 (the 128th
sprite).
Don't think you're finished yet: There is another table of data
you have to make.
2 bits are defined for each sprite (ie. Byte #0 holds the info for
Sprite #0, #1, #2, and #3). Therefore, 128/4 = 32 bytes of data for
this table.
The bit-definitions follow ("x" is which bit i'm speaking about).
Bit 0 is the MSB of X position bit (0x)
Bit 1 is the size-toggle bit (x0).
So the 4 bytes/sprites + the block are put into the OAM table
by consecutive writes to the OAM data register. You first should
set the OAM address to $0, then shove your data thru it.
*** REMEMBER ***. If you don't set the block after the OAM as
well, the results can be nasty: All the data for the MSB stuff
wouldn't be defined correctly, which would result in your entire
sprite-table being silly :-). Have atleast some 0's there or
a table which you really want to use in the longrun.
=-=-=
9) Magicom Disk registers and Memory controller locations.
-----------
Do note that i've never used a Magicomm before, and I would
strongly recommend not using these unless you know what each
one does for 100% sure. If you're going to write an OS for
the SNES, i'll be at your door worshipping you when it
comes out :-)
The below registers i've never tested, or had tested. If you
end up fucking up your drive, it's not my fault. Someone
could remap the $C007 Disk Control Register to the +5V pin on the
SNES, and you could end up with a fried Magicomm (maybe. I'm not
into Electrical Engineering, so i'm probably wrong, but it'd
be funny to see what it did :-)).
Disk Registers:
Location Value returned when read Value inputted when written
---------------------------------------------------------------------------
$C000: Input Register
$C002: Digital Output Register
$C004: Main Status Register
$C005: Data Register Data Register
$C007: Digital Input Register Disk Control Register
$C008: Parallel Data Parallel Data
$C009: Parallel Status
---------------------------------------------------------------------------
Memory Controller: $E000 to $E00D (maybe?).
=-=-=
69) About the author (ME! :-))...
-----------
How come everyone probably goes here LAST :-)
I'm 16 years old; blonde hair, blue/grey eyes, 5'10" tall, 140
pounds. I currently am attending Corvallis High School in
Corvallis, Oregon (I'm a senior, believe it or not). I work
at the University (Oregon State, not University of Oregon)
as a Computer Science apprentice (volunteered there for fun).
In my spare time, I enjoy writing 1100+ lines of SNES doc-
umentation (just kidding!), programming, biking, sleeping,
composing music, drawing (freehand and via mouse), spending
time on IRC (YAY!!!), taking care of our CS users, and just
being myself. And for those who REALLY care, i'm single (for
females; i've already got a boyfriend: I luv ya, Chris!!!).
I've been programming in assembly for, oh, 4 years or so now.
I also know BASIC, Pascal, a little 680x0asm, C, and 80x86asm.
You can reach me many ways:
InterNET: yoshi@CSOS.ORST.EDU
yoshi@rush.cc.edu
Phone: (503)753-2431
SnailMail: Digital Exodus - All mail bombs
c/o Jeremy Chadwick - ...
ATTN: SNES DIVISION - will be returned.
33811 Twin Maple Lane - Money is glady
Corvallis, OR, 97333 - accepted: Thanx :-)
=-=-=
FF) Greetings, Thanx, etc...
-----------
Greetings/Comments go out to the following people:
* Maxx Headroom: Heh heh. Does this make me the OFFICIAL SNES
department for Digital Exodus? :-)
* med: Well, here's our document for starting out via
SNES assembly programming.
* IRSMan: About time someone wrote a CORRECT SNES document,
and this time it was me :-)
* TheJazz: A document this is: Maybe NOW you'll move to
California with med and I?
* JackRippr: We need to compare documents, dude. You probably
have information which I don't have, and it'd be
nice to have them all in one document, mmm?
* Souther: I think i'll be using THIS document instead of
"SNES.GFX" and "BLWSNES.DOC" :-) And no, I don't
know MODE 7! SHUTUP! :-)
* Section Z-Man &
Ghost: SCHIZZO BEATER! Ghost, stop bringing Jen over
into Z-Mans' trailer. "That's two..." :-)
* M.BiSON: You asked if I knew 65c816asm: I hope this proves
a tiny bit of my knowledge. Need me to write a
damn crack/intro page NOW? :-)
* Rasta Catcha: Gee, I wonder if this document is better than
yours. Maybe we can team up and write a book :-)
* Norman Yen: Thanx for SNESASM, and all those documents!!!!!
* All the dorks on
rec.games.v.n: Shut the fuck up already! Stop complaining.
* Those who mailed
me for a doc: This is for you guys!!! (I hope :-))
* All the guys on
#SNES & #SNES!: YAY!!! PROGRAMMING TIME!!! :-) :-)
{@8~r~x_{>a|%$}x
NO CARRIER
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Jeremy "Yoshi" Chadwick |Internet: yoshi@CSOS.ORST.EDU
LocalSupport-Apprentice for |Phone: (503) 753-2431
Computer Science Outreach Services|IRC & UNiX Support (Yoshi on IRC)
at Oregon State University |65c816 programmer (IIGS/SNES)
Opinions expressed may not be those of the CS Outreach Services dept.