Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
1 user currently in Super Mario World hacking: |
Acmlm's Board - I2 Archive - Super Mario World hacking - Learning SMW ASM [ASM howto] | | | |
Pages: 1 2 3 4 5 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Glyph Phoenix Level: 39 Posts: 599/745 EXP: 385876 For next: 18895 Since: 11-07-04 Since last post: 2 hours Last activity: 2 hours |
| ||
Ha ha. Figures, of all games with a life bar to pick you picked the one for SNES that happened to have NES graphics in one of the only times that it mattered. This sort of thing happens to me all the time. Now push it to the floor. | |||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 1906/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Well, as another part of my little series on ASM, I'm going to do the commands ADC and SBC.ADCADC stands for ADd with Carry. It is used for addition, and also uses the carry flag as an extra number (sort of). To use ADC for normal addition, you first want to clear the carry flag with the instruction CLC (CLear Carry flag). After that, you simple use the command ADC ____, such as ADC #$88 or ADC $1A76. In both of these examples, the value after ADC is added to the accumulator, for the first, that's $88, and for the second that's the value at $1A76 in RAM. Let's say that A was originally $20, and $1A76 is $10. With the carry flag cleared, the results would be $A8 and $30, respectively. However, if the carry flag is set, then the results would have been $A9 and $31, respectively. See the difference? SBCSBC stands for SuBtract with Carry. It is the opposite of ADC, and also affects the accumulator. Like ADC, to subtract properly the carry flag must be cleared (Use CLC). So, with A still being $20, and $1A76 still $10, here are the results for SBC #$18 and SBC $1A76 with the carry flag cleared- $08 and $10, respectively. Although you may guess what SBC will output with the carry flag set, I'll mention it anyways- $07 and $0F, respectively. That ends the mini-tutorial on ADC and SBC EDIT: Whoa, why'd the post get so big? (edited by HyperHacker on 10-08-05 04:45 PM) (edited by Sukasa on 10-08-05 07:15 PM) |
|||
TapTap Nipper Plant Level: 24 Posts: 192/405 EXP: 68995 For next: 9130 Since: 08-22-05 From: Yoshi's Island Current Posting Mode: Spree Since last post: 7 hours Last activity: 6 hours |
| ||
Aw, man, can that be sized down a bit? that just... takes a lot of scrolling... | |||
Glyph Phoenix Level: 39 Posts: 617/745 EXP: 385876 For next: 18895 Since: 11-07-04 Since last post: 2 hours Last activity: 2 hours |
| ||
The funny part is that he calls it a mini tutorial. I'll add it to the front post, and update a bunch of other stuff I should have updated already. |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 7546/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Psst... < |
|||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 1908/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
I did close the tags though...The Transfer CommandThe transfer command is composed of 3 parts, and has a sort of 'syntax' associated with it. Fisrt, there is the letter "T", followed without a space by the source register (A, X, Y, etc.) Thirdly, theere is the destination register (A, X, Y, etc.), Except during accumulator/direct page transfers. Then, A is represented by "C". An example of the Transfer command would be TAX, which copies the contents of A to X. TXA, which does the opposite, X into A. Valid source and destination registers are: A / C - Accumulator X - X Register Y - Y Register D - Direct page S - Stack The list of valid Transfer commands is as follows: TAX - Transfer Accumulator to X TAY - Transfer Accumulator to Y TCD - Transfer Accumulator to Direct Page TCS - Transfer Accumulator to Stack TSC - Transfer Stack to Accumulator TSX - Transfer Stack to X TXA - Transfer X to Accumulator TXS - Transfer X to Stack TXY - Transfer X to Y TYA - Transfer Y to Accumulator TYX - Transfer Y to X (edited by Sukasa on 10-08-05 07:24 PM) (edited by Sukasa on 10-08-05 07:25 PM) |
|||
Dark Ludwig Red Paratroopa Level: 21 Posts: 149/172 EXP: 45740 For next: 4203 Since: 09-17-04 From: Georgia Since last post: 9 days Last activity: 2 days |
| ||
Ah, what the heck. Here's my contribution. COMPARE (also CPX & CPY) The CMP command will compare a value with the one held by the accumulator, or one of the registers. In cases in which it's absolute, it does so with a RAM value, in bank 7E (usually). Glyph didn't go into full detail about the processor status flags, there are 8 (Overflow, Negative, Zero, Decimal, Interrupt, and Carry; I forgot what the M and X flags do). All you're going to have to worry about are the Negative, Zero, and Carry flags, since that's all CMP/CPX/CPY can mess with. The CMP instruction will check to see how large the number in the accumulator is, and how large the number it's comparing it to is: If the number in the accumulator is less than the immediate/memory value, it will set the Negative flag. If the number in the accumulator is greater than the immediate/memory value, it will set the Carry flag. If the number in the accumulator is equal to the immediate/memory value, it will set the Zero flag. The CPX instruction will do the same thing, but with the X register in place of the accumulator. The CPY instruction will do the same thing, but with the Y register in place of the accumulator. Now, branch instructions will usually operate depending upon which flags are or are not set. If you had 5 in the accumulator, and you compared it with 6, it would set the Negative flag, obviously, since the number in the accumulator is less than that of operand. Then, if you had a BMI branch instruction (Branch if MInus, branches if Negative flag is set), it would branch. A BNE (Branch if Not Equal, branches if the Zero flag is not set) would branch because the Zero flag is not set, since the compare didn't affect it. However, a BPL (Branch if PLus, branches if the Carry flag is set) would not branch, since the compare didn't affect the Carry flag. I hope that was understandable. Some of the most useful compare opcodes are: C9: CMP immediate Syntax: C9 XX (XX) <--If the accumulator's in 16-bit mode. -Compares the value in the accumulator with the next number. CD: CMP absolute Syntax: CD XX XX -Compares the value in the accumulator with the two-byte RAM address after the CMP absolute, always in bank 7E. CF: CMP long Syntax: CF XX XX XX -Compares the value in the accumulator with the three-byte RAM address after the CMP long, any bank. E0: CPX immediate Syntax: E0 XX -Comapres the value in the X register with the next number. C0: CPY immediate Syntax: C0 XX -Compares the value in the Y register with the next number. There are also several, less-used comparing opcodes, see 65816REF.HLP to view them, too. Hope this helps. |
|||
Ghettoyouth Paragoomba Level: 13 Posts: 51/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
i know how to load sound effects, but how can i play a soundeffect on every 8th frame? can anyone help me with this? (edited by Ghettoyouth on 10-18-05 11:23 AM) |
|||
Dark Ludwig Red Paratroopa Level: 21 Posts: 153/172 EXP: 45740 For next: 4203 Since: 09-17-04 From: Georgia Since last post: 9 days Last activity: 2 days |
| ||
Have a counter triggered every frame by LevelASM. Decrement it each frame, and have it do nothing. But, once it reaches 0, have it trigger the sound effect and load 8 into some spare ram value for the counter. | |||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 1923/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Ehh, wrong. Not always bank 7E, but whatever the direct page is set to. (use lda #$xx tcd for example) You could use that to compare a value with a hardware register or whatever. | |||
knuck Hinox Banned until 19-58-5815: trolling, flaming, spamming, being a general fucktard... Level: 62 Posts: 1729/1818 EXP: 1894574 For next: 90112 Since: 03-15-04 Since last post: 14 hours Last activity: 9 hours |
| ||
ASM is easy. Tracing is another thing... | |||
Ghettoyouth Paragoomba Level: 13 Posts: 52/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
Originally posted by Dark Ludwig sorry but i didn't understand anything Edit: i tried it this way: AD 13 00 C9 08 D0 05 A9 03 8D F9 1D 6B it plays a constantly a sound effect, but not on the 8th frame O_o whats wrong with this code? Edit2: AD 13 00 C9 58 D0 05 A9 03 8D F9 1D 6B now it plays sfx every 2nd, 8th frame (edited by Ghettoyouth on 10-19-05 10:02 AM) (edited by Ghettoyouth on 10-19-05 11:10 AM) (edited by Ghettoyouth on 10-19-05 11:45 AM) |
|||
Dark Ludwig Red Paratroopa Level: 21 Posts: 156/172 EXP: 45740 For next: 4203 Since: 09-17-04 From: Georgia Since last post: 9 days Last activity: 2 days |
| ||
Find an empty RAM place, and use it instead of 7E0013. Try: LDA (RAM value) CMP $00 BEQ (next LDA) DEC (RAM value) RTS LDA $08 STA (RAM value) LDA (Sound effect) STA (Sound register) RTS I don't have time to convert it to numbers, as I have to go to school. *leaves* (edited by Dark Ludwig on 10-20-05 08:03 AM) |
|||
Ghettoyouth Paragoomba Level: 13 Posts: 53/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
i don't know why but it doesn't work this is the way i typed it in the hex editor: AD 00 C1 C5 00 F0 06 3A C6 00 C1 6B A9 08 8D 00 C1 A9 4A 8D FC 1D 6B the sfx is only played one time at the beginning of the level. (edited by Ghettoyouth on 10-20-05 10:14 AM) |
|||
Dark Ludwig Red Paratroopa Level: 21 Posts: 157/172 EXP: 45740 For next: 4203 Since: 09-17-04 From: Georgia Since last post: 9 days Last activity: 2 days |
| ||
I'm back from school now. Instead of: AD 00 C1 C5 00 F0 06 3A C6 00 C1 6B A9 08 8D 00 C1 A9 4A 8D FC 1D 6B Try: AD 00 C1 C9 00 F0 04 CE 00 C1 6B A9 08 8D 00 C1 A9 4A 8D FC 1D 6B In your code, in place of the decrement instruction decrementing memory, you were having it decrement the accumulator. As for the compare instruction, you were having it compare direct page, not memory. Also, your branch was one too high. I tuned it down two, though, since the compare instruction caused me to have to take one out. Whenever I have the time, which I rarely do, I use geiger's SNES9X debugger to check my work and disassemble data. Here's what I just put up there turns out to look like: $00/8000 AD 00 C1 -- LDA $C100 $00/8003 C9 00 -- -- CMP #$00 $00/8005 F0 04 -- -- BEQ $04 $00/8007 CE 00 C1 -- DEC $C100 $00/800A 6B -- -- -- RTL $00/800B A9 08 -- -- LDA #$08 $00/800D 8D 00 C1 -- STA $C100 $00/8010 A9 4A -- -- LDA #$4A $00/8012 8D FC 1D -- STA $1DFC $00/8015 6B -- -- -- RTL As of yet, it's still untested, as I have homework. This should work though. (edited by Dark Ludwig on 10-20-05 08:27 PM) |
|||
Ghettoyouth Paragoomba Level: 13 Posts: 54/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
thanks man, i'll try it after school edit: hmm doesn't work. i can't hear the sfx (edited by Ghettoyouth on 10-21-05 08:13 AM) |
|||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 1931/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Wow, I'm amazed it didn't crash. Change the RTL's to RTS's, then try moing around while you're touching the block if you don't already, with top, sides, and bottom offsets set at 0. If it still doesn't work, change the lda and sta statements to 24-bit addresses (lda $7EC100 instead of lda $C100, sta $7E1DFC instead of sta $1DFC, etc.) and try that. | |||
Ghettoyouth Paragoomba Level: 13 Posts: 55/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
if change RTL to RTS it'll crash because i use level asm and the thing with the 24-bit adresses doesn't work too | |||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 1933/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Oh, levelASM (missed that). Why won't the 24-bit addresse work? how did you store that addresses? They should be in hex like this: 7E1DFC = FC 1D 7E in the .bin file. | |||
Ghettoyouth Paragoomba Level: 13 Posts: 56/73 EXP: 9433 For next: 834 Since: 03-18-05 From: Herford, Germany Since last post: 17 hours Last activity: 16 hours |
| ||
this is the way i typed it in: AF 00 C1 7E C9 00 F0 04 CE 00 C1 6B A9 08 8F 00 C1 7E A9 4A 8F FC 1D 7E 6B |
Pages: 1 2 3 4 5 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Super Mario World hacking - Learning SMW ASM [ASM howto] | | | |