Re: [stella] Sprite kernel (was: Distella --> DAsm problem)

Subject: Re: [stella] Sprite kernel (was: Distella --> DAsm problem)
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Sat, 22 Aug 1998 03:13:28 GMT
>If anyone gets a chance to look at it, give me a yell!  It's just a 
>missile that you can move with the player 1 joystick.  Watch out!  Fancy 
>code!  The .bin works on MacStella 0.7 and PCAE I believe.

Nit-picky correction here.  The left controller port is usually referred to
in the real documentation as Player 0, and the right one is Player 1.  To
get around that confusion, I usually use "first player" and "second player"
rather than "player 1" which could refer to either player.

>LF044: LDA    #$88    ;2  setting up the colors
>       STA    COLUP0  ;3  P0 is blue
>       LDA    #$36    ;2
>       STA    COLUPF  ;3  PF redish (won't see that here, though)
>       LDA    #$D8    ;2
>       STA    COLUP1  ;3  P1 yellow (Sir Not Pictured in this film)

ITYM "The aptly named Sir Not-appearing-in-this-film." ;)

>       LDY    #$10    ;2  I'm using BMI to read D7 of SWCHA
>       STY    HMM0    ;3  (which has been read into the accumulator)
>LF06C: ROL            ;2  Then rolling the byte to the left and reading 

This whole section is a little messy, but there isn't an easy way to clean
it up.. I'd guess that in a proper source listing, it'd be a little more
spread out and labeled better.

>LF07D: LDA    INTIM   ;4  Here's the screen draw routine.
>       BNE    LF07D   ;2
>       STA    WSYNC   ;3
>       STA    VBLANK  ;3
>       LDA    #$02    ;2
>       STA    CTRLPF  ;3
>       LDX    #$01    ;2
>       STA    HMOVE   ;3 DON'T FORGET TO HIT HMOVE!! or the object won't 
>move
>LF08E: STA    WSYNC   ;3 horizontally.  I might have forgotten that for a 
>while...

HMOVE should be executed immediately after a WSYNC.

>       INX            ;2 causing nearly unbearable psychological pain.
>       BEQ    LF0B7   ;2
>       CPX    $80     ;3
>       BEQ    LF09A   ;2
>       JMP    LF08E   ;3
>LF09A: LDA    #$02    ;2
>       STA    ENAM0   ;3 Turn the missile on by putting %00000010 into
>       STA    WSYNC   ;3 ENAM0
>       INX            ;2
>       CPX    #$C1    ;2
>       BEQ    LF0B7   ;2
>       STA    WSYNC   ;3
>       INX            ;2
>       CPX    #$C1    ;2
>       BEQ    LF0B7   ;2
>       LDA    #$00    ;2
>       STA    ENAM0   ;3 Turn it off by putting zero into ENAM0.  Here, 
>the missile
>       STA    WSYNC   ;3 is two scans tall.  Cute little bugger.
>LF0B2: INX            ;2
>       CPX    #$C1    ;2
>       BNE    LF0B2   ;2

I believe there should be a STA WSYNC in that LF0B2 loop somewhere, if it's
supposed to count off the remaining screen time after drawing the missile.

Another comment here.  Most if not all of these move-an-object first
attempts have worked by counting off the time until the object is
displayed, displaying it, then counting off the rest of the screen.  While
that certainly works, I'd suggest changing the kernel so that the same
WSYNC counts off every line of screen, as follows:

    ldy #0
DoScreen:
    STA WSYNC
    ldx #0
    tay             ;using Y to count scanlines
    sec             ;
    sbc $80         ;A now has the distance between current line and object
    cmp #7          ;7=height of object
    bcs DontDraw    ;branch if (scanline-$80)>7
    ldx #2          ;if (scanline-$80) was <= 7, enable the object
DontDraw:
    stx ENAM0
    iny
    cpy #192
    bne DoScreen

This is a decent amount more streamlined and flexible.  Much easier to add
more objects, and it's less prone to error - you're always simply counting
lines from 0 to 191 instead of from 0 to x, eight lines to display the
object, then 0 to 191-8-x.

--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread