]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_init.s
Added strftime
[cc65] / libsrc / tgi / tgi_init.s
1 ;
2 ; Ullrich von Bassewitz, 21.06.2002
3 ;
4 ; void __fastcall__ tgi_init (unsigned char mode);
5 ; /* Initialize the given graphics mode. */
6
7
8         .include        "tgi-kernel.inc"
9         .include        "tgi-error.inc"
10
11         .importzp       ptr1
12         .import         _tgi_done
13         .import         _tgi_setcolor
14         .export         _tgi_init
15
16 _tgi_init:
17         pha                             ; Save mode
18         jsr     _tgi_done               ; Switch off graphics if needed
19         pla
20         sta     _tgi_mode               ; Remember the mode
21         jsr     tgi_init                ; Go into graphics mode
22         jsr     tgi_geterror            ; Get the error code
23         sta     _tgi_error              ; Save for later reference
24         cmp     #TGI_ERR_OK
25         bne     @L9                     ; Jump on error
26
27 ; Do driver initialization. First set the default palette.
28
29         jsr     tgi_getdefpalette       ; Get the default palette into A/X
30         sta     ptr1
31         stx     ptr1+1
32         ora     ptr1+1                  ; Do we have a default palette?
33         beq     @L1                     ; Jump if no
34         jsr     tgi_setpalette          ; Set the default palette
35
36 ; Set the drawing color to the maximum color
37
38 @L1:    ldx     _tgi_colorcount
39         dex
40         txa
41         jsr     _tgi_setcolor           ; tgi_setcolor (tgi_getmaxcolor ());
42
43 ; Set the text style
44
45         lda     #TGI_TEXT_HORIZONTAL
46         sta     _tgi_textdir
47         ldx     #1
48         stx     _tgi_textmagx
49         ldy     #1
50         sty     _tgi_textmagy
51         jsr     tgi_textstyle           ; Tell the driver about the text style
52
53 ; Clear the screen
54
55         jmp     tgi_clear
56
57 ; Error exit
58
59 @L9:    lda     #$00
60         sta     _tgi_mode               ; Clear the mode if init was not successful
61         rts
62