Subject: Re: [stella] Very BASIC ASM Info needed... From: "Thomas Jentzsch" <tjentzsch@xxxxxx> Date: Wed, 7 Mar 2001 15:35:17 +0100 |
Manuel Polik wrote: > Andrew Davie wrote: > > > > Can someone please find _and_ explain it to me? :-) > > > Well, this isn't an eor-trick. But fairly efficient. > > Depends on what's your poison... code size or speed. > > Thanks for pointing out these two ways. The one with the table is the > one I'll probably use, but the second one I liked more from a *style* > point of view, since it's very clever that way. Well, the most compact way is (as always) to count down (8 bytes): dec FrameCounter bpl .skipReset lda #2 sta FrameCounter .skipReset But I don't know an EOR trick for this too. > Just for the record, can someone come up with an elegant 'division by 3' > solution? > (quicker than subtracting multiple numbers of '3's I mean) > That would save a BYTE'o'RAM then, since I wouldn't have to install > another frame counter. I guess, what you need is a framecounter that allows you to do something every 2nd, 3rd or maybe 6th frame. I had the same problem with Thrust too. My solution was to combine both counters into one byte. I used the upper two bits for counting to 3 and the lower 6 bits for counting up to 64. That way I could simple define masks for the needed intervalls: ; masks for FrameCnt: FRAME1MASK = %00000000 FRAME2MASK = %00000001 FRAME3MASK = %11000000 FRAME4MASK = %00000011 FRAME6MASK = FRAME2MASK|FRAME3MASK ; %11000001 FRAME8MASK = %00000111 FRAME12MASK = FRAME4MASK|FRAME3MASK ; %11000011 FRAME16MASK = %00001111 FRAME32MASK = %00011111 FRAME48MASK = FRAME16MASK|FRAME3MASK ; %11001111 FRAME64MASK = %00111111 FRAME96MASK = FRAME32MASK|FRAME3MASK ; %11011111 FRAME192MASK = FRAME64MASK|FRAME3MASK ; %11111111 And the code looked like this: lda FrameCnt and #mask beq doSomething The resulting code for increasing the framecounter was a bit complicated, but I needed one byte only: lda FrameCnt ; 3 bpl .okCnt3 ; 2³ ora #$40 ; 2 reset Cnt3 .okCnt3: clc ; 2 adc #$40 ; 2 increase Cnt3 sta FrameCnt ; 3 and #$3f ; 2 bne .okCnt64 ; 2³ lda #$3f ; 2 reset Cnt64 BIT_W ; 2 .okCnt64: lda #$ff ; 2 increase Cnt64 clc ; 2 adc FrameCnt ; 3 sta FrameCnt ; 3 = 28-32 Have fun! _______________________________________________________ Thomas Jentzsch | *** Every bit is sacred ! *** tjentzsch at web dot de | _______________________________________________________________________________ Alles unter einem Dach: Informationen, Fun, E-Mails. Bei WEB.DE: http://web.de Die große Welt der Kommunikation: E-Mail, Fax, SMS, WAP: http://freemail.web.de - Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Important! Repository idea! (was: R, Manuel Polik | Thread | Re: [stella] Very BASIC ASM Info ne, Manuel Polik |
Re: [stella] Overscan & Vblank conf, Manuel Polik | Date | Re: [stella] Very BASIC ASM Info ne, Manuel Polik |
Month |