[NDS] Bilou School Rush

Discussion of development of software for any "obsolete" computer or video game system. See the WSdev wiki and ObscureDev wiki for more information on certain platforms.
Shonumi
Posts: 342
Joined: Sun Jan 26, 2014 9:31 am

Re: [NDS] Bilou School Rush

Post by Shonumi »

PypeBros wrote:One thing I had in mind to ease the porting towards other platforms was to merge the C++ logic of the code with an NDS emulator. We'd still have emulated sound & graphics, but the CPU wouldn't need emulation because there would be native code instead. Is that something GBE+ would make possible / easier than hacking desmume source code ?
Realistically speaking, GBE+ is in no shape to be used regularly as a replacement for Desmume. I can get School Rush to run, but there are a bunch of issues with GBE+ (not 60FPS, no sound, slow to load levels due to bad timings, etc). It "works" meaning it doesn't cause the host PC to explode :D

Repackaging Desmume or MelonDS would be much more feasible as GBE+ is quite a bit behind both. So far, the only professional software that actually boots and runs in GBE+ are some demos. I've had no success just yet with commercial carts (although with any luck, maybe Super Princess Peach will run soon).

Anyway, I don't want to dwell on my project in a thread about your project. I have an NDS flashcart, so when I get the chance, I want to play this on my DS Lite. Maybe I'll get the chance this weekend. It's great that you have other example games on SoureForge too!
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: [NDS] Bilou School Rush

Post by 93143 »

PypeBros wrote:The tiles count could work too, although only 512 tiles could mean some "advanced" backgrounds (in the secret level) would have to be dropped (that's ok).
I think what he's done is he's attempted to come up with a notional resource allocation plan for the limited VRAM, without knowing about the secret level. I'm pretty sure there are no BG layers that are restricted to 512 tiles in hardware.

A single BG on the GBA can use a pool of 1024 tiles (16-bit tilemap with x/y flip bits and 4-bit subpalette), unless it's an affine layer in which case it can only use 256 tiles (8-bit tilemap, no flipping or subpalettes). Basically the same as the SNES, except the non-affine BGs on SNES only use 3 subpalette bits; the spare bit is used for tile priority.
PypeBros wrote:After checks, the thing that blocked me was that Mega-drive (which had my focus in the previous "demake" study) has only 4 palettes for both sprites and backgrounds and that was ... wel... not so appealing.
The SNES has 16 palettes in total (when using 4bpp BG layers): 8 for backgrounds, and 8 more for sprites. Obviously you can freely rewrite the palettes between frames, and even between scanlines (up to 8 colour changes per line without special tricks), though it doesn't look like you'd need the latter.

The SNES also allows 1024 tiles for each BG layer, although sprites can only use 16 KB (512 tiles) at any one time. These tile pools can overlap. Their starting addresses in VRAM can be freely changed between scanlines (doing this with sprite graphics requires an undocumented trick, but it seems to work fine), but there's only 64 KB of VRAM total, so this may be of limited utility. However, you can of course stream tiles during VBlank. With the standard screen height (no letterboxing) in NTSC, you can stream about 130-190 4bpp tiles per frame depending on what else has to get done during VBlank. PAL is substantially easier as the frame is longer; even with a 239-line active area you can stream perhaps 320-370 4bpp tiles per frame on a PAL SNES.

You also get two multipurpose window masks, which can be used to draw simple shapes onscreen.

You only get 34 8-pixel slivers worth of sprite overdraw per scanline, but you do get three BG layers in the most common BG mode (Mode 1), with one of the layers being 2bpp (seems ideal for the ink).

One notable difference between the SNES and the DS is that the pixels aren't square. The standard 256x224 NTSC SNES screen has about the same aspect ratio as the 256x192 screen on the DS, and a PAL SNES can't render enough scanlines to make the display 4:3 without pillarboxing. You could trim the screen on the SNES to get 256x192, with the added bonus that you'd be able to stream about twice as much graphics data during VBlank on NTSC (~300-360 tiles; even more for PAL of course), but the image would look horizontally stretched unless it was being played on an emulator with square pixels. ...more precisely, if you didn't want the graphics to look stretched, you'd have to rescale them, at which point you'd probably want to use a different screen size anyway...

...

Again, though, you or whoever was porting it would have to be willing to rewrite at least part of the game in assembly. I'm unaware of any C++ solution on the 65C816, and C is not performant on the SNES, partly because the compiler situation is not good and partly because the CPU simply isn't well suited to C. The Mega Drive has none of these problems.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

calima wrote:You're just a bit too late, krikzz's black friday sale was 1.5 weeks ago.
unsure how krikzz could have helped me to that regards.
Image - may the source be with you.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: [NDS] Bilou School Rush

Post by Banshaku »

PypeBros wrote:
calima wrote:You're just a bit too late, krikzz's black friday sale was 1.5 weeks ago.
unsure how krikzz could have helped me to that regards.
I think his comment was related to my interest to get someday a flashcart, which seems was on sale for black friday. Since I'm in Japan, I'm not following those kind of sales because it's US specific (well they are starting to do black friday sales in Japan as a new marketing trick these days but it doesn't make much sense ^^;;;).
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: [NDS] Bilou School Rush

Post by tepples »

But then Japan is next door to China, where they have a huge Veteran's Day sale roughly two weeks before Black Friday.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: [NDS] Bilou School Rush

Post by Banshaku »

@tepples

Japan don't follow Chinese holidays, that is for sure. As for the subject at end, Black Friday in Japan is something fairly new, maybe a few years ago, and is mostly a marketing stunt for creating sales. This is similar to Valentine day/white day in Japan, where they added an extra day (white day) on march 14, where you gave back something, thus extra sales. Most "imported" holidays/event is Japan is for commercial purpose only.

Now we are completely off-topic (nesdev! :lol:) but is such topic is interesting, it can be discusses in another one.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: [NDS] Bilou School Rush

Post by 93143 »

Canada pretty much fully "celebrates" Black Friday and Cyber Monday and all the rest of it, at the same time the USA does. Even though our Thanksgiving is in early October...
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: [NDS] Bilou School Rush

Post by Bregalad »

Banshaku wrote:As for the subject at end, Black Friday in Japan is something fairly new, maybe a few years ago, and is mostly a marketing stunt for creating sales. This is similar to Valentine day/white day in Japan, where they added an extra day (white day) on march 14, where you gave back something, thus extra sales. Most "imported" holidays/event is Japan is for commercial purpose only.

Now we are completely off-topic (nesdev! :lol:) but is such topic is interesting, it can be discusses in another one.
Oh my god, I don't know for Japan but here in Switzerland they never stop to force importing shitty american commerical "days". Back when I was 10 (that is, 20 years ago) they suddenly introduced Hallowen, a feast nobody had never heard about before that point and that in only 2 years became incredibly popular - and they manage to sell all kind of shit for this occasion, with medias talking all about it suddently, as if it had always been there. Now 10 years ago they introduced Valentine's day, with always the same purpose (selling stuff); and last year Black Friday was introduced for the first time - once again nobody had no idea this existed 2 years ago, but this year all media, and stuff was only talking about "black friday", as if it had always existed since decades. And guess what ? They just sell shit that would never sell, for a reduced price, and people belives they make a good deal - when in fact the real good deal would have been to never produce the said shit in the 1st place. Not to even mention they didn't translate the expression "black friday", just leave it in English to show how cool and american this day is.

Not to mention old feast days, such as Christmas or Easter, are turned into commercial feasts and have nothing to do with the christian celebrations they still were only 20 years ago. Pentcost day is now turned into a long week-end where people have to buy cheap easyjet tickets and spend their money to visit the world.

