--- /dev/null
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void chline (unsigned char length);
+;
+
+ .export _chlinexy, _chline, chlinedirect
+ .import popa, _gotoxy, cputdirect
+ .importzp tmp1
+
+ .include "../apple2/apple2.inc"
+
+_chlinexy:
+ pha ; Save the length
+ jsr popa ; Get y
+ jsr _gotoxy ; Call this one, will pop params
+ pla ; Restore the length and run into _chline
+
+_chline:
+ ldx #'S' ; MouseText character
+ ldy INVFLG
+ cpy #$FF ; Normal character display mode?
+ beq chlinedirect
+ ldx #'-' | $80 ; Horizontal line, screen code
+
+chlinedirect:
+ cmp #$00 ; Is the length zero?
+ beq L9 ; Jump if done
+ sta tmp1
+L1: txa ; Screen code
+ jsr cputdirect ; Direct output
+ dec tmp1
+ bne L1
+L9: rts
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 06.08.1998
+;
+; void cputcxy (unsigned char x, unsigned char y, char c);
+; void cputc (char c);
+;
+
+ .constructor initconio
+ .export _cputcxy, _cputc
+ .export _gotoxy, cputdirect
+ .export newline, putchar
+
+ .import popa
+
+ .include "../apple2/apple2.inc"
+
+
+initconio:
+ lda #$FF ; Normal character display mode
+ sta INVFLG
+ sta SETALTCHAR ; Switch in alternate charset
+ rts
+
+; Plot a character - also used as internal function
+
+_cputcxy:
+ pha ; Save C
+ jsr popa ; Get Y
+ jsr _gotoxy
+ pla ; Restore C
+
+_cputc:
+ cmp #$0D ; Test for \r = carrage return
+ bne L1
+ stz CH ; Goto left edge of screen
+ rts ; That's all we do
+L1:
+ cmp #$0A ; Test for \n = line feed
+ beq newline
+ ora #$80 ; Turn on high bit
+
+cputdirect:
+ jsr putchar
+ inc CH ; Bump to next column
+ lda CH
+ cmp WNDWDTH
+ bne return
+ stz CH
+return:
+ rts
+
+putchar:
+ ldy INVFLG
+ cpy #$FF ; Normal character display mode?
+ beq put
+ cmp #$E0 ; Lowercase?
+ bmi mask
+ and #$7F ; Inverse lowercase
+ bra put
+mask:
+ and INVFLG ; Apply normal, inverse, flash
+put:
+ ldy CH
+ bit RD80VID ; In 80 column mode?
+ bpl col40 ; No, in 40 cols
+ pha
+ tya
+ lsr ; Div by 2
+ tay
+ pla
+ bcs col40 ; Odd cols go in 40 col memory
+ bit HISCR
+ sta (BASL),Y
+ bit LOWSCR
+ rts
+col40:
+ sta (BASL),Y
+ rts
+
+newline:
+ lda CH
+ pha
+ inc CV
+ lda CV
+ cmp WNDBTM
+ bne L2
+ lda #$00
+ sta CV
+L2:
+ jsr VTABZ
+ pla
+ sta CH
+ rts
+
+_gotoxy:
+ sta CV ; Store Y
+ jsr VTABZ
+ jsr popa ; Get X
+ sta CH ; Store X
+ rts
--- /dev/null
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void cvline (unsigned char length);
+;
+
+ .export _cvlinexy, _cvline, cvlinedirect
+ .import popa, _gotoxy, putchar, newline
+ .importzp tmp1
+
+_cvlinexy:
+ pha ; Save the length
+ jsr popa ; Get y
+ jsr _gotoxy ; Call this one, will pop params
+ pla ; Restore the length and run into _cvline
+
+_cvline:
+ ldx #'|' | $80 ; Vertical line, screen code
+
+cvlinedirect:
+ cmp #$00 ; Is the length zero?
+ beq L9 ; Jump if done
+ sta tmp1
+L1: txa ; Screen code
+ jsr putchar ; Write, no cursor advance
+ jsr newline ; Advance cursor to next line
+ dec tmp1
+ bne L1
+L9: rts
--- /dev/null
+;
+; Oliver Schmidt, 10.03.2004
+;
+; void _textframexy (unsigned char x, unsigned char y,
+; unsigned char width, unsigned char height,
+; unsigned char style);
+; void _textframe (unsigned char width, unsigned char height);
+; unsigned char style);
+;
+
+ .export __textframexy, __textframe
+ .import popa, pusha, _gotoxy
+ .import chlinedirect, cvlinedirect
+ .importzp tmp2, tmp3, tmp4, ptr1
+
+ .include "../apple2/apple2.inc"
+
+WIDTH = tmp2
+HEIGHT = tmp3
+XORIGIN = tmp4
+YORIGIN = ptr1
+
+__textframexy:
+ sec
+ bra textframe
+
+__textframe:
+ clc
+textframe:
+ ldx INVFLG
+ phx ; Save character display mode
+ ldx #$FF
+ stx INVFLG ; Set normal character display mode
+ pha ; Save index
+ jsr popa ; Get height
+ sta HEIGHT
+ jsr popa ; Get width
+ sta WIDTH
+ lda CH
+ ldx CV
+ bcc noxy
+ jsr popa ; Get y
+ tax
+ jsr popa ; Get x
+noxy: sta XORIGIN
+ stx YORIGIN
+ plx ; Restore index
+loop: lda XOFFS,x
+ clc
+ bpl L1 ; Relative to left edge?
+ adc WIDTH
+L1: adc XORIGIN
+ jsr pusha
+ lda YOFFS,x
+ clc
+ bpl L2 ; Relative to top?
+ adc HEIGHT
+L2: adc YORIGIN
+ jsr _gotoxy ; Call this one, will pop params
+ txa
+ tay
+ lsr ; Get bit 0 (vline) into carry
+ lda LENGTH,x
+ phx ; Save index
+ ldx CHAR,y
+ bcc hline
+ clc
+ adc HEIGHT
+ jsr cvlinedirect
+ bra next
+hline: adc WIDTH
+ jsr chlinedirect
+next: plx ; Restore index
+ inx
+ txa
+ and #$03 ; Mask style
+ bne loop
+ pla
+ sta INVFLG ; Restore character display mode
+ rts
+
+ .rodata
+
+; 2 styles with 4 lines each make up 8 entries per table
+; - even entry numbers mean horizontal lines
+; - odd entry numbers mean vertical lines
+
+; x offset for the line starting point
+; - a positive value means relative to the frame left edge
+; - a negative value menas relative to the frame right edge
+XOFFS: .byte 0, 0, 0, -2, 1, 0, 1, -2
+
+; y offset for the line starting point
+; - a positive value means relative to the frame top
+; - a negative value menas relative to the frame bottom
+YOFFS: .byte 0, 1, -2, 1, 0, 0, -2, 0
+
+; length of the line relative to the frame size
+; - a negative value for hlines means shorter than the width
+; - a negative value for vlines menas shorter than the height
+LENGTH: .byte 0, -2, 0, -2, -2, 0, -2, 0
+
+; character to use for drawing the line
+; - hibit set means normal printable character
+; - hibit clear means MouseText character
+CHAR: .byte '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_'