Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode 5, 6 examples ? #14

Closed
gameblabla opened this issue Oct 29, 2018 · 13 comments
Closed

Mode 5, 6 examples ? #14

gameblabla opened this issue Oct 29, 2018 · 13 comments

Comments

@gameblabla
Copy link

Hello,
Mode 1, 2, 3 and 7 examples work great. So it would be nice to have an example for Mode 5 and 6 : P
I've been told that triggering Mode 5 or Mode 6 "automatically" enables high resolution mode. (512x448)
I took the Mode 1 example and simply changed from setMode(BG_MODE1,0); to setMode(BG_MODE5,0); but it doesn't seem like it actually enables interlaced mode or even 512 width mode. (it pretty much works like Mode 1)
Taking a closer look at setMode, it looks like it enables background 2 even for Mode 6. Is that on purpose ? Pretty sure i'm doing something wrong but i can't find any example even in assembly that uses Mode 5.

@alekmaul
Copy link
Owner

You're right, I need to work on this mode, I had a request to change "Teenage Queen" game resolution to 512x448.
I will try to find information and update the lib with this modes.

@gameblabla
Copy link
Author

gameblabla commented Oct 30, 2018

I asked Optiroc how to trigger Mode5/6 and he told me this

Hires is a bit finicky.. For starters you should usually set the same value to both TM and TS (main/sub screen designation)

Based on his info and your setmode function, i think i somehow managed to make Mode 5 work by manually triggering it with this function.

void setMode5(u8 size) 
{
	_iloc = (BG_MODE5 & 0x03);
	REG_BGMODE = BG_MODE5 | size;
	
	REG_TM = BG1_ENABLE | BG2_ENABLE | OBJ_ENABLE;
	REG_TS = BG1_ENABLE | BG2_ENABLE | OBJ_ENABLE;
	
	_bgCnt = 2;
	
	for(_iloc=0;_iloc<_bgCnt;_iloc++) // No Scroll
	{
		bgSetScroll(_iloc,0,0);
	}
	
	REG_NMITIMEN = INT_VBLENABLE | INT_JOYPAD_ENABLE; 
}

So instead of using setMode(BG_MODE1,0);, i use setMode5(0) instead.
It seems to work, kind of ?
I've heard that this mode uses wider tiles for the 8x8 tiles (16x8 or 8x16, i forgot exactly).
This is how the Mode 1 example looks like when setting the mode to 5.
2018-10-30-210016_1920x1080_scrot

I thought the issue was due to the wider width for tiles so i thought : Might as well give Sprites a shot then, should be easier !
The problem is that sprites also seem to be affected by the same issue...
I tried the SimpleSprite example but using a size of 64x64 just to see if i could notice the increased the resolution. Well it's hard to tell due to the glitch...
snes_64x64_sprite

Both rom images were tested on Higan. A game like RPM Racing which fully uses this mode looks properly on it.
As soon as i go back to Mode 1, both examples look properly.
It seems that this does double the width but does not seem to trigger the interlaced mode, which would then make it double vertically.
And even if the width is doubled, it still looks wrong.
It could also be an issue with gfx2snes too, that tool also doesn't seem to support tile sizes other than 8x8.

@alekmaul
Copy link
Owner

alekmaul commented Oct 31, 2018

thanks a lot for your work ! great explanantion of this mode.
I will check tomorrow (day off in France) th try to implement it.
regarding y resolution, i found that : (https://megacatstudios.com/blogs/press/super-nintendo-graphic-guide)
Mode 5 :

1 BG with 16 colors
1 BG with 4 colors

BG Priority (from front to back)
  Sprite (prio 3)
  BG1 prio 1
  Sprites (prio2)
  BG2 prio1
  Sprite (prio 1)
  BG1 prio 0
  Sprites (prio0)
  BG2 prio0

"Mode 5 is rather different from the previous modes. Instead of using an 8/16 pixel wide tile as normal, it always takes a 16 pixel wide tile (the height may still be 8 or 16) and only uses half the pixels (zero-based, the even pixels for subscreen tiles and the odd pixels for mainscreen tiles). Then it forces pseudo-hires on to render a 512-pixel wide scanline. Also, if Interlace mode is on (see bit 0 of $2133), the screen is 448 or 478 half-lines high instead of 224 or 239. Either the odd half-lines or the even half-lines are drawn each frame, as indicated by bit 7 of $213f. Note that this means you must set $212c and $212d to the same value to get the ‘expected’ display."

Another nice explanantion (put here for saving purpose) : https://www.reddit.com/r/snes/comments/73n06k/technical_explanation_of_snes_background_modes_06/

@alekmaul
Copy link
Owner

alekmaul commented Nov 9, 2018

I worked on mode 5, which is fully functionnal now. I need to find a way to adapt gfx2snes because of the way the information are stored in this mode. Every document, tool usable for this mode are welcome !

@gameblabla
Copy link
Author

gameblabla commented Nov 10, 2018

I've found a very interesting discussion about Mode 5 and interlaced mode
https://forums.nesdev.com/viewtopic.php?f=12&t=14440

As for sprites : they say that width for sprites are doubled and don't take advantage of the increased resolution.
It is different however vertically, but most hires games don't take advantage of that. This could explain the appearance of the sprite in screenshot 2.

I also found another utility (in python) that can convert a map to SNES format using 16x16 tiles here
https://github.com/fo-fo/snes-tile-tool

An example for Mode 7 (using 8x8 tiles)
python snes-tile-tool.py -i map.bmp -b 8 -s 8x8 -m7 -Od -o map

I think it should be easier if you just stick with adding support for 16x16 tiles (which Mode 5 does support) for Mode 5/6.

@ArtemioUrbina
Copy link

Any chance of continuing this? I can help if needed. I browsed to find the code changes made, but I guess they were not committed.

@alekmaul
Copy link
Owner

yeah, nothing commit yet because gfx2snes is not ok for decoding this mode. I added the code to switch to this mode in video.c, I just push it but not yet test it. Use it at your own risk ;) !

@ArtemioUrbina
Copy link

Thank you very much my friend

@Alirio926
Copy link

Is the gfx2snes done to work with Mode5? downloaded the demo but graphics no good conversion.
I'm listting files from a sd, so need hi-res, less cor.

@alekmaul
Copy link
Owner

No, currently it does not support mode 5 &6

@alekmaul
Copy link
Owner

mode 5 is added, mode 6 works like mode 5.

@gameblabla
Copy link
Author

I don't see any mode 5/6 examples in the Backgrounds folder tho ? Maybe you just added mode 5 to setmode ?

@RetroAntho
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants