Re: 640*480 memory modes

new topic     » goto parent     » topic index » view thread      » older message » newer message

The Reaper wrote:

> Okay, I was wondering if there was any way to use the memory-copying
> techniques in graphics_mode 19. Can anyone help?

    ?? Mode 19, is normal MCGA, you mean SVGA ??    Well thanx to Pete
Eberlein (if you looked at his SVGA tricks mail...)   it is possible to
do this...

    * You can copy 320*200 bytes at once.... (max)
    * Also in SVGA you can only acces from #A0000 until #A0000+(320*200)

    * But with this interrupt trick you can set where you want #A0000 to
be on the svga screen..
-- Code begins..
    integer bank_start, bytes_per_line, bank_granularity

    procedure svga_offset (sequence p)
    sequence regs, dummy_s
        regs = repeat(0,10)
        regs[REG_AX] = #4F05
        regs[REG_BX] = #0000
        regs[REG_DX] = floor(p[2] * bytes_per_line + p[1] /
bank_granularity
        dummy_s = dos_interrupt(#10, regs)
        bank_start = regs[REG_DX] * bank_granularity
end procedure

procedure svga_setup(integer mode)
    atom data
    sequence regs
    data = allocate_low(256)
    regs = repeat(0,10)
    regs[REG_AX] = #4F01
    regs[REG_CX] = mode
    regs[REG_ES] = floor(data / 16)
    regs[REG_DI] = and_bits(data, 15)
    regs = dos_interrupt(#10, regs)
    bank_granularity = (peek(data + 4) + 256 * peek(data + 5)) * 1024
    bytes_per_line = peek(data + #10) + 256 * peek(data + #11)
    free_low(data)
end procedure
-- code ends (full credits to Pete Eberlein)

You can now use it like this:

    ? graphics_mode (257)
    svga_setup(257)
    svga_offset({100,100})
    mem_set (#A0000,4,320*200)

It will set the screen to color 4, from position {100,100} until 320*200
bytes(max)
It shouldn't be too hard to copy a virtual screen to the svga... you can
use this routine, to copy a equal size virtual screen to the svga screen
of 640*400 (this is more an example..)
svga_offset ({0,0})
mem_copy (#A0000, my_vs, 320*200)
svga_offset({0,100})
mem_copy(#A0000,my_vs, 320*200)
svga_offset({0,200})
mem_copy(#A0000,my_vs, 320*200)
svga_offset({0,300})
mem_copy(#A0000,my_vs, 320*200)
-- Eh voila, overhead is 4 interrupts and 4 times as much to copy..

Compare to euphoria this is lightning fast, euphoria's overhead is...
    * function calling (call display_image, assuming the virtual screen
is in a sequence)
    * atom to byte converting (not so big deal, it is already saved as
4-byte integer, simply the first or last is copied, i believe)
    * interrupt for *every* pixel after the first 320*200 pixels (thus
100 lines)

The last of euphoria's overhead is giant, and a real slowdown... try
this code and see how fast it is.. bet you'll be suprised..! I suppose a
speed increase (compared to virtual screen in sequence, and then
display_imaged to the screen) of about 300%, just guessing...try!

I learned all this from hacking Pete's svga tricks file....
Maybe you should do the same.. ??

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

> http://www.geocities.com/TimesSquare/Alley/4444/eugames.html

Eh... what about an update someday ??

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu