|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
Here's an example that moves a sprite around on the screen:
* = $0801
lda #$01
sta $d015 ; Turn sprite 0 on
sta $d027 ; Make it white
lda #$40
sta $d000 ; set x coordinate to 40
sta $d001 ; set y coordinate to 40
lda #$80
sta $07f8 ; set pointer: sprite data at $2000
mainloop
lda $d012
cmp #$ff ; raster beam at line $ff?
bne mainloop ; no: go to mainloop
lda dir ; in which direction are we moving?
beq down ; if 0, down
; moving up
ldx coord ; get coord
dex ; decrement it
stx coord ; store it
stx $d000 ; set sprite coords
stx $d001
cpx #$40 ; if it's not equal to $40...
bne mainloop ; just go back to the mainloop
lda #$00 ; otherwise, change direction
sta dir
jmp mainloop
down
ldx coord ; this should be familiar
inx
stx coord
stx $d000
stx $d001
cpx #$e0
bne mainloop
lda #$01
sta dir
jmp mainloop
coord
.byte $40 ; current x and y coordinate
dir
.byte 0 ; direction: 0 = down-right, 1 = up-left
|

This post has been edited 1 times, last edit by "WhiskiX" (Oct 21st 2003, 2:36pm)
Quoted
Original von kairo
Hallo!
Ich versuche mich seit ca. 3 Wochen in Assembler und komme nur mäßig voran. Zum Glück bin ich nun auf einige Seiten im Netz gestoßen, mit denen ich ein Stückchen weiter gekommen bin.
...
Dann noch zwei allgemeinere Fragen:
- Wie habt ihr eigentlich den Einstig in Assembler geschafft? Doch wohl nicht mit Data Becker-Büchern, oder etwa doch? Mich verwirren die nur noch mehr.
- Wie bekomme ich denn die Sprite-Daten in $2000? Mit dem Monitor von VICE?
Quoted
Wie habt ihr eigentlich den Einstig in Assembler geschafft? Doch wohl nicht mit Data Becker-Büchern, oder etwa doch?
Quoted
Original von kairo
Allerdings bewegt sich mein Sprite (läuft in VICE, ich benutze den Turboassembler V7) nur von links-oben nach rechts-unten und bleibt dann dort. Kann mir jemand sagen, warum?
This post has been edited 1 times, last edit by "WhiskiX" (Oct 21st 2003, 3:20pm)
Quoted
Original von Brueggi
Und die Verzögerung is ja das warten auf Strahl bei $FF - oder?
Korrigiert mich bitte, wenn ich falsch lieg... meine C64-Kenntnisse sind schon sehr...äh....angestaubt...
Quoted
Original von Metalmorphosis
Moin!
Probier doch mal zwischen "Lda Dir" und "beq down" "cmp #$01" dazwischenzusetzen.
...
Quoted
Original von Thomas H
Dann würde das Programm aber in der up-left Schleife hängenbleiben, oder meintest Du statt "cmp #$01" "cmp#$00", was nicht nötwendig ist, da das zero-flag schon beim LDA gesetzt wird (, oder gelöscht)
Gruß Thomas
Ja, ich meinte doch "cmp #$00". Hatte irgendwie #$01 im Kopf gehabt. Und das mit dem Zero-Flag hatte ich gerade nicht dran gedacht.
C64-Wiki This post has been edited 2 times, last edit by "WhiskiX" (Oct 27th 2003, 10:38pm)
This post has been edited 1 times, last edit by "biguser" (Oct 27th 2003, 11:21pm)
Forum Software: Burning Board® 3.1.7, developed by WoltLab® GmbH