Guest User

Untitled

a guest
Jul 17th, 2019
496
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .text
  2. .align 2
  3. .global SND_PaintChannelFrom8
  4. .type SND_PaintChannelFrom8, %function
  5. SND_PaintChannelFrom8:
  6. // r0: int true_lvol
  7. // r1: int true_rvol
  8. // r2: char *sfx
  9. // r3: int count
  10.  
  11. stmfd sp!, {r4, r5, r6, r7, r8, r9}
  12.  
  13. ldr ip, .paintbuf
  14. ldr ip, [ip]
  15. sub r3, r3, #1 // we'll count backwards
  16. // r9 = 0xffff0000
  17. ldr r9, =0xffff0000
  18. .loop:
  19. ldrsb r4, [r2, r3] // load *sfx[i] -> r4
  20. ldr r8, [ip, r3, lsl #2] // load paintbuffer[0:1] = LEFTCHANORIG, RIGHTCHANNEL
  21.  
  22. mul r5, r4, r0 // SCALEDLEFT = SFXI * true_lvol
  23. mov r5, r5, asl #16 // shift SCALEDLEFT << by 16
  24.  
  25. and r6, r8, r9 // extract left channel from paintbuffer
  26.  
  27. // r7 holds left channel in high half with zero bottom half
  28. qadd r7, r5, r6 // LEFTCHANORIG = SCALEDLEFT + LEFTCHANORIG (high half)
  29.  
  30. // trash r5, r6 and handle right channel
  31. mul r5, r4, r1 // SCALEDRIGHT = SFXI * true_rvol
  32.  
  33. mov r8, r8, lsl #16 // shift RIGHTCHANORIG << 16 to extract
  34.  
  35. // r8 holds right channel in high half with zero bottom half
  36. qadd r8, r5, r8
  37.  
  38. // combine the two 16-bit samples in r7 as 32-bit [left:right]
  39. // (use lsr to not sign-extend the lower half)
  40. orr r7, r7, r8, lsr #16
  41.  
  42. str r7, [ip, r3, lsl #2] // write 32-bit to paintbuffer
  43.  
  44. subs r3, r3, #1
  45. bne .loop
  46.  
  47. ldmfd sp!, {r4, r5, r6, r7, r8, r9}
  48.  
  49. bx lr
  50.  
  51. .paintbuf:
  52. .word paintbuffer
RAW Paste Data