// File: 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
subq $0x30, %rsp
movb %cl, %al
movb %dl, %cl
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb %cl, -0xd(%rbp)
movb %al, -0xe(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x26756f(%rip), %eax    # 0x2779e0
jle 0x1047c
movl 0x267567(%rip), %eax    # 0x2779e0
movl %eax, -0x8(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x26755f(%rip), %eax    # 0x2779e4
jle 0x10490
movl 0x267557(%rip), %eax    # 0x2779e4
movl %eax, -0xc(%rbp)
cmpq $0x0, 0x38ec30(%rip)    # 0x39f0c8
jne 0x104a8
leaq 0x1a132f(%rip), %rax    # 0x1b17d0
movq %rax, 0x38ec20(%rip)    # 0x39f0c8
cmpl $0x0, 0x272271(%rip)    # 0x282720
je 0x104d8
movl $0x90, -0x1c(%rbp)
movzbl -0xd(%rbp), %eax
cmpl $0x1, %eax
jne 0x104c7
movb $-0x8, -0xd(%rbp)
jmp 0x104d6
movzbl -0xd(%rbp), %eax
cmpl $0x1f, %eax
jne 0x104d4
movb $-0xf, -0xd(%rbp)
jmp 0x104d6
jmp 0x10508
movzbl -0xd(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x104f9
movb $0x20, -0xd(%rbp)
movzbl -0xd(%rbp), %eax
shll $0x2, %eax
addl $0x10, %eax
movl %eax, -0x1c(%rbp)
jmp 0x10506
movzbl -0xd(%rbp), %eax
shll $0x2, %eax
addl $0x10, %eax
movl %eax, -0x1c(%rbp)
jmp 0x10508
movq 0x38ebb9(%rip), %rax    # 0x39f0c8
movzbl 0x8(%rax), %eax
movl %eax, -0x14(%rbp)
movq 0x38ebab(%rip), %rax    # 0x39f0c8
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq 0x38eb94(%rip), %rcx    # 0x39f0c8
movl -0x1c(%rbp), %edx
addl $0x0, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq 0x38eb7b(%rip), %rax    # 0x39f0c8
movslq -0x1c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, 0x2721b8(%rip)    # 0x282720
je 0x105fb
movl 0x2721a8(%rip), %eax    # 0x28271c
movl %eax, -0x2c(%rbp)
movl $0x1, 0x27219b(%rip)    # 0x28271c
movl -0x18(%rbp), %eax
imull 0x272199(%rip), %eax    # 0x282724
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, 0x267457(%rip)    # 0x2779f0
movl -0x14(%rbp), %eax
imull 0x272181(%rip), %eax    # 0x282724
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, 0x267443(%rip)    # 0x2779f4
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movb -0xe(%rbp), %al
movl $0x1, %edx
movzbl %al, %ecx
movzbl -0xd(%rbp), %r8d
callq 0x10710
movl 0x26741e(%rip), %eax    # 0x2779f0
movl %eax, -0x30(%rbp)
callq 0x10970
movl %eax, %ecx
movl -0x30(%rbp), %eax
imull $0x0, %ecx, %ecx
addl %ecx, %eax
movl %eax, -0x18(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, 0x27212c(%rip)    # 0x28271c
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x106f8
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movl 0x2673e9(%rip), %edx    # 0x2779f0
movl 0x2673e7(%rip), %ecx    # 0x2779f4
callq 0xf250
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x106f2
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x106e2
movq 0x38ea82(%rip), %rax    # 0x39f0c8
movslq -0x1c(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x10695
cmpl $0x0, -0x28(%rbp)
jge 0x1065c
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jl 0x10693
cmpl $0x0, -0x28(%rbp)
jl 0x10691
movl -0x8(%rbp), %edi
addl -0x28(%rbp), %edi
movl -0xc(%rbp), %esi
addl -0x24(%rbp), %esi
movl -0x8(%rbp), %edx
addl -0x20(%rbp), %edx
movl -0xc(%rbp), %ecx
addl -0x24(%rbp), %ecx
movzbl -0xe(%rbp), %r8d
callq 0x109c0
jmp 0x10693
jmp 0x106cb
cmpl $0x0, -0x28(%rbp)
jl 0x106c9
movl -0x8(%rbp), %edi
addl -0x28(%rbp), %edi
movl -0xc(%rbp), %esi
addl -0x24(%rbp), %esi
movl -0x8(%rbp), %edx
movl -0x20(%rbp), %eax
subl $0x1, %eax
addl %eax, %edx
movl -0xc(%rbp), %ecx
addl -0x24(%rbp), %ecx
movzbl -0xe(%rbp), %r8d
callq 0x109c0
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0x106cb
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x10633
jmp 0x106e4
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x10619
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)