]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi-kernel.s
Working
[cc65] / libsrc / tgi / tgi-kernel.s
1 ;
2 ; Ullrich von Bassewitz, 21.06.2002
3 ;
4 ; Common functions of the tgi graphics kernel.
5 ;
6
7         .include        "tgi-kernel.inc"
8
9         .export         _tgi_setup
10         .importzp       ptr1
11
12
13 ;----------------------------------------------------------------------------
14 ; Variables
15
16 .bss
17
18 _tgi_drv:       .res    2               ; Pointer to driver
19 _tgi_error:     .res    1               ; Last error code
20 _tgi_mode:      .res    1               ; Graphics mode or zero
21 _tgi_xres:      .res    2               ; X resolution of the current mode
22 _tgi_yres:      .res    2               ; Y resolution of the current mode
23         
24
25 .data
26
27 ; Jump table for the driver functions.
28
29 tgi_install:    jmp     $0000
30 tgi_deinstall:  jmp     $0000
31 tgi_init:       jmp     $0000
32 tgi_done:       jmp     $0000
33 tgi_control:    jmp     $0000
34 tgi_clear:      jmp     $0000
35 tgi_setcolor:   jmp     $0000
36 tgi_setpixel:   jmp     $0000
37 tgi_getpixel:   jmp     $0000
38 tgi_line:       jmp     $0000
39 tgi_bar:        jmp     $0000
40 tgi_circle:     jmp     $0000
41
42
43 ;----------------------------------------------------------------------------
44 ; void __fastcall__ tgi_setup (void);
45 ; /* Setup the driver and graphics kernel once the driver is loaded */
46
47
48 copy:   lda     (ptr1),y
49         sta     tgi_install,x
50         iny
51         inx
52         rts
53
54
55 _tgi_setup:
56         jsr     tgi_set_ptr             ; load _tgi_drv into ptr1
57
58 ; Copy the jump vectors
59
60         ldy     #TGI_HDR_JUMPTAB
61         ldx     #0
62 @L1:    inx                             ; Skip JMP opcode
63         jsr     copy                    ; Copy one byte
64         jsr     copy                    ; Copy one byte
65         cpx     #(TGI_HDR_JUMPCOUNT*3)
66         bne     @L1
67
68 ; Copy the screen dimensions
69
70         ldy     #TGI_HDR_XRES
71         lda     (ptr1),y
72         sta     _tgi_xres
73         iny
74         lda     (ptr1),y
75         sta     _tgi_xres+1
76         ldy     #TGI_HDR_YRES
77         lda     (ptr1),y
78         sta     _tgi_yres
79         iny
80         lda     (ptr1),y
81         sta     _tgi_yres+1
82
83 ; Initialize variables
84
85         lda     #$00
86         sta     _tgi_error
87         sta     _tgi_mode
88
89         jsr     tgi_install             ; Call driver install routine
90
91 ;       jmp     tgi_fetch_error
92
93 ;----------------------------------------------------------------------------
94 ; Fetch the error code from the driver and place it into the global error
95 ; variable. The function will also return the error in A and the flags from
96 ; loading the error code are set.
97
98 tgi_fetch_error:
99         jsr     tgi_set_ptr
100         ldy     #TGI_HDR_ERROR
101         lda     (ptr1),y
102         sta     _tgi_error
103         rts
104
105 ;----------------------------------------------------------------------------
106 ; Load the pointer to the tgi driver into ptr1.
107
108 tgi_set_ptr:
109         lda     _tgi_drv
110         sta     ptr1
111         lda     _tgi_drv+1
112         sta     ptr1+1
113         rts
114