]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_getset.s
New module fileio-test.c
[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 tgi_getset:
15         jsr     tgi_popxy       ; Pop X/Y into ptr1/ptr2
16
17 ; Are the coordinates out of range? First check if any coord is negative.
18
19         txa
20         ora     ptr2+1
21         bmi     @L9             ; Bail out if negative
22
23 ; Check if X is larger than the maximum x coord. If so, bail out
24
25         lda     ptr1
26         cmp     _tgi_xres
27         txa
28         sbc     _tgi_xres+1
29         bcs     @L9
30
31 ; Check if Y is larger than the maximum y coord.
32
33         lda     ptr2
34         cmp     _tgi_yres
35         lda     ptr2+1
36         sbc     _tgi_yres+1
37 @L9:    rts
38
39