]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_map_mode.s
Added strftime
[cc65] / libsrc / tgi / tgi_map_mode.s
1 ;
2 ; Ullrich von Bassewitz, 31.05.2002
3 ;
4 ; const char* __fastcall__ tgi_map_mode (unsigned char mode);
5 ; /* Map tgi mode codes to driver names */
6 ;
7
8         .export         _tgi_map_mode
9         .import         _tgi_mode_table
10         .import         return0
11         .importzp       tmp1
12
13 ;----------------------------------------------------------------------------
14 ; BEWARE: The current implementation of tgi_map_mode does not work with tables
15 ; larger that 255 bytes!
16
17 .code
18
19 _tgi_map_mode:
20         sta     tmp1                    ; Save mode
21         ldy     #$00
22
23 @L0:    lda     _tgi_mode_table,y
24         beq     NotFound                ; Branch if mode code zero
25         cmp     tmp1
26         beq     Found
27
28 ; Skip the name
29
30 @L1:    iny
31         lda     _tgi_mode_table,y
32         bne     @L1                     ; Loop until end marker found
33         iny                             ; Skip end marker
34         bne     @L0                     ; Branch always
35
36 ; Mode not found
37
38 NotFound:
39         jmp     return0
40
41 ; Mode found
42
43 Found:  tya
44         ldx     #>_tgi_mode_table
45         sec                             ; Account for the mode byte
46         adc     #<_tgi_mode_table       ; Return pointer to file name
47         rts
48