ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
; plasmoid/deep 1994:
; well, sure you don't know that wilkins is now going to make trainers
; in fact his missing knowledge in coding allows him just to find some
; interesting adresses...who has to code the trainer? me plasmoid, and
; here he is: the universal tainer code menu.
; if you modify anything on diz code, remember ds is always cs, if you
; change it, you have to restore it afterwards!
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
.286
.model tiny
code            segment
		locals
		assume  cs:code
		org     100h
trainer:        jmp     main
db  " ת code by plasmoid ת trained by wilkins ת soundsystem by psi ת "
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
shades          proc
		mov     dx,0a000h
		mov     es,dx
		mov     ax,x1_direct
		mov     di,y2_direct
		add     ax,x1_point

		mov     bx,y1_point
		mov     si,x2_point
		cmp     delay,02
		jb      @jump
		mov     bx,y1_direct
		mov     si,x2_direct
		add     bx,y1_point
		add     si,x2_point
		mov     delay,00

@jump:          add     di,y2_point
		inc     delay
		mov     x1_point,ax
		mov     y1_point,bx
		mov     x2_point,si
		mov     y2_point,di
		cmp word ptr x1_point,319
		jae     x1_down
		cmp word ptr x1_point,1
		jbe     x1_up
		cmp word ptr x2_point,319
		jae     x2_down
		cmp word ptr x2_point,1
		jbe     x2_up
		cmp word ptr y1_point,199
		jae     y1_left
		cmp word ptr y1_point,1
		jbe     y1_right
		cmp word ptr y2_point,199
		jae     y2_left
		cmp word ptr y2_point,1
		jbe     y2_right
		call    line
		ret
x1_down:        mov     x1_direct,-1
		ret
x1_up:          mov     x1_direct, 1
		ret
x2_down:        mov     x2_direct,-1
		ret
x2_up:          mov     x2_direct, 1
		ret
y1_left:        mov     y1_direct,-1
		ret
y1_right:       mov     y1_direct, 1
		ret
y2_left:        mov     y2_direct,-1
		ret
y2_right:       mov     y2_direct, 1
		ret

x1_point        dw      30
x1_direct       dw      1
y1_point        dw      32
y1_direct       dw      1
x2_point        dw      141
x2_direct       dw      1
y2_point        dw      149
y2_direct       dw      1
delay           db      00
shades          endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
pixel           proc near
		push    dx                      ; ש ax-x bx-y
		push    bx
		push    ax
		mov     dx,ax                   ; ש multis y * 320
		shl     dx,8                    ;   using    * 256
		shl     ax,6                    ;   using    *  64
		add     ax,dx                   ;            = 320
		add     bx,ax                   ; ש add y to x
		cmp     byte ptr es:[bx],31+19
		jae     @okay
		cmp     byte ptr es:[bx],19
		jb      @okay
@inc:           inc     byte ptr es:[bx]        ; ש mov it!
@okay:          pop     ax
		pop     bx
		pop     dx
		ret
pixel           endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
line            proc near
		s1      equ [bp-10h]            ; ש ax-x bx-y
		s2      equ [bp-0eh]            ; ש si-x bx-y
		s3      equ [bp-0ch]
		s4      equ [bp-0ah]
		x1      equ [bp-08h]
		y1      equ [bp-06h]
		x2      equ [bp-04h]
		y2      equ [bp-02h]

		enter   10h,0
		mov     x1,ax                   ; ש here cum some nice
		mov     y1,bx                   ;   explaining words
		mov     x2,si
		mov     y2,di
		mov     si,x2                   ; ש checks if sign
		sub     si,x1                   ;   meaning if  or 
		jns     @lab1
		neg     si                      ; ש change sign
@lab1:          mov     di,y2                   ; ש checks if sign
		sub     di,y1                   ;   meaning if  or 
		jns     @lab2
		neg     di                      ; ש change sign
@lab2:          cmp     si,di
		jge     @lab3a                  ; ש m <= 1
		jmp     @lab20                  ; ש m >  1

