| | awsm
Registered: Feb 2015 Posts: 13 |
Moving koala to different address (n00b)
I'm having a hard time understanding why this doesn't work for me:
The code below loads a koala file to $2000. All fine.
But in combination with music (starting at $1000) I get the music messed up. I figured that the pic overwrites parts of the music (>4096 bytes). Any other starting address than $2000 fails however, showing just garbage (updated $d018 too, but it didn't do the trick).
PICTURE = $2000
VIDEO = PICTURE+$1f40
COLOR = PICTURE+$2328
BACKGROUND = PICTURE+$2710
* = PICTURE
!binary "resources/mypic.kla",,2
* = $c000
init_koala
sei
lda #$00
sta $d020 ; Border Color
lda BACKGROUND
sta $d021 ; Screen Color
; Transfer Video and Color
ldx #$00
; Transfers video data
vloop lda VIDEO,x
sta $0400,x
lda VIDEO+$100,x
sta $0500,x
lda VIDEO+$200,x
sta $0600,x
lda VIDEO+$2e8,x
sta $06e8,x
; Transfers color data
lda COLOR,x
sta $d800,x
lda COLOR+$100,x
sta $d900,x
lda COLOR+$200,x
sta $da00,x
lda COLOR+$2e8,x
sta $dae8,x
inx
bne vloop
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
; When bitmap adress is $2000
; Screen at $0400
; Value of $d018 is $18
lda #$18
sta $d018
jmp *
|
|
... 11 posts hidden. Click here to view all posts.... |
| | awsm
Registered: Feb 2015 Posts: 13 |
Oh yeah, I tried sidreloc, great tool. In the end it all comes down to me needing to understand the memory mapping better. Otherwise it's just trial and error.
I could easily have chosen a smaller tune, but I hate bailing out and problems like these are the perfect opportunity to learn.
I always thought coding is like playing adventures. In the beginning the puzzle pieces are overwhelming, but piece after piece you see the bigger picture - pure fun! |
| | SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
addition:
you must also poke d018 with charrom address.
do it this way:
so, when the koala is in $6000
here is to make d018 poke:
selectchar
lda $d018
and #240
ora #0 ;0-2-4-6-8-10-12-14 : 0000-07ff, 0800-0fff, 1000-17ff, 1800-1fff
; 2000-27ff, 2800-2fff, 3000-37ff, 3800-3fff
sta $d018
so, change the ORA
charbank 2 starts at $4000
so the ora must be 0
if the char of the koala is in 4800,
then it must be 2
each 0800 hop = +2 on the ORA |
| | awsm
Registered: Feb 2015 Posts: 13 |
@SIDwave
I think I'm almost there. The bank switching happens, the music plays fine along with the image and so on. But I still must oversee something trivial, as the bitmap displays, but color seems to be off: http://i.imgur.com/DcPzQdl.png
PIC_ADD = $4000
* = $6000
!binary "resources/mypic.kla",,2
init_koala
;put this inside irq if used, else just do it
;KOALA PIC 2000
lda $dd00
and #%11111100
ora #%00000010 ;vic bank 3 (they go 3-2-1-0, so $6000 is #2)
sta $dd00
lda $d016
ora #$10
sta $d016
LDA #$19
STA $D018
lda #$3b
sta $d011
ldx #$00
KOALARE
lda $3f40+PIC_ADD,x ;add +$4000 on these to setup for $6000
sta $0400,x
lda $4040+PIC_ADD,x
sta $0500,x
lda $4140+PIC_ADD,x
sta $0600,x
lda $4228+PIC_ADD,x
sta $06e8,x
lda $4328+PIC_ADD,x ;add +$4000 for these to setup at $6000
sta $d800,x
lda $4428+PIC_ADD,x
sta $d900,x
lda $4528+PIC_ADD,x
sta $da00,x
lda $4610+PIC_ADD,x
sta $dae8,x
dex
bne KOALARE
lda $4710+PIC_ADD
sta $d021
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
lda $d018
and #240
ora #8 ;0-2-4-6-8-10-12-14 : 0000-07ff, 0800-0fff, 1000-17ff, 1800-1fff
; 2000-27ff, 2800-2fff, 3000-37ff, 3800-3fff
sta $d018
rts
|
| | Bamse
Registered: Apr 2013 Posts: 7 |
Looks like you are still copying the "screen"-data to $0400. But since you switched the vic-bank this isn´t your screen anymore. Try copying to $4400,$4500... in your vloop. |
| | awsm
Registered: Feb 2015 Posts: 13 |
@Bamse: Hm. Are you looking at the code in the first post or the one from the last? Because I can't see where I'm copying to 0400 etc. anymore. Thank you! |
| | iAN CooG
Registered: May 2002 Posts: 3194 |
sta $0400,x <- |
| | awsm
Registered: Feb 2015 Posts: 13 |
I'm an idiot. Plus, it works now. But mainly idiot. :D
Thanks guys! |
| | Oswald
Registered: Apr 2002 Posts: 5094 |
no you're not, I remember how confusing this could be even when I wasnt a beginner. |
| | The Phantom
Registered: Jan 2004 Posts: 360 |
ldx #$00
wrap
lda $3f40,x
sta $0400,x
lda $4040,x
sta $0500,x
lda $4140,x
sta $0600,x
lda $4240,x
sta $0700,x
lda $4338,x
sta $d800,x
lda $4438,x
sta $d900,x
lda #4538,x
sta $da00,x
lda $4638,x
sta $db00,x
inx
bne wrap
lda #$18
ldx #$f8
ldy #$3b
sta $d018
stx $d016
sty $d011
rts
That's how I display koala/ocp from $2000-$4720. A koala from $6000-$8720 can be loaded into memory at $2000 and use the same code.
To display a koala where it stands in memory, from $6000 requires bank switching, which I don't have time to do at this moment, but that's not what you wanted to do ;)
I think $471e and $471f are bits for $d020 and $d021, not sure as I never use them :D
Doing it my way will also require any sprite inits to take place AFTER, since we write to $7f8-$7ff |
| | Ejner
Registered: Oct 2012 Posts: 43 |
Hey, just a small note about memory and graphics if you missed it...
When the VIC chip looks at $1000-$1fff and also $9000-$9fff, regardless of the data you have here, the VIC chip will see a mirror of the ROM charset. So no bitmap, fonts or screen color data can be displayed from these addresses...
Meaning, no FULLSCREEN bitmap in $0000 or $8000. Use instead $2000,$4000,$6000,$a000,$c000,$e000. |
Previous - 1 | 2 | 3 - Next | |