SMB1 -- 5-3, 7-3 Change to Winter Graphics?
Moderator: Moderators
SMB1 -- 5-3, 7-3 Change to Winter Graphics?
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
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
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
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!
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
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)
[...]
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)
[...]
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)
[...]
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
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
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
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
@frantikfrantik 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
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
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
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
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
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
@frantik,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
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:
World 7-3:
Thank you,
Ben
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
right on, glad it's working!
Re: SMB1 -- 5-3, 7-3 Change to Winter Graphics?
Hi frantik,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
I forgot to add in my original suggestion that World 7-2's pipe intro (room ID $29) should also match up with the winter theme, so we should have a gray pipe here instead of green, and also the pipe you come out of in that part of 1-1 (specifically page 11, or $0b, of room ID $25) that you come to after entering the water area's goal pipe. Hence, may I please ask you what else would I add to the code you had made, to change room IDs $25 and $29 just for this purpose?
UPDATE 10/10/2023 -- I managed to solve this myself!
UPDATE 10/12/2023: Working from the original code you submitted, I can update it like this:
Code: Select all
...
ldx WorldNumber ;check world number
cpx #World5 ;is it world 5?
bcc StoreBGColor ;if not, branch to old code
ldx AreaPointer ;if so, get area pointer
cpx #$25 ;world 7-2 goal area?
beq UpdateBGColor ;if found, branch to change to snow graphics
cpx #$26 ;world 5-3?
beq UpdateBGColor ;if found, do same
cpx #$27 ;world 7-3?
beq UpdateBGColor ;if found, do same
cpx #$29 ;world 7-2 pipe intro?
bne StoreBGColor ;if none of these found, branch to old code
UpdateBGColor:
lda #$05 ;set to snow graphics ($05)
StoreBGColor: (original code continues here)
Screenshots for proof:
World 7-2 pipe intro: World 7-2 goal area: Similarly, if one wanted to alter world 1's attributes to match those in All Night Nippon Super Mario Bros., here's what you'd do:
First, change these data header bytes (level data) to the following:
World 1-1 (L_GroundArea6): from $50 to $54
World 1-3 (L_GroundArea7): from $90 to $94
PipeIntro (L_GroundArea10): from $38 to $3c
and then also add (to preserve the original attributes for world 2 and up)...
Code: Select all
...
ldx WorldNumber ;check world number
beq StoreBGColor ;if on world 1, branch to old code
ldx AreaPointer ;if on world 2 and up, get area pointer
cpx #$25 ;world 2-2, 4-2 and 7-2 goal area?
beq UpdateBGColor ;if found, branch to change to day graphics
cpx #$26 ;world 5-3?
beq UpdateBGColor ;if found, do same
cpx #$29 ;world 2-2, 4-2 and 7-2 pipe intro?
bne StoreBGColor ;if none of these found, branch to old code
UpdateBGColor:
lda #$00 ;set to day graphics ($00)
StoreBGColor: (original code continues here)
~Ben (SMB2J-2Q)