Copperbar effect with image on 80×86

Last Updated or created 2023-10-05

I’m still having problems getting a working floppy drive in my machine.
(Broken FDD card, drive errors etc)

The raster bar (also referred to as rasterbar or copperbar) is an effect used in demos and older video games that displays animated bars of colour, usually horizontal, which additionally might extend into the border, a.k.a. the otherwise unalterable area (assuming no overscan) of the display

When you look at the left side of the screen you see the color bar in the border (outside the normal pixel screen)

I first tried to get it working in DosBOX, but thats a mess.
Good for simple emulation but not hardcore register manipulation.

Below dosbox

Three examples below are in PCem

Not waiting for vsync, gives some idea how much timing is left when doing bars
Other effect added
Effect as on the real hardware except emulated using PCeM
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
use16
org 0x100
CRTC_INDEX = 0x03D4
CRTC_DATA = 0x03D5
INPUT_STATUS = 0x03DA
MAXIMUM_SCAN_LINE = 0x09
LINE_OFFSET = 0x13
jmp start
updown DB 30
direction DB 0
filename DB "shoes.bmp",0
start:
; set mode 320x200 256 colors palette
mov ah,0x0
mov al,13h
int 10h
; clear screen routine, not really needed
clearscreen:
push ax
mov ax, 0a000h
mov es, ax
pop ax
xor di, di
inc ax
mov cx, 64000 ; 320x200
rep stosb
; call file loader
call Loadfile
push cs
pop ds
; after displaying the image or displaying an error, wait for keypress to exit
waitforkeyloop:
call effect ; Calling the effect
MOV AH,1
INT 16h
JZ waitforkeyloop
XOR AH,AH
INT 16h
Exit:
MOV AX,3 ; default text mode 3
INT 10h
MOV AX,4C00h ; exit to dos (terminate process)
INT 21h
Loadfile:
MOV DX,filename
MOV AX,3D00h ; open filehandle
INT 21h
JC Err1
MOV BX,AX ; filehandle
MOV CX,0FFFFh ; size
mov dx,0a000h ; destination 0000:a000h - Screen memory
mov ds,dx
MOV DX,0
MOV AH,3Fh ; read from file
INT 21h
JC Err1
MOV AH,3Eh ; close filehandle
INT 21h
RET
; print error
Err1:
push cs ; make ds same as cs
pop ds
MOV DX,TxtErr1 ; error
MOV AH,09h
INT 21h
RET
effect:
cli ; stop interrupts
call waitvretrace ; wait for vertical retrace
mov al, 0 ; set color index 0 to black (needs to be converted to a function
mov dx, 3c8h
out dx, al
inc dx ; now 3c9h
mov al, 0h
out dx, al ; set R = 0
mov al, 0h
out dx, al ; set G = 0
mov al, 0h
out dx, al ; set B = 0
; gets start scanline and direction
mov al,[updown]
mov ah,[direction]
cmp ah,0
jz addcounter
dec al
cmp al,30
jnz gohere
mov ah,0
mov [direction],ah
jmp gohere
addcounter:
inc al
cmp al,100
jnz gohere
mov ah,1
mov [direction],ah
gohere:
mov [updown],al
; al = scanline, call wait for scanline
call waithretrace
mov al, 0 ; set color index 0 to blueish
mov dx, 3c8h
out dx, al
inc dx
mov al, 11h
out dx, al
mov al, 22h
out dx, al
mov al, 33h
out dx, al
; wait 10 scanlines (height of bar)
mov al,10
call waithretrace
; draw black again
mov al, 0 ; set color index 0's rgb value
mov dx, 3c8h
out dx, al
inc dx ; now 3c9h
mov al, 0
out dx, al ; set R = 11h
mov al, 0h
out dx, al ; set G = 22h
mov al, 0h
out dx, al ; set B = 33h
sti ; start interrupts again
ret
; this waits for vertical retrace
waitvretrace:
mov dx,INPUT_STATUS
waitv1:
in al,dx
test al,8
jnz waitv1
waitv2:
in al,dx
test al,8
jz waitv2
ret
; routine that waits for horizontal retrace
waithretrace:
mov cl,al
mov dx,INPUT_STATUS
waith1:
in al,dx
test al,1
jnz waith1
waith2:
in al,dx
test al,1
jz waith2
dec cl
cmp cl,0
jnz waith1
ret
TxtErr1 DB "shoes.bmp not found!",7,10,13,"$"
use16 org 0x100 CRTC_INDEX = 0x03D4 CRTC_DATA = 0x03D5 INPUT_STATUS = 0x03DA MAXIMUM_SCAN_LINE = 0x09 LINE_OFFSET = 0x13 jmp start updown DB 30 direction DB 0 filename DB "shoes.bmp",0 start: ; set mode 320x200 256 colors palette mov ah,0x0 mov al,13h int 10h ; clear screen routine, not really needed clearscreen: push ax mov ax, 0a000h mov es, ax pop ax xor di, di inc ax mov cx, 64000 ; 320x200 rep stosb ; call file loader call Loadfile push cs pop ds ; after displaying the image or displaying an error, wait for keypress to exit waitforkeyloop: call effect ; Calling the effect MOV AH,1 INT 16h JZ waitforkeyloop XOR AH,AH INT 16h Exit: MOV AX,3 ; default text mode 3 INT 10h MOV AX,4C00h ; exit to dos (terminate process) INT 21h Loadfile: MOV DX,filename MOV AX,3D00h ; open filehandle INT 21h JC Err1 MOV BX,AX ; filehandle MOV CX,0FFFFh ; size mov dx,0a000h ; destination 0000:a000h - Screen memory mov ds,dx MOV DX,0 MOV AH,3Fh ; read from file INT 21h JC Err1 MOV AH,3Eh ; close filehandle INT 21h RET ; print error Err1: push cs ; make ds same as cs pop ds MOV DX,TxtErr1 ; error MOV AH,09h INT 21h RET effect: cli ; stop interrupts call waitvretrace ; wait for vertical retrace mov al, 0 ; set color index 0 to black (needs to be converted to a function mov dx, 3c8h out dx, al inc dx ; now 3c9h mov al, 0h out dx, al ; set R = 0 mov al, 0h out dx, al ; set G = 0 mov al, 0h out dx, al ; set B = 0 ; gets start scanline and direction mov al,[updown] mov ah,[direction] cmp ah,0 jz addcounter dec al cmp al,30 jnz gohere mov ah,0 mov [direction],ah jmp gohere addcounter: inc al cmp al,100 jnz gohere mov ah,1 mov [direction],ah gohere: mov [updown],al ; al = scanline, call wait for scanline call waithretrace mov al, 0 ; set color index 0 to blueish mov dx, 3c8h out dx, al inc dx mov al, 11h out dx, al mov al, 22h out dx, al mov al, 33h out dx, al ; wait 10 scanlines (height of bar) mov al,10 call waithretrace ; draw black again mov al, 0 ; set color index 0's rgb value mov dx, 3c8h out dx, al inc dx ; now 3c9h mov al, 0 out dx, al ; set R = 11h mov al, 0h out dx, al ; set G = 22h mov al, 0h out dx, al ; set B = 33h sti ; start interrupts again ret ; this waits for vertical retrace waitvretrace: mov dx,INPUT_STATUS waitv1: in al,dx test al,8 jnz waitv1 waitv2: in al,dx test al,8 jz waitv2 ret ; routine that waits for horizontal retrace waithretrace: mov cl,al mov dx,INPUT_STATUS waith1: in al,dx test al,1 jnz waith1 waith2: in al,dx test al,1 jz waith2 dec cl cmp cl,0 jnz waith1 ret TxtErr1 DB "shoes.bmp not found!",7,10,13,"$"
use16
org 0x100

CRTC_INDEX = 0x03D4
CRTC_DATA = 0x03D5
INPUT_STATUS = 0x03DA
MAXIMUM_SCAN_LINE = 0x09
LINE_OFFSET = 0x13

jmp start

updown DB 30
direction DB 0
filename DB "shoes.bmp",0

start:
; set mode 320x200 256 colors palette
        mov ah,0x0
        mov al,13h
        int 10h

; clear screen routine, not really needed
clearscreen:
        push ax
        mov ax, 0a000h
        mov es, ax
        pop ax
        xor di, di
        inc ax
        mov cx, 64000 ; 320x200
        rep stosb

; call file loader
        call Loadfile

        push cs
        pop ds

; after displaying the image or displaying an error, wait for keypress to exit
waitforkeyloop:
        call effect     ; Calling the effect
        MOV AH,1
        INT 16h
        JZ waitforkeyloop
        XOR AH,AH
        INT 16h
Exit:
        MOV AX,3        ; default text mode 3
        INT 10h
        MOV AX,4C00h    ; exit to dos (terminate process)
        INT 21h

Loadfile:
        MOV DX,filename
        MOV AX,3D00h    ; open filehandle
        INT 21h
        JC Err1
        MOV BX,AX       ; filehandle
        MOV CX,0FFFFh   ; size
        mov dx,0a000h   ; destination 0000:a000h - Screen memory
        mov ds,dx

        MOV DX,0
        MOV AH,3Fh      ; read from file
        INT 21h
        JC  Err1
        MOV AH,3Eh      ; close filehandle
        INT 21h

        RET
; print error
Err1:
        push cs         ; make ds same as cs
        pop ds
        MOV DX,TxtErr1  ; error
        MOV AH,09h
        INT 21h
        RET

effect:
        cli             ; stop interrupts
        call waitvretrace       ; wait for vertical retrace
        mov al, 0    ; set color index 0 to black (needs to be converted to a function
        mov dx, 3c8h
        out dx, al
        inc dx       ; now 3c9h
        mov al, 0h
        out dx, al   ; set R = 0
        mov al, 0h
        out dx, al   ; set G = 0
        mov al, 0h
        out dx, al   ; set B = 0

; gets start scanline and direction
        mov al,[updown]
        mov ah,[direction]
        cmp ah,0
        jz      addcounter
        dec al
        cmp al,30
        jnz gohere
        mov ah,0
        mov [direction],ah
        jmp gohere
addcounter:
        inc al
        cmp al,100
        jnz gohere
        mov ah,1
        mov [direction],ah
gohere:
        mov [updown],al

; al = scanline, call wait for scanline
        call waithretrace
        mov al, 0    ; set color index 0 to blueish
        mov dx, 3c8h
        out dx, al
        inc dx
        mov al, 11h
        out dx, al
        mov al, 22h
        out dx, al
        mov al, 33h
        out dx, al
; wait 10 scanlines (height of bar)
        mov al,10
        call waithretrace

; draw black again
        mov al, 0    ; set color index 0's rgb value
        mov dx, 3c8h
        out dx, al
        inc dx       ; now 3c9h
        mov al, 0
        out dx, al   ; set R = 11h
        mov al, 0h
        out dx, al   ; set G = 22h
        mov al, 0h
        out dx, al   ; set B = 33h

        sti     ; start interrupts again
        ret

; this waits for vertical retrace
waitvretrace:
        mov dx,INPUT_STATUS
waitv1:
        in al,dx
        test al,8
        jnz waitv1
waitv2:
        in al,dx
        test al,8
        jz waitv2
        ret

; routine that waits for horizontal retrace
waithretrace:
        mov cl,al
        mov dx,INPUT_STATUS
waith1:
        in al,dx
        test al,1
        jnz waith1
waith2:
        in al,dx
        test al,1
        jz waith2
        dec cl
        cmp cl,0
        jnz waith1
        ret

TxtErr1 DB "shoes.bmp not found!",7,10,13,"$"
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *