]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_getset.s
Fixed problems that were introduced with r4287.
[cc65] / libsrc / tgi / tgi_getset.s
1 ;
2 ; Ullrich von Bassewitz, 22.06.2002
3 ;
4 ; Helper function for getpixel/setpixel. Load X/Y from stack and check if
5 ; the coordinates are valid. Return carry clear if so.
6 ;
7
8         .include        "tgi-kernel.inc"
9
10         .import         popax
11         .importzp       ptr1, ptr2
12
13
14 .proc   tgi_getset
15
16         jsr     tgi_popxy       ; Pop X/Y into ptr1/ptr2
17
18 ; Are the coordinates out of range? First check if any coord is negative.
19
20         txa
21         ora     ptr2+1
22         bmi     @L9             ; Bail out if negative
23
24 ; Check if X is larger than the maximum x coord. If so, bail out
25
26         lda     ptr1
27         cmp     _tgi_xres
28         txa
29         sbc     _tgi_xres+1
30         bcs     @L9
31
32 ; Check if Y is larger than the maximum y coord.
33
34         lda     ptr2
35         cmp     _tgi_yres
36         lda     ptr2+1
37         sbc     _tgi_yres+1
38 @L9:    rts
39
40 .endproc
41