// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::TED()
TED::TED() : filter(0), sidCard(0)
{
	unsigned int i;

	instance_ = this;
	// clearing cartdridge ROMs
	for (i=0;i<4;++i) {
		memset(&(RomHi[i]),0,ROMSIZE);
		memset(&(RomLo[i]),0,ROMSIZE);
		memset(romlopath,0,sizeof(romlopath));
		memset(romhighpath,0,sizeof(romhighpath));
	};
	// default ROM sets
	strcpy(romlopath[0],"BASIC");
	strcpy(romhighpath[0],"KERNAL");

	// 64 kbytes of memory allocated
	RAMMask=0xFFFF;

	// actual ram bank pointer default setting
	actram=Ram;

	// setting screen memory pointer
	scrptr=screen;
	// pointer of the end of the screen memory
	endptr=scrptr+456*312-8;
	// setting the CPU to fast mode
	fastmode=1;
	// initial position of the electron beam (upper left corner)
	irqline=VertSubCount=0;
	beamy=0;
	beamx=0;
	hshift = 0;
	scrblank= false;

	charrombank=charrambank=cset=VideoBase=Ram;
	scrattr=0;
	timer1=timer2=timer3=0;
	chrbuf = DMAbuf;
	clrbuf = DMAbuf + 64;
	tmpClrbuf = DMAbuf + 128;
	memset(DMAbuf, 0, sizeof(DMAbuf));

	// create an instance of the keyboard class
//	keys = new KEYS;
//	tap = new TAP;
	// setting the TAP::mem pointer to this MEM class
//	tap->mem=this;
//	tcbmbus = NULL;
	crsrblinkon = false;
	VertSubActive = false;
	CharacterPositionReload = CharacterPosition = 0;
	SideBorderFlipFlop = false;
	render_ok = false;

	BadLine = 0;
	CycleCounter = 0;
	oscillatorInit();
	memset(protectedPlayerMemory, 0xfe, sizeof(protectedPlayerMemory));
	enableSidCard(1, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xa6e7(%rip), %rax      # 0x13d38
movq %rax, (%rdi)
andq $0x0, 0x65fd8(%rdi)
andq $0x0, 0xb71d0(%rdi)
movq %rdi, 0x1be25(%rip)     # 0x25490
leaq 0x1b(%rdi), %r14
movl $0x55fc0, %r15d         # imm = 0x55FC0
cmpq $0x65fc0, %r15          # imm = 0x65FC0
je 0x96bd
leaq (%rbx,%r15), %rdi
movl $0x4000, %edx           # imm = 0x4000
xorl %esi, %esi
callq 0x3130
leaq (%rbx,%r15), %rdi
addq $0x10020, %rdi          # imm = 0x10020
movl $0x4000, %edx           # imm = 0x4000
xorl %esi, %esi
callq 0x3130
movl $0x800, %edx            # imm = 0x800
movq %r14, %rdi
xorl %esi, %esi
callq 0x3130
addq $0x4000, %r15           # imm = 0x4000
jmp 0x9675
movw $0x43, 0x4(%r14)
movl $0x49534142, (%r14)     # imm = 0x49534142
movl $0x4c414e, 0x41e(%rbx)  # imm = 0x4C414E
movl $0x4e52454b, 0x41b(%rbx) # imm = 0x4E52454B
movl $0xffff, 0x76008(%rbx)  # imm = 0xFFFF
leaq 0x45fc0(%rbx), %rax
movq %rax, 0xb6010(%rbx)
leaq 0x824(%rbx), %rcx
movq %rcx, 0xb6160(%rbx)
leaq 0x233dc(%rbx), %rcx
movq %rcx, 0xb6168(%rbx)
movl $0x1, 0xb6180(%rbx)
andl $0x0, 0x1bd74(%rip)     # 0x25498
andl $0x0, 0xb6184(%rbx)
andq $0x0, 0x81c(%rbx)
andl $0x0, 0xb601c(%rbx)
xorl %ebp, %ebp
movb %bpl, 0xb601b(%rbx)
movq %rax, 0x1bd56(%rip)     # 0x254a0
movq %rax, 0xb6198(%rbx)
movq %rax, 0xb6150(%rbx)
movq %rax, 0xb6148(%rbx)
andl $0x0, 0xb6130(%rbx)
andl $0x0, 0x65fcc(%rbx)
andq $0x0, 0x65fc4(%rbx)
leaq 0xb602c(%rbx), %rdi
movq %rdi, 0xb60f0(%rbx)
leaq 0xb606c(%rbx), %rax
movq %rax, 0xb60f8(%rbx)
leaq 0xb60ac(%rbx), %rax
movq %rax, 0xb6100(%rbx)
movl $0xc0, %edx
xorl %esi, %esi
callq 0x3130
movb %bpl, 0x45fb0(%rbx)
movb %bpl, 0x1bcef(%rip)     # 0x254a8
andl $0x0, 0x1bcec(%rip)     # 0x254ac
andl $0x0, 0x1bce9(%rip)     # 0x254b0
movb %bpl, 0x1bce6(%rip)     # 0x254b4
movb %bpl, 0x45fa4(%rbx)
andl $0x0, 0x1bcdc(%rip)     # 0x254b8
andq $0x0, 0x1bca4(%rip)     # 0x25488
movq %rbx, %rdi
callq 0xb7b0
leaq 0xb61b8(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
movl $0xfe, %esi
callq 0x3130
pushq $0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x981a
nop