SHARE
TWEET

Zelda Disk Code

LuigiBlood Sep 4th, 2017 203 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Zelda Expansion Disk
  2. //By LuigiBlood
  3.  
  4. arch n64.cpu
  5. endian msb
  6. output "EZLJ_new.ndd", create
  7.  
  8. include "N64_CPUREGS.asm"
  9.  
  10. macro seek(n) {
  11.   origin {n}
  12. }
  13.  
  14. //FILL
  15. seek(0x0)
  16. fill 0x3DEC800
  17.  
  18. //System Area
  19. seek(0x0)
  20. //System Data
  21. define x(0)
  22. while {x} < 14 {
  23.   define y(0)
  24.   while {y} < 86 { //232 * 85
  25.  
  26.     dw 0xE848D316   //Disk Region
  27.     db 0x10
  28.     db 0x11     //Disk Type
  29.     dh 0x0001       //Boot Blocks Load
  30.     db 0x0C, 0x18, 0x24, 0x30, 0x3C, 0x48, 0x54, 0x60, 0x6C, 0x78, 0x84, 0x90, 0x9C, 0xA8, 0xB4, 0xC0
  31.     dw 0xFFFFFFFF
  32.     dw 0x80000400
  33.     db 0x10, 0x16, 0x1C, 0x22, 0x28, 0x2E, 0x34, 0x36, 0x37, 0x40, 0x46, 0x4C
  34.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  35.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  36.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x73
  37.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  38.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  39.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x92
  40.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x6F
  41.     db 0x56, 0x5C, 0x62, 0x68, 0x6E, 0x74, 0x7A, 0x7F, 0x86, 0x8C, 0x92, 0x98
  42.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x88
  43.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  44.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  45.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  46.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x69
  47.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x93
  48.     db 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x44, 0x4C, 0x54, 0x5C
  49.     dh 0x061E, 0x07AE, 0x10C3, 0xFFFF
  50.    
  51.     evaluate y({y} + 1)
  52.   }
  53.   evaluate x({x} + 1)
  54. }
  55.  
  56. //Disk ID
  57. define x(14)
  58. while {x} < 24 {
  59.   define y(0)
  60.   while {y} < 86 { //232 * 85
  61.  
  62.     db "EZLJ"   //Game ID code
  63.     db 0    //Version 0
  64.     db 0    //Disk Number 0
  65.     db 0    //Does not use MFS
  66.     db 0    //Disk Use
  67.     db "URAZELDA"
  68.     db "ITISREAL"
  69.     db "01"
  70.     db "WOAHHH"
  71.    
  72.     fill 200
  73.    
  74.     evaluate y({y} + 1)
  75.   }
  76.   evaluate x({x} + 1)
  77. }
  78.  
  79. //LBA 25
  80. seek(0x785C8)
  81.  
  82. constant DDHOOK_RAM(0x80410000)
  83. constant DDHOOK_GPRAM(0x80400000)
  84. constant DDHOOK_NESTEST(0x80440000)
  85.  
  86. base DDHOOK_RAM
  87.  
  88. ddhook_start:
  89. db "URAZELDA"
  90. ddhook_list_start:
  91. dw (ddhook_setup)   //00: 64DD Hook
  92. dw 0x00000000       //04: 64DD Unhook
  93. dw 0x00000000       //08: Room Loading
  94. dw 0x00000000       //0C: Scene Loading (???)  
  95. dw 0x00000000       //10:
  96. dw 0x00000000       //14:
  97. dw 0x00000000       //18:
  98. dw 0x00000000       //1C:
  99. dw 0x00000000       //20:
  100. dw 0x00000000       //24:
  101. dw 0x00000000       //28:
  102. dw 0x00000000       //2C:
  103. dw 0x00000000       //30:
  104. dw 0x00000000       //34:
  105. dw 0x00000000       //38:
  106. dw 0x00000000       //3C:
  107. dw 0x00000000       //40:
  108. dw 0x00000000       //44:
  109. dw (ddhook_scenedetect_real)        //48: Scene Entry Replacement
  110. dw 0x00000000       //4C:
  111. dw 0x00000000       //50:
  112. dw 0x00000000       //54:
  113. dw (ddhook_text_table)  //58: Message Table Replacement
  114. dw 0x00000000       //5C:
  115. dw 0x00000000       //60:
  116. dw 0x00000000       //64:
  117. dw (ddhook_textUSload)  //68: US Text Data Loading
  118. dw 0x00000000       //6C:
  119. dw 0x00000000       //70:
  120. dw 0x00000000       //74:
  121. dw 0x00000000       //78:
  122. ddhook_list_end:
  123.  
  124. ddhook_setup:
  125.     //A0=p->p->n64dd_Func_801C7C1C (USEFUL!)
  126.     //800FEE70 - Offset Table
  127.     //  +0x0 = 801C7C1C
  128.     //  +0x50 = osSendMesg
  129.     //  +0x88 = Save Context
  130.     //8011A5D0 - Save Context
  131.     //  +0x1409 = Language (8011B9D9)
  132.    
  133.     addiu sp,sp,-0x10
  134.     sw ra,4(sp)
  135.    
  136.     //Change language to English
  137.     lw a1,0x88(a0)
  138.     addiu a1,a1,0x1409
  139.     ori a2,0,1
  140.     sb a2,0(a1)
  141.    
  142.     //save pointer to 801C7C1C
  143.     li a3,(DDHOOK_GPRAM)
  144.     lw a2,0x50(a0)
  145.     sw a2,4(a3)
  146.     lw a0,0(a0)
  147.     sw a0,0(a3)
  148.    
  149.     or a3,0,a0
  150.    
  151.     //load text data into RAM (avoid music stop)
  152.     li a1,0x00966000    //A1=00966000 (Offset)
  153.     li a2,0x00039000    //A2=00039000 (Size)
  154.     li a0,DDHOOK_NESTEST    //A0=DDHOOK_NESTEST (Dest)
  155.     jalr a3         //read from disk
  156.     nop
  157.    
  158.     lw ra,4(sp)
  159.     addiu sp,sp,0x10
  160.     jr ra
  161.     nop
  162.  
  163. ddhook_textUSload:
  164.     //A0=p->Text Heap
  165.     //  +0 = Offset
  166.     //  +4 = Size
  167.     //  +DC88 = Destination
  168.     addiu sp,sp,-0x10
  169.     sw ra,4(sp)
  170.    
  171.     lw a2,4(a0)         //A2 = Size
  172.     lw a1,0(a0)     //A1 = Offset
  173.     li a3,DDHOOK_NESTEST    //A3 = DDHOOK_NESTEST
  174.     addu a1,a1,a3       //A1 = A3 + Offset
  175.     ori a3,0,0xDC88
  176.     addu a0,a0,a3       //A0 = RAM Dest
  177. ddhook_textUSloop:
  178.     lb a3,0(a1)
  179.     sb a3,0(a0)
  180.     addiu a0,a0,1
  181.     addiu a1,a1,1
  182.     subi a2,a2,1
  183.     bnez a2,ddhook_textUSloop
  184.    
  185.     lw ra,4(sp)
  186.     addiu sp,sp,0x10
  187.     jr ra
  188.     nop
  189.    
  190. constant DDHOOK_MESSAGETABLENES(0x80420000)
  191. ddhook_text_table:
  192.     //A0=p->p->jpn_message_data_static table
  193.     //A1=p->p->nes_message_data_static table
  194.     //A2=p->p->staff_message_data_static table
  195.     //You can change the pointers.
  196.     addiu sp,sp,-0x10
  197.     sw ra,4(sp)
  198.    
  199.     li a0,DDHOOK_MESSAGETABLENES
  200.     sw a0,0(a1)     //Change pointer
  201.     li a1,0x00008004    //A1=Source
  202.     li a2,0x421C        //A2=Size
  203.    
  204.     li a3,(DDHOOK_GPRAM)
  205.     lw a3,0(a3)
  206.     jalr a3         //read from disk
  207.     nop
  208.    
  209.     lw ra,4(sp)
  210.     addiu sp,sp,0x10
  211.     jr ra
  212.     nop
  213.  
  214. ddhook_scenedetect_real:
  215.     //A0=Scene ID
  216.     //A1=p->Scene Table
  217.     addiu sp,sp,-0x10
  218.     addiu a3,0,0x14
  219.     multu a0,a3
  220.     mflo a0
  221.     addu v0,a0,a1
  222.     bnez a0,ddhook_scenedetect_real_notdeku
  223.     li a0,ddhook_list_start
  224.     li a1,ddhook_roomload
  225.     sw a1,8(a0)
  226.     b ddhook_scenedetect_real_return
  227.     nop
  228. ddhook_scenedetect_real_notdeku:
  229.     sw 0,8(a0)
  230.    
  231. ddhook_scenedetect_real_return:
  232.     addiu sp,sp,0x10
  233.     jr ra
  234.     nop
  235.    
  236. ddhook_roomload:
  237.     //A0=p->Global Context
  238.     //A1=p->Room Context
  239.     //A2=Room ID
  240.    
  241.     addiu sp,sp,-0x10
  242.     sw ra,4(sp)
  243.     sw a1,8(sp)
  244.    
  245.     lw a0,0x0134(a1)    //load Room List Pointer
  246.     sll a3,a2,3     //Room ID * 8
  247.     addu a2,a0,a3       //calculate offset from Room ID
  248.     lw a0,0x34(a1)      //A0=RAM Address
  249.     lw a3,0x8(a2)       //RoomEnd
  250.     lw a1,0x0(a2)       //RoomStart (A1=VROM Address)
  251.     subu a2,a3,a1       //A2=Size
  252.    
  253.     lw a3,8(sp)
  254.     sw a1,0x38(a3)      //Store VROM Address
  255.     sw a0,0x3C(a3)      //Store RAM Address
  256.     sw a2,0x40(a3)      //Store Size
  257.    
  258.     li a3,(DDHOOK_GPRAM)
  259.     lw a3,0(a3)
  260.     jalr a3         //read from disk
  261.     nop
  262.    
  263.     //VERY HACKY MAP LOADING UNSTABLE
  264.     lw a1,8(sp)
  265.     addiu a0,0,1
  266.     sw a0,0x60(a1)
  267.    
  268.     //lw a0,8(sp)
  269.     //addiu a0,a0,0x58
  270.     //li a1,1
  271.     //li a2,0
  272.    
  273.     //li a3,(DDHOOK_GPRAM)
  274.     //lw a3,4(a3)
  275.     //jalr a3   //osSendMesg
  276.     //nop
  277.    
  278.     lw ra,4(sp)
  279.     addiu sp,sp,0x10
  280.     jr ra
  281.     nop
  282.  
  283. ddhook_end:
  284.  
  285. seek(0x79628)
  286. dw (ddhook_start - ddhook_start)    //Source Start
  287. dw (ddhook_end - ddhook_start)      //Source End
  288. dw (ddhook_start)           //Dest Start
  289. dw (ddhook_end)             //Dest End
  290. dw (ddhook_list_start)
  291.  
  292. seek(0x785C8 + 0x8000)
  293. insert "ezlj_nes_message_table.bin"
  294.  
  295. seek(0x785C8 + 0x00966000)
  296. insert "ezlj_nes_message_data_static.bin"
  297.  
  298. //parody message shit
  299. seek(0x9ED325)
  300. db 0x57, 0x6F, 0x77, 0x21, 0x20, 0x41, 0x20, 0x36, 0x34, 0x44, 0x44, 0x21, 0x21, 0x21, 0x04, 0x1A, 0x49, 0x74, 0x27, 0x73, 0x20, 0x61, 0x62, 0x6F, 0x75, 0x74, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x75, 0x73, 0x65, 0x64, 0x20, 0x6F, 0x6E, 0x65
  301.  
  302. seek(0x9ED39E)
  303. db 0x4C, 0x65, 0x74, 0x20, 0x6D, 0x65, 0x20, 0x68, 0x75, 0x6D, 0x70, 0x20, 0x6D, 0x79, 0x20, 0x72, 0x6F, 0x63, 0x6B, 0x20, 0x69, 0x6E, 0x20, 0x70, 0x65, 0x61, 0x63, 0x65, 0x21, 0x01, 0x53, 0x65, 0x72, 0x69, 0x6F, 0x75, 0x73, 0x6C, 0x79, 0x2C, 0x20, 0x6C, 0x6F, 0x73, 0x65, 0x72, 0x2C, 0x20, 0x79, 0x6F, 0x75, 0x27, 0x72, 0x65, 0x20, 0x72, 0x75, 0x69, 0x6E, 0x69, 0x6E, 0x67, 0x20, 0x69, 0x74, 0x21, 0x02
  304.  
  305.  
  306. seek(0x785C8 + 0x02499000)
  307. //insert "ezlj_ydan_all_ntsc1.0.bin"
  308. insert "ezlj_ydan_scene_palmq.bin"
  309.  
  310. seek(0x785C8 + 0x01F61000)
  311. insert "ezlj_ydan_rooms_palmq.bin"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top