Subject: [stella] Missile Collisions -- "missile.bin series" From: Ruffin Bailey <rufbo1@xxxxxxxxxxx> Date: Tue, 02 Jul 2002 06:44:59 -0400 |
Welp, for a reason similar to that of Bob Colbert's disappearance quite some time ago (from which he's since reappeared), I've been pulling some pretty late nights/early morning recently with some free time for hacking. Slowly but surely something's happening. :^) Much more slowly than surely, but something's happening... This is the latest iteration of the "missile.bin" series. In this episode, we figure out how to capture missile0/missile1 collisions, and change the color of the background when this happens. Note that missile0 (blue) is still moved by joystick one and missile1 (yellow) with joystick 2. Two main lessons learned: 1.) Indeed, hitting CXCLR before checking for collisions is a bad idea. 2.) COLUPF is *not* the same as COLUBK. :^) Unfortunately most of my time was spent learning number 2. "Man, I'm getting the right values, and it _is_ bpl; why aren't I getting a different colored background?" *SMACK* Here's the "important" new code: [new code] ;======================================= ; Collisons ;======================================= ; check for missile/missile collison lda CXPPMM ; now we've got a 1 in D7 if player 0 touches player 1 ; and a 1 in D6 if missile 0 touches missile 1 sta GRP1 ; stick it into player1's graphic to debug rol ; We want D6 from CXPPMM, so roll to the left one bit bpl noMMcol ; If D6 is switched on, our new number in the accumulator ; will be negative. So if positive, skip the bit below ; where we change the background color lda #%11111111 ; white, give or take sta COLUBK ; smack it into the background ; Note that COLUBK isn't the same as COLUPF *sigh* noMMcol: STA CXCLR ;3 Clear the collision latches. [/new code] I also fixed the positioning of the variable initialization code (Thanks again, Chris) and added a NUSIZ1 bit to that section so that it's easier to get the two missiles to overlap. ;Width of a missile is controlled by writing into ; bits D4 and D5 of the number-size registers (NUSIZ0, ; NUSIZ1). lda #%00110000 sta NUSIZ1 Hope this helps someone, even if it's just me in four years checking the archives. Ruffin Bailey http://myfreakinname.blogspot.com
Attachment:
2missileCol.asm
Description: application/applefile
; ------------------------------------------------------------------------ ; * Subject: [stella] Distella --> DAsm problem ; * From: Ruffin Bailey <rufbo@xxxxxxxxxxxxx> ; * Date: Fri, 21 Aug 98 13:55:03 -0000 ; ------------------------------------------------------------------------ ; See original message post for details ; http://www.biglist.com/lists/stella/archives/9808/msg00065.html ; dasm source.s -f3 -osource.bin ; Disassembly of missile.bin aka How to move a missile around your screen. ; Disassembled Sat Aug 15 11:32:54 1998 ; Using DiStella v2.0 on a Mac, no less! ; ; Command Line: distella -pafs missile.bin ; processor 6502 include vcs.h ORG $F000 START: SEI ;2 CLD ;2 LDX #$FF ;2 TXS ;2 LDA #$00 ;2 LF00B: STA VSYNC,X ;4 DEX ;2 BNE LF00B ;2 ;========================= ; init some vars ;========================= LDA #$40 ;2 STA $80 ;3 $80 is holding the value where missle zero should be shown (the "y-value") ; starting at $40 (64 decimal) STA $81 ;3 $81 is holding the value where missle one should be shown (the "y-value") ; also starting at $40 (64 decimal) ;Width of a missile is controlled by writing into ; bits D4 and D5 of the number-size registers (NUSIZ0, ; NUSIZ1). lda #%00110000 sta NUSIZ1 ;========================= ; end of initing ; some vars ;========================= ; it'd seem someone was using Nick's "How to Draw a Playfield" :^) JSR LF0D8 ;6 LF013: JSR LF025 ;6 JSR LF03F ;6 JSR LF044 ;6 JSR LF07D ;6 JSR LF0D0 ;6 JMP LF013 ;3 LF025: LDX #$00 ;2 LDA #$02 ;2 STA WSYNC ;3 STA WSYNC ;3 STA WSYNC ;3 STA VSYNC ;3 STA WSYNC ;3 STA WSYNC ;3 LDA #$2C ;2 STA TIM64T ;4 STA WSYNC ;3 STA VSYNC ;3 RTS ;6 LF03F: LDA #$00 ;2 STA COLUBK ;3 RTS ;6 LF044: LDA #$88 ;2 setting up the colors STA COLUP0 ;3 P0 is blue LDA #$36 ;2 STA COLUPF ;3 PF redish (won't see that here, though) LDA #$D8 ;2 STA COLUP1 ;3 P1 yellow (Sir Not Pictured in this film) LDA #$00 ;2 STA COLUBK ;3 BK black LDA #$00 ;2 STA CTRLPF ;3 LDA #$00 ;2 STA HMM0 ;3 if there's no joystick move, m0 goes nowhere sta HMM1 ; set missile one's move to nothing as well LDA SWCHA ;4 SWCHA dissection BMI LF065 ;2 Player 0 | Player 1 LDY #$F0 ;2 ===============|=============== STY HMM0 ;3 D7 D6 D5 D4 | D3 D2 D1 D0 LF065: ROL ;2 rt lt dn up | rt lt dn up BMI LF06C ;2 LDY #$10 ;2 I'm using BMI to read D7 of SWCHA STY HMM0 ;3 (which has been read into the accumulator) LF06C: ROL ;2 Then rolling the byte to the left and reading the BMI LF073 ;2 next bit (D6,5,4...) with BMI since the next INC $80 ;5 bit would now be D7. INC $80 ;5 LF073: ROL ;2 $80 holds the scan line that the missile BMI MISSLE1CHECK ;2 will appear on, and since I'm counting up from 1 DEC $80 ;5 in the screen drawing loop, I decrease $80 to move DEC $80 ;5 the missile up and increase $80 to go down. ; we're going to do the same thing now with missile 1 ; SWCHA's got that too! Keep rolling left MISSLE1CHECK rol ; grab the next bit BMI M1LEFT ;2 LDY #$F0 ;2 STY HMM1 ;3 M1LEFT: ROL ;2 BMI M1DOWN ;2 LDY #$10 ;2 STY HMM1 ;3 M1DOWN: ROL ;2 BMI M1UP ;2 INC $81 ;5 INC $81 ;5 M1UP: ROL ;2 BMI JOYDONE ;2 DEC $81 ;5 DEC $81 ;5 JOYDONE: ;======================================= ; Collisons ;======================================= ; check for missile/missile collison lda CXPPMM ; now we've got a 1 in D7 if player 0 touches player 1 ; and a 1 in D6 if missile 0 touches missile 1 sta GRP1 ; stick it into player1's graphic to debug rol ; We want D6 from CXPPMM, so roll to the left one bit bpl noMMcol ; If D6 is switched on, our new number in the accumulator ; will be negative. So if positive, skip the bit below ; where we change the background color lda #%11111111 ; white, give or take sta COLUBK ; smack it into the background ; Note that COLUBK isn't the same as COLUPF *sigh* noMMcol: STA CXCLR ;3 Clear the collision latches. RTS ;6 I assume the HMM0 commands are self-explanatory! ;) ; SCREEN DRAW LF07D: LDA INTIM ;4 Here's the screen draw routine. BNE LF07D ;2 STA WSYNC ;3 STA VBLANK ;3 LDA #$02 ;2 STA CTRLPF ;3 LDX #$01 ;2 STA HMOVE ;3 DON'T FORGET TO HIT HMOVE!! or the object won't move ; horizontally. I might have forgotten that for a while, ; causing nearly unbearable psychological pain. LF08E: STA WSYNC ;3 INX ;2 Increase the line counter BEQ endScreen ;2 LF0B2: INX ;2 ldy #$00 txa ; get the line count in the accum sbc $80 adc #$10 bcc nextCheck ldy #$02 nextCheck sty ENAM0 ldy #$00 txa sbc $81 adc #$10 bcc beyondThis ldy #$02 beyondThis sty ENAM1 CPX #$C1 ;2 BEQ endScreen STA WSYNC ;3 looks like I was missing this line JMP LF0B2 ;2 ; Clean everything out and skip on out of the endScreen: LDA #$02 ;2 STA WSYNC ;3 STA VBLANK ;3 LDY #$00 ;2 STY PF0 ;3 STY PF1 ;3 STY PF1 ;3 STY GRP0 ;3 STY GRP1 ;3 STY ENAM0 ;3 STY ENAM1 ;3 STY ENABL ;3 RTS ;6 LF0D0: LDX #$1E ;2 LF0D2: STA WSYNC ;3 DEX ;2 BNE LF0D2 ;2 RTS ;6 LF0D8: LDA #$00 ;2 STA $90 ;3 RTS ;6 org $FFFC .word START .word START
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [stella] Marble Craze v0.90, Albert Yarusso - Ata | Thread | Re: [stella] Reverse Adventure (for, Gonzalo Fernández |
Re: [stella] Fishing for comments, Andrew Davie | Date | Re: [stella] Reverse Adventure (for, Gonzalo Fernández |
Month |