Jump to content
IGNORED

Setting RESP right after previous RESP causes HMOVE to get reset


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 by lucienEn
Link to comment
Share on other sites

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:

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

 

 

  • Thanks 1
Link to comment
Share on other sites

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):
image.thumb.png.f39ad7417302d125c33a501519d4034b.png

image.thumb.png.ca7509eb4dcd84959c8128bc878e785b.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...