@lab3a:         mov     bx,x1                   ; ש checks if x1 <= x2
		cmp     bx,x2
		jg      @lab4
		mov     bx,1                    ; ש go right!
		jmp     @lab5
@lab4:          mov     bx,-1                   ; ש go left!
@lab5:          mov     ax,y1                   ; ש checks if y1 <= y2
		cmp     ax,y2
		jg      @lab6
		mov     ax,1                    ; ש go up!
		jmp     @lab7

@lab6:          mov     ax,-1                   ; ש go down!
; small comment: Going down, mayday, mayday (from Comanche)
@lab7:          mov     s1,bx                   ; ש save m on stack
		mov     s2,ax
		add     di,di                   ; ש draw point
		mov     s3,di
		sub     di,si
		mov     bx,di
		sub     bx,si
		mov     s4,bx
		mov     bx,x1
		mov     ax,y1
		call    pixel

@lab8:          cmp     bx,x2                   ; ש points left?
		jz      @lab3
		add     bx,s1                   ; ש increases x
		or      di,di                   ; ש checks if y should
		jns     @lab10                  ;   be increased
		add     di,s3
		jmp     @lab11
@lab10:         add     di,s4                   ; ש next point
		add     ax,s2
@lab11:         call    pixel
		jmp     @lab8

@lab20:         mov     bx,y1                   ; ש checks if y1 <= y2
		cmp     bx,y2
		jg      @lab12
		mov     bx,1                    ; ש go up!
		jmp     @lab13

@lab12:         mov     bx,-1                   ; ש go down!
; small comment: Going down, mayday, mayday (from Comanche)
@lab13:         mov     ax,x1                   ; ש checks if x1 <= x2
		cmp     ax,x2
		jg      @lab14
		mov     ax,1                    ; ש go right!
		jmp     @lab15
@lab14:         mov     ax,-1                   ; ש go left!
@lab15:         mov     s1,bx                   ; ש save m on stack
		mov     s2,ax
		add     si,si                   ; ש draw point
		mov     s3,si
		sub     si,di
		mov     bx,si
		sub     bx,di
		mov     s4,bx
		mov     di,si
		mov     bx,x1
		mov     ax,y1
		call    pixel
@lab16:         cmp     ax,y2                   ; ש points left?
		jz      @lab3
		add     ax,s1                   ; ש increases x
		or      di,di                   ; ש checks if y should
		jns     @lab18                  ;   be increased
		add     di,s3
		jmp     @lab19
@lab18:         add     di,s4                   ; ש next point
		add     bx,s2
@lab19:         call    pixel
		jmp     @lab16

@lab3:          leave
		ret
line            endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
fill            proc
		mov     dx,0a000h
		mov     es,dx
		xor     di,di
		mov     cx,320*200
@@f2:           cmp byte ptr es:[di],00
		jne     @@f1
		mov byte ptr es:[di],19
@@f1:           inc     di
		loop    @@f2
		ret
fill            endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
; diz is the original future crew simplex adlib player, which i ripped
; out of the sp2.com source. anyway, thousands of thanks fly to future
; crew for diz tiny code, it's pretty cool...
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
a_lodsboutaw03: call    a_lodsboutaw            ; ש out data to adlib
		add     ah,3
a_lodsboutaw:   lodsb
a_outaw         proc near                       ; ש ah=reg,al=data
		push    ax
		push    cx
		xchg    al,ah
		mov     dx,388h
		out     dx,al
		mov     cx,7
		call    a_wait
		mov     dx,389h
		mov     al,ah
		out     dx,al
		mov     cx,30
		call    a_wait
		pop     cx
		pop     ax
		ret
a_wait:         in      al,dx
		loop    a_wait
		ret
a_outaw         endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
a_loadinstrument proc near      ; ש bx=channel, ds:si=offset to instrument data
		mov     ah,ds:a_inst_table[bx]
		mov     cx,4
@@1:            call    a_lodsboutaw03
		add     ah,20h-3
		loop    @@1
		add     ah,40h
		call    a_lodsboutaw03
		mov     ah,bl
		add     ah,0c0h
		jmp     a_lodsboutaw
a_loadinstrument endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
a_playnote      proc near               ; ש bx=channel, ax=data
		push    bx
		xchg    ah,bl
		add     ah,0a0h
		call    a_outaw
		mov     al,bl
		add     ah,010h
		pop     bx
		jmp     a_outaw
a_playnote      endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
a_init          proc near
		mov     ax,00120h
		call    a_outaw
		mov     ax,00800h
		call    a_outaw
		mov     ah,0bdh
		call    a_outaw
		mov     bp,9
		xor     bx,bx
		mov     di,offset music_instruments
@@1:            mov     si,ds:[di]
		add     di,2
		call    a_loadinstrument
		xor     ax,ax
		call    a_playnote
		inc     bx
		dec     bp
		jnz     @@1
		ret
a_init          endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
a_dorow         proc near                       ; ש play a row
		push    ds
		push    cs
		pop     ds
		sub     ds:a_musiccnt,1
		jnc     @@0
		mov     ds:a_musiccnt,music_speed
		mov     cx,music_channels
		mov     di,offset music_patterns
		xor     bx,bx
@@1:            sub     ds:a_chdelaycnt[bx],1
		jns     @@2
		mov     si,ds:[di]
		xor     ax,ax
		call    a_playnote
@@4:            lodsb
		or      al,al
		jz      @@7
		jns     @@6
		sub     al,81h
		mov     ds:a_chdelay[bx],al
		lodsb
@@6:            mov     dl,al
		and     ax,15
		mov     bp,ax
		add     bp,bp
		mov     ax,ds:a_note_table[bp]
		shr     dl,2
		and     dl,not 3
		add     ah,dl
		call    a_playnote
		mov     al,ds:a_chdelay[bx]
		mov     ds:a_chdelaycnt[bx],al
		mov     ds:[di],si
@@2:            add     di,4
		inc     bx
		loop    @@1
@@0:            pop     ds
		ret
@@7:            mov     si,ds:[di+2]
		jmp     @@4
a_dorow         endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
timer           proc near
		push    ax
		mov     al,20h
		out     20h,al
		inc     cs:counter
		inc     cs:wait70Hz
		cmp     cs:wait70Hz,15
		jb      no_wait70Hz
		inc	cs:waitClock
		cmp	cs:waitClock,4
		jb	no_waitClock
		mov	cs:waitClock,00
		int	1ch
no_waitClock:	mov     cs:wait70Hz,00
		pusha
		call    a_dorow
		popa
no_wait70Hz:    pop     ax
		iret
counter         dw      0000h
wait70Hz        db      00h
waitClock	db	00h
timer           endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
init_timer      proc    near
		xor     dx,dx                   ; ש rescue old int 8
		mov     es,dx
		mov     ax,es:[8*4]+0
		mov     cs:oldint8[0],ax
		mov     ax,es:[8*4]+2
		mov     cs:oldint8[2],ax

		mov     dx,1193                 ; ש new freq 1000 hz

		cli
		mov     ax,cs
		mov     es:[8*4]+2,ax           ; ש set new int 8
		mov     ax,offset timer
		mov     es:[8*4]+0,ax

out_it:         mov     al,036h                 ; ש out these things, they
		out     43h,al                  ;   just remain a secret
		mov     al,dl                   ;   for me...
		out     40h,al
		mov     al,dh
		out     40h,al
		sti
		ret

oldint8         dw 2 dup (?)
init_timer      endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
kill_timer      proc near
		xor     dx,dx
		mov     es,dx
		cli
		mov     ax,cs:oldint8[0]        ; ש restore old setting
		mov     es:[8*4]+0,ax
		mov     ax,cs:oldint8[2]
		mov     es:[8*4]+2,ax
		jmp     out_it
kill_timer      endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
rotate           proc near
		 mov    si,bp
		 mov    dx,08000h
		 mov    es,dx
		 xor    di,di
		 mov    cx,bx
		 rep    movsb

