# # BETATRON high level library for platform and action arcade games. # Copyright (C) 1997 Liouros Thanasis, liouros@hotmail.com # # CLIPRLE.CPS: This file is part of the BETATRON library and can be used # and/or distributed only under the terms of the GNU Library # General Public License. See doc/readme.1st for details. # .globl _cliprle .globl _dummycliprle .extern _pl_videolen .extern _pl_videoselector # extern "C" void cliprle(char *rle,long toofs, ush bufx, ush bufy # ush sx, ush sy, ush l, ush h ); # periorismoi sx+l <= rlelen, sy+h <= rlehei // procedure for cliping rle sprites in modex 320x200 // RLE sprites are not supported in this mode // so this proc simply rets _dummycliprle: ret #define rle1 8(%ebp) #define buf1 12(%ebp) #define x1 16(%ebp) #define y1 20(%ebp) #define sx1 24(%ebp) #define sy1 28(%ebp) #define l1 32(%ebp) #define h1 36(%ebp) _cliprle: pushl %ebp movl %esp,%ebp pusha pushw %es movw _pl_videoselector, %ax movw %ax, %es movl buf1,%edi shll $2, %edi # se tetrades to ofs movl _pl_videolen,%eax movzwl y1, %edx mull %edx movzwl x1,%ebx addl %ebx,%eax addl %eax,%edi # proorismos entaksei movl rle1,%esi addl $8,%esi #parekapse mikos ,ipsos, mikos eggrafis xorl %ebx,%ebx xorl %eax,%eax xorl %ecx,%ecx xorl %edx,%edx movw sy1,%cx # etoimasou na kaneis skip tis 1es sy1 grammes skiploop1: testw %cx,%cx jz endskiploop1 movw (%esi),%ax # ax: arithmos bytes tis grammis addl %eax,%esi # pigaine stin epomeni grammi decw %cx jmp skiploop1 endskiploop1: verloop1: cmpw $0,h1 # ftasame sti teleutaia grammi jnz noendverloop1 jmp endverloop1 noendverloop1: pushl %edi # sose metriti buffer pushl %esi # sose metriti grammis addl $4,%esi # kane skip bytes grammis & arithmo paketon movw sx1,%dx # bytes pou tha kanoume skip skiphorloop1: movb (%esi),%al # pare tipo paketou incl %esi # epomeno byte movb %al,%cl andb $0x07f,%cl # count ston cl shrb $7,%al # al: tipos paketou testb %al,%al # einai 0 jnz _skip1 # an oxi einai skip paketo _copy1: subw %cx,%dx # ftasame sto proto byte gia antigrafi jl copy1here # nai ftasame addl %ecx,%esi # kane skip ola ta bytes gia antigrafi jmp skiphorloop1 copy1here: # esi += (ecx-edx) addl %ecx,%esi # kane skip count bytes negw %dx # posa emeinan gia antigrafi subl %edx,%esi # pigaine piso edx bytes movb %dl,%cl # ston ecx posa tha antigrapseis movw l1,%dx # posa emeinan gia antigrafi jmp mainhorloop1 # arxise tin antigrafi _skip1: subw %cx,%dx jl skip1here jmp skiphorloop1 skip1here: negw %dx # posa emeinan na kaneis skip movb %dl,%cl # ston ecx posa tha kaneis skip movw l1,%dx # posa emeinan gia antigrafi jmp mainhorloop1 endskiphorloop1: actualmainloop: movb (%esi),%al # pare tipo paketou incl %esi # epomeno byte movb %al,%cl andb $0x07f,%cl # count ston cl shrb $7,%al # al: tipos paketou mainhorloop1: testb %al,%al jnz _mainskip1 _maincopy1: subw %cx,%dx # posa menoun gia antigrafi akoma < 0 jg maincopymore # an einai thetiko exoume akoma gia antigrafi addw %cx,%dx # arnitiko ftasame sto terma movw %dx,%cx rep movsb # steile kai ta teleutaia bytes stin othoni jmp skipline1 # pigaine stin epomeni grammi maincopymore: rep movsb # steilta ston buffer jmp actualmainloop _mainskip1: subw %cx,%dx jng skipline1 #ftasame sto telos , epomeni grammi addl %ecx,%edi #pida tosa bytes stin othoni jmp actualmainloop endmainhorloop1: skipline1: popl %esi movzwl (%esi),%eax # eax arithmos bytes grammis addl %eax,%esi # esi apomeni grammi popl %edi movw _pl_videolen,%ax addl %eax,%edi # edi epomeni grammi ston buffer decw h1 jmp verloop1 endverloop1: popw %es popa popl %ebp ret