Happy_Dude Posted August 5, 2003 Share Posted August 5, 2003 I had some internet issues and have been away from the net for 4 whole days. Wait a minute, just what is this doing in the homebrew section you may wonder, well I'v got 4 days of solid coding behing me and although I'v given up on Mr Driller for now I'v made a little hack that shows me the decimal value of a colour being displayed on screen and allows joystick control of the colour. Very simple and probably been done before but I'm just happy to have made something work Now to my question, I'v had some trouble with getting a score decreasing routine working. heres a snipit from my code which I'll post after I'm happy with it (which means when this bit is working ) Someone tell me what I'm doing wrong binary math is not my strong point ;decrease score; Not working past 0 ldx #5 scloop2 dec score,x ; decrease score lda score,x cmp #0 ; is it 0 bne scdone2 ; no? then move on lda #10 ; yes? then make it 10 sta score,x dex ; and the next number is beq scloop2 ; decreased ? scdone2 Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted August 5, 2003 Share Posted August 5, 2003 Hi there! ;decrease score ; Not working past 0 ldx #5 scloop2 dec score,x ; decrease score lda score,x cmp #0 ; is it 0 bne scdone2 ; no? then move on lda #10 ; yes? then make it 10 sta score,x dex ; and the next number is beq scloop2 ; decreased ? scdone2 Ok. The main bug is that you do "beq scloop2", ie "Branch if Equal". In this case an implicit compare with 0 happens, so it'd branch if X would be zero. You should replace it with "bpl scloop2", ie "Branch if Positive". Then it is running from 5 to 0 as intended (As I assume ) Next thing is, you don't need to do "cmp #0" after a load. This is done implicit again, so you can remove that for being redundant. And you probably want to switch from 0 to 9 rather than 1 to 10. Finally, I hope you're aware that you're decreasing all 6 digits at once with this. For a real score display you'd better switch to BCD and 3 byte storage, as with 6 bytes in binary you'll most likely kill yourself programmig that... HTH Greetings, Manuel Quote Link to comment Share on other sites More sharing options...
Happy_Dude Posted August 5, 2003 Author Share Posted August 5, 2003 Hi there! ;decrease score; Not working past 0 ldx #5 scloop2 dec score,x ; decrease score lda score,x cmp #0 ; is it 0 bne scdone2 ; no? then move on lda #10 ; yes? then make it 10 sta score,x dex ; and the next number is beq scloop2 ; decreased ? scdone2 Ok. The main bug is that you do "beq scloop2", ie "Branch if Equal". In this case an implicit compare with 0 happens, so it'd branch if X would be zero. You should replace it with "bpl scloop2", ie "Branch if Positive". Then it is running from 5 to 0 as intended (As I assume ) Next thing is, you don't need to do "cmp #0" after a load. This is done implicit again, so you can remove that for being redundant. And you probably want to switch from 0 to 9 rather than 1 to 10. Finally, I hope you're aware that you're decreasing all 6 digits at once with this. For a real score display you'd better switch to BCD and 3 byte storage, as with 6 bytes in binary you'll most likely kill yourself programmig that... HTH Greetings, Manuel I figured "cld" at startup meant all numbers were BCD Your suggestions worked but it just wont roll from 1 to 0 but straight to 9 and 11 to 10 is messed up btw it doesn't do all 6 numbers just the first one and if it's changed it checks the next one. also it's not a "real" score display so this should work just fine Quote Link to comment Share on other sites More sharing options...
Sheddy Posted August 5, 2003 Share Posted August 5, 2003 Hi there! ;decrease score ; Not working past 0 ldx #5 scloop2 dec score,x ; decrease score lda score,x cmp #0 ; is it 0 bne scdone2 ; no? then move on lda #10 ; yes? then make it 10 sta score,x dex ; and the next number is beq scloop2 ; decreased ? scdone2 Ok. The main bug is that you do "beq scloop2", ie "Branch if Equal". In this case an implicit compare with 0 happens, so it'd branch if X would be zero. You should replace it with "bpl scloop2", ie "Branch if Positive". Then it is running from 5 to 0 as intended (As I assume ) Next thing is, you don't need to do "cmp #0" after a load. This is done implicit again, so you can remove that for being redundant. And you probably want to switch from 0 to 9 rather than 1 to 10. Finally, I hope you're aware that you're decreasing all 6 digits at once with this. For a real score display you'd better switch to BCD and 3 byte storage, as with 6 bytes in binary you'll most likely kill yourself programmig that... HTH Greetings, Manuel I figured "cld" at startup meant all numbers were BCD Your suggestions worked but it just wont roll from 1 to 0 but straight to 9 and 11 to 10 is messed up btw it doesn't do all 6 numbers just the first one and if it's changed it checks the next one. also it's not a "real" score display so this should work just fine The CLD won't make a difference to INC or DEC. Only the maths instructions are affected (ADC and SBC). Don't ask me why, but INC and DEC don't count as maths.....well they do COUNT......but you know what I mean Assuming you are NOT working in decimal, you also don't need the "lda score,x" - the DEC will also flag for zero or negative. And just change the "lda #10" to "lda #9" as Manuel suggests, and you should be in business (I think!) Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted August 5, 2003 Share Posted August 5, 2003 Hi there! Your suggestions worked but it just wont roll from 1 to 0 but straight to 9 and 11 to 10 is messed up I'm short of time at the moment so here's a quicky: Try replacing "bne scdone2" with "bmi scdone2" so it should go to 0. Greetings, Manuel Quote Link to comment Share on other sites More sharing options...
Happy_Dude Posted August 5, 2003 Author Share Posted August 5, 2003 Hi there! Your suggestions worked but it just wont roll from 1 to 0 but straight to 9 and 11 to 10 is messed up I'm short of time at the moment so here's a quicky: Try replacing "bne scdone2" with "bmi scdone2" so it should go to 0. Greetings, Manuel Very close I replaced it with bpl and it works now ldx #5 scloop2 dec score,x ; decrease score bpl scdone2 ; no? then move on lda #9 ; yes? then make it 9 sta score,x dex ; and the next number is bpl scloop2 ; decreased ? scdone2 I'm happy with the code now it does what I want it to When I'v learnt a bit more (mabye in a few years) I'll probably come back to this and optimise the heck out of it Or mabye I'll just do stuff as I learn. Anyway, heres the offending peice of code p.s Fell free to tell me its crap colourtest.zip Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted August 6, 2003 Share Posted August 6, 2003 Hi there! Very close I replaced it with bpl and it works now Just to see if you learned something: Why does it work with BPL? :wink: Greetings, Manuel Quote Link to comment Share on other sites More sharing options...
Happy_Dude Posted August 6, 2003 Author Share Posted August 6, 2003 Hi there! Very close I replaced it with bpl and it works now Just to see if you learned something: Why does it work with BPL? :wink: Greetings, Manuel BPL checks if score,x is "more" than zero. Because it doesn't need to do anything unless it is zero :wink: Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted August 6, 2003 Share Posted August 6, 2003 Hi there! BPL checks if score,x is "more" than zero.Because it doesn't need to do anything unless it is zero :wink: Almost. It checks wether it is still positive. If score,x is 0, it still doesn't do anything (and so displays the 0 this frame). But when you decrease it once more, it'll turn to $FF (a negative number!) and then we do something. With the BNE you used before, you already did something when 0 was reached, so when decreasing from 1 to 0, you immediately switched that to 9, thereby skipping the display of the 0. Greetings, Manuel Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 6, 2003 Share Posted August 6, 2003 BPL checks if score,x is "more" than zero.Because it doesn't need to do anything unless it is zero :wink: So how about e.g. x=200 Quote Link to comment Share on other sites More sharing options...
Happy_Dude Posted September 19, 2003 Author Share Posted September 19, 2003 BPL checks if score,x is "more" than zero.Because it doesn't need to do anything unless it is zero :wink: So how about e.g. x=200 I'm looking around for some BCD info and found that I didn't respond to this (mabey my computer crashed just as I posted like always ) Anyway, x is the index it can only be 5 to 0. also, score,x can only be 9 to 0 because this routine resets each digit to 9 after 0 so no x=200 I do realise how faulty my explanation of BPL was but I really do understand it ..... (no really I do ....) Quote Link to comment Share on other sites More sharing options...
Happy_Dude Posted April 16, 2004 Author Share Posted April 16, 2004 It's been awhile but I finaly came back to this little program. I'v added 2 T.V modes. 50 & 60hz. Use the Colour/B&W switch to change between them. I'v also added a indicator of what mode you are currently in, which was an exercise in repositioning the players during the display. And now you can reset the whole thing by pressing reset I'd like to know if this works on a real PAL telivision because the values I needed to get 312 scanlines looked way too weird. colourtest.bin.gz Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.