This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
asm_stylesheet [2015/10/25 13:10] – [One Event Per Line] black_falcon | asm_stylesheet [2015/10/25 19:57] – [Super Metroid Assembly Style Guide] black_falcon | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== Super Metroid Assembly Style Guide ====== | ====== Super Metroid Assembly Style Guide ====== | ||
- | **A guide that helps you correctly writing and organizing your ASM code to optimize your workflow and keep you motivated! :) | + | **A guide that helps you correctly writing and organizing your ASM code to optimize your workflow and keep you motivated! :)\\ |
Please note that this is __NO ASM TUTORIAL!__. \\ | Please note that this is __NO ASM TUTORIAL!__. \\ | ||
You have to know how ASM code works and how it is stored in the game's ROM in order to make use of this guide. | You have to know how ASM code works and how it is stored in the game's ROM in order to make use of this guide. | ||
Line 23: | Line 23: | ||
- Commentary | - Commentary | ||
- | 3. xkas command structurization **in progress** | + | 3. Organizing Xkas Commands **done** |
4. Tips for Optimizing Your Workflow using N++ Macros **pending** | 4. Tips for Optimizing Your Workflow using N++ Macros **pending** | ||
Line 84: | Line 84: | ||
N++ is one of, if not the most versatile and popular code viewers out there. It supports lots of different programming languages such as batch or C++. | N++ is one of, if not the most versatile and popular code viewers out there. It supports lots of different programming languages such as batch or C++. | ||
If the language you need is not supported, you can simply define it nice and easy using the custom language feature. | If the language you need is not supported, you can simply define it nice and easy using the custom language feature. | ||
- | Lucky for you I already made one for SNES ASM so you don't have to bother. | + | Lucky for you I already made one for SNES ASM so you don't have to bother.\\ |
- | To add the ASM language stylesheet, open up N++ and go to Language > User-defined (at the very bottom) | + | To add the ASM language stylesheet, open up N++ and go to '' |
Alternatively you can simply click the toolbar icon for it (it's a window with a lightning drawn into it) | Alternatively you can simply click the toolbar icon for it (it's a window with a lightning drawn into it) | ||
{{: | {{: | ||
- | In the opened window, click 'import' and select my stylesheet: | + | In the opened window, click '' |
{{: | {{: | ||
Line 103: | Line 103: | ||
====== 2. Basic code structure ====== | ====== 2. Basic code structure ====== | ||
- | ===== One Event Per Line ===== | + | ===== One Event/ |
The following example shows how I used to write code when I just got started: | The following example shows how I used to write code when I just got started: | ||
Line 409: | Line 409: | ||
- | ====== 3. xkas command structurization (WIP) ====== | + | ====== 3. Organizing Xkas Commands |
+ | In the ASM stylesheet, xkas commands are blue, operators are teal (or red in previous versions). | ||
+ | |||
+ | ===== Org and Data Commands ===== | ||
- | In the ASM stylesheet, all the xkas commands are blue by default. | ||
Most commonly used commands are '' | Most commonly used commands are '' | ||
'' | '' | ||
Line 432: | Line 434: | ||
} | } | ||
- | __Xkas fill functions organzation: | + | ===== Label Definitions ===== |
- | org $808000 | + | Defines are awesome and very helpful, though only if organized properly. |
- | fillbyte | + | This is how I used to write label definitions: |
+ | !input = $8B | ||
+ | !frameinput = $8F | ||
+ | !up = $09AA | ||
+ | !down = $09AC | ||
+ | !left = $09AE | ||
+ | !right = $09B0 | ||
+ | !speed = #$0006 | ||
+ | !jump = $09B4 | ||
+ | !timer = $072D | ||
+ | !EnemySizeX = #$0020 | ||
+ | !EnemySizeY = #$0010 | ||
+ | !SMILEspeed = $0FB4 | ||
+ | !SMILEspeed2 = $0FB6 | ||
+ | !bomby = $0B82,x | ||
+ | !samusy = $0AFA | ||
+ | !pby = $0CE4 | ||
+ | !projectiley = $0B78,x | ||
+ | |||
+ | Having them like this is especially bad if you have a large file with tons of asm defines, so try to categorize and visually separate them: | ||
+ | |||
+ | { ; LABEL DEFINES ====================== | ||
+ | { ; BUTTON INPUT ----------------- | ||
+ | !input = $8B : !frameinput = $8F | ||
+ | !up = $09AA : !down = $09AC | ||
+ | !left = $09AE : !right = $09B0 | ||
+ | !jump = $09B4 | ||
+ | } | ||
+ | |||
+ | { ;IMMEDIATE VALUES--------------- | ||
+ | !speed = #$0006 : !region = #$0005 | ||
+ | !EnemySizeX = #$0020 : !EnemySizeY = #$0010 | ||
+ | } | ||
+ | |||
+ | { ;SMILE ENEMY EDITOR ------------ | ||
+ | !SMILEspeed = $0FB4 : !SMILEspeed2 = $0FB6 | ||
+ | } | ||
+ | |||
+ | { ;Y POSITIONS-------------------- | ||
+ | !samusy = $0AFA : !bomby = $0B82,x | ||
+ | !projectiley = $0B78,x : !pby = $0CE4 | ||
+ | } | ||
+ | |||
+ | { ;MISC -------------------------- | ||
+ | !timer = $072D | ||
+ | } | ||
+ | } | ||
+ | |||
+ | In N++: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== Repeatitions ===== | ||
__Repeatedly used opcodes:__ | __Repeatedly used opcodes:__ | ||
Line 447: | Line 501: | ||
LDA $07A5 : AND #$00FF : ASL : ASL : ASL : ASL : STA $0AF6 | LDA $07A5 : AND #$00FF : ASL : ASL : ASL : ASL : STA $0AF6 | ||
- | ...you can let xkas create pseudo | + | ...you can let xkas create pseudo |
NOP # | NOP # | ||
LDA $07A5 : AND #$00FF : ASL #4 : STA $0AF6 | LDA $07A5 : AND #$00FF : ASL #4 : STA $0AF6 | ||
- | But be careful | + | But be careful |
SEP #$20 | SEP #$20 | ||
Line 458: | Line 512: | ||
REP # | REP # | ||
+ | __Xkas fill functions organzation: | ||
- | + | org $808000 : padbyte $FF : pad $808010 ; | |
- | + | fillbyte $ff : fill 16 | |
- | + | ||
- | + | ||
====== 4. Tips for Optimizing Your Workflow using N++ Macros (Pending) ====== | ====== 4. Tips for Optimizing Your Workflow using N++ Macros (Pending) ====== | ||