News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Copper fix needed

Started by skywalker, September 23, 2006, 02:29:52 AM

Previous topic - Next topic

skywalker

With WinXP, this starts OK, but the 3 bars meet together and start blinking. I know it's old, but does someone know how to fix it.

Being single has it's advantages. :-)

Thanks.

; COPPER.ASM - 3 simultaneous copper bars  by Tenie Remmel
;              COM FILE 
;            - this version clears the screen and hides the cursor
;   Modification to copper.asm   Works on Windows 98 and ME
;   Andrew Kennedy   May 2002

code Segment
Assume cs:code,ds:code
Org 100h

Start:

     mov     ah,15   ; clear screen         
     int     10h                                   
     mov     ah,0                                   
     int     10h                                   

     xor        ax,ax
     xor        bx,bx
     mov        bh,0            ; hide cursor by moving it to
     mov        dh,25           ; column 1 of row 26
     mov        dl,0
     mov        ah,2
     int        10h
       
Top0001:                      ; for each frame:
        Mov          cx,01FFh ; cx = max scanline (512) - 1
   Inc          bp
        And          bp,cx  ; advance bp (red), speed 1
        Cmpsw               ; tricky: advance si and di by 2
        And          di,cx  ; advance di (green), speed 2
   Inc          si
        And          si,cx  ; advance si (blue), speed 3
        Mov          ah,8   ; for vertical retrace
   Cli
        Mov          cl,Low(384);  ints off, cx = 384 (0180h)

Top0002:     ;  for each of 384 scanlines:
   Mov          dx,3DAh;   dx = IS0 port addr.

Top0003:
   In           AL,DX
   And          al,ah
        Jnz          Top0003

Top0004:      ;   wait for bit to turn off
   In           AL,DX
   And          al,ah
        Jz           Top0004

   ;   wait for bit to come on again
   Push         si
        Call         Value        ; calculate blue,
   Push         di
        Call         Value        ; green, and red values,
   Push         bp
        Call         Value        ; leaving each one on the stack.
        Mov          dl,Low(3C8h) ; dx = Palette Write Reg port addr.
   Sub          al,al
   Out          DX,AL
   Inc          dx
   Pop          ax
        Out          DX,AL  ; select DAC register 0, write red,
   Pop          ax
   Out          DX,AL
   Pop          ax
        Out          DX,AL  ; green and blue intensity values.
        Mov          ah,1   ; for horiz retrace and check key.
        Loop         Top0002

;  loop through all 384 scanlines...

        Int          16h   ; check for key press (enables ints)

        Jz           Top0001

Els0001:

End0001:         ; loop while no key pressed...
        Ret      ; return to DOS...

;--------------------------------------------------------------------
; Value -- Compute a color bar's value.
;--------------------------------------------------------------------
; In: Bar position on stack     Out: Color value on stack

Value:
   Pop          bx
   Pop          ax
        Push         cx      ; ax = bar, bx = return address, save cx

                             ; check this bar's limits:
   Test         ah,ah
        Jbe          Els0006
   Xor          ax,01FFh

Els0006:               ; if moving up, reverse direction.
   Sub          cx,ax
   Cmp          cx,127
   Mov          al,0
        Ja           End0005  ; return 0 if out of range
   Xchg         ax,cx
        Cmp          al,63    ; al = color intensity, fading out
        Jbe          Els0007
   Not          al

Els0007:                    ; yes, invert color.

End0005:                      ; end check this bar's limits.
   Pop          cx
   Push         ax
        Jmp          bx       ; return with color value on stack...
;--------------------------------------------------------------------
code EndS
End Start


sinsi

No problems on my machine, except for a bit of flickering.
Specs are Athlon 2600+, Radeon 9600 pro, XP Home SP2.

Windows doesn't like I/O via the VGA ports, maybe that has something to do with it?
Light travels faster than sound, that's why some people seem bright until you hear them.