Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Moving koala to different address (n00b)
2015-02-19 14:35
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 *
2015-02-19 14:47
TNT
Account closed

Registered: Oct 2004
Posts: 189
http://codebase64.org/doku.php?id=base:vicii_memory_organizing
2015-02-19 15:16
Dr.j

Registered: Feb 2003
Posts: 277
i don't watch any problem with the view bitmap routine , so i believe something with the music clash your gfx. try to initialize the music player on the IRQ setup, and add irq to run(play) the music and take care for the $dd00 for choose banks, normally i do lda #$97 sta $dd00 to be on the safe side, so better also to make iniz. for vic/gfx registers at the start of your program. g'luck mate
2015-02-19 15:32
Bamse

Registered: Apr 2013
Posts: 7
@awsm: keep in mind that all bitmap-data needs to be within the 16kb memory block of the selected vic-bank. just use another bank (e.g. bitmap data under $d000) & don´t forget to change the "screen" from $0400 to somewhere within the newly selected vic-bank!
Check TNTs link for details...
2015-02-19 15:36
awsm

Registered: Feb 2015
Posts: 13
With the link and what Dr.j said I understand that the problem is that sound + graphic share the same bank and overlap. I can easily reproduce it: if I load music first, the image destroys parts of the music routine (music all weird), if I load the image first, the music overwrites the first chars on screen.
Music is played like Dr.j suggested btw.

So far so good.
Now the hard part of understanding what to do actually.
Do I load the image to one bank, display the pic, switch to another bank, load and play the music?

Thank you guys... this is literally day 3 after a 20 years 6502 asm coma ;)
2015-02-19 15:53
Dr.j

Registered: Feb 2003
Posts: 277
Im glad you are into it ;-) happy coding mate...
btw a little off topic: after you practice with code
and get back your skills , consider using KickAss with
a nice cross dev. editor (like Eclipse for instance) it could make your life easier and some strong capabilities
for coding asm6502. cheers!
2015-02-19 17:39
Count Zero

Registered: Jan 2003
Posts: 1932
You can play the music from $1000 without vic bank switching of course. So you may e.g. load the picture to $4000, align the values for vic display and play the music without problems at $1000. Or stick to your current settings and choose a shorter music :)
2015-02-19 18:39
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
just move the picture to another address, use your setup, and add the bytes as +$xxxx to the setup

if you move to 6000, standard koala place, then add $4000 to your setupcodes.

then change the vic bank and d018
2015-02-19 18:42
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
setup
;put this inside irq if used, else just do it
;KOALA PIC 2000
lda $dd00
and #%11111100
ora #%00000011 ;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
;------------------------------------


KOALASETUP

ldx #0
KOALARE
lda $3f40,x ;add +$4000 on these to setup for $6000
sta $0400,x
lda $4040,x
sta $0500,x
lda $4140,x
sta $0600,x
lda $4228,x
sta $06e8,x

lda $4328,x ;add +$4000 for these to setup at $6000
sta $d800,x
lda $4428,x
sta $d900,x
lda $4528,x
sta $da00,x
lda $4610,x
sta $dae8,x
dex
bne KOALARE

lda $4710
sta $d021
rts


;include koala pic from file
*=$2000
!BIN "graveyard.kla",, $02
2015-02-19 19:43
awsm

Registered: Feb 2015
Posts: 13
Great info and support from you guys! I'm impressed.
It might take me a while to understand (like, really understand) everything and try out the different approaches.
Until then, thank you!
I'll post again with the results...
2015-02-19 20:08
user

Registered: Mar 2011
Posts: 8
Another solution would be the relocating of the SID. There exists Sidreloc V1.0 which can move most SID's. But $1000 is perfect for SID's, because the VIC can only see the Charset ROM on this location.
The tool has other advantages too, you can see which Zero-Page adresses are used and other stuff.
2015-02-19 20:15
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!
2015-02-19 22:17
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
2015-02-20 13:02
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
2015-02-20 13:15
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.
2015-02-20 13:31
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!
2015-02-20 13:36
iAN CooG

Registered: May 2002
Posts: 3194
sta $0400,x <-
2015-02-20 13:40
awsm

Registered: Feb 2015
Posts: 13
I'm an idiot. Plus, it works now. But mainly idiot. :D
Thanks guys!
2015-02-20 13:52
Oswald

Registered: Apr 2002
Posts: 5094
no you're not, I remember how confusing this could be even when I wasnt a beginner.
2015-02-20 14:26
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
2015-02-20 21:06
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.
2015-02-20 21:08
awsm

Registered: Feb 2015
Posts: 13
Got it Ejner, thank you for the heads up!
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
MWR/Visdom
E$G/HF ⭐ 7
Alakran_64
The MeatBall
/Panor..
Guests online: 95
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.188 sec.