]> git.sur5r.net Git - cc65/blob - libsrc/apple2/textframe.s
55ac235b896b169518630f74b2d478ecff91dfab
[cc65] / libsrc / apple2 / textframe.s
1 ;
2 ; Oliver Schmidt, 10.03.2004
3 ;
4 ; void __fastcall__ textframexy (unsigned char x, unsigned char y,
5 ;                                unsigned char width, unsigned char height,
6 ;                                unsigned char style);
7 ; void __fastcall__ textframe (unsigned char width, unsigned char height,
8 ;                              unsigned char style);
9 ;
10         .ifdef  __APPLE2ENH__
11
12         .export         _textframexy, _textframe
13         .import         popa, pusha, _gotoxy
14         .import         chlinedirect, cvlinedirect
15
16         .include        "zeropage.inc"
17         .include        "apple2.inc"
18
19 WIDTH   = ptr1
20 HEIGHT  = ptr1+1
21 XORIGIN = ptr2
22 YORIGIN = ptr2+1
23
24 _textframexy:
25         sec
26         bra     :+
27
28 _textframe:
29         clc
30 :       ldx     INVFLG
31         phx                     ; Save character display mode
32         ldx     #$FF
33         stx     INVFLG          ; Set normal character display mode
34         pha                     ; Save index
35         jsr     popa            ; Get height
36         sta     HEIGHT
37         jsr     popa            ; Get width
38         sta     WIDTH
39         lda     CH
40         ldx     CV
41         bcc     noxy
42         jsr     popa            ; Get y
43         tax
44         jsr     popa            ; Get x
45 noxy:   sta     XORIGIN
46         stx     YORIGIN
47         plx                     ; Restore index
48 loop:   lda     XOFFS,x
49         clc
50         bpl     :+              ; Relative to left edge?
51         adc     WIDTH
52 :       adc     XORIGIN
53         jsr     pusha
54         lda     YOFFS,x
55         clc
56         bpl     :+              ; Relative to top?
57         adc     HEIGHT
58 :       adc     YORIGIN
59         jsr     _gotoxy         ; Call this one, will pop params
60         txa
61         tay
62         lsr                     ; Get bit 0 (vline) into carry
63         lda     LENGTH,x
64         phx                     ; Save index
65         ldx     CHAR,y
66         bcc     hline
67         clc
68         adc     HEIGHT
69         jsr     cvlinedirect
70         bra     next
71 hline:  adc     WIDTH
72         jsr     chlinedirect
73 next:   plx                     ; Restore index
74         inx
75         txa
76         and     #$03            ; Mask style
77         bne     loop
78         pla
79         sta     INVFLG          ; Restore character display mode
80         rts
81
82         .rodata
83
84 ; 2 styles with 4 lines each make up 8 entries per table
85 ; - even entry numbers mean horizontal lines
86 ; - odd entry numbers mean vertical lines
87
88 ; x offset for the line starting point
89 ; - a positive value means relative to the frame left edge
90 ; - a negative value menas relative to the frame right edge
91 XOFFS:  .byte   0, 0, 0, <-2, 1, 0, 1, <-2
92
93 ; y offset for the line starting point
94 ; - a positive value means relative to the frame top
95 ; - a negative value menas relative to the frame bottom
96 YOFFS:  .byte   0, 1, <-2, 1, 0, 0, <-2, 0
97
98 ; length of the line relative to the frame size
99 ; - a negative value for hlines means shorter than the width
100 ; - a negative value for vlines menas shorter than the height
101 LENGTH: .byte   0, <-2, 0, <-2, <-2, 0, <-2, 0
102
103 ; character to use for drawing the line
104 ; - hibit set means normal printable character
105 ; - hibit clear means MouseText character
106 CHAR:   .byte   '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_'
107
108         .endif                  ; __APPLE2ENH__