]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_getset.s
Working on the TGI library
[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         sta     ptr2            ; Y
16         stx     ptr2+1
17         jsr     popax
18         sta     ptr1            ; X
19         stx     ptr1+1
20
21 ; Are the coordinates are out of range? First check if any ccord is negative.
22
23         txa
24         ora     ptr2+1
25         asl     a
26         bcs     @L9             ; Bail out if negative
27
28 ; Check if X is larger than the maximum x coord. If so, bail out
29
30         lda     ptr1
31         cmp     _tgi_xres
32         txa
33         sbc     _tgi_xres+1
34         bcs     @L9
35
36 ; Check if Y is larger than the maximum y coord.
37
38         lda     ptr2
39         cmp     _tgi_yres
40         lda     ptr2+1
41         sbc     _tgi_yres+1
42 @L9:    rts
43
44