Category : OS/2 Files
Archive   : PMPAL.ZIP
Filename : PAL2.ASM

 
Output of file : PAL2.ASM contained in archive : PMPAL.ZIP
.model large,pascal
public _palette_regs
.fardata PALDATA
flag db 0
_palette_regs db 16 dup (0) ;0,1,2,3,4,5,6,7
; db 38h, 09h, 12h, 1Bh, 24h, 2Dh, 36h, 3Fh
assume ds:PALDATA
.code PALETTE
.286
readpal: ; read out all 16 palette registers
mov cx,10h
mov ax,PALDATA
mov ds,ax
lea di,_palette_regs
nextpalette:
mov dx,3DAh
cli
in al,dx
push dx
mov dl,0C0h
mov al,10h ; 10h-cx
sub al,cl ; pal register
out dx,al
jmp yyyy
yyyy:
inc dx
in al,dx
xor ah,ah
mov bx,ax
pop dx
in al,dx
mov dl,0C0h
mov al,20h
out dx,al
sti
mov byte ptr ds:[di],bl
inc di
loop nextpalette

ret

public REMAPALLPALETTE
REMAPALLPALETTE:

push bp
mov bp,sp
push ds
push si
push di

mov cx,word ptr [bp+10]
push cx
push dx

test cx,010h ; 16 color mode ?
jz color256
mov ax,seg flag
mov ds,ax
cmp byte ptr ds:[flag],0 ; palette table read in ?
jnz color256
mov byte ptr ds:[flag],1 ; set flag
call readpal ; read 16 palette registers
color256:
mov ax,word ptr [bp+ 8] ; pointer to color table
mov es,ax
mov di,word ptr [bp+ 6]

xor cx,cx
jmp okay
loop1: mov dx,3DAh
in al,dx
and al,8
jnz okay
loop loop1
okay:
pop dx
pop cx
mov ah,dh

mov si,cx
mov bx,cx ; number of colors
dec bx
shl bx,2 ; four bytes for every color
add di,bx
loop2:
mov al,cl
dec al
test si,0F0h ; 256 colors mode ?
jz noread
lea bx,_palette_regs
xlat
noread:
mov dx,3C8h ; palette register
pushf
cli
out dx,al ; palette register number
inc dx
mov al,es:[di+2]
shr ax,2
out dx,al ; update red register
mov al,es:[di+1]
shr ax,2
out dx,al ; update green register
mov al,es:[di]
shr ax,2
out dx,al ; update blue register
sti
popf
sub di,4
loop loop2

jmp retrn

retrn:
xor ax,ax
pop di
pop si
pop ds
pop bp
retf 6

if 0

int pascal far gpirealizecolortable(HPS hps)
{


endif
end


  3 Responses to “Category : OS/2 Files
Archive   : PMPAL.ZIP
Filename : PAL2.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/