SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

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

SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by SMB2J-2Q »

May I ask how you guys would fix up Worlds 5-3 and 7-3 so that they use winter graphics, since the other outside stages are set in winter, too?

Since these two stages I mention are repeats of Worlds 1-3 and 2-3, respectively, what I would like to do is to do this in a way so as to have their regular plain background attributes be overwritten just for this occasion, without having to duplicate the area data for them (that is, to make an L_GroundArea23 and L_GroundArea24 that would in the end be pretty hefty for this ROM).

We would be telling the game these instructions for the temporary modification of these two levels:
a. Are we on World 5 or later?
b. If less than 5, skip.
c. If we're on level 1 or 2, skip.

Thank you,



Ben
User avatar
Dwedit
Posts: 4687
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by Dwedit »

Haven't looked at the source recently, but it might be possible to make another entry that points to all the old stuff, just with different properties?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
SMB2J-2Q
Posts: 26
Joined: Thu Jul 27, 2017 5:13 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by SMB2J-2Q »

Dwedit wrote: Tue Sep 20, 2022 9:10 pm Haven't looked at the source recently, but it might be possible to make another entry that points to all the old stuff, just with different properties?
Here's doppelganger's SMB1 disassembly page:
https://gist.github.com/1wErt3r/4048722

What you suggest would be to make a new L_GroundArea23 ($36) and L_GroundArea24 ($37), along with the respective enemy data for each, which was also my first possibility as to doing this, but I would prefer not to do that yet for the sake of available ROM space and hence why I wish to do this alternative method.

Also, we may tell it to point to the specific address containing the background type we want to override, since the background type is four bytes past both starting area addresses. In this case, we would add an instruction for L_GroundArea7+4 (for 5-3) and L_GroundArea8+4 (7-3), meaning to have it look four bytes past the respective starting addresses.

World 1-3 & 5-3 start data:

Code: Select all

;level 1-3/5-3
L_GroundArea7:
    .db $90, $11 (the header)
    .db $0f, $26 (starting castle)
    .db $fe, $10 (plain background, daytime)
[...]
World 2-3 & 7-3 start data:

Code: Select all

;level 2-3/7-3
L_GroundArea8:
    .db $90, $11 (the header)
    .db $0f, $26 (starting castle)
    .db $6e, $10 (plain background, daytime)
[...]
SMB2J's World 3-3 start data (World B-3 in All Night Nippon SMB is similar):

Code: Select all

;level 3-3
L_GroundArea7:
    .db $55, $10 (the header)
    .db $0b, $1f
    .db $0f, $26 (starting castle)
    .db $d6, $12 (winter background, daytime)
[...]
~Ben
frantik
Posts: 373
Joined: Tue Mar 03, 2009 3:56 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by frantik »

easiest way would be to add a check in the level load routine (GetAreaDataAddrs) and modify the header when you're on 5-3 and 7-3. Look where BackgroundColorCtrl is set

The data 4 bytes after the header that set the background in the level do not set the background color, they just enable the clouds
SMB2J-2Q
Posts: 26
Joined: Thu Jul 27, 2017 5:13 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by SMB2J-2Q »

frantik wrote: Fri Sep 23, 2022 1:53 am easiest way would be to add a check in the level load routine (GetAreaDataAddrs) and modify the header when you're on 5-3 and 7-3. Look where BackgroundColorCtrl is set

The data 4 bytes after the header that set the background in the level do not set the background color, they just enable the clouds
@frantik

Code: Select all

GetAreaDataAddrs:
            lda AreaPointer          ;use 2 MSB for Y
            jsr GetAreaType
            tay
            lda AreaPointer          ;mask out all but 5 LSB
            and #%00011111
            sta AreaAddrsLOffset     ;save as low offset
            lda EnemyAddrHOffsets,y  ;load base value with 2 altered MSB,
            clc                      ;then add base value to 5 LSB, result
            adc AreaAddrsLOffset     ;becomes offset for level data
            tay
            lda EnemyDataAddrLow,y   ;use offset to load pointer
            sta EnemyDataLow
            lda EnemyDataAddrHigh,y
            sta EnemyDataHigh
            ldy AreaType             ;use area type as offset
            lda AreaDataHOffsets,y   ;do the same thing but with different base value
            clc
            adc AreaAddrsLOffset        
            tay
            lda AreaDataAddrLow,y    ;use this offset to load another pointer
            sta AreaDataLow
            lda AreaDataAddrHigh,y
            sta AreaDataHigh
            ldy #$00                 ;load first byte of header
            lda (AreaData),y     
            pha                      ;save it to the stack for now
            and #%00000111           ;save 3 LSB for foreground scenery or bg color control
            cmp #$04
            bcc StoreFore
            sta BackgroundColorCtrl  ;if 4 or greater, save value here as bg color control
            lda #$00
I wonder if, per your suggestion, I might be able to do a "beq" for World5Or7:

Code: Select all

World5Or7:
    lda WorldNumber
    cmp #World5  ;are we on World 5-3?
    bcc StoreFore
    cmp #Level3  ;if 1 or 2, skip check
    lda WorldNumber
    cmp #World7  ;are we on World 7-3?
    bcc StoreFore
    cmp #Level3  ;if 1 or 2, skip check
~Ben
frantik
Posts: 373
Joined: Tue Mar 03, 2009 3:56 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by frantik »

i think this would work

Code: Select all

            lda (AreaData),y     
            pha                      ;save it to the stack for now
            and #%00000111           ;save 3 LSB for foreground scenery or bg color control

;---            
            ldx LevelNumber          ;load Level number into x to not disturb A
            cpx #$02                 ;#$02 is World x-3
            bne StoreBGColor:        ;if not World x-3, write existing color code
            ldx WorldNumber          ;load world number
            cpx #World5              
            beq UpdateBGColor:       ;if in World 5, update color code
            cpx #World7               
            bne StoreBGColor:        ;if not in world 7 skip to old code
UpdateBGColor:                       
            lda #$05                 ;#$05 for snow, 06 for night and snow, 07 for castle colors
StoreBGColor:

;---
            cmp #$04
            bcc StoreFore
            sta BackgroundColorCtrl  ;if 4 or greater, save value here as bg color control
            lda #$00
SMB2J-2Q
Posts: 26
Joined: Thu Jul 27, 2017 5:13 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by SMB2J-2Q »

frantik wrote: Fri Sep 23, 2022 7:15 am i think this would work

Code: Select all

            lda (AreaData),y     
            pha                      ;save it to the stack for now
            and #%00000111           ;save 3 LSB for foreground scenery or bg color control

;---            
            ldx LevelNumber          ;load Level number into x to not disturb A
            cpx #$02                 ;#$02 is World x-3
            bne StoreBGColor:        ;if not World x-3, write existing color code
            ldx WorldNumber          ;load world number
            cpx #World5              
            beq UpdateBGColor:       ;if in World 5, update color code
            cpx #World7               
            bne StoreBGColor:        ;if not in world 7 skip to old code
UpdateBGColor:                       
            lda #$05                 ;#$05 for snow, 06 for night and snow, 07 for castle colors
StoreBGColor:

;---
            cmp #$04
            bcc StoreFore
            sta BackgroundColorCtrl  ;if 4 or greater, save value here as bg color control
            lda #$00
@frantik,

I tried out your code and it worked perfectly! World 5-3 and 7-3 are finally updated with the snow graphics, while World 1-3 and 2-3 remain untouched.

World 5-3:
Image

World 7-3:
Image

Thank you,



Ben
frantik
Posts: 373
Joined: Tue Mar 03, 2009 3:56 pm

Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?

Post by frantik »

right on, glad it's working! :mrgreen:
Post Reply