Posted Thu Jun 15, 2006 8:18 PM
Posted Thu Jun 15, 2006 10:42 PM
nmoog, on Thu Jun 15, 2006 10:18 PM, said:
LDX COARSE_VALUE LOOP DEX BNE LOOP STX RESP0The DEX instruction takes 2 machine cycles, and taking a branch takes 3 machine cycles (as long as you don't cross a page boundary), so each time you go through the loop, you're waiting a total of 5 machine cycles, or 15 color clocks-- hence, when you hit RESP0 you are setting player 0's position to a coarse location, where each possible coarse location is 15 color clocks after the previous coarse location. Hence, you probably won't be setting the player to the exact X position you wanted; more likely, it will be some 7 or 8 color clocks to the left or right of the desired location.
LDX FINE_VALUE STX HMP0 LDX COARSE_VALUE LOOP DEX BNE LOOP STX RESP0 STX WSYNC STX HMOVE
Posted Fri Jun 16, 2006 12:43 AM
nmoog, on Thu Jun 15, 2006 9:18 PM, said:
Posted Fri Jun 16, 2006 6:39 AM
supercat, on Fri Jun 16, 2006 2:43 AM, said:
Posted Fri Jun 16, 2006 8:22 PM
; Sprite Horizontal Positioning Routine (Battlezone Variant)
; On Entry: A = Coordinate and X = Object ID
XPosition
sta WSYNC ; [0]
sec ; [0] + 2
; Divide Position by 15
Divide15
sbc #15 ; [2] + 2
bcs Divide15 ; [4] + 2/3
nop ; [6] + 2
tay ; [8] + 2
; Store Coarse and Fine Position
lda fineAdjustTable,y ; [10] + 4
sta HMP0,x ; [14] + 4
sta RESP0,x ; [18] + 4
; Position At Cycles: [22/27/32/37/42/47/52/57/62/67/72/77]
rts
ORG $F300
fineAdjustBegin
DC.B %01110000; Left 7
DC.B %01100000; Left 6
DC.B %01010000; Left 5
DC.B %01000000; Left 4
DC.B %00110000; Left 3
DC.B %00100000; Left 2
DC.B %00010000; Left 1
DC.B %00000000; No movement.
DC.B %11110000; Right 1
DC.B %11100000; Right 2
DC.B %11010000; Right 3
DC.B %11000000; Right 4
DC.B %10110000; Right 5
DC.B %10100000; Right 6
DC.B %10010000; Right 7
fineAdjustTable EQU fineAdjustBegin - %11110001; NOTE: %11110001 = -15
ldx #NUMBER_LINES-1; Load number of rows of enemy SetupEnemies lda EnemyX,x ; Load the X pos for each enemy jsr ConvertToFC ; Magical convert it to "FC" positioning that I dont understand sta EnemyFC_X,x ; and save the result in in the FC array dex bpl SetupEnemies
ldy LineCounter; Current row lda EnemyFC_X,y; Get Player1 position sta WSYNC ; Start with a new scanline. sta HMP1 ; Prepare Player1 fine motion and #$0F ; Prepare Player1 coarse positioning tay PositionLine dey ; Waste time bpl PositionLine sta RESP1 ; Position Player1 sta WSYNC ; Wait for next scanline sta HMOVE ; Apply fine motionTo position each enemy correctly. This works fine (though doing move HMOVE messes up my player 0 sprite at the bottom of the screen for some reason) but adds those short black lines on the left side of the screen as in Air Sea Battle. Which probably isnt a co-incidence, as the mystical ConvertToFC routine is this:
; Straight from "Air sea battle", here's the routine
; to convert from standard X positions to FC positions.
ConvertToFC
STA TEMP+1
BPL LF34B
CMP #$9E
BCC LF34B
LDA #$00
STA TEMP+1
LF34B: LSR
LSR
LSR
LSR
TAY
LDA TEMP+1
AND #$0F
STY TEMP+1
CLC
ADC TEMP+1
CMP #$0F
BCC LF360
SBC #$0F
INY
LF360: CMP #$08
EOR #$0F
BCS LF369
ADC #$01
DEY
LF369: INY
ASL
ASL
ASL
ASL
STA TEMP+1
TYA
ORA TEMP+1
RTS
Posted Sun Jun 18, 2006 6:37 PM
nmoog, on Fri Jun 16, 2006 10:22 PM, said:
Edited by DEBRO, Mon Jun 19, 2006 5:14 AM.
Posted Mon Jun 19, 2006 10:56 PM
Edited by nmoog, Tue Jun 20, 2006 3:47 AM.
Posted Tue Jun 20, 2006 5:43 AM
nmoog, on Tue Jun 20, 2006 12:56 AM, said:
nmoog, on Tue Jun 20, 2006 12:56 AM, said:
Posted Tue Jun 20, 2006 10:18 AM
DEBRO, on Tue Jun 20, 2006 4:43 AM, said:
nmoog, on Tue Jun 20, 2006 12:56 AM, said:
nmoog, on Tue Jun 20, 2006 12:56 AM, said:
0 members, 0 guests, 0 anonymous users