Posted Sun Mar 29, 2009 3:45 PM
Posted Sun Mar 29, 2009 3:48 PM
MAC READ_PADDLE_1 lda INPT0 ; 3 - always 9 bpl .save ; 2 3 .byte $2c ; 4 0 .save sty Paddle1 ; 0 3 ENDM MAC READ_PADDLE_2 lda INPT1 ; 3 - always 9 bpl .save ; 2 3 .byte $2c ; 4 0 .save sty Paddle2 ; 0 3 ENDM
Edited by Wickeycolumbus, Sun Mar 29, 2009 3:52 PM.
Posted Sun Mar 29, 2009 5:03 PM
Wickeycolumbus, on Sun Mar 29, 2009 1:48 PM, said:
Posted Sun Mar 29, 2009 5:16 PM
Posted Mon Mar 30, 2009 9:07 AM
Wickeycolumbus, on Sun Mar 29, 2009 4:48 PM, said:
MAC READ_PADDLE_1 lda INPT0; 3 - always 9 bpl .save; 2 3 .byte $2c; 4 0 .save sty Paddle1 ; 0 3 ENDM MAC READ_PADDLE_2 lda INPT1; 3 - always 9 bpl .save; 2 3 .byte $2c; 4 0 .save sty Paddle2 ; 0 3 ENDM
Posted Mon Mar 30, 2009 9:43 AM
Edited by SpiceWare, Mon Mar 30, 2009 9:45 AM.
Posted Mon Mar 30, 2009 10:02 AM
processor 6502 ; Then we have to include the "vcs.h" file ; that includes all the "convenience names" ; for all the special atari memory locations... include "vcs.h" include "macro.h" ;************************************************************************** SEG.U vars ; tells dasm that the proceding instructions are variable declarations ORG $80 ; tells dasm to start placing our variables in memory location 0080 missile0x = $80 ; player0's x position missile0y = $81 ; player0's y position visiblemissile0line = $82 ; current visible line for player 0 missile1x = $83 ; player0's x position missile1y = $84 ; player0's y position visiblemissile1line = $85 ; current visible line for player 0 ballx = $86 ; ball's x position bally = $87 ; ball's y position ballvx = $88 ; ball's x velocity ballvy = $89 ; ball's y velocity visibleballline = $8a ; line where ball is drawn leftplayerscore = $8b ; left player's score rightplayerscore = $8c ; right player's score SEG code ; tell DASM where in the memory to place ; all the code that follows...$F000 is the preferred ; spot where it goes to make an atari program ORG $F800 ; we'll call the start of our program "Start". Start sei ; Disable Any Interrupts cld ; Clear BCD math bit. ldx #$FF ; put X to the top... txs ; ...and use it reset the stack pointer ; Clear RAM and all TIA registers lda #0 ; Put Zero into A, X is at $FF Clear sta 0,x ; Now, this doesn't mean what you think... dex ; decrement X (decrease X by one) bne Clear ; if the last command resulted in something ; that's "N"ot "Equal" to Zero, branch back ; to "Clear" ;--------------------- ; One Time Initiations lda #$00 sta COLUBK ; set the background color to black lda #$0F sta COLUPF ; set the playfield color to white sta COLUP0 ; set player 0's color to white sta COLUP1 ; set player 1's color to white lda #%00100001 ; turn on playfield reflections and make the ball 4 ticks wide sta CTRLPF lda #%00010000 sta NUSIZ0 ; set player 0 width to 4 ticks wide sta NUSIZ1 ; set player 1 width to 4 ticks wide ;--------------------- ; Start New Game StartNewGame lda #2 sta missile0x ; player0's initial x position lda #150 sta missile1x ; player1's initial x position lda #95 sta missile0y ; player0's initial y position sta missile1y ; player1's initial y position sta bally ; ball's initial y position lda #75 sta ballx ; ball's initial x position lda #0 sta leftplayerscore ; set the left player's score to 0 sta rightplayerscore ; set the right player's score to 0 GameLoop ;*********************** VERTICAL SYNC HANDLER lda #$82 sta VBLANK ; perform a vertical blank and discharge the caps ; on the paddle controllers lda #2 sta VSYNC ; Sync it up you damn dirty television! ; and that vsync on needs to be held for three scanlines... ; count with me here, sta WSYNC ; one... (our program waited for the first scanline to finish...) sta WSYNC ; two... sta WSYNC ; three... lda #43 ;load 43 (decimal) in the accumulator sta TIM64T ;and store that in the timer lda #0 ; Zero out the VSYNC sta VSYNC ; cause that time is over ;*************************** Paddle Input ; Here we check for left and right paddle ; paddle controller input and check if ; the reset game switch is depressed lda #%00000001 ; a 0 in bit D0 means the reset switch was pressed bit SWCHB ; was the reset switch pressed? bne SkipResetSwitchPressed; if bit D0 isn't equal to 0 then jump to SkipResetSwitchPressed jmp StartNewGame ; if it was then start a new game SkipResetSwitchPressed lda missile0x ; load the millile 0's position into the accumulator ldx #2 ; set the sprite to be positioned as missile 0 jsr PositionSprite ; jump to our Position Sprite Subroutine to position player 0 sta WSYNC ; wait for sync lda ballx ; load the ball's x position into the acumulator ldx #4 ; set the sprite to be positioned to ball jsr PositionSprite ; jump to our Position Sprite Subroutine to position ball sta WSYNC ;wait for sync lda missile1x ; load player 1's x position into the accumulator ldx #3 ; set the sprite to be positioned as missile 1 jsr PositionSprite ; jump to our Position Sprite Subroutine to position player 1 ButtonNotPressed ;*********************** VERTICAL BLANK WAIT-ER WaitForVblankEnd lda INTIM ; load timer... bne WaitForVblankEnd ; killing time if the timer's not yet zero ldy #191 ; Y is going to hold how many lines we have to do ; ...we're going to count scanlines here. theoretically ; since this example is ass simple, we could just repeat ; the timer trick, but often its important to know ; just what scan line we're at. sta WSYNC ; We do a WSYNC just before that so we don't turn on sta VBLANK ; End the VBLANK period with the zero and start charging ; the paddle controllers capasitors ;*********************** Scan line Loop ScanLoop lda INPT0 ; read the charge from the first paddle controller bmi paddle0 ; if paddle 0 is charged .byte $2c ; paddle 0 wasn't charged so waste 2 cycles paddle0 sty missile0y ; then set player 0's y position ; based on it's readout lda INPT1 ; read the charge from the first paddle controller bmi paddle1 ; if paddle 1 is charged .byte $2c ; paddle 1 wasn't charged so waste 2 cycles paddle1 sty missile1y ; then set player 1's y position ; based on it's readout lda #2 sta WSYNC ; Wait for the previous line to finish cpy missile0y ; is Missile 0's y position the same as the current scanline? bne SkipActivateMissile0; if it isn't then don't set Missile 0's visible lines lda #20 ; otherwise set Missile 0's visible lines to 20 sta visiblemissile0line ; and store it in the visiblemissile0line SkipActivateMissile0 lda visiblemissile0line ; if the visiblemissile0line is zero beq FinishMissile0 ; don't draw Missile 0 lda #2 ; otherwise set the accumulator to 2 dec visiblemissile0line ; and decrement the visiblemissile0line by 1 FinishMissile0 sta ENAM0 ; enable/disable Missile 0 ; if the visiblemissile0line is non zero, ; we're drawing it cpy bally ; is ball's y position the same as the current scanline? bne SkipActivateBall ; if it isn't then don't set ball's visible lines lda #8 ; otherwise set the ball's visible lines to 4 sta visibleballline ; and store it in the visibleballline SkipActivateBall lda visibleballline ; if the visibleballline is zero beq FinishBall ; don't draw the ball lda #2 ; otherwise set the accumulator to 2 dec visibleballline ; and decrement the visibleballline by 1 FinishBall sta ENABL ; enable/disable the ball ; if visibleballline is non, zero, ; we're drawing it cpy missile1y ; is Missile 1's y position the same as the current scanline? bne SkipActivateMissile1; if it isn't then don't set Missile 1's visible lines lda #20 ; otherwise set Missile 1's visible lines to 20 sta visiblemissile1line ; and store it in the visiblemissile1line SkipActivateMissile1 lda visiblemissile1line ; if the visibleballline is zero beq FinishMissile1 ; don't draw Missile 1 lda #2 ; otherwise set the accumulator to 2 dec visiblemissile1line ; and decrement the visiblemissile1line by 1 FinishMissile1 sta ENAM1 ; enable/disable Missile 1 ; if the visibleballline is non zero, ; we're drawing it dey ; subtract one off the line counter thingy bne ScanLoop ; and repeat if we're not finished with all the scanlines. lda #2 ;#2 for the VBLANK... sta WSYNC ;Finish this final scanline. lda #$82 ;sta VBLANK ; Make TIA output invisible for the overscan, ; (and keep it that way for the vsync and vblank) ;***************************** OVERSCAN CALCULATIONS ;I'm just gonna count off the 30 lines of the overscan. ;You could do more program code if you wanted to. ldx #30 ;store 30 OverScanWait sta WSYNC ; wait for VSync dex ; decrement the x register bne OverScanWait ; if it hasn't been 30 scanlines jump to OverScanWait jmp GameLoop ;Continue this loop forver! Back to the code for the vsync etc PositionSprite sta HMCLR sec sta WSYNC PositionSpriteLoop sbc #15 bcs PositionSpriteLoop eor #7 asl asl asl asl sta.wx HMP0,X sta RESP0,X sta WSYNC sta HMOVE rts ;************************************************************************* ; Interrupt Vectors ORG $FFFA InterruptVectors .word Start ; NMI .word Start ; RESET .word Start ; IRQI removed the last VBLANK from my previous code and still am having problems. Any ideas?
Posted Mon Mar 30, 2009 12:50 PM
Posted Mon Mar 30, 2009 3:30 PM
ScanLoop ; this tag is reached @50/80 cycles.
lda INPT0 ;3 @53/83 read the charge from the first paddle controller
bmi paddle0 ;2 @55/85 if paddle 0 is charged
.byte $2c ;4 @59/89 paddle 0 wasn't charged so waste 2 cycles
paddle0
sty missile0y ;3 @59/89 then set player 0's y position
; based on it's readout
lda INPT1 ;3 @62/92 read the charge from the first paddle controller
bmi paddle1 ;2 @64/94 if paddle 1 is charged
.byte $2c ;4 @68/98 paddle 1 wasn't charged so waste 2 cycles
paddle1
sty missile1y ;3 @68/98 then set player 1's y position
; based on it's readout
lda #2 ;2 @70/100!
sta WSYNC ;Wait for the previous line to finish
;--------------------------
cpy missile0y ;3 @3 is Missile 0's y position the same as the current scanline?
bne SkipActivateMissile0 ;2 @5 if it isn't then don't set Missile 0's visible lines
lda #20 ;2 @7 otherwise set Missile 0's visible lines to 20
sta visiblemissile0line ;3 @10 and store it in the visiblemissile0line
SkipActivateMissile0
lda visiblemissile0line ;3 @9/13 if the visiblemissile0line is zero
beq FinishMissile0 ;2 @11/15 don't draw Missile 0
lda #2 ;2 @13/17 otherwise set the accumulator to 2
dec visiblemissile0line ;5 @18/22 and decrement the visiblemissile0line by 1
FinishMissile0
sta ENAM0 ;3 @15/25 enable/disable Missile 0
; if the visiblemissile0line is non zero,
; we're drawing it
cpy bally ;3 @18/28 is ball's y position the same as the current scanline?
bne SkipActivateBall ;2 @20/30 if it isn't then don't set ball's visible lines
lda #8 ;2 @22/32 otherwise set the ball's visible lines to 4
sta visibleballline ;3 @25/35 and store it in the visibleballline
SkipActivateBall
lda visibleballline ;3 @24/38 if the visibleballline is zero
beq FinishBall ;2 @26/40 don't draw the ball
lda #2 ;2 @28/42 otherwise set the accumulator to 2
dec visibleballline ;5 @33/47 and decrement the visibleballline by 1
FinishBall
sta ENABL ;3 @30/50 enable/disable the ball
; if visibleballline is non, zero,
; we're drawing it
cpy missile1y ;3 @33/53 is Missile 1's y position the same as current scanline?
bne SkipActivateMissile1 ;2 @35/55 if it isn't then don't set Missile 1's visible lines
lda #20 ;2 @37/57 otherwise set Missile 1's visible lines to 20
sta visiblemissile1line ;3 @40/60 and store it in the visiblemissile1line
SkipActivateMissile1
lda visiblemissile1line ;3 @39/63 if the visibleballline is zero
beq FinishMissile1 ;2 @41/65 don't draw Missile 1
lda #2 ;2 @43/67 otherwise set the accumulator to 2
dec visiblemissile1line ;5 @48/72 and decrement the visiblemissile1line by 1
FinishMissile1
sta ENAM1 ;3 @45/75 enable/disable Missile 1
; if the visibleballline is non zero,
; we're drawing it
dey ;2 @47/77 subtract one off the line counter thingy
bne ScanLoop ;2 @49/79 and repeat if we're not finished with all the scanlines.
Posted Tue Mar 31, 2009 12:46 AM
MAC READ_PADDLE_1 lda INPT0 ; 3 - always 8 bmi .save+1 ; 2/3 .save sty paddle1 ; 3/2 ENDM
Posted Tue Mar 31, 2009 1:59 PM
Thomas Jentzsch, on Tue Mar 31, 2009 2:46 AM, said:
MAC READ_PADDLE_1 lda INPT0 ; 3 - always 8 bmi .save+1; 2/3 .save sty paddle1; 3/2 ENDM
Edited by Wickeycolumbus, Tue Mar 31, 2009 2:00 PM.
0 members, 0 guests, 0 anonymous users