Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 4.70 KB | None | 0 0
  1. //Installing Interupt Test 1
  2. .global InstallIntTable
  3. InstallIntTable:
  4.   Push    {r0-r12, lr}
  5.   ldr     r0, =IntTable
  6.   mov     r1, #0x00000000
  7.  
  8.  
  9.  
  10. // load the first 8 words and store at the 0 address
  11.     ldmia   r0!, {r2-r9}
  12.     stmia   r1!, {r2-r9}
  13.  
  14.     // load the second 8 words and store at the next address
  15.     ldmia   r0!, {r2-r9}
  16.     stmia   r1!, {r2-r9}
  17.  
  18.  
  19. // switch to IRQ mode and set stack pointer
  20.     mov     r0, #0xD2
  21.     msr     cpsr_c, r0
  22.     mov     sp, #0x8000
  23.  
  24.     // switch back to Supervisor mode, set the stack pointer
  25.     mov     r0, #0xD3
  26.     msr     cpsr_c, r0
  27.     mov     sp, #0x8000000
  28.  
  29.     bx      lr
  30.  
  31.  
  32. //This subroutine will count 30s until it call draw value pack which is the Value pack function
  33.  
  34. .global IntFunc
  35. IntFunc:
  36.       Push    {r0-r12, lr}
  37.       ldr     r5, =0x3F003004       //Adress of CLO
  38.       ldr     r6, [r5]              //ReadCLO
  39.       ldr     r7, =0x1C9C380         //Time to let the Function Wait until to draw the value pack
  40.  
  41.       add     r6, r7                // add the wait time to the system's current time
  42.      ldr     r8, =0x3F003010
  43.       str     r6, [r8]              // time + delay
  44.       ldr     r5, =0x3F00B210       // loading stored value in address 0x3F000b210
  45.       ldr     r6, =0XA              // mask
  46.      str     r6, [r5]
  47.      ldr     r0, =0x3F00B214
  48.      mov     r1, #0
  49.      str     r1, [r0]
  50.       mrs     r5, cpsr              // abed uses r0, is it r0 or 5 check later chris
  51.      bic     r5, #0x80
  52.      msr     cpsr_c ,r5
  53.  
  54.      pop   {r0-r12, lr}
  55.      bx    lr
  56.  
  57.  
  58. //this subroutine will determine when to trigger the draw value pack function
  59.  
  60. .global Setting
  61. Setting:
  62.        push    {r0-r12, lr}
  63.        ldr     r0, =0x3F00B204             //load the address
  64.        ldr     r1, [r0]                    //load the address in r0 to r1
  65.        ldr     r3, =0x2                    //load the address into r3
  66.        tst     r1, r3                      //tst the two inputs (theortical and which leads to 00 as an output)
  67.        beq     Clearing
  68.  
  69.    // Check if the user is in the game map or not, if the user isn't in the game Map then we dont draw
  70.         ldr    r0, =enterTheGameCheck
  71.         ldr    r1, [r0]
  72.         cmp    r1, #1
  73.         beq    Clearing
  74.   // Add a condition here later
  75.  
  76. /*
  77.         ldr     r0, =mapTransitionCheck
  78.         ldr     r1, [r0]
  79.         cmp     r1, #1
  80.         beq     Clearing
  81. */
  82.  
  83.   // if the previouis conditions are all pass it will branch down to here automatically where it draws the value pack
  84.  
  85. drawValuePack:
  86.           push {lr}
  87.  
  88.           ldr     r0, =IsItFirstTimeDraw
  89.           ldr     r1, [r0]
  90.           cmp     r1, #1
  91.           bne     ItIsNot
  92.  
  93.         // if the value pack already exist and the player hasn't used it in the past 30 seconds dont generate another value pack
  94.          ldr     r0, =valuePackExist
  95.          ldr     r0, [r0]
  96.          cmp     r0, #1
  97.          beq     ItIsNot
  98.  
  99.  
  100.  //This is the value pack drawing locations and calling
  101.  
  102.        ldr     r7, =mapNumber
  103.        ldr     r8, [r7]
  104.        cmp     r8, #1
  105.        beq     LoadFirstMap
  106.  
  107.        /*
  108.        cmp     r8, #2
  109.        beq     LoadSecondMap
  110.        cmp     r8, #3
  111.        beq     LoadThirdMap
  112. */
  113.  
  114.  
  115. LoadFirstMap:
  116.  ldr   r7, =screenOne
  117.  bl    RNG
  118.  mov   r4, r0
  119.  cmp   r4, #0
  120.  beq   DrawPipe1
  121.  cmp   r4, #1
  122.  beq   DrawPipe2
  123.  
  124. DrawPipe1:
  125. bl  drawMagikarp
  126.  
  127. /*
  128.  ldr r8, =0x8D
  129.  ldr r9, =0xE0
  130.  b  drawValuePackContinue
  131. */
  132.  
  133. DrawPipe2:
  134. ldr r8, =0x2C7
  135. ldr r9, =0xF4
  136. b   drawValuePackContinue
  137.  
  138. drawValuePackContinue:
  139.  
  140.  ldr   r6, =ValuePack
  141.  ldr   r7, =32
  142.  ldr   r7, =32
  143.  
  144.  bl    drawPictureLoop2
  145.  
  146.   ldr           r0, =valuePackExist
  147.   mov           r1, #1
  148.   str       r1, [r0]
  149.  
  150.  
  151.  
  152.  
  153. ItIsNot:
  154.    // Trigger the label to let program know that it is nto the first time the programing is running
  155.  
  156.      ldr       r0, =IsItFirstTimeDraw
  157.      mov       r1, #1
  158.      str       r1, [r0]
  159.      pop       {lr}
  160.  
  161.  
  162. Clearing:
  163. /*
  164.        ldr   r5, =0x3F003000
  165.        ldr   r6, =0x2
  166.        str   r6, [r5]
  167.        bl    IntFunc
  168. */
  169.        ldr   r5, =0x3F003000
  170.        ldr   r4, [r5]
  171.        ldr   r6, =0x2
  172.        orr   r4, r6
  173.        str   r4, [r5]
  174.  
  175.        pop   {r0-r12, lr}
  176.        sub   pc, lr, #4
  177.  
  178. //this is the data section that intialize any system calls
  179.  
  180.   .section  .data
  181. IntTable:
  182. ldr     pc, reset_handler
  183. ldr     pc, undefined_handler
  184. ldr     pc, swi_handler
  185. ldr     pc, prefetch_handler
  186. ldr     pc, data_handler
  187. ldr     pc, unused_handler
  188. ldr     pc, irq_handler
  189. ldr     pc, fiq_handler
  190.  
  191. reset_handler:          .word   InstallIntTable
  192. undefined_handler:  .word   haltLoop$
  193. swi_handler:                .word   haltLoop$
  194. prefetch_handler:       .word   haltLoop$
  195. data_handler:               .word   haltLoop$
  196. unused_handler:         .word   haltLoop$
  197. irq_handler:                .word   Setting
  198. fiq_handler:                .word   haltLoop$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement