|
Subject: [stella] Gunfight 2600: Little progress... From: Manuel Polik <manuel.polik@xxxxxxxxxxx> Date: Fri, 09 Mar 2001 09:53:29 +0100 |
Hi there! Here's the next little step of Gunfight 2600: After I talked everybody into giving me 9 bullets, I started with a version that let's the bullets bounce from the borders, then, seeing the output and watching it for two minutes I halfway got a headache :-) I subsequently dumped all that & restarted with 6 bullets. Fine result now, don't you agree? (Ok, it's the death of the 3-way shot, maybe of 2-way too, but why forcing it, when the little VCS such isn't capable enough) BTW: The older two test versions crashed the StellaX emulator with various effects when positioning objects on coordinates <0 or >160. At least I _assume_ that this was the reason, not quite sure here. Now I really wonder how these two old versions behaved on the real thing? Worked like on Z26, crashed like StellaX or ??? Hope you like the new BIN, it's a funny demo, isn't it? Greetings, Manuel
Attachment:
gunfight.bin
Description: Binary data
processor 6502
include vcs.h
SCREENSTART = $60
UP = SCREENSTART
DOWN = $00
LEFT = $00
RIGHT = $A0
SEG.U vars
org $80
horPosP0 ds 1 ; Horizontal position player 0
horPosP1 ds 1 ; Horizontal position player 1
horPosM0 ds 1 ; Horizontal position missile 0
horPosM1 ds 1 ; Horizontal position missile 1
horPosBL ds 1 ; Horizontal position ball
verPosP0 ds 1 ; Vertical position player 0
verPosP1 ds 1 ; Vertical position player 1
verPosM0 ds 1 ; Vertical position missile 0
verPosM1 ds 1 ; Vertical position missile 1
verPosBL ds 1 ; Vertical position ball
frameCounter ds 1 ;
colorBuffer ds 2 ; Buffer player colors temporary
hairBuffer ds 2 ; Buffer player haircolor permanent
playerShapePtr00 ds 2 ; Pointer to current player 0 shape in the ROM
playerShapePtr01 ds 2 ; Pointer to current player 1 shape in the ROM
animCounter ds 2 ; Simple frameCounters, one for each player
playerMovement ds 2 ; backup the Joystick readings for each player
rnd ds 2 ; random
bulletHorPos ds 6 ; X Koordinates of the bullets
bulletVerPos ds 6 ; Y Koordinates of the bullets
bulletData ds 6 ; Direction & other Data of the bullets
playerShape00 ds 11 ; Player 0 shape complete in the RAM
playerShape01 ds 11 ; Player 1 shape complete in the RAM
colorShape00 ds 11 ; Player 0 colors complete in the RAM
colorShape01 ds 11 ; Player 1 colors complete in the RAM
SEG code
org $F000
start SEI
CLD
LDX #$FF
TXS
LDA #$00
zero STA $00,X ;zero out the machine
DEX
BNE zero
LDA #$30 ;set up the starting vertical pos
STA verPosP0
STA verPosP1
LDA #$25
STA verPosM0
STA verPosM1
STA verPosBL
LDA #$18
STA horPosP0
LDA #$90
STA horPosP1
LDA #$1C
STA COLUBK
LDA #$01
STA CTRLPF
LDA #<cbup00
sta playerShapePtr00
sta playerShapePtr01
LDA #>cbup00
sta playerShapePtr00+1
sta playerShapePtr01+1
LDA #$3C
STA hairBuffer
STA hairBuffer+1
LDX #$0A
ResetPlayers LDA cbup00,X
STA playerShape00,X
STA playerShape01,X
LDA colordata,X
STA colorShape00,X
LDA colordata2,X
STA colorShape01,X
DEX
BPL ResetPlayers
LDA menwithouthats
STA playerShape01+9
LDA menwithouthats+1
STA playerShape01+10
LDA #$F4
STA colorShape01+9
; Testing Code...
LDX #$05
BulletSpread JSR Random
JSR Random
JSR Random
AND #$3E
STA bulletHorPos,X
JSR Random
JSR Random
JSR Random
AND #$3F
STA bulletVerPos,X
TXA
ASL
TAY
STY bulletData,X
DEX
BPL BulletSpread
LDA #$01
STA VDELP0
MainLoop JSR VerticalSync ;
JSR VerticalBlank ;
JMP MainScreen ; The mainscreen must be no sub!
; Here we're in the vertical sync, it animates the cowboys, too!
; Manuels Reminder: There's 20 cycles left before the RTS...
VerticalSync LDA #$02 ;
STA WSYNC ; Finish current line
STA VSYNC ; start vertical sync
LDY #$06
AnimateCowboys LDA (playerShapePtr01),Y
STA playerShape01,Y
LDA (playerShapePtr00),Y
STA playerShape00,Y
TYA ; A needs to be zero at the end
DEY
BPL AnimateCowboys
RTS
; Here we're in the vertical blank!
VerticalBlank STA WSYNC ; Finish current line
STA VSYNC ; Stop vertical sync
LDA #$2B ;
STA TIM64T ; Init timer
; Move bullets
LDX #$05
BulletMove
LDA bulletData,X
LSR
BCC DoVertical
LSR
LSR
JMP SkipVertical ; Maybe BCS later...
DoVertical LSR
BCS vertIncrement
DEC bulletVerPos,X
LSR
BCC SkipVertical
DEC bulletVerPos,X
JMP SkipVertical ; Maybe BCS later...
vertIncrement
INC bulletVerPos,X
LSR
BCC SkipVertical
INC bulletVerPos,X
SkipVertical LSR
BCS HorzIncrement
DEC bulletHorPos,X
LSR
BCC SkipHorizontal
DEC bulletHorPos,X
JMP SkipVertical ; Maybe BCS later...
HorzIncrement
INC bulletHorPos,X
LSR
BCC SkipHorizontal
INC bulletHorPos,X
SkipHorizontal
; Bounce bullets
LDA bulletData,X
LDY bulletVerPos,X
BPL BulletDownOK
ORA #%00000010
BulletDownOK
CPY #UP
BMI BulletUpOK
AND #%11111101
BulletUpOK
LDY bulletHorPos,X
BNE BulletLeftOK
ORA #%00001000
BulletLeftOK
CPY #RIGHT
BNE BulletRightOK
AND #%11110111
BulletRightOK
STA bulletData,X
DEX
BPL BulletMove
; Copy the right bulletdtata to the actual used bullet pointers.
INC frameCounter
LDA frameCounter
AND #$01
TAY
LDX bulletaccesstab,Y
LDY #$02
CopyNextBullet LDA bulletHorPos,X
STA horPosM0,Y
LDA bulletVerPos,X
STA verPosM0,Y
INX
DEY
BPL CopyNextBullet
; Position all objects
LDY #$04
PosAnother LDX horPosP0,Y ;
JSR PosPlayer
DEY
BPL PosAnother
STA WSYNC ; Finish current line
STA HMOVE
LDY #SCREENSTART ; Init display Kernel
WaitIntimReady LDA INTIM ; finish vertical blank
BNE WaitIntimReady ;
RTS
SkipDraw
NOP
SEC
LDA VSYNC
LDA #$00
BEQ Continue
SkipDraw2
NOP
SEC
LDA VSYNC
LDA #$00
BEQ Continue2
MainScreen STA WSYNC ; Finish current line
STA VBLANK ; Stop vertical blank
NextLine LDX #$1F
TXS
TYA
STA WSYNC
CPY verPosBL
PHP
CPY verPosM1
PHP
CPY verPosM0
PHP
SEC
SBC verPosP0 ;
ADC #$0B
BCC SkipDraw
TAX
LDA colorShape00,X
STA colorBuffer
LDA playerShape00,X ;
Continue
STA GRP0
TYA
SBC verPosP1 ;
ADC #$0B
BCC SkipDraw2
TAX
LDA colorShape01,X
STA colorBuffer+1
LDA playerShape01,X ;
Continue2
LDX colorBuffer
; STY PF2
NOP
STA WSYNC
STA GRP1
STX COLUP0
LDA colorBuffer+1
STA COLUP1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DEY
BNE NextLine
; Ok, screen is drawn, now start the overscan & blank the screen
LDX #$FF
TXS
STA WSYNC
LDA #$02 ;
STA VBLANK ; Start vertical blank
LDA #$23 ;
STA TIM64T ; Init timer
; We're in the overscan now...
JSR joy ; Read the joysticks.
; After we read the joysticks, animate!
LDX #$01
AnimPlayer LDA playerMovement,X
EOR #$FF
AND #$0F
BEQ NoAnim
LDY #$3C ; Assume No Hair
CMP #$01
BNE HairsOk
LDY haircolors,X ; Load Hair
HairsOk STY hairBuffer,X
AND #$0F
BEQ NoAnim
ASL
ASL
STA playerMovement,X
INC animCounter,X
LDA animCounter,X
AND #$18
LSR
LSR
LSR
ADC playerMovement,X
TAY
TXA
ASL
TAX
LDA cowboyWalk,Y
STA playerShapePtr00,X
TXA
LSR
TAX
NoAnim DEX
BPL AnimPlayer
LDA hairBuffer
STA colorShape00+8
LDA hairBuffer+1
STA colorShape01+8
JSR WaitIntimReady
JMP MainLoop
joy LDA SWCHA
LDX INPT4
BMI NoButton1
TAY
EOR #$FF
LSR
LSR
LSR
LSR
TAX
AND #$08
BEQ NoButton05
LDA cowboyShoot,X
STA playerShapePtr00
LDA #$00
STA REFP0
LDA #$3C
STA hairBuffer
TYA
ORA #$F0
BNE NoButton1
NoButton05 TYA
NoButton1 LDX INPT5
BMI NoButton2
TAY
EOR #$FF
AND #$0F
TAX
AND #$04
BEQ NoButton15
LDA cowboyShoot,X
STA playerShapePtr01
LDA #$08
STA REFP1
LDA #$3C
STA hairBuffer+1
TYA
ORA #$0F
BNE NoButton2
NoButton15 TYA
NoButton2 LDX #$01
JoyPlayer2
STA playerMovement,X
LSR
TAY
BCC up
UpDone TYA
LSR
TAY
BCC down
DownDone TYA
LSR
TAY
BCC left
LeftDone TYA
LSR
TAY
BCC right
RightDone TYA
DEX
BPL JoyPlayer2
RTS
right INC horPosP0,X
LDA horPosP0,X
CMP rightrestriction,X
BNE HorPosOK
DEC horPosP0,X
LDA playerMovement,X
ORA #$08
STA playerMovement,X
HorPosOK LDA #$00
STA REFP0,X
JMP RightDone
left DEC horPosP0,X
LDA horPosP0,X
CMP leftrestriction,X
BNE HorPosOK2
INC horPosP0,X
LDA playerMovement,X
ORA #$04
STA playerMovement,X
HorPosOK2 LDA #$08
STA REFP0,X
JMP LeftDone
up INC verPosP0,X
LDA verPosP0,X
CMP #SCREENSTART+2
BNE VerPosOk
DEC verPosP0,X
LDA playerMovement,X
ORA #$01
STA playerMovement,X
VerPosOk JMP UpDone
down DEC verPosP0,X
LDA verPosP0,X
CMP #$0C
BNE VerPosOk2
INC verPosP0,X
LDA playerMovement,X
ORA #$02
STA playerMovement,X
VerPosOk2 JMP DownDone
PosPlayer
sta WSYNC ;begin scanline
lda HorzTable,X ;+4 7
sta HMP0,Y ;+3 10
and #$0F ;+2 12
tax ;+2 14
P0 dex ;+2 16
bpl P0 ;
sta RESP0,Y ;
rts
Random
lda rnd
lsr
lsr
sbc rnd
lsr
ror rnd+1
ror rnd
ror rnd
lda rnd
rts
cowboyWalk
.byte #<cbup01,#<cbup00,#<cbup01,#<cbup02 ; DummyLine
.byte #<cbup01,#<cbup00,#<cbup01,#<cbup02 ; Up
.byte #<cbup01,#<cbup00,#<cbup01,#<cbup02 ; Down
.byte #<cbup01,#<cbup00,#<cbup01,#<cbup02 ; DummyLine
.byte #<cblt01,#<cblt00,#<cblt01,#<cblt02 ; Left
.byte #<cblu01,#<cblu00,#<cblu01,#<cblu02 ; Left-Up
.byte #<cbld01,#<cbld00,#<cbld01,#<cbld02 ; Left-Down
.byte #<cbup01,#<cbup00,#<cbup01,#<cbup02 ; DummyLine
.byte #<cblt01,#<cblt00,#<cblt01,#<cblt02 ; Right
.byte #<cblu01,#<cblu00,#<cblu01,#<cblu02 ; Right-Up
.byte #<cbld01,#<cbld00,#<cbld01,#<cbld02 ; Right-Down
menwithouthats
.byte %00111000
.byte %00000000
cowboyShoot
.byte #<cbup01 ; DummyLine
.byte #<cbup01 ; DummyLine
.byte #<cbup01 ; DummyLine
.byte #<cbup01 ; DummyLine
.byte #<cblt03 ; Left
.byte #<cblu03 ; Left-Up
.byte #<cbld03 ; Left-Down
.byte #<cbup01 ; DummyLine
.byte #<cblt03 ; Right
.byte #<cblu03 ; Right-Up
.byte #<cbld03 ; Right-Down
ORG $F400
cbup00
.byte %00001100
.byte %01101100
.byte %01101100
.byte %00111000
.byte %00111010
.byte %10111010
.byte %01111100
.byte %00010000
.byte %00111000
.byte %01111100
.byte %00111000
cbup01
.byte %01101100
.byte %01101100
.byte %01101100
.byte %00111000
.byte %10111010
.byte %10111010
.byte %01111100
cbup02
.byte %01100000
.byte %01101100
.byte %01101100
.byte %00111000
.byte %10111000
.byte %10111010
.byte %01111100
cblt00
.byte %11000011
.byte %11000110
.byte %01101100
.byte %00111000
.byte %10111000
.byte %10111110
.byte %01111000
cblt01
.byte %00111100
.byte %00111000
.byte %00111000
.byte %00111000
.byte %01111000
.byte %01111000
.byte %00111000
cblt02
.byte %11000011
.byte %11000110
.byte %01101100
.byte %00111000
.byte %01111000
.byte %00111100
.byte %00111000
cblt03
.byte %00111100
.byte %00111000
.byte %00111000
.byte %00111000
.byte %00111100
.byte %00111111
.byte %00111000
cbld00
.byte %11001100
.byte %11001110
.byte %01101100
.byte %00111000
.byte %01111000
.byte %11111000
.byte %01111000
cbld01
.byte %01111110
.byte %01101100
.byte %01101100
.byte %00111000
.byte %10111010
.byte %11111100
.byte %01111000
cbld02
.byte %11001100
.byte %11001110
.byte %01101100
.byte %00111000
.byte %10111100
.byte %10111111
.byte %01111100
cbld03
.byte %01111110
.byte %01101100
.byte %01101100
.byte %00111000
.byte %01111010
.byte %11111100
.byte %01111000
cblu00
.byte %11001100
.byte %11001110
.byte %01101100
.byte %00111000
.byte %00111000
.byte %01111100
.byte %01111100
cblu01
.byte %01111110
.byte %01101100
.byte %01101100
.byte %00111000
.byte %11111001
.byte %11111110
.byte %01111100
cblu02
.byte %11001100
.byte %11001110
.byte %01101100
.byte %00111000
.byte %10111000
.byte %11111110
.byte %01111100
cblu03
.byte %01111110
.byte %01101100
.byte %01101100
.byte %00111000
.byte %10111000
.byte %01111110
.byte %01111101
rightrestriction
.byte $29,$99
leftrestriction
.byte $FF,$6F
haircolors
.byte $00,$F4
bulletaccesstab
.byte $00,$03
colordata
.byte $F4
.byte $F2
.byte $F2
.byte $F0
.byte $00
.byte $00
.byte $00
.byte $3C
.byte $3C
.byte $15
.byte $17
colordata2
.byte $E4
.byte $E2
.byte $E2
.byte $E0
.byte $00
.byte $00
.byte $00
.byte $3C
.byte $3C
.byte $00
.byte $00
ORG $FF00
HorzTable ;this must not cross a page boundary
.byte $30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90
.byte $71,$61,$51,$41,$31,$21,$11,$01,$F1,$E1,$D1,$C1,$B1,$A1,$91
.byte $72,$62,$52,$42,$32,$22,$12,$02,$F2,$E2,$D2,$C2,$B2,$A2,$92
.byte $73,$63,$53,$43,$33,$23,$13,$03,$F3,$E3,$D3,$C3,$B3,$A3,$93
.byte $74,$64,$54,$44,$34,$24,$14,$04,$F4,$E4,$D4,$C4,$B4,$A4,$94
.byte $75,$65,$55,$45,$35,$25,$15,$05,$F5,$E5,$D5,$C5,$B5,$A5,$95
.byte $76,$66,$56,$46,$36,$26,$16,$06,$F6,$E6,$D6,$C6,$B6,$A6,$96
.byte $77,$67,$57,$47,$37,$27,$17,$07,$F7,$E7,$D7,$C7,$B7,$A7,$97
.byte $78,$68,$58,$48,$38,$28,$18,$08,$F8,$E8,$D8,$C8,$B8,$A8,$98
.byte $79,$69,$59,$49,$39,$29,$19,$09,$F9,$E9,$D9,$C9,$B9,$A9,$99
.byte $7A,$6A,$5A,$4A,$3A,$2A,$1A,$0A,$FA,$EA,$DA,$CA,$BA,$AA,$9A
org $FFFC
.word start
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] Turtles (was: And now,, Debro, Dennis | Thread | Re: [stella] Gunfight 2600: Little , Joe Grand |
| [stella] Turtles (was: And now, for, Kurt . Woloch | Date | [stella] Another day, another probl, Manuel Polik |
| Month |