From 3e504a80d8fe4e3f6043818b232fcdec49971673 Mon Sep 17 00:00:00 2001 From: 4am Date: Mon, 30 Nov 2020 14:55:10 -0500 Subject: [PATCH] shave some bytes --- src/fx/fx.dhgr.48boxes.common.a | 295 ++++++++++++++++---------------- 1 file changed, 146 insertions(+), 149 deletions(-) diff --git a/src/fx/fx.dhgr.48boxes.common.a b/src/fx/fx.dhgr.48boxes.common.a index 8788b619f..ffebf6d79 100644 --- a/src/fx/fx.dhgr.48boxes.common.a +++ b/src/fx/fx.dhgr.48boxes.common.a @@ -80,22 +80,25 @@ k_right_mask_aux = 8 ; must be 8 k_current_page = 9 k_switch_to_main = 10 k_switch_to_aux = 11 -k_inx_and_recalc = 12 -k_recalc = 13 -k_set_row_count = 14 -k_set_first_row = 15 -k_iny = 16 -k_dey = 17 -k_save_y = 18 -k_restore_y = 19 -k_middle_jsr = 20 -k_outer_jsr = 21 -k_middle_branch = 22 -k_outer_branch = 23 -k_bitcopy = 24 -k_mask_copy_pre = 25 -k_mask_copy_post = 26 -k_byte_copy = 27 +k_switch_to_aux_and_byte_copy = 12 +k_inx_and_recalc = 13 +k_recalc = 14 +k_set_row_count = 15 +k_set_first_row = 16 +k_iny2 = 17 +k_iny = 18 +k_dey = 19 +k_save_y = 20 +k_restore_y = 21 +k_middle_jsr = 22 +k_outer_jsr = 23 +k_middle_branch = 24 +k_outer_branch = 25 +k_mask_copy_pre = 26 +k_mask_copy_post = 27 +k_byte_copy = 28 +k_byte_copy_and_iny = 29 +k_bitcopy = 30 ; must be last token !source "src/fx/macros.a" @@ -179,37 +182,54 @@ NextBox dex ; Note that several pieces overlap in order to minimize code size. ; Everything from CODEGEN_COPY_START and onward is copied to zero page for ; the code generation phase on program startup. +EDGE_LEFT_MASK_MAIN = $01 ; address $01 to match token +EDGE_RIGHT_MASK_MAIN = $02 ; address $02 to match token +LEFT_MASK_MAIN = $03 ; address $03 to match token +RIGHT_MASK_MAIN = $04 ; address $04 to match token +EDGE_LEFT_MASK_AUX = $05 ; address $05 to match token +EDGE_RIGHT_MASK_AUX = $06 ; address $06 to match token +LEFT_MASK_AUX = $07 ; address $07 to match token +RIGHT_MASK_AUX = $08 ; address $08 to match token CODEGEN_COPY_START -!pseudopc 0 { +!pseudopc 9 { RTS0 - rts ; also terminates MainLoop -RTS0_E -; -EDGE_LEFT_MASK_MAIN ; must be at address $01 to match token - !byte $FD -EDGE_RIGHT_MASK_MAIN ; must be at address $02 to match token - !byte $FD -LEFT_MASK_MAIN ; must be at address $03 to match token - !byte $FD -RIGHT_MASK_MAIN ; must be at address $04 to match token - !byte $FD -EDGE_LEFT_MASK_AUX ; must be at address $05 to match token - !byte $FD -EDGE_RIGHT_MASK_AUX ; must be at address $06 to match token - !byte $FD -LEFT_MASK_AUX ; must be at address $07 to match token - !byte $FD -RIGHT_MASK_AUX ; must be at address $08 to match token - !byte $FD SWITCH_TO_MAIN sta $C054 SWITCH_TO_MAIN_E + rts ; also terminates MainLoop +RTS0_E ; +SWITCH_TO_AUX_AND_BYTE_COPY SWITCH_TO_AUX sta $C055 lda auxsrc_hgrhi, x sta src+1 SWITCH_TO_AUX_E +BYTECOPY_AND_INY +BYTECOPY + lda (src), y + sta (dst), y +BYTECOPY_E +SWITCH_TO_AUX_AND_BYTE_COPY_E +INY2 +INY1 + iny +INY1_E +BYTECOPY_AND_INY_E + iny +INY2_E +; +DEY1 + dey +DEY1_E +; +SAVE_Y + sty tmpy +SAVE_Y_E +; +RESTORE_Y + ldy tmpy +RESTORE_Y_E ; INX_AND_RECALC inx @@ -244,38 +264,19 @@ BIT_FOR_CLEAR !byte $29 ; (AND #$44 opcode) MASKCOPY_PRE_E ; -MASKCOPY_POST - eor (dst), y - sta (dst), y -MASKCOPY_POST_E + +codegen_pieces ; address of each of the pieces (on zero page, so 1 byte) + !byte do special bitcopy logic during codegen - !byte MASKCOPY_PRE_E-MASKCOPY_PRE - !byte MASKCOPY_POST_E-MASKCOPY_POST - !byte BYTECOPY_E-BYTECOPY - -codegen_pieces ; address of each of the pieces (on zero page, so 1 byte) - !byte do special bitcopy logic during codegen BuildDrawingRoutineFrom - sta nothing to generate - bmi + ; copymask>$80 -> assume full byte + bmi + ; copymask>=$80 -> assume full byte lda #k_mask_copy_pre jsr ProcessToken + lda #1 + sta $80 + bmi ProcessBitcopyToken ; only bitcopy has length>=$80 sta * != >STAGE0 { !error "Templates are not all on same page"