This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Has anyone released a multidirectional scrolling demo?

Has anyone released a multidirectional scrolling demo?
by on (#102584)
Has anyone released a multidrectional scrolling demo with source code? I've seen the one on the main nesdev website but it doesn't seem to take into account metatiles. I've seen there are a lot of members here who have made a multidirectional scroller but have not released the source code. Any suggestions would be greatly appreciated, thank you.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102589)
Here's my abandoned game.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102599)
Dwedit wrote:
Here's my abandoned game.

Abandoned? Looks like it could be a great game! Do you mind if I try to make a NESICIDE template out of it?
Re: Has anyone released a multidirectional scrolling demo?
by on (#102610)
cpow wrote:
Dwedit wrote:
Here's my abandoned game.

Abandoned? Looks like it could be a great game! Do you mind if I try to make a NESICIDE template out of it?


I'd just be happy with a working Hello World template. viewtopic.php?f=2&t=9306#p99490
But, everyone dreams of making a 4 way scrolling game :) Is asm source actually easy to turn back into C equivalents?
Re: Has anyone released a multidirectional scrolling demo?
by on (#102612)
slobu wrote:
I'd just be happy with a basic Hello World template. But, everyone dreams of making a 4 way scrolling game :) Is asm source actually easy to turn back into C equivalents?


You have to redo everything by hand, C and ASM are totally different languages, C compilation to ASM is possible, but not the other way around!
Re: Has anyone released a multidirectional scrolling demo?
by on (#102614)
Well I made several demos but none of them seems to be fully working !

I had one of them which used 1 screen mirroring, used raw nametable data, and that had vertical update hidden by a dummy status bar, and it also used the Wizard & Warriors way of having a sprite zero hit for the status bar which I think is pretty cool. Unfortunately I lost this one at a computer crash and I had no backup of it.

I had made a second one which is entirely based on 2x2 metatiles (or 16x16 pixels metatiles if you prefer). It works pretty well and I made it's update logic quite robust, but it sometimes glitches if you combine horizontal and vertical scrolling at the same time. I'm not even sure why, but both works perfectly when used separately. It looks quite ugly as I did a random generated maps, with many grass tiles and other random tiles here and here. It's quite funny to see actually.

In an attempt to recreate something like the 1st demo, I made a 3rd one which I was making single-screen mirroring and this time without a status bar. My goal was to show how to cleverly minimize the attributes clashes at the screen's edge. However I made it only horizontal scrolling and never implemented the vertical part. However it's logic is rock-solid, and could definitely be used in a game.

Tell me if you're interested in the 2nd or the 3rd one.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102617)
slobu wrote:
cpow wrote:
Dwedit wrote:
Here's my abandoned game.

Abandoned? Looks like it could be a great game! Do you mind if I try to make a NESICIDE template out of it?


I'd just be happy with a working Hello World template. viewtopic.php?f=2&t=9306#p99490
But, everyone dreams of making a 4 way scrolling game :) Is asm source actually easy to turn back into C equivalents?

slobu: did you miss this post? Hello World template has been working [for me].
Re: Has anyone released a multidirectional scrolling demo?
by on (#102630)
Thanks for the response cpow. Um, The NROM template seems to create an assembly project and not a C project. Also, the Hello World project in C still doesn't work - but compiles just fine from the command line.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102635)
Hamtaro126 wrote:
C compilation to ASM is possible, but not the other way around!

Why is that? You can easily make an assembler tool that would compile ASM to C, no problem at all. But it would be really inefficient, as C would be then compiled back to ASM, with a major overhead.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102636)
slobu wrote:
Thanks for the response cpow. Um, The NROM template seems to create an assembly project and not a C project. Also, the Hello World project in C still doesn't work - but compiles just fine from the command line.

You're correct. My NROM Template is an assembly "Hello World". What C "Hello World" are you referring to? I guess I could add one pretty easily.
Re: Has anyone released a multidirectional scrolling demo?
by on (#102645)
There's a Hello World example here:
http://rpgmaker.net/tutorials/227/
Re: Has anyone released a multidirectional scrolling demo?
by on (#102668)
Hamtaro126 wrote:
slobu wrote:
I'd just be happy with a basic Hello World template. But, everyone dreams of making a 4 way scrolling game :) Is asm source actually easy to turn back into C equivalents?


You have to redo everything by hand, C and ASM are totally different languages, C compilation to ASM is possible, but not the other way around!


Decompilers exist and there is a decompiler for 6502.
http://6502.emulinks.de/blog/

You need Python 3.0 to try it out. Not sure how sound it is. I tried it with the reset vector for SMB:

Code:
ldy #ColdBootOffset          ;load default cold boot pointer
             ldx #$05                     ;this is where we check for a warm boot
WBootCheck:  lda TopScoreDisplay,x        ;check each score digit in the top score
             cmp #10                      ;to see if we have a valid digit
             bcs ColdBoot                 ;if not, give up and proceed with cold boot
             dex                     
             bpl WBootCheck
             lda WarmBootValidation       ;second checkpoint, check to see if
             cmp #$a5                     ;another location has a specific value
             bne ColdBoot   
             ldy #WarmBootOffset          ;if passed both, load warm boot pointer
ColdBoot:    jsr InitializeMemory         ;clear memory using pointer in Y


It outputs this mess which omits the first y load and includes code below the ColdBoot label:

Code:
x = 5;
    do {
        a = arr_07d7[x];
        if (a >= 10) {
label_003b:
            fun_90cc();
            outb(0x4011, a);
            mem_0770 = a;
            mem_07ff = 165;
            mem_07a7 = 165;
            outb(0x4015, 0xf);
            outb(0x2001, 0x6);
            fun_8220();
            fun_8e19();
            mem_0774 = mem_0774 + 1;
            fun_8eed();
            __illegal(0xf); /* XXX: unimplemented illegal opcode */
        }
        x = x - 1;
    } while (x < 128);
    a = mem_07ff;
    goto label_003b;


Here's a decompilation of that loop I made by hand:

Code:
y = #ColdBootOffset
x = 5

do {
   a = TopScoreDisplay[x]
   x = x - 1
   if (a < 10) {      
      if (x >= 128) {
         if (0xA5 == WarmBootValidation) {
            y = #WarmBootOffset
         }
      }
   }
} while (x < 128)

InitializeMemory()


This command line got the above output in case someone wants to look at it. At a glance, it only decompiles snippets of code and stops when it hits an illegal instruction. Not sure if it can decompile a whole binary, but the -help is pretty vague on that score.

python3 decomp.py -o 0 -e 10 smb.nes > smb.c

Edit: His own example of disassembling the smb reset vector actually works; I had some difficulty figuring out the command line outside of the binaries included with the decompiler, so whatever.

Code:
y = 254;
    x = 5;
    do {
        if (arr_07d7[x] >= 10) {
label_802b:
            a = fun_90cc(y);
            outb(0x4011, a);
            mem_0770 = a;
            mem_07ff = 165;
            mem_07a7 = 165;
            outb(0x4015, 0xf);
            outb(0x2001, 0x6);
            fun_8220();
            fun_8e19();
            mem_0774 = mem_0774 + 1;
            fun_8eed(mem_0778 | 128);
            for (;;);
        }
        x = x - 1;
    } while (x < 128);
    if (mem_07ff == 165) {
        y = 214;
    }
    goto label_802b;
Re: Has anyone released a multidirectional scrolling demo?
by on (#102677)
I see slobu is looking for some kind of highlevel language solution to coding for NES.

How about this syntax?

Code:
.proc reset

   sei                     ; pretty standard 6502 type init here
   cld
   lda #%00010000                     ; init PPU control register 1
   sta PPU_CTRL
   ldx #$ff                       ; reset stack pointer
   txs
   
   repeat
   until lda PPU_STATUS == bit7
   
   repeat
   until lda PPU_STATUS == bit7

   ldy #ColdBootOffset         ; load default cold boot pointer
   ldx #$05                                 ; this is where we check for a warm boot
   
   repeat
     lda TopScoreDisplay,x          ; check each score digit in the top score
     if  [ a >= #10 ] goto coldboot    ; to see if we have a valid digit   
   until dex == negative   
   
   if [ WarmBootValidation = #$a5 ]      ; second checkpoint, check to see if  another location has a specific value
      ldy #WarmBootOffset         ;  if passed both, load warm boot pointer
   endif

   coldboot:
   
   jsr InitializeMemory           ; clear memory using pointer in Y
; etc ...
Re: Has anyone released a multidirectional scrolling demo?
by on (#102775)
I've managed to get multidirectional scrolling working without flaws (at least any that I know of). The only problem is it doesn't update and attribute table and only displays 4 colors. It was a nightmare just getting it to work correctly. It might be hard to understand since I don't comment. When it's perfected I'll try to make a turtorial on how to use it. However, matrix is used for setting up the world map, table is used for extracting metatiles and cell extracts tiles from the metatiles. I had problems getting it to work on both directions at once but got past it. I'm just taking a break, after 3 months of attempts and finally getting the scrolling working I'm burned out, but once the attribute table is able to update it will be easy sailing from there. Right now I don't want to look at it, the Y coordinate translations killed me, but in the end it was an easy solution, but not easy to make work.

The metatiles are 4x4 tiles in size or 32pixels by 32pixels.

Here is a youtube vid showing it in action, I was curious if there were any other samples since I could use some tips on optimization. Also I don't see ppl bringing up asking about it too often, I figured a new topic would break that ice.

https://www.youtube.com/watch?v=A7gbYDj ... ature=plcp
Re: Has anyone released a multidirectional scrolling demo?
by on (#102804)
@Movax12: Thanks for that example! Code like that brings me closer to understanding assembly. Kind of like watching a foreign movie and reading the translated dialogue at the same time.

My intention was to see if cpow would be inclined to make a NROM Hello World template for a C project. Beginners are used to robust GUI development environments like NESICIDE. I'd hope in the future one would start with "Hello World" in C and work through the examples up to a multidirection scrolling example.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103665)
What is it you are looking for exactly? Status bar really complicates things and makes clean 4 way scrolling impossible without additional 2k CIRAM on the cart. Otherwise it's pretty straight forward using vertical mirroring.

The biggest thing though is going to be name table / map compression using at least RLE.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103678)
Quote:
Status bar really complicates things and makes clean 4 way scrolling impossible without additional 2k CIRAM on the cart.

Impossible ? Most certainly not.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103679)
It's not 100% clean, but Crystalis does it pretty well with a status bar.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103680)
Yeah, with an IRQ it's doable.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103682)
Here's a little demo of multidirectional scrolling with statusbar without IRQ that I whipped up some time ago (no source): viewtopic.php?p=81267#p81267

Direct download: http://kkfos.aspekt.fi/downloads/status-bar3.zip

Don't mind the attribute glitching in the status bar, that's simply because I couldn't bother to upload the proper attributes.
Re: Has anyone released a multidirectional scrolling demo?
by on (#103686)
You can have 4-way scrolling and a status bar without visible artifacts, but it's not trivial. One solution is to completely redraw your status bar in a safe (mostly off-screen) location every frame, but that will make you spend a lot of precious VRAM time on it. Another option is to maintain 2 (or more) copies of the status bar (that are updated progressively, not all at once), and whenever the gameplay window overwrites the status bar that's in use you switch to another one in a safe location.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104687)
Without 8 pixel attribute alignment errors at the edges ?

I admit I haven't thought too hard about it but Im thinking status bar requires you to use horizontal mirroring (vertical frame buffer). You can scroll indefinitely horizontally with hardware wrapping, use scan line breaks to reset vertical scroll to wrap around the static status bar, but not much you can do about attributes unless you just simply not use the first and last column?

Hardware mask 8 pixels on the left, and right would just require two column updates (bg strip + mask strip) to keep pushing the mask to the right as you scroll and keeping the hardware horizontal wrap.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104688)
The attribute clashes can be reduced to 3 pixels on the left and 4 pixels on the right (never simultaneously). On PAL screen, and several NTSC screens that have more horizontal overscan, it will show as 3 pixels on the left and 2 pixels on the right.
http://forums.nesdev.com/viewtopic.php?f=22&t=9545

In all cases it's much less noticeable than 8+ pixels on the right like the original SMB3 have.

If this is still not enough it's possible to use sprites to mask the right edge.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104689)
exdeath wrote:
Without 8 pixel attribute alignment errors at the edges ?

Yup, just look at thefox's demo. An actual game that uses a similar trick is The Jungle Book.

Bregalad wrote:
If this is still not enough it's possible to use sprites to mask the right edge.

Alfred Chicken and Felix the Cat do this.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104690)
Bregalad wrote:
In all cases it's much less noticeable than 8+ pixels on the right like the original SMB3 have.

I'm not so quick to agree. Even without clipping the eight leftmost columns of pixels, the NTSC NES picture is already shifted a couple pixels to the right because the horizontal sync pulse triggers a bit early. So the right side is more likely to be in or near overscan than the left side.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104691)
I absolutely HATE scrolling-related attribute glitches, and will do anything to avoid them.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104692)
I don't quite like them either, but if you don't want to eat on your 8-sprites per line and 64-sprites per frame limitations, minimizing them like I did in my demo is probably "less worse" than doing it like SMB3 or Kirby's Adventure where there is easily 8+ pixels columns with wrong colours at the edges, which looks ugly.

Also you have to keep in mind that, in PAL territories, all 240 pixels are visible vertically. Which means a lot of NAME table clashes when scrolling vertically, which are in some sense worse than attribute clashes as it's not only the wrong colours, but also the wrong graphics.

Therefore, on a PAL TV, doing it the way I do it in the demo is the way with the least clashes possible (without a status bar). With a status bar, however, I guess the method used by "Jungle Book" wins.

Quote:
So the right side is more likely to be in or near overscan than the left side.

Which is why I choose to put up to 4 wrong pixels to the right and only 3 on the left, as opposed to do it vice-versa.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104693)
Can't look yet, but I assume thefox/jungle book use vertical mirroring to avoid the horizontal attribute clashing. And two scan line triggers; the obvious one for the status bar, and another for vertical scroll seam wrapping.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104694)
exdeath wrote:
And two scan line triggers; the obvious one for the status bar, and another for vertical scroll seam wrapping.

That's not the case... thefox even mentioned his demo doesn't use IRQs, and this makes it really hard to have splits in the middle of the gameplay area. The trick here is to redraw/relocate the status bar as necessary, so that it never overlaps the gameplay area.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104696)
What exdeath mention is perfectly possible, and Krusty's fun house uses this.
The problem is that a MMC3 or upper class scanline counter is required (well technically it could be done with DMC without any mapper, but it would be hard to do).

Relocating the status bar is more complex logic-wise but less complex for splitting. However the BG needs to be either disabled or masked with a dummy blank CHR bank for some scan-lines.
Re: Has anyone released a multidirectional scrolling demo?
by on (#104699)
Bregalad wrote:
What exdeath mention is perfectly possible, and Krusty's fun house uses this.

Yes, Crystalis and Beauty and the Beast do it too, I think.

Quote:
The problem is that a MMC3 or upper class scanline counter is required (well technically it could be done with DMC without any mapper, but it would be hard to do).

This is a big downside IMO. AFAIK, mappers with scanline counters are not easily available to homebrewers.

Quote:
However the BG needs to be either disabled or masked with a dummy blank CHR bank for some scan-lines.

Yes, some scanlines have to be masked off so that the vertical scroll doesn't cause visible glitches.