C64 Assembly - Cycling through Bitmaps as a graphical introduction to my game

406 Views Asked by At

Assembler: CBM prg Studio

This is from my previous post, where I feel I have gained some ground, but still very stuck. My previous post requesting help on this issue a few stages ago... From the answer submitted by a the helpful community member, Emir Akayd , I have chosen to take on option 1.

At the moment I am just using the TEST JUMPER to try each image, with a look to move onto a timer between each loaded image and initialisation into my game.

I think the solution here must now seem obvious to a more advanced programmer. I think i must be doing something stupid either in the not so obvious Loading the screen Ram sections or later in the code under the label "setup", my comments should explain all.

Happy with any suggestions and thank you so much for taking a look!

; 10 SYS (4096)


*=$0801

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

*=$1FFE
        incbin "ASTRO1.prg" ;2 bytes behind as stated in tutorial due to header.
*=$5FFE
        incbin "ASTRO2.prg"
*=$9FFE
        incbin "ASTRO3.prg"

*=$1000


start1              ;         SET THE BACKGROUND SCREEN COLOURS!
        lda #$00    ; This is where the main background colour of image is
        sta $d020   ; sent to the C64 background and boarder.
        sta $d021   ; Becasue all three images have black as their backgrounds
        ldx #$00    ; I have just used the black colour from the system to 
                    ; store them respectively.


        jmp LDimg2  ; TEST JUMPER! Change this each time to view a different 
                    ; bitmap? Once working, which it isn't, we can look at adding
                    ; a timer to allow for switching between each bitmap at game 
                    ; start.


LDimg1              ;             LOADING THE SCREEN RAM.
        lda $3f40,x ; The Charmem data from the export is loaded into A
        sta $0c00,x ; This is a loop that fills the next400 bytes of screen
        lda $4040,x ; RAM with our data from the bitmap
        sta $0d00,x
        lda $4140,x
        sta $0e00,x
        lda $4240,x
        sta $0f00,x

        lda $4328,x ;              LOADING COLOUR RAM!
        sta $d800,x
        lda $4428,x
        sta $d900,x
        lda $4528,x
        sta $da00,x
        lda $4628,x
        sta $db00,x
        inx         ; Inc the X registry   
        bne LDimg1  ; While x is not equal to zero keep branch looping!    

        jmp setup

LDimg2              ;             LOADING THE SCREEN RAM.
        lda $3f40,x ; The Charmem data from the export is loaded into A
        sta $4c00,x ; This is a loop that fills the next400 bytes of screen
        lda $4040,x ; RAM with our data from the bitmap
        sta $4d00,x
        lda $4140,x
        sta $4e00,x
        lda $4240,x
        sta $4f00,x
        
        lda $4328,x ;              LOADING COLOUR RAM!
        sta $d800,x
        lda $4428,x
        sta $d900,x
        lda $4528,x
        sta $da00,x
        lda $4628,x
        sta $db00,x
        inx         ; Inc the X registry   
        bne LDimg2  ; While x is not equal to zero keep branch looping!    

        jmp setup

LDimg3              ;             LOADING THE SCREEN RAM.
        lda $3f40,x ; The Charmem data from the export is loaded into A
        sta $8c00,x ; This is a loop that fills the next400 bytes of screen
        lda $4040,x ; RAM with our data from the bitmap
        sta $8d00,x
        lda $4140,x
        sta $8e00,x
        lda $4240,x
        sta $8f00,x
        

        lda $4328,x ;              LOADING COLOUR RAM!
        sta $d800,x
        

        lda $4428,x
        sta $d900,x
        lda $4528,x
        sta $da00,x
        lda $4628,x
        sta $db00,x
        inx         ; Inc the X registry   
        bne LDimg3  ; While x is not equal to zero keep branch looping!   

        jmp setup


setup
     
        lda #$3b    ;             BITMAP MODE!
        sta $d011   ; Mode storage. #$3b is Bitmap mode.

        lda #$18    ;            COLOUR MODE!?
        sta $d016   ; Load $d016 into #$18 we switch to multi-colour mode.

        lda #$38    ; image 1 - I understand that this 0c00 / 0400 = 3 
                    ; & the 8 comes from 2000 (starting mem of Bitmap) divided
                    ; by 0400 (screen RAM in bytes).
        sta $d018   ; Guessing the significance of this address is screen based?

        ;lda #$??  ; image 2 - doing the math above with the image two the 
                   ; conditions the results here are 13 & 18, but how do I 
                   ; combine larger hex numbers like this?
        ;sta $d018 ; See query above
        
        ;lda #$??  ; image 3 - As above the math here is clear. But how do I 
                   ; combine the results into the 2 numbers?
        ;sta $d018

play    jmp play

1

There are 1 best solutions below

0
On

If I understand you correctly, you're trying to copy a bitmap into the area which the VIC-II is set to read from. That isn't what your program is doing though!

Your program starts at start1, sets the background color and border color to black, and then jumps to LDimg2, which copies the screen ram to some destination, and then jumps to setup, and then proceeding to play which is an infinite loop.

Your setup routine seems to set things up for bitmap 1 (But your program seems to copy (part of) bitmap 2 only?).

The following is a guess, because I can't see what's inside ASTRO1.prg. But LDimg2 appears to copy something from ASTRO1.prg to a region starting at $4c00. It doesn't seem to copy a whole bitmap, though. A C64 bitmap is 8 kilobytes. You're only copying 1 kilobyte.