| View previous topic :: View next topic |
| Author |
Message |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Mon Aug 06, 2012 6:33 pm Post subject: Using DASM for assembly; Need help |
|
|
Hi all, I'm looking for some help with doing assembly using DASM. I made this little BASIC game that I wanted to make an intro picture for with music (having a scroller too would be a bonus) and I found some great tutorials that have helped me do this using DASM but unfortunately only works separately.
That is, when I try to combine the image & the sid music I get this error message in DASM:
segment: INITIAL CODE SEGMENT 3502 vs current org: 4711
intro.asm (84): error: Origin Reverse-indexed.
Aborting assembly
[Example codes were made by Digitalerr0r of Dark Codex]
Here is the code for the image.asm:
| Code: |
processor 6502
org $1000
lda $4710
sta $d020
sta $d021
ldx #$00
loaddccimage:
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 $4328,x
sta $d800,x
lda $4428,x
sta $d900,x
lda $4528,x
sta $da00,x
lda $4628,x
sta $db00,x
inx
bne loaddccimage
lda #$3b
sta $d011
lda #$18
sta $d016
lda #$18
sta $d018
loop:
jmp loop
org $1FFE
INCBIN "image.PRG"
|
This work on its own very well.
And here is the Music-code:
| Code: |
processor 6502
org $0810
lda #$00
tax
tay
jsr $3580
sei
lda #$7f
sta $dc0d
sta $dd0d
lda #$01
sta $d01a
lda #$1b
ldx #$08
ldy #$14
sta $d011
stx $d016
sty $d014
lda #<irq
ldx #>irq
ldy #$7e
sta $0314
stx $0315
sty $d012
lda $dc0d
lda $dd0d
asl $d019
cli
loop: jmp loop
irq: jsr $3583
asl $d019
jmp $ea81
org $3580-$7e
INCBIN "music.sid"
|
On it's own this works perfectly as well.
Can someone help me in combining these two so I get both the image and music working together? Also would be great if you could explain what the error message means. Thanks alot for any help.
Kind regards,
ARG |
|
| Back to top |
|
 |
Immortal Grandmaster of C64

Joined: 13 Oct 2004 Posts: 4698
|
Posted: Mon Aug 06, 2012 6:36 pm Post subject: |
|
|
the problem is that different parts of the code (and data) overlap each other, you'll have to adjust the .org directives and make sure that this doesnt happen. _________________ |
|
| Back to top |
|
 |
Master of C64


Joined: 31 Jan 2003 Age: 42 Posts: 1152 Location: Italy
|
Posted: Mon Aug 06, 2012 6:41 pm Post subject: |
|
|
The error is already telling what to do, just put the various sections in increasing org address order.
org $0810
org $1000
org $1ffe
org $3580
dasm requires the lowest org to be the first, at that point you can even mix them. _________________ -=[]=--- iAN CooG/HVSC & C64Intros ---=[]=- |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Mon Aug 06, 2012 11:14 pm Post subject: |
|
|
Short story after much mucking about, I can't get it to work. I don't see where the data overlap is occuring and adjusting the org directives have but given me a slight variation of the error segment numbers. Attempting to put the various sections in increasing address order failed to compile.
Thanks. |
|
| Back to top |
|
 |
Über Groupie


Joined: 12 Jun 2012 Posts: 310 Location: Wuppertal, FRG
|
Posted: Tue Aug 07, 2012 9:05 am Post subject: |
|
|
Your bitmap ($1FFE-$4710) and music data ($3502-....) are overlapping.
It says 4711 in the error message, because $4711 would be the PC after including the koala bitmap and it collides with your ORG $3580-$7e command, which is the same as ORG $3502. |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Tue Aug 07, 2012 8:28 pm Post subject: |
|
|
Thanks Spider-j for that explanation, now I understand the error message. I didn't see that the Image took up so much memory. I suppose since the SID file's Load range is $3580-$414B this data overlap can be fixed by moving the music in memory? What would be your best opinion on what to do here? |
|
| Back to top |
|
 |
Über Groupie


