Subject: Re: [stella] behold, i am become shiva, destroyer of kernals! From: KirkIsrael@xxxxxxxxxxxxx Date: 11 Mar 2004 14:01:38 -0000 |
> ;we have a hit - if ball is positioned > ; on left side, it goes right. On right, > ; it goes left. > lda #BALLPOS_CENTER > clc > cmp ballXposition+1 > bcc BallHitPlayerOnRight > > > The clc above, and in similar code, is totally superfluous. Remove it. > The comparison sets or clears the carry, and also N and Z flags. The > previous state of these is lost/ignored. Yeah, that mighta been "this isn't working (for some other reason) maybe it's a flag thing". > There are many low/high byte additions and declarations like this... > > > ;-11 > SLOW_GRAV_LO_BYTE = #%11110101 > SLOW_GRAV_HI_BYTE = #%11111111 > > clc > lda slowP1YSpeed > adc #SLOW_GRAV_LO_BYTE > sta slowP1YSpeed > lda slowP1YSpeed+1 > adc #SLOW_GRAV_HI_BYTE > sta slowP1YSpeed+1 > > > It's easier (for a human) to just use a 16-bit value and let the assembler > calculate the high/low bytes. > > SLOW_GRAV = -2.5 * 256 ; easy way to visualise 8.8 format... use > decimal as you think of it, mult by 256 to get actual 8.8 format Do you have to make sure X (in this case the -2.5) * 256 = an integer? Does that automagically store in low byte, high byte format? > > This code is a bit dangerous... > ;-------------------------------------- > ;CALCULATE SCORE POINTERS > ;-------------------------------------- > > lda p0score ;accumulator = score > asl ;accumulator = score * 2 > asl ;accumulator = score * 4 > adc p0score ;accumulator = (score * 4) + score = score * 5 > adc #<Score0Graphic-1 ;add in the low byte of the graphic location > sta pointerP0Score > ;lda #>Score0Graphic ;grab the hight byte of the graphic location > ;sta pointerP0Score+1 > > > In particular, it's initialising the high and low byte of a 16-bit pointer w > ith different values. Specifically, it puts the low byte of address-1 (plus > score * 5) into the low byte, and the high byte is elsewhere initialised to > the high byte of Score0Graphic. If I'm reading this right, assume p0score = > 0, then this would initialise (pointerP0Score) to point to 255 bytes PAST > the start of Score0Graphic. I ripped that code from someone, I'll take a look... > In several places in the code, you're using $2D to waste cycles (with a > store, etc). > Use the SLEEP macro. Code like this... > > sta $2D ... or > dec $2d; wait 5 cycles > > should be replaced by > > SLEEP 3 ... or > SLEEP 10 > > The meaning is clearer, and it's easier to make systemwide changes (eg: use > of illegal opcodes or not). Finally, the dec may have unforseen effects, > and the SLEEP is guaranteed to have NO effect on hardware OR flags (for > illegal opcode version). For the legal opcode version, it only affects > flags. I know, I was getting paranoid about StellaX. Not that it helped. I guess I don't usually set flags, sleep, and then check flags, so maybe it'll be ok to switch > By the way, there was some interesting posts a few years back on > "efficiently wasting time" which gave the least number of bytes necessary to > waste a particular number of cycles. Worth a read. > > I find the mix of UPPERCASE and lowercase op-codes quite inelegant... eg: > > ;divide by 32 for the count, then multiply by 8 for the offset... > > LSR > > tax > > LSR > > lsr > lsr > LSR > tay > ASL > asl > asl > > (actual code, by the way!). It would be nice to stick to one or the other, > preferably lowercase :) I'm not randomly sometimes typing ASL and asl...see, I sometimes rely on a 6502 simulator to figure out math stuff, and the one I use has an editor that likes to put it in uppercase, but depending on if I type or paste the line, it sometimes misses.... (Also, cut and paste code from elsewhere sometimes is uppercase) I like lowercase as well, since uppercase doesn't even color code in the textpad syntax file I'm using. Except for maybe the score thing, none of this probably related to my supercharger issue? :-( -- KirkIsrael@xxxxxxxxxxxxx http://kisrael.com "All life is 6-to-5 against, just enough to keep you interested" --Runyon ---------------------------------------------------------------------------------------------- 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 -> |
---|---|---|
[stella] Looking for a list member, Bill Heineman | Thread | Re: [stella] behold, i am become sh, Christopher Tumber |
RE: [stella] behold, i am become sh, KirkIsrael | Date | Re: [stella] Cybertech board manufa, Chris Wilkson |
Month |