1
votes

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
You forgot to adjust the destination addresses? It's unclear what is in title.prg, does it have a full screen dump? That can not simply be moved and expected to work.Jester
I'm not quite sure what a full screen dump is (if you're asking if it has data for the whole screen then yes). But I've exported the title.prg so that its character, color and background locations match the variables in the code. Also I'm not sure what you mean by the destination addresses.Insert joke here
The bitmap screen is at $2000. If you have a full screen image, it must be located there.Jester
Yes that is correct. The image is made up from screen memory at $0400, color at $d800 and bitmap at $2000. All of those are fixed (except for the bank setting.)Jester
To be more accurate: the address of a bitmap must be a multiple of $2000 and cannot be $0000 or $8000 (because the lower halves would use the built-in character ROM instead). And obviously the bitmap has to be in the $4000 bank used by VIC, so $2000 is the only place that works in the 0th bank.Karol S

1 Answers

2
votes

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.