Results 1 to 10 of 14

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

Hybrid View

  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:


Posting Permissions

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