JPEGView/Source/68020/UpdateRegion.a
Aaron Giles 92bdb55672 JPEGView 3.3 for Macintosh
These are the sources for the final official release of JPEGView for the
Mac, back in 1994.
2015-02-05 00:18:10 -08:00

1 line
2.1 KiB
Plaintext

;*********************************************************/
;* This source code copyright (c) 1991-2001, Aaron Giles */
;* See the Read Me file for licensing information. */
;* Contact email: mac@aarongiles.com */
;*********************************************************/
;
; On entry here we expect the following values:
;
; a0 = pointer to the current region definition
; a1 = pointer to rgnBuffer[2]
; d0 = boxRect.left
;
; The following registers will be modified:
;
; d0,d1
; a0,a1
;
movem.l a2/d2,-(sp) ;save a2/d2 on the stack
move.l a1,a2 ;copy a1 to a2
subq.l #4,a2 ;point a2 to rgnBuffer[0]
move.w d0,d2 ;copy boxRect.left to d2
move.w -2(a0),d1 ;get last Y coordinate
;
; The region definition has changed: set up to add/delete elements as necessary
;
@URgnLoop:
move.w (a0)+,d0 ;get next X coordinate
cmpi.w #32767,d0 ;end of list? (32767 == $7fff)
bne.s @ScanRgn ;if not, skip ahead
move.w (a0)+,d0 ;get next Y
sub.w d1,d0 ;minus the old Y
move.w d0,(a2) ;store it in the rgnBuffer
movem.l (sp)+,a2/d2 ;restore a2/d2 from the stack
bra.s @TheEnd ;return
@ScanRgn:
sub.w d2,d0 ;offset X by left side
@SRgnLoop:
cmp.w (a1)+,d0 ;compare to our buffer
beq.s @DeleteRgn ;if equal, they cancel
bgt.s @SRgnLoop ;if greater, keep looking
;
; Insert an element into our region buffer
;
move.l a1,-(sp) ;save a1
subq.l #2,a1 ;decrement a1 back one word
swap d0 ;swap d0 high
@IRgnLoop:
move.w (a1),d0 ;get next word
swap d0 ;swap it high
move.w d0,(a1)+ ;store the old word
cmpi.w #32767,d0 ;done? (32767 == $7fff)
bne.s @IRgnLoop ;if not, loop
move.l (sp)+,a1 ;restore a1
bra.s @URgnLoop ;loop for some more
;
; Delete an element from our region buffer
;
@DeleteRgn:
move.l a1,-(sp) ;save a1
@DRgnLoop:
move.w (a1)+,d0 ;get this value
move.w d0,-4(a1) ;store it back one
cmpi.w #32767,d0 ;done? (32767 == $7fff)
bne.s @DRgnLoop ;if not, loop
move.l (sp)+,a1 ;restore a1
subq.l #2,a1 ;point back one word
bra.s @URgnLoop ;loop for some more
@TheEnd: