SPRITES-IN-ASSEMBLER-COORDINATES! -------------------------------------------------------------------------------------------------- TOOL: EDASS-128 Editor/Assembler {and Commodore C128 ML-Monitor} Language: Assembler Extra: - Author: Misel Zivanovic Note: (C) 03rd of May 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- SPRITE COORDINATES ARE STARTING FROM THE ADDRESS $d000: $d000 = Sprite 0 X Coordinate $d001 = Sprite 0 y Coordinate $d002 = Sprite 1 X Coordinate $d003 = Sprite 1 y Coordinate $d004 = Sprite 2 X Coordinate $d005 = Sprite 2 y Coordinate $d006 = Sprite 3 X Coordinate $d007 = Sprite 3 y Coordinate $d008 = Sprite 4 X Coordinate $d009 = Sprite 4 y Coordinate $d00a = Sprite 5 X Coordinate $d00b = Sprite 5 y Coordinate $d00c = Sprite 6 X Coordinate $d00d = Sprite 6 y Coordinate $d00e = Sprite 7 X Coordinate $d00f = Sprite 7 y Coordinate --------------------------------------------------------------------------------------------------- Why loops and tables are your best friend? Well, imagine doing what i like to do because it's "fun", haha... lda #50 sta $d000 lda #100 sta $d001 lda #200 sta $d002 lda #10 sta $d003 lda #120 sta $d004 sta $d005 Even if you have to position just 4 sprites out of 4, a loop would eat up less bytes and be practically less "expensive" in terms of time investment. Let's see this table version of sprite positioning. And as you can see, you can add a color information to it just like that. This will make it possible to use black screen color to better see the sprite colors! sprites.asm -a:0048-a: -e: ; ; -------------------------------------- ; ldy #$00 ldx #$00 place lda xpos,y sta $d000,x lda ypos,y sta $d001,x lda col,y sta $d027,y inx inx iny cpx #$10 bne place rts ; xpos .byte 50,75,100,125,150,175,200 .byte 225 ypos .byte 50,75,100,125,150,175,150 .byte 125 col .byte 2,3,4,5,6,7,8 ; ; ; -------------------------------------- And here the full listing: spr-pos.asm -a:0011-a: -e: ; -------------------------------------- ; sprites in assembler! ; we will now write a program that ; theoretically should work, but it will ; not do a thing practically! ; on commodore c128! ; -------------------------------------- ; *= $1300 .obj m .bank 15 ; lda #$00 sta $d020 ; border & backg. lda #$00 sta $d021 ; color ; lda #$ff ; sprites on sta $d015 ; ; -------------------------------------- ; remove command lda #$01 ; semicolons to sta $12fd ; enable access ; to sprites ; -------------------------------------- ; lda #2 ; pointer to mem ldx #$08 ; location #2 loop dex ; just to have a sta 2040,x ; random pattern bne loop ; sprite shape ; ; -------------------------------------- ; ldy #$00 ldx #$00 place lda xpos,y sta $d000,x lda ypos,y sta $d001,x lda col,y sta $d027,y inx inx iny cpx #$10 bne place rts ; xpos .byte 50,75,100,125,150,175,200 .byte 225 ypos .byte 50,75,100,125,150,175,150 .byte 125 col .byte 2,3,4,5,6,7,8 ; ; --------------------------------------