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

0 users currently in SMW Hacking | 1 guest

Main - SMW Hacking - HEX problems New thread | Thread closed


cory21391
Posted on 05-14-07 08:46 PM Link | Quote | ID: 35284


Flurry
Level: 37

Posts: 1/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
Well, I'm learning hex (trying to) and asm, trying to make custom blocks. well, i had an idea, and here was my thought progression of code:

AD 0D BF 5A A8 C9 32 B0 AD 0D B4 1A 8D 0D B4 A8 0D BF 7A 60

AD: LDA 0DBF (mario's coin value)

5A: PHY (push whats currently in the y reg to the stack)

A8: TAY (transfer Accumulator to y reg)

C9 32: compare y reg to 32 (50 in deimal) (carry flag set if 32>y reg)

B0: BCS branch if the carry flag is set (32>y reg, which is mario's coins)

AD 0DB4 LDA abs 0DB4 (mario's lives)

1A increment marios lives by 1

8D 0DB4 Store accumulator to abs 0DB4 (marios lives)

A8 trasfer y to accumulator

8D 0DBF STA abs 0DBF (marios coins) (y reg is coin value)

60 return from subroutine


i thought this would compare marios coind to 32 (50) and if greater, it would give an extra life

i set all offsets to -1 except above to 0; and it freezes the game. any thoughts?

____________________




Smallhacker
Posted on 05-14-07 10:18 PM (rev. 2 of 05-14-07 10:20 PM) Link | Quote | ID: 35308


Panser
Swedish weirdo times eleven

Level: 42

Posts: 86/339
EXP: 494874
Next: 26488

Since: 02-19-07
From: Stockholm, Sweden

Last post: 5195 days
Last view: 5194 days
For RAM and ROM addresses, you have to switch the byte order.

2 byte addresses:
AB CD
becomes
CD AB


3 byte addresses:
AB CD EF
becomes
EF CD AB

Also, you forgot to push Y from the stack.

____________________
SMW Central

Ninetales
Posted on 05-14-07 10:30 PM (rev. 2 of 05-14-07 10:36 PM) Link | Quote | ID: 35310


Panser
Level: 42

Posts: 260/338
EXP: 492682
Next: 28680

Since: 02-19-07

Last post: 5521 days
Last view: 4919 days
Posted by Smallhacker
Also, you forgot to push Y from the stack.
I think you meant pull Y from the stack. He already used a PHY statement.

Bio
Posted on 05-14-07 10:34 PM Link | Quote | ID: 35314


Red Paragoomba
Level: 19

Posts: 32/58
EXP: 35021
Next: 756

Since: 02-19-07

Last post: 5844 days
Last view: 5707 days
Posted by cory21391
C9 32: compare y reg to 32 (50 in deimal) (carry flag set if 32>y reg)

CPY is C0 in hex, not C9

It's nice to see more people are having interrest in Hex/ASM, we need more ASM hacker

cory21391
Posted on 05-14-07 11:20 PM (rev. 2 of 05-14-07 11:29 PM) Link | Quote | ID: 35327


Flurry
Level: 37

Posts: 2/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
thans, i didnt know if i had to reverse the byte order for the rom/ram addresses or not in opcodes. and whoops... "pull Y from the stack"

oh, and i wasnt sure if that was how you used branch statements and carry flags or not.

and do i have to push to stack from y/pull from stack to y? i did that to clear the y register just in case, but idk... (working on it lol)

im trying to get a general feel of how the accumulator works (which i pretty much get, tis kinda simple), as weel as the x and y registers, carry and zero flags, the 'stack,' and the increment/decrementing and opcodes etc. that im just learning by practicing/learning how different opcodes work.

next is add w/ carry, subtract w/ carry. and damn does 65816ref help file really actually HELP

well, to more practice and work on my hack
(working on Super Mario Journey, which ive actually canned everything and started over from scratch)


EDIT: it still doesnt work, heres my code:



any thoughts as to why?

____________________




Bio
Posted on 05-14-07 11:36 PM (rev. 2 of 05-14-07 11:36 PM) Link | Quote | ID: 35330


Red Paragoomba
Level: 19

Posts: 33/58
EXP: 35021
Next: 756

Since: 02-19-07

Last post: 5844 days
Last view: 5707 days
you're suppose to add the number of bytes to skip after the BCS instruction

cory21391
Posted on 05-14-07 11:38 PM (rev. 3 of 05-15-07 12:04 AM) Link | Quote | ID: 35332


Flurry
Level: 37

Posts: 4/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
OMFG now i feel like a dumbass thanks tho

now lets try this one more time...

EDIT: well, now my code is



the gfxfor the block dont show up at all (its invisible) and when i touch it (i go through it even though its set to act like 130) and then the game glitches up as though the framerate has dropped

urg.... hex is pretty complicated, but im not giving up yet! although im out of ideas and could use a tiny bit more help

EDIT2: i went here (http://www.smwcentral.net/?p=map&type=ram) and found that the marios coin counter was wrong (fixed it to 0DB6 [B60D byteswapped]) and still the same, but i'd like to add the fact that all the the offsets in blocktool are -1, except above, which is 0. and when i edit the map16 block data to act like 130, it reverts to 29

any ideas of wuts wrong?

____________________




Smallhacker
Posted on 05-15-07 07:24 AM (rev. 2 of 05-15-07 07:25 AM) Link | Quote | ID: 35501


Panser
Swedish weirdo times eleven

Level: 42

Posts: 87/339
EXP: 494874
Next: 26488

Since: 02-19-07
From: Stockholm, Sweden

Last post: 5195 days
Last view: 5194 days
"when i edit the map16 block data to act like 130, it reverts to 29 "
After changing that setting, did you right click on the block to update it, and then press F9 to save it?

Anyway. This is what your code does:
LDA $0DBF	;\
PHY ; |Load A and Y with Mario's coins, remember old value of Y
TAY ;/
CPY #$32 ;\ If Y>=x32, branch to BrEnd
BCS #$07 ;/
LDA $0DB4 ;\
INC A ; |Otherwise, increase Mario's lives
STA $0DB4 ;/
: BrEnd
TAY ;Does nothing of interest
STA $0DBF ;If lives were increased, store lives to coins, otherwise, store coins to coins
PLY ;Bring back old value of Y
RTS ;End of block

In short:
If Mario's Coins >= x32, increase Mario's lives and set Mario's coins to Mario's lives.

One of the mistakes you've made is to use the Mario's Coins and Mario's Lives addresses. These are the correct ones:
$0DBE for lives, $0DBF for coins. The Mario's Coins/Lives are only used to remember Mario's Coins/Lives while playing as Luigi. $0DBE and $0DBF are used by the current player. (I have renamed those two address to be less confusing.)

____________________
SMW Central

cory21391
Posted on 05-15-07 10:47 PM (rev. 3 of 05-15-07 11:03 PM) Link | Quote | ID: 35628


Flurry
Level: 37

Posts: 6/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
well thank you for the explanation, ecspecially about the addresses

(SMW Central ROM/RAM map just said 'mario's lives' and 'mario's coins' so i assumed they were the ones to use)

"STA $0DBF; If lives were increased, store lives to coins, otherwise, store coins to coins"

thanks, i didnt know exactly how that opcode worked, i assumed it did nothing but increment the following address if the carry flag was set

so if i just take out the part after the increment and fix the addresses, it should check to see if mario's coins>x32 and if so increment lives by 1, if not, just skip the increment opcode and return from subroutine, right?

EDIT: and yea, i forgot to save w/ F9; i just got back into SMW hacking like 5 days ago (after like 8 months of not hacking anything) so I'm a little rusty

EDIT AGAIN: well, i got it to work somewhat at least, it gave me like 53 lives (YEAH! ) when i stood on it from the top, but for some reason, the GFX for the block still dont show up.

____________________




Smallhacker
Posted on 05-16-07 06:51 AM (rev. 2 of 05-16-07 06:52 AM) Link | Quote | ID: 35745


Panser
Swedish weirdo times eleven

Level: 42

Posts: 88/339
EXP: 494874
Next: 26488

Since: 02-19-07
From: Stockholm, Sweden

Last post: 5195 days
Last view: 5194 days
I would just like to clearify why "STA $0DBF ;If lives were increased, store lives to coins, otherwise, store coins to coins" does what it does

LDA $0DBF	;<--- Here, A is set to amount of coins
PHY
TAY
CPY #$32
BCS #$07 ;<--- Ignore the following three lines if Y is equal to or greater than x32
LDA $0DB4 ;<--- On this and the next line, A is set to amount of lives+1
INC A ;(but is jumped past if Y is less than x32)
STA $0DB4
: BrEnd
TAY
STA $0DBF ;<--- Store A to coins.
PLY
RTS


____________________
SMW Central

cory21391
Posted on 05-16-07 10:44 PM Link | Quote | ID: 35847


Flurry
Level: 37

Posts: 8/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
I got the branch statement confused, it BRANCHES IF the carry flag is set (which is if coins>=x32) so i should change that to a branch if carry clear opcode, that way, if the carry flag is set, it reads the next 7 bytes, but if it isnt set, it skips them

but after the branch
TAY
STA $0DBF

i meant to put 98 (TYA) instead of (TAY)

heres my new code (hope its right now)

AD BF 0D A8 C9 32 90 07 AD B4 0D 1A 8D B4 0D 98 8D BF 0D 60

AD BF0D (LDA BF 0D marios coins)

A8 (TAY)

C9 32(CPY to x32; set carry flag if >= x32; clear carry flag if
90 07 (BCC 07 skips 7 bytes if carry flag is clear, read the next code if carry is set)

AD B40D (LDA B40D mario's lives)

1A (INC adds 1 to A (mario's lives))

8D B40D (STA B40D; stores A (marios lives) to marios lives address)

98 (TYA transfers y (marios coins) to A)

8D BF0D (STA BF0D stores A (marios coins) to marios coins address)

60 (RTS Return from subroutine)

____________________




Smallhacker
Posted on 05-17-07 02:17 AM Link | Quote | ID: 35901


Panser
Swedish weirdo times eleven

Level: 42

Posts: 93/339
EXP: 494874
Next: 26488

Since: 02-19-07
From: Stockholm, Sweden

Last post: 5195 days
Last view: 5194 days
Posted by cory21391
AD B40D (LDA B40D mario's lives)


I told you to use 0DBE instead of 0DB4, remember?

____________________
SMW Central

cory21391
Posted on 05-17-07 10:52 PM (rev. 2 of 05-17-07 11:04 PM) Link | Quote | ID: 36058


Flurry
Level: 37

Posts: 10/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
whoops

well, im getting better (i think, hope so anyways )

now how would i go about stopping it from giving an extra life every time you touch it with more than 50 coins?

____________________




cory21391
Posted on 05-19-07 10:01 PM Link | Quote | ID: 36497


Flurry
Level: 37

Posts: 11/260
EXP: 332135
Next: 6118

Since: 03-01-07
From: NC, US

Last post: 5138 days
Last view: 5138 days
this thread can be closed now

____________________




Main - SMW Hacking - HEX problems New thread | Thread closed

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

Page rendered in 0.027 seconds. (339KB of memory used)
MySQL - queries: 102, rows: 135/136, time: 0.018 seconds.