Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,507,208
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 05-01-24 05:24 PM
Guest: Register | Login

0 users currently in SMW Hacking | 1 guest

Main - SMW Hacking - ASM Hack Doesnt Work D= [Solved] New thread | New reply


Darknoob
Posted on 05-27-10 10:57 PM Link | Quote | ID: 131513


Micro-Goomba
Level: 9

Posts: 3/11
EXP: 2603
Next: 559

Since: 05-22-10

Last post: 5085 days
Last view: 5006 days
ok i have created a ASM hack but something is wrong with it

Heres The Code:

dcb "INIT"
RTL

dcb "MAIN"
LDA $00 ;makes ON/OFF Swtich OFF (Works)
STA $14AF ;Save Status
LDA $0DBF ;Loads Marios Coins
CMP #30 ;If Marios Coins Is Less Than 30
BCC Return ;Return
LDA $01 ;makes ON/OFF Swtich ON (Not Works)
STA $14AF ;Save Status (Not Works)
RTL
Return:
RTL

Ok so Wheres The Error?
Did I Miss Something?

____________________
Hi All!

Kiokuffiib11
Posted on 05-27-10 11:05 PM (rev. 3 of 05-27-10 11:13 PM) Link | Quote | ID: 131514


Porcupo
Level: 40

Posts: 97/313
EXP: 407255
Next: 34054

Since: 07-10-09
From: Marquette, Michigan

Last post: 3317 days
Last view: 1940 days
Posted by Darknoob
ok i have created a ASM hack but something is wrong with it

Heres The Code:

dcb "INIT"
RTL

dcb "MAIN"
LDA $00 ;makes ON/OFF Swtich OFF (Works)
STA $14AF ;Save Status
LDA $0DBF ;Loads Marios Coins
CMP #30 ;If Marios Coins Is Less Than 30
BCC Return ;Return
LDA $01 ;makes ON/OFF Swtich ON (Not Works)
STA $14AF ;Save Status (Not Works)
RTL
Return:
RTL

Ok so Wheres The Error?
Did I Miss Something?


I don't know too much about programming, but I think the return should be AFTER the STA $14AF

See above your return works and below it, it does not.

Therefore where the RTL is, I would say replace that with the BCC return.

Don't forget to remove the original BCC return.

____________________
セシル

zkip
Posted on 05-28-10 12:43 AM Link | Quote | ID: 131515


Level: 15

Posts: 14/34
EXP: 14284
Next: 2100

Since: 02-13-10

Last post: 4184 days
Last view: 3058 days


~zkip:
Okay, lets see here. Quick lesson: LDA $00 puts the VALUE of the RAM address $00 into the accumulator. $00-$01 aren't needed here. So, try this:

dcb "INIT"
RTL

dcb "MAIN"
LDA $0DBF
CMP #$30
BCC Return
LDA #$01
STA $14AF
Return:
RTL


I erased one of the RTL's are it's not needed, that's just wasting cycles. (Okay, it's just 6, but code efficiency is important!)

I didn't test this, but I should work. Also, I'm guessing this is a generator to be inserted with spritetool, remember, generators run from the moment you walk into the screen they're on until the end of the level. That being said I removed the first 2 lines as it would useless to set it to 00 all the time.

____________________



Kiokuffiib11
Posted on 05-28-10 02:50 AM (rev. 2 of 05-28-10 03:01 AM) Link | Quote | ID: 131518


Porcupo
Level: 40

Posts: 98/313
EXP: 407255
Next: 34054

Since: 07-10-09
From: Marquette, Michigan

Last post: 3317 days
Last view: 1940 days
That's kind of interesting.

Sou if I'm understanding this, the STA $14AF was making the rest of the code not work?

Or was it the LDA $00 that was overloading the memory, thus not allowing it to work?



---------------------------Edit-------------------------------------------------------------
OH!

Upon looking at this a bit closer, it looks like the return to RTL returned to the later RTL not the first RTL, therefore after it got done with the sequence the first time, it went to the last RTL, which didn't have any code after it, therefore creating an endless empty loop.

Eg:"

RTL
Return:
RTL

"

This would send the loop back to the previous RTL (Shown here) looping it endlessly with nothing in between those two commands. Am I right?

____________________
セシル

blackhole89
Posted on 05-28-10 03:14 AM Link | Quote | ID: 131519


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3124/4196
EXP: 21541981
Next: 294620

Since: 02-19-07
From: Ithaca, NY, US

Last post: 476 days
Last view: 89 days



Sorry, but I don't think RTLs work like that.

First of all, you should state what exactly your code is *supposed* to do; without that, the information that it doesn't do what it is supposed to do is not very valuable.

Secondly, as DarkBoyHacker pointed out, it seems to me like your parameter sigils might be off. If you want to load a particular "constant" (immediate) byte into the accumulator, you should prefix it with #$, i.e. LDA #$00, LDA #$01 etc.; the same also goes for your CMP instruction, i.e. you probably want CMP #$30.

There is nothing wrong with your returning strategy; it just had one RTL tht you didn't really need as something like bcc return, ..., return: RTL would have sufficed. The "label:" thing does not correspond an actual opcode - it's just a clue for the compiler to record the position the next opcode winds up at and use it for branches which go off to that label.

____________________



Darknoob
Posted on 05-28-10 07:24 AM (rev. 4 of 05-28-10 07:25 AM) Link | Quote | ID: 131535


Micro-Goomba
Level: 9

Posts: 4/11
EXP: 2603
Next: 559

Since: 05-22-10

Last post: 5085 days
Last view: 5006 days
LDA $00 Was Needed Because It Shall Set The ON/OFF Switch To OFF and that works.
The last one i added: LDA $01 (That shall Set the ON/OFF Status to ON) Doesnt Work


____________________
Hi All!

blackhole89
Posted on 05-28-10 02:07 PM Link | Quote | ID: 131539


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3126/4196
EXP: 21541981
Next: 294620

Since: 02-19-07
From: Ithaca, NY, US

Last post: 476 days
Last view: 89 days



Are you even listening? "LDA $00" doesn't necessarily load 00 into the accumulator, and "LDA $01" doesn't necessarily load 01. "LDA $00"/"LDA $01" and "LDA #$00"/"LDA #$01" are different things respectively, and you want to do the latter.

____________________



Darknoob
Posted on 05-28-10 03:39 PM Link | Quote | ID: 131540


Micro-Goomba
Level: 9

Posts: 5/11
EXP: 2603
Next: 559

Since: 05-22-10

Last post: 5085 days
Last view: 5006 days
Thanks Blackhole89!
Also Heres The Working Code =D

dcb "INIT"		;INIT
RTL ;Return
dcb "MAIN" ;MAIN
LDA #$01 ;makes ON/OFF Swtich OFF (Works)
STA $14AF ;Save Status
LDA $0DBF ;Loads Marios Coins
CMP #50 ;If Marios Coins Is Less Than 50
BCC Return ;Goto Return
LDA #$00 ;makes ON/OFF Swtich ON
STA $14AF ;Save Status
Return: ;Return Label
RTL ;Return



It makes ON/Off Switch ON When Entering The Same Screen As The Sprite.
If Mario's Coins Is Less Than 50 It Will Return
Else It Will Change Switch Status To ON


Thanks For The Help!

____________________
Hi All!

Main - SMW Hacking - ASM Hack Doesnt Work D= [Solved] New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.022 seconds. (341KB of memory used)
MySQL - queries: 57, rows: 84/85, time: 0.016 seconds.