backward:        mov    ds,dx
		 push   cs
		 pop    es
		 mov    si,3
		 mov    di,bp
		 sub    bx,3
		 mov    cx,bx
		 add    bx,3
		 rep    movsb

		 xor    si,si
		 mov    cx,3
		 rep    movsb
		 sub    bp,3


		 push   cs
		 pop    ds
		 call   palette
		 ret
rotate           endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
fade            proc near
		cmp     fadecount,3fh        ; ש stop fading
		jae     @skip

		mov     si,offset vga_palette
		mov     dx,03c8h                 ; ש write to PEL port
		mov     al,00h
		out     dx,al
		inc     dx

		mov     ah,fadecount
		xor     ah,direction

		mov     cx,256
@change:        lodsb
		sub     al,ah
		jnc     $+4
		mov     al,00h
		out     dx,al
		lodsb
		sub     al,ah
		jnc     $+4
		mov     al,00h
		out     dx,al
		lodsb
		sub     al,ah
		jnc     $+4
		mov     al,00h
		out     dx,al
		loop    @change
		inc     fadecount
		mov     ax,1200h        ; ש screen on!
		mov     bl,36h
		int     10h
		ret
@skip:          mov     bp,offset go
		mov     bx,4*3
		call    rotate
		ret
fadecount       db      00
direction       db      3fh
fade            endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
palette         proc near
		mov     si,offset vga_palette
		mov     dx,03c8h         ; ש port PEL write mode
		mov     al,00h           ;   at register 00h
		out     dx,al
		inc     dx               ; ש port PEL data register
		mov     cx,0100h*3
		rep     outsb            ; ש define the selected
		ret                      ;   vga color a 100h times
palette         endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
waitkey         proc    near
		mov     ah,01
		int     16h
		jnz     @true
		ret
@true:          mov     ah,07
		int     21h
		jmp     bx
		ret                           ; ש again a senseless return!
waitkey         endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
init            proc near
		mov     ax,13h                  ; ש set mode
		int	10h
		mov     dx,03c8h         ; ש port PEL write mode
		mov     al,00h           ;   at register 00h
		out     dx,al
		inc     dx
		mov     cx,0100h*3
@i1:            out     dx,al
		loop    @i1
		mov     ah,02
		mov     bh,00
		mov     dh,cursor_y
		mov     dl,cursor_x
		int     10h
		ret
cursor_x        db      7
cursor_y        db      2
init            endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
bitmap_ball     proc    near
		push    cx
		push    ax
		mov     dx,0a000h
		mov     es,dx
		mov     si,offset ball
		xor     di,di
		add     di,55
		mov     dx,ax
		shl     ax,8
		shl     dx,6
		add     ax,dx
		add     di,ax

		mov     dx,11
@b1:            mov     cx,11
		rep     movsb
		add     di,320-11
		dec     dx
		jnz     @b1
		pop     ax
		pop     cx
		ret
bitmap_ball     endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
print           proc near
		mov     bx,9
		mov     cx,26
		mov     si,offset headline
@d1:            push    cx
		lodsb
		mov     ah,09                           ; ש print letter
		mov     cx,01
		int     10h
		mov     ah,02                           ; ש change cursor
		inc     cursor_x
		mov     dh,cursor_y
		mov     dl,cursor_x
		int     10h
		pop     cx
		loop    @d1

		add     cursor_y,2
		mov     si,offset keys
		mov     bx,9
		mov     cx,09                           ; ש number of keys
@d2:            push    cx
		mov     cx,32                           ; ש length of keys
		mov     cursor_x,10
@d3:            push    cx
		mov     ah,02                           ; ש change cursor
		mov     dh,cursor_y
		mov     dl,cursor_x
		int     10h
		inc     cursor_x
		lodsb
		mov     ah,09                           ; ש print letter
		mov     cx,01
		int     10h
		pop     cx
		loop    @d3
		add     cursor_y,2
		pop     cx
		loop    @d2

		mov     cx,9                            ; ש number of keys
		mov     ax,29
