flat assembler
Message board for the users of flat assembler.

Index > DOS > Defining Segments in FASM

Author
Thread Post new topic Reply to topic
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 03:09
How do I define segments in FASM like. DATA, CODE, etc.?

Also, how do I define how much stack to allocate?

Let's say my program is greater than 64kb, would FASM automatically add the PSP on the program and make it an EXE?

Thanks!! This is for an little arcade game I'm amking in mode 13h.

If anyone has a multikey handler for FASM I'd be glad to use it. I have a multikey handler myself but I'm too lazy to convert it. Plus mine hooks a new interrupt handler( which I make) to the old interrupt vector. Messy. :*(

_________________
Hello
Post 08 Apr 2006, 03:09
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Apr 2006, 10:18
In the Examples folder, that comes with fasm theres a example.
Use
Code:
format MZ    
at start of exe.
I have a multi keypress code for dos, but it tasm code, but it needs hook into the interrut vector, like they all do. I have a built in multi-keypress games keyboard, for Dex4u OS, all you need do is
Code:
call [GameKeyBoardOn] ;start of gamecall [GameKeyBoardOff] ;end of game    
Cool.
; functions inc
GameKeyBoardOn rd 1 ; 33.Puts the game keyboard on, ESI points to KeyDown a 128 byte array.
GameKeyBoardOff rd 1 ; 34.Turns the Game keyboard off.
Post 08 Apr 2006, 10:18
View user's profile Send private message Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 11:11
Thanks!!!!

What does MZ mean? Frankly, I need to read the manual more often but I'm a little busy with work. :*)

Yeah, we probably have the same algo for then keyboard handler, TASM too. I'm just too lazy to convert it. Not that there are a lot to convert. :*)

It uses an array of 128 bytes to get the keypress after each interrupt.

Oh well, I may just read BIOS:1047 directly to get the status of CTRL, ALT, SHIFT, etc. since the game should only need 3 keys. :*)

Now I'm really inerested in this dex4u. I already downloaded dex4u, I'll test it when I go out of town tomorrow. Not internet for a week :*(

_________________
Hello
Post 08 Apr 2006, 11:11
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 08 Apr 2006, 11:40
Hi!
i whould help, but i not yet have program > 64K...
in dos Wink
format MZ means to generate dos exe file
if you just need to use conventional memory, you can use memory from your code segment up to $a000, this is the video memory,
this is also a way to detect free conventional memory in a com file, since by default, all available memory will be allocated for your com file for use, unless you free it up, and allocate yourself the amount needed.
video bank starts at address 655360 ($a000*16=640kB) approximatly Wink
Memory Management
MODE-X
Start VGA Programming
Introduction to VGA Graphics Programming Using Mode 13h
.
.
.
Post 08 Apr 2006, 11:40
View user's profile Send private message Visit poster's website Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 12:05
It's probably be less than 64 kb. So I'd probably just use a com file. :*) It's a small but fun game. At least that's what my friend told me when he played the HL version coded in 2 hours and 15 mnutes. :*)

Thanks for the links. I'm not gonna use the planar mode-x version though as I heard from a friend that out/inp would be vary slow on windows. :*)
Post 08 Apr 2006, 12:05
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 08 Apr 2006, 12:52
relsoft,
why not draw in a virtual screen then rep movsd the data to video segment?
it whould be fairly fast with simple 320x200x256 too...
write/read pixels will be much faster.
and you don't have to wait retrace on every line draw, only before a page flip.
(this is because you cannot access that memory area while it is automatically updated, memory mapped onto port, so, you whould have to wait even if you are willing to write 5 pixels...)
Post 08 Apr 2006, 12:52
View user's profile Send private message Visit poster's website Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 14:17
Matrix wrote:
relsoft,
why not draw in a virtual screen then rep movsd the data to video segment?
it whould be fairly fast with simple 320x200x256 too...
write/read pixels will be much faster.
and you don't have to wait retrace on every line draw, only before a page flip.
(this is because you cannot access that memory area while it is automatically updated, memory mapped onto port, so, you whould have to wait even if you are willing to write 5 pixels...)

