8x16 and whatever else unreg wants to know
Moderator: Moderators
Re: 8x16 sprite is really a 16x32 pixel image?
Yes, this is correct. I like to think about it this way: the carry flag, in subtractions, is actually a value that can be borrowed if necessary. After the subtraction (CMP acts just like SEC + SBC, except it doesn't change A), if the carry is still set, a borrow wasn't necessary, so the value in A was large enough for you to subtract from it as much as you did (it's >= the value you subtracted). If the carry is clear, a borrow was necessary and the value in A wasn't large enough (it's < than the subtracted value).
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Re: 8x16 sprite is really a 16x32 pixel image?
Ah yes, I was correct in my guess!! Thank you so much tokumaru!tokumaru wrote:Yes, this is correct. I like to think about it this way: the carry flag, in subtractions, is actually a value that can be borrowed if necessary. After the subtraction (CMP acts just like SEC + SBC, except it doesn't change A), if the carry is still set, a borrow wasn't necessary, so the value in A was large enough for you to subtract from it as much as you did (it's >= the value you subtracted). If the carry is clear, a borrow was necessary and the value in A wasn't large enough (it's < than the subtracted value).
edited text
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Re: 8x16 sprite is really a 16x32 pixel image?
I have a loop in my code.
If I have to run one line of code only on the first time through my loop
and then at all other times I'll need to run this line instead:
How would be a good way to set that up... something simple maybe? And these lines of code will be in the middle of my large loop. I'm trying to use one of those temp variables Kasumi recommended me.
If I have to run one line of code only on the first time through my loop
Code: Select all
lda t6+1
Code: Select all
lda t6
Re: 8x16 sprite is really a 16x32 pixel image?
It sorta depends on how long the loop is/what registers you need.
I'd just do the obvious and double the loop code if it's shortish. (Yeah, I realize you said it was long)
If it's long, I might just store whatever is in t6 or t6+1 into a new temp variable or a register and then just always use the new temp variable or register.
Or... alternatively, depending on your conditional not requiring the use of A:
Edit:
Or this:
That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.
Or I might do something totally different depending on the setup of the loop. But there's some ideas.
I'd just do the obvious and double the loop code if it's shortish. (Yeah, I realize you said it was long)
Code: Select all
lda t6+1
;loop stuff
looplabel:
lda t6
;loop stuff
Code: Select all
ldy t6+1
looplabel:
tya
;loopstuff
ldy t6
;conditional on whether you loop to looplabel again
Code: Select all
lda t6+1
looplabel:
;loopstuff
lda t6
;conditional on whether you loop to looplabel again
Or this:
Code: Select all
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel
Or I might do something totally different depending on the setup of the loop. But there's some ideas.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Re: 8x16 sprite is really a 16x32 pixel image?
This one rocks!! (I just figured it out! ) Thank you Kasumi!!! They are all good though, thanks very much!Kasumi wrote: Edit:
Or this:That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.Code: Select all
lda t6+1 jmp skiploadt6 looplabel: lda t6 skiploadt6: ;loop stuff ;conditional on whether you loop to looplabel
AND GOODNESS!! THIS FORUM JUST KEEPS GETTING BETTER AND BETTER, THANKS YALL! Edit: It's kindof slow right now...but maybe that's because there's been lot of my time coding these days.[color=#FFFF00][b]...NESDEV's improvements[/b][/color] wrote:Code: Select all
...
Code: Select all
...etc.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Re: 8x16 sprite is really a 16x32 pixel image?
unregistered [color=#FF0000]un -[/color] wrote:This one rocks!! (I just figured it out! )Kasumi wrote: Edit:
Or this:That one is probably best, because it doesn't add setup time to each loop after the first like the others. It just came to mind third.Code: Select all
lda t6+1 jmp skiploadt6 looplabel: lda t6 skiploadt6: ;loop stuff ;conditional on whether you loop to looplabel
Thank you Kasumi!!!They are all good though, thanks very much!
Kasumi wrote:If it's long, I might just store whatever is in t6 or t6+1 into a new temp variable or a register and then just always use the new temp variable or register.
Ahhh, I see now... after rereading and understanding your dark orange text up there... now, now... thank you so much Kasumi!!! Brilliant! I'm a step closer now! I'm in for some more gettin' dirty coding, I think.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Code: Select all
lda t6 ;pla ;<--------------------------------------
;on every 8th run do this instead:
lda t6+1
Is there a simple way to do this? I'm trying to make a simple solution.
Re:
Have a counter that counts upwards each run. Calculate counter AND 7, if result is zero, lda t6+1, otherwise lda t6. If counter starts at zero this will load t6+1 on the first run too. If you don't want that you can initialize the counter to a different value.unregistered wrote:Code: Select all
lda t6 ;pla ;<-------------------------------------- ;on every 8th run do this instead: lda t6+1
Is there a simple way to do this? I'm trying to make a simple solution.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Re: 8x16 sprite is really a 16x32 pixel image?
This should be close:
Code: Select all
ldx t6
lda runCount
and #$07
bne :+
ldx t6+1
:
txa
Re:
Another one
I would point out that in Kasumi's code
There's the possibility of using a branch instead of
a jmp if that seems desirable eg if you know
t6+1 will never be 0 you could bne
saves a byte, might cost you a cycle at a page boundary,
more relocatable
Code: Select all
lda #$80
sta counter
LOOP
lda t6
lsr counter
bne SKIP
ror counter
lda t6+1
SKIP
.
.
Code: Select all
lda t6+1
jmp skiploadt6
looplabel:
lda t6
skiploadt6:
;loop stuff
;conditional on whether you loop to looplabel
a jmp if that seems desirable eg if you know
t6+1 will never be 0 you could bne
saves a byte, might cost you a cycle at a page boundary,
more relocatable
unregistered wrote:Code: Select all
lda t6 ;pla ;<-------------------------------------- ;on every 8th run do this instead: lda t6+1
Is there a simple way to do this? I'm trying to make a simple solution.
Re: Re:
Using branch also loses some maintainability (in case the code above changes so that the zero flags value isn't a constant anymore). I tend to avoid this optimization. It sure would be nice to be able to do runtime assertions... (I'm considering implementing something like that in NintendulatorDX).bogax wrote:There's the possibility of using a branch instead of
a jmp if that seems desirable eg if you know
t6+1 will never be 0 you could bne
saves a byte, might cost you a cycle at a page boundary,
more relocatable
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Re: 8x16 sprite is really a 16x32 pixel image?
Emulator-side runtime assertions are implemented in FCEUX.
Re: 8x16 sprite is really a 16x32 pixel image?
Not what I'm looking for. I don't want to specify the conditions manually and have to update them every time the addresses change. What I'm thinking about doing is a macro that outputs the assert expressions in a separate file (easily done with CC65). Something like this:tepples wrote:Emulator-side runtime assertions are implemented in FCEUX.
Code: Select all
runTimeAssert "A == 0 && C"
runTimeAssert "current_bank == 0x12"
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: 8x16 sprite is really a 16x32 pixel image?
You could implement an assert macro that reads or writes to a specific address, executes a bad opcode, or something else that is not dependent on the program counter. This would let you keep the same "assert" breakpoint from build to build.
Alternatively, you could try to auto-generate the .dbg file FCEUX uses based on compile symbols. This would be better, since you could then have asserts without any extra code in the ROM.
Alternatively, you could try to auto-generate the .dbg file FCEUX uses based on compile symbols. This would be better, since you could then have asserts without any extra code in the ROM.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
new question
Code: Select all
0002D attNextRowStart .dsb 1 ;thank you !!!! :D
0002E every8thRun .dsb 1 ;will stay at 0 until the 8th attribute table block, the start of a new row, is to b
0002F atttablerownums: .db $00, $20, $40,$60,$80,$a0,$c0,$e0
00037 tA .dsb 2
Code: Select all
00:C26D:E6 37 INC $0037 = #$05
00:C26F:A6 37 LDX $0037 = #$05
00:C271:B5 2F LDA $2F,X @ $003D = #$00
00:C273:85 2D STA $002D = #$00
edit: Thank yall for helping with my last question. I'm tired, it is time to get away from this right now for me. Will elaborate my thanks soon, I promise. : )