{"id":466,"date":"2013-06-11T20:55:18","date_gmt":"2013-06-12T01:55:18","guid":{"rendered":"http:\/\/snarfblam.com\/words\/?p=466"},"modified":"2014-01-06T21:03:07","modified_gmt":"2014-01-07T02:03:07","slug":"editroid-3-5","status":"publish","type":"post","link":"http:\/\/snarfblam.com\/words\/?p=466","title":{"rendered":"Editroid 3.5"},"content":{"rendered":"<p><em><span style=\"color: #ff0000;\">Update: <a href=\"http:\/\/snarfblam.com\/words\/?p=515\">Version 3.6 is available<\/a>, which fixes bugs found in version 3.5.<\/span><\/em><\/p>\n<p>Time to release a new version of my Metroid editor. This version allows you to add ASM to each screen that will run when the screen loads. It includes a built-in assembler so you can do everything right in Editroid. This makes it easy to do things like bankswap graphics for different areas of a level or change music for different areas, or to load additional objects into the screen based on a condition, or change the lava height in different screens so it doesn&#8217;t have to be right at the bottom in every screen. So yeah&#8230; all sorts of stuff.<!--more--><br \/>\n<a href=\"http:\/\/snarfblam.com\/words\/wp-content\/uploads\/2013\/06\/Editroid-3.5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-467 aligncenter\" title=\"Editroid 3.5\" alt=\"Editroid Screenshot\" src=\"http:\/\/snarfblam.com\/words\/wp-content\/uploads\/2013\/06\/Editroid-3.5.png\" width=\"464\" height=\"298\" srcset=\"http:\/\/snarfblam.com\/words\/wp-content\/uploads\/2013\/06\/Editroid-3.5.png 464w, http:\/\/snarfblam.com\/words\/wp-content\/uploads\/2013\/06\/Editroid-3.5-300x192.png 300w\" sizes=\"auto, (max-width: 464px) 100vw, 464px\" \/><\/a><br \/>\nThis is an alpha version, meaning everything is implemented and works, but hasn&#8217;t been tested and debugged too thoroughly, but I&#8217;ve been using it without any problems.<\/p>\n<p>Before you start adding ASM, the ROM needs to be expanded (under the file menu), and then you can click &#8220;Create Project&#8221; in the project menu. Then, everything ASM-related can be found in the project menu.<\/p>\n<p><del><a href=\"http:\/\/snarfblam.com\/files\/Editroid%203.5a.zip\" target=\"_blank\">http:\/\/snarfblam.com\/files\/Editroid%203.5a.zip<\/a><\/del><br \/>\nCheck out the <a href=\"http:\/\/www.romhacking.net\/utilities\/474\/\">RHDN Editroid page<\/a> for the most recent version.<\/p>\n<p>&nbsp;<\/p>\n<h2>Code Samples<\/h2>\n<p>Here are some examples of code you can add to a screen to do nifty things.<\/p>\n<pre>; Background graphics bank swap\r\n\r\nlda #$09 ; Bank 9\r\nsta $7801 ; (First bank in animation)\r\nsta $7802 ; (Last bank in animation)\r\nsta $7803 ; (Current bank)\r\nrts<\/pre>\n<pre>;Play Tourian theme (simple :)\r\njmp TourianMusic\r\n;(You can insert a different song in its place to allow two songs in an area)<\/pre>\n<pre>; Draw an object on the screen if the player has at least 1 full e-tank\r\n; (Requires that the code below be added to the general code file!)\r\n\r\n; Exit if player doesn't have any full tanks\r\nlda HealthHi\r\nand #$F0\r\nbne +\r\n    rts    \r\n*\r\n\r\n; Load ptr to data and draw it\r\nldx #&lt;ObjectData\r\nldy #&gt;ObjectData\r\njmp ExtraRoomData\r\n\r\nObjectData:\r\n;    xy  type pal  end\r\n.db $88, $08, $01, $FF<\/pre>\n<pre>; This is required by the above example.\r\n; This would be placed in the general code file.\r\n\r\n; ----------------------------\r\n;  ExtraRoomData\r\n; ----------------------------\r\n;  Draws additional objects to a screen. Call in screen-load\r\n;  routine. This is a modified version of a similar routine in\r\n;  the original game.\r\n;     Parameters:\r\n;     x - low byte of object data\r\n;     y - high byte of object data\r\n\r\n    ExtraRoomData:\r\n                stx RoomPtr                             ; Store data address\r\n                sty RoomPtr + 1\r\n                ldy #$00                                ; Point to first byte\r\n                lda (RoomPtr),Y                         ; Read it\r\n\r\n    DrawExtraObject:\r\n                sta $0E                         ;Store object position byte(%yyyyxxxx).\r\n                lda CartRAMPtr                  ;\r\n                sta CartRAMWorkPtr              ;Set the working pointer equal to the room pointer--&gt;\r\n                lda CartRAMPtr+1                ;(start at beginning of the room).\r\n                sta CartRAMWorkPtr+1            ;\r\n                lda $0E                         ;Reload object position byte.\r\n                jsr Adiv16                      ;($C2BF)\/16. Lower nibble contains object y position.--&gt;\r\n                tax                             ;Transfer it to X, prepare for loop.\r\n                beq +++                         ;Skip y position calculation loop as y position=0 and--&gt;\r\n                                                ;does not need to be calculated.\r\n         *      lda CartRAMWorkPtr              ;LoW byte of pointer working in room RAM.\r\n                clc                             ;\r\n                adc #$40                        ;Advance two rows in room RAM(one y unit).\r\n                sta CartRAMWorkPtr              ;\r\n                bcc +                           ;If carry occurred, increment high byte of pointer--&gt;\r\n                inc CartRAMWorkPtr+1            ;in room RAM.\r\n         *      dex                             ;\r\n                bne --                          ;Repeat until at desired y position(X=0).\r\n\r\n         *      lda $0E                         ;Reload object position byte.\r\n                and #$0F                        ;Remove y position upper nibble.\r\n                asl                             ;Each x unit is 2 tiles.\r\n                adc CartRAMWorkPtr              ;\r\n                sta CartRAMWorkPtr              ;Add x position to room RAM work pointer.\r\n                bcc +                           ;If carry occurred, increment high byte of room RAM work--&gt;\r\n                inc CartRAMWorkPtr+1            ;pointer, else branch to draw object.\r\n\r\n    ;CartRAMWorkPtr now points to the object's starting location (upper left corner)\r\n    ;on the room RAM which will eventually be loaded into a name table.\r\n\r\n          *     iny                             ;Move to the next byte of room data which is--&gt;\r\n                lda (RoomPtr),y                 ;the index into the structure pointer table.\r\n                tax                             ;Transfer structure pointer index into X.\r\n                iny                             ;Move to the next byte of room data which is--&gt;\r\n                lda (RoomPtr),y                 ;the attrib table info for the structure.\r\n                sta ObjectPal                   ;Save attribute table info.\r\n                txa                             ;Restore structure pointer to A.\r\n                asl                             ;*2. Structure pointers are two bytes in size.\r\n                tay                             ;\r\n                lda (StructPtrTable),y          ;Low byte of 16-bit structure ptr.\r\n                sta StructPtr                   ;\r\n                iny                             ;\r\n                lda (StructPtrTable),y          ;High byte of 16-bit structure ptr.\r\n                sta StructPtr+1                 ;\r\n                jsr DrawStruct                  ;($EF8C)Draw one structure.\r\n\r\n    ; Next Object\r\n                lda #$03                        ;Move to next set of structure data.\r\n                jsr AddToRoomPtr                ;($EAC0)Add A to room data pointer.\r\n                ldy #$00                        ;Zero index.\r\n                lda (RoomPtr),y                 ;Load byte of room data.--&gt;\r\n                cmp #$FF                        ;Is it #$FF(end-of-room)?--&gt;\r\n                beq +                           ;If so, branch to exit.\r\n                jmp DrawExtraObject\r\n              * rts<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Time to release a new version of my Metroid editor. This version allows you to add ASM to each screen that will run when the screen loads. It includes a built-in assembler so you can do everything right in Editroid.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,25,8,4,3],"tags":[26,27,17,10,13,16,12,46,9,41,28],"class_list":["post-466","post","type-post","status-publish","format-standard","hentry","category-asm-romhacking","category-editroid-romhacking","category-front-page","category-general","category-romhacking","tag-26","tag-asm","tag-editroid","tag-hacking","tag-level-editor","tag-metroid","tag-nes","tag-programming","tag-rom","tag-rom-hacking","tag-snarfblasm"],"_links":{"self":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=466"}],"version-history":[{"count":11,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":518,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions\/518"}],"wp:attachment":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}