That's exactly what I'd do. Make a double buffer. But I won't blit in a mode-x plane but the chainmode 13h that I am used to.

Anyways, here's an affine textured triangle routine I made 3 years ago. It's in tasm but I want it to put on the game I'm making.


Code:

;;;Fix point Textured triangle routine. :*)
;;;Call with:
;;;Declare sub (Byval Layer%, Byval x1%, Byval y1%,Byval u1%,Byval v1%, Byval x2%,_
;;;     Byval y2%,Byval u2%,Byval v2%, Byval x3%, Byval y3%,Byval u3%,Byval v3%, Byval TSEG%, Byval TOFF%)

.Model Medium, BASIC
.386
.Code

align 2

;;*****************Near procedure for preclipped Textured Hline*****************************************
HTline     Proc  near\
            x1:word, x2:word, y:word, lu:dword, ru:dword, lv:dword, rv:dword, Tsize:word

                        Local udelta:   dword
                        Local vdelta:   dword
                        Local u:                dword
                        Local v:                dword
                        Local dy:               word
                        Local TsizeM1:  word
                        Local Toff:             word
                        Local wid:              word

                        ;GS = Xshift


    mov ax, x1
    mov bx, x2
    cmp ax,bx
    jle Short @Postswapx
        xchg ax, bx
        mov ecx, lu
        mov edx, ru
        xchg ecx, edx
        mov x1, ax
        mov x2, bx
        mov eax, lv
        mov ebx, rv
        xchg eax, ebx
        mov lu, ecx
        mov ru, edx
        mov lv, eax
        mov rv, ebx
@PostSwapX:



        mov ecx, lu
        mov edx, lv
        mov u, ecx
        mov v, edx
        ;U
    mov ax, x1
    mov bx, x2
    mov edx, ru
    mov ecx, lu
                                                                ;Gdx% = (Gx2% - Gx1%) + 1       'Get Xdelta(+1) for the Div by 0 error
                                                                ;Cdx& = Clr2& - Clr1&           'Color delta                                                                    ;deltac& = Cdx& \ Gdx%          'Interpolate
                                                                ;col& = Clr1&                   'save orig color to be safe
    sub edx, ecx

    sub bx, ax
    jz  @NolineH
    mov dy, bx                          ;save ydelta
    mov ax, bx
    cwde                                        ;eax = gdx
    mov ecx, edx                        ;ecx = cdx
    xchg eax, ecx                       ;eax = cdx  : ecx = gdx
    cdq                                         ;eax:edx = cdx

    idiv ecx                                            ;eax = edxedx\ecx
    mov udelta, eax


        ;V
        mov edx, rv
    mov ecx, lv
                                                                ;Gdx% = (Gx2% - Gx1%) + 1       'Get Xdelta(+1) for the Div by 0 error
                                                                ;Cdx& = Clr2& - Clr1&           'Color delta                                                                    ;deltac& = Cdx& \ Gdx%          'Interpolate
                                                                ;col& = Clr1&                   'save orig color to be safe
    sub edx, ecx
    mov ax, dy
    cwde                                        ;eax = gdx
    mov ecx, edx                        ;ecx = cdx
    xchg eax, ecx                       ;eax = cdx  : ecx = gdx
    cdq                                         ;eax:edx = cdx

    idiv ecx                                            ;eax = edxedx\ecx
    mov vdelta, eax



    mov ax, x1
    mov bx, x2


;;;;;;;;;;
    cmp ax,319
    jg @NolineH
    cmp ax,0
    jl  @clipLeft
@PostclipLeft:
    cmp bx,0
    jl  @NolineH
    cmp bx,319
    jg  @clipRight
@PostclipRight:



        mov cx, Tsize
    mov dx, bx                                                  ;dx = (bx - ax)+1
    inc dx
    dec cx
    mov TsizeM1, cx
    sub dx, ax
    jz   @NolineH
    mov cx, y                           ;put in y value
    xchg ch, cl                         ;y = y *256 ;di& = cx * 320& + ax
    mov di, cx                          ;di = 256
    shr di, 2                           ;di = 64
    add di, cx                          ;di = 256+64 = 320
    add di, ax                          ;di = y*320+x


                                                                        ;FOR l% = Gx1% TO Gx2%                   'Rasterizer loop
                                                                        ;    PSET (l%, yy%), col& \ FIXPOINT     'Use poke for speed
                                                                        ;    col& = col& + deltac&               'DDA
                                                                        ;NEXT l%


