|
Subject: [stella] Gunfight 2600: Worst Nightmare... From: Manuel Polik <manuel.polik@xxxxxxxxxxx> Date: Wed, 21 Feb 2001 16:11:07 +0100 |
Hi there! Just to show you, that I'm at least working on something, here's an update on Gunfight 2600. The kernel is now pushed to it's very limits, that means: - Two cycles left in the kernel - One cycle left in the each skipdraw branch Plus, coming to the nightmare, I'm already doing the complete kernel _without_ any STA WSYNC. Ok, I didn't play all my jokers yet and maybe I'm able to get rid of one or another CLC, SEC - or what I'm most positive about - the two EORs. I need some more cycles, in order to replace some immediate reads with variable reads here & there. Even more important - to reduce flicker later, I should somewhere be able to verify if I'm ready to reposition, which would force another... CPY line BEQ Reposition ...with 6 cycles :-) If you look carefully at the demo, you see that I already had to compromise here & there (e.g. I've redesigned the colors, so that it doesn't matter if they're shifted a line. I just can't take care of all timings anymore) and you see approximately where the cowboys are restricted to move later. That changes by the minute at the moment, so I didn't restrict the movement 100%. It's better for testing too, when the cowboys have more freedom in their movement as I allow later. I still can't tell wether the kernel will work out in the end, or if I've to do more compromises or skip some features... Comment if you like, any ideas to squeeze another cycle out of the kernel appreciated. Ok, now I'll see if these EORs can be removed. I had some reason to invert all logic here in an earlier stage, maybe the reason is gone by now :-) Greetings, Manuel
processor 6502
include vcs.h
SCREENSTART = $60
SEG.U vars
org $80
horPosP0 ds 1 ; Horizontal position
horPosP1 ds 1 ; Horizontal position
horPosM0 ds 1 ; Horizontal position
horPosM1 ds 1 ; Horizontal position
horPosBL ds 1 ; Horizontal position
verPosP0 ds 1 ; Vertical position
verPosP1 ds 1 ; Vertical position
verPosM0 ds 1 ; Vertical position
verPosM1 ds 1 ; Vertical position
verPosBL ds 1 ; Vertical position
colorpointer ds 4 ; pointer to color tables
playerpointer ds 4 ; pointer to shape tables
gunShift ds 2 ; cowboy colors
SEG code
org $F000
start SEI
CLD
LDX #$FF
TXS
LDA #$00
zero STA $00,X ;zero out the machine
DEX
BNE zero
LDA #$32 ;set up some of the variables.
STA COLUP0 ;set up sprite colour
LDA #$30 ;set up the starting vertical position of sprite
STA verPosP0
STA verPosP1
LDX #$26
STX verPosM1
STX verPosM0
STA verPosBL
LDX #$03
SetUpHorizontal LDA horpostab,X
STA horPosP0,X
DEX
BPL SetUpHorizontal
LDA #$1C
STA COLUBK
MainLoop JSR VerticalSync ;
JSR VerticalBlank ;
JMP MainScreen ; MainScreen does Overscan
VerticalSync LDA #$02 ;
STA WSYNC ; Finish current line
STA VSYNC ; start vertical sync
LDA #$03 ;
STA TIM64T ;
JMP WaitIntimReady ; Wait until vertical sync finished
VerticalBlank STA WSYNC ; Finish current line
STA VSYNC ; Stop vertical sync
LDA #$2B ;
STA TIM64T ; Init timer
; Position all objects
LDY #$04
PosAnother ldx horPosP0,Y ;+3 3
JSR PosPlayer
DEY
BPL PosAnother
STA WSYNC ; Finish current line
sta HMOVE
LDY #SCREENSTART ; Init display Kernel
LDA #$08
STA REFP1 ; Reflect Player 1
; Init pointers (yes, a very quick hack :-))
CLC
LDA #<p0data ; Init Pointers
SBC verPosP0
ADC #$13
STA playerpointer ;
LDA #>p0data ; Init Pointers
STA playerpointer+1 ;
CLC
LDA #<p0data ; Init Pointers
SBC verPosP1
ADC #$13
STA playerpointer+2 ;
LDA #>p0data ; Init Pointers
STA playerpointer+3 ;
LDA #$01
sta VDELP0
sta VDELBL
LDA #$30
sta NUSIZ0
sta NUSIZ1
STA HMCLR ; must be enough space from WSYNC!
LDA #$00
sta HMM0 ;+3 10
LDA #$00
sta HMM1 ;+3 10
LDA #$00
sta HMP1 ;+3 10
sta HMP0 ;+3 10
inc horPosBL
CLC
LDA #<colordata ; Init Pointers
SBC verPosP0
ADC #$13
STA colorpointer ;
LDA #>colordata ; Init Pointers
STA colorpointer+1 ;
CLC
LDA #<colordata2 ; Init Pointers
SBC verPosP1
ADC #$13
STA colorpointer+2 ;
LDA #>colordata2 ; Init Pointers
STA colorpointer+3 ;
WaitIntimReady LDA INTIM ; Wait until vertical blank finished
BNE WaitIntimReady ;
RTS
Waste STA WSYNC ; Waste a line
DEX ;
BNE Waste ; if X is not zero, do more lines
RTS
SkipDraw LDA #$10
STA.w gunShift+1
SEC
LDA #$00
BEQ Continue
SkipDraw2 LDA #$F0
STA.w gunShift
SEC
LDA #$00
BEQ Continue2
MainScreen STA WSYNC ; Finish current line
STA VBLANK ; Stop vertical blank
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NextLine LDX #$1F
TXS
LDX #$00
TYA
SBC verPosP0 ;
ADC #$13
STA HMOVE
BCC SkipDraw
LDA (colorpointer),Y
STA COLUP0
LDA (playerpointer),Y ;
STX COLUP1
Continue
STA GRP0 ;
TYA
SBC verPosP1 ;
ADC #$13
BCC SkipDraw2
LDA (colorpointer+2),Y
STA COLUP1
STX COLUP0
LDA (playerpointer+2),Y ;
Continue2
CPY verPosBL
PHP
NOP
STA GRP1
LDA gunShift
EOR #$F0
STA HMM0
LDA gunShift+1
EOR #$10
STA HMM1
STA HMOVE
STX COLUP1
LDA (colorpointer),Y
STA COLUP0
TYA
CLC
SBC verPosM1
AND #$FF
PHP
TYA
CLC
SBC verPosM0
AND #$FF
PHP
STX gunShift
SEC
STX gunShift+1
LDA (colorpointer+2),Y
STA COLUP1
STX COLUP0
DEY
BNE NextLine
LDX #$FF
TXS
oscan2 JSR joy ;overscan. Time to read the joysticks.
LDX #$1E
STA WSYNC
LDA #$02
STA VBLANK ; Start vertical blank
JSR Waste
JMP MainLoop ; Repeat
joy LDY #$00
LDA SWCHA
ASL
BCC right
ASL
BCC left
ASL
BCC down
ASL
BCC up
ASL
BCC right2
ASL
BCC left2
ASL
BCC down2
ASL
BCC up2
RTS
right INC horPosM1
INC horPosP0
LDA horPosP0
CMP #$31
BNE HorPosOK
DEC horPosP0
DEC horPosM1
HorPosOK rts
left DEC horPosM1
DEC horPosP0 ;set horizontal motion register to one pixel left
LDA horPosP0
CMP #$07
BNE HorPosOK2
INC horPosM1
INC horPosP0
HorPosOK2 rts
up LDA verPosP0 ;make sure we haven't gone over the top of the screen
CMP #SCREENSTART-1
BEQ NoClimb
INC verPosP0 ;if not then increase the vertical position
INC verPosM1 ;if not then increase the vertical position
NoClimb RTS
down LDA verPosP0
CMP #$15
BEQ NoSink
DEC verPosP0 ;decrease the vertical position
DEC verPosM1 ;decrease the vertical position
NoSink RTS
right2 INC horPosM0
INC horPosP1 ;set horizontal motion register to one pixel right
LDA horPosP1
CMP #$99
BNE HorPosOK3
DEC horPosM0
DEC horPosP1
HorPosOK3 rts
left2 DEC horPosP1 ;set horizontal motion register to one pixel left
DEC horPosM0
LDA horPosP1
CMP #$68
BNE HorPosOK4
INC horPosP1
INC horPosM0
HorPosOK4 rts
up2 LDA verPosP1 ;make sure we haven't gone over the top of the screen
CMP #SCREENSTART-1
BEQ NoClimb2
INC verPosP1 ;if not then increase the vertical position
INC verPosM0 ;if not then increase the vertical position
NoClimb2 RTS
down2 LDA verPosP1
CMP #$15
BEQ NoSink2
DEC verPosP1 ;decrease the vertical position
DEC verPosM0 ;decrease the vertical position
NoSink2 RTS
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 ;when branch not taken: +2 (18 + x*5)
sta RESP0,Y ;(21 + x*5)
sta WSYNC
rts
ORG $FE00
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
horpostab
.byte $18,$90,$78,$32
ORG $FF80
p0data
.byte %11101110
.byte %10001000
.byte %01001100
.byte %00100110
.byte %01111110
.byte %10111100
.byte %10111100
.byte %10111100
.byte %11111100
.byte %01111111
.byte %00111111
.byte %00011000
.byte %00111100
.byte %00111110
.byte %00110100
.byte %11111111
.byte %00111100
.byte %00101100
.byte %00101000
colordata
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $E8
.byte $E6
.byte $E4
.byte $E2
.byte $E2
.byte $E2
.byte $3E
.byte $3E
.byte $3E
.byte $00
.byte $13
.byte $15
.byte $15
.byte $17
colordata2
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $F8
.byte $F6
.byte $F4
.byte $F2
.byte $F2
.byte $F2
.byte $3E
.byte $3E
.byte $3E
.byte $00
.byte $11
.byte $12
.byte $13
.byte $14
org $FFFC
.word start
.word startAttachment:
gunfight.bin
Description: Binary data
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [stella] Gunfight 2600: It could've, Manuel Polik | Thread | Re: [stella] Gunfight 2600: Worst N, Thomas Jentzsch |
| [stella] Qb: v0.10, Andrew Davie | Date | Re: [stella] Qb: v0.10, Glenn Saunders |
| Month |