6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 23, 2024 8:13 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Aug 30, 2004 4:29 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I am now to the point of code of using a set of cmp/beqs to let me know where to branch to based on a variable. But the results are wierd...

Code is
lda GameJob
cmp #$03 ; Test passes?
beq TestPassesJump
cmp #$04 ; is it the attract mode?
beq AttractModeJump
cmp #$05 ; Is it Fireball?
beq FireballModeJump
cmp #$06 ; is it Hokus Pokus?
beq HokusPokusJump

and so on up to 8.

The fun part, if the GameJob variable is odd, then it works fine. If it is EVEN, then it adds 1 to the GameJob variable and branches there.

I cant find anythign else int he code to account for this behavior wierdness. Help!

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 30, 2004 7:13 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8442
Location: Southern California
It should work, so I expect your problem is somewhere else other than the little piece of code you gave. There are several more-efficient ways to do it though. One would be
Code:
        LDA GameJob
        ASL A
        TAX
        JMP (Game_Addr_Table,X)

(although you'll need a CMOS 6502 for the JMP (ind,X). If you can just make the GameJob variable twice as high, you can skip the ASL and just load X directly with the value of the index into the address table:
Code:
        LDX GameJob
        JMP (Game_Addr_Table,X)


Another way would be to keep decrementing the register and branching if the decrement resulted in 0:
Code:
        LDX GameJob
        BEQ This_Game
        DEX
        BEQ That_Game
        DEX
        BEQ The_Other_Game
        DEX
        BEQ Yet_Another_Game
      etc.


This of course means you're back to branching to jumps since the game programs s won't be small enough to reach them all by jumping only half a page.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 01, 2004 6:34 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Thanks on the ideas of how to play with the jumps.

I have swithced over to the 65C02 and 65C22 after having heat problemns and intetrmittent frenzies from running a 6502B at 4 mhz. Am much happier witht the Cs, Western Design had been super wonderful ing etting them out here.


I am wondering a noise problem with it now. I had been running roudn the code and cant see where else it would mess with tyhe variable. I had thrown in a tiny display to show me what the variable is at all times, simple

DisplayGameJob
lda GameJob
clc
adc #$30 ; this allows for ascii representation)
sta Display6
rts

If I had a gamejob of 4, it would turn into 5. Now, it actually waits a little while, from a split second to 30 seconds to change from 4 to 5.

This is with GaqmeJob being at $23 in zero page. If I put it at $24, then it skips 2. Putting it up past the stack at $203 lets it behave for about 30 seconds, then i6 jumps up the notch where it shouldnt./


I am thinking now it might be a noise glitch into my RAM access lines. Am going to play with a 100 pF cap on either the /CD or ./WR lines to the RAM chip. The circuit is basically the same as Darryl's first version of the SBC, but with some slight differences.


What is wierd is that the first part of tghe code with GameJob works sbout 99.995% of the time in which at GameJob = 3 shows a TEST PASSES ont he display, then goes onto gameJob 4, which iis the attract mode. Come to think of it, thos4e few times, it would merely lock up. I am wondering if I am looking at more of a glitch rathewr than a true programming problem.

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Sep 03, 2004 3:46 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Nightmaretony wrote:
If I had a gamejob of 4, it would turn into 5. Now, it actually waits a little while, from a split second to 30 seconds to change from 4 to 5.


The amount of difference from one spontaneous increment to another depends on what address you use for the variable?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 07, 2004 6:20 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
It wasm, yes. But finally found the problem, I hope. I was using a slow RAM of 100 nS. I found some 70 nS from a Primal Rage arcade game, and then it seemed to calm down.. Since I am running this poup at 4 mhz, th3 100 nS was a tad too slow....

am staying with the cmp/beq in a row, only for readability purposes. But atleast ont he switch, it behaved for an hour at work; going to try it once again, lets hope it keeps behaving :).....

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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

Search for:
Jump to: