header lorom !Freespace = $19B000 !Freespace2 = $1E8000 !Freespace3 = $1F8000 !Freespace4 = $19A000 org $01812C ; JSR $FFC4 ; hijack the sprite status pointer routine org $018139 ; hijack the sprite init pointer dw $FFBF ; org $01FFBF ; sprites' init routine JSL NewInit ; RTS org $01FFC4 ; sprites' main routine JSL NewMain ; PEI ($0C) ; push a return address if necessary RTS org !Freespace db "STAR" dw CodeEnd-CodeStart-$01 dw CodeEnd-CodeStart-$01^$FFFF CodeStart: NewInit: PHP PHK PLB JSL NewInitRoutines PLB RTL NewMain: PHP PHK PLB JSL NewMainRoutines PLB RTL NormalInit: ; LDA #$01 ; set the return address: PHA ; PEA $8172 ; $018172 RTL ; NormalMain: ; PHY ; push Y PHP ; and the processor flags REP #$10 ; LDY #$8133 ; LDA $14C8,x ; check the sprite status CMP #$08 ; if the sprite is in normal status... BNE StoreReturn ; return to $018133 LDY #$8130 ; if not, return to $018130 StoreReturn: ; STY $0C ; store the return address PLP ; pull back the processor flags PLY ; and Y RTL ; NewInitRoutines: LDA $7FAB10,x ; check the extra bits AND #$0C ; bits 2 and 3 CMP #$04 ; ----01-- = extra bits X1 BNE NewSprites1 ; if it isn't X1, then just return... PHY ; *unless* it is an unused sprite LDY #$00 ; start the pointer index at 00 LDA $9E,x ; check the sprite number CMP #$12 ; is it 12? BEQ SpriteList2 ; if so, then use second table pointer #0 INY ; CMP #$36 ; is it 36? BEQ SpriteList2 ; if so, then use second table pointer #1 INY ; CMP #$69 ; is it 69? BEQ SpriteList2 ; if so, then use second table pointer #2 INY ; CMP #$F0 ; is it F0? BEQ SpriteList2 ; if so, then use second table pointer #3 INY ; CMP #$F1 ; is it F1? BEQ SpriteList2 ; if so, then use second table pointer #4 CMP #$F6 ; is it F6 or greater? BCC NormalInit ; if not, just use the normal pointers SEC ; if the sprite number is F6-FF, SBC #$F1 ; then use second table pointers 5-14 TAY ; SpriteList2: ; TYA ; transfer the index to A JSL $0086FA ; jump to a pointer dl Sprite12Init0 ; dl Sprite36Init0 ; dl Sprite69Init0 ; dl SpriteF0Init0 ; dl SpriteF1Init0 ; dl SpriteF6Init0 ; dl SpriteF7Init0 ; dl SpriteF8Init0 ; dl SpriteF9Init0 ; dl SpriteFAInit0 ; dl SpriteFBInit0 ; dl SpriteFCInit0 ; dl SpriteFDInit0 ; dl SpriteFEInit0 ; dl SpriteFFInit0 ; NewSprites1: ; LDA $9E,x ; load the sprite number JSL $0086FA ; jump to a pointer incsrc initpointers1.asm ; NormalMain1: JMP NormalMain NewMainRoutines: LDA $7FAB10,x ; check the extra bits AND #$0C ; bits 2 and 3 CMP #$04 ; ----01-- = extra bits X1 BNE NewSprites2 ; if it isn't X1, then just return... PHY ; *unless* it is an unused sprite LDY #$00 ; start the pointer index at 00 LDA $9E,x ; check the sprite number CMP #$12 ; is it 12? BEQ SpriteList4 ; if so, then use second table pointer #0 INY ; CMP #$36 ; is it 36? BEQ SpriteList4 ; if so, then use second table pointer #1 INY ; CMP #$69 ; is it 69? BEQ SpriteList4 ; if so, then use second table pointer #2 INY ; CMP #$F0 ; is it F0? BEQ SpriteList4 ; if so, then use second table pointer #3 INY ; CMP #$F1 ; is it F1? BEQ SpriteList4 ; if so, then use second table pointer #4 CMP #$F6 ; is it F6 or greater? BCC NormalMain1 ; if not, just use the normal pointers SEC ; if the sprite number is F6-FF SBC #$F1 ; then use second table pointers 5-14 TAY ; SpriteList4: ; TYA ; transfer the index to A JSL $0086FA ; jump to a pointer dl Sprite12Main0 ; dl Sprite36Main0 ; dl Sprite69Main0 ; dl SpriteF0Main0 ; dl SpriteF1Main0 ; dl SpriteF6Main0 ; dl SpriteF7Main0 ; dl SpriteF8Main0 ; dl SpriteF9Main0 ; dl SpriteFAMain0 ; dl SpriteFBMain0 ; dl SpriteFCMain0 ; dl SpriteFDMain0 ; dl SpriteFEMain0 ; dl SpriteFFMain0 ; NewSprites2: incsrc mainpointers1.asm SetTweakerBits: ; this subroutine sets a sprite's Tweaker table values; ; it should be JSL'd to in the init routine PHY ; preserve Y LDY $9E,x ; load the sprite number LDA Sprite1656Values,y ; load a value for $1656,x STA $1656,x ; set Tweaker byte 1 LDA Sprite1662Values,y ; load a value for $1662,x STA $1662,x ; set Tweaker byte 2 LDA Sprite166EValues,y ; load a value for $166E,x STA $166E,x ; set Tweaker byte 3 LDA Sprite167AValues,y ; load a value for $167A,x STA $167A,x ; set Tweaker byte 4 LDA Sprite1686Values,y ; load a value for $1686,x STA $1686,x ; set Tweaker byte 5 LDA Sprite190FValues,y ; load a value for $190F,x STA $190F,x ; set Tweaker byte 6 PLY RTL GetXPositionIndex: ; a routine that returns with Y = 00, 01, 02, or 03 ; depending on a sprite's initial X position LDA $E4,x ; sprite X position low byte AND #$30 ; 4 tiles LSR ; LSR ; LSR ; LSR ; divided by 16 TAY ; into Y RTL incsrc extraspriteproperties.asm incsrc globaldefines.asm CodeEnd: org !Freespace2 ; just in case the sprite code crosses a bank boundary... db "STAR" dw InitCodesEnd-InitCodesStart-$01 dw InitCodesEnd-InitCodesStart-$01^$FFFF InitCodesStart: incsrc newspriteinitcodes.asm InitCodesEnd: org !Freespace3 db "STAR" dw MainCodesEnd-MainCodesStart-$01 dw MainCodesEnd-MainCodesStart-$01^$FFFF MainCodesStart: incsrc newspritemaincodes.asm MainCodesEnd: org !Freespace4 db "STAR" dw SharedRoutinesEnd-SharedRoutinesStart-$01 dw SharedRoutinesEnd-SharedRoutinesStart-$01^$FFFF SharedRoutinesStart: incsrc sharedroutines.asm SharedRoutinesEnd: