move sprites beyond 255 x - horizontal

JMP $FCE2
peppe56
Member
Member
Posts: 3
Joined: Thu May 13, 2021 9:01 am
Contact:

move sprites beyond 255 x - horizontal

Post by peppe56 »

hi, I was wondering how I can move the sprite
"penguino" over 255 position,
I tried, but it only works on first start, can you please tell me how to do it.
this is the portion of the code affected thanks.
the code is written in cbm prg studio

; 10 SYS (2064)

*=$0801

BYTE $0E, $08, $0A, $00, $9E, $20, $28, $32, $30, $36, $34, $29, $00, $00, $00

clear = $e544


*=$3000
incbin "pinguino.bin"
incbin "dog.bin"

*=$0810

jsr clear ;print chr$(147) cancella schermo
lda #00 ;A=0
sta $d020 ;poke53280,0 (bordo)
lda #02 ;A=2
sta $d021 ;poke53281,2 (sfondo)


lda #$01 ;A=1 (sprite 0 )
sta $d015 ;53269,3 (abilita sprite 0 )


lda #$c0 ;c0=192 (192*64 = 12288)
sta $07f8 ;2040,192


lda #$90 ;A=144
sta $d000 ;poke53248,144 (sprite 0 posiz. X) pinguino
sta $d001 ;poke53249,144 (sprite 0 posiz. Y) pinguino


muovix

ldx $d000 ;X= peek(53248)
ldy $d001 ;Y= peek(53249)

goto

lda #250 ;ritardo
cmp $d012 ;raster
bne goto

inx ;X=X+1

stx $d000 ;poke53248,x
sty $d001 ;poke53249,x
bne goto

lda#$01 ;A=1
sta$d010 ;53264,1 attiva bit HIGH

jmp muovix

lda#$0 ;A=10
sta$d010 ;53264,0 attiva bit LOW

rts


MarcWalters
Member
Member
Posts: 53
Joined: Wed Jun 11, 2014 2:33 pm
Location: Lake Macquarie, NSW, Australia
Contact:

Re: move sprites beyond 255 x - horizontal

Post by MarcWalters »

Basically, what you need to do is to maintain a sprite X coordinate in memory that can be translated into the VIC Sprite X low byte and high bit registers.

The simplest way would be to store sprite X in a single byte of memory and alter its value using simple inc/dec instructions.

Then:
1) Load the sprite X value into the Accumulator (rA)
2) Use ASL to double the value
3) Store rA into the VIC sprite X low byte register
4) Based on the Carry Flag status from the ASL operation, either Clear or Set the appropriate bit in the sprite X 9th bit register

The sprite will move in 2-pixel steps, but that's fine for testing the logic of your code. IIRC, many later Ocean Software games used this method.
Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 2 guests