Creating RAM Addresses?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
SMB2J-2Q
Posts: 154
Joined: Thu Jul 27, 2017 5:13 pm

Creating RAM Addresses?

Post by SMB2J-2Q »

May I please ask, exactly, how are RAM address defines created?

For example: these in Super Mario Bros.:
074E = AreaType (00=water; 01=ground; 02=below ground; and 03=castle)
075F = WorldNumber (00=World 1; 01=World 2; 02=World 3; 03=World 4; and so on)
0760 = AreaNumber (00=area 1; 01=area 2; 02=area 3; and 03=area 4)
0754 = PlayerSize
0756 = PlayerStatus (00=small; 01=Super; and 02=Fiery)

In some cases, instead of just making a separate command within the ROM, one may wish to do so via a RAM define instead.

~Ben
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Creating RAM Addresses?

Post by Oziphantom »

depends on the Assembler.

AreaType .EQU 074E
WorldNumber .EQU 075F
or in the old days you would chain them so you have

AreaType .EQU 074e
WorldNumber .EQU AreaType +1
AreaNumber .EQU WorldNumber +1

etc

modern assemblers you can .db or .byte and then give it a ?. In 64tass for example you could just do
* = $074e
AreaType .byte ?
WorldNumber .byte ?
AreaNumber .byte ?
etc
SMB2J-2Q
Posts: 154
Joined: Thu Jul 27, 2017 5:13 pm

Re: Creating RAM Addresses?

Post by SMB2J-2Q »

Oziphantom wrote: Fri Feb 03, 2023 6:44 am depends on the Assembler.

AreaType .EQU 074E
WorldNumber .EQU 075F
or in the old days you would chain them so you have

AreaType .EQU 074e
WorldNumber .EQU AreaType +1
AreaNumber .EQU WorldNumber +1

etc

modern assemblers you can .db or .byte and then give it a ?. In 64tass for example you could just do
* = $074e
AreaType .byte ?
WorldNumber .byte ?
AreaNumber .byte ?
etc
For example, in Super Mario All-Stars AreaType was defined by two bytes, $5C and $BA, depending on where it's used.

~Ben
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Creating RAM Addresses?

Post by Oziphantom »

ah yes 5f not 4f

AreaType .EQU 074e
WorldNumber .EQU AreaType +17
AreaNumber .EQU WorldNumber +1

etc

modern assemblers you can .db or .byte and then give it a ?. In 64tass for example you could just do
* = $074e
AreaType .fill $16
WorldNumber .byte ?
AreaNumber .byte ?
etc
Post Reply