Page 1 of 2
Some question about Mode 7
Posted: Mon Apr 11, 2016 8:20 pm
by Kannagi
I managed to get perspective on the Mode 7:
http://pixelretro.hebergratuit.net/NesBox/m7.html
(Though I wonder how the calculation soft , for the moment I precalculation in C language).
But I would use a second background.
When I active ext BG ,I have the impression that the BG2 is identical to BG1.
He uses every 2 BG1H0FS/BG1V0FS.
On Secret of Mana, it uses
BG1SC $ 51
BG2SC $ 59
BG12NBA $ 44
and $4000, data on 4bpp
Code: Select all
SNES_BGMODE $07 ; Mode 7
SNES_BG1SC $51 ; address data tiles BG1 $5000
SNES_BG2SC $59 ; address data tiles BG2 $5800
SNES_BGNBA $44 $04; address BG1,2,3,4 (2,1 / 4,3)
SNES_SETINI $40 ;$40 ext BG
SNES_TM $13 ; obj & bg 1,2 enable
Of course I did the same , but with no result on screen.
I forgot something ?
Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 8:43 pm
by Drew Sebastino
Unfortunately, there is only one BG in mode 7. "EXTBG", which shouldn't even be called so because it really isn't that, is that I think that any pixel with the highest bit set, using colors 127-255, will appear over sprites. It's kind of like how color 0 always appears behind sprites while colors 1-3 or 1-15 can appear above, except now 127-255. So yeah, no extra bandwidth is being used so it really isn't even an "EXTra Back Ground" like the name implies.
Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 9:03 pm
by Drew Sebastino
How does transparency work if there's nothing behind it? Wouldn't it appear opaque if by itself, but then translucent wherever a sprite is?
10 MHz 68000 CPU...
Why 68000?

Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 9:33 pm
by 93143
Sorry for the ninja. I realized I wanted to be a little more sure of one thing before trying to explain this feature to others, so I deleted my post.
I have heard that the SNES was originally supposed to have a 10 MHz 68000, and that the slower 65816 derivative was used to reduce costs.
Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 10:48 pm
by ccovell
93143 wrote:Sorry for the ninja. I realized I wanted to be a little more sure of one thing before trying to explain this feature to others, so I deleted my post.
I have heard that the SNES was originally supposed to have a 10 MHz 68000, and that the slower 65816 derivative was used to reduce costs.
That might have been true perhaps in 1986 or 1987 (early days), but sounds like hearsay, unless you have a link. The Nikkei newspaper reported it as having a 65816 as early as January 1988. (link:
http://www.chrismcovell.com/secret/SFC_1989Q3.html )
Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 11:27 pm
by Sik
If the way the hardware seems to be arranged is anything to go by, it probably was always a 65816. If anything, it may have started with a 6502 instead (I wouldn't be surprised if the early Superfamicom designs were just a Famicom with extra stuff on top of it).
Re: Some question about Mode 7
Posted: Mon Apr 11, 2016 11:30 pm
by 93143
ccovell wrote:That might have been true perhaps in 1986 or 1987 (early days), but sounds like hearsay, unless you have a link.
I could link a couple of forum posts, but that doesn't really prove much. That's why I said "I have heard" rather than just asserting it as fact.
The effect on the system architecture would have been huge. If this really was true, it must have been changed very early.
The original context (now deleted, as noted above) was a list of might-have-beens from SNES development. It was purely a personal choice not to include all manner of wishful thinking and restrict myself to what Nintendo is said to have actually considered; accordingly I do not feel too bothered about defending the reference.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 12:05 am
by AWJ
Kannagi wrote:I managed to get perspective on the Mode 7:
http://pixelretro.hebergratuit.net/NesBox/m7.html
(Though I wonder how the calculation soft , for the moment I precalculation in C language).
But I would use a second background.
When I active ext BG ,I have the impression that the BG2 is identical to BG1.
He uses every 2 BG1H0FS/BG1V0FS.
On Secret of Mana, it uses
BG1SC $ 51
BG2SC $ 59
BG12NBA $ 44
and $4000, data on 4bpp
Of course I did the same , but with no result on screen.
I forgot something ?
Most "Mode 7" scenes in games actually only use Mode 7 on part of the screen--they use a raster effect to change modes at a certain scanline. Here's how you'd set up a typical driving/flying scene like F-Zero, Super Mario Kart, Secret of Mana, FF6, etc.:
Set up an IRQ to trigger on the scanline where the horizon is.
In the NMI (VBlank) handler, set BGMODE to 1 and set the scroll registers up for the skyline.
In the IRQ handler, set BGMODE to 7 and load the M7 matrix registers.
You can also use HDMA, but it's a bit wasteful of DMA channels--you need one channel for BGMODE and several more for the M7 registers, and you're only writing to those registers once per frame.
Remember that Mode 7 completely ignores BG*SC and BG**NBA--the interleaved tilemap and pattern data always start at the beginning of VRAM.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 12:24 am
by 93143
AWJ wrote:You can also use HDMA, but it's a bit wasteful of DMA channels--you need one channel for BGMODE and several more for the M7 registers, and you're only writing to those registers once per frame.
BGMODE yes, but the Mode 7 registers need to be written every line if you're doing perspective.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 2:00 am
by Kannagi
@Espozo ok , this confirms me that finally I didn't need "ext BG"

AWJ thank you, I understand better now.
@93143 You are right , but the operating principle should be close to what was said by AWJ and then I finally understand why he uses IRQ
I'll try to make this change, this requires some change in my code to make it work.
I find it a pity that the SNES not think more is the perspective of the mode 7, the calculations being heavy enough without external chip it is very difficult to use this one.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 5:41 am
by tepples
EXTBG is useful primarily if there's something below the plane. This is how the supports in Ghost House tracks in Super Mario Kart appear below (behind) the track.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 6:45 am
by Kannagi
Ok I see , thank you.
I finally succeeded, I think I will put the source code on github,make the mode 7 has been long and difficult for me I think it will be also for other.
In the IRQ handler, set BGMODE to 7 and load the M7 matrix registers.
I did not set the M7 matrix registers in IRQ.
init code :
Code: Select all
SNES_NMITIMEN $B1; Enable NMI,IRQ H/V , enable joypad
cli
ldy #$80
sty HTIMEL
ldy #$60
sty VTIMEL
IRQ:
Code: Select all
IRQ:
Timer:
phb
pha
phx
phy
lda $4211
SNES_BGMODE $07
SNES_TM $11
ply
plx
pla
plb
rti
VBlank:
Code: Select all
;code Vblank
;end vblank:
SNES_BGMODE $31 ; BG1 ,16x16
SNES_TM $12 ; BG2 & obj enable
Screen:
Screen SNES PAL:
http://img15.hostingpics.net/pics/93398 ... 152418.jpg
I can update a demo now

Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 6:46 am
by Stef
It's just about providing low / high priority to the mode 7 plan right ? I wonder why they called it EXTBG, that confused me as well the first time i saw it.
Kannagi> I guess you use the HDMA to set the M7 matrix regs ? That is the primary purpose for the HDMA actually.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 6:51 am
by Kannagi
Stef wrote:Kannagi> I guess you use the HDMA to set the M7 matrix regs ? That is the primary purpose for the HDMA actually.
yes on each line.
Re: Some question about Mode 7
Posted: Tue Apr 12, 2016 7:32 am
by AWJ
Stef wrote:It's just about providing low / high priority to the mode 7 plan right ? I wonder why they called it EXTBG, that confused me as well the first time i saw it.
EXTBG is actually "external BG"--it was apparently meant to allow an external video signal (say, from an expansion chip on a cartridge) to be treated as an additional BG layer and mixed with the S-PPU's sprites and BGs. The NES PPU has EXT pins as well, but they aren't connected to anything on a NES. On the SNES, the EXT pins are short-circuited with the VRAM data bus, which in Mode 7 has the happy effect of duplicating the BG.
An interesting consequence of how EXTBG is implemented is how it interacts with mosaic. Vertical mosaic is handled in the BG generator on PPU1 and actually affects what data is fetched from VRAM, but horizontal mosaic is implemented in the layer mixer on PPU2. So when EXTBG is used, BG1's mosaic setting affects both layers' vertical mosaic, but BG1 and BG2 can have different horizontal mosaic settings.