Joined: 12 Jun 2012 Posts: 310 Location: Wuppertal, FRG
|
Posted: Tue Aug 07, 2012 11:21 pm Post subject: |
|
|
i.e. use vic-bank 1 ($4000-$7fff) for your picture and screen memory. Relocating graphics is usually easier than relocating sid tunes.
You can just load your koala file to $6000 and nearly use the same code. And: I'd use plain binary files without load adress and/or sid header.
The way you did it only puts garbage in memory that you don't need. |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Wed Aug 08, 2012 2:45 am Post subject: |
|
|
Thanks for suggestions.
Since the SID's Load range had $3580-$414B If I understand you correct I must relocate the graphics to vic-bank 1 ($8000–$BFFF). Will try this.
I followed a tutorial by digitalerr0r where I learned to make MultiColor images, resolution of 160×200 pixels, with the support of 16 colors using Timanthes 3.0 beta. Upon exporting image as .PRG I was given the following info:
| Code: | Settings
Bitmap data 2000
Charmem data 3F40
Colormem data 4328
Background data 4710
|
These numbers I were to use in the image.asm example. How do you propose I load "my koala file to $6000" ?
Would be grateful for more help on relocating this correctly. |
|
| Back to top |
|
 |
Über Groupie


Joined: 12 Jun 2012 Posts: 310 Location: Wuppertal, FRG
|
Posted: Wed Aug 08, 2012 8:32 am Post subject: |
|
|
Okay just some thoughts how I'd do it:
- split koala file in bitmap, colorram, videoram data
- load videoram to $4400 and colorram afterwards
- load bitmap to $6000
I can't tell you how you do that in DASM. I'm using ACME and there you can skip bytes from your binary includes. I assume there should be something similiar in DASM too.
EDIT: ah, and with load I just mean include with your assemblers include command. The only thing that is important with bitmaps is to align them to vic-bank startadr +$0000 or vic-bank startadr + $2000. And of course that you can not use $0000 and $8000 for your bitmap screen.
You only have to change your display routine.
EDIT2: okay, I looked into DASM docs and saw that it doesn't support byte skip/offset with INCBIN command. So you have to split your binary files manually (i.e. with a hex-editor) before you can use it this way. |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Wed Aug 08, 2012 6:32 pm Post subject: |
|
|
Let's see if we can do this in DASM (sorry, I need your help) since I am unfamiliar with ACME. When exporting my image to Koala Painter format I get the following values:
- Bitmap data 6000
- Charmem data 7F40 (Is this what you call videoram?)
- Colormem data 8328
- Background data 8710
This won't crash with the SID's Load range and bitmap is already loaded to $6000. However I haven't split the bitmap, colorram and videoram data as you suggested, do I really need to split them in 3 files ? I have no idea how to do that.
Couldn't I still make this work by relocating the videoram at $4400 ?
You wrote I ofcourse couldn't use $8000 for my bitmap screen, does this mean that the Koala Painter format is not helping me?
I basically want a routine that both loads an image and a sid without competing about the memory locations. Since there is a wide range of Load ranges of the various SID files how do you stack it so your data doesn't crash. Is it possible to show a generic routine for this? |
|
| Back to top |
|
 |
Forum Junkie

Joined: 13 Aug 2009 Age: 44 Posts: 422
|
Posted: Wed Aug 08, 2012 9:36 pm Post subject: |
|
|
Yes, load the koala file at $6000 then copy the 2 colour datas to their respective positions (ie with code, lda $blah,x sta $4000,x). The one goes to $d800 the other can go anywhere from $4000-$6000. $4400 is fine. No need to split anything. _________________ |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Wed Aug 08, 2012 9:50 pm Post subject: |
|
|
Here's what I did, it doesn't show the image just a blank black screen. What is wrong with this code?
| Code: |
; SYS 20480 to start
processor 6502 ; C=64
org $5000 ; Start address in memory
; Image exported in Koala Painter format:
; Bitmap data 6000
; Charmem data 7F40
; Colormem data 8328
; Background data 8710
; First of all, we set the background color to the same as our image.
lda $8710 ; Get the value from this address
sta $d020 ; Store it as the border color
sta $d021 ; Store it as the background color
; Used to copy data to the screen RAM that starts at $0400,
; But now we use $4400 instead..
; The data for our image is located at $7f40
ldx #$00 ; First set the X-register to zero
loadimage:
lda $7F40,x ; then start copying
sta $4400,x
lda $8040,x
sta $4500,x
lda $8140,x
sta $4600,x
lda $8240,x
sta $4700,x
lda $8328,x ; Also, we must copy the color RAM for our image located at $8328
sta $d800,x
lda $8428,x
sta $d900,x
lda $8528,x
sta $da00,x
lda $8628,x
sta $db00,x
inx
bne loadimage
; Image is loaded and (almost) ready to display
; Setup bitmap mode & multicolor mode:
lda #$3b
sta $d011 ; bitmap mode
lda #$18
sta $d016 ; multicolor-mode
; tell the VIC that the screen RAM is at $0400 and that the bitmap is at $6000.
lda #$18 ; -?
sta $d018 ; ...
loop: jmp loop
; Image at memory location $6000-2 bytes = 51FFE
org $5FFE
INCBIN "image.prg"
|
I suppose there's alot wrong with this code, also see the ; -? remark, I don't know what value to represent the bitmap at $6000, lda #$18 used to work in earlier example for bitmap at $2000.
Thanks alot ! |
|
| Back to top |
|
 |
