Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 5.64 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, =0x2FAF080
  40.       ldr     r7, =0x1C9C380         //Time to let the Function Wait until to draw the value pack
  41.  
  42.       add     r6, r7                // add the wait time to the system's current time
  43.      ldr     r8, =0x3F003010
  44.       str     r6, [r8]              // time + delay
  45.       ldr     r5, =0x3F00B210       // loading stored value in address 0x3F000b210
  46.       ldr     r6, =0XA              // mask
  47.      str     r6, [r5]
  48.      ldr     r0, =0x3F00B214
  49.      mov     r1, #0
  50.      str     r1, [r0]
  51.       mrs     r5, cpsr              // abed uses r0, is it r0 or 5 check later chris
  52.      bic     r5, #0x80
  53.      msr     cpsr_c ,r5
  54.  
  55.      pop   {r0-r12, lr}
  56.      bx    lr
  57.  
  58.  
  59. //this subroutine will determine when to trigger the draw value pack function
  60.  
  61. .global Setting
  62. Setting:
  63.        push    {r0-r12, lr}
  64.        ldr     r0, =0x3F00B204             //load the address
  65.        ldr     r1, [r0]                    //load the address in r0 to r1
  66.        ldr     r3, =0x2                    //load the address into r3
  67.        tst     r1, r3                      //tst the two inputs (theortical and which leads to 00 as an output)
  68.        beq     Clearing
  69.  
  70.    // Check if the user is in the game map or not, if the user isn't in the game Map then we dont draw
  71.         ldr    r0, =enterTheGameCheck
  72.         ldr    r1, [r0]
  73.         cmp    r1, #1
  74.         beq    Clearing
  75.   // Add a condition here later
  76.  
  77. /*
  78.         ldr     r0, =mapTransitionCheck
  79.         ldr     r1, [r0]
  80.         cmp     r1, #1
  81.         beq     Clearing
  82. */
  83.  
  84.   // if the previouis conditions are all pass it will branch down to here automatically where it draws the value pack
  85.  
  86. drawValuePack:
  87.           push {lr}
  88.  
  89.           ldr     r0, =IsItFirstTimeDraw
  90.           ldr     r1, [r0]
  91.           cmp     r1, #0
  92.           beq      firstTimeDraw
  93.  
  94.         // if the value pack already exist and the player hasn't used it in the past 30 seconds dont generate another value pack
  95.          ldr     r0, =valuePackExist
  96.          ldr     r0, [r0]
  97.          cmp     r0, #1
  98.          beq     secondTimeDraw
  99. /*
  100.  
  101.  //This is the value pack drawing locations and calling
  102.  
  103.        ldr     r7, =mapNumber
  104.        ldr     r8, [r7]
  105.        cmp     r8, #1
  106.        beq     LoadFirstMap
  107.  
  108.        /*
  109.        cmp     r8, #2
  110.        beq     LoadSecondMap
  111.        cmp     r8, #3
  112.        beq     LoadThirdMap
  113. */
  114.  
  115. /*
  116. LoadFirstMap:
  117.  ldr   r7, =screenOne
  118.  bl    RNG
  119.  mov   r4, r0
  120.  cmp   r4, #0
  121.  beq   DrawPipe1
  122.  cmp   r4, #1
  123.  beq   DrawPipe2
  124.  
  125. DrawPipe1:
  126. bl  drawMagikarp
  127.  
  128. /*
  129.  ldr r8, =0x8D
  130.  ldr r9, =0xE0
  131.  b  drawValuePackContinue
  132. */
  133. /*
  134. DrawPipe2:
  135. ldr r8, =0x2C7
  136. ldr r9, =0xF4
  137. b   drawValuePackContinue
  138.  
  139. drawValuePackContinue:
  140.  
  141.  ldr   r6, =ValuePack
  142.  ldr   r7, =32
  143.  ldr   r7, =32
  144.  
  145.  bl    drawPictureLoop2
  146.  
  147.   ldr           r0, =valuePackExist
  148.   mov           r1, #1
  149.   str       r1, [r0]
  150.  
  151. */
  152.  
  153. firstTimeDraw:
  154.  
  155.      ldr       r0, =IsItFirstTimeDraw
  156.      mov       r1, #1
  157.      str       r1, [r0]
  158.      pop       {lr}
  159.  
  160.       // Checks for which screen you are on
  161.       push      {r4-r9, lr}
  162.       ldr       r0, =stackMemory
  163.       ldr       r1, [r0, #12]
  164.       cmp       r1, #1
  165.       beq       onScreenOne
  166.  
  167.  
  168.       onScreenOne:
  169.  
  170.         ldr   r7, =screenOne
  171.         bl    RNG
  172.         mov   r4, r0
  173.         cmp   r4, #0
  174.         beq   DrawPipe1
  175.         cmp   r4, #1
  176.         beq   DrawPipe2
  177.  
  178.  
  179.         DrawPipe1:
  180.         ldr r4, =0x8D
  181.         ldr r5, =0xE0
  182.         ldr r7, =0xAD
  183.         ldr r8, =0x100
  184.         mov r9, r4
  185.         b  drawValuePackContinue
  186.  
  187.         DrawPipe2:
  188.         ldr r4, =0x2C7  //636
  189.         ldr r5, =0xF4   // 244
  190.         ldr r7, =0x29C
  191.         ldr r8, =0x114
  192.         mov r9, r4
  193.  
  194.         b   drawValuePackContinue
  195.  
  196.  
  197.         drawValuePackContinue:
  198.  
  199.           ldr   r6, =ValuePack
  200.           bl    drawPictureLoop2
  201.  
  202.           ldr           r0, =valuePackExist
  203.           mov           r1, #1
  204.           str       r1, [r0]
  205.  
  206.           pop {r4-r9, lr}
  207.  
  208.  
  209.  
  210.  
  211. secondTimeDraw:
  212.    // Trigger the label to let program know that it is nto the first time the programing is running
  213.  
  214.      ldr       r0, =IsItFirstTimeDraw
  215.      mov       r1, #2
  216.      str       r1, [r0]
  217.      pop       {lr}
  218.  
  219.  
  220. Clearing:
  221. /*
  222.        ldr   r5, =0x3F003000
  223.        ldr   r6, =0x2
  224.        str   r6, [r5]
  225.        bl    IntFunc
  226. */
  227.        ldr   r5, =0x3F003000
  228.        ldr   r4, [r5]
  229.        ldr   r6, =0x2
  230.        orr   r4, r6
  231.        str   r4, [r5]
  232.  
  233.        pop   {r0-r12, lr}
  234.        sub   pc, lr, #4
  235.  
  236. //this is the data section that intialize any system calls
  237.  
  238.   .section  .data
  239. IntTable:
  240. ldr     pc, reset_handler
  241. ldr     pc, undefined_handler
  242. ldr     pc, swi_handler
  243. ldr     pc, prefetch_handler
  244. ldr     pc, data_handler
  245. ldr     pc, unused_handler
  246. ldr     pc, irq_handler
  247. ldr     pc, fiq_handler
  248.  
  249. reset_handler:          .word   InstallIntTable
  250. undefined_handler:  .word   haltLoop$
  251. swi_handler:                .word   haltLoop$
  252. prefetch_handler:       .word   haltLoop$
  253. data_handler:               .word   haltLoop$
  254. unused_handler:         .word   haltLoop$
  255. irq_handler:                .word   Setting
  256. fiq_handler:                .word   haltLoop$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement