]> git.sur5r.net Git - cc65/blob - libsrc/apple2enh/textframe.s
Moved additional zeropage variables into an extra module.
[cc65] / libsrc / apple2enh / textframe.s
1 ;
2 ; Oliver Schmidt, 10.03.2004
3 ;
4 ; void _textframexy (unsigned char x, unsigned char y,
5 ;                    unsigned char width, unsigned char height,
6 ;                    unsigned char style);
7 ; void _textframe (unsigned char width, unsigned char height);
8 ;                  unsigned char style);
9 ;
10
11         .export         __textframexy, __textframe
12         .import         popa, pusha, _gotoxy
13         .import         chlinedirect, cvlinedirect
14         .importzp       tmp2, tmp3, tmp4, ptr1
15
16         .include        "../apple2/apple2.inc"
17
18 WIDTH = tmp2
19 HEIGHT = tmp3
20 XORIGIN = tmp4
21 YORIGIN = ptr1
22
23 __textframexy:
24         sec
25         bra     textframe
26
27 __textframe:
28         clc
29 textframe:
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     L1              ; Relative to left edge?
51         adc     WIDTH
52 L1:     adc     XORIGIN
53         jsr     pusha
54         lda     YOFFS,x
55         clc
56         bpl     L2              ; Relative to top?
57         adc     HEIGHT
58 L2:     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, '_'