sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

rspboot.s (1906B)


      1 .rsp
      2 
      3 .include "rsp/rsp_defs.inc"
      4 
      5 // This file assumes CODE_FILE is set on the command line
      6 .create CODE_FILE, 0x04001000
      7 
      8 .if defined(VERSION_JP) || defined(VERSION_US)
      9     ori   $1, $1, 0x0001
     10 .endif
     11     j     boot_04001068
     12      addi  $1, $zero, OSTask_addr
     13 boot_load_ucode:
     14     lw    $2, OSTask_ucode($1)
     15     addi  $3, $zero, 0x0f7f    // hard-coded length = 0xF80
     16     addi  $7, $zero, 0x1080    // hard-coded address = 0x1080
     17     mtc0  $7, SP_MEM_ADDR
     18     mtc0  $2, SP_DRAM_ADDR
     19     mtc0  $3, SP_RD_LEN
     20 boot_ucode_dma_busy:
     21     mfc0  $4, SP_DMA_BUSY
     22     bne   $4, $zero, boot_ucode_dma_busy
     23      nop
     24     jal   check_yielded
     25      nop
     26     jr    $7                   // jump to the loaded ucode
     27      mtc0  $zero, SP_SEMAPHORE // clear semaphore
     28 
     29 check_yielded:
     30     mfc0  $8, SP_STATUS
     31     andi  $8, $8, 0x0080       // yield signal is set
     32     bne   $8, $zero, boot_04001054
     33      nop
     34     jr    ra
     35 boot_04001054:
     36      mtc0  $zero, SP_SEMAPHORE // clear semaphore
     37     ori   $8, $zero, 0x5200    // clear yield, set yielded, set taskdone?
     38     mtc0  $8, SP_STATUS
     39     break                      // halt RSP and set SP_STATUS_BROKE
     40     nop
     41 
     42 boot_04001068:
     43     lw    $2, OSTask_flags($1)
     44     andi  $2, $2, OS_TASK_DP_WAIT
     45     beq   $2, $zero, boot_load_data
     46      nop
     47     jal   check_yielded
     48      nop
     49     mfc0  $2, DPC_STATUS
     50     andi  $2, $2, DPC_STATUS_DMA_BUSY
     51     bgtz  $2, check_yielded
     52      nop
     53 boot_load_data:
     54     lw    $2, OSTask_ucode_data($1)
     55     lw    $3, OSTask_ucode_data_size($1)
     56     addi  $3, $3, -1
     57 boot_dma_not_full:
     58     mfc0  $30, SP_DMA_FULL
     59     bne   $30, $zero, boot_dma_not_full
     60      nop
     61     mtc0  $zero, SP_MEM_ADDR   // ucode_data store at base of DMEM
     62     mtc0  $2, SP_DRAM_ADDR
     63     mtc0  $3, SP_RD_LEN
     64 boot_data_dma_busy:
     65     mfc0  $4, SP_DMA_BUSY
     66     bne   $4, $zero, boot_data_dma_busy
     67      nop
     68     jal   check_yielded
     69      nop
     70     j     boot_load_ucode
     71      nop
     72 
     73 .close // CODE_FILE