// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: dot_char(int, int, unsigned char, unsigned char)
int dot_char(COORD x, COORD y, u08 c, u08 attr)
{
int h,w;
int p;
int xx,yy;
int xl;

   // draw a VFX font character using the line drawing routine
   // (useful if porting Heather to a differnt operating system)
   if(x > SCREEN_WIDTH) x = SCREEN_WIDTH;
   if(y > SCREEN_HEIGHT) y = SCREEN_HEIGHT;

   if(dot_font == 0) dot_font = &h_font_12[0];
   if(use_vc_fonts) {
      p = (4*4) + (0x20*4);    // index of offset to char definition of a valid char
      if(c == DEG_CODE) c = 0xF8;
      else if(c == PLUS_MINUS) c = 0xF1;
   }
   else if(c & 0x80) {
      c = ' '; // char out of range
      p = (4*4) + (c*4);    // index of offset to char definition
   }
   else p = (4*4) + (c*4);    // index of offset to char definition

   h = dot_font[8];      // char height

   p = (dot_font[p+1] * 256) + dot_font[p+0];  // pointer to char definition
   w = dot_font[p];      // char width
   p += 4;               // pointer to char pattern

   if(use_vc_fonts) {  // draw all text using vector characters
      int old_scale;
      old_scale = VCHAR_SCALE;
      VCHAR_SCALE = 1;
      TEXT_WIDTH = (w*vc_font_scale) / 100;
      TEXT_HEIGHT = (h*vc_font_scale) / 100;
      vchar(x,y, 1, attr, c);  // draw a vector character
      if(0 && VCharThickness) w = (TEXT_WIDTH+VCharThickness-1);
      else w = (TEXT_WIDTH+VCharThickness*0);
      VCHAR_SCALE = old_scale;
      return w;
   }

   erase_rectangle(x,y, TEXT_WIDTH,TEXT_HEIGHT);

   for(yy=0; yy<h; yy+=1) {    // for each row in a character
      xl = (-1);               // left-most pixel of a run of dots
      for(xx=0; xx<w; xx+=1) { // for each pixel in a character row
         if(dot_font[p]) {       // character has a visible dot
            if(xl < 0) xl = xx;  // it's the first dot of a run

            if(xx >= (w-1)) {    // this is the last dot in the character row
               if(xl >= 0) {     // we have a run of dots pending, draw it
                  line(x+xl,y+yy, x+xx,y+yy, attr);
               }
            }
         }
         else { // it's a background color dot
            if(xl >= 0) {  // this pixel ends a pending run of visible dots
               line(x+xl,y+yy, x+(xx-1),y+yy, attr);
               xl = (-1);
            }
         }

         ++p;  // next pixel in the char
      }
   }

   return w;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
movslq 0x20a841(%rip), %r12    # 0x218800
cmpl %edi, %r12d
movl %edi, %eax
cmovll %r12d, %eax
movq %rax, -0x38(%rbp)
movl 0x20a832(%rip), %eax    # 0x218804
cmpl %esi, %eax
cmovll %eax, %esi
movq %rsi, -0x40(%rbp)
movq 0x331f06(%rip), %rax    # 0x33fee8
testq %rax, %rax
jne 0xdff5
leaq 0x1447f2(%rip), %rax    # 0x1527e0
movq %rax, 0x331ef3(%rip)    # 0x33fee8
cmpl $0x0, 0x215544(%rip)    # 0x223540
je 0xe0ad
cmpb $0x1f, %dl
movzbl %dl, %esi
movl $0xf1, %edx
cmovnel %esi, %edx
cmpb $0x1, %sil
movl $0xf8, %r8d
cmovnel %edx, %r8d
movzbl 0x8(%rax), %edx
movzwl 0x90(%rax), %esi
movzbl (%rax,%rsi), %eax
movl 0x215509(%rip), %ebx    # 0x22353c
movl $0x1, 0x2154ff(%rip)    # 0x22353c
movl 0x215501(%rip), %esi    # 0x223544
imull %esi, %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rdi
shrq $0x3f, %rdi
sarq $0x25, %rax
addl %edi, %eax
movl %eax, 0x20a7ae(%rip)    # 0x218810
imull %esi, %edx
movslq %edx, %rax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rax
addl %edx, %eax
movl %eax, 0x20a792(%rip)    # 0x218814
movzbl %r8b, %r8d
movzbl %cl, %ecx
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0xe1d8
movl 0x20a76e(%rip), %r15d   # 0x218810
movl %ebx, 0x215494(%rip)    # 0x22353c
jmp 0xe1c6
movl %ecx, -0x2c(%rbp)
testb %dl, %dl
movzbl %dl, %ecx
leaq 0x10(,%rcx,4), %rcx
movl $0x90, %edx
cmovnsq %rcx, %rdx
movzbl 0x8(%rax), %r13d
movzwl (%rax,%rdx), %r14d
movzbl (%rax,%r14), %r15d
movl 0x20a735(%rip), %edx    # 0x218810
movl 0x20a733(%rip), %ecx    # 0x218814
movq $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %r8d, %r8d
callq 0xf298
movl %r13d, -0x4c(%rbp)
testl %r13d, %r13d
je 0xe1c6
addl $0x4, %r14d
leal -0x1(%r15), %eax
movl %eax, -0x50(%rbp)
movslq %ebx, %rax
cmpq %rax, %r12
cmovlq %r12, %rax
movq %rax, -0x60(%rbp)
decq %rax
movq %rax, -0x58(%rbp)
movzbl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
testb %r15b, %r15b
je 0xe1b0
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
leal (%rcx,%rax), %r13d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
movq 0x331d9b(%rip), %rax    # 0x33fee8
addq %r14, %rax
cmpb $0x0, (%r12,%rax)
je 0xe183
testl %ebx, %ebx
cmovsl %r12d, %ebx
cmpl -0x50(%rbp), %r12d
jl 0xe1a8
movq -0x38(%rbp), %rax
leal (%rbx,%rax), %edi
movq -0x60(%rbp), %rax
leal (%rax,%r12), %edx
movl %r13d, %esi
movl %r13d, %ecx
movl -0x2c(%rbp), %r8d
callq 0xe38a
jmp 0xe1a8
testl %ebx, %ebx
js 0xe1a8
addl -0x38(%rbp), %ebx
movq -0x58(%rbp), %rax
leal (%rax,%r12), %edx
movl %ebx, %edi
movl %r13d, %esi
movl %r13d, %ecx
movl -0x2c(%rbp), %r8d
callq 0xe38a
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
incq %r12
cmpl %r12d, %r15d
jne 0xe146
movq -0x48(%rbp), %rax
incl %eax
addq %r15, %r14
movq %rax, -0x48(%rbp)
cmpl -0x4c(%rbp), %eax
jne 0xe12d
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq