a bunch of simple conio fixes, makes a few more samples work

This commit is contained in:
mrdudz
2025-06-25 00:23:58 +02:00
parent fa6d72cae5
commit 23336420b1
21 changed files with 484 additions and 2 deletions

View File

@@ -233,3 +233,7 @@ CASSMOT = $20 ; Cassette motor on
TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
; temporary, to get conio working
XSIZE = 80
YSIZE = 50

View File

@@ -233,3 +233,7 @@ CASSMOT = $20 ; Cassette motor on
TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
; temporary, to get conio working
XSIZE = 80
YSIZE = 50

12
libsrc/c65/_scrsize.s Normal file
View File

@@ -0,0 +1,12 @@
;
; Ullrich von Bassewitz, 26.10.2000
;
; Screen size variables
;
.export screensize
.import SCREEN
screensize = SCREEN

17
libsrc/c65/bordercolor.s Normal file
View File

@@ -0,0 +1,17 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _bordercolor
.include "c65.inc"
_bordercolor:
ldx VIC_BORDERCOLOR ; get old value
sta VIC_BORDERCOLOR ; set new value
txa
rts

15
libsrc/c65/clrscr.s Normal file
View File

@@ -0,0 +1,15 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; void clrscr (void);
;
.export _clrscr
.include "cbm_kernal.inc"
;_clrscr = CLRSCR
_clrscr:
lda #$93
jmp CHROUT

24
libsrc/c65/color.s Normal file
View File

@@ -0,0 +1,24 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ textcolor (unsigned char color);
; unsigned char __fastcall__ bgcolor (unsigned char color);
;
.export _textcolor, _bgcolor
.include "c65.inc"
_textcolor:
ldx CHARCOLOR ; get old value
sta CHARCOLOR ; set new value
txa
rts
_bgcolor:
ldx VIC_BG_COLOR0 ; get old value
sta VIC_BG_COLOR0 ; set new value
txa
rts

10
libsrc/c65/conio.s Normal file
View File

@@ -0,0 +1,10 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; Low level stuff for screen output/console input
;
.exportzp CURS_X, CURS_Y
.include "c65.inc"

118
libsrc/c65/cputc.s Normal file
View File

@@ -0,0 +1,118 @@
;
; Ullrich von Bassewitz, 1998-08-06, 2009-09-26
;
; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
; void __fastcall__ cputc (char c);
;
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import gotoxy
.import PLOT
.include "c65.inc"
_cputcxy:
pha ; Save C
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function
_cputc: cmp #$0A ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
L1: cmp #$0D ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
cmp #' '
bcc cputdirect ; Other control char
tay
bmi L10
cmp #$60
bcc L2
and #$DF
bne cputdirect ; Branch always
L2: and #$3F
cputdirect:
jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
iny
cpy #XSIZE
bne L3
jsr newline ; new line
ldy #0 ; + cr
L3: sty CURS_X
rts
newline:
clc
lda #XSIZE
adc SCREEN_PTR
sta SCREEN_PTR
bcc L4
inc SCREEN_PTR+1
clc
L4: lda #XSIZE
adc CRAM_PTR
sta CRAM_PTR
bcc L5
inc CRAM_PTR+1
L5: inc CURS_Y
rts
; Handle character if high bit set
L10: and #$7F
cmp #$7F ; PI?
bne L11
lda #$5E ; Load screen code for PI
L11: ora #$40
bne cputdirect
; Set cursor position, calculate RAM pointers.
plot: ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
ora RVS ; Set revers bit
ldy CURS_X
pha
lda SCREEN_PTR + 1
clc
adc #>$0800
sta SCREEN_PTR + 1
pla
sta (SCREEN_PTR),y ; Set char
lda SCREEN_PTR + 1
sec
sbc #>$0800
sta SCREEN_PTR + 1
lda CHARCOLOR
; lda #$88
; sta (CRAM_PTR),y ; Set color
rts

7
libsrc/c65/devnum.s Normal file
View File

@@ -0,0 +1,7 @@
;
; Oliver Schmidt, 2010-02-14
;
.include "c65.inc"
.exportzp devnum := DEVNUM

24
libsrc/c65/kbhit.s Normal file
View File

@@ -0,0 +1,24 @@
; FIXME: is $d610 mega65 specific?
; FIXME: this should rather use the kernal (with keyboard buffer etc)
.export _cgetc
_cgetc:
: lda $d610
beq :-
ldx #0
stx $d610
rts
.export _kbhit
_kbhit:
lda $d610
beq :+
lda #1
:
ldx #0
rts

5
libsrc/c65/status.s Normal file
View File

@@ -0,0 +1,5 @@
;
; Oliver Schmidt, 2012-09-30
;
.exportzp ST := $90 ; IEC status byte

12
libsrc/mega65/_scrsize.s Normal file
View File

@@ -0,0 +1,12 @@
;
; Ullrich von Bassewitz, 26.10.2000
;
; Screen size variables
;
.export screensize
.import SCREEN
screensize = SCREEN

View File

@@ -0,0 +1,17 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _bordercolor
.include "mega65.inc"
_bordercolor:
ldx VIC_BORDERCOLOR ; get old value
sta VIC_BORDERCOLOR ; set new value
txa
rts

15
libsrc/mega65/clrscr.s Normal file
View File

@@ -0,0 +1,15 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; void clrscr (void);
;
.export _clrscr
.include "cbm_kernal.inc"
;_clrscr = CLRSCR
_clrscr:
lda #$93
jmp CHROUT

24
libsrc/mega65/color.s Normal file
View File

@@ -0,0 +1,24 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ textcolor (unsigned char color);
; unsigned char __fastcall__ bgcolor (unsigned char color);
;
.export _textcolor, _bgcolor
.include "mega65.inc"
_textcolor:
ldx CHARCOLOR ; get old value
sta CHARCOLOR ; set new value
txa
rts
_bgcolor:
ldx VIC_BG_COLOR0 ; get old value
sta VIC_BG_COLOR0 ; set new value
txa
rts

10
libsrc/mega65/conio.s Normal file
View File

@@ -0,0 +1,10 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; Low level stuff for screen output/console input
;
.exportzp CURS_X, CURS_Y
.include "mega65.inc"

118
libsrc/mega65/cputc.s Normal file
View File

@@ -0,0 +1,118 @@
;
; Ullrich von Bassewitz, 1998-08-06, 2009-09-26
;
; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
; void __fastcall__ cputc (char c);
;
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import gotoxy
.import PLOT
.include "mega65.inc"
_cputcxy:
pha ; Save C
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function
_cputc: cmp #$0A ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
L1: cmp #$0D ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
cmp #' '
bcc cputdirect ; Other control char
tay
bmi L10
cmp #$60
bcc L2
and #$DF
bne cputdirect ; Branch always
L2: and #$3F
cputdirect:
jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
iny
cpy #XSIZE
bne L3
jsr newline ; new line
ldy #0 ; + cr
L3: sty CURS_X
rts
newline:
clc
lda #XSIZE
adc SCREEN_PTR
sta SCREEN_PTR
bcc L4
inc SCREEN_PTR+1
clc
L4: lda #XSIZE
adc CRAM_PTR
sta CRAM_PTR
bcc L5
inc CRAM_PTR+1
L5: inc CURS_Y
rts
; Handle character if high bit set
L10: and #$7F
cmp #$7F ; PI?
bne L11
lda #$5E ; Load screen code for PI
L11: ora #$40
bne cputdirect
; Set cursor position, calculate RAM pointers.
plot: ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
ora RVS ; Set revers bit
ldy CURS_X
pha
lda SCREEN_PTR + 1
clc
adc #>$0800
sta SCREEN_PTR + 1
pla
sta (SCREEN_PTR),y ; Set char
lda SCREEN_PTR + 1
sec
sbc #>$0800
sta SCREEN_PTR + 1
lda CHARCOLOR
; lda #$88
; sta (CRAM_PTR),y ; Set color
rts

7
libsrc/mega65/devnum.s Normal file
View File

@@ -0,0 +1,7 @@
;
; Oliver Schmidt, 2010-02-14
;
.include "mega65.inc"
.exportzp devnum := DEVNUM

24
libsrc/mega65/kbhit.s Normal file
View File

@@ -0,0 +1,24 @@
; FIXME: is $d610 mega65 specific?
; FIXME: this should rather use the kernal (with keyboard buffer etc)
.export _cgetc
_cgetc:
: lda $d610
beq :-
ldx #0
stx $d610
rts
.export _kbhit
_kbhit:
lda $d610
beq :+
lda #1
:
ldx #0
rts

5
libsrc/mega65/status.s Normal file
View File

@@ -0,0 +1,5 @@
;
; Oliver Schmidt, 2012-09-30
;
.exportzp ST := $90 ; IEC status byte

View File

@@ -241,7 +241,12 @@ EXELIST_c64 = \
tgidemo
EXELIST_c65 = \
checkversion
ascii \
checkversion \
enumdevdir \
hello \
sieve \
tinyshell
EXELIST_c128 = \
ascii \
@@ -316,7 +321,12 @@ EXELIST_lynx = \
notavailable
EXELIST_mega65 = \
checkversion
ascii \
checkversion \
enumdevdir \
hello \
sieve \
tinyshell
EXELIST_nes = \
hello