Shave off another byte by copying HGR scanliens vertically -- Thank Mike B

This commit is contained in:
Michaelangel007 2017-07-27 09:23:32 -07:00
parent 5805947c93
commit 81908682ab
4 changed files with 33 additions and 34 deletions

View File

@ -3,7 +3,7 @@
Optimized Linux Logo in 6502 assembly language for size. Optimized Linux Logo in 6502 assembly language for size.
Size: 660 ($294) bytes Size: 659 ($293) bytes
# Screenshots # Screenshots

BIN
linuxlogo

Binary file not shown.

View File

@ -308,47 +308,46 @@ MakeShiftMask
lda zCursorY lda zCursorY
jsr BASCALC jsr BASCALC
; ------------------------------------------------------------------------
; Copy unpacked buffer to 8 HGR scanlines
Draw8Rows
ldy #39 ; 280/7 = 40 bytes/scanline
; Yes, this is evil ... ; Yes, this is evil ...
; Instead of copying zTxtPtr over to zHgrPtr ; Instead of copying zTxtPtr over to zHgrPtr
; We re-use it by forcing it to be a HGR address! ; We re-use it by forcing it to be a HGR address!
; This *is* safe BECAUSE we call JSR BASCALC _before_ we do any text printing. ; This *is* safe BECAUSE we call JSR BASCALC _before_ we do any text printing.
lda zTxtPtr+1 ; every 8 HGR scanline address lda zTxtPtr+1 ; Translate text page row address to
eor #$24 ; is Text Page $04 + $1C = HGR Page $20; CLC, ADC #$1C eor #$24 ; every eighth HGR row address
sta zTxtPtr+1 ; but we can optimize for HGR page 1 via EOR #$24 -- Thanks Mike B.! tax
; ------------------------------------------------------------------------ Copy7x8
; Copy unpacked buffer to 8 HGR scanlines lda UnpackAddr,Y
stx zTxtPtr+1
ldx #7 ; Repeat each scanline 8 times
Draw8Rows
ldy #39 ; 280/7 = 40 bytes/scanline
CopyScanLine
lda UnpackAddr,Y
sta (zTxtPtr),Y sta (zTxtPtr),Y
inx ; y = y+1
inx ; HGR addr_y+1 = addr_y + $0400
inx
inx
cpx #$40 ; hit HGR page 2 ? i.e. 8 scan lines done?
bcc Copy7x8 ; Loop until 7x8 pixel block is complete
txa ; Clear source on last scanline copy txa
bne CopyNextByte sbc #$20 ; Reset pointer for top of next 7x8 block
sta UnpackAddr,Y tax
CopyNextByte lda #0
dey sta UnpackAddr,Y ; Clear source on last scanline copy
bpl CopyScanLine sta zDstOffset ; reset to start of unpack buffer
dey
bpl Copy7x8 ; Loop until all 280x8 pixels are copied
clc ; y = y+1 ldx zCursorY ; (1) X=14, see (2)
lda zTxtPtr+1 ; HGR addr_y+1 = addr_y + $0400 cpx #$14 ; Y=$40 .. $A0, Rows $8..$13 (inclusive)
adc #$04 FitSameByte
sta zTxtPtr+1 sta zDstShift
ldy zSrcOffset ; NOTE: C=0 from CMPs above
stx zDstOffset ; X=0 last loop iteration rts
txa ; A=0 zDstShift
dex
bpl Draw8Rows
ldx zCursorY ; (1) X=14, see (2)
cpx #$14 ; Y=$40 .. $A0, Rows $8..$13 (inclusive)
FitSameByte
sta zDstShift
ldy zSrcOffset ; NOTE: C=0 from CMPs above
rts
; ======================================================================== ; ========================================================================

Binary file not shown.