; D:TRCB.ASM ; Check triggers ; if there is a change reflect it in ; the speed flag and set the sound ; freq. base value registers TRIGS PROC LDX STRIG0 BEQ :SKIP LDY P0FLG BEQ NWSPD1 JMP TPLR2 :SKIP LDY P0FLG BNE NWSPD2 JMP TPLR2 NWSPD1 = * STX P0FLG LDA #RNFRQS STA FRQSTO STA SAUDF2 JMP TPLR2 NWSPD2 = * STX P0FLG LDA #RNFRQF STA FRQSTO STA SAUDF2 TPLR2 = * ;test player two LDX STRIG0+1 BEQ CKT10 LDY P0FLG+1 BEQ NWSPD3 RTS CKT10 LDY P0FLG+1 BNE NWSPD4 RTS NWSPD3 = * STX P0FLG+1 LDA #RNFRQS STA FRQSTO+1 STA SAUDF2+1 RTS NWSPD4 = * STX P0FLG+1 LDA #RNFRQF STA FRQSTO+1 STA SAUDF2+1 RTS ; Update direction values from the sticks ; converting the data into a useable index STKCPL DS 2 ;stick complement INDEX DS 2 ;direction index MINMV2 DS 2 ;minimum move of 2 pixels reg. DIRVAL DB $E,$D,$7,$B ;OS stick values ; Complement stick values used to ; prevent reversing ones direction CPLTBL DB $D,$E,$B,$7 FRQSTO DB 0,0 ;Holds audio freq SSTICK DB 0,0 ;Holds current stick dir. value UPDATE PROC LDY #01 :NEXT LDX #03 LDA MINMV2,Y ;min. move 2 pix BPL :SKIP2 ;skip new dir if + :NEXT2 LDA DIRVAL,X CMP STICK0,Y BNE :SKIP ;skip if not UDRL CMP STKCPL,Y BEQ :SKIP ;skip if opp dir. CMP SSTICK,Y BEQ :SKIP ;skip if curr dir STA SSTICK,Y LDA CPLTBL,X STA STKCPL,Y TXA ASL A STA INDEX,Y ; new dir reset sound to base freq. LDA FRQSTO,Y ; Y=0,1 for plyr 0,1 STA SAUDF2,Y LDA #1 ; set for min move STA MINMV2,Y :SKIP DEX BPL :NEXT2 :SKIP2 DEY BPL :NEXT RTS ; Move both players P0FLG DB 0,0 ;move fast flag MVCNT DB 0,0 ;move count to alter fast speed CKFLGS PROC LDX #01 :LOOP TXA PHA JSR MVPLYR PLA TAX DEX BPL :LOOP LDA MVCNT CMP #FAST BEQ FLGXT INC MVCNT FLGXT = * RTS MVFAST PROC LDA MVCNT CMP #FAST BMI :EXIT LDA #0 STA MVCNT LDX #01 :LOOP LDA P0FLG,X ; skip if button BNE :SKIP ; not pressed TXA PHA JSR MVPLYR PLA TAX :SKIP = * DEX BPL :LOOP :EXIT = * RTS ; Move players indexed by X PVPRG DS 2 ;player vert pos reg. PHPRG DS 2 ;player horiz pos reg. WORK DS 1 VECTBL DW MOVEUP,MOVEDN,MOVERT,MOVELT PVCTBL DW PL0UP,PL0DN,PL0RT,PL0LT,PL1UP,PL1DN,PL1RT,PL1LT ; Player missle data PLDN0 DB 0,0,0,$14,$14,0,0,0,0,0 PLDN1 DB 0,0,8,0,$00,0,0,0,0,0 PLUP0 DB 0,0,0,0,0,0,$14,$14,0,0 PLUP1 DB 0,0,0,0,0,0,$00,0,8,0 PLRT0 DB 0,0,0,0,6,0,6,0,0,0 PLRT1 DB 0,0,0,0,0,1,0,0,0,0 PLLT0 DB 0,0,0,0,$30,$00,$30,0,0,0 PLLT1 DB 0,0,0,0,$00,$40,$00,0,0,0 PLDN2 DB 0,0,0,8,$14,0,0,0,0,0 PLDN3 DB 0,0,8,0,$00,0,0,0,0,0 PLUP2 DB 0,0,0,0,0,0,$14,8,0,0 PLUP3 DB 0,0,0,0,0,0,$00,0,8,0 PLRT2 DB 0,0,0,0,4,2,4,0,0,0 PLRT3 DB 0,0,0,0,0,1,0,0,0,0 PLLT2 DB 0,0,0,0,$10,$20,$10,0,0,0 PLLT3 DB 0,0,0,0,$00,$40,$00,0,0,0 ; perform position updates then perform ; graphic movement rtns. and hardware regs ; updating MVPLYR PROC LDA MINMV2,X ;test for minimum move BMI NODEC DEC MINMV2,X NODEC JSR PROSND LDY INDEX,X ;on index gosub LDA VECTBL,Y STA SUBVC1+1 LDA VECTBL+1,Y STA SUBVC1+2 SUBVC1 JSR SUBVC1 TXA PHA ASL A ASL A ASL A STA WORK TYA CLC ADC WORK TAY LDA PVCTBL,Y ; on gosub STA SUBVC2+1 LDA PVCTBL+1,Y STA SUBVC2+2 SUBVC2 JSR SUBVC2 PLA TAX ASL A TAY LDA PHPRG,X ;set P/M horiz reg. STA HPOSP0,Y STA HPOSP0+1,Y LDA PLROW,X STA ROWCRS LDA PLCOL,X STA COLCRS LDA #2 STX WORK ORA WORK ;data for put JSR $F5B7 ;SYSPUT RTS ; update position RTNS MOVEUP DEC PLROW,X DEC PVPRG,X RTS MOVEDN INC PLROW,X INC PVPRG,X RTS MOVERT INC PLCOL,X INC PHPRG,X RTS MOVELT DEC PLCOL,X DEC PHPRG,X RTS EPROC ; Macro to spin P/M data into designated RAM PRAMLP MACRO PLDAT0,PLDAT1,GRRAM0,GRRAM1,REGISTER %L = * LDX #9 LDY %5 ?%K LDA %1,X STA %3,Y LDA %2,X STA %4,Y INY DEX BPL ?%K RTS ENDM PL0UP PRAMLP PLUP0,PLUP1,GRP0,GRP1,PVPRG PL0DN PRAMLP PLDN0,PLDN1,GRP0,GRP1,PVPRG PL0RT PRAMLP PLRT0,PLRT1,GRP0,GRP1,PVPRG PL0LT PRAMLP PLLT0,PLLT1,GRP0,GRP1,PVPRG PL1UP PRAMLP PLUP2,PLUP3,GRP2,GRP3,PVPRG+1 PL1DN PRAMLP PLDN2,PLDN3,GRP2,GRP3,PVPRG+1 PL1RT PRAMLP PLRT2,PLRT3,GRP2,GRP3,PVPRG+1 PL1LT PRAMLP PLLT2,PLLT3,GRP2,GRP3,PVPRG+1 ; Process sound dec FREQ'S. X carries ; 0,1. Y=0,4 to access AUDF2,4;1,3 SAUDF1 DS 2 ;shadow audio freq1 SAUDF2 DS 2 ;shadow audio freq2 PROSND PROC TXA ASL A ASL A TAY SEC LDA SAUDF1,X SBC #FDECV BCS :OUT DEC SAUDF2,X :OUT = * STA SAUDF1,X STA AUDF1,Y LDA SAUDF2,X STA AUDF2,Y RTS LINK D:TRCC.ASM