Jump to content



0

lda #NUMBER in three cycles?


4 replies to this topic

#1 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Fri Dec 10, 2004 11:53 AM

Can someone tell me if there is a way to load A with an absolute value in three cycles instead of two?

I need to set A to zero and use three cycles, so right now I have a variable that is always set to zero, so I do this:
lda Zero ;+3
But it burns me up to waste a variable like this. Is there another way?

#2 Cybergoth OFFLINE  

Cybergoth

    Quadrunner

  • 8,207 posts
  • This is Sparta!
  • Location:Bavaria

Posted Fri Dec 10, 2004 11:54 AM

Hi there!

Can you post some more of the surrounding code?

Greetings,
Manuel

#3 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Fri Dec 10, 2004 12:28 PM

Cybergoth said:

Hi there!

Can you post some more of the surrounding code?

Sure.
	ldx #BAND1HEIGHT;+2	72

	jmp BeginBand1	;+3	75


;---Draw Second Band (Band1):



SkipDrawP0Band1

	lda Zero  ;+3	63

	bcc ReturnFromSkipDrawP0Band1;+3	66



LoopBand1

	nop  ;+2	73

	nop  ;+2	75

BeginBand1	

	sta GRP0	;+3  2

	lda (P0DataColorPtr),Y;+5  7

	sta COLUP0	;+3	10	

	

	dey  ;+2	12	decrement absolute scanline value by one here

	sec  ;+2	14


;---Next 12 lines (machine cycles 15-50) draw an asymmetrical playfield---



	lda PF0Data+1;+3	17

	sta PF0	;+3	20	PF0 drawn to screen at machine cycle (MC) 22.7

	lda PF1Data+1;+3	23

	sta PF1	;+3	26	PF1 drawn to screen at MC 28

	lda PF2Data+1;+3	29

	sta PF2	;+3	32	PF2 drawn to screen at MC 38.7

	lda PF3Data+1;+3	35

	sta PF0	;+3	38	PF0 finished at MC 28, drawn to screen again at MC 49.3

	lda PF4Data+1;+3	41

	sta PF1	;+3	44	PF1 finished at MC 38, drawn to screen again at MC 54.7	

	lda PF5Data+1;+3	47

	sta PF2	;+3	50	PF2 finished at MC 49.3, drawn to screen again at MC 65.3


;---End draw of asym playfield---


;------!!carry must be set!!---



	tya  ;+2	52

	sbc P0Top	;+3	55

	adc #P0HEIGHT	;+2	57	

	bcc SkipDrawP0Band1;+2/3	59/60	Branch to SkipDraw must not cross page boundary.

	lda (P0DataPtr),Y;+5	64

	nop  ;+2	66	Draw at beginning of next line.

ReturnFromSkipDrawP0Band1  



	dex  ;+2	68

	bne LoopBand1	;+2/3	70/71	


;---Initialization between bands:



	ldx #BAND2HEIGHT;+2	72

	jmp BeginBand2	;+3	75

It isn't really "wasting" a variable, since I only need it to equal zero during the Kernel, so I could reuse it for something else when I'm not drawing the screen...but I'd still prefer not to use any RAM. This is one of 10 "bands" in my kernel - so my program is already pretty RAM-intensive (60 bytes for the playfield data).

#4 Cybergoth OFFLINE  

Cybergoth

    Quadrunner

  • 8,207 posts
  • This is Sparta!
  • Location:Bavaria

Posted Fri Dec 10, 2004 1:29 PM

Hi there!

Well, if you'd use the illegal opcade version of skipdraw, your problem would go away:


lda #C_P0_HEIGHT-1; 2 

dcp P0_Y; 5 (DEC and CMP) 

bcs .doDraw0; 2/3 

lda #0; 2 

.byte $2c;-1 (BIT ABS to skip next 2 bytes) 

.doDraw0: 

lda (P0_Ptr),y; 5 

sta GRP0; 3 = 18 cycles (constant, if drawing or not!)


Greetings,
Manuel

#5 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Fri Dec 10, 2004 2:13 PM

Thanks!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users