News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Super Mario Bros. (NES) - "Pages"?  (Read 1722 times)

MongoLloyd

  • Newbie
  • *
  • Posts: 2
    • View Profile
Super Mario Bros. (NES) - "Pages"?
« on: June 06, 2019, 07:10:28 am »
Hey! I'm pretty new to 6502 assembly and I've been trying to study the disassembly of Super Mario Bros. and I came upon the word pages and was wondering what they are referring to. What does pages mean in the context of the code?

Here's some examples of what I mean:

Near the beginning of RenderSceneryTerrain
Code: [Select]
lda CurrentPageLoc        ;otherwise check for every third page
At the start of Entrance_GameTimerSetup
Code: [Select]
lda ScreenLeft_PageLoc    ;set current page for area objects
sta Player_PageLoc        ;as page location for player

The code I'm using: https://www.romhacking.net/documents/344/

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Super Mario Bros. (NES) - "Pages"?
« Reply #1 on: June 06, 2019, 10:11:29 am »
This is a little confusing because he does not appear to be using "page" to mean a memory page.  So this is not really a 6502 question as much as it is a question about this specific game.

From what I can tell having glanced at the code, I would bet that the level maps are broken into sections (which he's calling pages), and when the player transitions to a new page, new stuff on the map gets loaded.

I deduced this specifically from some code starting at line 5997:

Code: [Select]
CSetFDir:    lda Player_X_Position
             clc                      ;add or subtract from player's horizontal position
             adc ClimbAdderLow,x      ;using value here as adder and X as offset
             sta Player_X_Position
             lda Player_PageLoc       ;add or subtract carry or borrow using value here
             adc ClimbAdderHigh,x     ;from the player's page location
             sta Player_PageLoc

Player X position seems to be tied directly to player Page location.  As you move further right, you move onto a different page.

This also suggests that pages are 256 ?pixels? wide... so basically one "screen" worth of map?

Keep in mind this is all kind of a guess, as I looked at this for less than a minute.  But I can say for certain that "page" in this context is referring to something specific to this game and not to anything related to 6502 or NES architecture.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7060
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Super Mario Bros. (NES) - "Pages"?
« Reply #2 on: June 06, 2019, 07:58:20 pm »
I suspect a "page" might be a screen width.

I think Super Mario World ROM hacking uses the same term (or was it "screen"), as I think some things (such as door/pipe exit destinations) are coded to a limit of one per page.
"My watch says 30 chickens" Google, 2018

MongoLloyd

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Super Mario Bros. (NES) - "Pages"?
« Reply #3 on: June 07, 2019, 07:50:42 am »
Thanks for the responses. As I studied the code some more it was the conclusion I started to suspect as well.