@d4:            call    bitmap_ball
		add     ax,16
		loop    @d4

		ret                             ;   you can only write here
headline        db      "TRAINER FOR PINBALL DREAMS"
keys            db      "F1  - HELLO WILKINS!            "
		db      "F2  - UNLIMITED BALLS           "
		db      "F3  - REAL MULTI-PLAY           "
		db      "F4  - BONUS OF 1.000            "
		db      "F5  - THE SONG IS NOT           "
		db      "F6  - FINISHED...YOU            "
		db      "F7  - ARE LISTENING TO          "
		db      "F8  - SKAVEN`S TUNE!            "
		db      "F9  - PLASMOID                  "
print           endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
fade_it         proc    near
		cmp     back,22h
		jne     @f1
		mov     fadecount,00            ; ש fade out !
		mov     direction,00
@f1:            mov     cx,3fh
@f2:            push    cx                      ; ש fade in!
		mov     cs:counter,00
		call    fade
@f3:            cmp     cs:counter,40
		jb      @f3
		pop     cx
		loop    @f2
		ret
back            db      00
fade_it         endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
messages	db 	" ת greetz  mister ed ת tronics ת rooster ת kluth ת "
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
shadow          proc near
		mov     si,32*320+80
		mov     dx,17
		mov     bp,32*320+80
@s1:            mov     ax,0a000h
		mov     ds,ax
		mov     ax,08000h
		mov     es,ax
		xor     di,di
		mov     bx,08
@s2:            mov     cx,110
		rep     movsw
		add     si,100
		dec     bx
		jnz     @s2

		xor     di,di
		mov     al,09
		mov     bx,09
@s3:            mov     cx,220
@s4:            repne   scasb
		cmp     cx,00
		je      @s5
		dec     di
@@1:            cmp     cs:status,00
		jne     @@2
		mov  byte ptr es:[di],0Ah
		inc     cs:status
		jmp     @cont

@@2:            cmp     cs:status,01
		jne     @@3
		mov  byte ptr es:[di],0Bh
		inc     cs:status
		jmp     @cont

@@3:            cmp     cs:status,02
		jne     @@4
		mov  byte ptr es:[di],0Ch
		inc     cs:status
		jmp     @cont

@@4:            cmp     cs:status,03
		jne     @@1
		mov  byte ptr es:[di],0Dh
		mov     cs:status,00
		jmp     @cont

@cont:          jmp     @s4
@s5:            dec     di
		dec     bx
		jnz     @s3

		push    es
		push    ds
		pop     es
		pop     ds
		mov     di,bp
		sub     di,321
		xor     si,si
		mov     bx,08
@s6:            mov     cx,220
@s7:            cmp byte ptr ds:[si],00
		je      @s8
		movsb
		dec     cx
		jmp     @s9
@s8:            inc     di
		inc     si
		dec     cx
@s9:            cmp     cx,00
		jnz     @s7
		add     di,100
		dec     bx
		jnz     @s6

		add     bp,8*320
		mov     si,bp
		dec     dx
		jz      @s10
		jmp     @s1
@s10:           push    cs
		pop     ds
		ret
status          db      00
shadow          endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
double          proc    near
		mov     dx,0a000h
		mov     ds,dx
		mov     si,320*16
		mov     dx,08000h
		mov     es,dx
		xor     di,di
		mov     cx,320*8/2
		rep     movsw

		xor     di,di
		mov     al,09
		mov     cx,320*8
@1:             repne   scasb
		cmp     cx,00
		je      @2
		dec     di
		inc     cx
		mov byte ptr es:[di],17
		jmp     @1

@2:             push    ds
		push    es
		pop     ds
		pop     es
		mov     di,320*15-1
		xor     si,si
		mov     cx,320*8
@new:           cmp byte ptr ds:[si],00
		je      @5
		movsb
		dec     cx
		jmp     @new
@5:             inc     di
		inc     si
		dec     cx
		cmp     cx,00
		jnz     @new

		mov     di,320*14-1
		xor     si,si
		mov     cx,320*8
@newer:         cmp byte ptr ds:[si],00
		je      @6
		mov     al,ds:[si]
		inc     al
		mov     es:[di],al
@6:             inc     di
		inc     si
		dec     cx
		cmp     cx,00
		jnz     @newer

		push    cs
		pop     ds
		ret
scount          db      00
double          endp
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
ball 	 db 000h,000h,000h,002h,002h,002h,003h,002h,000h,000h,000h
	 db 000h,000h,002h,002h,003h,003h,003h,003h,003h,000h,000h
	 db 000h,002h,002h,007h,003h,003h,003h,004h,004h,003h,000h
	 db 002h,002h,007h,008h,007h,003h,004h,004h,004h,004h,002h
	 db 002h,003h,003h,007h,003h,004h,004h,006h,005h,004h,003h
	 db 002h,003h,003h,003h,004h,004h,005h,006h,006h,004h,003h
	 db 002h,003h,003h,004h,004h,005h,007h,006h,005h,004h,003h
	 db 002h,003h,004h,004h,006h,006h,006h,006h,004h,003h,002h
	 db 000h,003h,003h,005h,005h,006h,005h,004h,004h,002h,000h
	 db 000h,000h,003h,003h,004h,004h,004h,003h,002h,000h,000h
	 db 000h,000h,000h,002h,003h,003h,003h,002h,000h,000h,000h

vga_palette     db 000h, 000h, 000h                 ; ש colors of the ball
		db 000h, 000h, 0003h
		db 016h-0dh, 000h, 011h-00h
		db 019h-0ch, 000h, 019h-0ch
		db 01ch-0bh, 000h, 01ch-0bh
		db 020h-0ah, 000h, 020h-0ah
		db 024h-0ah, 000h, 024h-0ah
		db 028h-0ah, 000h, 028h-0ah
		db 02fh, 02fh, 02fh
		db 000h, 010h, 012h        ; 9
go:             db 000h, 01fh, 01fh        ; 10
		db 000h, 022h, 022h        ; 11
		db 000h, 024h, 024h        ; 12
		db 000h, 026h, 026h        ; 13
		db 000h, 024h, 024h        ; 14
		db 000h, 022h, 022h        ; 15
		db 000h, 022h, 022h        ; 16
		db 02dh, 000h, 02dh
		db 024h, 000h, 024h
shady           db 000h,000h,000h          ; ש ground   19
		db 000h,000h,001h
		db 000h,000h,002h
		db 000h,000h,003h
		db 000h,000h,004h
		db 000h,000h,005h
		db 000h,000h,006h
		db 000h,000h,007h
		db 000h,000h,008h          ; ש shades
		db 000h,000h,009h
		db 000h,000h,00ah
		db 000h,000h,00bh
		db 000h,000h,00ch
		db 000h,000h,00dh
		db 000h,000h,00eh
		db 000h,000h,00fh
		db 000h,000h,010h             ; ש shades
		db 001h,000h,011h
		db 002h,000h,012h
		db 003h,000h,013h
		db 004h,000h,014h
		db 005h,000h,015h
		db 006h,000h,016h
		db 007h,000h,015h
		db 008h,000h,016h
		db 009h,000h,017h
		db 00ah,000h,018h
		db 00bh,000h,019h
		db 00ch,000h,01ah
		db 00dh,000h,01bh
		db 00eh,000h,01ch
		db 00fh,000h,01dh
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
;adlib player data by future crew
a_inst_table    label byte
		db 20h+0,20h+1,20h+2,20h+8,20h+9,20h+10,20h+16,20h+17,20h+18
