It is currently Mon Oct 14, 2019 8:42 am

 All times are UTC - 7 hours

 Page 47 of 102 [ 1523 posts ] Go to page Previous  1 ... 44, 45, 46, 47, 48, 49, 50 ... 102  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Fri Aug 24, 2012 3:04 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11415
Location: Rio de Janeiro - Brazil
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).

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Fri Aug 24, 2012 3:14 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
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).

Ah yes, I was correct in my guess!! Thank you so much tokumaru!

edited text

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 01, 2012 4:02 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
I have a loop in my code.

If I have to run one line of code only on the first time through my loop
Code:
lda t6+1

and then at all other times I'll need to run this line instead:
Code:
lda t6

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.

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 01, 2012 4:13 pm

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1289
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)
Code:
lda t6+1
;loop stuff
looplabel:
lda t6
;loop stuff

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.

Code:
ldy t6+1
looplabel:
tya
;loopstuff
ldy t6
;conditional on whether you loop to looplabel again

Or... alternatively, depending on your conditional not requiring the use of A:

Code:
lda t6+1
looplabel:
;loopstuff
lda t6
;conditional on whether you loop to looplabel again

Edit:
Or this:
Code:
lda t6+1
looplabel:
lda t6
;loop stuff
;conditional on whether you loop to looplabel

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.

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 01, 2012 5:12 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
Kasumi wrote:
Edit:
Or this:
Code:
lda t6+1
looplabel:
lda t6
;loop stuff
;conditional on whether you loop to looplabel

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.
This one rocks!! (I just figured it out! ) Thank you Kasumi!!! They are all good though, thanks very much!

...NESDEV's improvements wrote:
Code:
...
Code:
...etc.
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.

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 01, 2012 9:16 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
unregistered un - wrote:
Kasumi wrote:
Edit:
Or this:
Code:
lda t6+1
looplabel:
lda t6
;loop stuff
;conditional on whether you loop to looplabel

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.
This one rocks!! (I just figured it out! ) 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.

Top

 Post subject: Posted: Fri Sep 07, 2012 5:00 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
Code:
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.

Top

 Post subject: Re:Posted: Fri Sep 07, 2012 5:36 pm

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3141
Location: Tampere, Finland
unregistered wrote:
Code:
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.

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.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Fri Sep 07, 2012 5:38 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21625
Location: NE Indiana, USA (NTSC)
This should be close:
Code:
ldx t6
lda runCount
and #\$07
bne :+
ldx t6+1
:
txa

_________________
Pin Eight | Twitter | GitHub | Patreon

Top

 Post subject: Re:Posted: Fri Sep 07, 2012 8:24 pm

Joined: Wed Jul 30, 2008 12:03 am
Posts: 34
Another one

Code:
lda #\$80
sta counter

LOOP
lda t6
lsr counter
bne SKIP
ror counter
lda t6+1
SKIP
.
.

I would point out that in Kasumi's code
Code:
lda t6+1
looplabel:
lda t6
;loop stuff
;conditional on whether you loop to looplabel

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

unregistered wrote:
Code:
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.

Top

 Post subject: Re: Re:Posted: Sat Sep 08, 2012 3:14 am

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3141
Location: Tampere, Finland
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

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).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 08, 2012 6:28 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21625
Location: NE Indiana, USA (NTSC)
Emulator-side runtime assertions are implemented in FCEUX.

_________________
Pin Eight | Twitter | GitHub | Patreon

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 08, 2012 7:40 am

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3141
Location: Tampere, Finland
tepples wrote:
Emulator-side runtime assertions are implemented in FCEUX.

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:
Code:
runTimeAssert "A == 0 && C"
runTimeAssert "current_bank == 0x12"

Et cetera.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

Top

 Post subject: Re: 8x16 sprite is really a 16x32 pixel image?Posted: Sat Sep 08, 2012 9:12 am

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7598
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.

Top

 Post subject: new questionPosted: Fri Sep 14, 2012 4:19 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
Code:
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

There's the ^ code that shows the addresses.

Code:
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

WHY IS \$002D AT #\$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. : )

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 47 of 102 [ 1523 posts ] Go to page Previous  1 ... 44, 45, 46, 47, 48, 49, 50 ... 102  Next

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2019 NESdev Competition       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki