]> git.sur5r.net Git - cc65/blob - libsrc/joystick/joy_unload.s
Adjusted doc to code.
[cc65] / libsrc / joystick / joy_unload.s
1 ;
2 ; Ullrich von Bassewitz, 2002-11-29
3 ;
4 ; unsigned char joy_unload (void);
5 ; /* Unload the currently loaded driver. */
6
7
8         .include        "joy-kernel.inc"
9         .include        "joy-error.inc"
10         .include        "modload.inc"
11
12         .import         joy_clear_ptr
13         .import         return0
14
15
16
17 _joy_unload:
18         lda     _joy_drv
19         pha                             ; Save pointer to driver
20         ora     _joy_drv+1
21         beq     no_driver               ; No driver
22         lda     _joy_drv+1
23         pha
24
25         jsr     _joy_uninstall          ; Uninstall the driver
26
27         pla
28         tax
29         pla                             ; Get pointer to driver
30         jsr     _mod_free               ; Free the driver
31         jmp     return0                 ; Return JOY_ERR_OK
32
33 no_driver:
34         tax                             ; X = 0
35         pla                             ; Remove pushed junk
36         lda     #JOY_ERR_NO_DRIVER
37         rts