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