Subject: RE: [stella] RE: Illegal opcodes...another question From: "Andrew Davie" <adavie@xxxxxxxxxxxxx> Date: Mon, 13 Jan 103 22:47:12 CST |
It's a real elegant piece of code, Dennis. My reading of it: The DCP opcode decrements a memory location and compares with the accumulator, setting the carry flag appropriately (Clear if the accumulator is less than). So we start with the accumulator holding the height of the sprite (ie: its size in pixels, 0-based). We do the DCP on the memory location holding the y position of the sprite (so as we go down the screen, that variable holding the y position is decremented). As the decrement is done, we get a 'free' comparison with the height of the sprite. If the carry flag is set then we branch to the actual draw code... the y register holds the line number (presumably) on the screen, the (p0_ptr) variable will have been pre-adjusted to point to n lines BEFORE the actual data, so that when we branch into the actual code here, (p0_ptr),y will point exactly to the start of the sprite graphics the first time it executes. And to subsequent lines afterwards. If the DCP returned carry clear (ie: it was not within the valid draw-range of the sprite) - ie2: it was greater than #CAR_HEIGHT-1 - then we don't want the draw to happen, and we instead load the accumulator with 0 (blank) and execute the 3-byte BIT absolute instruction (starting at $2C)... this causes the subsequent lda (P0_Ptr),y to be ignored, thus saving 0 into the sprite register. Every scan line Y would be incremented by 1. As I said, 'elegant'. I could never write code like this! I'm not sure I'd want to... ! Cheers A -----Original Message----- From: owner-stella@xxxxxxxxxxx [mailto:owner-stella@xxxxxxxxxxx]On Behalf Of Dennis Debro Sent: Tuesday, 14 January 2003 3:14 PM To: stella@xxxxxxxxxxx Subject: [stella] RE: Illegal opcodes...another question Sorry for the multiple questions but I want to understand how these illegal opcodes work as I think they may help me... Thomas, I'm looking at the kernel you did for Glenn for Death Race and I have a question. In this code snippet... ; draw car #0: lda #CARHEIGHT-1 ; 2 dcp P0_Y ; 5 bcs .doDraw0 ; 2³ lda #0 ; 2 .byte $2c ;-1 .doDraw0: lda (P0_Ptr),y ; 5 sta GRP0 ; 3 = 18 @20 I see you are using dcp (opcode $c7, decrement and compare). What does this have to do with the y-register? You're not updating y for each scanline, right? Does dcp effect the y-register is some way? I had this question back when you posted skipDraw (http://www.biglist.com/lists/stella/archives/200102/msg00282.html) but I never asked :) Apparently, I'm the only one here that doesn't get it :( Take care, Dennis ---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/ ---------------------------------------------------------------------------------------------- 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 -> |
---|---|---|
RE: [stella] RE: Illegal opcodes..., Thomas Jentzsch | Thread | Re: [stella] Illegal opcodes...anot, Dennis Debro |
Re: [stella] Collaboration, Thomas Jentzsch | Date | Re: [stella] Collaboration, Glenn Saunders |
Month |