; 暗号処理 / encrypt routine ; in. ecx:address,edx:data ; out. ecx:address,edx:data ; uses eax,ebx,ecx,edx,esi,di encrypt: lea di,encrypttable encrypt_loop: mov esi,[di] call crypt1 add ecx,eax call crypt2 add edx,eax sub di,4 cmp di,offset decrypttable-4 jnz encrypt_loop ret ; 復号処理 / decrypt routine ; in. ecx:address,edx:data ; out. ecx:address,edx:data ; uses eax,ebx,ecx,edx,esi,di decrypt: lea di,decrypttable decrypt_loop: mov esi,[di] call crypt2 sub edx,eax call crypt1 sub ecx,eax add di,4 cmp di,offset encrypttable+4 jnz decrypt_loop ret ; cryptsub1 address用 ; in. edx:data,esi:crypt# ; out. eax:add/sub# for address crypt1: mov ebx,edx shl ebx,04 add ebx,009f4fbbdh mov eax,edx add eax,esi xor ebx,eax mov eax,edx shr eax,05 add eax,09681884ah xor eax,ebx ret ; cryptsub2 data用 ; in. ecx:address,esi:crypt# ; out. eax:add/sub# for data crypt2: mov ebx,ecx shl ebx,04 add ebx,0352027e9h mov eax,ecx add eax,esi xor ebx,eax mov eax,ecx shr eax,05 add eax,0f3dee5a7h xor eax,ebx ret ; ; crypt# table for GBA-PAR ; align 4 decrypttable dd 0c6ef3720h dd 028b7bd67h dd 08a8043aeh dd 0ec48c9f5h dd 04e11503ch dd 0afd9d683h dd 011a25ccah dd 0736ae311h dd 0d5336958h dd 036fbef9fh dd 098c475e6h dd 0fa8cfc2dh dd 05c558274h dd 0be1e08bbh dd 01fe68f02h dd 081af1549h dd 0e3779b90h dd 0454021d7h dd 0a708a81eh dd 008d12e65h dd 06a99b4ach dd 0cc623af3h dd 02e2ac13ah dd 08ff34781h dd 0f1bbcdc8h dd 05384540fh dd 0b54cda56h dd 01715609dh dd 078dde6e4h dd 0daa66d2bh dd 03c6ef372h encrypttable dd 09e3779b9h