Posted Fri May 2, 2008 8:21 AM
Posted Fri May 2, 2008 3:37 PM
sec sta HMCLR sta WSYNC DivideLoop sbc #15 bcs DivideLoop eor #7 asl asl asl asl sta.wx HMP0,X sta RESP0,X sta WSYNC sta HMOVEThis will run in constant time, which is almost necessary for in-kernal use. Starting after the first STA WSYNC, it will end exactly 79 cycles later for all horizontal positions <= 160. Plus it's general, compact, and very easy to use. I've use this routine, or variations, in every 2600 program I've written.
sta WSYNC sec sta HMCLR DivideLoop sbc #15 bcs DivideLoop tay lda HMPxTable,Y;not crossing page boundary sta HMP0,X sta RESP0,X sta WSYNC sta HMOVEYou have to set up the table carefully so that either you always cross a page boundary when you read it or so that you never do (since Y will hold -1 through -15).
Edited by vdub_bobby, Fri May 2, 2008 3:40 PM.
Posted Mon May 5, 2008 7:12 AM
Posted Mon May 5, 2008 10:29 AM
PosPlayer1: ; A holds X position for player 1 sec ; X holds GRP0 sta WSYNC; Y holds COLUP0 stx GRP0 ; 3 sty COLUP0; 3 6 DivideLoop1: sbc #15 ; 2 8 bcs DivideLoop1; 2 10 eor #7 ; 2 12 asl ; 2 14 asl ; 2 16 asl ; 2 18 asl ; 2 20 sta RESP1 ; 2 23 <- set object position sta HMP1 ; 3 26 sta WSYNC sta HMOVE rts
Edited by SpiceWare, Mon May 5, 2008 10:30 AM.
Posted Mon May 5, 2008 11:51 AM
Posted Mon May 5, 2008 1:18 PM
Posted Sat May 24, 2008 7:31 PM
processor 6502 include "vcs.h" include "macro.h" org $F000 START CLEAN_START lda #$FF sta GRP0 lda #$F0 sta COLUP0 STARTFRAME lda #0 sta VBLANK lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC ldy #37 ldx #0 lda #0 VERT sta WSYNC sec sta HMCLR sta WSYNC DivideLoop sbc #15 bcs DivideLoop eor #7 asl asl asl asl sta.wx HMP0,X sta RESP0,X sta WSYNC sta HMOVE dey bne VERT ldy #192 picture sta WSYNC dey bne picture ldy #30 over dey sta WSYNC bne over jmp STARTFRAME org $FFFA .word START .word START .word START
Edited by Wickeycolumbus, Sat May 24, 2008 8:38 PM.
Posted Sat May 24, 2008 9:43 PM
SpiceWare, on Mon May 5, 2008 10:29 AM, said:
0 members, 1 guests, 0 anonymous users