NTB             equ 8192 ;+1024*1
a_note_table    label word
		dw NTB+363,NTB+385,NTB+408,NTB+432,NTB+458,NTB+485
		dw NTB+514,NTB+544,NTB+577,NTB+611,NTB+647,NTB+868
		dw 00
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
;adlib tune by plasmoid (not now!, it's still skaven's tune)
;music_channels equ 8
;music_speed equ 8
;music_instruments LABEL BYTE
;dw OFFSET ains6
;dw OFFSET ains2
;dw OFFSET ains4
;dw OFFSET ains3
;dw OFFSET ains3
;dw OFFSET ains1
;dw OFFSET ains1
;dw OFFSET ains4
;ains1 LABEL BYTE
;db 65,194,6,0,35,242,240,240,1,0,4
;ains2 LABEL BYTE
;db 145,64,135,128,243,111,35,3,1,1,2
;ains3 LABEL BYTE
;db 225,33,17,128,17,19,34,34,0,0,12
;ains4 LABEL BYTE
;db 97,33,27,0,98,132,86,85,0,0,14
;ains6 LABEL BYTE
;db 145,64,135,136,243,111,35,3,1,1,2
;music_patterns LABEL BYTE
;ach0 dw OFFSET ach0d,OFFSET ach0dr
;ach1 dw OFFSET ach1d,OFFSET ach1dr
;ach2 dw OFFSET ach2d,OFFSET ach2dr
;ach3 dw OFFSET ach3d,OFFSET ach3d
;ach4 dw OFFSET ach4d,OFFSET ach4d
;ach5 dw OFFSET ach5d,OFFSET ach5d
;ach6 dw OFFSET ach6d,OFFSET ach6d
;ach7 dw OFFSET ach7d,OFFSET ach7d
;ach0d LABEL BYTE
;db 081h
;ach0dr LABEL BYTE
;db 057h,050h,050h,055h,057h,050h,055h,057h
;db 050h,055h,057h,050h,055h,057h,050h,055h
;db 0
;ach1d LABEL BYTE
;db 081h
;ach1dr LABEL BYTE
;db 050h,055h,057h,050h,055h,057h,050h,055h
;db 057h,050h,055h,057h,050h,055h,057h,050h
;db 0
;ach2d LABEL BYTE
;db 0C0h,050h,084h
;db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
;db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
;ach2dr LABEL BYTE
;db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
;db 025h,015h,025h,015h,028h,018h,02Ah,01Ah
;db 0
;ach3d LABEL BYTE
;db 0A0h,050h,040h,0C0h,040h,088h,040h,040h
;db 03Ah,042h,090h,045h,088h,040h,042h,040h
;db 047h,090h,04Ah,088h,045h,098h,040h
;db 0
;ach4d LABEL BYTE
;db 0A0h,050h,030h,0C0h,047h,088h,047h,043h
;db 042h,045h,047h,045h,048h,047h,047h,050h
;db 052h,084h,050h,04Ah,088h,050h,098h,045h
;db 0
;ach5d LABEL BYTE
;db 0C0h,020h,0A0h,010h,010h,090h,010h,02Ah
;db 025h,088h,028h,02Ah,090h,010h,02Ah,025h
;db 088h,028h,02Ah
;db 0
;ach6d LABEL BYTE
;db 0C0h,020h,0A0h,020h,020h,090h,020h,01Ah
;db 015h,088h,018h,01Ah,090h,020h,01Ah,015h
;db 088h,018h,01Ah
;db 0
;ach7d LABEL BYTE
;db 0C0h,00Ch,0FEh,050h,090h,00Ch,081h,04Ah
;db 050h,084h,052h,055h,086h,04Ah,081h,050h
;db 04Ah,086h,050h,082h,055h,098h,045h
;db 0


music_channels  equ 8
music_speed     equ 8
music_instruments label byte
               dw offset ains1         ; synthyתstrings
               dw offset ains1         ; synthyתstrings
               dw offset ains1         ; synthyתstrings
               dw offset ains2         ; octavedתstring
               dw offset ains3         ; woawתsynthתlead
               dw offset ains3         ; woawתsynthתlead
               dw offset ains4         ; electricתpiano
               dw offset ains5         ; hihatתsnaredrum

ains1           label byte
               db 0e1h,021h,011h,080h,011h,013h,022h,022h,000h,000h,00ch