;;xloop okay
Mov Toff, fs
mov bx, dx                              ;do divide
cmp bx, 4
jle @Less4
and bl, 3
shr dx, 2
mov ch, bl                              ;odd pixels I used dy to conserve mem. :*)
mov wid, dx
mov ax, gs                              ;shift counter
mov cl, al                              ;use cl
mov ebx, u                              ;save u and v
mov edx, v

@xloop:
        ;1.
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di], al
    add ebx, udelta
    add edx, vdelta
    ;2.
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di+1], al
    add ebx, udelta
    add edx, vdelta
    ;3.
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di+2], al
    add ebx, udelta
    add edx, vdelta
    ;4.
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di+3], al
    add ebx, udelta
    add edx, vdelta
    add di, 4
    dec wid
    jnz @xloop

test ch,ch
jz short @NolineH
@xloop2:
        ;1.
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di], al
    add ebx, udelta
    add edx, vdelta
    inc di
    dec ch
    jnz @xloop2

@NolineH:

Ret

@clipLeft:
        mov cx, ax                                                      ;save in cx
        neg cx                                                          ;cx = clipped width
    mov dx,bx
    sub dx,ax
    add ax,dx
    cmp ax,0
    jl short @NolineH
        xor eax, eax
        mov ax, cx
        imul eax, udelta                                ;eax=wid*udelta
        add u, eax                                      ;add to u to clip
        xor eax,eax
        mov ax, cx
        imul eax, vdelta                                ;eax=wid*vdelta
        add v, eax                                              ;add to v to clip
        xor eax,eax
    Jmp  @PostclipLeft

@clipRight:
    mov bx,319
    Jmp  @PostclipRight


;Less then 4
@Less4:
mov wid, dx
mov ax, gs                              ;shift counter
mov cl, al                              ;use cl
mov ebx, u                              ;save u and v
mov edx, v

@xloopLess4:
        ;;v
    mov eax, edx
    shr eax, 16
    and ax, TsizeM1
    shl ax, cl
    mov si, ax
    add si, Toff
    ;;u
    mov eax, ebx
    shr eax, 16
    and ax, TsizeM1
    add si, ax
    mov al,[si+4]
    mov es:[di], al
    add ebx, udelta
    add edx, vdelta
    inc di
    dec wid
    jnz short @xloopLess4
Ret

EndP


;;*****************Procedure for Textured Triangle Filler**************************************************

Public  RelTriT
RelTriT     Proc  Uses es di ds si,\
            Layer:word, x1:word, y1:word, u1:word, v1:word, x2:word, y2:word, u2:word, v2:word,\
            x3:word, y3:word, u3:word, v3:word, Tseg: word, Toff: word

            Local delta1:   dword
            Local delta2:   dword
            Local delta3:   dword
            Local Lx:       dword
            Local Rx:       dword
            Local udelta1:  dword
            Local udelta2:  dword
            Local udelta3:  dword
            Local Lu:       dword
            Local Ru:       dword
            Local vdelta1:  dword
            Local vdelta2:  dword
            Local vdelta3:  dword
            Local Lv:       dword
            Local Rv:       dword
            Local ycounter: word
            Local Tsize:        word
            Local xshift:       word

mov ax, y1
mov bx, y2
cmp bx, ax                      ;cmp y2, y1
jge short @noswapy1
        xchg ax, bx             ;xchg y1, y2
        mov cx, x1
        mov dx, x2
        xchg cx, dx             ;xchg x1, x2
        mov y1, ax
        mov y2, bx
        mov x1, cx
        mov x2, dx
        mov cx, u1
        mov dx, u2
        xchg cx, dx
        mov u1, cx
        mov u2, dx
        mov cx, v1
        mov dx, v2
        xchg cx, dx
        mov v1, cx
        mov v2, dx
@noswapy1:


