1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00
cc65/libsrc/atari7800/mono_cputc.s

103 lines
2.3 KiB
ArmAsm
Raw Normal View History

2022-04-18 08:59:06 +00:00
;
; Mark Keates, Christian Groessler, Piotr Fusik, Karri Kaksonen
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _mono_cputc
2022-04-18 10:49:29 +00:00
.import mono_gotox, mono_gotoy, pusha0
2022-04-18 09:05:36 +00:00
.import pushax
.import _mono_screen
2022-04-18 08:59:06 +00:00
.include "atari7800.inc"
.include "extzp.inc"
2022-04-18 09:05:36 +00:00
.code
2022-04-18 08:59:06 +00:00
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
2022-04-18 09:05:36 +00:00
lda #0
2022-04-18 08:59:06 +00:00
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
2022-04-18 09:05:36 +00:00
clc
2022-04-18 08:59:06 +00:00
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;-----------------------------------------------------------------------------
; Put a character on screen
;
; The code will handle newlines that wrap to start of screen
;
.proc _mono_cputc
2022-04-18 09:05:36 +00:00
cmp #$0A ; LF
2022-04-18 08:59:06 +00:00
bne @L4
2022-04-18 09:05:36 +00:00
@L1: lda #0 ; newline
2022-04-18 10:49:29 +00:00
jsr mono_gotox
2022-04-18 09:05:36 +00:00
lda CURS_Y
cmp #(screenrows-1)
2022-04-18 08:59:06 +00:00
bne @L2
2022-04-18 09:05:36 +00:00
lda #0
beq @L3
@L2: clc
adc #1
2022-04-18 10:49:29 +00:00
@L3: jmp mono_gotoy
2022-04-18 08:59:06 +00:00
@L4:
2022-04-18 09:05:36 +00:00
pha
2022-04-18 08:59:06 +00:00
2022-04-18 09:05:36 +00:00
lda #0
sta ptr7800+1
sta ptrtmp+1
lda CURS_Y ; Find position on screen buffer
sta ptr7800
lda #mono_charsperline
sta ptrtmp
jsr umula0
clc
adc CURS_X
bcc @L11
inx
@L11: clc
adc #<(_mono_screen)
sta ptr7800
bcc @L12
inx
@L12: txa
clc
adc #>(_mono_screen)
sta ptr7800+1
2022-04-18 08:59:06 +00:00
2022-04-18 09:05:36 +00:00
pla ; Print character on screen
ldy #0
sta (ptr7800),y
2022-04-18 08:59:06 +00:00
2022-04-18 09:05:36 +00:00
lda CURS_X ; Increment cursor
cmp #(mono_charsperline-1)
beq @L1
clc
adc #1
2022-04-18 10:49:29 +00:00
jmp mono_gotox
2022-04-18 08:59:06 +00:00
.endproc