// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
cmpb $0x0, 0x9e45(%rip)      # 0x13194
je 0x954f
movq 0x9e6c(%rip), %rax      # 0x131c8
movq %rax, 0x18(%rsp)
callq 0x18a0
movl 0x9e84(%rip), %eax      # 0x131f0
movl 0x9ea6(%rip), %ecx      # 0x13218
subl $0x319, %ecx            # imm = 0x319
cmpl %ecx, %eax
jbe 0x93c6
movl 0x9e6e(%rip), %eax      # 0x131f0
cmpl 0x9e90(%rip), %eax      # 0x13218
jae 0x93c6
cmpl $0x2, 0x24(%rsp)
jne 0x93c4
leaq 0x12100(%rip), %rdi     # 0x1b498
callq 0x2370
leaq 0x120f4(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %eax
movzbl 0x9d2d(%rip), %ecx      # 0x130e0
xorl %ecx, %eax
movzbl 0x9d25(%rip), %ecx      # 0x130e1
addl %ecx, %eax
movb %al, 0x9d1c(%rip)       # 0x130e0
jmp 0x93c6
movl 0x9e24(%rip), %eax      # 0x131f0
cmpl 0x9e4a(%rip), %eax      # 0x1321c
jae 0x93e6
movl 0x9e16(%rip), %eax      # 0x131f0
addl 0x24(%rsp), %eax
cmpl 0x9e38(%rip), %eax      # 0x1321c
jbe 0x945f
cmpl $0xc000, 0x9e28(%rip)   # imm = 0xC000
jbe 0x93fe
cmpl $0xc000, 0x9df4(%rip)   # imm = 0xC000
ja 0x9416
cmpl $0xc000, 0x9e10(%rip)   # imm = 0xC000
jae 0x945f
cmpl $0xc000, 0x9ddc(%rip)   # imm = 0xC000
jae 0x945f
cmpl $0x80, 0x24(%rsp)
jbe 0x943f
leaq 0x16299(%rip), %rdi     # 0x1f6c0
leaq 0x719f(%rip), %rsi      # 0x105cd
callq 0x1050
movl $0x8, %edi
callq 0x15c0
jmp 0x945d
movl 0x9dab(%rip), %eax      # 0x131f0
subl 0x9dd1(%rip), %eax      # 0x1321c
movb %al, 0x17(%rsp)
movl 0x24(%rsp), %edi
movzbl 0x17(%rsp), %esi
callq 0x8f00
jmp 0x945f
movl 0x9dbf(%rip), %eax      # 0x13224
addl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x16aad(%rip), %rax     # 0x1ff20
movzbl (%rax,%rcx), %eax
movl 0x9da7(%rip), %ecx      # 0x13224
addl $0x3, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x16a95(%rip), %rcx     # 0x1ff20
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, 0x9d5a(%rip)      # 0x131f4
cmpl $0x0, 0x9d53(%rip)      # 0x131f4
je 0x950e
movl 0x9d4b(%rip), %eax      # 0x131f4
addl $0x1, %eax
movl %eax, 0x9d42(%rip)      # 0x131f4
movb $0x0, 0x16713(%rip)     # 0x1fbcc
movl 0x9d65(%rip), %eax      # 0x13224
movl %eax, %ecx
leaq 0x16a58(%rip), %rax     # 0x1ff20
movzbl (%rax,%rcx), %eax
movl 0x9d52(%rip), %ecx      # 0x13224
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x16a40(%rip), %rcx     # 0x1ff20
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, 0x9d01(%rip)      # 0x131f0
movl 0x9d2f(%rip), %eax      # 0x13224
addl $0x4, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x16a1d(%rip), %rax     # 0x1ff20
movb (%rax,%rcx), %al
movb %al, 0x16d14(%rip)      # 0x20220
jmp 0x9515
movb $0x1, 0x166b7(%rip)     # 0x1fbcc
movl 0x9d09(%rip), %eax      # 0x13224
addl $0x5, %eax
movl %eax, 0x9d00(%rip)      # 0x13224
movq 0x18(%rsp), %rax
movq %rax, 0x9c98(%rip)      # 0x131c8
movzbl 0x9d29(%rip), %edi      # 0x13260
movq 0x9c8a(%rip), %rsi      # 0x131c8
xorl %edx, %edx
callq 0x10b0
movl $0x0, 0x9e11(%rip)      # 0x13360
cmpb $0x0, 0x9c3c(%rip)      # 0x13192
je 0x9715
cmpb $0x0, 0x9cad(%rip)      # 0x13210
je 0x95db
callq 0x18a0
callq 0x18e0
leaq 0x11f22(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movb %al, 0x9c88(%rip)       # 0x13211
cmpl $0x5b00, 0x9c5d(%rip)   # imm = 0x5B00
jne 0x95b0
movzbl 0x9c75(%rip), %eax      # 0x13211
cmpl $0x3b, %eax
je 0x95b0
movl $0x0, 0x9c45(%rip)      # 0x131f0
jmp 0x981b
leaq 0x11ee1(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movb %al, 0x9c47(%rip)       # 0x13211
callq 0x18a0
callq 0x1a10
movb $0x0, 0x9c35(%rip)      # 0x13210
movsd 0x16185(%rip), %xmm0    # 0x1f768
movsd 0x1619d(%rip), %xmm1    # 0x1f788
movl $0x4, %edi
callq 0x4d70
movl $0x8, %edi
movl $0x4, %esi
callq 0x84d0
callq 0x18e0
callq 0x18a0
leaq 0x11e83(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movzbl %al, %eax
movl %eax, 0x9bc9(%rip)      # 0x131f4
leaq 0x11e66(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movzbl %al, %eax
shll $0x8, %eax
addl 0x9ba9(%rip), %eax      # 0x131f4
movl %eax, 0x9ba3(%rip)      # 0x131f4
leaq 0x11e40(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movzbl %al, %eax
movl %eax, 0x9b82(%rip)      # 0x131f0
leaq 0x11e23(%rip), %rdi     # 0x1b498
callq 0x2370
movzbl %al, %edi
callq 0x5cd0
movzbl %al, %eax
shll $0x8, %eax
addl 0x9b62(%rip), %eax      # 0x131f0
movl %eax, 0x9b5c(%rip)      # 0x131f0
cmpl $0x0, 0x9b55(%rip)      # 0x131f0
je 0x96d6
movzbl 0x9b6d(%rip), %eax      # 0x13211
cmpl $0x24, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
shll $0x8, %eax
movzbl 0x9b58(%rip), %ecx      # 0x13211
cmpl $0x25, %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
shll $0x8, %ecx
subl %ecx, %eax
addl 0x9b20(%rip), %eax      # 0x131f0
movl %eax, 0x9b1a(%rip)      # 0x131f0
callq 0x1a10
cmpl $0x5, 0x9b12(%rip)      # 0x131f4
jbe 0x9703
cmpl $0x5b1c, 0x9b02(%rip)   # imm = 0x5B1C
jae 0x970c
movl 0x9afa(%rip), %eax      # 0x131f0
addl 0x9af8(%rip), %eax      # 0x131f4
cmpl $0x5b1d, %eax           # imm = 0x5B1D
jbe 0x970c
movb $0x1, 0x9b06(%rip)      # 0x13210
jmp 0x9713
movb $0x0, 0x9afd(%rip)      # 0x13210
jmp 0x9715
cmpb $0x0, 0x9a79(%rip)      # 0x13195
je 0x981b
movq 0x9a9f(%rip), %rax      # 0x131c8
movq %rax, 0x8(%rsp)
callq 0x18a0
movl 0x9aeb(%rip), %eax      # 0x13224
movl %eax, %ecx
leaq 0x167de(%rip), %rax     # 0x1ff20
movb (%rax,%rcx), %al
movb %al, 0x16ad5(%rip)      # 0x20220
cmpb $0x0, 0x16ace(%rip)     # 0x20220
je 0x97da
movb $0x0, 0x1646d(%rip)     # 0x1fbcc
movl 0x9abf(%rip), %eax      # 0x13224
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x167ad(%rip), %rax     # 0x1ff20
movzbl (%rax,%rcx), %eax
addl $0x1, %eax
movl 0x9aa4(%rip), %ecx      # 0x13224
addl $0x2, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x16792(%rip), %rcx     # 0x1ff20
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, 0x9a57(%rip)      # 0x131f4
movl 0x9a81(%rip), %eax      # 0x13224
addl $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1676f(%rip), %rax     # 0x1ff20
movzbl (%rax,%rcx), %eax
movl 0x9a69(%rip), %ecx      # 0x13224
addl $0x4, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x16757(%rip), %rcx     # 0x1ff20
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, 0x9a18(%rip)      # 0x131f0
jmp 0x97e1
movb $0x1, 0x163eb(%rip)     # 0x1fbcc
movl 0x9a3d(%rip), %eax      # 0x13224
addl $0x5, %eax
movl %eax, 0x9a34(%rip)      # 0x13224
movq 0x8(%rsp), %rax
movq %rax, 0x99cc(%rip)      # 0x131c8
movzbl 0x9a5d(%rip), %edi      # 0x13260
movq 0x99be(%rip), %rsi      # 0x131c8
xorl %edx, %edx
callq 0x10b0
movl $0x0, 0x9b45(%rip)      # 0x13360
addq $0x28, %rsp
retq