tschak909 Posted June 5, 2016 Share Posted June 5, 2016 Hey guys, finally have a working kernel for Dodgeball. The motion of the players seems smooth enough, missiles I can't obviously vdel, ball I can...how should I go about implementing the vdel toggle on the ball? and is there a way to make the missiles not jump...so much? I know part of it has to do with the fact that I'm quantising to 4 byte increments so that I can get the missiles/ball big enough, but... hum.... Ideas? Code: ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;; Scratchpad to test ideas. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROCESSOR 6502 include vcs.h include macro.h SEG.U VARS ORG $80 ScanLine: ds 1 ; scanline counter PlayerY0: ds 1 ; Player Y0 PlayerY1: ds 1 ; Player Y1 BallY0: ds 1 ; ball y0 BallY1: ds 1 ; missile y0 BallY2: ds 1 ; missile y1 Score: ds 1 ; Score Timer: ds 1 ; Timer DigitOnes: ds 2 ; Player 0 and 1 digit graphics DigitTens: ds 2 ; Player 0 and 1 digit graphics ScoreGfx: ds 1 ; pointers TimerGfx: ds 1 ; pointers Temp: ds 1 ; Temp TempStackPtr: ds 1 ; Temporary Stack Pointer SEG CODE ORG $F800 ColdStart: CLEAN_START lda #$32 sta PlayerY0 sta RESM0 lda #$50 sta PlayerY1 lda #$80 sta BallY0 lda #$90 sta BallY1 lda #$A0 sta BallY2 sta RESBL sta RESM1 lda #$10 sta NUSIZ0 sta NUSIZ1 MainLoop: jsr VerticalSync jsr VerticalBlank jsr Kernel jsr OverScan jmp MainLoop VerticalSync: lda #$02 ; Get ready to start VSYNC ldx #45 sta WSYNC ; Next line sta VSYNC ; Start VSYNC stx TIM64T sta CTRLPF sta WSYNC sta WSYNC lda #$00 sta PF0 sta PF1 sta PF2 sta WSYNC sta VSYNC Sleep12: rts VerticalBlank: jsr ProcessSwitches jsr SetTIA jsr PrepScoreForDisplay rts ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;; Kernel ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Kernel: lda INTIM bne Kernel sta VBLANK lda #$20 sta ScanLine sta WSYNC sta HMOVE TSX ; Grab stack ptr STX TempStackPtr ; put stack ptr into variable to restore at kernel end ;; ;; two digit score ;; ldx #5 ScoreLoop: ldy DigitTens lda DigitGfx,y and #$f0 sta ScoreGfx ldy DigitOnes lda DigitGfx,y and #$0F ora ScoreGfx sta ScoreGfx sta WSYNC ;; sta PF1 ldy DigitTens+1 lda DigitGfx,y and #$F0 sta TimerGfx ldy DigitOnes+1 lda DigitGfx,y and #$0F ora TimerGfx sta TimerGfx jsr Sleep12 sta PF1 ldy ScoreGfx sta WSYNC sty PF1 inc DigitTens inc DigitTens+1 inc DigitOnes inc DigitOnes+1 jsr Sleep12 dex sta PF1 bne ScoreLoop sta WSYNC lda #$00 sta PF0 sta PF1 sta PF2 sta WSYNC sta WSYNC lda #$15 sta CTRLPF ;; ;; top border ;; ldx #$07 lda #$F0 ldy #$FF sta PF0 sty PF1 sty PF2 toploop: sta WSYNC dex bne toploop lda #$10 sta PF0 lda #$00 sta PF1 sta PF2 lda #$20 sta ScanLine sta WSYNC ;; ;; 174 ;; vfield: ldx #$1F txs sec lda PlayerY0 sbc ScanLine and #$FE tax and #$F0 beq vdotank lda #$00 beq vnotank vdotank: lda PLAYER,X vnotank: sta WSYNC STA GRP0 lda BallY2 eor ScanLine and #$FC php lda BallY1 eor ScanLine and #$FC php lda BallY0 eor ScanLine and #$FC php lda ScanLine bpl vvrefl eor #$F8 vvrefl: cmp #$20 bcc vfdone lsr lsr lsr tay vfdone: lda PlayerY1 sec sbc ScanLine inc ScanLine nop ora #$01 tax ;; and #$F0 beq vdot1 lda #$00 beq vnot1 vdot1: lda PLAYER,X vnot1: sta GRP1 lda PF1_0,Y sta PF1 lda PF2_0,Y sta PF2 inc ScanLine lda ScanLine eor #$CE bne vfield ;; ;; bottom border ;; ldx #$08 lda #$F0 ldy #$FF sta PF0 sty PF1 sty PF2 botloop: sta WSYNC dex bne botloop kernel_cleanup: lda #$F0 sta HMP0 sta HMP1 sta HMM0 sta HMM1 sta HMBL ldx TempStackPtr txs sta WSYNC lda #$00 rts OverScan: sta WSYNC lda #2 sta VBLANK lda #22 sta TIM64T OSWait: sta WSYNC lda INTIM bne OSWait rts ProcessSwitches: lda SWCHB lsr bcs NoNuGam sta RESP0 NoNuGam: rts SetTIA: ldx #3 ldy #3 lda SWCHB and #$08 bne SOCloop ldy #7 SOCloop: lda Colors,Y sta COLUP0,x dey dex bpl SOCloop setvals: clc lda BallY0 adc #$01 sta BallY0 sec lda BallY1 sbc #$01 sta BallY1 clc lda BallY2 adc #$01 sta BallY2 sec lda PlayerY0 sbc #$01 sta PlayerY0 clc lda PlayerY1 adc #$01 sta PlayerY1 rts PrepScoreForDisplay: inc Timer bne PSFDskip inc Score PSFDskip: ldx #1 PSFDloop: lda Score,X and #$0F sta Temp asl asl adc Temp sta DigitOnes,x lda Score,x and #$F0 lsr lsr sta Temp lsr lsr adc Temp sta DigitTens,x dex bpl PSFDloop rts Colors: .byte $DA .byte $8A .byte $0E .byte $32 .byte $0e .byte $00 .byte $08 .byte $04 align 256 PF1_0 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $38 .byte $00 .byte $00 .byte $00 .byte $60 .byte $20 .byte $20 .byte $23 PF2_0 .byte $00 .byte $00 .byte $00 .byte $00 .byte $80 .byte $80 .byte $00 .byte $00 .byte $00 .byte $1C .byte $04 .byte $00 .byte $00 .byte $00 .byte $00 PLAYER: .byte $00 .byte $00 .byte $00 .byte $00 .byte $3C .byte $3C .byte $3C .byte $3C .byte $3C .byte $3C .byte $3C .byte $3C .byte $00 .byte $00 .byte $00 .byte $00 DigitGfx: .byte %01110111 .byte %01010101 .byte %01010101 .byte %01010101 .byte %01110111 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %01110111 .byte %00010001 .byte %01110111 .byte %01000100 .byte %01110111 .byte %01110111 .byte %00010001 .byte %00110011 .byte %00010001 .byte %01110111 .byte %01010101 .byte %01010101 .byte %01110111 .byte %00010001 .byte %00010001 .byte %01110111 .byte %01000100 .byte %01110111 .byte %00010001 .byte %01110111 .byte %01110111 .byte %01000100 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01110111 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01110111 .byte %01010101 .byte %01110111 .byte %00010001 .byte %01110111 .byte %00100010 .byte %01010101 .byte %01110111 .byte %01010101 .byte %01010101 .byte %01100110 .byte %01010101 .byte %01100110 .byte %01010101 .byte %01100110 .byte %00110011 .byte %01000100 .byte %01000100 .byte %01000100 .byte %00110011 .byte %01100110 .byte %01010101 .byte %01010101 .byte %01010101 .byte %01100110 .byte %01110111 .byte %01000100 .byte %01100110 .byte %01000100 .byte %01110111 .byte %01110111 .byte %01000100 .byte %01100110 .byte %01000100 .byte %01000100 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;; Function to check for free space at end of cart. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; echo "------", [$FFFA - *]d, "bytes free before End of Cartridge" ORG $FFFA .WORD ColdStart .WORD ColdStart .WORD ColdStart Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 5, 2016 Share Posted June 5, 2016 You can attach ASM files to posts, easier than having to copy/paste the text. scratchpad.asm Add something like this after you've updated the Y values: lda BallY2 lsr sta VDELBL It makes it smoother, but not totally. I suspect it's clashing a bit with your quantizing. Minor change to VerticalSync to stop the lines in the score: lda #$00 ; 2 2 ; use idle time to blank out objects sta GRP1 ; 3 5 ; so no more "wrap around" thru the score sta GRP0 ; 3 8 sta ENABL ; 3 11 sta ENAM0 ; 3 14 sta ENAM1 ; 3 17 sta GRP1 ; 3 20 - yep, twice - this makes sure GRP0 and ENABL are ; zeroed if VDELP0 or VDELBL are on sta PF0 ; 3 23 sta PF1 ; 3 26 sta PF2 ; 3 29 sta WSYNC ; 3 32 Don't forget to cycle count your Kernel. Also when using tricks to update registers it's best to document them - loading X with ENABL, instead of $1F, makes it easier to keep track of what you're doing: vfield: ldx #ENABL txs ... php ; this updates ENABL ... php ; this updates ENAM1 ... php ; this updates ENAM0 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted June 5, 2016 Author Share Posted June 5, 2016 Thanks, as always. I had to quantise to 4 scanlines in order to get the ball size correct, is there a better way to do this ? -Thom Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 5, 2016 Share Posted June 5, 2016 See supercat's suggestion here in this blog entry, then the implementation in this blog entry. Basically you'll end up with 2 Y values for each ball. To use them you'll copy/paste your 2LK, turning it into a 4LK, and revise it so that the original 2LK uses one set of Y values and the cloned 2LK uses the other. I'm using subpixel positioning in Medieval Mayhem so my program uses this to keep track of location. M0yPosLow ds 1 M1yPosLow ds 1 BLyPosLow ds 1 M0yPosHigh ds 1 M1yPosHigh ds 1 BLyPosHigh ds 1 And then converts those values into these for Kernel use: M0yEvenRow ds 1 M1yEvenRow ds 1 BLyEvenRow ds 1 M0yOddRow ds 1 M1yOddRow ds 1 BLyOddRow ds 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted June 5, 2016 Author Share Posted June 5, 2016 iiinteresting... -Thom 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.