Question on palette data

[green]I wrote a program that saves the rgb values of mode 13h to a file called palette.pal. All well said and done but for one thing, I was looking through the file through a hex editor and the last 15-17 bytes are all 0 which would mean that the final colors in the palette would be black! That can't be right since the values of rgb bytes range from 0-63 possible intensity's for each with 256 colors. Am I doing it right or reading my palette file wrong?
[green]
[code]

xor al, al
mov cx, 768
cld
mov di, offset palette
mov dx, 03c8h
out dx, al
inc dx ;data port 03c9h
rep insb
[/code]

Comments

  • [code]
    mov dx, 03c8h [blue]<-3C8 is for outsb,not insb![/blue]
    [/code]hm,do you know what the standard VGA Palette look like?
    [code]byte PAL[768]; main()
    {AL=0x13; $INT 0x10 AX=0xA000; DX=0x3C7; $OUT DX,AL
    DL=0xC9; DI=#PAL; CX=768; $REP $INSB ES=AX; DI=0;
    CL=200; loop(CX) {do {$STOSB AX++;} while(AL); DI+=64;}
    AH='<'; CX=0; DX=0x149; $INT 0x21 BX>'; $INT 0x21 AH=0; $INT 0x16 AX=3; $INT 0x10
    } byte FN="VGA.PAL";[/code]Or press F3 in this puzzle game http://pheaven.com/c/MsgBoard/read.asp?Board=16&MsgID=253410 to see a nicer palette.
  • : [code]
    : mov dx, 03c8h [blue]<-3C8 is for outsb,not insb![/blue]
    : [/code]hm,do you know what the standard VGA Palette look like?
    : [code]byte PAL[768]; main()
    : {AL=0x13; $INT 0x10 AX=0xA000; DX=0x3C7; $OUT DX,AL
    : DL=0xC9; DI=#PAL; CX=768; $REP $INSB ES=AX; DI=0;
    : CL=200; loop(CX) {do {$STOSB AX++;} while(AL); DI+=64;}
    : AH='<'; CX=0; DX=0x149; $INT 0x21 BX>'; $INT 0x21 AH=0; $INT 0x16 AX=3; $INT 0x10
    : } byte FN="VGA.PAL";[/code]Or press F3 in this puzzle game http://pheaven.com/c/MsgBoard/read.asp?Board=16&MsgID=253410 to see a nicer palette.
    :

    [green]
    Port 03c8 is used to specify the color index you wish to either read/write from Port 03c9h.
    [/green]
    [code]
    xor al, al ;al=0
    mov cx, 768 ;palette size= 256*3
    cld ;set direction for up in memory
    mov di, palette ;offset of our data array
    mov dx, 03c8h ;set to color index=0
    out dx, al
    inc dx ;inc dx to 03c9h
    rep insb ;Repeat 768 times and store at es:di or palette array
    ;Each 3bytes the index at port 03c8h is automatically
    ;incremented to the next color value!
    [/code]
    [green]
    using outsb would be used to set the palette to your color values which I'm not trying to do. I'm trying to copy the default palette to a file called palette.pal .
    [/green]

    Here's the whole program. Uses NASM syntax.
    [code]

    BITS 16
    ORG 0x0100

    xor al, al
    mov cx, 768
    cld
    mov di, palette
    mov dx, 03c8h
    out dx, al
    inc dx
    rep insb



    done:
    mov ah, 39h
    mov dx, pal
    int 21h
    jc Directory_Failed

    mov ah, 03ch
    mov dx, palette_file
    mov cx, 0
    int 21h
    jc Write_Error
    mov [palette_handle], ax

    mov ah, 40h
    mov bx, [palette_handle]
    mov cx, 768
    mov dx, palette
    int 21h
    jc Write_Error
    cmp ax, 768
    je WriteOK

    mov ah, 03eh
    mov bx, [palette_handle]
    int 21h
    jc Close_Error

    End:
    mov ah, 7
    int 21h
    mov ax, 0003h
    int 10h
    mov ax, 4c00h
    int 21h

    Close_Error:
    mov dx, close
    mov ah, 9
    int 21h
    jmp End

    Directory_Failed:
    mov dx, directory
    mov ah, 9
    int 21h
    jmp End


    Write_Error:
    mov dx, error
    mov ah, 9
    int 21h
    jmp End

    WriteOK:
    mov dx, writeok
    mov ah, 9
    int 21h
    jmp End

    SEGMENT .data

    palette times 768 db 0
    palette_file db "C:palpalette.pal",0
    palette_handle dw 0
    error db "Write failed!",13, 10, '$'
    writeok db "768bytes written!",13,10,'$'
    pal db "pal",0
    close db "Couldn't Close file!",13,10,'$'
    directory db "Couldn't create directory!",13,10,'$'

    SEGMENT .bss
    [/code]



  • [quote shaolin007 (#120191) on October 12,2004 at 5:30:17AM]
    [green]Port 03c8 is used to specify the color index you wish to either read/write from Port 03c9h.[/green]
    [/quote]
    Read my C-- program again,Carefully.
    and did your NASM program ever switch to mode13h before reading the palette port?
    ok,for reference:[code]3C7h (W): PEL Address Read Mode (VGA Only)
    bit 0-7 The PEL data register (0..255) to be read from 3C9h.
    Note: After reading the 3bytes at 3C9h this register will increment,pointing to the next data register.

    3C8h (R/W): PEL Address Write Mode (VGA Only)
    bit 0-7 The PEL data register (0..255) to be written to 3C9h.
    Note: After writing the 3bytes at 3C9h this register will increment,pointing to the next data register.

    3C9h (R/W): PEL Data Register (VGA Only)
    bit 0-5 Color value
    Note: Each read or write of this register will cycle through first
    the registers for Red,Blue and Green,then increment the
    appropriate address register,thus the entire palette can be
    loaded by writing 0 to the PEL Address Write Mode register 3C8h
    and then writing all 768bytes of the palette to this register.[/code]
  • you dont need to switch the graphicsmode,reading/writing the palette works in almost all modes.however,switching graphicsmode will set a default-palette for the new graphcsmode and all your changes are lost.ive read some cards provide a flag for Int10h/Func00h-calls which dont change the palette-registers on mode-set,but i never tried that.
  • : [quote shaolin007 (#120191) on October 12,2004 at 5:30:17AM]
    : [green]Port 03c8 is used to specify the color index you wish to either read/write from Port 03c9h.[/green]
    : [/quote]
    : Read my C-- program again,Carefully.
    : and did your NASM program ever switch to mode13h before reading the palette port?
    : ok,for reference:[code]3C7h (W): PEL Address Read Mode (VGA Only)
    : bit 0-7 The PEL data register (0..255) to be read from 3C9h.
    : Note: After reading the 3bytes at 3C9h this register will increment,pointing to the next data register.
    :
    : 3C8h (R/W): PEL Address Write Mode (VGA Only)
    : bit 0-7 The PEL data register (0..255) to be written to 3C9h.
    : Note: After writing the 3bytes at 3C9h this register will increment,pointing to the next data register.
    :
    : 3C9h (R/W): PEL Data Register (VGA Only)
    : bit 0-5 Color value
    : Note: Each read or write of this register will cycle through first
    : the registers for Red,Blue and Green,then increment the
    : appropriate address register,thus the entire palette can be
    : loaded by writing 0 to the PEL Address Write Mode register 3C8h
    : and then writing all 768bytes of the palette to this register.[/code]
    :
    [green]
    You shouldn't have to switch to mode 13h to copy the palette, it represents all 256 colors. I tried what you said and I made 03c7h start at 0 and then copy the 768bytes from 03c9h, but the file is exactly the same as doing it via 03c8h. The problem I'm having is the last 15-17bytes are 0 which would mean black. Why would that be? Also, I did try and analyze your code but the way it was formatted made it hard to decipher plus this is the x86 assembly board and not C. My C is very rusty and I haven't programmed in C in more than a year or two.
    Try assembling the program I posted with NASM and change 03c8h to 03c7h. Then run it through a hex editor and tell me what you see. I get exactly the same results. Also on a final note, this is what my Norton Guide says:
    [/green]
    [code]
    Color registers (no indexing)
    DAC state read 03C7h write n/a
    PEL address read mode read n/a write 03C7h
    PEL address write mode read 03C8h write 03C8h
    PEL data read 03C9h write 03C9h
    PEL mask read 03C6h write 03C6h
    [/code]
    [green]
    So I guess 03c7h is shared with the DAC state? Now I'm confused! :-)
    [/green]

  • my intlist says 3c8h is for puting dac in writemode and 3c7h for readmode.i could imagine that the first vga-cards used two different ports for read-index and write-index.3c7 provides some information about the dac to see wether its in writemode(last index was written to 3c8h) or in readmode(last index written to 3c7h).my manual says its not a good idea to write to 3c9h while in readmode and vice versa.
    however,i never used 3c7h to read the palette and my code works on all vga-cards i know.

    the values of the palette depend on the current graphicsmode and perhaps the actions of the last program you run.(re-)setting the graphicsmode will return to a standart-palette.

    not all modes use all 256 possible colors,some (<8bpp) modes map bytes to a value within their supported color-depths.

    try to write a program in mode 13h that fills the screen with colored lines.draw a line with color 0x00 in column #0,color 0x01 in column #1 up to column #ff ( = #255).fill the last screen with white (color 0x0f i think) to get a contrast to the used palette.now you can see what colors result from the standart-palette.maybe the colors >#200 or so are black by default?try and see :)
  • : my intlist says 3c8h is for puting dac in writemode and 3c7h for readmode.i could imagine that the first vga-cards used two different ports for read-index and write-index.3c7 provides some information about the dac to see wether its in writemode(last index was written to 3c8h) or in readmode(last index written to 3c7h).my manual says its not a good idea to write to 3c9h while in readmode and vice versa.
    : however,i never used 3c7h to read the palette and my code works on all vga-cards i know.
    :
    : the values of the palette depend on the current graphicsmode and perhaps the actions of the last program you run.(re-)setting the graphicsmode will return to a standart-palette.
    :
    : not all modes use all 256 possible colors,some (<8bpp) modes map bytes to a value within their supported color-depths.
    :
    : try to write a program in mode 13h that fills the screen with colored lines.draw a line with color 0x00 in column #0,color 0x01 in column #1 up to column #ff ( = #255).fill the last screen with white (color 0x0f i think) to get a contrast to the used palette.now you can see what colors result from the standart-palette.maybe the colors >#200 or so are black by default?try and see :)
    :
    [green]
    I was going to try and test it but that is a good idea. I'll give it a go, thanks.
    [/green]

  • : [green]
    : You shouldn't have to switch to mode 13h to copy the palette, it represents all 256 colors. I tried what you said and I made 03c7h start at 0 and then copy the 768bytes from 03c9h, but the file is exactly the same as doing it via 03c8h.
    : [/green]
    okay..Experiment time! :-)
    hexdump of the palette:
    [code]mode 3:
    00000000002A002A00002A2A2A00002A002A2A2A002A2A2A00001500003F002A
    15002A3F2A00152A003F2A2A152A2A3F00150000152A003F00003F2A2A15002A
    152A2A3F002A3F2A00151500153F003F15003F3F2A15152A153F2A3F152A3F3F
    15000015002A152A00152A2A3F00003F002A3F2A003F2A2A15001515003F152A
    15152A3F3F00153F003F3F2A153F2A3F15150015152A153F00153F2A3F15003F
    152A3F3F003F3F2A15151515153F153F15153F3F3F15153F153F3F3F153F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F
    3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F

    mode13h:
    00000000002A002A00002A2A2A00002A002A2A15002A2A2A15151515153F153F
    15153F3F3F15153F153F3F3F153F3F3F0000000505050808080B0B0B0E0E0E11
    11111414141818181C1C1C2020202424242828282D2D2D3232323838383F3F3F
    00003F10003F1F003F2F003F3F003F3F002F3F001F3F00103F00003F10003F1F
    003F2F003F3F002F3F001F3F00103F00003F00003F10003F1F003F2F003F3F00
    2F3F001F3F00103F1F1F3F271F3F2F1F3F371F3F3F1F3F3F1F373F1F2F3F1F27
    3F1F1F3F271F3F2F1F3F371F3F3F1F373F1F2F3F1F273F1F1F3F1F1F3F271F3F
    2F1F3F371F3F3F1F373F1F2F3F1F273F2D2D3F312D3F362D3F3A2D3F3F2D3F3F
    2D3A3F2D363F2D313F2D2D3F312D3F362D3F3A2D3F3F2D3A3F2D363F2D313F2D
    2D3F2D2D3F312D3F362D3F3A2D3F3F2D3A3F2D363F2D313F00001C07001C0E00
    1C15001C1C001C1C00151C000E1C00071C00001C07001C0E001C15001C1C0015
    1C000E1C00071C00001C00001C07001C0E001C15001C1C00151C000E1C00071C
    0E0E1C110E1C150E1C180E1C1C0E1C1C0E181C0E151C0E111C0E0E1C110E1C15
    0E1C180E1C1C0E181C0E151C0E111C0E0E1C0E0E1C110E1C150E1C180E1C1C0E
    181C0E151C0E111C14141C16141C18141C1A141C1C141C1C141A1C14181C1416
    1C14141C16141C18141C1A141C1C141A1C14181C14161C14141C14141C16141C
    18141C1A141C1C141A1C14181C14161C0000100400100800100C001010001010
    000C100008100004100000100400100800100C001010000C1000081000041000
    00100000100400100800100C001010000C100008100004100808100A08100C08
    100E081010081010080E10080C10080A100808100A08100C08100E081010080E
    10080C10080A100808100808100A08100C08100E081010080E10080C10080A10
    0B0B100C0B100D0B100F0B10100B10100B0F100B0D100B0C100B0B100C0B100D
    0B100F0B10100B0F100B0D100B0C100B0B100B0B100C0B100D0B100F0B10100B
    0F100B0D100B0C103F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F[/code]first 16colors (48bytes):[code][3C7]=0 [3C8]=0
    000000 00002A 002A00 002A2A 2A0000 2A002A 2A1500 2A2A2A
    151515 15153F 153F15 153F3F 3F1515 3F153F 3F3F15 3F3F3F
    [3C7]=1 [3C8]=0
    00002A 002A00 002A2A 2A0000 2A002A 2A1500 2A2A2A 151515
    15153F 153F15 153F3F 3F1515 3F153F 3F3F15 3F3F3F 000000
    [3C7]=2 [3C8]=0
    002A00 002A2A 2A0000 2A002A 2A1500 2A2A2A 151515 15153F
    153F15 153F3F 3F1515 3F153F 3F3F15 3F3F3F 000000 050505
    [3C7]=3 [3C8]=0
    002A2A 2A0000 2A002A 2A1500 2A2A2A 151515 15153F 153F15
    153F3F 3F1515 3F153F 3F3F15 3F3F3F 000000 050505 080808[/code]now plz explain Why the palette is rotating if [b]3C8[/b] remain Zero?
  • [green]
    Ok, why are these two dumps similiar then? And again what mode your in has nothing to do with the palette. The palette at those ports have 256 colors represented by 3 bytes each. Look appreciate the help but it looks like you can't explain it either so lets drop it.
    Here's a dump of both using 03c7h and 03c8h
    [/green]
    [red]03c7h[/red]
    00000000002a002a00002a2a2a00002a002a2a2a002a2a2a00001500003f002a15002a3f2a00152a003f2a2a152a2a3f00150000152a003f00003f2a2a15002a152a2a3f002a3f2a00151500153f003f15003f3f2a15152a153f2a3f152a3f3f15000015002a152a00152a2a3f00003f002a3f2a003f2a2a15001515003f152a15152a3f3f00153f003f3f2a153f2a3f15150015152a153f00153f2a3f15003f152a3f3f003f3f2a15151515153f153f15153f3f3f15153f153f3f3f153f3f3f3f1f1f3f271f3f2f1f3f371f3f3f1f373f1f2f3f1f273f1f1f3f1f1f3f271f3f2f1f3f371f3f3f1f373f1f2f3f1f273f2d2d3f312d3f362d3f3a2d3f3f2d3f3f2d3a3f2d363f2d313f2d2d3f312d3f362d3f3a2d3f3f2d3a3f2d363f2d313f2d2d3f2d2d3f312d3f362d3f3a2d3f3f2d3a3f2d363f2d313f00001c07001c0e001c15001c1c001c1c00151c000e1c00071c00001c07001c0e001c15001c1c00151c000e1c00071c00001c00001c07001c0e001c15001c1c00151c000e1c00071c0e0e1c110e1c150e1c180e1c1c0e1c1c0e181c0e151c0e111c0e0e1c110e1c150e1c180e1c1c0e181c0e151c0e111c0e0e1c0e0e1c110e1c150e1c180e1c1c0e181c0e151c0e111c14141c16141c18141c1a141c1c141c1c141a1c14181c14161c14141c16141c18141c1a141c1c141a1c14181c14161c14141c14141c16141c18141c1a141c1c141a1c14181c14161c0000100400100800100c001010001010000c100008100004100000100400100800100c001010000c100008100004100000100000100400100800100c001010000c100008100004100808100a08100c08100e081010081010080e10080c10080a100808100a08100c08100e081010080e10080c10080a100808100808100a08100c08100e081010080e10080c10080a100b0b100c0b100d0b100f0b10100b10100b0f100b0d100b0c100b0b100c0b100d0b100f0b10100b0f100b0d100b0c100b0b100b0b100c0b100d0b100f0b10100b0f100b0d100b0c100000000000


    [red]03c8[/red]
    00000000002a002a00002a2a2a00002a002a2a2a002a2a2a00001500003f002a15002a3f2a00152a003f2a2a152a2a3f00150000152a003f00003f2a2a15002a152a2a3f002a3f2a00151500153f003f15003f3f2a15152a153f2a3f152a3f3f15000015002a152a00152a2a3f00003f002a3f2a003f2a2a15001515003f152a15152a3f3f00153f003f3f2a153f2a3f15150015152a153f00153f2a3f15003f152a3f3f003f3f2a15151515153f153f15153f3f3f15153f153f3f3f153f3f3f3f1f1f3f271f3f2f1f3f371f3f3f1f373f1f2f3f1f273f1f1f3f1f1f3f271f3f2f1f3f371f3f3f1f373f1f2f3f1f273f2d2d3f312d3f362d3f3a2d3f3f2d3f3f2d3a3f2d363f2d313f2d2d3f312d3f362d3f3a2d3f3f2d3a3f2d363f2d313f2d2d3f2d2d3f312d3f362d3f3a2d3f3f2d3a3f2d363f2d313f00001c07001c0e001c15001c1c001c1c00151c000e1c00071c00001c07001c0e001c15001c1c00151c000e1c00071c00001c00001c07001c0e001c15001c1c00151c000e1c00071c0e0e1c110e1c150e1c180e1c1c0e1c1c0e181c0e151c0e111c0e0e1c110e1c150e1c180e1c1c0e181c0e151c0e111c0e0e1c0e0e1c110e1c150e1c180e1c1c0e181c0e151c0e111c14141c16141c18141c1a141c1c141c1c141a1c14181c14161c14141c16141c18141c1a141c1c141a1c14181c14161c14141c14141c16141c18141c1a141c1c141a1c14181c14161c0000100400100800100c001010001010000c100008100004100000100400100800100c001010000c100008100004100000100000100400100800100c001010000c100008100004100808100a08100c08100e081010081010080e10080c10080a100808100a08100c08100e081010080e10080c10080a100808100808100a08100c08100e081010080e10080c10080a100b0b100c0b100d0b100f0b10100b10100b0f100b0d100b0c100b0b100c0b100d0b100f0b10100b0f100b0d100b0c100b0b100b0b100c0b100d0b100f0b10100b0f100b0d100b0c100000000000

    [green]
    Funny how it increments itself both ways don't you think? Looks the same don't it?
    [/green]
  • each videomode has its own default-palette which is loaded when you set it.you can always read/write all 256 palette-registers,even when not all of them are used by your current mode.i think the unused registers are undefined,maybe their contents are different on other graphiccards.

    after 3 reads/writes to 3c9 the palette-register-index increments to the next color-index.ive read older (ISA?-)cards need a cycle or two to increment the index so you should do a JMP-instruction (or dont use REP-prefix for all 768 bytes) to waste some cycles.however i never experienced any problems with that.

    most applications using mode 13h use their own palette-data which is optimized for very their needs.imagine an game with lots of bitmap-data and animated water and fire.it needs more different blue and red colors for animations and maybe 64 or 128 colors for bitmap-data.even a simple 8bpp bitmap-viewer have to set a new palette to display the picture with right colors.
  • [green]
    ok, dump of switch to mode 13h
    [/green]

    [code]
    000 00 00 00 00 00 2a 00 2a 00 00 2a 2a 2a 00 00 2a 00 2a 2a 15 00 2a .....*.*..***..*.**..*
    016 2a 2a 15 15 15 15 15 3f 15 3f 15 15 3f 3f 3f 15 15 3f 15 3f 3f 3f **.....?.?..???..?.???
    02c 15 3f 3f 3f 00 00 00 05 05 05 08 08 08 0b 0b 0b 0e 0e 0e 11 11 11 .???..................
    042 14 14 14 18 18 18 1c 1c 1c 20 20 20 24 24 24 28 28 28 2d 2d 2d 32 ......... $$$(((---2
    058 32 32 38 38 38 3f 3f 3f 00 00 3f 10 00 3f 1f 00 3f 2f 00 3f 3f 00 22888???..?..?..?/.??.
    06e 3f 3f 00 2f 3f 00 1f 3f 00 10 3f 00 00 3f 10 00 3f 1f 00 3f 2f 00 ??./?..?..?..?..?..?/.
    084 3f 3f 00 2f 3f 00 1f 3f 00 10 3f 00 00 3f 00 00 3f 10 00 3f 1f 00 ??./?..?..?..?..?..?..
    09a 3f 2f 00 3f 3f 00 2f 3f 00 1f 3f 00 10 3f 1f 1f 3f 27 1f 3f 2f 1f ?/.??./?..?..?..?'.?/.
    0b0 3f 37 1f 3f 3f 1f 3f 3f 1f 37 3f 1f 2f 3f 1f 27 3f 1f 1f 3f 27 1f ?7.??.??.7?./?.'?..?'.
    0c6 3f 2f 1f 3f 37 1f 3f 3f 1f 37 3f 1f 2f 3f 1f 27 3f 1f 1f 3f 1f 1f ?/.?7.??.7?./?.'?..?..
    0dc 3f 27 1f 3f 2f 1f 3f 37 1f 3f 3f 1f 37 3f 1f 2f 3f 1f 27 3f 2d 2d ?'.?/.?7.??.7?./?.'?--
    0f2 3f 31 2d 3f 36 2d 3f 3a 2d 3f 3f 2d 3f 3f 2d 3a 3f 2d 36 3f 2d 31 ?1-?6-?:-??-??-:?-6?-1
    108 3f 2d 2d 3f 31 2d 3f 36 2d 3f 3a 2d 3f 3f 2d 3a 3f 2d 36 3f 2d 31 ?--?1-?6-?:-??-:?-6?-1
    11e 3f 2d 2d 3f 2d 2d 3f 31 2d 3f 36 2d 3f 3a 2d 3f 3f 2d 3a 3f 2d 36 ?--?--?1-?6-?:-??-:?-6
    134 3f 2d 31 3f 00 00 1c 07 00 1c 0e 00 1c 15 00 1c 1c 00 1c 1c 00 15 ?-1?..................
    14a 1c 00 0e 1c 00 07 1c 00 00 1c 07 00 1c 0e 00 1c 15 00 1c 1c 00 15 ......................
    160 1c 00 0e 1c 00 07 1c 00 00 1c 00 00 1c 07 00 1c 0e 00 1c 15 00 1c ......................
    176 1c 00 15 1c 00 0e 1c 00 07 1c 0e 0e 1c 11 0e 1c 15 0e 1c 18 0e 1c ......................
    18c 1c 0e 1c 1c 0e 18 1c 0e 15 1c 0e 11 1c 0e 0e 1c 11 0e 1c 15 0e 1c ......................
    1a2 18 0e 1c 1c 0e 18 1c 0e 15 1c 0e 11 1c 0e 0e 1c 0e 0e 1c 11 0e 1c ......................
    1b8 15 0e 1c 18 0e 1c 1c 0e 18 1c 0e 15 1c 0e 11 1c 14 14 1c 16 14 1c ......................
    1ce 18 14 1c 1a 14 1c 1c 14 1c 1c 14 1a 1c 14 18 1c 14 16 1c 14 14 1c ......................
    1e4 16 14 1c 18 14 1c 1a 14 1c 1c 14 1a 1c 14 18 1c 14 16 1c 14 14 1c ......................
    1fa 14 14 1c 16 14 1c 18 14 1c 1a 14 1c 1c 14 1a 1c 14 18 1c 14 16 1c ......................
    210 00 00 10 04 00 10 08 00 10 0c 00 10 10 00 10 10 00 0c 10 00 08 10 ......................
    226 00 04 10 00 00 10 04 00 10 08 00 10 0c 00 10 10 00 0c 10 00 08 10 ......................
    23c 00 04 10 00 00 10 00 00 10 04 00 10 08 00 10 0c 00 10 10 00 0c 10 ......................
    252 00 08 10 00 04 10 08 08 10 0a 08 10 0c 08 10 0e 08 10 10 08 10 10 ......................
    268 08 0e 10 08 0c 10 08 0a 10 08 08 10 0a 08 10 0c 08 10 0e 08 10 10 ......................
    27e 08 0e 10 08 0c 10 08 0a 10 08 08 10 08 08 10 0a 08 10 0c 08 10 0e ......................
    294 08 10 10 08 0e 10 08 0c 10 08 0a 10 0b 0b 10 0c 0b 10 0d 0b 10 0f ......................
    2aa 0b 10 10 0b 10 10 0b 0f 10 0b 0d 10 0b 0c 10 0b 0b 10 0c 0b 10 0d ......................
    2c0 0b 10 0f 0b 10 10 0b 0f 10 0b 0d 10 0b 0c 10 0b 0b 10 0b 0b 10 0c ......................
    2d6 0b 10 0d 0b 10 0f 0b 10 10 0b 0f 10 0b 0d 10 0b 0c 10 00 00 00 00 ......................
    2ec 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....................
    [/code]
    [green]
    If you see those last bytes are 0 value which would mean black right?
    See code below:
    [/green]

    [code]

    BITS 16
    ORG 0x0100

    mov ax,0013h
    int 10h

    xor ax, ax
    mov cx, 768
    cld
    mov di, palette
    mov dx, 03c7h
    out dx, al
    add dx, 2
    rep insb



    done:
    mov ah, 39h
    mov dx, pal
    int 21h
    jc Directory_Failed

    mov ah, 03ch
    mov dx, palette_file
    mov cx, 0
    int 21h
    jc Write_Error
    mov [palette_handle], ax

    mov ah, 40h
    mov bx, [palette_handle]
    mov cx, 768
    mov dx, palette
    int 21h
    jc Write_Error
    cmp ax, 768
    je WriteOK

    mov ah, 03eh
    mov bx, [palette_handle]
    int 21h
    jc Close_Error

    End:
    mov ah, 7
    int 21h
    mov ax, 4c00h
    int 21h

    Mode_03:
    mov ax, 0003h
    int 10h
    ret

    Close_Error:
    call Mode_03
    mov dx, close
    mov ah, 9
    int 21h
    jmp End

    Directory_Failed:
    call Mode_03
    mov dx, directory
    mov ah, 9
    int 21h
    jmp End


    Write_Error:
    call Mode_03
    mov dx, error
    mov ah, 9
    int 21h
    jmp End

    WriteOK:
    call Mode_03
    mov dx, writeok
    mov ah, 9
    int 21h
    jmp End

    SEGMENT .data

    palette times 768 db 0
    palette_file db "C:palpalette.pal",0
    palette_handle dw 0
    error db "Write failed!",13, 10, '$'
    writeok db "768bytes written!",13,10,'$'
    pal db "pal",0
    close db "Couldn't Close file!",13,10,'$'
    directory db "Couldn't create directory!",13,10,'$'
    SEGMENT .bss

    [/code]
  • [green]Ok, why are these two dumps similiar then? And again what mode your in has nothing to do with the palette. The palette at those ports have 256 colors represented by 3 bytes each. Look appreciate the help but it looks like you can't explain it either so lets drop it.
    Here's a dump of both using 03c7h and 03c8h
    [/green]
    [red]03c7h[/red][blue]=what? [3C8]=what?[/blue]

    [red]03c8[/red][blue]=what? [3C7]=what?[/blue]

    [green]Funny how it increments itself both ways don't you think? Looks the same don't it?[/green]
    *snicker*
    I've the palette rotated because I set [3C7] Explicitly in my program.

    [green]ok, dump of switch to mode 13h
    [/green]

    [green]
    If you see those last bytes are 0 value which would mean black right?[/green]
    ..so? you don't like Black?
    Send your gfx card to the manufacturer and have them alter the palette for you?
  • : [green]Ok, why are these two dumps similiar then? And again what mode your in has nothing to do with the palette. The palette at those ports have 256 colors represented by 3 bytes each. Look appreciate the help but it looks like you can't explain it either so lets drop it.
    : Here's a dump of both using 03c7h and 03c8h
    : [/green]
    : [red]03c7h[/red][blue]=what? [3C8]=what?[/blue]
    :
    : [red]03c8[/red][blue]=what? [3C7]=what?[/blue]
    :
    : [green]Funny how it increments itself both ways don't you think? Looks the same don't it?[/green]
    : *snicker*
    : I've the palette rotated because I set [3C7] Explicitly in my program.
    :
    : [green]ok, dump of switch to mode 13h
    : [/green]
    :
    : [green]
    : If you see those last bytes are 0 value which would mean black right?[/green]
    : ..so? you don't like Black?
    : Send your gfx card to the manufacturer and have them alter the palette for you?
    :

    [green] Look, I'm just learning and I don't really appreciate your childish attitude. If you don't know the answer to my original question to begin with then do me a favor and don't bother answering. I'm going to be wrong and that is why I'm going to ask a question on this board. I don't go to school for this, it is done on my spare time so I do not have the privilege of a professor or teacher to come to for any questions or advice. Like I said earlier, if you don't want to help but want to ridicule then I suggest you take yourself elsewhere. Nobody else on this board has a problem with helping out people so whats your problem?
    [/green]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories