Elijah Posted February 21 Share Posted February 21 Hey friends! Despite making progress, I have run into an issue with the code that I'm struggling to resolve. Specifically, I have managed to address the initial hurdle of getting the sprites to draw, albeit with some assistance from a persons code in Andrew Davies' tutorial, which I modified to suit my requirements. However, I am currently facing confusion regarding the output of the code. Upon execution, the code segment "Character" generates approximately 50 scanlines, whereas my expectation was for it to produce only 17. Consequently, this discrepancy has led to several complications, notably an oversized play screen that exceeds the standard dimensions of CRT TV displays. Moreover, I have encountered limitations in adjusting the code, as it appears to cap at 313 scanlines, anything more seems to break the entire code. Below, I have included the code for your review and potential insights. Any guidance or suggestions you could provide to rectify this issue would be immensely appreciated. Thank you in advance for your time and assistance. Yours, Elijah processor 6502 include "vcs.h" include "macro.h" PFCOL equ #$A2 BACKGROUND equ #$00 COL0 equ #$1E sprite_draw equ #$80 seg.u vars ; uninitialized segment seg main ORG $F000 ;Created using Atari Dev Studio ;assembly format (bottom to top) -actually i flipped it -elijah mainplayer .byte %01111110 ; .byte %01111010 ; .byte %01101110 ; .byte %01110010 ; .byte %01111110 ; .byte %00011000 ; .byte %00011000 ; .byte %00111100 ; .byte %01011010 ; .byte %00011000 ; .byte %00111100 ; .byte %00100100 ; .byte %01100110 ; .byte %00000000 ; .byte %00000000 ; .byte #%00000000 reset cld ;clear the decimal flag ldX #$ff tXs ;set the stack pointer to "$ff" ldX #0 ; Clear RAM and all TIA registers lda #0 clear sta 0,X ; $0 to $7F (0-127) reserved OS page zero, $80 to $FF (128-255) user zero page ram. inX bne clear lda #%00000001 ; Set D0 to reflect the playfield sta CTRLPF ; Apply to the CTRLPF register lda #PFCOL sta COLUPF ; Set the PF color lda #COL0 sta COLUP0 sta WSYNC SLEEP 19 sta RESP0 StartOfFrame lda #%00000010 sta VSYNC sta WSYNC sta WSYNC sta WSYNC ; turn off vsync lda #0 sta VSYNC lda #43 sta TIM64T ldX #0 lvblank sta WSYNC lda INTIM bne lvblank sleep 24 STA RESP0 ldy #17 ldx #0 sta VBLANK Drawfield lda #%00000000 ;2 sta PF0 ;3 sta PF1 ;3 sta PF2 ;3 stX COLUBK ;note, havent loaded background yet, 3 sta WSYNC ;3 inX ;2 cpX #133 ;2? bne Drawfield ;2 ldX #0 ;2 stx sprite_draw Character cpy 17 bpl No_Drawing ldx sprite_draw cpx 17 beq No_Drawing lda mainplayer,x sta GRP0 inx stx sprite_draw Drawfield2 lda #%11111100 ;2 sta PF0 ;3 sta PF1 ;3 sta PF2 ;3 lda #BACKGROUND ;load background color,3 sta COLUBK ;3 inX ;2 cpX #17 ;2 bne Drawfield2 ;2 ldX #0 ;2 No_Drawing STA WSYNC DEY ; 192 Scanlines drawn ? BNE Character ; No = Continue overscan sta WSYNC inX cpX #30 bne overscan jmp StartOfFrame org $FFFA irqvectors .word reset ; NMI .word reset ; RESET .word reset ; IRQ END Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted February 22 Share Posted February 22 I took a quick look and this jumped out at me: Character cpy 17 bpl No_Drawing ldx sprite_draw cpx 17 beq No_Drawing The cpy 17 and cpx 17 are comparing against the value retrieved from address 17, which is a mirror of TIA register CXM1P So you're not comparing against 17, but against the collision detection results of missile1/player0 and Missile1/player1. cpy #17 and cpx #17 will compare against the number 17. Quote Link to comment Share on other sites More sharing options...
Elijah Posted February 22 Author Share Posted February 22 2 hours ago, SpiceWare said: I took a quick look and this jumped out at me: Character cpy 17 bpl No_Drawing ldx sprite_draw cpx 17 beq No_Drawing The cpy 17 and cpx 17 are comparing against the value retrieved from address 17, which is a mirror of TIA register CXM1P So you're not comparing against 17, but against the collision detection results of missile1/player0 and Missile1/player1. cpy #17 and cpx #17 will compare against the number 17. Hi there! That doubtlessly saved me some head ache later, so thank you! But unfortunately that didn't seem to solve the weirdly high screenlines! Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted February 25 Share Posted February 25 You'll want to learn how Stella's Debugger works to figure this out. Compile your code after making the cpy #17 and cpx #17 fixes, then load your ROM into Stella: Press the ` key on your keyboard (next to 1, above tab, below ESCape) to enter the debugger: In the prompt type break Character then hit RETURN: Hit ` again, your program will run and then reenter the debugger when it gets to Character: At this point hit the Step button in the upper right to single step through your code. Repeatedly hit Step while watching what the code does, as well as the registry values, the current Scanline and the Scan Cycle position. What I see when stepping thru the program is that after GRP0 is updated the program will do a loop which updates PF0, PF1, and PF2 over multiple scanlines before it does the next update to GRP0. This is what's causing your player to be so tall. You might also like to take a look at my Collect tutorial, which covers writing a complete 2K game from scratch. Quote Link to comment Share on other sites More sharing options...
Elijah Posted February 26 Author Share Posted February 26 Oh cool, I didn't know any of this, thank you! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.