]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_init.s
GETDEFPALETTE will no longer return an error
[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_setpalette          ; Set the default palette.
30         jsr     tgi_geterror            ; Clear a possible error code
31
32 ; Set the drawing color to the maximum color
33
34 @L1:    ldx     _tgi_colorcount
35         dex
36         txa
37         jsr     _tgi_setcolor           ; tgi_setcolor (tgi_getmaxcolor ());
38
39 ; Set the text style
40
41         lda     #TGI_TEXT_HORIZONTAL
42         sta     _tgi_textdir
43         ldx     #1
44         stx     _tgi_textmagx
45         ldy     #1
46         sty     _tgi_textmagy
47         jsr     tgi_textstyle           ; Tell the driver about the text style
48
49 ; Clear the screen
50
51         jmp     tgi_clear
52
53 ; Error exit
54
55 @L9:    rts
56
57 .endproc
58
59