Drawing bitmap in 6502 assembly

624 views Asked by At

so I've been trying to draw a bitmap in 6502 (for the Commodore 64). When I load the image into adress 2000 it's works fine, but as soon as try a different address like 2400 it doesn't work anymore.

Also I'm using CBM prg Studio as my IDE, and Vice as my C64 emulator... don't know if that matters.

Here's an image of the result I get Image of my result

And here's my code


*=$0801

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

*=$0900

; **************************************************************
;                       VARIABLES
; **************************************************************

TITLE_CHARMEM   = $4340
TITLE_COLRMEM   = $4728
TITLE_BACKMEM   = $4B10

; **************************************************************
;                       MACROS
; **************************************************************

; **************************
; KEYWAIT
defm KEYWAIT                    ; Paramters: [Key]
@WAITLOOP
        lda #$CB
        cmp /1
        bne @WAITLOOP

        endm


; **************************
; PRINT
defm PRINT                      ; Paramters: [String]
        lda #</1
        ldy #>/1
        jsr $AB1E
        endm

; **************************************************************
;                       GAME CODE
; **************************************************************

INIT
        lda #%00111011          ; Enable bitmap mode
        sta $D011
        lda #%11011000          ; Enable multicolor mode
        sta $D016

        lda TITLE_BACKMEM       ; Load background data from
        sta $D020               ; Store it in the background addresses
        sta $D021

        ldx #$00

TITLE
        ; Load the image and store it in memory
        ; -- Image data
        lda TITLE_CHARMEM,x
        sta $0400,x
        lda TITLE_CHARMEM + $0100,x
        sta $0500,x
        lda TITLE_CHARMEM + $0200,x
        sta $0600,x
        lda TITLE_CHARMEM + $0300,x
        sta $0700,x

        ; -- Color data
        lda TITLE_COLRMEM,x
        sta $D800,x
        lda TITLE_COLRMEM + $0100,x
        sta $D900,x
        lda TITLE_COLRMEM + $0200,x
        sta $DA00,x
        lda TITLE_COLRMEM + $0300,x
        sta $DB00,x

        inx
        bne TITLE

        lda #$19
        sta $D018

FOREVER
        jmp FOREVER

*=$23FE         ; 2400 - 2 bytes for the header
INCBIN "bitmaps/title.prg"
1

There are 1 answers

0
Omar and Lorraine On BEST ANSWER

When I load the image into adress 2000 it's works fine, but as soon as try a different address like 2400 it doesn't work anymore.

This is your answer. The bitmap needs to be located at the same address where the video chip is going to read it. Usually that address is $2000, but that can be changed.

Similarly, colour must always be at address $d800. This address is fixed in hardware.