This is a forum dedicated to Zelda hacking (specifically A Link To The Past).
HomeGalleryFAQROM MapRAM MapMemberlistUsergroupsRegisterLog in

Share | 

 Custom Sprite Tutorial

View previous topic View next topic Go down 
Need anything? PM me and i'll try my best to help!

Posts : 114
Join date : 2011-12-28

PostSubject: Custom Sprite Tutorial   Thu Apr 19, 2012 3:48 pm

This is a tutorial I made for inserting and making custom sprites. Since none of the current level editors for alttp (Hyrule Magic/Black Magic) support these types of sprites inserting them can be a little tricky, but if you follow along carefully it shoudnt be that hard to do.

--- Table of contents ---

What you will need
Using the Sprites
Making Custom Sprites

--- What you will need ---

If you just want to insert them you will need:

To know how to insert xkas patches. If you don't know how read this.

If you want to know how to make sprites you will need the above as well as:

ASM knowledge (if you don't know what LDA and STA do you are not ready yet)

--- Using the Sprites ---

This tutorial explains how to use the sprites after you have inserted the sprites with SpriteC00l.asm. Now how do you use them you say? Well since Hyrule Magic or any other level editor currently doesnt support these sprites we will need to use Overlord.asm. If you havent done so already first open up DungoenINIT.asm if you are using this sprite for a dungeon or OWINIT.asm if you are using it in the OW. Go to the level this is for. Once you are there copy and paste this there:

LDA #$SpriteState
STA $00
LDA #$SpriteSpawn
STA $01
LDA #$Xpos
STA $02
LDA #$Ypos
STA $03
LDA #$XposHigh
STA $04
LDA #$YposHigh
STA $05
LDA #$ExtraSettings
STA $06
LDA #$SpriteType
JSL SpawnSprite

Now before you do anything you need to replace those words I have with your values:

SpriteState = Unless the sprite you have says otherwise just leave it at #$08.

SpriteSpawn = This is the sprite to spawn/sprite number. You replace this with the custom sprite number. We are going to assume the sprite I inserted was the meat sprite I included with SpriteC00l, and that I inserted it as sprite number #$00.

Xpos = This is the sprite's X pos, or horizontal pos. How do we find this? Well if you go to Hryule Magic switch to sprite editing mode, select at sprite then move it to where you want your sprite, then at the bottom you should see this:

Spr XX
X: xx
Y: xx
P: xx

Get the X pos. and open a calculator, then switch to hex (for windows go to view>programmer then swith to hex), and multiply the X pos by 8. Thats the X pos for your sprite.

Ypos = Same as above, but use the Y pos.

XposHigh = If you want to use the left half of the screen use #$08 if you want to use the right half use #$09. Also when multiplying if you get a number like 1xx make the high byte #$09.

YposHigh = If you want to use the top part of the screen use #$20 if you want to use the bottom part use #$21. Also when multiplying if you get a number like 1xx make the high byte #$21.

Note: When in the OW you need to get the pos's differently (It's actually a bit easier). In the menu click "Addr. Calc" then click where you want your sprite. A window will open up telling you the position. The first number is the X pos, and the second one is it's Y pos. You'll see you get a bigger number though. Well the first two numbers (XXYY) are the high byte of your pos, so just stick them in your high byte. Then for the last two numbers you need to round it to it's closest number divisible by 10. So if you get E5, thats E0, if you get 44 thats 40, etc.

ExtraSettings = Unless the file says otherwise leave it at #$01. The meat sprite we are using says:

;; Uses extra settings? Yes
;; #$01 - Small meat
;; #$02 - Big meat
;; #$03 - Small meat (bad)
;; #$04 - Big meat (bad)

So if we set it to #$01 it will be small meat, if we set it to #$02 it will be big meat, etc.

SpriteType = This is the type of custom sprite the sprite is.
#$00 = Normal (Custom) Sprite
#$01 = Extended sprite
#$02 = Generator
#$03 = Title Screen Sprite

This might be a good time to explain what each of these sprites do. Normal custom sprites and extended sprites aren't really anything special, extended sprites are usually used for special effects and projectiles, but thats about it. Generators run every frame in the level and dont normally don't use GFX. Title screen sprites will run during the title screen *only*. Now insert Overlord.asm again enter your level and you should see your sprite!

--- Making Custom Sprites ---

Ok lets first start by making a generator, since they are a bit easier to make. Ther first thing you need to do is create a .txt file in the generators folder. After that rename it to your sprite and replace the .txt extension with .asm. Also there is no spaces in the name. Ok now open the file and type your MAIN label in the sprite (there is no INIT in generators). Like this:


It's better to use periods in front of labels since it will stop inserting errors if someone else uses the same label name as you. Ok now lets make it do something. Lets make the rupee counter always stay at #$00. For this we just need to make $7EF360 #$00. So:

LDA #$00
STA $7EF360

Insert you sprite and it should work! Lets make another one. How about one that gives you a bomb after you get 10 rupees then resets it back to #$00? Try this:

LDA $7EF362
CMP #$0A
BCC .Return

LDA #$01
STA $7EF375

LDA #$00
STA $7EF360

Now what that code does is first check if we have 10 (#$0A in hex) rupees, if we have less than 10 coins (BCC) return, if we have 10 rupees we increase the amount of bombs we have by 1, and then reset the counter. So yeah thats about it for making generators. How about we move on to custom sprites? First put in your INIT and MAIN labels, like so:



Now lets first make a static sprite, meaning one that only has GFX but no function. First it's good to keep your code clean so lets JSR to our GFX routine like this:


JSR .GFXRoutine


Back to top Go down
View user profile
Custom Sprite Tutorial
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
» Need a custom html page?
» Custom Pagination
» Social Engineering Tutorial
» Custom Firefox profile doesn't work
» [ANSWERED] Integrate drivers tutorial

Permissions in this forum:You cannot reply to topics in this forum
Hyrule Hacking :: Resources :: Tutorials-
Jump to: