Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Something I've been working on...

  1. #1
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default Something I've been working on...

    I was bored the last few days, so I've been working on this.
    It's finished, I'm just thinking about adding a few things
    I'll make it better once I figure out why the "clz count leading zeroes" instruction freezes...



    Always willing to help with anything, code-related or not. :]

  2. The Following 2 Users Say Thank You to dragonboy269 For This Useful Post:


  3. #2

    Default

    I never knew r10 could be used in thumb (or ARM, but thumb mostly).
    3DS Friend Code: 4699-6293-3106

  4. #3
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    I just found out THUMB has a divide instruction :P
    Code:
    sdiv r0, r1, r0
    that's a signed divide, and
    Code:
    udiv r0, r1, r0
    that's unsigned

    It freezes though...
    maybe I'm using it wrong


    Probably cause it's not supported I guess
    Always willing to help with anything, code-related or not. :]

  5. #4
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    I noted the calculations part for RTWE.
    Well, actually here's a simple code that places red tulips under you when you're outside.

    L+R+A
    Code:
    94000130 FCFE0000
    023FF090 012FFF11
    E0000000 00000048
    E28F2001 E12FFF12
    68244C0D 00D222A9
    68231AA4 68A20B5B
    3B100B52 210F3A10
    4019240F 4014091B
    00490912 025B0164
    186402D2 18E418A4
    22004902 4770530A
    021C6DEC 021E3124
    023FF090 E3520003
    D2000000 00000000
    Noted Source (you can probably understand this Demonic)
    Code:
    .set LRA, 0x301
    
    /* Make our activator line
     * activator is L+R+A
     */
    
    .long 0x94000130
    .short 0x0,0 !LRA
    
    .long 0x23FF090, 0x12FFF11
    
    .long 0xE0000000, Code_End-Code_Begin
    
    Code_Begin:
    @Convert to THUMB
    add r2, pc, #0x1
    bx r2
    .thumb
    
    ldr r4, Coordinates
    ldr r4, [r4]
    
    mov r2, #0xA9
    lsl r2, #3
    sub r4, r2
    ldr r3, [r4] @r3 now holds x coordinate
    
    /*shift to get only 2 digits
     *and divide those digits by 2
     *so we get the number of slots 
     */
    
    lsr r3, #0xD 
    
    ldr r2, [r4, #8] @r2 now holds y coordinate
    lsr r2, #0xD
    
    
    /*subtract #16 because the first acre
     *is above/to the left of the wall
     *so we dont need to use those slots
     */
    sub r3, #0x10
    sub r2, #0x10
    
    BeginDivision:
    mov r1, #0xF
    mov r4, #0xF
    
    /* this will divide by #16 (#0x10)
     * so we can get acres
     * r1 holds remainder
     * r3 holds quotient
     */
    DivideX:
    and r1, r3, r1
    lsr r3, #4
    
    /* r4 holds remainder
     * r2 holds quotient
     */
    DivideY:
    and r4, r2, r4
    lsr r2, #4
    
    /* this will multiply the results
     * each X single slot increments by 0x2
     * so multiply that by 0x2
     * each Y single slot increments by 0x20 (#32)
     * because to increment 1 Y you need 0x10 X (0x10 * 0x2)
     * each X acre increments by #512 (0x200)
     * 16*16 slots in each acre, 256*2 is #512
     * each Y acre increments by #2048 (0x800)
     * to increment 1 Y acre you need 1 X row
     * which is 256*4 = 1024*2 = #2048
     * so multiply by #2048
     */
    lsl r1, #1
    lsl r4, #5
    lsl r3, #9
    lsl r2, #0xB
    
    @now, add the results together to get offset
    add r4, r1
    add r4, r2
    add r4, r3
    
    ldr r1, Map
    mov r2, #0
    
    @store item in slot1 + offset
    strh r2, [r1,r4]
    bx lr
    
    .arm
    Coordinates:
    .long 0x21C6DEC
    Map:
    .long 0x21E3124
    
    Code_End:
    .align 3
    
    .long 0x23FF090, 0xE3520003
    .long 0xD2000000, 0x00000000
    If you compile the ASM source, compile it under nitrohax, and copy everything except the c2 line at the top.
    Always willing to help with anything, code-related or not. :]

  6. The Following User Says Thank You to dragonboy269 For This Useful Post:


  7. #5
    Chris (Administrator) Vash's Avatar
    Join Date
    Sep 2007
    Location
    Teh Interwebz
    Posts
    1,992
    Blog Entries
    27

    Default

    Thumb divide doesn't work in ARM9 for whatever reason. You have to use a "dirty hack" to divide. Check out toenailed's noted RTWE source. He has his version of divide in there. I see you already have your own, though.
    Animal Crossing: City Folk
    ACToolkit - NPC_Tool - PattView

  8. #6
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    Toenailed's divide routine is good for dividing any number by any number. It works in all cases, but it's not always the simplest or fastest method.
    Besides, his RTWE is a lot more complex, but I guess it's more "neat and organized."
    I tried to make mine in a way I could understand, and that's why mine is simplified. I just used animalmap and a calculator to figure it out :P

    Off-topic: this is useful
    http://infocenter.arm.com/help/topic...a/DVI0022A.pdf

    its the exact version that the Nintendo DS has.
    Always willing to help with anything, code-related or not. :]

  9. The Following User Says Thank You to dragonboy269 For This Useful Post:


  10. #7

    Default

    -Removed-
    Last edited by Demonic722; 07-03-2012 at 03:00 AM.
    3DS Friend Code: 4699-6293-3106

  11. #8
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    I added a few features.
    Now you can press L+R+B to store the item underneath you in your first inventory slot, AND in your RTWE saved item.
    If you're using text to item, the "store item in slot" part doesn't work...so I separated it into a subroutine away from the rest of the code. Otherwise the entire code won't work if you're using TII. So everything should work fine.

    New Code for 1.0:

    Code:
    023FF090 012FFF11
    E0000000 000001D4
    E28F2001 E12FFF12
    6801A05E 88093004
    8B024688 D01D4211
    42113201 6881D01A
    8A836809 880B18C9
    42938B42 8B82D03F
    D1554293 2200788B
    D1002B9A 2B983210
    3220D100 D1002B91
    2B933240 3280D100
    43D1468A F00046F4
    4652F844 8B054643
    D006422B 422B3501
    5B0AD106 303C82C2
    8AC2E09A 4760530A
    7015258A 19093202
    240F2303 3901784D
    40251C28 28090900
    303EDC00 70103809
    D4723B01 DC002D09
    3D09353E 32027055
    D5EB3B01 22004760
    3102800A 220F2400
    780B250C 2B063101
    3329DC00 DB002B35
    2B203B05 3B01DC00
    40AB4013 3D0418E4
    82C4D5EF 7784780C
    68C54770 2D05782D
    6804DC4B 22A96824
    1AA400D2 0B5B6823
    0B5268A2 42212420
    3B01D100 42212410
    3301D100 42212440
    3A01D100 42212480
    3201D100 D0082D00
    DB2E2B00 DC2C2B0F
    DB2A2A00 DC282A0F
    2B10E007 2B50DB25
    2A10DA23 2A50DB21
    2D00DA1F 3B10DC01
    210F3A10 4019240F
    4014091B 00490912
    025B0164 186402D2
    18E418A4 3D016841
    2145D40A 434D0109
    19496901 2A917F82
    2220D102 18890112
    476046F7 04000130
    021C6DEC 021E3124
    021C5C88 021EED6C
    021E5328 000079E0
    2E340301 00003235
    68416805 29007809
    6885D102 780968C1
    021B2322 434B338C
    476052EA 021CFC26
    021CBD48 021D88FE
    021D02EC 00000000
    023FF090 E3520003
    ASM source:
    Always willing to help with anything, code-related or not. :]

  12. The Following User Says Thank You to dragonboy269 For This Useful Post:


  13. #9

    Default

    Thanks for the code, Dragonboy.
    Last edited by Demonic722; 10-25-2014 at 12:40 AM.
    3DS Friend Code: 4699-6293-3106

  14. #10

    Default

    *does an obvious action in spite of just adding 1 to my post count*
    lolme
    On topic now.
    I thought ARM7 was the best the AR can go. Wow. The Possibilities now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •