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