// File: khedoros[P]khednes/rom.cpp
// Function: rom::print_nsf_info()
void rom::print_nsf_info() {
    std::cout<<"Filename: "<<file.c_str()<<std::endl;
    std::cout<<"Filesize: "<<filesize<<std::endl;
    std::cout<<"Valid: "<<(valid?"true":"false")<<std::endl;
    printf("Init Insertion point: %04x\n",rst_addr);
    printf("Load Insertion point: %04x\n",load_addr);
    printf("Tick Insertion point: %04x\n",nmi_addr);
    printf("Extra hardware flag: %02x", header[0x7b]);
    if(header[0x07b]) {
        printf(" (Extra sound chip support specified, and I don't currently support that.)");
    }
    printf("\n");

    printf("Songs in file: %d\n", song_count);
    printf("Starting song: %d\n", song_index+1);
    printf("Load addr: %04x\nInit addr: %04x\nPlay addr: %04x\n", load_addr, rst_addr, nmi_addr);
    printf("Song name: %s\nArtist: %s\nCopyright: %s\n", &header[0x0e], &header[0x2e], &header[0x4e]);

    printf("NTSC ticks (uS): %d\nPAL ticks (uS): %d\n", ntsc_ticks, pal_ticks);

    printf("NTSC: %d\n PAL: %d\n", ntsc,pal);

    printf("Bank map\n--------\n");
    for(int i=0;i<8;++i) {
        printf("%02x ", header[0x70+i]);
    }
    printf("\n");
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x263b6(%rip), %rdi     # 0x36fb0
leaq 0x1a9f5(%rip), %rsi     # 0x2b5f6
callq 0x43c0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq 0x70(%rax), %rdi
callq 0x41a0
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x43c0
movq %rax, %rdi
movq 0x2635d(%rip), %rsi     # 0x36f90
callq 0x4400
movq 0x26371(%rip), %rdi     # 0x36fb0
leaq 0x1a9bb(%rip), %rsi     # 0x2b601
callq 0x43c0
movq %rax, %rdi
movq 0x20(%rsp), %rax
movl 0x8c(%rax), %esi
callq 0x4660
movq %rax, %rdi
movq 0x26328(%rip), %rsi     # 0x36f90
callq 0x4400
movq 0x2633c(%rip), %rdi     # 0x36fb0
leaq 0x1a991(%rip), %rsi     # 0x2b60c
callq 0x43c0
movq %rax, %rdi
movq 0x20(%rsp), %rax
movb 0x8(%rax), %cl
leaq 0x1a987(%rip), %rsi     # 0x2b619
leaq 0x1a97b(%rip), %rax     # 0x2b614
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x43c0
movq %rax, %rdi
movq 0x262e1(%rip), %rsi     # 0x36f90
callq 0x4400
movq 0x20(%rsp), %rax
movl 0x94(%rax), %esi
leaq 0x1aa30(%rip), %rdi     # 0x2b6f6
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0xb8(%rax), %esi
leaq 0x1aa33(%rip), %rdi     # 0x2b712
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0x98(%rax), %esi
leaq 0x1aa36(%rip), %rdi     # 0x2b72e
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rdi
addq $0x10, %rdi
movl $0x7b, %esi
callq 0x114a0
movzbl (%rax), %esi
leaq 0x1aa2e(%rip), %rdi     # 0x2b74a
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rdi
addq $0x10, %rdi
movl $0x7b, %esi
callq 0x114a0
cmpb $0x0, (%rax)
je 0x10d49
leaq 0x1aa22(%rip), %rdi     # 0x2b764
movb $0x0, %al
callq 0x4050
leaq 0x1ada7(%rip), %rdi     # 0x2baf7
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0xbc(%rax), %esi
leaq 0x1aa46(%rip), %rdi     # 0x2b7af
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0xc0(%rax), %esi
addl $0x1, %esi
leaq 0x1aa3d(%rip), %rdi     # 0x2b7c2
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0xb8(%rax), %esi
movl 0x94(%rax), %edx
movl 0x98(%rax), %ecx
leaq 0x1aa2b(%rip), %rdi     # 0x2b7d5
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rdi
addq $0x10, %rdi
movl $0xe, %esi
callq 0x114a0
movq 0x20(%rsp), %rdi
movq %rax, 0x8(%rsp)
addq $0x10, %rdi
movl $0x2e, %esi
callq 0x114a0
movq 0x20(%rsp), %rdi
movq %rax, 0x10(%rsp)
addq $0x10, %rdi
movl $0x4e, %esi
callq 0x114a0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
leaq 0x1a9fe(%rip), %rdi     # 0x2b806
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movl 0xc4(%rax), %esi
movl 0xc8(%rax), %edx
leaq 0x1aa07(%rip), %rdi     # 0x2b82e
movb $0x0, %al
callq 0x4050
movq 0x20(%rsp), %rax
movb 0xcd(%rax), %cl
andb $0x1, %cl
movzbl %cl, %esi
movb 0xcc(%rax), %al
andb $0x1, %al
movzbl %al, %edx
leaq 0x1aa05(%rip), %rdi     # 0x2b856
movb $0x0, %al
callq 0x4050
leaq 0x1aa0a(%rip), %rdi     # 0x2b869
movb $0x0, %al
callq 0x4050
movl $0x0, 0x2c(%rsp)
cmpl $0x8, 0x2c(%rsp)
jge 0x10eab
movq 0x20(%rsp), %rdi
addq $0x10, %rdi
movl 0x2c(%rsp), %eax
addl $0x70, %eax
movslq %eax, %rsi
callq 0x114a0
movzbl (%rax), %esi
leaq 0x1a608(%rip), %rdi     # 0x2b49f
movb $0x0, %al
callq 0x4050
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x10e6e
leaq 0x1ac45(%rip), %rdi     # 0x2baf7
movb $0x0, %al
callq 0x4050
addq $0x38, %rsp
retq
nop