entropy_tiny: got it to 64 byes

This commit is contained in:
Vince Weaver 2021-03-04 20:44:08 -05:00
parent 99425eb87e
commit d5add924ff
2 changed files with 54 additions and 24 deletions

View File

@ -0,0 +1,12 @@
MEMORY {
ZP: start = $70, size = $90, type = rw;
RAM: start = $70, size = $8E00, file = %O;
}
SEGMENTS {
#CODE: load = RAM, type = ro;
#RODATA: load = RAM, type = ro;
#DATA: load = RAM, type = rw;
#BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = ro;
}

View File

@ -29,11 +29,16 @@
; 88 bytes -- hack up the entropy code
; 83 bytes -- count down YPOS instead of up
; 73 bytes -- XPOS only up to 256
; 73 bytes -- move to zero page
; 65 bytes -- move XPOS/YPOS into X/Y, use RESTORE
;BLT=BCC, BGE=BCS
; zero page locations
HGR_SHAPE = $1A
A5H = $45
XREG = $46
YREG = $47
HGR_SCALE = $E7
HGR_ROTATION = $F9
FRAME = $FC
@ -44,7 +49,9 @@ YPOS = $FF
HGR2 = $F3D8
HPOSN = $F411
XDRAW0 = $F65D
RESTORE = $FF3F
.zeropage
entropy:
@ -52,51 +59,62 @@ entropy:
; Y=0, A=0 after this call
eloop:
lda #180 ; FOR Y=4 to 189 STEP 6
sta YPOS
ldy #180 ; Y=180 down to 0 STEP 6
yloop:
lda #4 ; FOR X=4 to 278 STEP 6
sta XPOS
ldx #4 ; FOR X=4 to 278 STEP 6
xloop:
ldx #1
ldy FRAME
lda $D000,y
bmi no_add
inx
no_add:
stx HGR_SCALE ; set scale value
frame_smc:
lda $D000 ; 3 ; also FRAME
and #1 ; 2
sta HGR_SCALE ; 2
inc HGR_SCALE ; 2 = 9
ldy #0 ; setup X and Y co-ords
ldx XPOS
lda YPOS
; ldx #1 ; 2
; ldy FRAME ; 2
; lda $D000,y ; 3
; bmi no_add ; 2
; inx ; 1
;no_add: ;
; stx HGR_SCALE ; 2 = 12
stx XREG ; save X
sty YREG ; save Y
; setup X and Y co-ords
tya ; YPOS into A
ldy #0 ; Y always 0
; XPOS already in X
jsr HPOSN ; X= (y,x) Y=(a)
ldx #<shape_table ; point to our shape
ldy #>shape_table
lda #0 ; ROT=0
tay ; ldy #>shape_table
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
nextx: ; NEXT X
inc FRAME
jsr RESTORE ; restore FLAGS/X/Y/A
lda XPOS ; 2
nextx: ; NEXT X
inc frame_smc+1
txa
clc ; 1
adc #6 ; x+=6 ; 2
sta XPOS ; 2
tax
bne xloop ; if so, loop ; 2
nexty:
sec
lda YPOS
sbc #6 ; y+=6
sta YPOS
; carry always set if we get here
; sec
tya
sbc #6 ; y-=6
tay
bne yloop ; if so, loop
beq eloop