Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Procedure SaveMap905608; stdcall; //New opcode 1A
- Begin
- asm
- push ebp
- push ebx
- push esi
- push edi
- xor eax,eax
- xor ebx,ebx
- xor edx,edx
- xor edi,edi
- mov al, byte ptr [$CC0964]
- mov dx, word ptr [eax*2+$CC0CF8]
- mov esi,[$CBF5E8]
- mov ax, word ptr [esi+edx+01] // From
- mov di, word ptr [esi+edx+03] // To
- mov ecx, [esi+edx+05] // Value (if From is FFFF)
- mov dl, byte ptr [esi+edx+09] // Flag (1= 8 bit, 2=16 bit, 3=24 bit, 4= 32 bit)
- // Flag also allows 0x10 for pointers from, 0x20 pointers to
- //Valid values are therefore, 1,2,3,4, 11,12,13,14, 21,22,23,24, 31,32,33,34 hex
- @Label700:
- {from}
- cmp ax,$FFFF
- je @label500
- cmp ax,$10F5
- jg @Label501
- mov esi,$DBFD38 //main save map base
- jmp @Label500
- @LABEL501:
- cmp ax,$50FF
- jg @EndLabel
- cmp ax,$5000
- jl @EndLabel
- sub ax,$5000
- mov esi,$CC14D0 // temp bank base
- @LABEL500:
- {to}
- cmp di,$10F5
- jg @Label601
- mov ebp,$DBFD38 //main save map base
- jmp @Label600
- @LABEL601:
- cmp di,$50FF
- jg @EndLabel
- cmp di,$5000
- jl @EndLabel
- sub di,$5000
- mov ebp,$CC14D0 // temp bank base
- @LABEL600:
- cmp bl,$FE
- jae @LABEL200
- mov bl,dl
- and bl,$10
- test bl,bl
- je @label200
- mov eax, [eax + esi] // if From holds a pointer.
- mov bl,$FE // flag to make sure only one final check is made.
- jmp @Label700
- @LABEL200:
- cmp bl,$FF
- je @LABEL201
- mov bl,dl
- and bl,$20
- test bl,bl
- je @label201
- mov edi, [edi + ebp] // if To holds a pointer.
- mov bl,$FF // flag to make sure only one final check is made.
- jmp @Label500
- @LABEL201:
- and dl,$F
- cmp dl,0
- jne @label300
- mov dl,1
- @LABEL300: //dl now holds only values from 1-8
- cmp di, $04
- jb @EndLabel //Jump to end if trying to write to checksum.
- cmp ax, $FFFF
- je @FromNotUsed
- jmp @labelstart
- @FROMNOTUSED:
- mov eax, ecx //eax now holds an absolute VALUE
- @LABELSTART:
- cmp dl,1
- jne @label1
- mov byte ptr [edi + ebp], al
- jmp @EndLabel
- @LABEL1:
- cmp dl,2
- jne @label2
- mov word ptr [edi + ebp], ax
- jmp @EndLabel
- @LABEL2:
- cmp dl,3
- jne @label3
- mov byte ptr [edi + ebp + 2], al
- shl eax,16
- mov word ptr [edi + ebp], ax
- jmp @EndLabel
- @LABEL3:
- mov [edi + ebp], eax
- @ENDLABEL:
- xor edx,edx
- mov byte ptr dl,[$CC0964]
- add word ptr [edx*2+$CC0CF8],$0A //advance script by 10 bytes
- pop edi
- pop esi
- pop ebx
- pop ebp
- xor eax,eax
- end;
- End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement