                .386p
		.model flat, c
		locals
		.code

                public          scroller

                extrn           fontbuffer      :dword
                extrn           scrollbuffer    :dword
                extrn           scrollend       :dword

                screenwidth     dd      256 ;320
                screenheight    dd      256 ;200
                actrow          dd      0
                hspacewidth     dd      5
                vspacewidth     dd      20
                charheights     dd      30
                kisbetuptr      dd      0
                nagybetuptr     dd      320*40
                numbersptr      dd      320*75
                scharwidths     dw      0  ,12          ;a
                                dw      12 ,13          ;b
                                dw      25 ,12          ;c
                                dw      37 ,13          ;d
                                dw      50 ,13          ;e
                                dw      63 ,08          ;f
                                dw      71 ,12          ;g
                                dw      83 ,13          ;h
                                dw      96 ,06          ;i
                                dw      102,08          ;j
                                dw      110,13          ;k
                                dw      123,06          ;l
                                dw      129,19          ;m
                                dw      148,12          ;n
                                dw      160,13          ;o
                                dw      173,12          ;p
                                dw      185,13          ;q
                                dw      198,09          ;r
                                dw      207,11          ;s
                                dw      218,08          ;t
                                dw      227,13          ;u
                                dw      240,12          ;v
                                dw      252,18          ;w
                                dw      270,13          ;x
                                dw      283,12          ;y
                                dw      295,12          ;z
                bcharwidths     dw      0  ,13          ;a
                                dw      13 ,12          ;b
                                dw      25 ,12          ;c
                                dw      37 ,13          ;d
                                dw      50 ,11          ;e
                                dw      61 ,09          ;f
                                dw      70 ,13          ;g
                                dw      83 ,13          ;h
                                dw      96 ,06          ;i
                                dw      102,10          ;j
                                dw      112,13          ;k
                                dw      125,10          ;l
                                dw      135,14          ;m
                                dw      149,12          ;n
                                dw      161,13          ;o
                                dw      174,11          ;p
                                dw      185,12          ;q
                                dw      197,12          ;r
                                dw      209,11          ;s
                                dw      220,11          ;t
                                dw      231,12          ;u
                                dw      243,12          ;v
                                dw      255,16          ;w
                                dw      271,13          ;x
                                dw      284,12          ;y
                                dw      296,12          ;z
                ncharwidths     dw      0  ,13          ;0
                                dw      13 ,09          ;1
                                dw      22 ,12          ;2
                                dw      34 ,11          ;3
                                dw      45 ,12          ;4
                                dw      57 ,12          ;5
                                dw      69 ,12          ;6
                                dw      81 ,12          ;7
                                dw      93 ,12          ;8
                                dw      105,12          ;9
                                dw      117,06          ;!
                                dw      123,12          ;?
                                dw      135,06          ;:
                                dw      141,05          ;.
                                dw      146,07          ;,
                                dw      153,11          ;+
                                dw      164,06          ;-
                                dw      170,12          ;/

                textptr         dd      0
                sorptr          dd      0

                scrolltext      db      '       Group greets go to:',254
                                db      254
                                db      '                Abaddon',254
                                db 254
                                db      '               Astroidea',254
                                db 254
                                db      '                 Capanna',254
                                db 254
                                db      '         Controlled Dreams',254
                                db 254
                                db      '            Criminal Gang',254
                                db 254
                                db      '           Enlightenment',254
                                db 254
                                db      '                    Exact',254
                                db 254
                                db      '               Exhumers',254
                                db 254
                                db      '                   Fiction',254
                                db 254
                                db      '                      Firg',254
                                db 254
                                db      '                      Grif',254
                                db 254
                                db      '                Hurricane',254
                                db 254
                                db      '                Hydrogen',254
                                db 254
                                db      '               Infomaniax',254
                                db 254
                                db      '          Machine Fun Crew',254
                                db 254
                                db      '             Murmidones',254
                                db 254
                                db      '                    Opium',254
                                db 254
                                db      '                   Promise',254
                                db 254
                                db      '                    Remal',254
                                db 254
                                db      '                 Tracktor',254
                                db 254
                                db      '                 Unicorn',254
                                db 254
                                db      '             United Force',254
                                db 254
                                db      '                  Urinate',254
                                db      '                             ',254
                                db      '                             ',254
                                db      '                             ',254
                                db      254
                                db      254
                                db      254
                                db      254
                                db      254
                                db      254
                                db      255

                
