save X and Y in CHROUT
This commit is contained in:
1 parent
aab7b98c27
commit
bf4e22b99a
1 file changed
+32
-2
+32
-2
@@ -1,9 +1,29 @@
|
||||
; Function defined on pp272-273 of C64 Programmers Reference Guide
|
||||
chrout:
|
||||
;; Crude implementation of character output
|
||||
|
||||
;; Save X and Y values
|
||||
;; (Confirmed by writing a test program that X and Y
|
||||
;; don't get modified, in agreement with C64 PRG's
|
||||
;; description of CHROUT)
|
||||
sta last_printed_character_ascii
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
lda last_printed_character_ascii
|
||||
|
||||
;; Write character on the screen
|
||||
ldy current_screen_x
|
||||
|
||||
;; Convert PETSCII to screen code
|
||||
cmp #$40
|
||||
bcc chrout_l1
|
||||
cmp #$59
|
||||
bcs chrout_l1
|
||||
and #$1f
|
||||
|
||||
chrout_l1:
|
||||
sta (current_screen_line_ptr),y
|
||||
|
||||
;; Advance the column, and scroll screen down if we need
|
||||
@@ -13,9 +33,19 @@ chrout:
|
||||
iny
|
||||
sty current_screen_x
|
||||
cpy #40
|
||||
beq screen_grow_logical_line
|
||||
bne no_screen_advance_to_next_line
|
||||
jsr screen_grow_logical_line
|
||||
cpy #79
|
||||
bcs screen_advance_to_next_line
|
||||
bcc no_screen_advance_to_next_line
|
||||
jsr screen_advance_to_next_line
|
||||
no_screen_advance_to_next_line:
|
||||
|
||||
;; Restore X and Y
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
|
||||
rts
|
||||
|
||||
screen_grow_logical_line:
|
||||
|
||||
Reference in new issue
Block a user