Holy shit we're really in a decadent society. God knowns what's coming next. I bet in a few years we'll get some more shit from america such as thanksgiving or whatnot - because those people can't stand that other countries don't do everything they do. For a while I though the election of Donald Trump would made people stop to want to imit America in all circumstances, and while for some people this worked, there's so much innertia that it doesn't change mentalities as quick as Black Friday was introduced.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

Bregalad wrote:
Banshaku wrote:, there's so much innertia that it doesn't change mentalities as quick as Black Friday was introduced.
Pretty much the same story here (a bit more in the North of Europe). It is completely ridiculous and somehow pushed by the large online shops. Someone managed to convince a few big players in the non-electronic business that they **need** to offer deals on that day too, but of course noone has a day off on that day because there is no reason thanksgiving would happen out of the US. So they extend it to "black week-end", which is even more ridiculous since this is the way we used to call worst possible time of summer when it comes to traffic jams. I hope I'm not the only one to have snobbed that and they will realize they wasted their money, but I doubt that will be the case. Selling Sales to most people is about as is as to sell sweets to kids. °_°
Image - may the source be with you.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

93143 wrote:
PypeBros wrote: One notable difference between the SNES and the DS is that the pixels aren't square. The standard 256x224 NTSC SNES screen has about the same aspect ratio as the 256x192 screen on the DS, and a PAL SNES can't render enough scanlines to make the display 4:3 without pillarboxing. You could trim the screen on the SNES to get 256x192, with the added bonus that you'd be able to stream about twice as much graphics data during VBlank on NTSC (~300-360 tiles; even more for PAL of course), but the image would look horizontally stretched unless it was being played on an emulator with square pixels. ...more precisely, if you didn't want the graphics to look stretched, you'd have to rescale them, at which point you'd probably want to use a different screen size anyway...
Thank you for all that information. The non-square pixels is likely the most annoying part. Likely much of the core engine would need a replacement. Here I mostly load everything in VRAM at level start and then leave it where it is, happily taking advantage of the quite generous 512KB of VRAM the NDS offers. Only a few tiles get replaced periodically to animate e.g. ink and keep the tileset compact enough.

Again, though, you or whoever was porting it would have to be willing to rewrite at least part of the game in assembly. I'm unaware of any C++ solution on the 65C816, and C is not performant on the SNES, partly because the compiler situation is not good and partly because the CPU simply isn't well suited to C. The Mega Drive has none of these problems.
That's more or less what I was afraid of. Well, I have significant knowledge of assembly, but mostly for 80x86 CPUs and a little bit for the 6502 (which might get handy for the 65C816). The idea would then to convert my RISC-like animation instructions (currently interpreted by the ARM CPU on the NDS) directly into machine code, and same for the behaviour transitions where the list of iGobController would essentially turn into a set of CALL instructions.

An interesting problem, but I don't know if I'll end up with a running game or just excessively techy tools if I follow that path.
Image - may the source be with you.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: [NDS] Bilou School Rush

Post by 93143 »

I mean, one could try it in C and see how it goes. Given how common slowdown was even among games programmed in assembly, and given how suboptimal C code tends to be on 65xx processors, I wouldn't expect a flawless result. But I could be wrong...

A working C version could be profiled, and the slow parts rewritten in assembly. To a 6502 programmer, 65C816 is a big improvement; the only real disadvantage is that you have to keep track of the sizes of the accumulator and the index registers (cc65 avoids this issue by doing everything in 8-bit mode).
PypeBros wrote:An interesting problem, but I don't know if I'll end up with a running game or just excessively techy tools if I follow that path.
That seems to be a risk with any kind of SNES development. It's friendlier than NES programming, but it's more complicated because you can do so much more with the console, and it's not nearly as friendly as a modern C++ framework. It's not something you can just turn to and dash off a quick side project in a few weeks; you have to be serious about getting something done.
PypeBros wrote:The non-square pixels is likely the most annoying part.
Perhaps. This one's a bit unusual, because with Mega Drive or arcade ports, they're already 224-line games and ideally would only need horizontal rescaling, but this is a 256-wide game that only needs to be scaled vertically. This means that it may be easier to rejigger the level maps, because horizontal widths and distances don't change.

