Guidance
指路人
g.yi.org
software / rapidq / Examples / Graphics & Animation / DXF / DxfONE! / dxfone.asm

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
;DxfONE.ASM (c) arch. Giovanni Seregni - 29.12.2002

;RQ CALL:
;CadColor = CallBinProc (rgbASM.Pointer,VarPtr(AsmPal(0)), Vista.Pixel(tt%,t%))
; instead of the RQ PseudoCode:         ^+8                ^+12
;FOR i% = 239 (Palette lenght) to 44 step - 1 (colors 0 to 44 are processed in RQcode)
; Difference% = ABS(RCol%-Palet(i%).Red) + ABS(GCol%-Palet(i%).Grn) + ABS(BCol%-Palet(i%).Ble)
; IF Difference% < OldDifference% THEN CadColor% = Palet(i%).NumPal : OldDifference% = Difference% : END IF
;NEXT

;ARRAY pointers:
;  0 TO  239  Palet(0).NumPal             0 (pointer CAD STANDARD PALETTE #COLOR)
;240 TO  479  Palet(0).R         * 4 =  960 (pointer CAD STANDARD PALETTE RED value)
;480 TO  719  Palet(0).G         * 4 = 1920 (pointer CAD STANDARD PALETTE GREEN value)
;720 TO  959  Palet(0).B         * 4 = 2880 (pointer CAD STANDARD PALETTE BLUE value)
;                                      3840 (pointer to general purpose memory)

bits 32
segment .text
start:
enter 32, 0
push esi
push ebx
push edx
push ecx

mov esi, [ebp+8]       ; get AsmPal address
mov ebx, 239           ; get last color
imul ebx, 4            ; exact ARRAY pointer
add ebx, 960           ; -> go to RED

mov edx, 769           ; max difference
push edx               ; saved

ini:

  mov eax, [ebp+12]    ; load BMP true color
  and eax, 255         ; cut RED only, low value
  push esi             ; save esi

  add esi, ebx         ; Red pointer
  sub eax, [esi]

  cdq                  ; \
  xor eax, edx         ;  this = abs(eax)!
  sub eax, edx         ; /

  push eax             ; 1st difference result (RED) stored in stack

  mov eax, [ebp+12]    ; re-load BMP true colors
  and eax, 65280       ; cut GREEN only, medium value
  shr eax, 8
  add esi, 960         ; Green pointer
  sub eax, [esi]

  cdq                  ; \
  xor eax, edx         ;  this = abs(eax)!
  sub eax, edx         ; /

  pop ecx
  add eax, ecx         ; add GREEN difference
  push eax

  mov eax, [ebp+12]    ; re-load BMP true colors
  shr eax, 16          ; cut BLUE only, hight value
  add esi, 960         ; Blue pointer
  sub eax, [esi]

  cdq                  ; \
  xor eax, edx         ;  this = abs(eax)!
  sub eax, edx         ; /

  pop ecx
  add eax, ecx         ; in eax (BLUE difference) add the saved (RED & GREEN) difference

  pop esi              ; restore esi
  pop edx              ; restore in edx max difference

  cmp eax, edx         ; compare new & old difference
  jl maxdiff           ; the new difference is good? (minus than..)

  push edx
  jmp crossover

maxdiff:               ; save new difference!
  push eax
  mov [esi + 3840], ebx   ; save good difference pointer!

crossover:
  sub ebx, 4           ; in ebx color segmented address
  cmp ebx, 176 + 960   ; if the loop is not in first asm color
  jne ini              ; repeat

pop edx

mov eax, [esi + 3840]  ; return result

sub eax, 960           ; scaled NumPal
shr eax, 2             ; idiv 4 (integer RQ ARRAY pointer)

pop ecx
pop edx
pop ebx 
pop esi
leave
ret 16
 
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-27  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-21 16:37:53