// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: GetLoadingParameters
void GetLoadingParameters(word loaded)
{
  if (slocktype)
     {
       dword savepos=filepos;
       ResetTempFile();
       if ((nxtloadpos>slockloadaddress-0x319) && (nxtloadpos<slockloadaddress))
	  {
	    if (loaded==2)
	       {
		 GetData(&tempfile);
		 xorbyte=((GetData(&tempfile))^xorbyte)+addbyte;
	       }
	  }

       if ((nxtloadpos>=loadertableadd || nxtloadpos+loaded>loadertableadd) && ((slockloadaddress>0xc000 && nxtloadpos>0xc000) || (slockloadaddress<0xc000 && nxtloadpos<0xc000)))
	  {
	    if (loaded>128) { strcpy(errstring,"Missing mid-sync"); Error(8);}
	    else {
		   byte offset=nxtloadpos-loadertableadd;
		   DecodeSpeedlockTable(loaded,offset);
		 }
	  }
       expectedlength=slockdata[tablepointer+2]+256*(slockdata[tablepointer+3]);
       if (expectedlength)
	  {
	    expectedlength++;
	    SpeedEndBlock=0;
	    nxtloadpos=slockdata[tablepointer]+256*(slockdata[tablepointer+1]);
	    rampage=slockdata[tablepointer+4];
	  }
       else SpeedEndBlock=1;
       tablepointer+=5;
       filepos=savepos;
       lseek(inpfile.handle,filepos,SEEK_SET);
       inpfile.bufpoint=0;
     }
  if (soft)
     {
       if (add256)
	  {
	    ResetTempFile();
	    PushFilePointers();
	    opcode=MirrorByte(GetData(&tempfile));
	    if (nxtloadpos==0x5b00 && opcode!=0x3b)
	       {
		 nxtloadpos=0; return;
	       }
	    opcode=MirrorByte(GetData(&tempfile));
	    ResetTempFile();
	    PopFilePointers();
//          RecoverFilePointers();
	    add256=0;
	  }
       DataRead(bit0.samples,bit1.samples,4);
       WriteTZXPureData(8,4);
       PushFilePointers();
       ResetTempFile();
       expectedlength=MirrorByte(GetData(&tempfile));
       expectedlength+=(256*(MirrorByte(GetData(&tempfile))));
       nxtloadpos=MirrorByte(GetData(&tempfile));
       nxtloadpos+=(256*(MirrorByte(GetData(&tempfile))));
       if (nxtloadpos) nxtloadpos+=((256*(opcode==0x24))-(256*(opcode==0x25)));
       PopFilePointers();
       if (expectedlength<=5 || (nxtloadpos<23324 && nxtloadpos+expectedlength>23325)) add256=1;
       else add256=0;
     }
  if (zeta)
     {
       dword savepos=filepos;
       ResetTempFile();
       rampage=slockdata[tablepointer];
       if (rampage)
	  {
	    SpeedEndBlock=0;
	    expectedlength=1+slockdata[tablepointer+1]+256*(slockdata[tablepointer+2]);
	    nxtloadpos=slockdata[tablepointer+3]+256*(slockdata[tablepointer+4]);
	  }
       else SpeedEndBlock=1;
       tablepointer+=5;
       filepos=savepos;
       lseek(inpfile.handle,filepos,SEEK_SET);
       inpfile.bufpoint=0;
     }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0x8943(%rip)      # 0xf1a4
je 0x69b4
movl %edi, %r14d
movq 0x8967(%rip), %rbx      # 0xf1d8
callq 0x15e9
movl 0x8984(%rip), %eax      # 0xf200
movl 0x89a6(%rip), %ecx      # 0xf228
leal -0x319(%rcx), %edx
cmpl %edx, %eax
jbe 0x68cb
cmpl %ecx, %eax
setae %cl
cmpl $0x2, %r14d
setne %dl
orb %cl, %dl
jne 0x68cb
leaq 0x10c05(%rip), %r15     # 0x174a8
movq %r15, %rdi
callq 0x1d32
movq %r15, %rdi
callq 0x1d32
xorb 0x8837(%rip), %al       # 0xf0f0
addb 0x8832(%rip), %al       # 0xf0f1
movb %al, 0x882b(%rip)       # 0xf0f0
movl 0x8935(%rip), %eax      # 0xf200
movl 0x895b(%rip), %edx      # 0xf22c
movl %eax, %ecx
subl %edx, %ecx
setb %sil
leal (%rax,%r14), %edi
cmpl %edx, %edi
setbe %dl
testb %dl, %sil
jne 0x692e
movl 0x893b(%rip), %edx      # 0xf228
movl $0xc001, %esi           # imm = 0xC001
cmpl %esi, %edx
setae %dil
cmpl %esi, %eax
setae %sil
testb %dil, %sil
jne 0x6916
movl $0xc000, %esi           # imm = 0xC000
cmpl %esi, %edx
setae %dl
cmpl %esi, %eax
setae %al
orb %dl, %al
jne 0x692e
cmpl $0x81, %r14d
jae 0x6be4
movzbl %cl, %esi
movl %r14d, %edi
callq 0x6629
movl 0x8900(%rip), %eax      # 0xf234
leal 0x2(%rax), %edx
leaq 0x155f2(%rip), %rcx     # 0x1bf30
movzbl (%rdx,%rcx), %esi
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
shll $0x8, %edx
orl %esi, %edx
movl %edx, 0x88b0(%rip)      # 0xf204
je 0x6984
incl %edx
movl %edx, 0x88a6(%rip)      # 0xf204
movzbl (%rax,%rcx), %edx
leal 0x1(%rax), %esi
movzbl (%rsi,%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movl %esi, 0x888c(%rip)      # 0xf200
leal 0x4(%rax), %edx
movb (%rdx,%rcx), %cl
movb %cl, 0x158b0(%rip)      # 0x1c230
xorl %ecx, %ecx
jmp 0x6986
movb $0x1, %cl
movb %cl, 0x15250(%rip)      # 0x1bbdc
addl $0x5, %eax
movl %eax, 0x889f(%rip)      # 0xf234
movq %rbx, 0x883c(%rip)      # 0xf1d8
movzbl 0x88cd(%rip), %edi      # 0xf270
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0x89bc(%rip)      # 0xf370
cmpb $0x0, 0x87e7(%rip)      # 0xf1a2
je 0x6b43
cmpb $0x0, 0x8858(%rip)      # 0xf220
je 0x6a3d
callq 0x15e9
callq 0x1618
leaq 0x10acd(%rip), %rdi     # 0x174a8
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movb %al, 0x8833(%rip)       # 0xf221
cmpl $0x5b00, 0x8808(%rip)   # imm = 0x5B00
sete %cl
cmpb $0x3b, %al
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x6a12
andl $0x0, 0x87f3(%rip)      # 0xf200
jmp 0x6bde
leaq 0x10a8f(%rip), %rdi     # 0x174a8
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movb %al, 0x87f5(%rip)       # 0xf221
callq 0x15e9
callq 0x16b7
movb $0x0, 0x87e3(%rip)      # 0xf220
movsd 0x14d33(%rip), %xmm0    # 0x1b778
movsd 0x14d4b(%rip), %xmm1    # 0x1b798
pushq $0x4
popq %rdi
callq 0x374a
pushq $0x8
popq %rdi
pushq $0x4
popq %rsi
callq 0x5f8b
callq 0x1618
callq 0x15e9
leaq 0x10a37(%rip), %rbx     # 0x174a8
movq %rbx, %rdi
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movzbl %al, %eax
movl %eax, 0x877a(%rip)      # 0xf204
movq %rbx, %rdi
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movzbl %al, %eax
shll $0x8, %eax
addl %eax, 0x875e(%rip)      # 0xf204
movq %rbx, %rdi
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movzbl %al, %eax
movl %eax, 0x8741(%rip)      # 0xf200
movq %rbx, %rdi
callq 0x1d32
movzbl %al, %edi
callq 0x414f
movzbl %al, %eax
shll $0x8, %eax
addl 0x8725(%rip), %eax      # 0xf200
movl %eax, 0x871f(%rip)      # 0xf200
je 0x6b10
movb 0x8738(%rip), %cl       # 0xf221
xorl %edx, %edx
cmpb $0x24, %cl
sete %dl
shll $0x8, %edx
xorl %esi, %esi
cmpb $0x25, %cl
setne %sil
shll $0x8, %esi
addl %eax, %edx
leal (%rsi,%rdx), %eax
addl $0xffffff00, %eax       # imm = 0xFFFFFF00
movl %eax, 0x86f0(%rip)      # 0xf200
callq 0x16b7
movl 0x86e9(%rip), %eax      # 0xf204
movb $0x1, %cl
cmpl $0x6, %eax
jb 0x6b3d
movl 0x86d8(%rip), %ecx      # 0xf200
cmpl $0x5b1c, %ecx           # imm = 0x5B1C
setb %dl
addl %ecx, %eax
cmpl $0x5b1e, %eax           # imm = 0x5B1E
setae %cl
andb %dl, %cl
movb %cl, 0x86dd(%rip)       # 0xf220
cmpb $0x0, 0x865b(%rip)      # 0xf1a5
je 0x6bde
movq 0x8681(%rip), %rbx      # 0xf1d8
callq 0x15e9
movl 0x86d2(%rip), %eax      # 0xf234
leaq 0x153c7(%rip), %rcx     # 0x1bf30
movb (%rax,%rcx), %dl
movb %dl, 0x156be(%rip)      # 0x1c230
testb %dl, %dl
je 0x6bae
leal 0x1(%rax), %edx
movzbl (%rdx,%rcx), %edx
leal 0x2(%rax), %esi
movzbl (%rsi,%rcx), %esi
shll $0x8, %esi
addl %esi, %edx
incl %edx
movl %edx, 0x8673(%rip)      # 0xf204
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
leal 0x4(%rax), %esi
movzbl (%rsi,%rcx), %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl %ecx, 0x8656(%rip)      # 0xf200
xorl %ecx, %ecx
jmp 0x6bb0
movb $0x1, %cl
movb %cl, 0x15026(%rip)      # 0x1bbdc
addl $0x5, %eax
movl %eax, 0x8675(%rip)      # 0xf234
movq %rbx, 0x8612(%rip)      # 0xf1d8
movzbl 0x86a3(%rip), %edi      # 0xf270
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0x8792(%rip)      # 0xf370
popq %rbx
popq %r14
popq %r15
retq
movups 0x3e0a(%rip), %xmm0     # 0xa9f5
movaps %xmm0, 0x14ade(%rip)    # 0x1b6d0
movb $0x0, 0x14ae7(%rip)     # 0x1b6e0
pushq $0x8
popq %rdi
callq 0x13ed