
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
; DATA
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
align 2
d8locs0         label   byte
temp0=192
temp1=188
temp2=53
temp3=37
rept 64
                db low(temp0*100+temp2),high(temp0*100+temp2),?,temp2+1
  temp0=temp0+temp1
  if temp0 gt 199
    temp0=temp0-200
    temp1=temp1-8
  endif
  temp2=temp2+temp3
  if temp2 gt 79
    temp2=temp2-80
    temp3=temp3-7
  endif
endm

d8locs1         label   byte
temp0=64
temp1=96
temp2=25
temp3=31
rept 32
                db low(temp0*100+temp2*2),high(temp0*100+temp2*2),?,temp2+1
  temp0=temp0+temp1
  if temp0 gt 199
    temp0=temp0-200
    temp1=temp1-8
  endif
  temp2=temp2+temp3
  if temp2 gt 39
    temp2=temp2-40
    temp3=temp3-3
  endif
endm

d8locs2         label   byte
temp0=132
temp1=96
temp2=13
temp3=13
rept 16
                db low(temp0*100+temp2*4),high(temp0*100+temp2*4),?,temp2+1
  temp0=temp0+temp1
  if temp0 gt 199
    temp0=temp0-200
    temp1=temp1-8
  endif
  temp2=temp2+temp3
  if temp2 gt 19
    temp2=temp2-20
    temp3=temp3-2
  endif
endm

d8cntr          db      0f0h
d8num           db      0
d8numd          db      1

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
; CODE
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
p80:
        mov al,d8cntr
        dec al
        jnz short p80f0
        mov d8cntr,0f0h
        mov d8num,0
        mov d8numd,1
        jmp setnext
p80f0:
        mov d8cntr,al
        mov ch,d8num
        mov cl,d8numd
        cmp al,010h
        jne short p80f1
        mov cl,-1
        mov d8numd,cl
p80f1:

        add ch,cl
        jz short p80f2
        cmp ch,10h
        jb short p80f3
p80f2:
        mov d8numd,0
p80f3:
        mov d8num,ch

        mov edi,_vidptr
        mov dx,3c5h
        xor ebx,ebx
        mov ah,0d9h

        mov esi,offset d8locs2
        mov cl,10h
p80l2:
        mov bx,[esi]
        add bx,1600
        cmp bx,100*208
        jb short p80l2f0
        sub bx,100*200
p80l2f0:
        sub ebx,4
        dec byte ptr [esi+3]
        jnz short p80l2f1
        mov byte ptr [esi+3],20
        add ebx,80
p80l2f1:
        mov [esi],bx
        cmp cl,ch
        ja short p80l2c
        @outb 1
        mov [edi+ebx],ah
        mov [edi+ebx-400+1],ah
        mov [edi+ebx-800+2],ah
        mov [edi+ebx-1200+3],ah
        @outb 2
        mov [edi+ebx-100],ah
        mov [edi+ebx-500+1],ah
        mov [edi+ebx-900+2],ah
        mov [edi+ebx-1300+3],ah
        @outb 4
        mov [edi+ebx-200],ah
        mov [edi+ebx-600+1],ah
        mov [edi+ebx-1000+2],ah
        mov [edi+ebx-1400+3],ah
        @outb 8
        mov [edi+ebx-300],ah
        mov [edi+ebx-700+1],ah
        mov [edi+ebx-1100+2],ah
        mov [edi+ebx-1500+3],ah
p80l2c:
        add esi,4
        dec cl
        jnz p80l2

        mov esi,offset d8locs1
        shl ch,1
        mov cl,20h
p80l1:
        mov bx,[esi]
        add bx,800
        cmp bx,100*200
        jb short p80l1f0
        sub bx,100*200
p80l1f0:
        sub ebx,2
        dec byte ptr [esi+3]
        jnz short p80l1f1
        mov byte ptr [esi+3],40
        add ebx,80
p80l1f1:
        mov [esi],bx
        cmp cl,ch
        ja short p80l1c
        @outb 1
        mov [edi+ebx],ah
        mov [edi+ebx-400+1],ah
        @outb 2
        mov [edi+ebx-100],ah
        mov [edi+ebx-500+1],ah
        @outb 4
        mov [edi+ebx-200],ah
        mov [edi+ebx-600+1],ah
        @outb 8
        mov [edi+ebx-300],ah
        mov [edi+ebx-700+1],ah
p80l1c:
        add esi,4
        dec cl
        jnz p80l1

        mov esi,offset d8locs0
        shl ch,1
        mov cl,40h
p80l0:
        mov bx,[esi]
        add bx,400
        cmp bx,100*200
        jb short p80l0f0
        sub bx,100*200
p80l0f0:
        dec ebx
        dec byte ptr [esi+3]
        jnz short p80l0f1
        mov byte ptr [esi+3],80
        add ebx,80
p80l0f1:
        mov [esi],bx
        cmp cl,ch
        ja short p80l0c
        @outb 1
        mov [edi+ebx],ah
        @outb 2
        mov [edi+ebx-100],ah
        @outb 4
        mov [edi+ebx-200],ah
        @outb 8
        mov [edi+ebx-300],ah
p80l0c:
        add esi,4
        dec cl
        jnz p80l0

        ret

