Have More Than One Set of GameObjectTiles in Your Game

baardbi

Well-known member
This will allow you to have several sets of game object tiles in your game. This is useful if you want the player graphics to change on certain screens. However this method will not let you change them on the fly (during gameplay). They need to be loaded on a screen by screen basis. What game object tileset will be loaded is based on what you set up in userScreenByte0. This tutorial will only add one new tileset.

game_000.png game_001.png

Before you begin make sure you have set up user screen bytes:

1. In the GraphicAssets folder of your game copy GameObjectTiles.bmp and paste it in the same folder. Rename the new file to GameObjectTiles1.bmp. What you do next will depend on what you want to achieve. If you for example want the player to get an armor during a cutscene and start the next level with the player object wearing the armor, then you need to make sure that the tilesets are set up identically. If you want the player to have different colors you can just set up the new screen with a different palette.

GameObjectTiles.bmp
tileset1.png

GameObjectTiles1.bmp
tileset2.png

2. Before you test the game you need to export the CHR graphics for GameObjectTiles1.bmp manually. You do this in the Pixel Editor. Go to Pixel Editor (at the top menu) and then Export CHR.
exportChr.png
Save the file here: NESmaker_4_5_x\GameEngineData\Graphics\Sprites
Save the file as CHR_GameObjectTiles1.chr
PS! You need to do this every time you make a change to this file.

3. Go to Project Settings - Project Labels. Find Screen Bytes in the list on the left. Change UserScreenByte00 to GameObject Tileset.

4. While you're still in Project Settings, go to the Script Settings tab at the top. Under Banks you will find Bank15. Select it and click Edit. Modify the Bank15.asm file to include your new CHR file. Just add two new lines like this (add the text in yellow):
GameObjectTiles00:
.incbin "Graphics\Sprites\CHR_GameObjectTiles.chr"

GameObjectTiles01:
.incbin "Graphics\Sprites\CHR_GameObjectTiles1.chr"
Save the file and close it.

5. Go back to Project Settings - Script Settings, select Bank16 and click Edit. Go down to line 417. It should look like this:
GameObjectCHRAddLo:
.db <GameObjectTiles00
GameObjectCHRAddHi:
.db >GameObjectTiles00
Change it to this (add the text in yellow):
GameObjectCHRAddLo:
.db <GameObjectTiles00
.db <GameObjectTiles01
GameObjectCHRAddHi:
.db >GameObjectTiles00
.db >GameObjectTiles01
Save the file and close it. Close Project Settings as well.

6. Go to your Subroutines folder. You can find it here: NESmaker_4_5_x\GameEngineData\Routines\BASE_4_5\Game\Subroutines
Open the file called doLoadScreen.asm and go to line 384. It should like this:
LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, #$00
Change it to this:
LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, userScreenByte0
Save the file and close it.

7. Now you can decide what tileset to use for each screen. By default userScreenByte0 is set to 0, so it will load the default tileset. If you change userScreenByte0 to 1 the screen will load the new tileset instead.
screenDetails.png

That's it.
 

Attachments

  • tileset1.png
    tileset1.png
    27.7 KB · Views: 2
Oh cool! I just did this myself when messing around with engine in my free time... though yours is more optimal I just checked a screenflag and if it's that screen flag I did a check and copied the code over and if the flag is checked it calls the other gameobjecttiles XD
 

baardbi

Well-known member
Oh cool! I just did this myself when messing around with engine in my free time... though yours is more optimal I just checked a screenflag and if it's that screen flag I did a check and copied the code over and if the flag is checked it calls the other gameobjecttiles XD
Nice. I haven't seen any tutorials about this, so I decided to make one that is (hopefully) easy to understand :)
 
Nice. I haven't seen any tutorials about this, so I decided to make one that is (hopefully) easy to understand :)
quick question...is there a way to change the gameobjecttiles WITHOUT re-loading the screen? because it only seems to work reloading the screen for me aka a warptoscreen macro
 

baardbi

Well-known member
quick question...is there a way to change the gameobjecttiles WITHOUT re-loading the screen? because it only seems to work reloading the screen for me aka a warptoscreen macro
The gameObjectTiles are loaded during screen load. So at least using this method it is only possible to do when the screen loads. I haven't experimented with changing graphics during gameplay.
 

dale_coop

Moderator
Staff member
quick question...is there a way to change the gameobjecttiles WITHOUT re-loading the screen? because it only seems to work reloading the screen for me aka a warptoscreen macro

You could, you would just have a small black screen flash, while the gfx are swapped:
Code:
    LDA #$00
    STA soft2001
    JSR doWaitFrame

    LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, userScreenByte0
    
    LDA #%00011110
    STA soft2001

Use any value for the last parameter (#$00 or userScreenByte0)
 

baardbi

Well-known member
You could, you would just have a small black screen flash, while the gfx are swapped:
Code:
    LDA #$00
    STA soft2001
    JSR doWaitFrame

    LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, userScreenByte0
   
    LDA #%00011110
    STA soft2001

Use any value for the last parameter (#$00 or userScreenByte0)
That sounds cool, but wouldn't there be a problem with bank switching if you do this during gameplay? I mean the game object graphics are in bank 15, so I would think there needs to be some bank switching involved..?
 

baardbi

Well-known member
Huh... it didn't work for me...
Well. It's not completely straightforward since the pickup script is in bank $1C. So I made a routine in $1F and call that routine from the pickup script:

doChangeGameObjectTiles:
ReturnBank

LDA #%00000000
STA soft2001
JSR doWaitFrame

LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, userScreenByte0

LDA #%00011110
STA soft2001

SwitchBank #$1C
RTS

JSR doChangeGameObjectTiles
 

baardbi

Well-known member
By the way. It's important that this part is in the static bank ($1F):

doChangeGameObjectTiles:
ReturnBank

LDA #%00000000
STA soft2001
JSR doWaitFrame

LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, userScreenByte0

LDA #%00011110
STA soft2001

SwitchBank #$1C
RTS
 
Top Bottom