LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_StepLoop(CapsFdc*)
void FdcComT1_StepLoop(PCAPSFDC pc)
{
	// clock cycles to complete
	UDWORD cmax=pc->clockreq-pc->clockact;

	// only allow delay cycles
	if (cmax > pc->clockcnt)
		cmax=pc->clockcnt;

	// run cycles
	pc->clockcnt-=FdcComIdle(pc, cmax);

	// if delay finished
	if (!pc->clockcnt) {
		// repeat step phase if seek or restore, or end loop
		if (pc->r_command < 0x20)
			pc->runstate--;
		else
			pc->runstate++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xb4(%rcx), %eax
jbe 0x8fb9
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
movl %eax, %edx
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xb4(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
jne 0x900e
movq -0x8(%rbp), %rax
cmpl $0x20, 0x3c(%rax)
jae 0x8fff
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x900c
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x900e
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_DelayStart(CapsFdc*)
void FdcComT1_DelayStart(PCAPSFDC pc)
{
	// end if no verify
	if (!(pc->r_command & DF_2)) {
		pc->endrequest|=CAPSFDC_ER_COMEND;
		return;
	}

	// set settle delay
	pc->clockcnt=pc->clockhs;

	// set loop
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
andq $0x4, %rax
cmpq $0x0, %rax
jne 0x9049
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
orq $0x1, %rcx
movl %ecx, 0x8(%rax)
jmp 0x906a
movq -0x8(%rbp), %rax
movl 0xdc(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xb4(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_DelayLoop(CapsFdc*)
void FdcComT1_DelayLoop(PCAPSFDC pc)
{
	// clock cycles to complete
	UDWORD cmax=pc->clockreq-pc->clockact;

	// only allow delay cycles
	if (cmax > pc->clockcnt)
		cmax=pc->clockcnt;

	// run cycles
	pc->clockcnt-=FdcComIdle(pc, cmax);

	// end loop if delay finished
	if (!pc->clockcnt)
		pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xb4(%rcx), %eax
jbe 0x90a9
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
movl %eax, %edx
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xb4(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
jne 0x90e3
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT2_DelayStart(CapsFdc*)
void FdcComT2_DelayStart(PCAPSFDC pc)
{
	// skip if no delay
	if (!(pc->r_command & DF_2)) {
		pc->runstate+=2;
		return;
	}

	// set settle delay
	pc->clockcnt=pc->clockhs;

	// set loop
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
andq $0x4, %rax
cmpq $0x0, %rax
jne 0x9338
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x9359
movq -0x8(%rbp), %rax
movl 0xdc(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xb4(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT3_IndexStart(CapsFdc*)
void FdcComT3_IndexStart(PCAPSFDC pc)
{
	// nothing changes if no input
	if (pc->driveprc) {
		// skip if on index
		if (!pc->driveprc->idistance) {
			pc->runstate+=2;
			return;
		}
	}

	// set loop
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
je 0x98f8
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
cmpl $0x0, 0x24(%rax)
jne 0x98f6
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x9905
jmp 0x98f8
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopw (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT3_IndexLoop(CapsFdc*)
void FdcComT3_IndexLoop(PCAPSFDC pc)
{
	// clock cycles to complete
	UDWORD cmax=pc->clockreq-pc->clockact;

	// if no drive selected run all cycles index can't happen
	if (!pc->driveprc) {
		FdcComIdle(pc, cmax);
		return;
	}

	// if index can't happen on enabled drive run all cycles
	PCAPSDRIVE pd=pc->driveprc;
	if ((pd->diskattr & CAPSDRIVE_DA_IPMASK) != CAPSDRIVE_DA_IPMASK) {
		FdcComIdle(pc, cmax);
		return;
	}

	// if index event won't happen, run it all
	if (pd->idistance+cmax < pd->clockrev){
		FdcComIdle(pc, cmax);
		return;
	}

	// cycles until index
	cmax=pd->clockrev-pd->idistance;

	// index happens now, only run cycles until index
	if (FdcComIdle(pc, cmax) != cmax)
		return;

	// end loop, but only if wait was complete
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
jne 0x994c
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x99cc
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x5, %rax
cmpq $0x5, %rax
je 0x997a
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x99cc
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
addl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jae 0x999b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x99cc
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0x24(%rcx), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
cmpl -0xc(%rbp), %eax
je 0x99bf
jmp 0x99cc
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT3_ReadStart(CapsFdc*)
void FdcComT3_ReadStart(PCAPSFDC pc)
{
	// reset logic
	FdcResetData(pc);
	pc->aminfo&=~CAPSFDC_AI_CRCENABLE;
	pc->amisigmask=CAPSFDC_AI_DSRREADY;

	// abort on next index
	pc->indexlimit=1;

	// set loop
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xaf30
movq -0x8(%rbp), %rax
movl 0x60(%rax), %ecx
andq $-0x3, %rcx
movl %ecx, 0x60(%rax)
movq -0x8(%rbp), %rax
movl $0x100, 0x64(%rax)      # imm = 0x100
movq -0x8(%rbp), %rax
movl $0x1, 0x98(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
addq $0x10, %rsp
popq %rbp
retq
nop
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT3_ReadLoop(CapsFdc*)
void FdcComT3_ReadLoop(PCAPSFDC pc)
{
	// update data access
	FdcUpdateData(pc);

	// get access hook, crc
	FDCREAD ph=FdcGetReadAccess(pc);

	// clock cycles to complete
	UDWORD cst=pc->clockact;

	// process requested cycles
	while (!pc->endrequest && pc->clockact<pc->clockreq) {
		// read byte when ready
		if (!ph(pc))
			continue;

		// dsr to data, drq signal
		pc->r_data=pc->dsr;
		FdcSetLine(pc, pc->lineout|CAPSFDC_LO_DRQSET);
	}

	// run cycles on unselected drives
	FdcComIdleOther(pc, pc->clockact-cst);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xb000
movq -0x8(%rbp), %rdi
callq 0xb130
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
movb %al, -0x15(%rbp)
jne 0x9a7f
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
setb %al
movb %al, -0x15(%rbp)
movb -0x15(%rbp), %al
testb $0x1, %al
jne 0x9a88
jmp 0x9abf
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jne 0x9a99
jmp 0x9a5c
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
orq $0x40, %rax
movl %eax, %esi
callq 0xa860
jmp 0x9a5c
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xc(%rax), %esi
subl -0x14(%rbp), %esi
callq 0xb200
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT3_WriteCheck(CapsFdc*)
void FdcComT3_WriteCheck(PCAPSFDC pc)
{
	// if wp signal, end command
	if (pc->r_st0 & CAPSFDC_SR_WP) {
		pc->endrequest|=CAPSFDC_ER_COMEND;
		return;
	}

	// next
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andq $0x40, %rax
cmpq $0x0, %rax
je 0x9b09
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
orq $0x1, %rcx
movl %ecx, 0x8(%rax)
jmp 0x9b16
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: CAPSFdcGetInfo(int, CapsFdc*, int)
UDWORD __cdecl CAPSFdcGetInfo(SDWORD iid, PCAPSFDC pc, SDWORD ext)
{
	UDWORD res=0;

	switch (iid) {
		case cfdciSize_Fdc:
			res=sizeof(CapsFdc);
			break;

		case cfdciSize_Drive:
			res=sizeof(CapsDrive);
			break;

		case cfdciR_Command:
			res=pc->r_command;
			break;

		case cfdciR_ST:
			res=(pc->r_st0 & ~pc->r_stm) | (pc->r_st1 & pc->r_stm);
			break;

		case cfdciR_Track:
			res=pc->r_track;
			break;

		case cfdciR_Sector:
			res=pc->r_sector;
			break;

		case cfdciR_Data:
			res=pc->r_data;
			break;
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x6, %eax
ja 0x9de1
movq -0x20(%rbp), %rax
leaq 0x14388(%rip), %rcx     # 0x1e0f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x134, -0x18(%rbp)     # imm = 0x134
jmp 0x9de1
movl $0x78, -0x18(%rbp)
jmp 0x9de1
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0x9de1
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
movl 0x38(%rcx), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movl 0x34(%rcx), %ecx
movq -0x10(%rbp), %rdx
andl 0x38(%rdx), %ecx
orl %ecx, %eax
movl %eax, -0x18(%rbp)
jmp 0x9de1
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0x9de1
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0x9de1
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcSetTiming(CapsFdc*)
void FdcSetTiming(PCAPSFDC pc)
{
	// drive specific values
	for (int drv=0; drv < pc->drivecnt; drv++) {
		PCAPSDRIVE pd=pc->drive+drv;

		// clock cycles per revolution
		pd->clockrev=UDWORD(((UQUAD)pc->clockfrq*60)/pd->rpm);

		// clock cycles for index pulse hold
		pd->clockip=UDWORD(((UQUAD)pc->clockfrq*pc->iptime)/1000000);
	}

	// clock cycles for stepping rates
	for (int drv=0; drv < 4; drv++)
		pc->clockstep[drv]=UDWORD(((UQUAD)pc->clockfrq*pc->steptime[drv])/1000000);

	// clock cycles for head settling
	pc->clockhs=UDWORD(((UQUAD)pc->clockfrq*pc->hstime)/1000000);

	// clock cycles for short operations (some SR updates)
	pc->clockupdate=UDWORD(((UQUAD)pc->clockfrq*pc->updatetime)/1000000);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xec(%rcx), %eax
jge 0xa11b
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
imulq $0x3c, %rax, %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0xe0(%rcx), %ecx
imulq %rcx, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xa09f
movl $0x0, -0x1c(%rbp)
cmpl $0x4, -0x1c(%rbp)
jge 0xa168
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x8(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
movl 0xb8(%rcx,%rdx,4), %ecx
imulq %rcx, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movl %eax, %edx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0xc8(%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa122
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0xd8(%rcx), %ecx
imulq %rcx, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xdc(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0xe4(%rcx), %ecx
imulq %rcx, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xe8(%rax)
popq %rbp
retq
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcInit(CapsFdc*)
void FdcInit(PCAPSFDC pc)
{
	// reset drives, no disk inserted
	for (int drv=0; drv < pc->drivecnt; drv++) {
		PCAPSDRIVE pd=pc->drive+drv;
		pd->track=0;
		pd->buftrack=-1;
		pd->side=0;
		pd->bufside=-1;
		pd->newside=0;
		pd->diskattr=CAPSDRIVE_DA_WP;
		pd->idistance=0;
		pd->ipcnt=0;
		pd->ovlact=0;
		pd->nact=0;
		pd->nseed=0x87654321;

		// no track data
		FdcClearTrackData(pd);
	}

	// reset internal state
	FdcResetState(pc);

	// all output lines are clear, without callbacks from init
	pc->dataline=0;
	pc->lineout=0;

	// forced update
	pc->drivesel=pc->drivenew-1;
	FdcUpdateDrive(pc, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xec(%rcx), %eax
jge 0xa290
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl $0x2, 0x20(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x18(%rbp), %rax
movl $0x87654321, 0x68(%rax) # imm = 0x87654321
movq -0x18(%rbp), %rdi
callq 0xabf0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xa1d3
movq -0x8(%rbp), %rdi
callq 0xac60
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x8(%rbp), %rax
movl 0xf4(%rax), %ecx
subl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xf8(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xa4d0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcReset(CapsFdc*)
void FdcReset(PCAPSFDC pc)
{
	// reset internal state
	FdcResetState(pc);

	// all output lines are clear
	pc->dataline=0;
	FdcSetLine(pc, 0);

	// forced update
	pc->drivesel=pc->drivenew-1;
	FdcUpdateDrive(pc, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xac60
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xa860
movq -0x8(%rbp), %rax
movl 0xf4(%rax), %ecx
subl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xf8(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xa4d0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: CAPSFdcEmulate(CapsFdc*, unsigned int)
void __cdecl CAPSFdcEmulate(PCAPSFDC pc, UDWORD cyclecnt)
{
	// no cycles done
	pc->clockact=0;

	// requested cycles
	pc->clockreq=cyclecnt;

	// no end request
	pc->endrequest=0;

	// run fdc for selected clock cycles
	if (pc->clockreq) {
		FDCCALL *fc=fdccall[pc->runmode];

		// process requested cycles
		while (!pc->endrequest && pc->clockact<pc->clockreq)
			fc[pc->runstate](pc);

		// stop processing after end request
		if (pc->endrequest)
			FdcComEnd(pc);
	}

	// update only if all cycles are complete
	if (pc->clockact >= pc->clockreq)
		FdcUpdateDrive(pc, pc->clockreq);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0xc(%rax)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0xa419
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, %ecx
leaq 0x1d227(%rip), %rax     # 0x275e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
movb %al, -0x19(%rbp)
jne 0xa3e4
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
setb %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0xa3ed
jmp 0xa404
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x2c(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0xa3c1
movq -0x8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0xa417
movq -0x8(%rbp), %rdi
callq 0xa440
jmp 0xa419
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jb 0xa439
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
callq 0xa4d0
addq $0x20, %rsp
popq %rbp
retq
nop
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComEnd(CapsFdc*)
void FdcComEnd(PCAPSFDC pc)
{
	// command complete
	if (pc->endrequest & CAPSFDC_ER_COMEND) {
		// start idle
		pc->runmode=cfdcrmIdle;
		pc->runstate=0;
		pc->indexlimit=-1;
		pc->idlecnt=0;

		// clear busy
		pc->r_st0&=~CAPSFDC_SR_BUSY;

		// set intrq
		FdcSetLine(pc, pc->lineout|CAPSFDC_LO_INTRQ);
	}

	// run remaining cycles
	FdcComIdle(pc, pc->clockreq-pc->clockact);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xa4b3
movq -0x8(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x98(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0xac(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
andq $-0x2, %rcx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
orq $0x2, %rax
movl %eax, %esi
callq 0xa860
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
movq -0x8(%rbp), %rax
subl 0xc(%rax), %esi
callq 0xae40
addq $0x10, %rsp
popq %rbp
retq
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: CAPSFdcRead(CapsFdc*, unsigned int)
UDWORD __cdecl CAPSFdcRead(PCAPSFDC pc, UDWORD address)
{
	UDWORD data;

	// mask valid address lines
	switch (address & pc->addressmask) {
		// status, clear intrq
		case 0:
			data=(pc->r_st0 & ~pc->r_stm) | (pc->r_st1 & pc->r_stm);
			FdcSetLine(pc, pc->lineout&~CAPSFDC_LO_INTRQ);
			break;

		// track
		case 1:
			data=pc->r_track;
			break;

		// sector
		case 2:
			data=pc->r_sector;
			break;

		// data, clear drq if set
		case 3:
			data=pc->r_data;
			FdcSetLine(pc, pc->lineout&~CAPSFDC_LO_DRQ);
			break;

		default:
			NODEFAULT;
	}

	// return valid data bits only
	data&=pc->datamask;

	// set data bus
	pc->dataline=data;

	return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl %ecx, %eax
movl %eax, %ecx
movq %rcx, -0x18(%rbp)
subl $0x3, %eax
ja 0xa836
movq -0x18(%rbp), %rax
leaq 0x1395f(%rip), %rcx     # 0x1e114
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %ecx
movq -0x8(%rbp), %rdx
andl 0x38(%rdx), %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andq $-0x3, %rax
movl %eax, %esi
callq 0xa860
jmp 0xa838
movq -0x8(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x10(%rbp)
jmp 0xa838
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x10(%rbp)
jmp 0xa838
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andq $-0x2, %rax
movl %eax, %esi
callq 0xa860
jmp 0xa838
jmp 0xa838
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
andl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0x10(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcSetLine(CapsFdc*, unsigned int)
void FdcSetLine(PCAPSFDC pc, UDWORD lineout)
{
	// forced interrupt keeps intrq set
	if (lineout & CAPSFDC_LO_INTFRC)
		lineout|=CAPSFDC_LO_INTRQ;

	// get old line state
	UDWORD oldline=pc->lineout;

	// check for drq set
	if (lineout & CAPSFDC_LO_DRQSET) {
		lineout&=~CAPSFDC_LO_DRQSET;
		lineout|=CAPSFDC_LO_DRQ;

		// data lost, if trying to set drq and drq is already set
		if (oldline & CAPSFDC_LO_DRQ)
			pc->r_st1|=CAPSFDC_SR_TR0_LD;
	}

	// changed bits are 1
	UDWORD chgmask=oldline ^ lineout;

	// set new line state
	pc->lineout=lineout;

	// drq change
	if (chgmask & CAPSFDC_LO_DRQ) {
		UDWORD setting=lineout & CAPSFDC_LO_DRQ;
		if (setting)
			pc->r_st1|=CAPSFDC_SR_IP_DRQ;
		else
			pc->r_st1&=~CAPSFDC_SR_IP_DRQ;
		pc->cbdrq(pc, setting);
	}

	// irq change
	if (chgmask & CAPSFDC_LO_INTRQ)
		pc->cbirq(pc, lineout & CAPSFDC_LO_INTRQ);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
andq $0x4, %rax
cmpq $0x0, %rax
je 0xa886
movl -0xc(%rbp), %eax
orq $0x2, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
andq $0x40, %rax
cmpq $0x0, %rax
je 0xa8ce
movl -0xc(%rbp), %eax
andq $-0x41, %rax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
orq $0x1, %rax
movl %eax, -0xc(%rbp)
movl -0x10(%rbp), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xa8cc
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
orq $0x4, %rcx
movl %ecx, 0x34(%rax)
jmp 0xa8ce
movl -0x10(%rbp), %eax
xorl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x14(%rbp), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xa930
movl -0xc(%rbp), %eax
andq $0x1, %rax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0xa90e
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
orq $0x2, %rcx
movl %ecx, 0x34(%rax)
jmp 0xa91c
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
andq $-0x3, %rcx
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rax
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq *%rax
movl -0x14(%rbp), %eax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xa957
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %ecx
andq $0x2, %rcx
movl %ecx, %esi
callq *%rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: CAPSFdcWrite(CapsFdc*, unsigned int, unsigned int)
void   __cdecl CAPSFdcWrite(PCAPSFDC pc, UDWORD address, UDWORD data)
{
	// allow valid data bits only
	data&=pc->datamask;

	// set data bus
	pc->dataline=data;

	// mask valid address lines
	switch (address & pc->addressmask) {
		// command, process type 4 always, type 1...3 only if not busy
		case 0:
			if (!(pc->r_st0 & CAPSFDC_SR_BUSY) || ((data & 0xf0) == 0xd0))
				FdcCom(pc, data);
			break;

		// track, not protected during busy despite documentation
		case 1:
			pc->r_track = data;
			break;

		// sector, not protected during busy despite documentation
		case 2:
			pc->r_sector = data;
			break;

		// data, clear drq if set
		case 3:
			pc->r_data = data;
			FdcSetLine(pc, pc->lineout&~CAPSFDC_LO_DRQ);
			break;

		default:
			NODEFAULT;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movl -0x10(%rbp), %eax
andl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl %ecx, %eax
movl %eax, %ecx
movq %rcx, -0x18(%rbp)
subl $0x3, %eax
ja 0xaa1e
movq -0x18(%rbp), %rax
leaq 0x13777(%rip), %rcx     # 0x1e124
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xa9d6
movl -0x10(%rbp), %eax
andl $0xf0, %eax
cmpl $0xd0, %eax
jne 0xa9e2
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0xaa30
jmp 0xaa20
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
jmp 0xaa20
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x44(%rax)
jmp 0xaa20
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andq $-0x2, %rax
movl %eax, %esi
callq 0xa860
jmp 0xaa20
jmp 0xaa20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcCom(CapsFdc*, unsigned int)
void FdcCom(PCAPSFDC pc, UDWORD data)
{
	// store command
	pc->r_command=data;

#ifdef _DEBUG
	{
		char dbuf[64];
		int rtrack=pc->driveprc ? pc->driveprc->track : -1;
		int rside=pc->driveprc ? pc->driveprc->side : -1;
		sprintf(dbuf, "%2.2x: %2.2x %2.2x %2.2x %d.%d\n",
			pc->r_command,
			pc->r_track,
			pc->r_sector,
			pc->r_data,
			rtrack,
			rside);
		OutputDebugString(dbuf);
	}
#endif

	// reset command state
	pc->runstate=0;
	pc->indexlimit=-1;

	int comcl=(pc->r_command>>4) & 0xf;

	if (comcl == 0xd)
		FdcComT4(pc);
	else {
		// start loop
		pc->runmode=fdcinit[comcl].runmode;
		pc->idlecnt=0;

		// set status type
		pc->r_stm=fdcinit[comcl].stmask;

		// clear status bits
		pc->r_st0&=~fdcinit[comcl].st0clr;
		pc->r_st1&=~fdcinit[comcl].st1clr;

		// set status bits
		pc->r_st0|=fdcinit[comcl].st0set;
		pc->r_st1|=fdcinit[comcl].st1set;

		// clear drq, intrq, forced interrupt and index enable lines
		FdcSetLine(pc, pc->lineout & ~(CAPSFDC_LO_DRQ | CAPSFDC_LO_INTRQ | CAPSFDC_LO_INTFRC | CAPSFDC_LO_INTIP));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x98(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
movl %eax, -0x10(%rbp)
cmpl $0xd, -0x10(%rbp)
jne 0xaa86
movq -0x8(%rbp), %rdi
callq 0xad20
jmp 0xab63
movslq -0x10(%rbp), %rcx
leaq 0x1c82f(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xac(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x1c806(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x1c7ea(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
xorl $-0x1, %ecx
movq -0x8(%rbp), %rax
andl 0x30(%rax), %ecx
movl %ecx, 0x30(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x1c7c8(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
xorl $-0x1, %ecx
movq -0x8(%rbp), %rax
andl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x1c7a6(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq -0x8(%rbp), %rax
orl 0x30(%rax), %ecx
movl %ecx, 0x30(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x1c787(%rip), %rax     # 0x272c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
orl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andq $-0x28, %rax
movl %eax, %esi
callq 0xa860
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: CAPSFdcInvalidateTrack(CapsFdc*, int)
SDWORD __cdecl CAPSFdcInvalidateTrack(PCAPSFDC pc, SDWORD drive)
{
	if (!pc)
		return imgeGeneric;

	if (drive<0 || drive>=pc->drivecnt)
		return imgeOutOfRange;

	PCAPSDRIVE pd=pc->drive+drive;
	pd->buftrack=-1;
	pd->bufside=-1;

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xab8b
movl $0x2, -0x4(%rbp)
jmp 0xabe0
cmpl $0x0, -0x14(%rbp)
jl 0xaba0
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xec(%rcx), %eax
jl 0xaba9
movl $0x3, -0x4(%rbp)
jmp 0xabe0
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcClearTrackData(CapsDrive*)
void FdcClearTrackData(PCAPSDRIVE pd)
{
	// no track data available
	pd->ttype=ctitNA;
	pd->trackbuf=NULL;
	pd->timebuf=NULL;
	pd->tracklen=0;
	pd->overlap=-1;
	pd->trackbits=0;
	pd->ovlmin=-1;
	pd->ovlmax=-1;
	pd->ovlcnt=0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x4c(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0x50(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x54(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x58(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0x5c(%rax)
popq %rbp
retq
nop
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcResetState(CapsFdc*)
void FdcResetState(PCAPSFDC pc)
{
	// clear internal registers
	pc->r_st0=0;
	pc->r_st1=0;
	pc->r_command=0;
	pc->r_track=0;
	pc->r_sector=0;
	pc->r_data=0;

	// type 1 status, idle
	pc->r_stm=CAPSFDC_SM_TYPE1;
	pc->runmode=cfdcrmIdle;
	pc->runstate=0;
	pc->indexcount=0;
	pc->indexlimit=-1;
	pc->spinupcnt=0;
	pc->idlecnt=0;
	pc->clockcnt=0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x94(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x98(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0xa4(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xac(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xb4(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT4(CapsFdc*)
void FdcComT4(PCAPSFDC pc)
{
	// set motor line
	pc->lineout |= CAPSFDC_LO_MO;

	// if valid drive selected turn on its motor
	if (pc->driveprc)
		pc->driveprc->diskattr |= CAPSDRIVE_DA_MO;

	// set sr motor
	pc->r_st0 |= CAPSFDC_SR_MO;

	// start type 1 idle
	pc->runmode=cfdcrmIdle;
	pc->runstate=0;
	pc->indexlimit=-1;
	pc->idlecnt=0;

	// check busy
	if (pc->r_st0 & CAPSFDC_SR_BUSY) {
		// busy, clear busy, leave sr unchanged
		pc->r_st0&=~CAPSFDC_SR_BUSY;
	} else {
		// not busy, set type 1 status
		pc->r_stm=CAPSFDC_SM_TYPE1;
		pc->r_st0 &= ~(CAPSFDC_SR_SU_RT | CAPSFDC_SR_RNF | CAPSFDC_SR_CRCERR);
		pc->r_st1 = 0;
	}

	// clear drq, intrq, forced interrupt and index enable lines
	UDWORD line=pc->lineout & ~(CAPSFDC_LO_DRQ | CAPSFDC_LO_INTRQ | CAPSFDC_LO_INTFRC | CAPSFDC_LO_INTIP);

	// set index interrupt if requested
	if (pc->r_command & DF_2)
		line|=CAPSFDC_LO_INTIP;

	// set forced interrupt
	if (pc->r_command & DF_3)
		line|=CAPSFDC_LO_INTFRC;

	// set line state
	FdcSetLine(pc, line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
orq $0x8, %rcx
movl %ecx, 0x24(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
je 0xad5d
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movl 0x20(%rax), %ecx
orq $0x4, %rcx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
orq $0x80, %rcx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x98(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0xac(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xadc1
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
andq $-0x2, %rcx
movl %ecx, 0x30(%rax)
jmp 0xade5
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
andq $-0x39, %rcx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andq $-0x28, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
andq $0x4, %rax
cmpq $0x0, %rax
je 0xae0e
movl -0xc(%rbp), %eax
orq $0x20, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
andq $0x8, %rax
cmpq $0x0, %rax
je 0xae29
movl -0xc(%rbp), %eax
orq $0x4, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa860
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComIdle(CapsFdc*, unsigned int)
UDWORD FdcComIdle(PCAPSFDC pc, UDWORD cyc)
{
	// wait state cancelled if end requested
	if (pc->endrequest & CAPSFDC_ER_REQEND)
		return 0;

	// process all drives
	for (int drv=0; drv < pc->drivemax; drv++) {
		// get drive
		PCAPSDRIVE pd=pc->drive+drv;

		// if motor off no distance change and no index signals to count
		if (!(pd->diskattr & CAPSDRIVE_DA_MO))
			continue;

		// motor on, advance distance
		UDWORD dist=pd->idistance+cyc;

		// restart distance count on new revolution
		if (dist >= pd->clockrev) {
			dist-=pd->clockrev;

			// process disk index
			pd->idistance=0;
			FdcIndex(pc, drv);
		}

		// set distance
		pd->idistance=dist;
	}

	// !!!
	pc->clockact+=cyc;
	return cyc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xae6c
movl $0x0, -0x4(%rbp)
jmp 0xaf1d
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xf0(%rcx), %eax
jge 0xaf0a
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x4, %rax
cmpq $0x0, %rax
jne 0xaeb3
jmp 0xaefc
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jb 0xaef2
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0xb2d0
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xae73
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcResetData(CapsFdc*)
void FdcResetData(PCAPSFDC pc)
{
	pc->seclen=0;
	pc->amdecode=0;
	pc->aminfo=0;
	pc->amisigmask=0;
	pc->amdatadelay=2;
	pc->amdataskip=0;
	pc->ammarkdist=0;
	pc->ammarktype=0;
	pc->dsr=0;
	pc->dsrcnt=0;
	pc->datalock=-1;
	pc->datamode=0;
	pc->datacycle=0;
	pc->indexcount=0;
	FdcResetAm(pc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x50(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x5c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x8(%rbp), %rax
movl $0x2, 0x68(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x6c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x74(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x78(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x7c(%rax)
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x80(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0x84(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x88(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x94(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xb1a0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcUpdateData(CapsFdc*)
void FdcUpdateData(PCAPSFDC pc)
{
	// if no drive selected
	if (!pc->driveprc) {
		// and still locked, keep state
		if (pc->datalock >= 0)
			return;

		// lock on data
		FdcLockData(pc);
		return;
	}

	// get selected drive
	PCAPSDRIVE pd=pc->driveprc;

	// keep state if track.side are the same as buffered data
	if (pd->track==pd->buftrack && pd->side==pd->bufside) {
		// keep state if still locked
		if (pc->datalock >= 0)
			return;

		// lock on data
		FdcLockData(pc);
		return;
	}

	// no track data
	FdcClearTrackData(pd);

	// set buffered data track.side
	pd->buftrack=pd->track;
	pd->bufside=pd->side;

	// request track data if disk inserted
	if (pd->diskattr & CAPSDRIVE_DA_IN) {
		// this is required to keep the host informed about the track change, even if the data may not be used later
		pc->cbtrk(pc, pc->driveact);

		// destroy track data if:
		// - drive is single sided and side 1 is being accessed
		// This will result in noise being fed to the DATA line. 
		// Since ttype is reset, track update callbacks won't happen - no need to replicate this code anywhere else.
		if ((pd->diskattr & CAPSDRIVE_DA_SS) && (pd->bufside == 1))
			FdcClearTrackData(pd);
	}

	// update track parameters
	FdcUpdateTrack(pc, pc->driveact);

	// lock on data
	FdcLockData(pc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
jne 0xb03a
movq -0x8(%rbp), %rax
cmpl $0x0, 0x80(%rax)
jl 0xb02c
jmp 0xb11c
movq -0x8(%rbp), %rdi
callq 0xb4d0
jmp 0xb11c
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0xb089
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0xb089
movq -0x8(%rbp), %rax
cmpl $0x0, 0x80(%rax)
jl 0xb07b
jmp 0xb11c
movq -0x8(%rbp), %rdi
callq 0xb4d0
jmp 0xb11c
movq -0x10(%rbp), %rdi
callq 0xabf0
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xb100
movq -0x8(%rbp), %rax
movq 0x120(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl 0xfc(%rcx), %esi
callq *%rax
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x8, %rax
cmpq $0x0, %rax
je 0xb0fe
movq -0x10(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0xb0fe
movq -0x10(%rbp), %rdi
callq 0xabf0
jmp 0xb100
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xfc(%rax), %esi
callq 0xb600
movq -0x8(%rbp), %rdi
callq 0xb4d0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcGetReadAccess(CapsFdc*)
FDCREAD FdcGetReadAccess(PCAPSFDC pc)
{
	// get hook
	switch (pc->datamode) {
		case cfdcdmNoline:
			return FdcComReadNoline;

		case cfdcdmNoise:
			return FdcComReadNoise;

		case cfdcdmData:
			return FdcComReadData;

		case cfdcdmDMap:
			return FdcComReadDMap;

		default:
			NODEFAULT;
	}

	// shouldn't happen
	return FdcComReadNoline;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movq %rax, -0x18(%rbp)
subq $0x3, %rax
ja 0xb194
movq -0x18(%rbp), %rax
leaq 0x12fdd(%rip), %rcx     # 0x1e134
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x779(%rip), %rax       # 0xb8e0
movq %rax, -0x8(%rbp)
jmp 0xb196
leaq 0x82c(%rip), %rax       # 0xb9a0
movq %rax, -0x8(%rbp)
jmp 0xb196
leaq 0x9df(%rip), %rax       # 0xbb60
movq %rax, -0x8(%rbp)
jmp 0xb196
leaq 0xb92(%rip), %rax       # 0xbd20
movq %rax, -0x8(%rbp)
jmp 0xb196
jmp 0xb196
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcResetAm(CapsFdc*, int)
void FdcResetAm(PCAPSFDC pc, int keepphase)
{
	pc->aminfo|=CAPSFDC_AI_AMDETENABLE|CAPSFDC_AI_CRCENABLE;
	pc->aminfo&=~(CAPSFDC_AI_CRCACTIVE|CAPSFDC_AI_AMACTIVE);
	pc->amisigmask=CAPSFDC_AI_DSRAM;
	if (!keepphase) {
		pc->dataphase=0;
		pc->datapcnt=0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x60(%rax), %ecx
orq $0x3, %rcx
movl %ecx, 0x60(%rax)
movq -0x8(%rbp), %rax
movl 0x60(%rax), %ecx
andq $-0xd, %rcx
movl %ecx, 0x60(%rax)
movq -0x8(%rbp), %rax
movl $0x200, 0x64(%rax)      # imm = 0x200
cmpl $0x0, -0xc(%rbp)
jne 0xb1f4
movq -0x8(%rbp), %rax
movl $0x0, 0x8c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x90(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComIdleOther(CapsFdc*, unsigned int)
void FdcComIdleOther(PCAPSFDC pc, UDWORD cyc)
{
	// process all drives
	for (int drv=0; drv < pc->drivemax; drv++) {
		// skip active drive
		if (drv == pc->driveact)
			continue;

		// get drive
		PCAPSDRIVE pd=pc->drive+drv;

		// if motor off no distance change
		if (!(pd->diskattr & CAPSDRIVE_DA_MO))
			continue;

		// motor on, advance distance
		UDWORD dist=pd->idistance+cyc;

		// restart distance count on new revolution
		if (dist >= pd->clockrev) {
			dist-=pd->clockrev;

			// process disk index
			pd->idistance=0;
			FdcIndex(pc, drv);
		}

		// set distance
		pd->idistance=dist;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xf0(%rcx), %eax
jge 0xb2be
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xfc(%rcx), %eax
jne 0xb23a
jmp 0xb2b0
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x4, %rax
cmpq $0x0, %rax
jne 0xb267
jmp 0xb2b0
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jb 0xb2a6
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0xb2d0
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xb216
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcLockData(CapsFdc*)
void FdcLockData(PCAPSFDC pc)
{
	// get selected drive
	PCAPSDRIVE pd=pc->driveprc;

	// check input available
	if (!pd || !(pd->diskattr & CAPSDRIVE_DA_IN)) {
		// if no input read 0 on reference clock
		pc->datamode=cfdcdmNoline;

		// lock onto reference clock 2us mfm*(8clock+8data)
		pc->datalock=UDWORD(((UQUAD)pc->clockfrq*2*16)/1000000);
		pc->datacycle=0;
		return;
	}

	// true if track data is defined
	int dat=pd->trackbuf && pd->tracklen;

	// density map is only used when track data is available
	if (pd->timebuf && dat) {
		pc->datamode=cfdcdmDMap;
		FdcLockTime(pc);
		return;
	}

	// noise or data input read
	pc->datamode=dat ? cfdcdmData : cfdcdmNoise;

	// lock onto bit in progress at the drive cycle
	pc->datalock=UDWORD(((UQUAD)pd->idistance*pd->trackbits)/pd->clockrev);
	pc->datacycle=0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xb503
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0xb548
movq -0x8(%rbp), %rax
movl $0x0, 0x84(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
shlq %rax
shlq $0x4, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x88(%rax)
jmp 0xb5f1
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x38(%rcx)
movb %al, -0x15(%rbp)
je 0xb566
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
setne %al
movb %al, -0x15(%rbp)
movb -0x15(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xb59b
cmpl $0x0, -0x14(%rbp)
je 0xb59b
movq -0x8(%rbp), %rax
movl $0x3, 0x84(%rax)
movq -0x8(%rbp), %rdi
callq 0xb770
jmp 0xb5f1
movl -0x14(%rbp), %edx
movl $0x1, %ecx
movl $0x2, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x10(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x10(%rbp), %rcx
movslq 0x50(%rcx), %rcx
imulq %rcx, %rax
movq -0x10(%rbp), %rcx
movl 0x28(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x88(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)