1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-24 09:29:06 +00:00

conio with fixed width and proportional font support

git-svn-id: svn://svn.cc65.org/cc65/trunk@1178 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst 2002-03-08 16:47:34 +00:00
parent d537134626
commit ae74057353
10 changed files with 96 additions and 92 deletions

View File

@ -7,8 +7,9 @@
@$(AS) -o $@ $(AFLAGS) $< @$(AS) -o $@ $(AFLAGS) $<
S_OBJS = cchvline.o cgetc.o clrscr.o color.o cputc.o cputs.o cursor.o gotoxy.o kbhit.o\ S_OBJS = cclear.o chline.o cvline.o cgetc.o clrscr.o color.o\
revers.o screensize.o where.o cputc.o cpputs.o cputs.o cursor.o gotoxy.o kbhit.o revers.o\
screensize.o where.o _scrsize.o
all: $(S_OBJS) all: $(S_OBJS)

View File

@ -3,32 +3,28 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; ;
; 27.10.2001 ; 27.10.2001
; 06.03.2002
; unsigned char cgetc (void); ; unsigned char cgetc (void);
.export _cgetc .export _cgetc
.import update_cursor
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
.include "cursor.inc" .include "../inc/cursor.inc"
_cgetc: _cgetc:
; show cursor if needed ; show cursor if needed
lda cursor_flag lda cursor_flag
beq L0 beq L0
lda #1 jsr update_cursor
sta r3L
lda cursor_x lda cursor_x
ldx cursor_x+1 ldx cursor_x+1
sta r4L
sta stringX sta stringX
stx r4H
stx stringX+1 stx stringX+1
lda cursor_y lda cursor_y
sec
sbc curHeight
sta r5L
sta stringY sta stringY
jsr PosSprite jsr PosSprite
jsr PromptOn jsr PromptOn

View File

@ -3,19 +3,21 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; ;
; 27.10.2001 ; 27.10.2001
; 06.03.2002
; void cputcxy (unsigned char x, unsigned char y, char c); ; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c); ; void cputc (char c);
.export _cputcxy, _cputc, update_cursor .export _cputcxy, _cputc, update_cursor
.import _gotoxy .import _gotoxy, fixcursor
.import popa .import popa
.import xsize,ysize
.include "../inc/const.inc" .include "../inc/const.inc"
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "cursor.inc" .include "../inc/cursor.inc"
_cputcxy: _cputcxy:
pha ; Save C pha ; Save C
@ -30,10 +32,15 @@ _cputc:
; some characters are not safe for PutChar ; some characters are not safe for PutChar
cmp #$20 cmp #$20
bcs L1 bcs L1
cmp #CR
beq echo_crlf
cmp #LF
beq do_lf
cmp #$1d cmp #$1d
bne L00 bne L00
ldx #BACKSPACE ldx #BACKSPACE
bne L1 sec
bcs L2
L00: cmp #ESC_GRAPHICS L00: cmp #ESC_GRAPHICS
beq L0 beq L0
cmp #ESC_RULER cmp #ESC_RULER
@ -50,7 +57,9 @@ L00: cmp #ESC_GRAPHICS
bne L1 bne L1
L0: rts L0: rts
L1: lda cursor_x L1: clc
L2: php
lda cursor_x
sta r11L sta r11L
lda cursor_x+1 lda cursor_x+1
sta r11H sta r11H
@ -58,16 +67,29 @@ L1: lda cursor_x
sta r1H sta r1H
txa txa
jsr PutChar jsr PutChar
plp
bcs update_cursor
inc cursor_c
lda cursor_c
cmp xsize
bne update_cursor
echo_crlf:
lda #0
sta cursor_c
do_lf: inc cursor_r
lda cursor_r
cmp ysize
bne update_cursor
dec cursor_r
update_cursor: update_cursor:
lda r11L jsr fixcursor
sta cursor_x lda cursor_x
sta r4L sta r4L
lda r11H lda cursor_x+1
sta cursor_x+1
sta r4H sta r4H
lda r1H lda cursor_y
sta cursor_y
sec sec
sbc curHeight sbc curHeight
sta r5L sta r5L

View File

@ -1,41 +1,36 @@
; ;
; Maciej 'YTM/Elysium' Witkowiak ; Ullrich von Bassewitz, 06.08.1998
; ;
; 27.10.2001
; void cputsxy (unsigned char x, unsigned char y, char* s); ; void cputsxy (unsigned char x, unsigned char y, char* s);
; void cputs (char* s); ; void cputs (char* s);
;
.export _cputsxy, _cputs .export _cputsxy, _cputs
.import popa, _gotoxy, _cputc
.import update_cursor, _gotoxy .importzp ptr1, tmp1
.import popa
.include "../inc/const.inc"
.include "../inc/geossym.inc"
.include "../inc/jumptab.inc"
.include "cursor.inc"
_cputsxy: _cputsxy:
sta r0L ; Save s for later sta ptr1 ; Save s for later
stx r0H stx ptr1+1
jsr popa ; Get Y jsr popa ; Get Y
jsr _gotoxy ; Set cursor, pop x jsr _gotoxy ; Set cursor, pop x
jmp L0 ; Same as cputs... jmp L0 ; Same as cputs...
_cputs: sta r0L ; Save s _cputs: sta ptr1 ; Save s
stx r0H stx ptr1+1
L0: ldy #0 L0: ldy #0
lda (r0),y L1: lda (ptr1),y
bne L1 ; Jump if there's something beq L9 ; Jump if done
rts iny
sty tmp1 ; Save offset
jsr _cputc ; Output char, advance cursor
ldy tmp1 ; Get offset
bne L1 ; Next char
inc ptr1+1 ; Bump high byte
bne L1
; Done
L9: rts
L1: lda cursor_x
sta r11L
lda cursor_x+1
sta r11H
lda cursor_y
sta r1H
jsr PutString
jmp update_cursor

View File

@ -7,29 +7,22 @@
; unsigned char cursor (unsigned char onoff); ; unsigned char cursor (unsigned char onoff);
.export _cursor .export _cursor
.import update_cursor
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
.include "cursor.inc" .include "../inc/cursor.inc"
_cursor: _cursor:
tay ; onoff into Y tay ; onoff into Y
ldx #0 ; High byte of result ldx #0 ; High byte of result
ldx cursor_flag ; Get old value lda cursor_flag ; Get old value
pha
sty cursor_flag ; Set new value sty cursor_flag ; Set new value
tya tya
beq L1 beq L1
lda curHeight ; prepare cursor lda curHeight ; prepare cursor
jsr InitTextPrompt jsr InitTextPrompt
lda cursor_x ; position it on screen jsr update_cursor ; place it on screen
sta r4L L1: pla
lda cursor_x+1 rts
sta r4H
lda cursor_y
sec
sbc curHeight
sta r5L
lda #1
sta r3L
jsr PosSprite
L1: rts

View File

@ -3,29 +3,38 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; ;
; 27.10.2001 ; 27.10.2001
; 06.03.2002
; void gotox (unsigned char x); ; void gotox (unsigned char x);
; void gotoy (unsigned char y); ; void gotoy (unsigned char y);
; void gotoxy (unsigned char x, unsigned char y); ; void gotoxy (unsigned char x, unsigned char y);
.export _gotox, _gotoy, _gotoxy .export _gotox, _gotoy, _gotoxy, fixcursor
.import popa .import popa
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "cursor.inc" .include "../inc/cursor.inc"
_gotox: sta cursor_x _gotox: sta cursor_c
jmp fixcursor jmp fixcursor
_gotoy: sta cursor_y _gotoy: sta cursor_r
inc cursor_r
jmp fixcursor jmp fixcursor
_gotoxy: sta cursor_y _gotoxy: sta cursor_r
inc cursor_r
jsr popa jsr popa
sta cursor_x sta cursor_c
; convert 8x8 x/y coordinates to GEOS hires ; convert 8x8 x/y coordinates to GEOS hires
fixcursor: fixcursor:
lda cursor_c
sta cursor_x
lda #0
sta cursor_x+1
lda cursor_r
sta cursor_y
ldx #cursor_x ldx #cursor_x
ldy #3 ldy #3
jsr DShiftLeft jsr DShiftLeft

View File

@ -7,7 +7,7 @@
; unsigned char revers (unsigned char onoff); ; unsigned char revers (unsigned char onoff);
.export _revers .export _revers
.import tmp1 .importzp tmp1
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
.include "../inc/const.inc" .include "../inc/const.inc"

View File

@ -3,6 +3,7 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; ;
; 27.10.2001 ; 27.10.2001
; 06.03.2002
; void screensize (unsigned char* x, unsigned char* y); ; void screensize (unsigned char* x, unsigned char* y);
; ;
@ -11,6 +12,7 @@
.import popax .import popax
.importzp ptr1, ptr2 .importzp ptr1, ptr2
.import xsize, ysize
.include "../inc/geossym.inc" .include "../inc/geossym.inc"
@ -23,13 +25,8 @@ _screensize:
sta ptr2 sta ptr2
stx ptr2+1 stx ptr2+1
ldy #0 lda xsize
lda graphMode
bpl L1
lda #80 ; 80 columns (more or less)
.byte $2c
L1: lda #40 ; 40 columns (more or less)
sta (ptr2),y sta (ptr2),y
lda #24 ; something like that for Y size lda ysize
sta (ptr1),y sta (ptr1),y
rts rts

View File

@ -3,6 +3,7 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; ;
; 27.10.2001 ; 27.10.2001
; 06.03.2002
; unsigned char wherex (void); ; unsigned char wherex (void);
; unsigned char wherey (void); ; unsigned char wherey (void);
@ -11,20 +12,10 @@
.importzp tmp1, tmp2 .importzp tmp1, tmp2
.include "../inc/jumptab.inc" .include "../inc/jumptab.inc"
.include "cursor.inc" .include "../inc/cursor.inc"
_wherex: lda cursor_x _wherex: lda cursor_c
sta tmp1
lda cursor_x+1
sta tmp2
ldx #tmp1
ldy #3
jsr DShiftRight
lda tmp1
rts rts
_wherey: lda cursor_y _wherey: lda cursor_r
lsr
lsr
lsr
rts rts

View File

@ -8,7 +8,7 @@
@$(AS) -o $@ $(AFLAGS) $< @$(AS) -o $@ $(AFLAGS) $<
S_OBJS = callroutine.o enterdesktop.o firstinit.o getrandom.o getserialnumber.o\ S_OBJS = ctype.o callroutine.o enterdesktop.o firstinit.o getrandom.o getserialnumber.o\
initdoneio.o mainloop.o panic.o tobasic.o setdevice.o get_ostype.o initdoneio.o mainloop.o panic.o tobasic.o setdevice.o get_ostype.o
all: $(S_OBJS) all: $(S_OBJS)