mov ax, y3
mov bx, y1
cmp ax, bx                      ;cmp y3, y1
jge short @noswapy2
        xchg ax, bx             ;xchg y3, y1
        mov cx, x3
        mov dx, x1
        xchg cx, dx             ;xchg x3, x1
        mov y3, ax
        mov y1, bx
        mov x3, cx
        mov x1, dx
        mov cx, u3
        mov dx, u1
        xchg cx, dx
        mov u3, cx
        mov u1, dx
        mov cx, v3
        mov dx, v1
        xchg cx, dx
        mov v3, cx
        mov v1, dx
@noswapy2:


mov ax, y3
mov bx, y2
cmp ax, bx                      ;cmp y3, y2
jge short @noswapy3
        xchg ax, bx             ;xchg y3, y2
        mov cx, x3
        mov dx, x2
        xchg cx, dx             ;xchg x3, x2
        mov y3, ax
        mov y2, bx
        mov x3, cx
        mov x2, dx
        mov cx, u3
        mov dx, u2
        xchg cx, dx
        mov u3, cx
        mov u2, dx
        mov cx, v3
        mov dx, v2
        xchg cx, dx
        mov v3, cx
        mov v2, dx
@noswapy3:

mov delta1, 0
mov udelta1, 0
mov vdelta1, 0

mov bx, y2                              ;bx = y2
sub bx, y1                              ;bx = bx - y1

jz short @delta1_is_zero                ;IF bx <> 0 THEN
    mov ax, x2                  ;ax = x2
    sub ax, x1                  ;ax = ax - x1

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&

    movsx ecx, bx               ;ecx& = bx
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov delta1, eax

                                        ;uDelta1& = du1 * FIXPOINT \ dy1
    mov ax, u2                  ;ax = u2
    sub ax, u1                  ;ax = ax - u1

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov udelta1, eax

                                        ;vDelta1& = dv1 * FIXPOINT \ dy1
    mov ax, v2                  ;ax = u2
    sub ax, v1                  ;ax = ax - u1

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov vdelta1, eax

@delta1_is_zero:



mov delta2, 0
mov udelta2, 0
mov vdelta2, 0

mov bx, y3                              ;bx = y3
sub bx, y2                              ;bx = bx - y2

jz short @delta2_is_zero                ;IF bx <> 0 THEN
    mov ax, x3                  ;ax = x3
    sub ax, x2                  ;ax = ax - x2

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&

    movsx ecx, bx               ;ecx& = bx
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov delta2, eax

                                        ;uDelta1& = du2 * FIXPOINT \ dy2
    mov ax, u3                  ;ax = u3
    sub ax, u2                  ;ax = ax - u3

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov udelta2, eax

                                        ;vDelta1& = dv2 * FIXPOINT \ dy2
    mov ax, v3                  ;ax = v3
    sub ax, v2                  ;ax = ax - v3

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov vdelta2, eax


@delta2_is_zero:


mov delta3, 0
mov udelta3, 0
mov vdelta3, 0

mov bx, y1                              ;bx = y1
sub bx, y3                              ;bx = bx - y3

jz short @delta3_is_zero                ;IF bx <> 0 THEN
    mov ax, x1                  ;ax = x1
    sub ax, x3                  ;ax = ax - x3

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&

    movsx ecx, bx               ;ecx& = bx
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov delta3, eax

                                        ;uDelta1& = du3 * FIXPOINT \ dy3
    mov ax, u1                  ;ax = u1
    sub ax, u3                  ;ax = ax - u3

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov udelta3, eax

                                        ;vDelta1& = dv3 * FIXPOINT \ dy3
    mov ax, v1                  ;ax = v1
    sub ax, v3                  ;ax = ax - v3

    shl eax, 16                 ;eax& = eax& * FIXPOINT
    cdq                                 ;edx& = eax&
                                        ;edxeax& = edx&
    idiv ecx                    ;delta1& = edxeax& \ ecx&
    mov vdelta3, eax

@delta3_is_zero:


Mov es, Layer
Mov ds, TSEG
mov ax, TOFF
mov fs, ax
mov si, ax
mov bx, [si]
shr bx,3                                ;width
mov Tsize, bx