ains2           label byte
               db 001h,005h,085h,040h,0f7h,0f3h,013h,0f2h,001h,000h,00ah
ains3           label byte
               db 041h,0c2h,006h,000h,023h,0f2h,0f0h,0f0h,001h,000h,004h
ains4           label byte
               db 041h,0c1h,009h,003h,0ffh,0f3h,060h,0f0h,002h,000h,008h
ains5           label byte
               db 030h,01eh,003h,000h,0f6h,0f2h,065h,007h,000h,003h,006h

music_patterns  label byte
ach1            dw offset ach0d
ach0            dw offset ach1d,offset ach1dr
ach2            dw offset ach2d,offset ach2dr
ach3            dw offset ach3d,offset ach3d
ach4            dw offset ach4d,offset ach4d
ach5            dw offset ach5d,offset ach5d
ach6            dw offset ach6d,offset ach6d
ach7            dw offset ach7d,offset ach7d

ach0d           label byte
               db  30h,32h,34h,35h,37h,39h,3bh,3ch,3dh,3eh,3fh,00h

ach1d           label byte
               db 081h
ach1dr          label byte
               db 050h,055h,057h,050h,055h,057h,050h,055h
               db 057h,050h,055h,057h,050h,055h,057h,050h
               db 0
ach2d           label byte
               db 0C0h,050h,084h
               db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
               db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
ach2dr          label byte
               db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
               db 025h,015h,025h,015h,028h,018h,02Ah,01Ah
               db 0
ach3d           label byte
               db 0A0h,050h,040h,0C0h,040h,088h,040h,040h
               db 03Ah,042h,090h,045h,088h,040h,042h,040h
               db 047h,090h,04Ah,088h,045h,098h,040h
               db 0
ach4d           label byte
               db 0A0h,050h,030h,0C0h,047h,088h,047h,043h
               db 042h,045h,047h,045h,048h,047h,047h,050h
               db 052h,084h,050h,04Ah,088h,050h,098h,045h
               db 0
ach5d           label byte
               db 0C0h,020h,0A0h,010h,010h,090h,010h,02Ah
               db 025h,088h,028h,02Ah,090h,010h,02Ah,025h
               db 088h,028h,02Ah
               db 0
ach6d           label byte
               db 0C0h,020h,0A0h,020h,020h,090h,020h,01Ah
               db 015h,088h,018h,01Ah,090h,020h,01Ah,015h
               db 088h,018h,01Ah
               db 0
ach7d           label byte
               db 0C0h,00Ch,0FEh,050h,090h,00Ch,081h,04Ah
               db 050h,084h,052h,055h,086h,04Ah,081h,050h
               db 04Ah,086h,050h,082h,055h,098h,045h
               db 0
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
;adlib data used by player
a_musiccnt      dw 0
a_chdelaycnt    db 9 dup(0)
a_chdelay       db 9 dup(0)
ִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִִ
main:           call    a_init                  ; ש adlib on
		call    init_timer              ; ש timer on
		call    init                    ; ש init screen, etc.
		call    print                   ; ש draw things
		call    shadow                  ; ש create shadow
		call    double                  ; ש double shadow
		call    fill                    ; ש fill screen
		call	fade_it			; ש fade in

@3:             mov     cs:counter,00
		cmp     intern,7                ; ש new frequency
		jb      @no_fade                ;   7*10 = 70/1000 sec
		call    fade                    ; ש rotate colors
		mov byte ptr intern,00
@no_fade:       inc byte ptr intern
		call    shades                  ; ש shades!
@4:             cmp     cs:counter,10           ; ש wait 10/1000 sec
		jb      @4
		mov     bx,offset exit
		call    waitkey                 ; ש jmp exit if key
		jmp     @3
exit:           mov     back,22h
		call    fade_it                 ; ש fade out
		call    kill_timer              ; ש timer off
		call    a_init                  ; ש adlib off
		mov	ax,0003h
		int	21h
		mov     ax,4c00h                ; ש see you soon!
		int     21h
intern          db      00
code            ends
end             trainer