Forum Junkie

Joined: 13 Aug 2009 Age: 44 Posts: 422
|
Posted: Wed Aug 08, 2012 9:54 pm Post subject: |
|
|
That looks ok, you just need to change the video bank with $dd00 as explained here
You're now using the 2nd bank $4000-$7fff so the bottom 2 bits need to be 10.
lda $DD00
and #$FC
ora #$02
sta $DD00
or (unsafely) lda #$96 sta $dd00  _________________ |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Wed Aug 08, 2012 10:07 pm Post subject: |
|
|
Wow that worked  Thanks alot for the clean fix! I would never have found that without your exact help, now I'll try to add the SID music. Take care |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Thu Aug 09, 2012 1:49 am Post subject: |
|
|
I'm almost able to combine the Image and SID routines now, only problem is that the upper half of the image is all black (blank) while the bottom half displays fine with the music playing correctly.
If I put the image-label just above the org $5000 line the upper half of the image has garbage graphics at the very top and the border color has been set to pink (though it should be black) while lower half displays fine.
What is causing the upper-half of the image to be like this? [Either empty/black or garbled] I was wondering if the irq-initialization in the music-routine is the culprit with those $d011, $d014 and $d016 but I see no change after setting these to the values from the Image routine.
Is there an easy fix for this current problem:
| Code: |
; SYS 2064
processor 6502 ; C=64
org $0810 ; Start address in memory
; Initiate the music
lda #$00 ; Load Acc. with 00 then copy it to
tax ; the X-register
tay ; and Y-register
jsr $3580 ; SID file's Init address (Load range $3580 - $414B)
; Initiate interrupts
sei ; Turn off interrupts
lda #$7f ; Load accumulator with value 7F, and
sta $dc0d ; turn off CIA I
sta $dd0d ; turn off CIA II
lda #$01 ; load acc with value 01 then
sta $d01a ; turn on/enable raster interrupts
lda #$1b ; Load A-register with hex 1b
ldx #$08 ; Load X-register with hex 08
ldy #$14 ; Load Y-register with hex 14
sta $d011 ; Inserting $1b will Clear high bit of $d012 & set text mode
stx $d016 ; Inserting $08 will Use single-colour
sty $d014 ; Inserting $14 will tell VIC that our screen RAM is at $0400
; and that we want to use default charset (at $2000).
lda #<irq ; Low part of address of interrupt handler code
ldx #>irq ; High part of address of interrupt handler code
ldy #$7e ; Line to trigger raster interrupt
sta $0314 ; Store in interrupt vector
stx $0315 ; Store in interrupt vector
sty $d012 ; Store in interrupt vector
lda $dc0d ; Clear pending interrupts for the CIA 1
lda $dd0d ; Clear pending interrupts for the CIA 2
asl $d019 ; Clear pending interrupts for the VIC
cli ; Enable interrupts
jmp image ; Show image
irq: jsr $3583 ; SID-file's Play address
asl $d019 ; ACK the interrupt
jmp $ea81 ; Restores the stack and return from interrupt.
; Load the music into $3580-$7e
org $3502
INCBIN "music.sid"
; Initiate MultiColor image
org $5000
; Exported in Koala Painter format:
; Bitmap data 6000
; Charmem data 7F40
; Colormem data 8328
; Background data 8710
image:
lda $8710 ; Get image background color
sta $d020 ; Store it as the border color
sta $d021 ; Store it as the background color
; Copy video RAM data to $4400.
; The data for our image is located at $7f40
ldx #$00 ; First set the X-register to zero
loadimage:
lda $7F40,x ; then start copying
sta $4400,x
lda $8040,x
sta $4500,x
lda $8140,x
sta $4600,x
lda $8240,x
sta $4700,x
lda $8328,x ; Copy the color RAM for our image located at $8328
sta $d800,x
lda $8428,x
sta $d900,x
lda $8528,x
sta $da00,x
lda $8628,x
sta $db00,x
inx
bne loadimage
; Change video-bank with $dd00:
lda $DD00 ; We now use the 2nd bank $4000-$7fff so the bottom 2 bits need to be 10.
and #$FC
ora #$02
sta $DD00
; Setup bitmap mode & multicolor mode:
lda #$3b
sta $d011 ; bitmap mode
lda #$18
sta $d016 ; multicolor-mode
; tell the VIC that the screen RAM is at $4400 and that the bitmap is at $6000.
lda #$18
sta $d018
loop: jmp loop
; Image at memory location $6000-2 bytes = 51FFE
org $5FFE
INCBIN "image.prg"
|
Any glaring mistakes in the code?
Edit: found a typo |
|
| Back to top |
|
 |
