// File: /workspace/github_c_makefile_star2_O0/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::memin(void*)
void TED::memin(void *img)
{

	// this is ugly :-P
   	fread(Ram,RAMSIZE,1,(FILE *) img);

	fread(&RAMenable,sizeof(RAMenable),1,(FILE *) img);
	fread(&t1start,sizeof(t1start),1, (FILE *) img);
	fread(&t1on,sizeof(t1on),1, (FILE *) img);
	fread(&t2on,sizeof(t2on),1, (FILE *) img);
	fread(&t3on,sizeof(t3on),1, (FILE *) img);
	fread(&timer1,sizeof(timer1),1, (FILE *) img);
	fread(&timer2,sizeof(timer2),1, (FILE *) img);
	fread(&timer3,sizeof(timer3),1, (FILE *) img);
	fread(&beamx,sizeof(beamx),1, (FILE *) img);
	fread(&beamy,sizeof(beamy),1, (FILE *) img);
	//fread(&x,sizeof(x),1, (FILE *) img);
	fread(&irqline,sizeof(irqline),1, (FILE *) img);
	fread(&crsrpos,sizeof(crsrpos),1, (FILE *) img);
	fread(&scrattr,sizeof(scrattr),1, (FILE *) img);
	fread(&tmp,sizeof(tmp),1, (FILE *) img);
	fread(&nrwscr,sizeof(nrwscr),1, (FILE *) img);
	fread(&hshift,sizeof(hshift),1, (FILE *) img);
	fread(&vshift,sizeof(vshift),1, (FILE *) img);
	fread(&fltscr,sizeof(fltscr),1, (FILE *) img);
	fread(&mcol,sizeof(mcol),1, (FILE *) img);
	fread(chrbuf,40,1, (FILE *) img);
	fread(clrbuf,40,1, (FILE *) img);
	fread(&charrom,sizeof(charrom),1, (FILE *) img);
	fread(&charbank,sizeof(charbank),1, (FILE *) img);
//	fread(&TEDfreq1,sizeof(TEDfreq1),1, (FILE *) img);
//	fread(&TEDfreq2,sizeof(TEDfreq2),1, (FILE *) img);
//	fread(&TEDVolume,sizeof(TEDVolume),1, (FILE *) img);
//	fread(&TEDDA,sizeof(TEDDA),1, (FILE *) img);
	fread(&framecol,sizeof(framecol),1, (FILE *) img);

	for (int i=0; i<5; i++)
		writeSoundReg(i, Ram[0xFF0E + i]);
	beamy=0;
	beamx=0;
	scrptr=&(screen[0]);
	charrambank=Ram+charbank;
	charrombank=&(RomHi[0][charbank & 0x3C00]);
	(charrom) ? cset = charrombank : cset = charrambank;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
addq $0x45fc0, %rdi          # imm = 0x45FC0
movq -0x10(%rbp), %rcx
movl $0x10000, %esi          # imm = 0x10000
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fd0, %rdi          # imm = 0x65FD0
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fc0, %rdi          # imm = 0x65FC0
movq -0x10(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fc1, %rdi          # imm = 0x65FC1
movq -0x10(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fc2, %rdi          # imm = 0x65FC2
movq -0x10(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fc4, %rdi          # imm = 0x65FC4
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fc8, %rdi          # imm = 0x65FC8
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x65fcc, %rdi          # imm = 0x65FCC
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x81c, %rdi            # imm = 0x81C
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x820, %rdi            # imm = 0x820
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6184, %rdi          # imm = 0xB6184
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0x45fa8, %rdi          # imm = 0x45FA8
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6130, %rdi          # imm = 0xB6130
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x10(%rbp), %rcx
leaq 0x1d078(%rip), %rdi     # 0x35950
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6024, %rdi          # imm = 0xB6024
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb601c, %rdi          # imm = 0xB601C
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6020, %rdi          # imm = 0xB6020
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6028, %rdi          # imm = 0xB6028
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb618a, %rdi          # imm = 0xB618A
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rax
movq 0xb60f0(%rax), %rdi
movq -0x10(%rbp), %rcx
movl $0x28, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rax
movq 0xb60f8(%rax), %rdi
movq -0x10(%rbp), %rcx
movl $0x28, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6120, %rdi          # imm = 0xB6120
movq -0x10(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6134, %rdi          # imm = 0xB6134
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movq -0x20(%rbp), %rdi
addq $0xb6138, %rdi          # imm = 0xB6138
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x33a0
movl $0x0, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jge 0x18a4c
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %esi
movl -0x14(%rbp), %ecx
addl $0xff0e, %ecx           # imm = 0xFF0E
movslq %ecx, %rcx
movq %rax, %rdi
movzbl 0x45fc0(%rax,%rcx), %edx
callq 0x19c60
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x18a18
movq -0x20(%rbp), %rax
movl $0x0, 0x820(%rax)
movl $0x0, 0x81c(%rax)
movq %rax, %rcx
addq $0x824, %rcx            # imm = 0x824
movq %rcx, 0xb6160(%rax)
movq %rax, %rcx
addq $0x45fc0, %rcx          # imm = 0x45FC0
movslq 0xb6134(%rax), %rdx
addq %rdx, %rcx
movq %rcx, 0xb6150(%rax)
movq %rax, %rcx
addq $0x55fc0, %rcx          # imm = 0x55FC0
movl 0xb6134(%rax), %edx
andl $0x3c00, %edx           # imm = 0x3C00
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0xb6148(%rax)
testb $0x1, 0xb6120(%rax)
je 0x18ada
movq -0x20(%rbp), %rax
movq 0xb6148(%rax), %rcx
movq %rax, %rdx
addq $0xb6198, %rdx          # imm = 0xB6198
movq %rcx, 0xb6198(%rax)
jmp 0x18af6
movq -0x20(%rbp), %rax
movq 0xb6150(%rax), %rcx
movq %rax, %rdx
addq $0xb6198, %rdx          # imm = 0xB6198
movq %rcx, 0xb6198(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)