Hello. Per Stella manual, when a byte is stored in the TIA HMP0 register, a fine position adjustment is applied to the coarse beam position. The manual says the value can be anywhere from -8 to 7 (in binary 1000 to 0111). As such the binary is read as twos-compliment.
The issue is I am having trouble getting the Sprite to render when any of the negative fine position values are applied (those are: 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111). In this demo, observe the diagonal lines rendered for Sprite 0 as the result of positive HMOVE shifts by raster line. However, notice also that when the value applied is negative the sprite disappears and there is nothing on that scan line. Also here for comparison and sanity-check I added another Sprite (Sprite 1) which renders as a straight line the length of the screen b/c no fine position is applied.
The code of the visible lines loop is as follows:
ScanLoop
REPEAT 10 ; wait to
nop ; get beam
REPEND ; arbitrarily near center
; All we do here is ++ the hi nibble in the Accumulator
; and apply it to HMP0 to adjust the fine position.
; QUESTION FOR READER: WHY DOESN'T THE SPRITE RENDER WHEN
; THE VALUE EQUATES TO A NEGATIVE VALUE (-8...-1?)
clc
adc #%00010000 ; Add (UI) '1' to high nibble in A
sta HMCLR ; Due diligence - clear all Motion values
sta HMP0 ; Set fine P0 Sprite pos to incremented value (*)
sta RESP0 ; set coarse position of P0 Sprite
sta RESP1 ; Set coarse position (only) of P1 Sprite
sta WSYNC ; Wait for next scanline
sta HMOVE ; Apply fine tweak
stx COLUBK ; Set the background color
dex ; decrement the scanline
bne ScanLoop
;(*)PS: Tried putting HMP0 after RESP's, didn't help
The project is for this code is here on teh githubs, and the project on the online Atari emulator 8bitworkshop is here.
As I understand, if a solution is provided, then the Sprite on the left will render on every line w/o break with the dot position two's complement bit-pattern.