]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_init.s
Fixed problem with tgi_init and tgi_setpalette
[cc65] / libsrc / tgi / tgi_init.s
1 ;
2 ; Ullrich von Bassewitz, 21.06.2002
3 ;
4 ; void __fastcall__ tgi_init (void);
5 ; /* Initialize the already loaded graphics driver */
6
7
8         .include        "tgi-kernel.inc"
9         .include        "tgi-error.inc"
10
11         .importzp       ptr1
12
13 .proc   _tgi_init
14
15         jsr     _tgi_done               ; Switch off graphics if needed
16         jsr     tgi_init                ; Go into graphics mode
17         jsr     tgi_geterror            ; Get the error code
18         sta     _tgi_error              ; Save for later reference
19         cmp     #TGI_ERR_OK
20         bne     @L9                     ; Jump on error
21
22         inc     _tgi_gmode              ; Remember that graph mode is active
23
24 ; Do driver initialization. First set the default palette.
25
26         jsr     tgi_getdefpalette       ; Get the default palette into A/X
27         sta     ptr1
28         stx     ptr1+1                  ; Save it
29         jsr     tgi_geterror            ; Check for errors in getdefpalette
30         cmp     #TGI_ERR_OK
31         beq     @L1                     ; Jump if there is no default palette
32         jsr     tgi_setpalette          ; Set the default palette. Since we're
33                                         ; setting the default palette, we don't
34                                         ; expect errors here.
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:    rts
60
61 .endproc
62
63