Forum Junkie

Joined: 13 Aug 2009 Age: 44 Posts: 422
|
Posted: Thu Aug 09, 2012 8:32 am Post subject: |
|
|
What SID are you using then I can test in case that's doing something weird?
The code itself looks fine. You can actually get rid of all the stores to d011,d016 and especially d014 (which is read only lightpen) from the music init part of the code.
It's also neater to not keep ORGing different bits of code in different RAM locations, just keep it all in one place and as long as it doesn't overlap the music or picture you'll be fine. _________________ |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
Posted: Thu Aug 09, 2012 5:32 pm Post subject: |
|
|
The SID I am using is called "No_Girl_No_Life.sid" by Kjell Nordø, you'll find it under HVSC 5.7 at this folder: \C64Music\MUSICIANS\B\Blues_Muz\Nordboe_Kjell
Still stuck with this little problem that the upper half of the image is black.
I did try to remark out those stores to d011, d014 and d016 but it didn't do anything different. I'm not sure how to clean up the code to make it neater as you mention with the ORGing. It appears that the music is still overlapping the image somehow.. just the upperhalf.
Thanks for any suggestions - almost there. |
|
| Back to top |
|
 |
Forum Junkie

Joined: 13 Aug 2009 Age: 44 Posts: 422
|
Posted: Thu Aug 09, 2012 5:47 pm Post subject: |
|
|
Yeah, looks like the SID init copies a load of RAM right over where the picture is..
As far as the other stores to d011/16/14, like I say, just remove the first lot they're either doing nothing or being overwritten.
Tidying the code a bit, just move the whole of the "image" chunk of code to where you've got jmp image (and remove the jmp image line). That will do exactly the same thing without splitting the code into different bits.
Fixing the SID/Bitmap problem means moving it somewhere else, or use a different SID
*edit*
You've chosen a pain in the ass SID there as far as making it as simple as possible
However, the "easiest" (not neatest) solution is to load the bitmap at $a000 then turn off BASIC ROM with a LDA #$35 STA $01 before you copy the data around. Copy the first chunk of data to $8c00 (anywhere $8000-$8fff really) the other to $d800 as normal. After the copy set the ROM back to on with LDA #$37 STA $01. You MUST move the CLI to after this routine (just put it right before the JMP LOOP) as interrupts will die if BASIC ROM isn't there..
The new value for DD00 is ORA #$01 and for the colours at $8c00 D018 would be #$38.
That now all works perfectly for me. _________________ |
|
| Back to top |
|
 |
Master of C64


Joined: 31 Jan 2003 Age: 42 Posts: 1152 Location: Italy
|
Posted: Thu Aug 09, 2012 6:24 pm Post subject: |
|
|
Many sids in Blues Muz dir are made like that, player is distant from data and have been manually narrowed to keep the sid file shorter, too bad the init have to "unpack" the data before initing.
Takes some time to make them compact and not writing data around.
http://iancoog.altervista.org/nogirlnolife_fix.rar
here are 2 versions, one manually compacted and one relocated to $1000 (relocation made easier with sidreloc/lft)
No_Girl_No_Life.sid
New range : $35C0-$4184
Init: $35c0 Play: $3603
No_Girl_No_Life-1000.sid
New range : $10C0-$1C84
Init: $10c0 Play: $1103 _________________ -=[]=--- iAN CooG/HVSC & C64Intros ---=[]=-
Last edited by iAN CooG on Fri Aug 10, 2012 12:13 am; edited 1 time in total |
|
| Back to top |
|
 |
Newbie

Joined: 06 Aug 2012 Posts: 28 Location: Norvegr
|
|
| Back to top |
|
 |
Newbie
Joined: 28 Oct 2012 Posts: 4
|
Posted: Sun Oct 28, 2012 9:12 pm Post subject: another DASM question |
|
|
Hello... new to the 64 scene as a 6502 ML coder -- been learning for about a week now how to write all sorts of programs... and I have cobbled together this:
| Code: |
processor 6502
;org $0810; run with sys 2064
org $0801
.byte $0b,$08,$06,$00,$9e,$32,$30,$36,$34
org $0810
; netrunner demo - bit map title screen image with SID intro music!!!
lda #$00 ; change border and background to black and clear screen
sta $d020 ; border
sta $d021 ; background
jsr $e544 ; clear screen
; IRQ to play a PSID at $9000
lda #$00
tax
tay
jsr $9000 ; init
sei
lda #$7f
sta $dc0d
sta $dd0d
lda #$01
sta $d01a
lda #$1b
ldx #$08
ldy #$14
sta $d011
stx $d016
sty $d014
lda #<irq ; setup irq for SID
ldx #>irq
ldy #$7e
sta $0314
stx $0315
sty $d012
lda $dc0d
lda $dd0d
asl $d019
cli
lda $4710 ; load bit map image routine
sta $d020
sta $d021
ldx #$00
loaddccimage:
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 $4328,x
sta $d800,x
lda $4428,x
sta $d900,x
lda $4528,x
sta $da00,x
lda $4628,x
sta $db00,x
inx
bne loaddccimage
lda #$3b
sta $d011
lda #$18
sta $d016
lda #$18
sta $d018 ; end of bit map display routine...
loop:
; check if space hit to exit program
lda $dc01 ;check keyboard
cmp #$ef ;spacebar pressed?
beq exit
jsr loop
exit:
jsr $9000 ; reset the SID chip
lda #$1b ; single-color text mode (normal font)
ldx #$08
ldy #$14
sta $d011
stx $d016
sty $d018
lda #$00 ; change border and background to black and clear screen
sta $d020 ; border
sta $d021 ; background
jsr $e544 ; clear screen
jmp $e394 ; reset 64
rts ; exit program and return to basic
irq: ; interrupt routine for SID
jsr $9003 ; play routine for SID
asl $d019 ; ack irq
jmp $ea81 ; back to kernal irq
;jmp $FA65 ; try this
; to implement - scroller message here...
; psuedo op-codes used by dasm
org $1FFE
INCBIN "nr.title.prg" ; image to load at $1FFE (Koala Paint picture)
org $9000-$7e
INCBIN "rg.sid" ; PSID tune to load at $9000
|
I need help! The pic is displayed with a white border -- which is ok but annoying... and the tune finally plays with the IRQ interrupt now just fine...
BUT how do I exit gracefully and STOP the tune from playing... and reset the C-64 to its default state to be able to run programs???
Also, does anyone know of any tutorials that show how to create using two stable rasters a split screen with a bit map image shown at the top half and a text mode scroller screen on the bottom half?
I realize that I cannot use a text scroller that works with single-color text mode while displaying the bit map in multi-color bit map mode without implementing this raster technique.
Would love to add the scroller to the demo/loader for my game that I am writing...
(need to load net.0 prg and draw5000 prg later after the demo is complete... the loader part of the intro/title prg)
Please can someone help me out here? Using DASM is both a blessing and a curse! I was given a demo source by Overlord from CCI but it doesn't run properly after I converted it to work with the DASM compiler.
Text issues had to change to .byte -- etc.
So... his demo code is too much to learn from and just doesn't work with my compiler that I have learned how to use.
I created the bit map rg.prg using Koala Paint and just am using the loader.sid tune from goattracker that I packed/relocated to $9000 with play routine at $9003.
Again, I have a working IRQ interrupt that plays the SID while the bit map is displayed... and the space bar EXITS the program but the tune does NOT stop playing... and the screen is not in the standard READY[] mode ... the cursor is gone...
Help!
S0RC3R0R
www.netrunner64.com |
|
| Back to top |
|
 |
Groupie in Training

Joined: 08 Jan 2002 Posts: 113 Location: Sweden
|
Posted: Sun Oct 28, 2012 10:40 pm Post subject: Re: another DASM question |
|
|
| s0rc3r0r wrote: | Also, does anyone know of any tutorials that show how to create using two stable rasters a split screen with a bit map image shown at the top half and a text mode scroller screen on the bottom half?
I realize that I cannot use a text scroller that works with single-color text mode while displaying the bit map in multi-color bit map mode without implementing this raster technique. |
You don't need a stable raster for that. You only need to wait for raster line #1, and change $d011 into bitmap mode, and then wait for raster line #2 and change it back to character mode.
| s0rc3r0r wrote: | | Again, I have a working IRQ interrupt that plays the SID while the bit map is displayed... and the space bar EXITS the program but the tune does NOT stop playing... and the screen is not in the standard READY[] mode ... the cursor is gone... |
Replace this:
| Code: |
exit:
jsr $9000 ; reset the SID chip
|
with this:
| Code: |
exit:
lda #0
sta $d418
sta $d01a
lda #<$ea31
ldx #>$ea31
sta $0314
stx $0315
lda #$81
sta $dc0d
|
|
|
| Back to top |
|
 |
|