Howdy, Stranger!

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


need for speed!

I have a feeling this will be a dificult question.
my problem is that my pixel setting routine is too slow:

PSET is the original pixel setting routine, but of course, we all know how slow it is.
then there's GET & PUT, quite fast, but no way to manipulate the sprites well for scrolling, special effects, etc.

then there's the POKEing method, where you POKE a color value into the VRAM (SEG = A000), at an offset that represents the pixel coordinates
(POKE 320& * Y% + X%)
this is very fast, (at least two times faster than PSET.)
and even faster in compilation.
and is what I have been using so far.
but... it seems it's STILL too slow, is there a faster way of plotting pixels?
should I do something different than plotting for drawing large scrolling backgrounds?
I want to do this without libraries. but ASM in the code is ok with me.
I've been trying to figure out the assembly equivelent to this code.
it seems easy, but I don't have TASM or NASM, so DEBUG:A is what I got.
and MOV [A000]:AX, BX doesn't work in debug, (what some one suggested to me).
I'm sorry for the long post, but if anyone can help me, then I would appreciate it greatly


  • IDKIDK Posts: 1,784
    MOV [leftbr]A000+AX[rightbr], BX
    I would use some REP STOSB or something similar.
    REP prefixed instructions are really fast.

    This code sets up for the rep movsb and executes it.
    MOV CX, 10 ;how many bytes to be copied
    MOV AX, yourSegment ;wherever you want to move from
    MOV BX, yourAddress
    MOV ES, AX
    MOV DI, BX
    MOV AX, 0A000h
    MOV BX, 0 ;wherever you want to move to
    MOV DS, AX
    MOV SI, BX
    This is 25 byte compiled, but the REP MOVSB is only 2...
    This takes CX clock cycles so it's fast as hell.

    I downloaded this program some years ago.
    The memcopy func is almost as mine above.
    Check it out:
    ' Bmpload Version 2 By Doug Barry (PD Computers)
    ' This is the fastest BMP Loader I have ever seen, and I wrote it !!!!
    ' God it's fast, anyway it uses assembler to copy a variable to the another
    ' part of the memory, here I have used it to put the image data into the
    ' bit of the Physical ram that overlaps the video memory, hence loading
    ' the picture in one vertical blank space (one 50Hz cycle)
    ' Thanks load to Dan Holmes for finding out the memory copying routine, and
    ' Andrew Griffin/Jon Sutton for info on the BMP structure.
    ' Also to the guy/gal that posted ShowBMP9.bas on the net and to the
    ' guy/gal that wrote CPLASMA.BAS for the "OUT" command for palette setting.

    ' Enjoy, even though it's uncommented it should be easy to understand,
    ' being only 65, yes count 'em 65 lines of code (WOW!!!!!!!!).

    ' My E-Mail is [email protected]
    ' or [email protected] if this don't work.
    ' i will try to reply and help with any of your problems.

    DECLARE SUB SetPALETTE (Slot%, R%, G%, B%)
    DECLARE SUB memcopy (fromseg%, fromoffset%, toseg%, tooffset%, bytes%)
    DIM SHARED Buffer(319, 199) AS STRING * 1
    DIM SHARED Pointer AS STRING * 1
    DIM SHARED ImageDataSegment(200) AS STRING * 320
    FileName$ = LCASE$(LTRIM$(RTRIM$(COMMAND$)))
    'FileName$ = "Test.Bmp"
    OPEN FileName$ FOR BINARY AS #1
    IF LOF(1) < 2 THEN PRINT "File does not exist": KILL FileName$: SYSTEM
    GET #1, 54, Pointer
    SCREEN 13
    FOR Slot% = 0 TO 255
    GET #1, , Pointer
    B% = INT(ASC(Pointer) / 4)
    GET #1, , Pointer
    G% = INT(ASC(Pointer) / 4)
    GET #1, , Pointer
    R% = INT(ASC(Pointer) / 4)
    SetPALETTE Slot%, R%, B%, G%
    GET #1, , Pointer
    NEXT Slot%
    FOR Y = 199 TO 0 STEP -1
    GET #1, , ImageDataSegment(Y)
    memcopy VARSEG(ImageDataSegment(0)), VARPTR(ImageDataSegment(0)), &HA000, 0, &HFA00

    SUB memcopy (fromseg%, fromoffset%, toseg%, tooffset%, bytes%)
    asm$ = ""
    asm$ = asm$ + CHR$(85)
    asm$ = asm$ + CHR$(137) + CHR$(229)
    asm$ = asm$ + CHR$(30)
    asm$ = asm$ + CHR$(139) + CHR$(70) + CHR$(10)
    asm$ = asm$ + CHR$(142) + CHR$(192)
    asm$ = asm$ + CHR$(139) + CHR$(70) + CHR$(14)
    asm$ = asm$ + CHR$(142) + CHR$(216)
    asm$ = asm$ + CHR$(139) + CHR$(118) + CHR$(8)
    asm$ = asm$ + CHR$(139) + CHR$(126) + CHR$(12)
    asm$ = asm$ + CHR$(139) + CHR$(78) + CHR$(6)
    asm$ = asm$ + CHR$(243)
    asm$ = asm$ + CHR$(164)
    asm$ = asm$ + CHR$(31)
    asm$ = asm$ + CHR$(93)
    asm$ = asm$ + CHR$(203)
    WAIT &H3DA, 8
    DEF SEG = VARSEG(asm$)
    CALL Absolute(BYVAL fromseg%, BYVAL fromoffset%, BYVAL toseg%, BYVAL tooffset%, BYVAL bytes%, SADD(asm$))

    SUB SetPALETTE (Slot, R, G, B)
    OUT &H3C8, Slot
    OUT &H3C9, R
    OUT &H3C9, B
    OUT &H3C9, G

    I don't know what you want to do, if you give me the basic code I can convert it to (f)asm
  • bosebonasbosebonas Posts: 87
    hi ,
    have you tried to use assembly language ?
    it is very fast .
    contact me to have the dma-straight-to-screen-kill-ya-momma-with-an-axe
    pixel routine (it is 48 microprocessor clock cycles)
    hoping you know how to include assembly in qbasic.
Sign In or Register to comment.