save X and Y in CHROUT
This commit is contained in:
1 parent
aab7b98c27
commit
bf4e22b99a
1 file changed
+32
-2
+32
-2
@@ -2,8 +2,28 @@
|
|||||||
chrout:
|
chrout:
|
||||||
;; Crude implementation of character output
|
;; 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
|
;; Write character on the screen
|
||||||
ldy current_screen_x
|
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
|
sta (current_screen_line_ptr),y
|
||||||
|
|
||||||
;; Advance the column, and scroll screen down if we need
|
;; Advance the column, and scroll screen down if we need
|
||||||
@@ -13,9 +33,19 @@ chrout:
|
|||||||
iny
|
iny
|
||||||
sty current_screen_x
|
sty current_screen_x
|
||||||
cpy #40
|
cpy #40
|
||||||
beq screen_grow_logical_line
|
bne no_screen_advance_to_next_line
|
||||||
|
jsr screen_grow_logical_line
|
||||||
cpy #79
|
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
|
rts
|
||||||
|
|
||||||
screen_grow_logical_line:
|
screen_grow_logical_line:
|
||||||
|
|||||||
Reference in new issue
Block a user