Subject: Re: [stella] GunFight 2600: One Limit Reached! From: "Andrew Davie" <adavie@xxxxxxxxxxxxx> Date: Thu, 15 Feb 2001 17:25:31 +1100 |
I thought, since I'm soliciting comments on my own code... the moral thing to do would be to comment on Manuel's code, too. So, here goes! Firstly, I find UPPERCASE quite difficult to read. I'm a lower-case guy myself, so prefer mnemonics in lowercase, and CONSTANTS in uppercase. It's pretty standard in the assembler world. Yes, it's a matter of personal preference; now you know mine! 1) What is the value of X when nextLine is first reached? It did not seem to be defined, as far as I could tell. 2) CLC SBC verPos ; STA WSYNC STA WSYNC ADC #$13 Check your usage of the carry flag. When subtracting, SEC - and it will leave the carry flag set if there's no overflow. If there is overflow, it will be clear. Likewise, for addition, CLC beforhand and it will be clear if no carry. The above code does subtraction with carry clear (so subtracts one more), and then (probably) the carry is set after the subtraction (no overflow) and it immediately does an add (which will add one more because the carry is set). This MIGHT be what you want, but just make sure you know what the carry is, and what you expect to happen isn't because you're fudging numbers until it 'looks right' :) 3) Skipdraw is 'wasting cycles'. A while ago there was some discussion on the list as to the most efficient way to waste cycles (that is, least number of bytes used, etc). Worth digging up. In this case you're doing 10 cycles 4) Looks like you've tried very hard to get the two writes to GRPx in the same scanline (to get the players to line up). Don't forget you can use VDELPx to shift one player down a line. This works very well, and is extremely easy to use. Then your loop doesn't need those two WSYNCs side-by-side. You may already know this, but you asked for comments :) 5) The PosPlayer code was of interest to me. That HorzTable routine must have taken ages to work out (!). Check out recent discussion on the list on how to do this with a routine instead of a table (MUCHO bytes savings... about 128 bytes, approx). Check the routine PositionSprites in Qb, for example). I reckon what you have already looks pretty good... I'd like to see more work done on it. Cheers A -- _ _ _| _ _ _| _ * _ _ , (_|| )(_|( (/_\/\/ (_|(_|\/(_(/_ ,~' L_|\ ,-' \ see my Museum of Soviet Calculators at ( \ http://www.taswegian.com/MOSCOW/soviet.html \ __ / L,~' "\__/ @--> v ----- Original Message ----- From: "Manuel Polik" <manuel.polik@xxxxxxxxxxx> To: <stella@xxxxxxxxxxx> Sent: Thursday, February 15, 2001 3:09 AM Subject: [stella] GunFight 2600: One Limit Reached! > Hi there! > > I'm through with the single line kernel now -> I definitely need two > lines. > The current demo (#2) pushed the single kernel to the max, there's some > cycles left, but none of my desired features can be added with these > few... > > Changes: > 1 - assimilated all of Thomas' superior knowledge and put it > straight into the kernel > 2 - limited the movement of the cowboys. > (Is it still enough for you Eckhard? :-)) > 3 - changed the colors. Now the sprites look exactly like > Pat Garret & Billy the Kid. > 4 - Enabled the Missile to display something that, nearly but not > totally, looks different than a pistol (#1) > 5 - Messed up the source some more with quick copy & paste stuff > > If you like, please comment on the demo as such, or about the 'nextline' > loop. Any ideas/improvements appreciated. > -> All the rest of the source is just to get that thing going, I'll fix > & clean up that mess later. > > Greetings, > Manuel > > #1 Uhm, I read the german translation of 'The Restaurant At The End Of > The Universe' and tried to re-translate that joke. If it shows no > similarity to the original words at all now, it's only 50% my fault. > #2 I forced it to display like a double line kernel, but it'd work as > single. Just remove the second STA WSYNC. I did this, that YOU already > get used to the new double line look :-) ---------------------------------------------------------------------------- ---- > processor 6502 > include vcs.h > > > SCREENSTART = $60 > > SEG.U vars > org $80 > > horPos ds 5 ; Horizontal positions (Player/Player/Missile/Missile/Ball) > verPos ds 2 ; Vertical positions (Player/Player) > colorpointer ds 4 ; pointer to color tables > playerpointer ds 4 ; pointer to shape tables > sizepointer ds 4 ; pointer to size tables > > 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 verPos > STA verPos+1 > > LDX #$03 > SetUpHorizontal LDA horpostab,X > STA horPos,X > DEX > BPL SetUpHorizontal > > LDA #$1C > STA COLUBK > > > MainLoop JSR VerticalSync ; > JSR VerticalBlank ; > JSR MainScreen ; MainScreen does Overscan > JMP MainLoop ; Repeat > > 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 #$02 ; > STA VBLANK ; Start vertical blank > LDA #$2B ; > STA TIM64T ; Init timer > > ; Position all objects > > LDY #$04 > PosAnother ldx horPos,Y ;+3 3 > JSR PosPlayer > DEY > BPL PosAnother > > STA WSYNC ; Finish current line > sta HMOVE > > LDX #SCREENSTART ; Init display Kernel > LDA #$08 > STA REFP1 ; Reflect Player 1 > LDA #$02 > STA ENAM0 > STA ENAM1 > > LDA $F0 > > > > ; Init pointers (yes, a quick hack :-)) > > LDA #<p0data ; Init Pointers > STA playerpointer ; > LDA #>p0data ; Init Pointers > STA playerpointer+1 ; > LDA #<p0data ; Init Pointers > STA playerpointer+2 ; > LDA #>p0data ; Init Pointers > STA playerpointer+3 ; > > LDA #<colordata ; Init Pointers > STA colorpointer ; > LDA #>colordata ; Init Pointers > STA colorpointer+1 ; > LDA #<colordata2 ; Init Pointers > STA colorpointer+2 ; > LDA #>colordata2 ; Init Pointers > STA colorpointer+3 ; > > LDA #<sizedata ; Init Pointers > STA sizepointer ; > LDA #>sizedata ; Init Pointers > STA sizepointer+1 ; > LDA #<sizedata2 ; Init Pointers > STA sizepointer+2 ; > LDA #>sizedata2 ; Init Pointers > STA sizepointer+3 ; > > > WaitIntimReady LDA INTIM ; Wait until vertical blank finished > BNE WaitIntimReady ; > RTS > > SkipDraw NOP > LDA VSYNC > NOP > LDA #$00 > BEQ Continue > > Waste STA WSYNC ; Waste a line > DEX ; > BNE Waste ; if X is not zero, do more lines > RTS > > SkipDraw2 NOP > LDA VSYNC > NOP > LDA #$00 > BEQ Continue2 > > MainScreen STA WSYNC ; Finish current line > STA VBLANK ; Stop vertical blank > > nextLine TXA > CLC > SBC verPos ; > STA WSYNC > STA WSYNC > ADC #$13 > TAY > BCC SkipDraw > LDA (colorpointer),Y > STA COLUP0 > LDA (playerpointer),Y ; > Continue STA GRP0 > > TXA > CLC > SBC verPos+1 ; > ADC #$13 > TAY > BCC SkipDraw2 > LDA (colorpointer+2),Y > STA COLUP1 > LDA (playerpointer+2),Y ; > Continue2 STA GRP1 > > DEX > BNE nextLine > > oscan2 JSR joy ;overscan. Time to read the joysticks. > LDX #$1E > JMP Waste > > 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 horPos ;set horizontal motion register to one pixel right > INC horPos+3 > LDA horPos+3 > CMP #$40 > BNE HorPosOK > DEC horPos > DEC horPos+3 > HorPosOK rts > > left DEC horPos+3 > DEC horPos ;set horizontal motion register to one pixel left > LDA horPos > CMP #$FF > BNE HorPosOK2 > INC horPos+3 > INC horPos > HorPosOK2 rts > > up LDA verPos ;make sure we haven't gone over the top of the screen > CMP #SCREENSTART > BEQ NoClimb > INC verPos ;if not then increase the vertical position > NoClimb RTS > > down LDA verPos > CMP #$14 > BEQ NoSink > DEC verPos ;decrease the vertical position > NoSink RTS > > right2 INC horPos+2 > INC horPos+1 ;set horizontal motion register to one pixel right > LDA horPos+1 > CMP #$99 > BNE HorPosOK3 > DEC horPos+2 > DEC horPos+1 > HorPosOK3 rts > > left2 DEC horPos+1 ;set horizontal motion register to one pixel left > DEC horPos+2 > LDA horPos+2 > CMP #$60 > BNE HorPosOK4 > INC horPos+1 > INC horPos+2 > HorPosOK4 rts > > up2 LDA verPos+1 ;make sure we haven't gone over the top of the screen > CMP #SCREENSTART > BEQ NoClimb2 > INC verPos+1 ;if not then increase the vertical position > NoClimb2 RTS > > down2 LDA verPos+1 > CMP #$14 > BEQ NoSink2 > DEC verPos+1 ;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 $10,$90,$89,$19 > > 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 > > ORG $FF00 > > colordata > .byte $00 > .byte $00 > .byte $00 > .byte $00 > .byte $00 > .byte $88 > .byte $86 > .byte $84 > .byte $82 > .byte $82 > .byte $82 > .byte $3C > .byte $3C > .byte $3C > .byte $3C > .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 > > sizedata > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > > sizedata2 > .byte $00 > .byte $00 > .byte $00 > .byte $00 > .byte $00 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $F0 > .byte $30 > .byte $30 > .byte $30 > .byte $00 > .byte $10 > .byte $10 > .byte $10 > .byte $10 > > org $FFFC > .word start > .word start - Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Random Numbers, Tim Böscke | Thread | Re: [stella] GunFight 2600: One Lim, Manuel Polik |
Re: [stella] Qb: v0.03, Glenn Saunders | Date | Re: [stella] Qb: v0.03 (no illegal , Andrew Davie |
Month |