// File: /workspace/github_c_makefile_star2_O1/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, 0x81a2(%rip)      # 0xf1b4
je 0x716c
movl %edi, %r14d
movq 0x81c6(%rip), %rbx      # 0xf1e8
callq 0x161f
movl 0x81e3(%rip), %eax      # 0xf210
movl 0x8205(%rip), %ecx      # 0xf238
leal -0x319(%rcx), %edx
cmpl %edx, %eax
jbe 0x7076
cmpl %ecx, %eax
setae %al
cmpl $0x2, %r14d
setne %cl
orb %al, %cl
jne 0x7076
leaq 0x10464(%rip), %r15     # 0x174b8
movq %r15, %rdi
callq 0x1db5
movq %r15, %rdi
callq 0x1db5
xorb 0x8096(%rip), %al       # 0xf100
addb 0x8091(%rip), %al       # 0xf101
movb %al, 0x808a(%rip)       # 0xf100
movl 0x8194(%rip), %ecx      # 0xf210
movl 0x81ba(%rip), %edx      # 0xf23c
movl %ecx, %eax
subl %edx, %eax
setb %sil
leal (%rcx,%r14), %edi
cmpl %edx, %edi
setbe %dl
testb %dl, %sil
jne 0x70df
movl 0x819a(%rip), %edx      # 0xf238
movl $0xc001, %esi           # imm = 0xC001
cmpl %esi, %edx
setae %dil
cmpl %esi, %ecx
setae %sil
testb %dil, %sil
jne 0x70c7
movl $0xc000, %esi           # imm = 0xC000
cmpl %esi, %edx
setae %dl
cmpl %esi, %ecx
setae %cl
orb %dl, %cl
jne 0x70df
cmpl $0x81, %r14d
jae 0x7415
movzbl %al, %esi
movl %r14d, %edi
callq 0x6da3
movl 0x815f(%rip), %eax      # 0xf244
leal 0x2(%rax), %edx
leaq 0x14e51(%rip), %rcx     # 0x1bf40
movzbl (%rdx,%rcx), %esi
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
shll $0x8, %edx
orl %esi, %edx
movl %edx, 0x810f(%rip)      # 0xf214
je 0x713a
incl %edx
movl %edx, 0x8105(%rip)      # 0xf214
movb $0x0, 0x14ad6(%rip)     # 0x1bbec
movzbl (%rax,%rcx), %edx
leal 0x1(%rax), %esi
movzbl (%rsi,%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movl %esi, 0x80e4(%rip)      # 0xf210
leal 0x4(%rax), %edx
movb (%rdx,%rcx), %cl
movb %cl, 0x15108(%rip)      # 0x1c240
jmp 0x7141
movb $0x1, 0x14aab(%rip)     # 0x1bbec
addl $0x5, %eax
movl %eax, 0x80fa(%rip)      # 0xf244
movq %rbx, 0x8097(%rip)      # 0xf1e8
movzbl 0x8128(%rip), %edi      # 0xf280
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x8214(%rip)      # 0xf380
cmpb $0x0, 0x803f(%rip)      # 0xf1b2
je 0x736d
cmpb $0x0, 0x80b0(%rip)      # 0xf230
je 0x721c
callq 0x161f
callq 0x165a
leaq 0x10321(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %dl
xorl %ecx, %ecx
movl %ecx, %esi
shrb %sil
movl %eax, %ecx
andb $-0x80, %cl
orb %sil, %cl
addb %al, %al
decb %dl
jne 0x71a0
movb %cl, 0x8078(%rip)       # 0xf231
cmpl $0x5b00, 0x804d(%rip)   # imm = 0x5B00
sete %al
cmpb $0x3b, %cl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x71e2
movl $0x0, 0x8033(%rip)      # 0xf210
jmp 0x740f
leaq 0x102cf(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x71f2
movb %dl, 0x8026(%rip)       # 0xf231
callq 0x161f
callq 0x16fb
movb $0x0, 0x8014(%rip)      # 0xf230
movsd 0x14564(%rip), %xmm0    # 0x1b788
movsd 0x1457c(%rip), %xmm1    # 0x1b7a8
movl $0x4, %edi
callq 0x39c9
movl $0x4, %esi
movl $0x8, %edi
callq 0x6442
callq 0x165a
callq 0x161f
leaq 0x10262(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x725f
movzbl %dl, %eax
movl %eax, 0x7f99(%rip)      # 0xf214
leaq 0x10236(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x728b
movzbl %dl, %eax
shll $0x8, %eax
addl %eax, 0x7f6a(%rip)      # 0xf214
leaq 0x10207(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x72ba
movzbl %dl, %eax
movl %eax, 0x7f3a(%rip)      # 0xf210
leaq 0x101db(%rip), %rdi     # 0x174b8
callq 0x1db5
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x72e6
movzbl %dl, %eax
shll $0x8, %eax
addl 0x7f0b(%rip), %eax      # 0xf210
movl %eax, 0x7f05(%rip)      # 0xf210
je 0x733a
movb 0x7f1e(%rip), %cl       # 0xf231
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, 0x7ed6(%rip)      # 0xf210
callq 0x16fb
movl 0x7ecf(%rip), %eax      # 0xf214
movb $0x1, %cl
cmpl $0x6, %eax
jb 0x7367
movl 0x7ebe(%rip), %ecx      # 0xf210
cmpl $0x5b1c, %ecx           # imm = 0x5B1C
setb %dl
addl %ecx, %eax
cmpl $0x5b1e, %eax           # imm = 0x5B1E
setae %cl
andb %dl, %cl
movb %cl, 0x7ec3(%rip)       # 0xf230
cmpb $0x0, 0x7e41(%rip)      # 0xf1b5
je 0x740f
movq 0x7e67(%rip), %rbx      # 0xf1e8
callq 0x161f
movl 0x7eb8(%rip), %eax      # 0xf244
leaq 0x14bad(%rip), %rcx     # 0x1bf40
movb (%rax,%rcx), %dl
movb %dl, 0x14ea4(%rip)      # 0x1c240
testb %dl, %dl
je 0x73dd
movb $0x0, 0x14845(%rip)     # 0x1bbec
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, 0x7e52(%rip)      # 0xf214
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
leal 0x4(%rax), %esi
movzbl (%rsi,%rcx), %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl %ecx, 0x7e35(%rip)      # 0xf210
jmp 0x73e4
movb $0x1, 0x14808(%rip)     # 0x1bbec
addl $0x5, %eax
movl %eax, 0x7e57(%rip)      # 0xf244
movq %rbx, 0x7df4(%rip)      # 0xf1e8
movzbl 0x7e85(%rip), %edi      # 0xf280
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x7f71(%rip)      # 0xf380
popq %rbx
popq %r14
popq %r15
retq
movups 0x4639(%rip), %xmm0     # 0xba55
movaps %xmm0, 0x142bd(%rip)    # 0x1b6e0
movb $0x0, 0x142c6(%rip)     # 0x1b6f0
movl $0x8, %edi
callq 0x140c