scroller:       pushad

                call    scrollup
                call    onerow

                popad
                ret

onerow:         pushad
                mov     eax,actrow
                cmp     eax,charheights
                jna     morerow
                mov     actrow,0
srche:          lea     esi,scrolltext
                add     esi,textptr
                cmp     byte ptr [esi],254
                jae     efound
                inc     textptr
                jmp     srche
efound:         inc     textptr
morerow:        lea     esi,scrolltext
                add     esi,textptr
                mov     edi,scrollbuffer
                mov     eax,screenwidth
                mul     screenheight
                sub     eax,screenwidth
                add     edi,eax

oneloop:        mov     eax,0
                lodsb
                cmp     al,254
                je      endofrow
                cmp     al,255
                je      endofrow2
                cmp     al,'a'
                jb      nemkisbetu
                cmp     al,'z'
                ja      nemkisbetu
                push    esi
                mov     esi,fontbuffer
                add     esi,kisbetuptr
                sub     al,61h
                movzx   ecx,word ptr scharwidths[eax*4]
                add     esi,ecx
                movzx   ecx,word ptr scharwidths[eax*4+2]
                mov     eax,320
                mul     actrow
                add     esi,eax
                rep     movsb
                pop     esi
                jmp     oneloop

nemkisbetu:     cmp     al,'A'
                jb      nemnagybetu
                cmp     al,'Z'
                ja      nemnagybetu
                push    esi
                mov     esi,fontbuffer
                add     esi,nagybetuptr
                sub     al,41h
                movzx   ecx,word ptr bcharwidths[eax*4]
                add     esi,ecx
                movzx   ecx,word ptr bcharwidths[eax*4+2]
                mov     eax,320
                mul     actrow
                add     esi,eax
                rep     movsb
                pop     esi
                jmp     oneloop

nemnagybetu:    cmp     al,20h
                jne     nemspace
                mov     ecx,hspacewidth
                mov     al,0
                rep     stosb
                jmp     oneloop

nemspace:       cmp     al,'0'
                jb      nemszam
                cmp     al,'9'
                ja      nemszam
rechar:         push    esi
                mov     esi,fontbuffer
                add     esi,numbersptr
                sub     al,30h
                movzx   ecx,word ptr ncharwidths[eax*4]
                add     esi,ecx
                movzx   ecx,word ptr ncharwidths[eax*4+2]
                mov     eax,320
                mul     actrow
                add     esi,eax
                rep     movsb
                pop     esi
                jmp     oneloop
nemszam:        cmp     al,'!'
                jne     nemfelk
                mov     al,10+48
                jmp     rechar
nemfelk:        cmp     al,'?'
                jne     nemkerd
                mov     al,11+48
                jmp     rechar
nemkerd:        cmp     al,':'
                jne     nemkett
                mov     al,12+48
                jmp     rechar
nemkett:        cmp     al,'.'
                jne     nempont
                mov     al,13+48
                jmp     rechar
nempont:        cmp     al,','
                jne     nemvesz
                mov     al,14+48
                jmp     rechar
nemvesz:        cmp     al,'+'
                jne     nemplusz
                mov     al,15+48
                jmp     rechar
nemplusz:       cmp     al,'-'
                jne     nemminusz
                mov     al,16+48
                jmp     rechar
nemminusz:      cmp     al,'/'
                jne     nemslash
                mov     al,17+48
                jmp     rechar

nemslash:       jmp     oneloop
endofrow:       mov     sorptr,0
                inc     actrow
                popad
                ret
endofrow2:      mov     sorptr,0
                inc     actrow
                mov     scrollend,1
                popad
                ret

scrollup:       pushad
                mov     esi,scrollbuffer
                add     esi,screenwidth
                mov     edi,scrollbuffer
                mov     eax,screenwidth
                mul     screenheight
                sub     eax,screenwidth
                mov     ecx,eax
                shr     ecx,2
                rep     movsd
                popad
                ret

                end
