lucienEn Posted February 28 Share Posted February 28 Hi, I want to set position of missile 1 on scanline 37, and position of missile 2 right after on next scanline 38. Is that possible? For some reason the code below causes both missiles to be at same position despite waiting 24 cpu cycles after RESP and strobing HMCLR. If I insert an extra WSYNC+HMOVE in-between it does work but cost now an extra scanline: NextFrame VERTICAL_SYNC ; 3 lines ; ----------------------------------------------- ; Vertical Blank Area. Add game logic here ; ----------------------------------------------- ldx #36 lda #$0 ; mask last line when we turn on again WaitVBlank sta WSYNC sta COLUBK dex bne WaitVBlank lda #0 ; 0 = turn off VBLANK sta VBLANK ; ; we are now at scanline = 36, pixel pos = -32 (next kernel will close this scanline) ; --------------------------------------- ; Kernel1 ; --------------------------------------- Kernel1_Setup ldx #2 ; 2 = M9 lda #10 ; x = 10 jsr SetHorizPos Kernel1_Exit ; --------------------------------------- ; Kernel2 ; --------------------------------------- Kernel2_Setup ldx #3 ; 3 = M1 lda #11 ; x = 11 nop nop nop nop nop nop nop sta HMCLR ; 24 cycles after sta RESP jsr SetHorizPos Kernel2_Exit ; --------------------------------------- ; Kernel3 ; Type: SkipScanlines ; --------------------------------------- Kernel3_Setup ldx #1 Kernel3_Loop dex nop nop nop nop nop nop nop sta HMCLR ; 24 cycles after sta RESP bne Kernel3_Loop Kernel3_Exit Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 28 Share Posted February 28 Can you post SetHorizPos, please? Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 Yes here you go, thanks! ; SetHorizPos - Sets the horizontal position of an object. ; A register = X position ; X register: ; 0: player 0 ; 1: player 1 ; 2: missile 0 ; 3: missile 1 ; 4: ball SetHorizPos sec sbc #6 cpx #2 ; players require extra -1 adjustment adc #00 sec sta WSYNC sta HMOVE SetHorizPosLoop sbc #15 bcs SetHorizPosLoop eor #7 ; calculate fine offset asl asl asl asl sta HMP0,X ; set fine offset sta RESP0,X ; fix coarse position ; strobe HMCLR after > 24 CPU cycles after HMOVE rts Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted February 28 Share Posted February 28 Your code is strobing HMOVE before you set HMP0,x.... you need to hit HMOVE after HMP0,x is set. 1 Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 (edited) 5 minutes ago, splendidnut said: Your code is strobing HMOVE before you set HMP0,x.... you need to hit HMOVE after HMP0,x is set. Ah good catch. And I can only set HMOVE right after WSYNC, correct? If that is the issue I guess there is no way to do this unless I remove HMOVE at next scanline but then I need to blank out first 8 pixels. WSYNC+HMOVE+RESM0 WSYNC+HMOVE+RESM1 --> this needs HMCLR to avoid adjusting 2x RESM0 WSYNC+HMOVE+HMCLR Edited February 28 by lucienEn Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 (edited) Actually I could just do this: WSYNC+HMOVE+RESM0 WSYNC+HMOVE+RESM1+24 cycles+RESM0=0 WSYNC+HMOVE Edited February 28 by lucienEn Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted February 28 Share Posted February 28 Order of register hits should be: HMP0,x / RESP,x / WSYNC / HMOVE / HMCLR. (HMP0,x and RESP0,x are swappable). --- To remove the HMOVE lines, there's the option of doing an "early" HMOVE (hitting the register on cycle 73/74). It requires a different of move values. One of the early discussions can be found here... this has the table with all the places (cycles) where HMOVE could be hit (and what move values are available) : https://www.biglist.com/lists/stella/archives/199804/msg00198.html Here's a link to some discussion on AtariAge about using the HMOVE variation: For Paint The City, I used code by Omegamatrix to do mid-screen sprite repositioning. Here's the link for that info: Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 28 Share Posted February 28 You only have to do one single HMOVE at the end. Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 1 hour ago, splendidnut said: Order of register hits should be: HMP0,x / RESP,x / WSYNC / HMOVE / HMCLR. (HMP0,x and RESP0,x are swappable). That is clear and working but I want to do another RESP,X on the next scanline. This works below to use instead of HMCLR, only clear RESM0: Kernel1_Setup ldx #2 lda #10 jsr SetHorizPos ; WSYNC + HMOVE + HMM0 + RESM0 Kernel2_Setup ldx #3 lda #11 jsr SetHorizPos ; WSYNC + HMOVE (apply HMM0) + HMM1 + RESM1 nop ; 6+2 = 8 cycles nop nop nop nop nop nop nop lda #0 ; 24 cpu cycles sta HMM0 Kernel3_Setup ldx #1 sta WSYNC sta HMOVE ; apply HMM1 dex nop nop nop nop nop nop nop nop nop nop nop sta HMCLR ; clear RESM1 Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 By the way is there really need for HMCLR after setting one RESP,x register? You could clear only the one you changed, correct? Slightly more expensive but helpful in this case. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 28 Share Posted February 28 HMCLR is only related to HMPx, HMMx and HMBL. It resets all 5 values to zero movement for the next HMOVE(s). 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted February 28 Share Posted February 28 2 hours ago, lucienEn said: WSYNC+HMOVE+RESM0 WSYNC+HMOVE+RESM1+24 cycles+RESM0=0 WSYNC+HMOVE Are you drawing the missiles on those scanlines, or just repositioning them for when they're drawn further down the screen? If just repositioning then you can do this: WSYNC + RESM0 + HMM0 ; set coarse position and adjustment of missile 0 WSYNC + RESM1 + HMM1 ; set coarse position and adjustment of missile 1 WSYNC + HMOVE ; apply adjustment of both missiles 1 Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 Yes just repositioning. Note this is auto-generated code so it will automatically keep track of what needs to be reset and I got it working now. Definitely do not need HMCLR. Thanks everyone for finding the issue. Quote Link to comment Share on other sites More sharing options...
lucienEn Posted February 28 Author Share Posted February 28 To give some background, I finished my editor to auto-generate all object types. In the editor you can indicate where you want to set the position of an object and with 'generate asm' I confirmed it's working now as expected (but there are lots of combinations so might be still some bugs left for me): Quote Link to comment Share on other sites More sharing options...
lucienEn Posted March 1 Author Share Posted March 1 7 hours ago, SpiceWare said: Are you drawing the missiles on those scanlines, or just repositioning them for when they're drawn further down the screen? If just repositioning then you can do this: WSYNC + RESM0 + HMM0 ; set coarse position and adjustment of missile 0 WSYNC + RESM1 + HMM1 ; set coarse position and adjustment of missile 1 WSYNC + HMOVE ; apply adjustment of both missiles I noticed Pitfall 2 sets the positioning in the vblank area. That's another option to do the above without requiring to blank first 8 pixels and then apply all at once. 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.