ideal
model tiny
P386N
JUMPS

ROZM equ 200

codeseg
startupcode

          mov  ax,0013h
          int  10h
          mov  ax,0A000h
          mov  es,ax

spherex:

          mov  dx,03DAh
sretrace: in   al,dx
          and  al,08h
          jz   sretrace


          xor  di,di
          mov  bp,offset SAKTX
          mov  [bp],di

          ;X1=word bp-12
          ;Y1=word bp-10
          ;X2=word bp-8
          ;Y2=word bp-6
          ;XR1=byte bp-4
          ;YR1=byte bp-3
          ;XR2=byte bp-2
          ;YR2=byte bp-1
          ;X=byte bp
          ;Y=byte bp+1

          ;SINFO=byte bp+2


          mov  cx,256*200
          mov  [bp+2],cl

skresli:  mov  al,[bp-11]
          mov  dl,[bp-9]
          call svzdial
          mov  bh,bl
          mov  al,[bp-7]
          mov  dl,[bp-5]
          call svzdial

          mov  al,bl
          add  al,bh
          jz   skresli3
          jns  skresli2
          xchg bh,bl
          mov  [byte bp+2],1
skresli2: mov  al,11
          cmp  bh,bl
          jc   skresli3
          mov  al,14
skresli3: stosb

          inc  [byte bp]
          jnz  skresli4
          add  di,320-256
          inc  [byte bp+1]

skresli4: loop skresli

          shr  [word bp+2],1
          jnc  sdalej

          mov  al,[bp-11]
          mov  ah,[bp-9]
          sub  al,[bp-7]
          sub  ah,[bp-5]

          shl  ah,2
          shl  al,2

          mov  [bp-4],ax
          neg  al
          neg  ah
          mov  [bp-2],ax




sdalej:   mov  si,4

sdalej1:  mov  di,si
          shl  di,1

          cmp  [byte di-13+bp],16

          jc   sdalej2
          cmp  [byte di-13+bp],ROZM-16
          jc   sdalej3

sdalej2:  neg  [byte si-5+bp]
sdalej3:
          movsx ax,[si-5+bp]

          sal  ax,1
          add  [di-14+bp],ax

          dec  si
          jnz  sdalej1


          mov  ah,01h
          int  16h
          jz   spherex

          xor  ah,ah
          int  16h
          mov  ax,0003h
          int  10h

          mov  dx,offset STEXT
          mov  ah,09h
          int  21h

          exitcode


svzdial:  sub  al,[bp]
          jnc  svzdial1
          neg  al
svzdial1: mul  al
          or   ah,ah
          jnz  svzdial3

          mov  bl,al

          mov  al,dl
          sub  al,[bp+1]
          jnc  svzdial2
          neg  ax
svzdial2: mul  al
          or   ah,ah
          jnz  svzdial3

          add  bl,al
          jnc  svzdial4

svzdial3: xor  bl,bl
svzdial4: shr  bl,1
          ret




dataseg

STEXT     db  'Picasso Pablo - ATRIP$'

S1POZX    db     0, 20;20
S1POZY    db     0, 20;20
S2POZX    db     0, 119;110
S2POZY    db     0, 153;91
S1RYCHX   db    127
S1RYCHY   db    015
S2RYCHX   db    129
S2RYCHY   db    240
SAKTX     db   1 dup(?)
SAKTY     db   1 dup(?)
SINFO     db   1 dup(?)


end