@asar 1.81 ;---------------------------------------------------------------------------------------- ; sma2 overworld status menu v2.68 ; by Ladida ;---------------------------------------------------------------------------------------- !timer = $7F9FB0 ; 9 bytes of freeram. holds digits for timer ; put this address into the sram/bwram+ patch to backup and initialize! !layer1gfx0 = $0D00 ; ExGFX file that holds page 0 of the layer 1 graphics (set YY-CHR pattern to "vertical") !layer1gfx1 = $0D01 ; ExGFX file that holds page 1 of the layer 1 graphics (set YY-CHR pattern to "vertical") !layer1gfx2 = $0D02 ; ExGFX file that holds page 2 of the layer 1 graphics ; theyre split because theres not enough RAM for decompressing larger files !layer2gfx = $0E00 ; ExGFX file that holds the layer 2 and sprite graphics (shared) !layer3gfx = $0F00 ; ExGFX file that holds the layer 3 graphics !layer1map = $0D11 ; ExGFX file that holds the layer 1 tilemap [64x32] !layer2map = $0E01 ; ExGFX file that holds the layer 2 tilemap [32x32] !layer3map = $0F01 ; ExGFX file that holds the layer 3 tilemap [64x32] !statussong = $2A ; song that should play on the status screen. ; change it to whatever you insert the included (or your own) song as ;---------------------------------------------------------------------------------------- ; below are optional defines !exitcounter = 96 ; # of exits needed before you can warp (and the *96 icon on title screen). ; decimal value; add a $ if youre gonna use a hex value. ; note that this edits address $009D6D for you !anywarp = 0 ; by default, the ability to warp is handled by !exitcounter above. ; if you want warping to be enabled from the start, set this to 1 ; (note that you can only warp to revealed levels) !momohime = 0 ; peach stops crying when the high bit of !timer+8 is set. if this is set to 1, ; then she will stop crying when you obtain the # of exits set in !exitcounter !jikanganai = 0 ; the timer stops when the high bit of !timer+8 is set. if this is set to 1, ; then it will stop when you obtain the # of exits set in !exitcounter. ; note that the timer will always stop whenever !timer+8 is nonzero, whether its due ; to the high bit being set or not. a nonzero positive !timer+8 occurs when the maximum ; time limit is achieved (99 days, 23 hours, 59 minutes, 59 seconds) !autosave = 0 ; setting this to 1 will make the game autosave when you EXIT the menu. ; (specifically: itll save once the menu fades completely to black.) ; if you exit the menu via warp, then it'll save your new overworld position. ; SMA2 doesn't have this behavior, so this is 0 by default (meaning no saving occurs). ; note that there is no visual indication that it will save your progress, ; so it's recommended that, if you enable this feature, that you communicate ; the behavior to the player via readme or a message box ingame !nihondash = 0 ; the Japanese version of SMA2 uses a - instead of a blank tile for levels that ; dont have yoshi coins or arent completable. set this to 1 if you want that behavior !worldpalettes = 0 ; if this is nonzero, a custom palette will be used for each world. ; the palettes themselves are loaded from worldpalettes.bin, 32 bytes (16 colors) per world. ; the first 12 colors are for the banner, the next 2 are the list colors for a world in ; progress, and the last 2 colors are for a completed world. ; note that nonzero also disables the banner palette animation. !menuscrollrate = 8 ; how fast the menu scrolls, in pixels per frame. only powers of 2 are accepted! ; minimum: 1 ; maximum: 256 (instant) !nonocomplete = 0 ; if this is nonzero, then the "nocompleted" table in levelnames.txt will not be used. ; instead, the patch will check if the level has "No Event" selected for it in LM ; (which just sets the event to activate as FF). ; the reason this isn't done by default is because SMW has events associated with ; certain star roads, the front/back doors, and yoshi's house, even though the events ; don't actually do anything (you can obviously change the levels to have "No Event" to fix, ; and obviously a custom hack will not be using the original level settings so it's ; beneficial to enable this if you don't want to edit yet another table in this patch) !nospeciallevel = 0 ; if this is nonzero, then the "speciallevel" table in levelnames.txt will not be used. ; instead, the patch will check if the level is set to be revealed by multiple events in LM. ; the reason this isn't done by default is because that method restricts events to "reveal" ; only 1 level, so it won't work for places like star world in SMW, where unlocking the ; star road also unlocks the level next to it (so you'll have to use pipes rather than star ; roads, or manually trigger event flags). honestly this define is not recommended unless ; you prefer using LM over editing tables in this patch. !player1luigi = 0 ; if this is nonzero, then in a 1 player game, switching to Luigi will not poll from ; controller port 2 for input (so input is always taken from port 1). However, Luigi's ; status will still be pulled from the respective addresses. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; dont edit anything below this unless you know what youre doing ; i provide zero support and zero warranty ; you have been warned ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !hdmaspace = 1 ; SMA2 uses sprites to display the level names. in doing so, its able ; to add a 1px space between the levels so they dont look too squished. ; since this patch uses layer 3 to display the levelnames, HDMA on ; layer 3 Y position is used to simulate the spacing effect. ; this define indicates the number of pixels said spacing should be. ; anything above 5 will look stupid, and anything above 16 WILL look broken. ; 0 will "disable" the HDMA (so itll look like the old patch) ; NOTE: higher values require a smaller !listlen value (thus a shorter list) ; NOTE2: you NEED to manually configure the GFX/tilemap so things look proper !listlen = 17 ; max # of levels per world (decimal) !namelen = 19 ; max levelname length. handles table index as well (decimal) math pri on math round off !sa1 = 0 !gsu = 0 !dp = $0000 !addr = $0000 !bank = $800000 !wram = $7E0000 if read1($00FFD6) == $15 sfxrom !gsu = 1 !dp = $6000 !addr = $6000 !bank = $000000 !wram = $7E0000 elseif read1($00FFD5) == $23 sa1rom !sa1 = 1 !dp = $3000 !addr = $6000 !bank = $000000 !wram = $400000 endif !bank8 #= <:!bank !wram8 #= <:!wram !dpaddr #= !addr-!dp assert read1($048E81|!bank) == $22,"Lunar Magic's level names table wasn't found. Please save the overworld in Lunar Magic before patching." assert read1($008075|!bank) == $5C,"AddmusicK wasn't found. Before running AMK, make sure you replace patch.asm in the /SNES/asm/ folder with the version included with this patch." if !sa1 assert read1($009BD2|!bank) == $5C,"bwram_plus wasn't found. Make sure to add the timer RAM and the Yoshi coin table." else assert read1($009BC9|!bank) != $8B,"sram_plus wasn't found. Make sure to add the timer RAM and the Yoshi coin table." endif !bigow #= equal(read1($04E46C|!bank),$22) !off1 #= select(!bigow,160,0) !off2 #= select(!bigow,177,0) !ram1F02 #= $1F02+!off1|!addr !ram1F2E #= $1F2E+!off2|!addr !ram1F2F #= read2($00977A|!bank) ; level names table address. default is lunar magic's table. each name within must be equal to !namelen in length !nametable = read3(read3($048E82|!bank)+$37) ; SPC upload routine. default is AMK's (via the custom patch.asm included). must be long-returnable (end in RTL) !spcuploadaddr = read3(read3($008076|!bank)+3) org $009D6D|!bank db !exitcounter org $008E28|!bank autoclean JML timerhandler NOP org $049120|!bank autoclean JML w NOP #2 freecode ;---------------------------------------------------------------------------------------- timerhandler: PHB PHK PLB LDA $0F31|!addr ORA $0F32|!addr ORA $0F33|!addr BEQ .return0 if !jikanganai LDA !ram1F2E CMP.b #!exitcounter BCS .return0 endif LDA !timer+8 BNE .return0 + LDA $14 AND #$3F BNE .return0 LDX #$00 - LDA !timer,x INC CPX #$04 BEQ .hours CMP .maxval,x BCS + --- STA !timer,x BRA .return0 + CPX #$07 BNE ++ -- LDA .topval,x STA !timer,x DEX BPL -- STA !timer+8 BRA .return0 ++ LDA #0 STA !timer,x -- INX CPX #$08 BCC - .return0 PLB DEC $0F30|!addr BPL .return2 .return1 JML $008E2D|!bank .return2 JML $008E6F|!bank - LDA !timer+1,x CMP .maxval+1,x BCC + LDA #0 STA !timer,x STA !timer+1,x INX BRA -- .hours TAY CMP #4 BEQ - + TYA CMP .maxval,x BCC --- LDA #0 STA !timer,x INX LDA !timer,x INC BRA --- .maxval db 10,6,10,6,10,2,10,10 .topval db 9,5,9,5,3,2,9,9 ;---------------------------------------------------------------------------------------- w: LDA $16 AND #$20 BNE + STZ $0DD8|!addr LDY $0EF7|!addr JML $049126|!bank .scrollrate dw clamp(2**log2(!menuscrollrate),1,256),-clamp(2**log2(!menuscrollrate),1,256) .scrolllowrate db $01,-$01 .scrolllowtable db $00,(worldlen_end-worldlen)/2-1 .andtable db $80,$40,$20,$10,$08,$04,$02,$01 if !sa1 .resetSA1stack SEI INC $0189 LDA #$F0 STA $220B PLD PLA PLA STA $2225 STA $318F PEA $0100 PLD PEA $1010 PLB LDA #$37 XBA LDA #$FF TCS CLI JML read3($008A64+$11) endif + SEI LDA #$E1 STA $4209 STZ $420A LDA #$21 STA $4200 LDA $0DAE|!addr AND #$0F - WAI BIT $4211 DEC STA $2100 BPL - STA $0DAE|!addr STZ $0D9F|!addr STZ $420C STZ $0DAF|!addr LDA #$0C STA $0100|!addr JSL read3($008643|!bank) LDA.b #!statussong STA $1DFB|!addr JSL !spcuploadaddr LDY #$21 STY $4200 ;---------------------------------------------------------------------------------------- LDA #$31 STA $2107 LDA #$38 STA $2108 LDA #$51 STA $2109 LDA #$60 STA $210B LDA #$44 STA $210C LDA #$01 STA $2105 LDA #$15 STA $212C LDA #$02 STA $212D LDA #$02 STA $2130 LDA #$20 STA $2131 STZ $4326 STZ $4336 LDA #$80 STA $2115 STZ $00 LDA #$01|!wram8 STA $4324 REP #$30 LDA.w #select(!sa1,$1FFF,$01FF) TCS LDA.w #$01C8|!wram>>8 STA $01 LDA #$1801 STA $4320 macro vram(dest,len,file) LDY.w # LDX.w # if LDA.w # JSR .upload else JSR .upload_raw endif endmacro %vram($0000,$2000,!layer1gfx0) %vram($1000,$2000,!layer1gfx1) %vram($2000,$2000,!layer1gfx2) %vram($6000,$2000,!layer2gfx) %vram($5800,$1000,!layer3gfx) %vram($3000,$1000,!layer1map) %vram($3800,$0800,!layer2map) %vram($5000,$1000,!layer3map) STZ $1A LDA #$FFFE STA $1C STZ $1E STZ $20 STZ $22 STZ $24 PHK LDX.w #menupal LDY #$1100|!addr LDA #$01FF MVN !bank8,<:menupal PLB SEP #$20 LDX.w #!nametable LDA.b #<:!nametable STX $0C STA $0E STZ $40 LDX #$15E0+!dpaddr LDA #$1F - STA $00,x INX CPX.w #!namelen+$15E0+!dpaddr BCC - LDA #$01 STA $00,x STA $01,x STA $02,x STA $03,x STA $04,x STA $05,x STZ $2A LDA.b #!namelen STA $4202 LDX #$0001 STX $3A TXA STA $3C PEA .caboose-1 PEA counters_init-1 PEA .peach_anim_init-1 PEA .yoshicoin_check-1 PEA .bannerinit-1 PEA .namerender-1 PEA .hdmasetup-1 PEA .populate-1 PEA .worldcheck-1 PEA .vrambuffer_init-1 JMP .speedup .caboose INC $0DAE|!addr JSR .update LDA $0DAE|!addr CMP #$0F BCC .caboose ;---------------------------------------------------------------------------------------- .loop if !player1luigi LDA $0DB2|!addr BEQ $03 endif LDA $0DB3|!addr ASL TAX LDA $2B BEQ ..notscroll ..scroll AND #$FE TAY REP #$21 LDA $22 ADC .scrollrate,y STA $22 STA $1A SEP #$20 CMP #$00 BNE + STZ $2B + JMP ..skipscroll ..quit LDA $0DAE|!addr AND #$0F - WAI BIT $4211 DEC STA $2100 BPL - STA $0DAE|!addr if !autosave JSL $009BC9|!bank endif if !sa1 LDA.b #.resetSA1stack STA $3180 LDA.b #.resetSA1stack>>8 STA $3181 LDA.b #.resetSA1stack>>16 STA $3182 JSR $1E80 endif LDA #!bank8 PHA PLB REP #$20 LDA.w #select(!sa1,$1FFF,$01FF) TCS SEP #$20 JML $008072|!bank ..notscroll LDA $27,x BIT #$60 BNE ..quit BIT #$90 BNE ..enter BIT #$0C BNE ..cursormove AND #$03 BEQ ..doublecheck ..lr STA $2B LSR TAY LDA $04 - CLC ADC .scrolllowrate,y CMP.b #(worldlen_end-worldlen)/2 BCC + LDA .scrolllowtable,y + CMP $04 BNE ++ STZ $2B JMP ..skipscroll ++ TAX LDA $15C0|!addr,x BNE + TXA BRA - + TXA JSR .repopulate JSR .bannerinit LDA $32 CMP $05 BCC + -- LDA $05 DEC + TAX - LDA $1500|!addr,x AND #$02 BEQ + DEX BPL - - INX CPX $05 BCS -- LDA $1500|!addr,x AND #$02 BNE - + STX $32 LDA #$06 STA $1DFC|!addr LDA $2B JMP ..scroll ..doublecheck LDA $26,x BMI ..enter BIT #$40 BNE + LSR #4 AND #$03 BNE ..lr BRA ..skipscroll + JMP ..quit ..enter if not(!anywarp) LDA !ram1F2E CMP.b #!exitcounter BCC ..skipscroll endif LDA #$01 STA $2143 JMP .warp ..cursormove LSR #3 AND #$01 TAY if not(!anywarp) LDA !ram1F2E CMP.b #!exitcounter BCC ..skipscroll endif LDA $05 DEC STA $01 STZ $00 LDA $32 - CLC ADC .scrolllowrate,y CMP $05 BCC + LDA $0000|!dp,y + TAX LDA $1500|!addr,x BIT #$02 BEQ + TXA BRA - + CPX $32 BEQ ..skipscroll LDA #$23 STA $1DFC|!addr TXA STA $32 ..skipscroll PEA .loop-1 PEA.w .update+2 PEA.w .spritehandler-1 PEA.w .peach_anim-1 PEA.w .bannerflashk-1 JMP .flashk ;---------------------------------------------------------------------------------------- .update JSR .spritehandler BIT $4211 WAI LDA #$80 STA $2100 ..palette STZ $2121 LDA #!bank8 STA $4324 REP #$20 LDA #$2202 STA $4320 LDA #$1100|!addr STA $4322 LDA #$0200 STA $4325 LDX #$04 STX $420B ..oam ASL STA $4320 STZ $2102 LDA #$0200|!addr STA $4322 LDA #$0220 STA $4325 STX $420B SEP #$20 ..layerupdate LDA $1A ADC #$01 STA $210D LDA $1B ADC #$00 STA $210D LDA $1C STA $210E LDA $1D STA $210E LDA $1E STA $210F LDA $1F STA $210F LDA $20 STA $2110 LDA $21 STA $2110 LDA $22 STA $2111 LDA $23 STA $2111 LDA $24 STA $2112 LDA $25 STA $2112 JSR .listupdate JSR .bannerrender JSR .vrambuffer_upload LDA $0D9F|!addr STA $420C LDA $0DAE|!addr STA $2100 LDA #$01 ..joypad BIT $4212 BNE ..joypad REP #$30 LDX $4218 LDA $08 STX $08 AND $08 STA $15 EOR $08 STA $26 LDX $421A LDA $0A STX $0A AND $0A STA $17 EOR $0A STA $28 LDA $22 STA $2C SEP #$30 INC $13 LDA $1DF9|!addr STA $2140 LDA $1DFC|!addr STA $2143 STZ $1DF9|!addr STZ $1DFC|!addr JMP counters_main .upload JSL $0FF900|!bank ..raw LDA #$C800 STA $4322 STX $4325 STY $2116 SEP #$30 LDA #$04 STA $420B REP #$30 RTS ;---------------------------------------------------------------------------------------- .populate LDY $0DD6|!addr LDA $1F17+!off2|!addr,y LSR #4 STA $0F LDA $1F19+!off2|!addr,y AND #$F0 ORA $0F XBA LDA $1F1A+!off2|!addr,y ASL ORA $1F18+!off2|!addr,y LDY $0DB3|!addr LDX $1F11+!off2|!addr,y REP #$11 BEQ + ADC #$04 + XBA TAX LDA $00D000|!wram,x STA $0F BEQ ++ LDX.w #worldlen_end-worldlen-2 -- LDY worldptrs,x STY $00 LDY worldlen,x - CMP ($00),y BEQ + DEY BPL - DEX #2 BPL -- ++ LDX #$0000 LDY #$FFFF + REP #$20 TXA LSR STA $06 TYA SEP #$30 STA $07 STA $32 LDA $06 .repopulate STA $04 REP #$30 AND #$00FF ASL TAX LDA worldptrs,x STA $02 LDA worldlen,x STZ $30 SEP #$30 INC STA $05 LDY #$00 LDA $2A ASL #4 ADC #$25 - STA $1500|!addr,y EOR #$0C INY CPY.b #!listlen BCC - LDA #$01 - STA $151F|!addr,y STA $153F|!addr,y STA $155F|!addr,y STA $157F|!addr,y STA $159F|!addr,y DEY : BNE - PHY REP #$10 LDX #$1938+!dpaddr STZ $35 .superloop LDA.b #!namelen-1 STA $01 LDA ($02),y STA $4203 STA $33 STZ $34 INC $35 PHX TAX .nocompletion if !nonocomplete LDA $05D608|!bank,x CMP #$FF BEQ .exits_pretend else LDY.w #nocompleted_end-nocompleted-1 ..loop CMP nocompleted,y BEQ .exits_pretend DEY BPL ..loop endif .exits LDA $03,s CLC ADC #$20 STA $2E LDA.b #$15|!addr>>8 STA $2F PEA.w ..end-1 LDA $33 LDY.w #secretexits_end-secretexits-2 ..loop CMP secretexits,y BEQ ..yes DEY #2 BPL ..loop BRA ..skip ..yes LDA secretexits+1,y STA $34 ..hai PEA.w ..loli-1 DEC BNE ..hai ..skip LDA $05D608|!bank,x STA $00 ..loli LDA $00 AND #$07 TAX LDA $00 LSR #3 TAY LDA !ram1F02,y AND .andtable,x BEQ ..null ..full LDA #$06 INC $31 BRA ..ski ..null LDA #$05 ..ski STA ($2E) LDA $2E CLC ADC #$20 STA $2E INC $00 INC $30 RTS ..pretend if !nihondash LDA $03,s TAY LDA #$02 STA $1520|!addr,y endif INC $30 INC $31 ..end .yoshicoins LDA $33 LDY.w #noyoshicoins_end-noyoshicoins-1 ..loop CMP noyoshicoins,y if !nihondash BEQ ..dash else BEQ ..end endif DEY BPL ..loop LSR #3 TAY LDA $33 AND #$07 TAX LDA !ram1F2F,y AND .andtable,x BEQ ..null ..full LDX #$0004 BRA ..skip ..dash LDX #$0002 BRA ..skip ..null LDX #$0003 ..skip LDA $03,s TAY TXA STA $15A0|!addr,y ..end .special if !nospeciallevel LDA $33 REP #$20 ASL TAX STZ $2E LDA $00E000|!wram,x LDX.w #select(!bigow,$00FF*2,$0078*2) ..loop DEX #2 BMI ..end CMP read3($04DA74|!bank),x BNE ..loop ..loli INC $2E PHA PHX TXA LSR #4 TAY TXA LSR AND #$0007 TAX LDA !ram1F02,y AND #$00FF AND .andtable,x BNE ..skip PLX PLA BRA ..loop ..skip PLX PLA STZ $2E ..end LDA $2E SEP #$20 BNE .transparent_ret else LDA $33 LDY.w #speciallevel_end-speciallevel-4 ..loop CMP speciallevel,y BEQ ..seek DEY #4 BPL ..loop BRA ..end ..seek LDA #$02 STA $00 ..loli INY PHY LDA speciallevel,y AND #$07 TAX LDA speciallevel,y LSR #3 TAY LDA !ram1F02,y PLY AND .andtable,x BNE ..end DEC $00 BPL ..loli BRA .transparent_ret ..end endif .transparent LDA $33 TAX LDA $1000|!addr,x LDX #$0015 ..loop CMP $04DA1D|!bank,x BEQ ..ret DEX BPL ..loop BRA ..end ..ret PLX ..null LDA #$01 ..loli STA $00,x INX DEC $01 BPL ..loli LDA $01,s TAY LDA $1500|!addr,y ORA #$03 STA $1500|!addr,y LDA #$01 STA $1520|!addr,y STA $1540|!addr,y STA $1560|!addr,y STA $1580|!addr,y STA $15A0|!addr,y DEC $35 ..dec DEC $30 DEC $31 DEC $34 BPL ..dec BRA .superskip ..end PLX LDY $4216 - LDA [$0C],y STA $00,x INY INX DEC $01 BPL - .superskip PLA INC TAY CMP $05 BCS + PHA JMP .superloop + CMP.b #!listlen BCS + PHY LDY #..null LDA $35 CMP $05 BCC ++ LDY #..full ++ STY $02 -- LDA.b #!namelen-1 STA $01 - LDA $0000,y STA $00,x INX INY DEC $01 BPL - PLY LDA $1500|!addr,y ORA #$03 STA $1500|!addr,y INY CPY.w #!listlen PHY LDY $02 BCC -- PLY + SEP #$10 if not(!worldpalettes) LDX $04 REP #$10 LDY #$1100|!addr LDA $15C0|!addr,x BPL + LDY #$1120|!addr + REP #$20 LDA $29 AND #$0100 LSR #3 ADC #$1100+!dpaddr TAX LDA $0008,y STA $02,x STA $0A,x LDA $0010,y STA $12,x SEP #$30 endif LDA #$80 TSB $2A - RTS ..null fillbyte $01 : fill !namelen ..full fillbyte $01 : fill !namelen/2-3 db $09,$0A fillbyte $01 : fill !namelen/2+2 ;---------------------------------------------------------------------------------------- .listupdate LDA $2A BPL - STZ $2115 LDX #!bank8 STX $4324 STX $4334 REP #$21 AND #$0001 XBA ASL ASL ADC #$50E5 PHA ADC.w #!listlen*32 STA $00 LDA #$1800 STA $4320 LDA #$1938|!addr STA $4322 LDA #$1908 STA $4330 LDA #$1500|!addr STA $4332 LDY.b #!namelen LDX #$04 PLA - STA $2116 STY $4325 STX $420B LDX #$80 STX $2115 STA $2116 STY $4335 LDX #$08 STX $420B ADC #$0020 CMP $00 INC $4332 LDX #$00 STX $2115 LDX #$04 BCC - SEP #$20 LDA #$01 STA $2115 LDA $2A REP #$21 AND #$0001 XBA ASL ASL ADC #$50F9 PHA ADC #$0005 STA $00 LDA #$1520|!addr STA $4322 LDY.b #!listlen LDX #$04 PLA - STA $2116 STY $4325 STX $420B PHA LDA $4322 AND #$FFE0 ADC #$0020 STA $4322 PLA INC CMP $00 BCC - SEP #$21 LDA $2A AND #$01 EOR #$01 STA $2A ROR TSB $36 RTS .speedup PHB PEA !wram8|$1000+!dpaddr PLB PLA XBA LDY #$07FF - LDA $D000,y BEQ + TAX LDA $C800,y STA $00,x if !nospeciallevel TXA REP #$20 ASL TAX TYA STA $E000,x LDA #$1000+!dpaddr SEP #$20 endif + DEY BPL - STZ $1000 if !nospeciallevel STZ $E000 STZ $E001 endif PLB RTS .worldcheck LDA.b #(worldlen_end-worldlen)/2-1 - PHA JSR .repopulate PLX LDA $30 BEQ + CMP $31 BNE + ORA #$80 + STA $15C0|!addr,x TXA DEC BPL - RTS ;---------------------------------------------------------------------------------------- .namerender LDX.b #!namelen-1 LDA #$1F - STA $0FC0|!addr,x DEX BPL - STZ $07A0|!addr LDY #$80 STY $2115 LDA $07 STA $4203 CMP #$FF BNE + STZ $32 REP #$31 LDA #$0FC0|!addr BRA ++ + REP #$31 LDA $4216 ADC #$1938|!addr ++ STA $00 PHB LDX #$07A0|!addr LDY #$07A1|!addr LDA.w #!namelen*32-2 MVN !bank8,!bank8 PLB SEP #$20 LDA.b #!namelen-1 STA $02 LDX #$07A0|!addr -- LDA ($00) REP #$20 AND #$00FF ASL #3 ORA #$4800 STA $2116 LDA #$0000 INC $00 SEP #$20 LDA $213A LDY #$0003 - LDA $2139 AND $213A STA $0008,x EOR #$FF STA $03 EOR #$FF XBA AND $03 STA $0009,x INX #2 DEY BPL - LDY #$0003 - LDA $2139 AND $213A STA.w !namelen*16-8,x EOR #$FF STA $03 EOR #$FF XBA AND $03 STA.w !namelen*16-7,x INX #2 DEY BPL - DEC $02 BPL -- LDX #$5A00 STX $2116 LDX #$1801 STX $4320 LDX #$07A0|!addr STX $4322 LDA #!bank8 STA $4324 LDX.w #!namelen*32 STX $4325 LDA #$04 STA $420B SEP #$10 RTS .hdmasetup REP #$20 STZ $2C LDA #$1142 STA $4350 LDA.w #..l3x STA $4352 LDA #$1202 STA $4340 LDA.w #..l3y STA $4342 SEP #$20 LDA.b #<:..l3x STA $4354 STA $4344 STA $4357 LDA #$30 TSB $0D9F|!addr RTS ..l3x db $30 : dw ..l3y+1 db $01 : dw $002C|!dp db $00 ..l3y db $16 : dw $0000 db $10 : dw $0001 db $01 : dw $FFC0 db $08 : dw $0000 db $05 : dw $0003 !countdown #= !listlen !spaceloc = $FFBB !nameloc #= $0003-floor(!hdmaspace/2)-!hdmaspace%2 while !countdown if !countdown == !listlen db floor(!hdmaspace/2)+!hdmaspace%2 : dw !spaceloc else db !hdmaspace : dw !spaceloc endif db $08 : dw !nameloc !nameloc #= !nameloc-!hdmaspace&$FFFF if !listlen%2 !spaceloc #= !spaceloc-!hdmaspace-16*(not(!countdown%2))&$FFFF else !spaceloc #= !spaceloc-!hdmaspace-16*(!countdown%2)&$FFFF endif !countdown #= !countdown-1 endif db $04 : dw $0002 db $00 ...end - STZ $40 RTS .flashk LDA $2A BMI - LDA $2B BNE + LDA $04 CMP $06 BNE + LDA $13 AND #$1F BNE + LDA $2A EOR #$01 ASL #2 STA $01 STZ $00 LDA $07 CMP #$FF BEQ + STA $4203 REP #$30 AND #$00FF XBA LSR #3 ADC #$50E5 ADC $00 STA $00 LDA.w #!namelen+6 STA $02 SEP #$20 LDX #$0780+!dpaddr LDY $4216 - LDA $1938|!addr,y STA $00,x INY INX CPX.w #!namelen+$0780+!dpaddr BCC - LDA $07 TAY LDA #$01 STA $00,x LDA $1520|!addr,y STA $01,x LDA $1540|!addr,y STA $02,x LDA $1560|!addr,y STA $03,x LDA $1580|!addr,y STA $04,x LDA $15A0|!addr,y STA $05,x LDY #$0780|!addr LDA $40 EOR #$01 STA $40 BEQ ++ LDY #$15E0|!addr ++ JSR .vrambuffer_update SEP #$10 + RTS ;---------------------------------------------------------------------------------------- .spritehandler REP #$31 ..coins LDX.w #(!listlen-1)*4|$0200+!dpaddr LDY #$0010 LDA $22 EOR #$FFFF INC ADC #$00E8 AND #$00FF ORA #$3500 - STA $00,x STA $80,x STY $02,x STY $82,x CLC ADC.w #$0800+(!hdmaspace<<8) DEX #4 CPX #$0200+!dpaddr BCS - ..cursor LDY #$0000 if not(!anywarp) LDA !ram1F2E AND #$00FF CMP.w #!exitcounter BCC + endif LDA $2B AND #$00FF BNE + LDY #$001F + TYA ORA #$3000 STA $02FE|!addr LDA $32 AND #$00FF STA $00 ASL ASL ASL ADC $00 ADC #$2034 XBA STA $02FC|!addr ..arrows LDX.w #(worldlen_end-worldlen)/2-1 LDY #$0000 - LDA $15C0|!addr,x AND #$00FF BEQ + INY + DEX BPL - DEY BEQ ..hightable LDA $13 LSR #2 AND #$0004 TAX LDA $2B AND #$00FF BEQ + LDX #$0004 + LDA ..left,x STA $0300|!addr LDA ..left+8,x STA $0302|!addr LDA ..left+2,x STA $0304|!addr LDA ..left+10,x STA $0306|!addr LDA ..right,x STA $0308|!addr LDA ..right+8,x STA $030A|!addr LDA ..right+2,x STA $030C|!addr LDA ..right+10,x STA $030E|!addr ..hightable STZ $040E|!addr STZ $0410|!addr STZ $0400|!addr STZ $0402|!addr STZ $0404|!addr LDA #$5555 STA $0408|!addr STA $040A|!addr STA $040C|!addr JSR .peach JSR .yoshicoin SEP #$30 RTS ..left dw $7801,$8001,$7801,$8001 dw $3016,$3017,$3000,$3000 ..right dw $78F7,$80F7,$78F7,$80F7 dw $3018,$3019,$3000,$3000 ;---------------------------------------------------------------------------------------- .peach LDY #$0000 if !momohime LDA !ram1F2E AND #$00FF CMP.w #!exitcounter BCC + else LDA !timer+7 CPY #$8000 BCC + endif LDY #$0008 + TYX LDA $3C AND #$00FF BCC + CMP.w #20 BRA ++ + CMP.w #10 ++ BCC + INY #4 + LDA ..top,y STA $034A|!addr LDA ..top+2,y STA $034E|!addr LDA $3B LSR BCC + INX #4 + LDA ..bottom,x STA $0342|!addr LDA ..bottom+2,x STA $0346|!addr LDA #$181D STA $0348|!addr LDA #$1825 STA $034C|!addr LDA #$201D STA $0340|!addr LDA #$2025 STA $0344|!addr LDA #$AAAA STA $0414|!addr RTS ..top dw $3230,$3231,$3233,$3234 dw $3236,$3237,$3239,$323A ..bottom dw $3240,$3241,$3243,$3244 dw $3246,$3247,$3249,$324A ..anim LDA $3C DEC BPL + ...init if not(!momohime) LDA !timer+8 TAX endif LDA #19 if !momohime LDX !ram1F2E CPX.b #!exitcounter else CPX #$80 endif BCC + LDA #34 + STA $3C LDA $3A DEC BNE + LDA $3B ASL TAX REP #$20 if not(!momohime) LDA !timer+8 TAY endif LDA ..timer,x if !momohime LDY !ram1F2E CPY.b #!exitcounter else CPY #$80 endif BCC + LDA ..timer-4,x + STA $3A SEP #$20 RTS db 7,$01 db 154,$00 ..timer db 8,$01 db 6,$02 db 8,$03 db 6,$04 db 8,$05 db 10,$06 db 15,$07 db 6,$00 ;---------------------------------------------------------------------------------------- .yoshicoin LDA #$F000 STA $0380|!addr STA $0384|!addr LDA $38 BPL + LDA #$303E STA $0382|!addr LDA #$304E STA $0386|!addr LDA #$19E5 STA $0380|!addr LDA #$21E5 STA $0384|!addr LDA #$AAAA STA $0418|!addr + RTS ..check STZ $00 LDX.b #select(!bigow,$1F,$0B) -- LDY #$07 LDA !ram1F2F,x - LSR BCC + INC $00 + DEY BPL - DEX BPL -- LDA worldlen_end SEC SBC.b #noyoshicoins_end-noyoshicoins STA $01 LDA $00 CMP $01 LDA #$FF BCS + INC + STA $39 RTS ;---------------------------------------------------------------------------------------- .bannerinit STZ $38 JSR .bannerflashk_init REP #$30 LDX #$1600+!dpaddr LDA $03 AND #$FF00 LSR #3 SEP #$20 - STA $00,x INC INX CPX #$1620+!dpaddr BCC - XBA ORA #$2C STA $36 LDA $2A AND #$01 ASL #4 TSB $36 ORA #$2E STA $01,x LDA $04 ASL #3 STA $00,x SEP #$10 - RTS .bannerrender LDA $36 BPL - AND #$7F STA $36 LDA #$01 STA $2115 LDA #!bank8 STA $4324 LDY #$04 LDA $2A EOR #$01 REP #$20 AND #$0001 XBA ASL ASL ADC #$3103 STA $00 DEC STA $2116 LDA #$1800 STA $4320 LDA #$1600|!addr STA $4322 LDX #$10 STX $4325 STY $420B LDA $00 STA $2116 STX $4325 STY $420B LDX #$81 STX $2115 STA $2116 LDA #$1908 STA $4320 LDA #$0036|!dp STA $4322 LDX #$10 STX $4325 STY $420B LDA $00 DEC STA $2116 STX $4325 STY $420B PHD LDA #$2100 TCD LDX #$80 STX $15 LDA $0000|!dp SEC SBC #$0041 STA $16 REP #$10 LDX $1620|!addr STX $18 INX STX $18 CLC ADC #$0020 STA $16 INX STX $18 INX STX $18 ADC #$0220 STA $16 INX STX $18 INX STX $18 ADC #$0020 STA $16 INX STX $18 INX STX $18 SEP #$30 PLD STZ $36 RTS .bannerflashk if !worldpalettes RTS else LDY $04 LDA $15C0|!addr,y BPL ++ LDA $37 DEC BPL + endif ..init if !worldpalettes PHB REP #$30 LDA $03 AND #$FF00 LSR #3 ADC.w #worldpal TAX LDA $29 AND #$0100 LSR ADC #$1160|!addr TAY PHY LDA #$001F MVN !bank8,<:worldpal LDA $04 AND #$00FF TAX PLY PLB LDA $15BF|!addr,x BPL + INY #4 + LDA $29 AND #$0100 LSR #3 ADC #$1100+!dpaddr TAX LDA $0018,y STA $02,x STA $0A,x LDA $001A,y STA $12,x SEP #$30 RTS else LDA $38 ASL TAX REP #$20 LDA $37 AND #$7F00 LSR #3 ADC #$1180|!addr STA $00 LDA $29 AND #$0100 EOR #$0100 LSR ADC #$1160|!addr STA $02 LDY #$1F - LDA ($00),y STA ($02),y DEY BPL - LDA ..timer,x + STA $37 SEP #$20 ++ RTS ..timer db 29,$01 db 9,$02 db 9,$00 endif ;---------------------------------------------------------------------------------------- .warp LDY $32 LDA $04 ASL TAX REP #$30 LDA worldptrs,x STA $00 LDA #$1F00+!dpaddr SEP #$20 PEA.w .warp>>8&$FF00|!wram8 LDA ($00),y PLB LDY #$0800 - DEY CMP $D000,y BNE - LDA $0DB3 ASL TAX LDA #$02 STA $13+!off2,x LDA $C800,y CMP #$80 BEQ ..water CMP #$6A BCC ..notwater CMP #$6E BCS ..notwater ..water LDA #$0A STA $13+!off2,x ..notwater STY $00 LDA $0DD6 TAX LDA #$1F XBA LDA $0DB3 TAY LDA $00 AND #$F0 ORA #$08 STA $19+!off2,x LSR #4 STA $21+!off2,x LDA $00 AND #$0F STA $1F+!off2,x ASL #4 ORA #$08 STA $17+!off2,x STZ $02 LDA $01 BIT #$04 BEQ ..ow AND #$03 STA $01 LSR ROR $00 LSR ROR $00 LDA $00 CMP.b #$0A<<2 BCC ..yi CMP.b #$10<<2 BCC ..va CMP.b #$1A<<2 BCC ..vb CMP.b #$20<<2 BCC ..sp CMP.b #$25<<2 BCC ..va CMP.b #$30<<2 BCC ..fi CMP.b #$35<<2 BCC ..sp ..sw INC $02 ..sp INC $02 ..vb INC $02 ..fi INC $02 ..va INC $02 ..yi INC $02 ..ow LDA $02 STA $0011+!off2,y LDA $01 LSR STA $1A+!off2,x ASL #4 ORA $21+!off2,x STA $21+!off2,x LDA $01 AND #$01 STA $18+!off2,x ASL #4 ORA $1F+!off2,x STA $1F+!off2,x SEP #$10 PLB JMP .loop_quit ;---------------------------------------------------------------------------------------- macro counterupdate(vadd,prop,len,src) REP #$10 LDX.w # STX $00 LDA.b # STA $03 LDA.b # STA $02 LDY.w # JSR w_vrambuffer_update SEP #$10 endmacro .vrambuffer ..update LDA.b #$13+(!dpaddr>>8) XBA LDA $3D REP #$20 TAX LDA $00 XBA STA $00,x LDA $02 STA $02,x SEP #$20 CLC ADC $3D ADC #$04 STA $3D - LDA $0000,y STA $04,x INY INX DEC $02 BNE - LDA #$FF STA $04,x RTS ..upload LDA #!bank8 STA $4324 REP #$10 LDX #$1300|!addr - LDA $0000,x BMI ..init STA $2117 LDA $0001,x STA $2116 LDA $0003,x STA $2115 ASL REP #$20 LDA $0002,x AND #$00FF STA $4325 STA $00 LDA #$1800>>1 ROL STA $4320 TXA CLC ADC #$0004 STA $4322 ADC $00 TAX SEP #$20 LDA #$04 STA $420B BRA - ..init LDA #$FF STA $1300|!addr STZ $3D SEP #$10 RTS ;---------------------------------------------------------------------------------------- counters: incsrc counters.asm menupal: incbin menupal.bin if !worldpalettes worldpal: incbin worldpalettes.bin endif !b = "skip 0" !c = "skip 0" !d = 0 !e = 0 macro world(num, ...) assert !e < 16,"There are too many worlds!" !e #= !e+1 world: !a #= 0 while !a < sizeof(...) db $-select(greater($,$100),$DC,0) !a #= !a+1 endif .end %variadicmacrosaresux(, !a-1) endmacro macro variadicmacrosaresux(num, len) assert < !listlen,"World has too many levels!" !b := "!b : dw world" !c := "!c : dw " !d #= !d++1 endmacro macro levels(lbl, ...) : !a #= 0 while !a < sizeof(...) db $-select(greater($,$100),$DC,0) !a #= !a+1 endif .end endmacro macro sp(lbl, ...) : !a #= 0 while !a < sizeof(...) db $-select(greater($,$100)¬(!a%4),$DC,0) !a #= !a+1 endif .end endmacro macro st(lbl, ...) : !a #= 0 while !a < sizeof(...) db $-select(greater($,$100)¬(!a%2),$DC,0) !a #= !a+1 endif .end endmacro incsrc levelnames.cfg worldptrs: !b .end worldlen: !c .end db !d ; madeulook