User Tools

Site Tools


asm_stylesheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
asm_stylesheet [2015/10/25 13:10] – [One Event Per Line] black_falconasm_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 ''Language > User-defined'' (at the very bottom)
 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)
  
 {{:asmguidecustomlang1.png|}} {{:asmguidecustomlang1.png|}}
  
-In the opened window, click 'import' and select my stylesheet:+In the opened window, click ''Import'' and select my stylesheet:
  
 {{:asmguidecustomlang2.png|}} {{:asmguidecustomlang2.png|}}
Line 103: Line 103:
 ====== 2. Basic code structure ====== ====== 2. Basic code structure ======
  
-===== One Event Per Line =====+===== One Event/Statement Per Line =====
  
 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 ''DB'' (Data Byte), ''DW'' (Data Word), ''DL'' (Data Long) and ''org'' (sets file position) Most commonly used commands are ''DB'' (Data Byte), ''DW'' (Data Word), ''DL'' (Data Long) and ''org'' (sets file position)
 ''org'' along with an optional label should always be put onto a single line, and if necessary be on the same line after the open brace to collapse the code that is following afterwards. ''org'' along with an optional label should always be put onto a single line, and if necessary be on the same line after the open brace to collapse the code that is following afterwards.
Line 432: Line 434:
  }  }
  
-__Xkas fill functions organzation:__+===== Label Definitions =====
  
- org $808000 padbyte $FF pad $808010 ;should always be on one line +Defines are awesome and very helpful, though only if organized properly. 
- fillbyte $ff fill 16+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++: 
 + 
 +{{:asmguidedef1.png|}} 
 + 
 +===== 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 upcodes using # and a number (always decimal):+...you can let xkas create pseudo opcodes using # and numbers (always decimal):
  
  NOP #7 ;this equals NOP : NOP : NOP : NOP : NOP : NOP : NOP  NOP #7 ;this equals NOP : NOP : NOP : NOP : NOP : NOP : NOP
  LDA $07A5 : AND #$00FF : ASL #4 : STA $0AF6  LDA $07A5 : AND #$00FF : ASL #4 : STA $0AF6
  
-But be careful when writing to status register (''SEP'',''REP''or 8 bit operations to not forget the '$' sign:+But be careful at status register (''SEP'',''REP''and 8 bit operations to not forget the '$' sign:
  
  SEP #$20  SEP #$20
Line 458: Line 512:
  REP #20 ;forgetting '$' will instead write REP #$00 20 times, meaning a total 40 bytes are written!  REP #20 ;forgetting '$' will instead write REP #$00 20 times, meaning a total 40 bytes are written!
  
 +__Xkas fill functions organzation:__
  
- + org $808000 : padbyte $FF : pad $808010 ;should always be on one line 
- + fillbyte $ff : fill 16
- +
- +
 ====== 4. Tips for Optimizing Your Workflow using N++ Macros (Pending) ====== ====== 4. Tips for Optimizing Your Workflow using N++ Macros (Pending) ======