;calculate shifts

mov ax, bx
    cmp ax, 2
    jne short @xpow4
        mov bx, 1
        jmp short @SizeOK
@xpow4:
    cmp ax, 4
    jne short @xpow8
        mov bx, 2
        jmp short @SizeOK
@xpow8:
    cmp ax, 8
    jne short @xpow16
        mov bx, 3
        jmp short @SizeOK
@xpow16:
    cmp ax, 16
    jne short @xpow32
        mov bx, 4
        jmp short @SizeOK
@xpow32:
    cmp ax, 32
    jne short @xpow64
        mov bx, 5
        jmp short @SizeOK
@xpow64:
    cmp ax, 64
    jne short @xpow128
        mov bx, 6
        jmp short @SizeOK
@xpow128:
    cmp ax, 128
    jne short @xpow256
        mov bx, 7
        jmp short @SizeOK
@xpow256:
    cmp ax, 256
    jne @exit
    mov bx, 8


@SizeOK:
;Flat bottom
;Top part of triangle

mov gs, bx                              ;save xshift

mov ax, x1                              ;ax = x1
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov ebx, eax                    ;ebx& = eax&
mov lx, eax
mov rx, ebx

mov ax, u1                              ;ax = u1
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov ebx, eax                    ;ebx& = eax&
mov lu, eax
mov ru, ebx

mov ax, v1                              ;ax = v1
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov ebx, eax                    ;ebx& = eax&
mov lv, eax
mov rv, ebx



mov cx, y1                                      ;cx = y1
mov ycounter, cx
@Loop1:
        cmp ycounter, 0
    jl short @Noline1
    cmp ycounter, 199
    jg short @Noline1
    mov eax, lx
    mov ebx, rx
    sar eax, 16                         ;ax = eax& \ FIXPOINT
    sar ebx, 16                         ;bx = ebx& \ FIXPOINT
    Push ax                             ;x1
    push bx                             ;x2
    mov ecx, lu                         ;u1
    mov edx, ru             ;u2
    mov ax, ycounter
    push ax
    Push ecx                            ;Lu
    push edx                            ;Ru
    mov eax, lv
    mov ebx, rv
    Push eax                            ;Lv
    push ebx                            ;Rv
    mov cx, Tsize
    push cx


    call HTline

@Noline1:
    mov eax, delta1
    mov ebx, delta3
    mov ecx, udelta1
    mov edx, udelta3

    add lx, eax                         ;eax& = eax& + delta1&
    add rx, ebx                         ;ebx& = ebx& + delta3&
    add lu, ecx                         ;eax& = eax& + udelta1&
    add ru, edx                         ;ebx& = ebx& + udelta3&

    mov eax, vdelta1
    mov ebx, vdelta3
    add lv, eax                         ;eax& = eax& + vdelta1&
    add rv, ebx                         ;ebx& = ebx& + vdelta3&


    inc ycounter
    mov cx, ycounter
    cmp cx, y2
    jle short @Loop1

    mov ebx, delta3
    sub rx, ebx                         ;subtexel accuracy
    mov edx, udelta3
    sub ru, edx
    mov eax, vdelta3
    sub rv, eax


;Flat top
;Lower part of triangle

mov ax, x2                              ;ax = x2
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov lx, eax

mov ax, u2                              ;ax = u2
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov lu, eax

mov ax, v2                              ;ax = v2
cwde                                    ;eax& = ax
sal eax, 16                             ;eax& = eax& * FIXPOINT
mov lv, eax


mov cx, y2                              ;cx = y2
mov ycounter, cx
@Loop2:
        cmp ycounter, 0
    jl short @Noline2
    cmp ycounter, 199
    jg short @Noline2
    mov eax, lx
    mov ebx, rx
    sar eax, 16                         ;ax = eax& \ FIXPOINT
    sar ebx, 16                         ;bx = ebx& \ FIXPOINT
    Push ax                             ;x1
    push bx                             ;x2
    mov ecx, lu                         ;u1
    mov edx, ru             ;u2
    mov ax, ycounter
    push ax
    Push ecx                            ;Lu
    push edx                            ;Ru
    mov eax, lv
    mov ebx, rv
    Push eax                            ;Lv
    push ebx                            ;Rv

    mov cx, Tsize
    push cx


    call HTline

@Noline2:
    mov eax, delta2
    mov ebx, delta3
    mov ecx, udelta2
    mov edx, udelta3

    add lx, eax                         ;eax& = eax& + delta2&
    add rx, ebx                         ;ebx& = ebx& + delta3&
    add lu, ecx                         ;eax& = eax& + udelta2&
    add ru, edx                         ;ebx& = ebx& + udelta3&

    mov eax, vdelta2
    mov ebx, vdelta3
    add lv, eax                         ;eax& = eax& + vdelta2&
    add rv, ebx                         ;ebx& = ebx& + vdelta3&


    inc ycounter
    mov cx, ycounter
    cmp cx, y3
    jl short @Loop2

@exit:
Ret

EndP

End


    



Now I converted the first lines notably the texured scanline routine:

errors out in proc htline....

Code:
proc htline  x1:WORD, x2:WORD, y:WORD, lu:DWORD, ru:DWORD, lv:DWORD, rv:DWORD, Tsize:WORD

                        Local udelta:   DWORD
                        Local vdelta:   DWORD
                        Local u:        DWORD
                        Local v:        DWORD
                        Local dy:       WORD
                        Local TsizeM1:  WORD
                        Local Toff:     WORD
                        Local wid:      WORD

                        ;GS = Xshift


    mov ax, [x1]
    mov bx, [x2]
    cmp ax,bx
    jle Short @Postswapx       
    


another suspect would be my using FS to store a value then doing this:
Code:
Mov [Toff], fs
    


don't know if FASM would even permit it.

thanks!

BTW, if you want to check out some of my old dos ASM proggie here's a lib I made for QB. There are some examples in there that used a double buffer. Should run in DOS and Windows. The ASM source are in the \source folder. It's in TASM though.

http://rel.betterwebber.com/junk.php?id=22

_________________
Hello
Post 08 Apr 2006, 14:17
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Apr 2006, 14:19
The code for Game keyboard for Dex4u in fasm is:
Code:
 ;----------------------------------------------------; ; Games Key board             ;call on keyboard irq. ; ;----------------------------------------------------;GamesKeyBoard:        cld        xor   eax,eax        in    AL,60h        test  al,10000000b        jnz   @f        mov   [WaitKPressed],1;====================================================;; ctrl down                                          ;;====================================================;@@:        mov   BX,AX        and   BX,007Fh                              ; switch high bit of BX to zero        and   AL,80h                                ; check high bit of port value        jz    PressRelease:                                            ; high bit = 1: "release" code        mov   [KeyDown+bx],00h                      ; write 00 to "down" array element        jmp   DoneGKPress:                                              ; high bit = 0: "press" code        mov   [KeyDown+bx],01h                      ; write 01 to "down" array element        jmp   DoneGKDoneGK:        in    AL,61h                                ; read port 61h, system ctrl port        mov   AH,AL                                 ; save value to AH        or    AL,80h                                ; set top bit to "1" - reset kbd        out   61h,AL                                ; write out value to port         xchg  AH,AL                                 ; put original value back into AL        out   61h,AL                                ; rewrite original value in AL nokeyGKboard:        ret ;----------------------------------------------------; ; Data                                               ; ;----------------------------------------------------;KeyDown           rb   128GameKeyBoardOn    db   0Q                 equ  10hA                 equ  1eh    

But you will need to hook it to keyboard interrupt.
As i go strait to pmode, i do not use real mode segmention.
I would use unrealmode see kelvar, for a good example
http://flatassembler.net/examples/kelvar.zip
Dex4u can be run from Dos, by running kernel32.exe at the dos prompt and you can also exit back to dos by typing exit at the CLI, but it must be real Dos, not a windows Dosbox.
Post 08 Apr 2006, 14:19
View user's profile Send private message Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 14:36
Well, your handler is a lot simpler than mine. :*). And after I make my game work on FASM, I'll try to post it to dex4u. :*)

Great job on the OS!
Post 08 Apr 2006, 14:36
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Apr 2006, 14:41
That would be cool Cool and if you have any ? when you come to convert it just ask here:
http://dex.7.forumer.com/
or here:
http://jas2o.forthworks.com/dexforum/index.php
Post 08 Apr 2006, 14:41
View user's profile Send private message Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 08 Apr 2006, 14:53
Actually I go and browse your forums when I'm online. :*) Just didn't register yet because I have nothing for the OS yet. Maybe next week, you'll get bored answering my stupid questions on how to port the game. :*)
Post 08 Apr 2006, 14:53
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Apr 2006, 17:07
relsoft wrote:
Actually I go and browse your forums when I'm online. :*) Just didn't register yet because I have nothing for the OS yet. Maybe next week, you'll get bored answering my stupid questions on how to port the game. :*)

We will not get bored, as that what the OS was designed for, Games and Demos etc Smile.
Working on a skinable dashboard as we speak Cool.

PS: would like a basic port one day.
Post 08 Apr 2006, 17:07
View user's profile Send private message Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 09 Apr 2006, 02:14
Cool. cya in a week. :*)
Very Happy

_________________
Hello
Post 09 Apr 2006, 02:14
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 09 Apr 2006, 14:53
Here's a screenshot of the New Dex4u OS Dashboard (gui), i am working on for Dex4u OS, fully skin able so if do not like it you can change it Wink.
http://www.dex4u.com/images/Dash4u.jpg

Note: the date and time is now in realtime.
Post 09 Apr 2006, 14:53
View user's profile Send private message Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 13 Apr 2006, 03:24
Cool Screenies!!! I'm a little hurried though. Just went back in the city to buy some flowers. :*) I'll be back on monday.

The engine, at least the VGA part, is almost finished.

Done are sprite routines, solid, transparent, and translucent; keyboard handler and collision routnes, plus some eye candy like mode7, etc.

One glaring problem though is it's in tasm.

Now I've looked at the help file that comes with fasm but the proc is not supported in the DOS version. I know proc in fasm is a macro (win32a?) but frankly, I'm not very conversant with fasm's macro language.

Has there been something, a macro, that I could use to emulate PROCS in tasm? thanks!!!

BTW, the dashboard looks awesome!!!!!
Post 13 Apr 2006, 03:24
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 13 Apr 2006, 11:53
Thank relsoft. look forward to test your game, but as for your ? about macro's, i do not use them.
but heres a example:
Code:
macro print string{        push    esi        mov     esi, string        mov     al, 00h        mov     ah, 09h        int     40h        pop     esi}    

Called with:
Code:
print   message    

Code:
message       db 13,'Press a key',13,13,0    

Hope this helps.
Post 13 Apr 2006, 11:53
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Apr 2006, 12:23
i would suggest procedure instead of macro in last example. This is not what macros are for.
Post 13 Apr 2006, 12:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 13 Apr 2006, 12:43
Tomasz seems to frown against using such things as proc which, in his opinion, are unnecessary, so that (supposedly) explains his lack of including such macros in the DOS package (besides obvious other ones like lack of time or better things to work on).

I haven't tried the proc macros in DOS (or Windows either, actually), but they probably work. Anyways, what is an example of a proc syntax that you wish to emulate? I'm guessing My_Label Proc Near or Proc My_Label Uses eax,ebx (N.B. I never used TASM, so I'm only guessing). It's very easy to write a program without all that red tape. Most people probably just use simple labels (My_Label:) and call or jump to them directly (like in NASM, which doesn't support proc either, AFAIK).

P.S. Sorry for the ugly formatting on this post, but it seemed like a good idea at the time! Smile
Post 13 Apr 2006, 12:43
View user's profile Send private message Visit poster's website Reply with quote
relsoft



Joined: 03 Apr 2006
Posts: 29
relsoft 17 Apr 2006, 11:32
rugxulo: I want to be able to call procs with parameters PUSHed to the stack in left to right order like tasm non-ideal. Do youhave a macro that emulates this?

Thanks in advance!
Post 17 Apr 2006, 11:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.