Qbasicnews.com
May 23, 2022, 09:10:47 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Opcodes....  (Read 3486 times)
relsoft
*/-\*
*****
Posts: 3927



WWW
« on: May 31, 2003, 02:31:42 AM »

I have no time to make a parser for this list file so I'm posting. Anyone know of an opcode(the one we use in CALL Absolute) for MASM/TASM specific code?

I could Use debug 95 but it has probs with forward jumps. And I'm too lazy to rewrite my code using BP offsets.

Here's the listing file:



BTW, this is a flipped sprite routine which is as fast as relsprite. :*)



Code:


Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 1
SprFlip.ASM



      1 ;SUB RelSpriteFlip(BYVAL Layer%,BYVAL X%,BYVAL Y%,BYVAL SprSeg%,BYVAL SPROff%,Byval    +
      2 Flipmode%)
      3 ;;;;;
      4 ;;;;;
      5 ;;
      6 ;0=NoFlip
      7 ;1=FlipH
      8 ;2=FlipV
      9 ;3=FlipVH
     10 ;Else=No Flip
     11 ;;
     12 ;;
     13    0000 .Model Medium,BASIC
     14 .386
     15    0000 .Code
     16
     17 Align 2
     18
     19
     20 PUBLIC RelSpriteFlip
     21
     22    0000 RelSpriteFlip PROC uses Ds Es Si di,\
     23     Layer:Word, X:Word, Y:Word, SprSeg:Word, SprOff:Word, FlipMode:Word
     24
     25     Local SiOff:    Word
     26     Local Wid:     Word
     27     Local Hei:     Word
     28     Local t20Mw:    Word
     29     Local OldWid:   Word
     30     Local OldHei:   Word
     31     Local ClipT:    Word     ;Clipping offsets
     32     Local ClipR:    Word
     33     Local ClipL:    Word
     34     Local ClipD:    Word
     35
     36
1    37    0000  C8 0014 00 ENTERW 00014h,0
1    38    0004  1E PUSH DS
1    39    0005  06 PUSH ES
1    40    0006  56 PUSH SI
1    41    0007  57 PUSH DI
1    42    0008  8E 5E 0A     Mov ds,SprSeg
     43    000B  8E 46 10     Mov es,Layer
     44    000E  8B 76 08     Mov si,SprOff
     45    0011  8B 1C     Mov bx,ds:[si] ;Width of spr
     46    0013  C1 EB 03     Shr bx,3
     47    0016  89 5E FC     Mov Wid,bx
     48    0019  89 5E F6     Mov OldWid,bx
     49    001C  8B 54 02     Mov dx,ds:[si+2] ;Height
     50    001F  89 56 FA     Mov Hei,dx
     51    0022  89 56 F4     Mov OldHei,Dx
     52    0025  C7 46 FE 0000     Mov Sioff,0
     53    002A  C7 46 F8 0000     Mov t20mW,0
     54    002F  C7 46 F2 0000     mov clipT,0
     55    0034  C7 46 F0 0000     mov clipR,0
     56    0039  C7 46 EC 0000     mov clipD,0
     57    003E  C7 46 EE 0000     mov clipL,0
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 2
SprFlip.ASM



     58
     59    0043  83 C6 04     Add si,4 ;1st color
     60
     61
     62 ;Note!!!!  After the clips
     63 ;Ax=X     Clipped
     64 ;Cx=Y     Clipped
     65 ;Bx=Width   New
     66 ;Dx=Height  New
     67
     68    0046  8B 46 0E Mov ax,X
     69    0049  3D 013F Cmp ax,319
     70    004C  0F 8F 007E Jg @exit
     71    0050  3D 0000 Cmp ax,0
     72    0053  0F 8C 007F Jl @ClipLeft
     73    0057 @PostClipLeft:
     74    0057  8B 4E 0C Mov cx,Y
     75    005A  81 F9 00C7 Cmp cx,199
     76    005E  7F 6E 90 90 Jg @exit
     77    0062  83 F9 00 Cmp cx,0
     78    0065  0F 8C 0080 Jl @ClipTop
     79    0069 @PostClipTop:
     80
     81    0069  03 D8 Add bx,ax ;Add X to WID and see if its over *BX is destroyed
     82    006B  81 FB 013F Cmp bx,319 ;If X+Width > 319,  crop it
     83    006F  0F 8F 0088 Jg  @ClipRight
     84    0073  2B D8 Sub bx,ax ;Restore bx
     85    0075 @PostClipRight:
     86
     87    0075  03 D1 Add dx,cx
     88    0077  81 FA 00C7 Cmp dx,199
     89    007B  0F 8F 008E Jg  @ClipDown
     90    007F  2B D1 Sub dx,cx ;Restore dx
     91    0081 @PostClipDown:
     92
     93 ;ax=X, cx=Y, bx=NewWidth, dx=NewHeight
     94
     95    0081  89 5E FC Mov Wid,bx ;Save wid
     96
     97 ;;;;;calc offset.....
     98
     99    0084  86 E9 Xchg ch,cl
    100    0086  BB 0140 Mov bx,320
    101
    102    0089  8B F9 Mov di,cx
    103    008B  2B 5E FC Sub bx,Wid ;get 320-Width
    104
    105    008E  C1 EF 02 Shr di,2
    106    0091  03 F9 Add di,cx ;Y*64+Y*256=Y*320  :)
    107    0093  89 5E F8 Mov T20Mw,bx
    108
    109    0096  03 F8 Add di,ax ;Offset done!!!=Y*320+X
    110
    111 ;;;;
    112 ;;;;
    113 ;;;;
    114 ;;;;
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 3
SprFlip.ASM



    115 ;;;;Check here for our flipmode
    116
    117    0098  83 7E 06 01 cmp FlipMode,1
    118    009C  0F 84 0084     Je @FlipH
    119    00A0  83 7E 06 02 cmp FlipMode,2
    120    00A4  0F 84 00A3     Je @FlipV
    121    00A8  83 7E 06 03 cmp FlipMode,3
    122    00AC  0F 84 00DF     Je @FlipVH
    123
    124    00B0  8B 5E FC Mov bx,Wid ;restore bx
    125
    126    00B3 @Yloop:
    127
    128    00B3  8B CB Mov cx,bx ;Clipped width to counter
    129
    130    00B5 @Xloop:
    131
    132    00B5  8A 04 Mov al,ds:[si] ;color
    133    00B7  46 Inc si ;Next color
    134    00B8  0A C0 Or al,al ;check for color 0
    135
    136    00BA  74 05 90 90 JZ @Skipcolor
    137    00BE  26: 88 05    Mov es:[di],al
    138    00C1 @Skipcolor:
    139
    140    00C1  47 Inc di
    141    00C2  49 Dec cx ;Check width
    142
    143    00C3  75 F0 Jnz @Xloop
    144
    145    00C5  03 7E F8     Add di,T20MW     ;Add to di 320-ClipWidth
    146    00C8  03 76 FE     Add si,SiOff     ;Si Offset clipped corrector
    147
    148    00CB  4A     dec dx     ;Check Height
    149
    150    00CC  75 E5     Jnz @Yloop
    151
    152    00CE @exit:
1   153    00CE  5F POP DI
1   154    00CF  5E POP SI
1   155    00D0  07 POP ES
1   156    00D1  1F POP DS
1   157    00D2  C9 LEAVEW
1   158    00D3  CA 000C RET 0000Ch
    159
    160
    161    00D6 @ClipLeft:
    162    00D6  F7 D8 Neg ax ;-ax=+ax
    163    00D8  2B D8 Sub bx,ax ;sub clipped width to read width
    164    00DA  7E F2 Jle @Exit ;Negative result = outa here
    165    00DC  03 F0 Add si,ax ;clip our sprite offset
    166 ;bx is the new clipped width
    167    00DE  89 46 FE Mov Sioff,ax ;save si offset corrector
    168    00E1  89 46 EE mov ClipL,ax ;for clip of flipH
    169    00E4  33 C0 Xor ax,ax ;zero out coord
    170    00E6  E9 FF6E Jmp @PostClipLeft
    171
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 4
SprFlip.ASM



    172
    173    00E9 @ClipTop:
    174    00E9  F7 D9 Neg cx
    175    00EB  2B D1 Sub dx,cx
    176    00ED  7E DF Jle @exit
    177    00EF  89 4E F2 mov ClipT,cx ;How much to clip down if flipped V
    178
    179    00F2      @HeightLoop:
    180    00F2  03 76 FC Add si,Wid ;add width to get to next scanline
    181    00F5  49 Dec cx
    182    00F6  75 FA      Jnz @HeightLoop ;Loop until we get to offset.cx=0
    183    00F8  E9 FF6E      Jmp @PostClipTop
    184
    185    00FB @ClipRight:
    186    00FB  81 EB 0140 Sub Bx,320 ;Bx is now clipped right
    187    00FF  01 5E FE Add Sioff,bx ;Add to si corrector
    188    0102  89 5E F0 mov ClipR,bx ;for clip of flipH
    189    0105  BB 0140 Mov bx,320 ;Correct bx to clipX2+1
    190    0108  2B D8 Sub bx,ax ;Subract ax to bx to correct width(0 TO 319)
    191    010A  E9 FF68 Jmp @PostClipRight
    192
    193    010D @ClipDown:
    194    010D  03 CA Add cx,dx ;add height to Y
    195    010F  81 E9 00C8 Sub cx,200 ;Correct it
    196    0113  2B D1 Sub dx,cx ;Crop out height
    197    0115  8B 4E F4 mov cx,OldHei ;put in OldHeight
    198    0118  89 4E EC mov ClipD,cx ;
    199    011B  29 56 EC sub ClipD,dx ;cropped down height
    200    011E  8B 4E 0C Mov cx,Y ;Restore Y
    201    0121  E9 FF5D Jmp @PostClipDown
    202
    203
    204 ;;==========Horizontal Flip clips perfectly!!!
    205    0124 @FlipH:
    206    0124  03 76 F0 add si,ClipR     ;if clipped right then correct start offset
    207    0127    @YloopFh:
    208    0127  8B 4E FC mov cx,Wid     ;put width to counter
    209    012A  8B D9 mov bx,cx     ;copy it to bx for the 'hack'
    210    012C  4B dec bx
    211    012D  2B 5E EE sub bx,ClipL     ;if Clipped Left
    212
    213    0130 @XloopFH:
    214
    215    0130  8A 00     mov al,ds:[si+bx]
    216    0132  0A C0     or al,al
    217    0134  74 05 90 90     jz @skipFh
    218    0138  26: 88 05 mov es:[di],al
    219    013B     @skipFh:
    220    013B  47     inc di
    221    013C  4B     dec bx
    222    013D  49     dec cx
    223
    224    013E  75 F0 jnz @XloopFH
    225    0140  03 7E F8 add di,t20Mw
    226    0143  03 76 F6 add si,oldWid
    227    0146  4A dec dx
    228
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 5
SprFlip.ASM



    229    0147  75 DE     jnz @YloopFh
    230
    231
    232    0149  EB 83 Jmp @Exit
    233
    234
    235 ;;==========Vertical Flip clips perfectly!!!
    236
    237    014B @FlipV:
    238
    239    014B  B9 0140     mov cx,320
    240    014E  8B DA     mov bx,dx       ;bx=height
    241    0150  4B     dec bx
    242    0151  0F AF CB     Imul cx,bx       ;cx=Xy+di offset
    243    0154  03 F9     add di,cx       ;Correct offset now
    244     ;;;
    245     ;;;clipT
    246    0156  8B 4E F6     mov cx,OldWid       ;mov oldWid to counter if
    247    0159  8B 5E F2     mov bx,ClipT       ;cropped height at top
    248    015C  0F AF CB     imul cx,bx       ;mutiply by width to get correct offset
    249    015F  2B F1     sub si,cx       ;correct offset
    250
    251     ;;;
    252     ;;;ClipD
    253    0161  8B 46 F6     mov ax,OldWid       ;mov oldWid to counter if
    254    0164  8B 5E EC     mov bx,ClipD       ;cropped height at top
    255    0167  0F AF C3     imul ax,bx       ;mutiply by width to get correct offset
    256    016A  03 F0     add si,ax       ;correct offset
    257
    258
    259    016C     @YloopV:
    260
    261    016C  8B 4E FC mov cx,wid
    262
    263    016F     @XloopV:
    264
    265    016F  8A 04     mov al,ds:[si]
    266    0171  46     inc si
    267    0172  0A C0     or al,al
    268    0174  74 05 90 90     jz @skipFv
    269    0178  26: 88 05 mov es:[di],al
    270    017B     @skipFv:
    271
    272    017B  47     inc di
    273    017C  49     dec cx
    274    017D  75 F0     jnz @XloopV
    275
    276    017F  2B 7E FC sub di,wid ;subract width
    277    0182  81 EF 0140 sub di,320 ;sub TO DI 320
    278    0186  03 76 FE add si,SiOff
    279    0189  4A dec dx
    280    018A  75 E0     jnz @YloopV
    281
    282    018C  E9 FF3F Jmp @Exit
    283
    284 ;;==========Vertical & Horizontal  clips perfectly!!!
    285    018F @FlipVH:
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 6
SprFlip.ASM



    286
    287     ;Recalculate Si
    288     ;Si=Si+(Height)*Width
    289
    290    018F  8B 4E F6     mov cx,OldWid
    291
    292    0192  8B DA     mov bx,dx ;Height
    293    0194  0F AF CB     imul cx,bx ;Offset
    294    0197  03 F1     add si,cx
    295    0199  4E     dec si ;Si= Last pixel on sprite
    296
    297     ;;;
    298     ;;;clipT
    299    019A  8B 4E F6     mov cx,OldWid       ;mov oldWid to counter if
    300    019D  8B 5E F2     mov bx,ClipT       ;cropped height at top
    301    01A0  0F AF CB     imul cx,bx       ;mutiply by width to get correct offset
    302    01A3  2B F1     sub si,cx       ;correct offset
    303
    304     ;;;
    305     ;;;ClipD
    306    01A5  8B 46 F6     mov ax,OldWid       ;mov oldWid to counter if
    307    01A8  8B 5E EC     mov bx,ClipD       ;cropped height at top
    308    01AB  0F AF C3     imul ax,bx       ;mutiply by width to get correct offset
    309    01AE  03 F0     add si,ax       ;correct offset
    310
    311     ;;;
    312     ;;;ClipL
    313    01B0  2B 76 EE     sub si,ClipL       ;correct startoff
    314
    315    01B3     @YloopVH:
    316    01B3  8B 4E FC mov cx,Wid
    317    01B6  2B 76 EE sub si,ClipL       ;add corrector
    318    01B9     @XloopVH:
    319
    320    01B9  8A 04     mov al,ds:[si]
    321    01BB  4E     dec si
    322    01BC  0A C0     or al,al
    323    01BE  74 05 90 90     jz @skipVH
    324    01C2  26: 88 05 mov es:[di],al
    325    01C5     @skipVH:
    326
    327    01C5  47     inc di
    328    01C6  49     dec cx
    329    01C7  75 F0     jnz @XloopVH
    330
    331    01C9  03 7E F8 add di,t20Mw
    332    01CC  2B 76 F0 sub si,ClipR ;clipRight
    333    01CF  4A dec dx
    334
    335    01D0  75 E1     jnz @YloopVH
    336
    337    01D2  E9 FEF9 Jmp @Exit
    338
    339    01D5 EndP
    340
    341 END
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 7
Symbol Table




Symbol Name  Type Value

??DATE  Text "05/30/03"
??FILENAME  Text "SprFlip "
??TIME  Text "16:41:25"
??VERSION  Number 040A
@32BIT  Text 0
@CLIPDOWN  Near SPRFLIP_TEXT:010D
@CLIPLEFT  Near SPRFLIP_TEXT:00D6
@CLIPRIGHT  Near SPRFLIP_TEXT:00FB
@CLIPTOP  Near SPRFLIP_TEXT:00E9
@CODE  Text SPRFLIP_TEXT
@CODESIZE  Text 1
@CPU  Text 0F0FH
@CURSEG  Text SPRFLIP_TEXT
@DATA  Text DGROUP
@DATASIZE  Text 0
@EXIT  Near SPRFLIP_TEXT:00CE
@FILENAME  Text SPRFLIP
@FLIPH  Near SPRFLIP_TEXT:0124
@FLIPV  Near SPRFLIP_TEXT:014B
@FLIPVH  Near SPRFLIP_TEXT:018F
@HEIGHTLOOP  Near SPRFLIP_TEXT:00F2
@INTERFACE  Text 06H
@MODEL  Text 4
@POSTCLIPDOWN  Near SPRFLIP_TEXT:0081
@POSTCLIPLEFT  Near SPRFLIP_TEXT:0057
@POSTCLIPRIGHT  Near SPRFLIP_TEXT:0075
@POSTCLIPTOP  Near SPRFLIP_TEXT:0069
@SKIPCOLOR  Near SPRFLIP_TEXT:00C1
@SKIPFH  Near SPRFLIP_TEXT:013B
@SKIPFV  Near SPRFLIP_TEXT:017B
@SKIPVH  Near SPRFLIP_TEXT:01C5
@STACK  Text DGROUP
@WORDSIZE  Text 2
@XLOOP  Near SPRFLIP_TEXT:00B5
@XLOOPFH  Near SPRFLIP_TEXT:0130
@XLOOPV  Near SPRFLIP_TEXT:016F
@XLOOPVH  Near SPRFLIP_TEXT:01B9
@YLOOP  Near SPRFLIP_TEXT:00B3
@YLOOPFH  Near SPRFLIP_TEXT:0127
@YLOOPV  Near SPRFLIP_TEXT:016C
@YLOOPVH  Near SPRFLIP_TEXT:01B3
CLIPD  Number [DGROUP:BP-0014]
CLIPL  Number [DGROUP:BP-0012]
CLIPR  Number [DGROUP:BP-0010]
CLIPT  Number [DGROUP:BP-000E]
FLIPMODE  Number [DGROUP:BP+0006]
HEI  Number [DGROUP:BP-0006]
LAYER  Number [DGROUP:BP+0010]
OLDHEI  Number [DGROUP:BP-000C]
OLDWID  Number [DGROUP:BP-000A]
RELSPRITEFLIP  Far SPRFLIP_TEXT:0000
SIOFF  Number [DGROUP:BP-0002]
SPROFF  Number [DGROUP:BP+0008]
SPRSEG  Number [DGROUP:BP+000A]
Turbo Assembler Version 4.1    05/30/03 16:41:25    Page 8
Symbol Table



T20MW  Number [DGROUP:BP-0008]
WID  Number [DGROUP:BP-0004]
X  Number [DGROUP:BP+000E]
Y  Number [DGROUP:BP+000C]

Groups & Segments  Bit Size Align  Combine Class

DGROUP  Group
  _DATA  16  0000 Word  Public  DATA
SPRFLIP_TEXT  16  01D5 Word  Public  CODE

[/code]
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #1 on: May 31, 2003, 04:01:18 AM »

I think the easiest way would be to port it to something one of those "qbasic assemblers" can handle.

I dunno if they support local vars (probably not), but at least you wouldn't have to convert labels to memory addresses, and it would probably convert parameters to BP relative addresses for you.

Or I could try to write a parser for that. It looks like it wouldn't be too difficult. Pseudocode:
1. skip whitespace
2. skip number (if there isn't one go to step 8)
3. skip whitespace
4. skip hex number (if there isn't one go to step 8)
5. skip whitespace
6. read in whitespace-delimited hex values (also skipping colons as whitespace - there are a few) until something that isn't a hex value is encountered.
7. for each hex value, create a binary representation (a byte, word, or dword) and PUT to a file opened in binary mode
8. next line
9. back to step 1 unless at end of file

EDIT: Why didn't this occur to me in the first place! Just include that subroutine in an empty stand alone asm program, and compile it to a COM file with MASM or TASM. You could put some kind of markers at the beginning and end of the routine, and write a simple program to extract the subroutine from the COM file.

EDIT #2: But the qbasic program that uses it would have to modify the destination address of any near jump opcodes based on the address of the string/array the machine code is stored in... hopefully most if not all of the jumps are short (IP relative) - that would make things much easier. You'd also have to do this with the machine code generated by the listing-parser.... Hmm, I guess the qbasic assembler solution might still be the easiest.
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #2 on: June 02, 2003, 12:22:07 AM »

What do you mean with COM files???
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #3 on: June 02, 2003, 05:03:49 AM »

A COM file is basically just a dump of the machine code (as far as I know there's no header or anything extra), which is what you're after, right?
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #4 on: June 07, 2003, 03:32:52 AM »

How do I make a COM file out of this:

Code:

;SUB RelSpriteFlip(BYVAL Layer%,BYVAL X%,BYVAL Y%,BYVAL SprSeg%,BYVAL SPROff%,Byval Flipmode%)
;;;;;                                                                                        
;;;;;
;;
;0=NoFlip
;1=FlipH
;2=FlipV
;3=FlipVH
;Else=No Flip
;;
;;
.Model Medium,BASIC
.386
.Code

Align 2


PUBLIC RelSpriteFlip

RelSpriteFlip  PROC uses Ds Es Si di,\
            Layer:Word, X:Word, Y:Word, SprSeg:Word, SprOff:Word, FlipMode:Word

            Local SiOff:    Word
            Local Wid:      Word
            Local Hei:      Word
            Local t20Mw:    Word
            Local OldWid:   Word
            Local OldHei:   Word
            Local ClipT:    Word            ;Clipping offsets
            Local ClipR:    Word
            Local ClipL:    Word
            Local ClipD:    Word


    Mov ds,SprSeg
    Mov es,Layer
    Mov si,SprOff                  
    Mov bx,ds:[si]                      ;Width of spr
    Shr bx,3
    Mov Wid,bx
    Mov OldWid,bx
    Mov dx,ds:[si+2]                   ;Height
    Mov Hei,dx
    Mov OldHei,Dx
    Mov Sioff,0
    Mov t20mW,0
    mov clipT,0
    mov clipR,0
    mov clipD,0
    mov clipL,0
   
    Add si,4                            ;1st color


                                        ;Note!!!!  After the clips
                                        ;Ax=X       Clipped
                                        ;Cx=Y       Clipped
                                        ;Bx=Width   New
                                        ;Dx=Height  New

        Mov ax,X
        Cmp ax,319              
        Jg @exit
        Cmp ax,0                
        Jl @ClipLeft
@PostClipLeft:
        Mov cx,Y
        Cmp cx,199
        Jg @exit
        Cmp cx,0                
        Jl @ClipTop
@PostClipTop:

        Add bx,ax               ;Add X to WID and see if its over *BX is destroyed
        Cmp bx,319              ;If X+Width > 319,  crop it
        Jg  @ClipRight
        Sub bx,ax               ;Restore bx
@PostClipRight:

        Add dx,cx  
        Cmp dx,199  
        Jg  @ClipDown
        Sub dx,cx               ;Restore dx
@PostClipDown:

                                ;ax=X, cx=Y, bx=NewWidth, dx=NewHeight

        Mov Wid,bx              ;Save wid
       
        ;;;;;calc offset.....
       
        Xchg ch,cl
        Mov bx,320
       
        Mov di,cx      
        Sub bx,Wid              ;get 320-Width
       
        Shr di,2  
        Add di,cx               ;Y*64+Y*256=Y*320  :)
        Mov T20Mw,bx
       
        Add di,ax               ;Offset done!!!=Y*320+X
       
        ;;;;
        ;;;;
        ;;;;
        ;;;;
        ;;;;Check here for our flipmode

        cmp FlipMode,1
            Je @FlipH
        cmp FlipMode,2
            Je @FlipV
        cmp FlipMode,3
            Je @FlipVH

        Mov bx,Wid              ;restore bx

@Yloop:

        Mov cx,bx               ;Clipped width to counter

@Xloop:

        Mov al,ds:[si]          ;color
        Inc si                  ;Next color
        Or al,al                ;check for color 0

        JZ @Skipcolor
           Mov es:[di],al
        @Skipcolor:

        Inc di
        Dec cx                  ;Check width

        Jnz @Xloop

    Add di,T20MW                    ;Add to di 320-ClipWidth
    Add si,SiOff                    ;Si Offset clipped corrector
   
    dec dx                          ;Check Height

    Jnz @Yloop

@exit:
Ret


@ClipLeft:
        Neg ax          ;-ax=+ax
        Sub bx,ax       ;sub clipped width to read width
        Jle @Exit       ;Negative result = outa here
        Add si,ax       ;clip our sprite offset
                        ;bx is the new clipped width
        Mov Sioff,ax    ;save si offset corrector
        mov ClipL,ax    ;for clip of flipH
        Xor ax,ax       ;zero out coord
        Jmp @PostClipLeft


@ClipTop:
        Neg cx          
        Sub dx,cx      
        Jle @exit
        mov ClipT,cx    ;How much to clip down if flipped V

     @HeightLoop:
        Add si,Wid      ;add width to get to next scanline
        Dec cx
     Jnz @HeightLoop    ;Loop until we get to offset.cx=0
     Jmp @PostClipTop

@ClipRight:
       Sub Bx,320       ;Bx is now clipped right
       Add Sioff,bx     ;Add to si corrector
       mov ClipR,bx     ;for clip of flipH
       Mov bx,320       ;Correct bx to clipX2+1
       Sub bx,ax        ;Subract ax to bx to correct width(0 TO 319)
       Jmp @PostClipRight

@ClipDown:
       Add cx,dx        ;add height to Y
       Sub cx,200       ;Correct it
       Sub dx,cx        ;Crop out height
       mov cx,OldHei    ;put in OldHeight
       mov ClipD,cx     ;
       sub ClipD,dx     ;cropped down height
       Mov cx,Y         ;Restore Y
       Jmp @PostClipDown


;;==========Horizontal Flip clips perfectly!!!
@FlipH:
       add si,ClipR                 ;if clipped right then correct start offset
   @YloopFh:
       mov cx,Wid                   ;put width to counter
       mov bx,cx                    ;copy it to bx for the 'hack'
       dec bx
       sub bx,ClipL                 ;if Clipped Left
   
        @XloopFH:
   
            mov al,ds:[si+bx]
            or al,al
            jz @skipFh
               mov es:[di],al
            @skipFh:
            inc di
            dec bx
            dec cx

        jnz @XloopFH
        add di,t20Mw
        add si,oldWid
        dec dx

    jnz @YloopFh


Jmp @Exit


;;==========Vertical Flip clips perfectly!!!

@FlipV:

    mov cx,320                
    mov bx,dx                 ;bx=height
    dec bx
    Imul cx,bx                ;cx=Xy+di offset
    add di,cx                 ;Correct offset now
    ;;;
    ;;;clipT
    mov cx,OldWid             ;mov oldWid to counter if
    mov bx,ClipT              ;cropped height at top
    imul cx,bx                ;mutiply by width to get correct offset
    sub si,cx                 ;correct offset

    ;;;
    ;;;ClipD
    mov ax,OldWid             ;mov oldWid to counter if
    mov bx,ClipD              ;cropped height at top
    imul ax,bx                ;mutiply by width to get correct offset
    add si,ax                 ;correct offset

   
    @YloopV:
   
        mov cx,wid
   
    @XloopV:
   
            mov al,ds:[si]
            inc si        
            or al,al
            jz @skipFv
               mov es:[di],al
            @skipFv:
           
            inc di
            dec cx
    jnz @XloopV
   
        sub di,wid                      ;subract width
        sub di,320                      ;sub TO DI 320
        add si,SiOff
        dec dx    
    jnz @YloopV

Jmp @Exit

;;==========Vertical & Horizontal  clips perfectly!!!
@FlipVH:

    ;Recalculate Si
    ;Si=Si+(Height)*Width
   
    mov cx,OldWid
   
    mov bx,dx           ;Height
    imul cx,bx          ;Offset
    add si,cx
    dec si              ;Si= Last pixel on sprite

    ;;;
    ;;;clipT
    mov cx,OldWid             ;mov oldWid to counter if
    mov bx,ClipT              ;cropped height at top
    imul cx,bx                ;mutiply by width to get correct offset
    sub si,cx                 ;correct offset

    ;;;
    ;;;ClipD
    mov ax,OldWid             ;mov oldWid to counter if
    mov bx,ClipD              ;cropped height at top
    imul ax,bx                ;mutiply by width to get correct offset
    add si,ax                 ;correct offset

    ;;;
    ;;;ClipL
    sub si,ClipL              ;correct startoff
       
    @YloopVH:
        mov cx,Wid
        sub si,ClipL          ;add corrector
    @XloopVH:
   
            mov al,ds:[si]
            dec si
            or al,al
            jz @skipVH
               mov es:[di],al
            @skipVH:
           
            inc di
            dec cx
    jnz @XloopVH    
   
        add di,t20Mw
        sub si,ClipR            ;clipRight
        dec dx
   
    jnz @YloopVH    

Jmp @Exit

EndP

END

Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #5 on: June 07, 2003, 04:45:39 AM »

Here...

Code:
C80014001E0656578E5E0A8E46108B76088B1CC1EB03895EFC895EF68B54028956FA8956F4C746FE
0000C746F80000C746F20000C746F00000C746EC0000C746EE000083C6048B460E3D013F0F8F007E
3D00000F8C007F8B4E0C81F900C77F6E909083F9000F8C008003D881FB013F0F8F00882BD803D181
FA00C70F8F008E2BD1895EFC86E9BB01408BF92B5EFCC1EF0203F9895EF803F8837E06010F840084
837E06020F8400A3837E06030F8400DF8B5EFC8BCB8A04460AC074059090268805474975F0037EF8
0376FE4A75E55F5E071FC9CA000CF7D82BD87EF203F08946FE8946EE33C0E9FF6EF7D92BD17EDF89
4EF20376FC4975FAE9FF6E81EB0140015EFE895EF0BB01402BD8E9FF6803CA81E900C82BD18B4EF4
894EEC2956EC8B4E0CE9FF5D0376F08B4EFC8BD94B2B5EEE8A000AC074059090268805474B4975F0
037EF80376F64A75DEEB83B901408BDA4B0FAFCB03F98B4EF68B5EF20FAFCB2BF18B46F68B5EEC0F
AFC303F08B4EFC8A04460AC074059090268805474975F02B7EFC81EF01400376FE4A75E0E9FF3F8B
4EF68BDA0FAFCB03F14E8B4EF68B5EF20FAFCB2BF18B46F68B5EEC0FAFC303F02B76EE8B4EFC2B76
EE8A044E0AC074059090268805474975F0037EF82B76F04A75E1E9FEF9


Generated from this little program I made...should work for all TASM listings:

Code:
DEFINT A-Z

OPEN "FILENAME.LST" FOR INPUT AS #1

DO WHILE NOT EOF(1)
  LINE INPUT #1, Text$
  Text$ = UCASE$(Text$)

  ' Convert tabs to spaces
  TabAt = INSTR(Text$, CHR$(9))
  DO WHILE TabAt
    LeftPart$ = LEFT$(Text$, TabAt - 1)
    RightPart$ = RIGHT$(Text$, LEN(Text$) - TabAt)
    Text$ = LeftPart$ + SPACE$(8 - (LEN(LeftPart$) AND 7)) + RightPart$
    TabAt = INSTR(Text$, CHR$(9))
  LOOP

  ' Just to make things easier...
  a1$ = MID$(Text$, 13, 1)
  a2$ = MID$(Text$, 14, 1)
  a3$ = MID$(Text$, 15, 1)
  a4$ = MID$(Text$, 16, 1)

  ' Make sure there's opcodes on this line
  IF (a1$ >= "0" AND a1$ <= "9") OR (a1$ >= "A" AND a1$ <= "F") THEN
    IF (a2$ >= "0" AND a2$ <= "9") OR (a2$ >= "A" AND a2$ <= "F") THEN
      IF (a3$ >= "0" AND a3$ <= "9") OR (a3$ >= "A" AND a3$ <= "F") THEN
        IF (a4$ >= "0" AND a4$ <= "9") OR (a4$ >= "A" AND a4$ <= "F") THEN
          IF MID$(Text$, 17, 2) = "  " THEN  'Yep, there is
            Char$ = ""
            FOR i = 19 TO LEN(Text$)
              LastChar$ = Char$
              Char$ = MID$(Text$, i, 1)
              IF Char$ = " " THEN
                IF LastChar$ = " " THEN EXIT FOR  ' No more opcodes here
              ELSE
                IF (Char$ >= "0" AND Char$ <= "9") OR (Char$ >= "A" AND Char$ <= "F") THEN
                  Opcode$ = Opcode$ + Char$       ' Save that one
                END IF
              END IF
            NEXT
          END IF
        END IF
      END IF
    END IF
  END IF

LOOP

CLS
PRINT Opcode$
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #6 on: June 09, 2003, 01:33:44 AM »

Thank you very much my good man!!!!
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #7 on: June 11, 2003, 12:08:54 AM »

ooops.. Doesn't work. ;*(

And its prolly not your parser nor my code since I tried making a QLB and it worked 100%.

I also tried to hand pick the opcodes and it crashed my system. ;*(
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!