Or you could just leave it the way it is:

Original:
bilou192_DS.png
NTSC:
bilou192_NTSC.png
PAL:
bilou192_PAL.png
(Please excuse the colour/gamma; the processing was kinda ad hoc...)

...

Regarding music, the SNES (as you may have noted) is limited to 8 channels including sound effects. They're all sample channels (or optionally noise), so you can use chord samples to boost the apparent polyphony. But there's only 64 KB of RAM for BRR samples, audio engine code, and the echo buffer, so if you're using a lot of sophisticated instruments you're going to bump your head. This memory limit shaped the sound of the SNES at least as much as did the capabilities of the DSP, and it didn't help that most developers were in too much of a hurry to spend much effort exploring the limits of optimization.

Real-time sample streaming is possible, as proved by Tales of Phantasia and Star Ocean, and there are a couple of homebrew audio engines that support it. But for various reasons they're more bandwidth-limited than I personally believe they could be (though I'm too busy to prove it), and last I checked you could only stream muffled mono. Good enough for sample replacement during playback and for some types of sound effects, but without more development you aren't going to be streaming 32 kHz stereo, not that a SNES cartridge could hold much music at that bitrate anyway...

The MSU1 is a possible way around this (up to 4 GB of Red Book audio with loops), but it loses authenticity somewhat as it is not period hardware, and not every emulator supports it. The Nintendo Play Station could potentially be used for CD audio, but it was never released and there's only one known extant hardware unit, with the result that it is not especially well understood or widely emulated. The Voicer-Kun is another period-accurate possibility, but in addition to the extra hardware (which was only released in Japan), it requires the use of a CD player with infrared remote control functionality, which may be overkill when you could just put up with somewhat cut-down music instead...
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

93143 wrote: (Please excuse the colour/gamma; the processing was kinda ad hoc...)
Very interesting. Thank you for taking the time to do that. I'd say the vertical squashing is tolerable, except maybe for the main character. Hopefully, it has 2 to 3 transparent lines at the bottom of its 16x16 frame so far, which I could use to slightly expand it and compensate the squash.
Regarding music, the SNES (as you may have noted) is limited to 8 channels including sound effects. They're all sample channels (or optionally noise), so you can use chord samples to boost the apparent polyphony. But there's only 64 KB of RAM for BRR samples, audio engine code, and the echo buffer, so if you're using a lot of sophisticated instruments you're going to bump your head. This memory limit shaped the sound of the SNES at least as much as did the capabilities of the DSP, and it didn't help that most developers were in too much of a hurry to spend much effort exploring the limits of optimization.
The soundtrack has been composed by my brother, and hopefully, he now also has experience with C64 (wolfling, powerglove) and NES (wolfling) composing. He's been doing lots of covers to chiptune, so I feel like he could be able to write a convincing score within the SNES limitations, possibly much quicker than the time it would take me to adapt the code to run over e.g. Alekmaul's library.
Image - may the source be with you.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

Interestingly, the extra 32 lines of the SNES could also be used to display a suited HUD, since I'm losing the bottom screen where we had the HUD so far.
Image - may the source be with you.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

tepples wrote:Do you foresee any significant issues that would block a port to Game Boy Advance?
Do you know whether something special would be needed to run a GBA homebrew through a "Supercard SD" linker ? I remember I had to patch commercial rom back then, but I'm afraid I lost the .exe that was doing that together with my Win98SE back in 2007.
Image - may the source be with you.
User avatar
PypeBros
Posts: 34
Joined: Sat Nov 10, 2018 7:35 am

Re: [NDS] Bilou School Rush

Post by PypeBros »

color12.png
By the way, I tried some preliminary fitting on 16-color palettes. With 5 or 6 of them, I think I cover most characters. They are typically 8 to 12 colors so I can even split the variants of e.g. feet among other palettes.
Image - may the source be with you.
Post Reply