mirror of
https://github.com/cc65/cc65.git
synced 2024-06-01 13:41:34 +00:00
Shortenned the VIC-20's cputc() by 17 bytes.
Changed to a modified table look-up method to convert PetSCII to screen-codes.
This commit is contained in:
parent
4905329ff6
commit
e72e44d14f
|
@ -1,5 +1,6 @@
|
||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
; 1998-08-06, Ullrich von Bassewitz
|
||||||
|
; 2020-10-09, Greg King
|
||||||
;
|
;
|
||||||
; 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);
|
||||||
|
@ -39,69 +40,64 @@ _cputcxy:
|
||||||
jsr gotoxy ; Set cursor, drop x and y
|
jsr gotoxy ; Set cursor, drop x and y
|
||||||
pla ; Restore C
|
pla ; Restore C
|
||||||
|
|
||||||
; Plot a character - also used as internal function
|
; Plot a character -- also used as an internal function
|
||||||
|
|
||||||
_cputc: cmp #$0A ; CR?
|
_cputc: cmp #$0D ; Is it CBM '\n'?
|
||||||
bne L1
|
|
||||||
lda #0
|
|
||||||
sta CURS_X
|
|
||||||
beq plot ; Recalculate pointers
|
|
||||||
|
|
||||||
L1: cmp #$0D ; LF?
|
|
||||||
beq newline ; Recalculate pointers
|
beq newline ; Recalculate pointers
|
||||||
|
cmp #$0A ; Is it CBM '\r'?
|
||||||
|
beq cr
|
||||||
|
|
||||||
; Printable char of some sort
|
; Printable char. of some sort
|
||||||
|
; Convert it from PetSCII into a screen-code
|
||||||
|
|
||||||
cmp #' '
|
cmp #$FF ; BASIC token?
|
||||||
bcc cputdirect ; Other control char
|
bne convert
|
||||||
|
lda #$DE ; Pi symbol
|
||||||
|
convert:
|
||||||
tay
|
tay
|
||||||
bmi L10
|
lsr a ; Divide by 256/8
|
||||||
cmp #$60
|
lsr a
|
||||||
bcc L2
|
lsr a
|
||||||
and #$DF
|
lsr a
|
||||||
bne cputdirect ; Branch always
|
lsr a
|
||||||
L2: and #$3F
|
tax ; .X = %00000xxx
|
||||||
|
tya
|
||||||
|
eor pet_to_screen,x
|
||||||
|
|
||||||
cputdirect:
|
cputdirect:
|
||||||
jsr putchar ; Write the character to the screen
|
jsr putchar ; Write the character to the screen
|
||||||
|
|
||||||
; Advance cursor position
|
; Advance the cursor position
|
||||||
|
|
||||||
advance:
|
advance:
|
||||||
iny
|
iny
|
||||||
cpy #XSIZE
|
cpy #XSIZE
|
||||||
bne L3
|
bne L3
|
||||||
jsr newline ; new line
|
jsr newline ; Wrap around
|
||||||
ldy #0 ; + cr
|
|
||||||
|
cr: ldy #$00 ; Do carriage-return
|
||||||
L3: sty CURS_X
|
L3: sty CURS_X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
; Move down by one full screen-line. Note: this routine doesn't scroll.
|
||||||
|
;
|
||||||
|
; (Both screen RAM and color RAM are aligned to page boundaries.
|
||||||
|
; Therefore, the lower bytes of their addresses have the same values.
|
||||||
|
; Shorten the code by taking advantage of that fact.)
|
||||||
|
|
||||||
newline:
|
newline:
|
||||||
clc
|
clc
|
||||||
lda #XSIZE
|
lda #XSIZE
|
||||||
adc SCREEN_PTR
|
adc SCREEN_PTR
|
||||||
sta SCREEN_PTR
|
sta SCREEN_PTR
|
||||||
bcc L4
|
|
||||||
inc SCREEN_PTR+1
|
|
||||||
clc
|
|
||||||
L4: lda #XSIZE
|
|
||||||
adc CRAM_PTR
|
|
||||||
sta CRAM_PTR
|
sta CRAM_PTR
|
||||||
bcc L5
|
bcc L5
|
||||||
|
inc SCREEN_PTR+1
|
||||||
inc CRAM_PTR+1
|
inc CRAM_PTR+1
|
||||||
L5: inc CURS_Y
|
L5: inc CURS_Y
|
||||||
rts
|
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
|
; Set cursor position, calculate RAM pointers
|
||||||
|
|
||||||
|
@ -111,14 +107,19 @@ plot: ldy CURS_X
|
||||||
jmp PLOT ; Set the new cursor
|
jmp PLOT ; Set the new cursor
|
||||||
|
|
||||||
|
|
||||||
|
; Write one character to the screen without doing anything else,
|
||||||
; Write one character to the screen without doing anything else, return X
|
; return the X position in .Y
|
||||||
; position in Y
|
|
||||||
|
|
||||||
putchar:
|
putchar:
|
||||||
ora RVS ; Set revers bit
|
ora RVS ; Set revers bit
|
||||||
ldy CURS_X
|
ldy CURS_X
|
||||||
sta (SCREEN_PTR),y ; Set char
|
sta (SCREEN_PTR),y ; Set char.
|
||||||
lda CHARCOLOR
|
lda CHARCOLOR
|
||||||
sta (CRAM_PTR),y ; Set color
|
sta (CRAM_PTR),y ; Set color
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
.rodata
|
||||||
|
pet_to_screen:
|
||||||
|
.byte %10000000,%00000000,%01000000,%00100000 ; PetSCII -> screen-code
|
||||||
|
.byte %01000000,%11000000,%10000000,%10000000
|
||||||
|
|
Loading…
Reference in New Issue
Block a user