entropy: qkumba shaved another byte by noticing XDRAW0 always exits with x=0

This commit is contained in:
Vince Weaver 2018-05-31 12:14:46 -04:00
parent e926b394d8
commit 59025a1d5d
2 changed files with 11 additions and 5 deletions

View File

@ -52,7 +52,7 @@ This sound simple, but it leads to some neat patterns.
=======================
I thought it would be neat to see how small I could make this in assembly
language. Currently I have it down to 120 bytes (the executable is 124
language. Currently I have it down to 119 bytes (the executable is 123
bytes because DOS33 includes size/address filesystem metadata in the file
itself).

View File

@ -26,6 +26,9 @@
; 126 bytes: nextx: simplify by using knowledge of possible x/y vals
; 124 bytes: qkumba noticed we can bump yloop up to include the
; pha, letting us remove two now unneeded stack ops
; 123 byts: qkumba noticed XDRAW0 always exits with X==0 so
; we can move some things to use X instead and
; can get a "1" value simply by using INX
;BLT=BCC, BGE=BCS
@ -76,8 +79,8 @@ yloop:
pha ; YPOS stored on stack
lda #4 ; FOR X=4 to 278 STEP 6
sta XPOS
lda #0 ; can't fit 278 in one byte, need overflow byte
sta XPOSH
ldx #0 ; can't fit 278 in one byte, need overflow byte
stx XPOSH
xloop:
@ -99,7 +102,10 @@ xloop:
; get random value in FAC
; (floating point accumlator)
ldx #1 ; RND(1), Force 1
inx ; X is always 0 coming in, increment to 1
; RND(1), Force 1
; returns "random" value between 0 and 1
jsr RND+6 ; we skip passing the argument
; as a floating point value
@ -160,7 +166,7 @@ done:
jsr XDRAW0 ; XDRAW 1 AT X,Y
; A is 0 at end. Does that help us?
; Both A and X are 0 at exit
nextx: ; NEXT X
lda XPOS ; 2