PHO - Pokémon Hackers Online
Go Back   PHO - Pokémon Hackers Online > Discussion Board > Archive > Questions & Answers

Notices

Questions & Answers Do you have a problem you need a straight answer for? Ask a question here and get an answer.

Reply
 
Thread Tools Display Modes
Old 31st January 2014, 04:40 PM   #1
Javi4315♪
Newbie
 
Javi4315♪'s Avatar
 
Join Date: Mar 2012
Age: 24
Posts: 4
Javi4315♪ is on a distinguished road
Default Help with ASM routine

Hi, I am trying to do something, but I would need that this routine saves the seconds in a variable. It is a routine to start a timer by JPAN, but I don't know if it is possible to save in a variable. I have tried several things, but I can't do it.

Code:
.align 2
.thumb

/*Special 0x46 Starts the timer*/

special_46: 	push {lr}
		ldr r0, timer_1
		mov r1, #0x0
		strb r1, [r0, #0x4]
		mov r1, #0x84
		strb r1, [r0, #0x6]
		mov r1, #0xc0
		lsl r1, r1, #0x8
		strh r1, [r0, #0x0]
		mov r1, #0x83
		strb r1, [r0, #0x2]
		pop {pc}
timer_1: .word 0x04000108
It would be possible?
For example, if I want to save the seconds in the variable 0x8000 (or another).

Sorry for my english xD
Javi4315♪ is offline   Reply With Quote
Sponsored Links
Old 31st January 2014, 06:29 PM   #2
Miksy91
Gotta fill something here.
 
Miksy91's Avatar
 
Join Date: Jul 2013
Location: Northern Europe
Age: 27
Posts: 117
Miksy91
Default

I'd imagine variables being normal pointers to a 1-byte data value.
If you know where a certain variable points to, you can directly store the seconds in those ram addresses, and it will work the way you want it.

(I'm pretty sure someone here can tell where the "table of the 1-byte values" is that all variables point to. I have never worked with gen III, so this is just a guess and I can't really help you out any more than this.)
__________________
Miksy91 is offline   Reply With Quote
Old 31st January 2014, 10:11 PM   #3
karatekid552
What does this button do?.....
Ex-Staff
 
karatekid552's Avatar
 
Join Date: Feb 2013
Location: Stalker.......
Posts: 229
karatekid552 karatekid552
Default

Miksy91, you are right. Variables are half-words and you can find their offset in HackMew's tutorials.
karatekid552 is offline   Reply With Quote
Old 1st February 2014, 11:25 AM   #4
Javi4315♪
Newbie
 
Javi4315♪'s Avatar
 
Join Date: Mar 2012
Age: 24
Posts: 4
Javi4315♪ is on a distinguished road
Default

Are you talking about change the offset 0x04000108 for the offset of the variable directly?
If it is, I have already tried it, but doesn't work.

Maybe I am not understanding... xD
Javi4315♪ is offline   Reply With Quote
Old 1st February 2014, 01:37 PM   #5
Miksy91
Gotta fill something here.
 
Miksy91's Avatar
 
Join Date: Jul 2013
Location: Northern Europe
Age: 27
Posts: 117
Miksy91
Default

I have no idea what you are trying to achieve exactly (have never bothered to learn ARM/Thumb assembly, so I don't know what your routine does), but like karatekid552 mentioned, you can access the addresses that the variables point to directly if you want by checking HackMew's documentation.

If you for some reason want to store the playing time, that could be a 3-byte value containing hours, minutes and seconds, in variables, you could call an asm routine that transfers the hours to variable 0x8000, minutes to 0x8001 and seconds to 0x8002 (if it is safe to use those variable numbers).

Code:
ld r1, ($tableWhereVariablesAreInRAM)
ld r2, ($hours) // ($minutes) and ($seconds) follow this
ld r3, 00000003
ld r5, 00000001
 
while (r3 > 0)
  ld r4, (r2)
  store r4, (r1)
  add r1, r5
  add r2, r5
  sub r3, r5
That was just an example of what the instructions could be like.
__________________
Miksy91 is offline   Reply With Quote
Old 1st February 2014, 02:20 PM   #6
Andrea
Beginner
 
Join Date: Oct 2013
Posts: 35
Andrea
Default

I haven't tried but I think the routine goes well, if it is wrong correct me.
Spoiler:

.thumb
.align 2

push {lr}
ldr r0, .8000 //var8000
ldr r1, .timer_1 //timer
strb r1,[r0]
pop {pc}

.align 2

.8000:
.word 0x0202E8C4
.timer_1:
.word 0x04000108
Andrea is offline   Reply With Quote
Old 1st February 2014, 08:09 PM   #7
Javi4315♪
Newbie
 
Javi4315♪'s Avatar
 
Join Date: Mar 2012
Age: 24
Posts: 4
Javi4315♪ is on a distinguished road
Default

I think I am doing it wrong. It doesn't work...
How would the complete routine be?
Javi4315♪ is offline   Reply With Quote
Reply

Tags
asm, routine

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:21 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc. User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo.
Pokémon Hackers Online (PHO) is in no way affiliated with or endorsed by Nintendo LLC, Creatures, GAMEFREAK inc,
The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast.
All forum/site content (unless noted otherwise) and site designs are © 2006-2013 Pokémon Hackers Online (PHO).
Green Charizard Christos TreeckoLv100

"Black 2" by ARTPOP. Kyurem artwork by XOUS.

no new posts