// File: pelrun[P]aft/CDSKFile.cpp
// Function: CExtendedDSKFile::readDSK(std::istream&)
bool CExtendedDSKFile::readDSK(std::istream &str)
{
	_header.Read(str);

	if (_header.NbTrack == 0 && _header.NbSide == 0)
		return false;

	_tracks = new CDSKTrack[_header.NbTrack * _header.NbSide];

	unsigned int trackOff = 0x100;
	for (int t=0 ; t<_header.NbTrack ; t++)
	{
		for (int s=0 ; s<_header.NbSide ; s++)
		{
			if (_header.TrackSizeTable[(t*_header.NbSide) + s] != 0)
			{
				str.seekg(trackOff, std::ios::beg);

				_tracks[(t*_header.NbSide) + s].Read(str);

				trackOff += _header.TrackSizeTable[(t*_header.NbSide) + s] << 8;
			}
		}
	}

	return true;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq 0x78(%rsp), %rdi
movq %rdi, 0x50(%rsp)
addq $0x10, %rdi
movq 0x70(%rsp), %rsi
callq 0x7f30
movq 0x50(%rsp), %rax
movzbl 0x4a(%rax), %eax
cmpl $0x0, %eax
jne 0xaba2
movq 0x50(%rsp), %rax
movzbl 0x4b(%rax), %eax
cmpl $0x0, %eax
jne 0xaba2
movb $0x0, 0x87(%rsp)
jmp 0xadad
movq 0x50(%rsp), %rcx
movzbl 0x4a(%rcx), %eax
movzbl 0x4b(%rcx), %ecx
imull %ecx, %eax
cltq
movq %rax, 0x38(%rsp)
movl $0x28, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, 0x30(%rsp)
callq 0x4030
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x48(%rsp)
cmpq $0x0, %rax
je 0xac4e
movq 0x48(%rsp), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x8a50
jmp 0xac36
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
addq $0x28, %rax
cmpq %rcx, %rax
movq %rax, 0x28(%rsp)
jne 0xac25
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl $0x100, 0x60(%rsp)      # imm = 0x100
movl $0x0, 0x5c(%rsp)
movq 0x50(%rsp), %rcx
movl 0x5c(%rsp), %eax
movzbl 0x4a(%rcx), %ecx
cmpl %ecx, %eax
jge 0xada5
movl $0x0, 0x58(%rsp)
movq 0x50(%rsp), %rcx
movl 0x58(%rsp), %eax
movzbl 0x4b(%rcx), %ecx
cmpl %ecx, %eax
jge 0xad93
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %ecx
movzbl 0x4b(%rax), %edx
imull %edx, %ecx
addl 0x58(%rsp), %ecx
movslq %ecx, %rcx
movzbl 0x4e(%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xad81
movq 0x70(%rsp), %rdi
movl 0x60(%rsp), %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x44d0
movq 0x50(%rsp), %rcx
movq 0x8(%rcx), %rdi
movl 0x5c(%rsp), %eax
movzbl 0x4b(%rcx), %ecx
imull %ecx, %eax
addl 0x58(%rsp), %eax
cltq
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq 0x70(%rsp), %rsi
callq 0x8b90
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %ecx
movzbl 0x4b(%rax), %edx
imull %edx, %ecx
addl 0x58(%rsp), %ecx
movslq %ecx, %rcx
movzbl 0x4e(%rax,%rcx), %eax
shll $0x8, %eax
addl 0x60(%rsp), %eax
movl %eax, 0x60(%rsp)
jmp 0xad81
movq 0x48(%rsp), %rcx
movq %rax, %rsi
movq 0x18(%rsp), %rax
movq %rsi, 0x68(%rsp)
movl %edx, 0x64(%rsp)
cmpq %rax, %rcx
movq %rax, 0x10(%rsp)
je 0xad70
movq 0x10(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x8(%rsp)
callq 0x8ae0
movq 0x48(%rsp), %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x10(%rsp)
jne 0xad49
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %rdi
callq 0x4660
jmp 0xadbe
jmp 0xad83
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0xac89
jmp 0xad95
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0xac6c
movb $0x1, 0x87(%rsp)
movb 0x87(%rsp), %al
andb $0x1, %al
addq $0x88, %rsp
retq
movq 0x68(%rsp), %rdi
callq 0x11ab0
nopl (%rax,%rax)