plasmag: more size opt

This commit is contained in:
Vince Weaver 2023-09-05 00:40:33 -04:00
parent 29564f6762
commit ee04e5f042
5 changed files with 304 additions and 2 deletions

View File

@ -7,11 +7,12 @@ EMPTYDISK = ../../../empty_disk/empty.dsk
all: plasmag.dsk
plasmag.dsk: HELLO PLASMAG PLASMAG_FULL
plasmag.dsk: HELLO PLASMAG PLASMAG_FULL PLASMAG_TINY
cp $(EMPTYDISK) plasmag.dsk
$(DOS33) -y plasmag.dsk SAVE A HELLO
$(DOS33) -y plasmag.dsk BSAVE -a 0x4000 PLASMAG
$(DOS33) -y plasmag.dsk BSAVE -a 0x4000 PLASMAG_FULL
$(DOS33) -y plasmag.dsk BSAVE -a 0x4000 PLASMAG_TINY
###
@ -28,6 +29,14 @@ plasmag.o: plasmag.s
###
PLASMAG_TINY: plasmag_tiny.o
ld65 -o PLASMAG_TINY plasmag_tiny.o -C $(LINKERSCRIPTS)/apple2_4000.inc
plasmag_tiny.o: plasmag_tiny.s gr_gbascalc.s
ca65 -o plasmag_tiny.o plasmag_tiny.s -l plasmag_tiny.lst
###
PLASMAG_FULL: plasmag_full.o
ld65 -o PLASMAG_FULL plasmag_full.o -C $(LINKERSCRIPTS)/apple2_4000.inc

View File

@ -0,0 +1,80 @@
; 11+48 = 59 bytes
gr_setup_line:
lda gr_lookup_low,X ; 4
sta GBASL ; 3
lda gr_lookup_high,X ; 4
sta GBASH ; 3
rts
gr_lookup_low:
.byte $00,$80,$00,$80,$00,$80,$00,$80
.byte $28,$A8,$28,$A8,$28,$A8,$28,$A8
.byte $50,$D0,$50,$D0,$50,$D0,$50,$D0
gr_lookup_high:
.byte $08,$08,$09,$09,$0A,$0A,$0B,$0B
.byte $08,$08,$09,$09,$0A,$0A,$0B,$0B
.byte $08,$08,$09,$09,$0A,$0A,$0B,$0B
; 28+10 = 38
gr_setup_line2:
txa
pha
and #7
lsr
tax
lda gr_lookup_high2,X
sta GBASH
pla
pha
lsr
php
lsr
lsr
plp
rol
tax
lda gr_lookup_low2,X
sta GBASL
pla
tax
rts
; high= gr_lookup_high[(line&3)>>1]
; low = gr_lookup_low[abc defgh -> 0 1 0 1 0 1 2 3 2 3 2 3 2 3 4 5 4 5 4 5 4 5
; deh
gr_lookup_low2:
.byte $00,$80,$28,$A8,$50,$D0
gr_lookup_high2:
.byte $08,$09,$0A,$0B
; 24 bytes
; based on GBASCALC from monitor firmware
gr_setup_line3:
txa ; 2
lsr ; 2
and #$03 ; 2
ora #$08 ; 2
sta GBASH ; 3
txa
and #$18
bcc gbcalc
adc #$7f
gbcalc:
sta GBASL
asl
asl
ora GBASL
sta GBASL
rts
gr_setup_line4:
txa
jmp GBASCALC

View File

@ -1,2 +1,2 @@
5 HOME
10 PRINT CHR$(4)"BRUN PLASMAG"
10 PRINT CHR$(4)"BRUN PLASMAG_TINY"

View File

@ -5,6 +5,10 @@
; this is just part3 and size optimized
; just the graphics, no music
; Note: look into modifying color lookup table
; there's a wide setting that gives a slightly different effect
.include "hardware.inc"
; Page Zero

View File

@ -0,0 +1,209 @@
; PLASMAGORIA, Tiny version
; original code by French Touch
; trying to see how small I can get it
; note can use $F000 (or similar) for color lookup to get passable
; effect on fewer bytes
.include "hardware.inc"
Table1 = $8000
Table2 = $8000+64
; Page Zero
GBASL = $26
GBASH = $27
COMPT1 = $30
COMPT2 = $31
PARAM1 = $60
PARAM2 = $61
PARAM3 = $62
PARAM4 = $63
; =============================================================================
; ROUTINE MAIN
; =============================================================================
plasma_debut:
bit PAGE1 ; set page 1
bit SET_GR ; set graphics
bit LORES ; set lo-res
jsr init_lores_colors
do_plasma:
; init
lda #02
sta COMPT2
sta PARAM1
sta PARAM2
sta PARAM3
sta PARAM4
BP3:
jsr precalc ; pre-calc
jsr display_normal ; display normal
inc COMPT1
bne BP3
dec COMPT2
bne BP3
jmp do_plasma
; ============================================================================
; Precalculate some values
; ROUTINES PRE CALCUL
; ============================================================================
precalc:
lda PARAM1 ; self modify various parts
sta pc_off1+1
lda PARAM2
sta pc_off2+1
lda PARAM3
sta pc_off3+1
lda PARAM4
sta pc_off4+1
; Table1(X) = sin1(PARAM1+X)+sin2(PARAM1+X)
; Table2(X) = sin3(PARAM3+X)+sin1(PARAM4+X)
ldx #$28 ; 40
pc_b1:
pc_off1:
lda sin1
pc_off2:
adc sin2
sta Table1,X
pc_off3:
lda sin3
pc_off4:
adc sin1
sta Table2,X
inc pc_off1+1
inc pc_off2+1
inc pc_off3+1
inc pc_off4+1
dex
bpl pc_b1
inc PARAM1
inc PARAM1
dec PARAM2
inc PARAM3
dec PARAM4
rts
; ============================================================================
; Display Routines
; ROUTINES AFFICHAGES
; ============================================================================
; Display "Normal"
; AFFICHAGE "NORMAL"
display_normal:
ldx #23 ; lines 0-23 lignes 0-23
display_line_loop:
txa
jsr GBASCALC
ldy #39 ; col 0-39
lda Table2,X ; setup base sine value for row
sta display_row_sin_smc+1
display_col_loop:
lda Table1,Y ; load in column sine value
display_row_sin_smc:
adc #00 ; add in row value
sta display_lookup_smc+1 ; patch in low byte of lookup
display_lookup_smc:
lda lores_colors_fine ; attention: must be aligned
sta (GBASL),Y
dey
bpl display_col_loop
dex
bpl display_line_loop
rts
lores_colors_fine=$8100
init_lores_colors:
ldx #0
ldy #0
init_lores_colors_loop:
lda lores_colors_lookup,X
sta lores_colors_fine,Y
iny
sta lores_colors_fine,Y
iny
sta lores_colors_fine,Y
iny
sta lores_colors_fine,Y
iny
beq done_init_lores_colors
inx
txa
and #$f
tax
jmp init_lores_colors_loop
done_init_lores_colors:
rts
lores_colors_lookup:
.byte $00,$88,$55,$99,$ff,$bb,$33,$22,$66,$77,$44,$cc,$ee,$dd,$99,$11
.align 256
; This appears to be roughly 47+32*sin(x)+16*sin(2x)
sin1: ; 256
.byte $2E,$30,$32,$34,$35,$36,$38,$3A,$3C,$3C,$3E,$40,$41,$42,$44,$45,$47,$47,$49,$4A,$4B,$4C,$4D,$4E,$4F,$50,$51,$52,$53,$53,$54,$54
.byte $55,$55,$56,$57,$57,$58,$58,$57,$58,$58,$58,$58,$58,$58,$58,$58,$58,$57,$57,$57,$56,$56,$55,$54,$55,$54,$53,$52,$52,$51,$50,$4F
.byte $4E,$4E,$4D,$4C,$4B,$4B,$4A,$49,$48,$47,$46,$45,$45,$44,$42,$42,$41,$41,$3F,$3F,$3D,$3D,$3C,$3B,$3B,$39,$39,$39,$38,$38,$37,$36
.byte $36,$35,$35,$34,$34,$33,$32,$32,$32,$31,$31,$31,$30,$31,$30,$30,$30,$30,$2F,$2F,$30,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2E,$2F,$2F,$2F
.byte $2E,$2F,$2F,$2F,$2F,$2E,$2F,$2F,$2F,$2E,$2F,$2F,$2E,$2E,$2F,$2E,$2E,$2D,$2E,$2D,$2D,$2D,$2C,$2C,$2C,$2B,$2B,$2B,$2A,$2A,$29,$28
.byte $28,$27,$27,$26,$26,$25,$25,$23,$23,$22,$21,$21,$20,$1F,$1F,$1D,$1D,$1C,$1B,$1A,$19,$19,$17,$16,$16,$15,$14,$13,$13,$12,$11,$10
.byte $0F,$0F,$0E,$0D,$0C,$0C,$0B,$0A,$09,$09,$08,$08,$08,$07,$06,$07,$06,$06,$06,$06,$05,$06,$05,$05,$06,$05,$06,$06,$07,$07,$08,$08
.byte $09,$09,$0A,$0B,$0B,$0C,$0C,$0D,$0F,$0F,$10,$12,$12,$14,$15,$16,$17,$19,$1A,$1B,$1D,$1E,$20,$21,$22,$24,$26,$27,$28,$2A,$2C,$2E
; This appears to be roughly 47+32*sin(4x)+16*sin(3x)
sin2: ; 256
.byte $2E,$33,$38,$3C,$40,$43,$47,$4B,$4E,$51,$54,$56,$59,$5A,$5C,$5D,$5D,$5E,$5E,$5D,$5C,$5A,$59,$57,$55,$53,$4F,$4C,$49,$46,$42,$3E
.byte $3A,$36,$32,$2E,$2A,$26,$23,$1F,$1C,$18,$15,$12,$10,$0E,$0C,$0A,$09,$08,$07,$07,$07,$07,$09,$0A,$0B,$0D,$0F,$11,$13,$16,$19,$1C
.byte $1F,$22,$26,$29,$2C,$2F,$32,$36,$38,$3B,$3E,$3F,$42,$44,$46,$47,$48,$49,$4B,$4B,$4B,$4A,$4A,$49,$49,$48,$46,$44,$43,$41,$3F,$3C
.byte $3A,$38,$35,$33,$30,$2E,$2C,$2A,$28,$26,$24,$22,$21,$20,$1F,$1F,$1E,$1E,$1D,$1D,$1E,$1E,$1F,$20,$21,$22,$24,$25,$27,$29,$2B,$2D
.byte $2E,$30,$33,$35,$37,$38,$3A,$3C,$3D,$3E,$3F,$3F,$40,$40,$41,$40,$40,$3F,$3F,$3E,$3D,$3B,$3A,$38,$36,$34,$31,$2F,$2D,$2B,$29,$25
.byte $23,$21,$1F,$1D,$1B,$19,$18,$16,$15,$14,$14,$13,$13,$13,$13,$14,$16,$17,$18,$1A,$1C,$1D,$20,$23,$26,$28,$2C,$2E,$32,$35,$38,$3B
.byte $3E,$41,$45,$48,$4B,$4C,$4F,$51,$53,$54,$55,$55,$57,$57,$57,$56,$55,$53,$52,$50,$4E,$4B,$49,$45,$42,$3F,$3B,$37,$34,$30,$2C,$27
.byte $23,$1F,$1C,$18,$14,$11,$0E,$0B,$09,$07,$05,$03,$02,$01,$00,$00,$01,$01,$02,$03,$05,$07,$0A,$0D,$10,$13,$17,$1A,$1E,$22,$26,$2A
; This appears to be roughly 38+24*sin(3x)+16*sin(8x)
sin3: ; 256
.byte $26,$2C,$31,$35,$39,$3D,$40,$42,$44,$45,$45,$46,$45,$43,$42,$40,$3C,$3A,$38,$36,$33,$31,$30,$2F,$2F,$2E,$2F,$2F,$30,$33,$33,$36
.byte $37,$3A,$3C,$3C,$3E,$3E,$3D,$3D,$3B,$39,$36,$34,$30,$2B,$28,$23,$1D,$19,$14,$11,$0C,$09,$07,$04,$03,$03,$03,$03,$04,$07,$09,$0C
.byte $0F,$13,$16,$18,$1B,$1E,$20,$22,$22,$23,$24,$24,$23,$22,$21,$20,$1D,$1C,$1B,$1A,$19,$19,$19,$1A,$1C,$1E,$20,$23,$27,$2B,$2F,$33
.byte $37,$3D,$40,$44,$47,$4A,$4C,$4D,$4E,$4E,$4D,$4C,$4A,$47,$45,$41,$3C,$39,$35,$32,$2E,$2B,$28,$26,$25,$23,$23,$22,$22,$24,$24,$25
.byte $26,$29,$2A,$2A,$2B,$2C,$2B,$2B,$29,$28,$25,$23,$20,$1C,$19,$15,$10,$0D,$09,$07,$04,$02,$01,$00,$00,$00,$02,$03,$06,$0A,$0D,$11
.byte $15,$1B,$1F,$23,$27,$2B,$2D,$30,$32,$33,$34,$35,$35,$33,$33,$32,$30,$2E,$2D,$2C,$2B,$2A,$2A,$2A,$2B,$2C,$2E,$30,$32,$36,$38,$3B
.byte $3E,$42,$45,$47,$49,$4B,$4B,$4B,$4A,$49,$47,$45,$42,$3D,$3A,$35,$30,$2B,$26,$22,$1E,$1A,$17,$14,$13,$11,$10,$10,$10,$12,$12,$14
.byte $15,$18,$1A,$1B,$1D,$1E,$1F,$1F,$1F,$1F,$1E,$1D,$1B,$18,$16,$14,$10,$0E,$0C,$0B,$09,$08,$08,$09,$0A,$0C,$0E,$11,$14,$19,$1D,$22