shave some bytes

This commit is contained in:
4am 2021-12-13 21:15:26 -05:00
parent 0229973ba9
commit 29536bd901
47 changed files with 91 additions and 80 deletions

View File

@ -13,6 +13,8 @@ copymasks = $6200 ; [256 bytes, page-aligned, duplicated in a
sta $FF, x
dex
bne -
;X=0
;A=3
-- ldy #$40 ; create identical copymask tables in main and aux memory
ora #%10000000
- sta copymasks, x
@ -50,9 +52,9 @@ copymasks = $6200 ; [256 bytes, page-aligned, duplicated in a
start
!pseudopc 0 {
!byte %00000011
;Y=0 on entry to copyaux
copyaux sta $C003 ; copy $4000/aux to $8000/main
ldx #$20
ldy #$00
a lda $4000, y
b sta $8000, y
iny
@ -90,9 +92,9 @@ dst sta $FD00, y ; write the result
bmi exit
txa
bne loop1
exit lda (src+1), y ; last lousy byte (because LFSR never hits 0)
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (dst+1), y
sta $C000 ; 80STORE mode off
exit sta $C000 ; 80STORE mode off
rts
aux sta $C055 ; switch $2000 access to aux memory (read/write!)

View File

@ -15,6 +15,7 @@ hgr1hi = $0300 ; [$C0 bytes, main memory only]
sta $FF, x
dex
bne -
;X=0
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
jmp loop

View File

@ -15,6 +15,7 @@ hgr1hi = $0300 ; [$C0 bytes, main memory only]
sta $FF, x
dex
bne -
;X=0
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
jmp loop

View File

@ -16,7 +16,7 @@ copymasks= $02C0 ; [$08 bytes, different values in main and
sta $FF, x
dex
bne -
;X=0
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
ldy #8 ; copy copymask arrays into place in main and auxmem

View File

@ -5,7 +5,7 @@
!to "build/FX.INDEXED/DHGR.FIZZLE",plain
*=$6000
addrs=$C0 ; [$40 bytes]
addrs=$BF ; [$40 bytes]
ldx #$1F ; build address lookup table
- txa
@ -15,18 +15,20 @@ addrs=$C0 ; [$40 bytes]
sta addrs+$20, x
dex
bpl -
ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
sta $FF, x
ldx #(end-start+1) ; copy LFSR code to zero page
- ldy start-2, x
sty $FE, x
dex
bne -
;X=0
;Y=0
jmp copyaux
start
!pseudopc 0 {
;Y=0 on entry to copyaux
copyaux sta $C003 ; copy $4000/aux to $8000/main
ldx #$20
ldy #$00
a lda $4000, y
b sta $8000, y
iny
@ -37,8 +39,7 @@ b sta $8000, y
bne a
sta $C002
sta $C001 ; 80STORE mode
; X,Y=0 on entry to LFSR
; in: X,Y=0
;X,Y=0 on entry to LFSR
loop txa
loop1 eor #$35 ; LFSR form 0x3500 with period 16383
tax
@ -62,9 +63,9 @@ dst sta $FD00, y
bmi exit
txa
bne loop1
exit lda (src+1), y ; last lousy byte (because LFSR never hits 0)
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (dst+1), y
sta $C000 ; 80STORE mode off
exit sta $C000 ; 80STORE mode off
rts
aux sta $C055 ; switch $2000 access to aux memory (read/write!)
sta <auxsrc+2

View File

@ -11,14 +11,14 @@ hgr1hi = $300 ; [$C0 bytes, main memory only]
!source "src/fx/macros.a"
ldx #(end-start) ; copy code to zero page
- lda start-1, x
sta $FF, x
lda #0
ldx #(end-start) ; copy code to zero page
- ldy start-1, x
sty $FF, x
sta startrows_by_column-1, x
dex
bne -
;X=0
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
jmp loop

View File

@ -13,6 +13,8 @@ copymasks = $6200 ; [256 bytes, page-aligned]
sta $FF, x
dex
bne -
;X=0
;A=1
-- ldy #$20 ; create copymask table
ora #%10000000
- sta copymasks, x
@ -63,8 +65,8 @@ dst sta $FD00, y ; write the result
bmi exit
txa
bne loop1
exit lda (src+1), y ; last lousy byte (because LFSR never hits 0)
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (dst+1), y
rts
exit rts
}
end

View File

@ -65,8 +65,8 @@ dst sta $FD00, y ; write the result
bmi exit
txa
bne loop1
exit lda (src+1), y ; last lousy byte (because LFSR never hits 0)
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (dst+1), y
rts
exit rts
}
end

View File

@ -7,13 +7,8 @@
!source "src/fx/fx.shr.common.a"
addrs=$80 ; [128 bytes]
addrs=$7F ; [128 bytes]
ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
sta $FF, x
dex
bne -
lda #$A0 ; create address lookup table
tax
tay
@ -21,8 +16,14 @@ addrs=$80 ; [128 bytes]
sty addrs-$21, x
dex
bne -
ldx #(end-start+1) ; copy LFSR code to zero page
- ldy start-2, x
sty $FE, x
dex
bne -
;X=0
ldy #0
;Y=0
+COPY_SCB_AND_PALETTES
;WRITEAUXMEM active
@ -37,10 +38,9 @@ loop txa
loop1 eor #$60 ; LFSR form 0x6000 with period 32767
tax
loop2 lda addrs, x
sta <src+1
src=*+1
lda $FD00, y ; SMC high byte
sta (<src), y
sta <src+2
src lda $FD00, y ; SMC high byte
sta (src+1), y
txa
lsr
tax
@ -53,8 +53,8 @@ src=*+1
bmi exit
txa
bne loop1
exit lda (src), y ; last lousy byte (because LFSR never hits 0)
sta (src), y
rts
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (src+1), y
exit rts
}
end

View File

@ -8,19 +8,21 @@
!source "src/fx/fx.shr.common.a"
shrlo = $301 ; $C8 bytes
shrhi = $38 ; $C8 bytes
ldx #(end-start-1) ; copy loop to zero page
- lda start, x
sta $00, x
dex
bpl -
shrhi = $37 ; $C8 bytes
+BUILD_SHR_LOOKUP_TABLES shrlo, shrhi
ldx #(end-start+1) ; copy loop to zero page
- ldy start-2, x
sty $FE, x
dex
bne -
;X=0
;Y=0
+COPY_SCB_AND_PALETTES
;WRITEAUXMEM active
ldy #0
jmp loop
start
@ -46,6 +48,6 @@ dst sta $0000, y ; SMC
end
; if zero page code gets too large, move shrhi to $201
!if end-start > $38 {
!if end-start > shrhi {
!error "code is too large: ends at ", end-start
}

View File

@ -6,12 +6,14 @@
; posted on comp.sys.apple2 on 2018-07-11
; https://groups.google.com/d/msg/comp.sys.apple2/v2HOfHOmeNQ/zD76fJg_BAAJ
!macro BUILD_HGR_LOOKUP_TABLES .hgrlo, .hgr1hi {
; preserves Y
ldx #0
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 .hgrlo, .hgr1hi
}
; use this macro instead if you know X is already 0 on entry, to save 2 bytes
!macro BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 .hgrlo, .hgr1hi {
; preserves Y
- txa
and #$F8
bpl +

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10947866
!be24 10947858
!le16 4281

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10900652
!be24 10900644
!le16 5239

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10843511
!be24 10843503
!le16 3586

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10855881
!be24 10855873
!le16 3946

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10871280
!be24 10871272
!le16 4998

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10888932
!be24 10888924
!le16 5571

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952147
!be24 10952139
!le16 410

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952932
!be24 10952924
!le16 448

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10953380
!be24 10953372
!le16 303

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10908037
!be24 10908029
!le16 1242

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952664
!be24 10952656
!le16 67

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10947807
!be24 10947799
!le16 59

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10946477
!be24 10946469
!le16 1249

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10932467
!be24 10932459
!le16 464

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10905891
!be24 10905883
!le16 2146

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10909510
!be24 10909502
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952557
!be24 10952549
!le16 107

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10947726
!be24 10947718
!le16 81

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952731
!be24 10952723
!le16 201

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10932931
!be24 10932923
!le16 4407

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10937338
!be24 10937330
!le16 1533

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10938871
!be24 10938863
!le16 1040

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10939911
!be24 10939903
!le16 3237

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10943148
!be24 10943140
!le16 2764

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10945912
!be24 10945904
!le16 460

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10946372
!be24 10946364
!le16 105

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10953683
!be24 10953675
!le16 2370

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10920572
!be24 10920564
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10894503
!be24 10894495
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10835479
!be24 10835471
!le16 8032

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10847097
!be24 10847089
!le16 8784

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10859827
!be24 10859819
!le16 11453

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10876278
!be24 10876270
!le16 12654

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10909279
!be24 10909271
!le16 231

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10915659
!be24 10915651
!le16 4913

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10926721
!be24 10926713
!le16 5746