; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
; ³ (c) Lord Julus - 2000                Vxtasy #1 - Magazine source code ³
; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

update_marquee:                            ;
do_again:                                  ;
       mov ax, data_segment                ;
       push ax ax                          ;
       pop ds es                           ;
                                           ;
       xor cx, cx                          ;
       xor ax, ax                          ;
       lea si, text                        ;
                                           ;
       mov al, crt_start_pos               ;
       add si, ax                          ;
       mov bp, si                          ;
       mov ax, 1301h                       ;
       mov bh, 0                           ;
       mov bl, marquee_attr                ;
       mov cl, end_col                     ;
       sub cl, crt_disp_pos                ;
       mov dh, row                         ;
       mov dl, crt_disp_pos                ;
                                           ;
       cmp dl, start_col                   ;
       jne no_adjust                       ;
                                           ;
no_adjust:                                 ;
                                           ;
rep_adj2:                                  ;
       mov bh, crt_start_pos               ;
       add bh, cl                          ;
       cmp bh, text_len                    ;
       jbe ok_adjust                       ;
       dec cl                              ;
       cmp cx, 0                           ;
       je reinit                           ;
       jmp rep_adj2                        ;
                                           ;
ok_adjust:                                 ;
       mov bh, 0                           ;
       int 10h                             ;
       dec crt_disp_pos                    ;
       mov al, crt_disp_pos                ;
       cmp al, start_col                   ;
       jae ok_start                        ;
       inc crt_disp_pos                    ;
       inc crt_start_pos                   ;
                                           ;
ok_start:                                  ;
       ret                                 ;
                                           ;
reinit:                                    ;
       mov al, 0                           ;
       mov crt_start_pos, al               ;
       mov al, end_col                     ;
       mov crt_disp_pos, al                ;
       jmp do_again                        ;
                                           ;
                                           ;
setnewint1c proc near                      ; Set new timer handler
         pusha                             ;
         push ds                           ;
         push si                           ;
         push es                           ;
         cli                               ;
         mov ax,351ch                      ; get old INT 1c
         int 21h                           ;
         mov si,offset oldint1c            ;
         mov word ptr cs:[si],bx           ; save offset
         mov word ptr cs:[si+2],es         ; save segment
         mov ax,251ch                      ; set new INT 1c
         mov dx,seg NewInt1c               ;
         mov ds,dx                         ;
         mov dx,offset NewInt1c            ;
         int 21h                           ;
         sti                               ;
         pop es                            ;
         pop si                            ;
         pop ds                            ;
         popa                              ;
         ret                               ;
setnewint1c endp                           ;

;===========( Restore the old timer handler )=============================

setoldint1c proc near                      ; Restore old timer handler
         push ds                           ;
         push es                           ;
         push si                           ;
         cli                               ;
         mov si,offset oldint1c             ;
         mov dx,word ptr cs:[si]           ; load offset
         mov ds,word ptr cs:[si + 2]       ; load segment
         mov ax,251ch                      ; set new INT 1c
         int 21h                           ;
         sti                               ;
         pop si                            ;
         pop es                            ;
         pop ds                            ;
         ret                               ;
setoldint1c endp                           ;

;=========( The new timer handler )=======================================

NewInt1c proc far                          ;
         pusha                             ;
         push ds                           ;
         push es                           ;
                                           ;
         pushf                             ;
         call dword ptr cs:[oldint1c]      ;
                                           ;
         cmp cs:events, 0                  ;
         je not_ready                      ;
                                           ;
         dec word ptr cs:[timer]           ;
         mov ax, word ptr [timer]          ;
         cmp ax, 0                         ;
         jne not_ready                     ;
                                           ;
         call update_marquee               ;
         mov cs:[timer], 02h               ;
                                           ;
not_ready:                                 ;
         pop es                            ;
         pop ds                            ;
         popa                              ;
         iret                              ; and exit
NewInt1c endp                              ;
                                           ;
timer dw 02h                               ;
oldint1c        dd      0                  ;
events db 0                                ;