// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0xa391(%rip), %rax      # 0x13d38
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x65fd8(%rdi)
movq %rax, 0xb71d0(%rdi)
movq %rdi, 0x1babf(%rip)     # 0x25480
addq $0x55fc0, %rdi          # imm = 0x55FC0
leaq 0x65fe0(%rbx), %r15
leaq 0x1b(%rbx), %r14
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
callq 0x3130
movl $0x10000, %edx          # imm = 0x10000
movq %r15, %rdi
xorl %esi, %esi
callq 0x3130
movl $0x4, %r15d
movl $0x800, %edx            # imm = 0x800
movq %r14, %rdi
xorl %esi, %esi
callq 0x3130
decq %r15
jne 0x99f4
movw $0x43, 0x1f(%rbx)
movl $0x49534142, 0x1b(%rbx) # imm = 0x49534142
movl $0x4e52454b, 0x41b(%rbx) # imm = 0x4E52454B
movl $0x4c414e, 0x41e(%rbx)  # imm = 0x4C414E
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)
xorl %r14d, %r14d
movl %r14d, 0x1ba17(%rip)    # 0x25488
movl %r14d, 0xb6184(%rbx)
movq %r14, 0x81c(%rbx)
movl %r14d, 0xb601c(%rbx)
movb %r14b, 0xb601b(%rbx)
movq %rax, 0x1b9fc(%rip)     # 0x25490
movq %rax, 0xb6198(%rbx)
movq %rax, 0xb6150(%rbx)
movq %rax, 0xb6148(%rbx)
movl %r14d, 0xb6130(%rbx)
movl %r14d, 0x65fcc(%rbx)
movq %r14, 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 %r14b, 0x45fb0(%rbx)
movb %r14b, 0x1b996(%rip)    # 0x25498
movl %r14d, 0x1b993(%rip)    # 0x2549c
movl %r14d, 0x1b990(%rip)    # 0x254a0
movb %r14b, 0x1b98d(%rip)    # 0x254a4
movb %r14b, 0x45fa4(%rbx)
movl %r14d, 0x1b983(%rip)    # 0x254a8
movq %r14, 0x1b94c(%rip)     # 0x25478
movq %rbx, %rdi
callq 0xbc32
leaq 0xb61b8(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
movl $0xfe, %esi
callq 0x3130
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
popq %rbx
popq %r14
popq %r15
jmp 0x9b5e