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 > Assembly and adding a Picture
2009-08-26 19:51
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Assembly and adding a Picture

Hi All,

I have some assembly code written for ACME assembler. I was just curious how I would add a picture into the code. I got the pause down but I just need a picture to show. Doesn't matter what format. I assume I can change my picture to most formats specified.

This would be great if someone could let me know.

Thanks,
MisterMSK
 
... 21 posts hidden. Click here to view all posts....
 
2009-08-28 06:50
Mace

Registered: May 2002
Posts: 1799
Quoting TWW
MisterMSK wanted someone to explain to him how to display a picture.

Well, actually he wanted to know how to add a picture into the code.
This can either be explained as how to attach a picture's binary file into the assembly code in order to have it added to the final PRG after compiling *OR* as how to write a routine to display the picture.

I was answering the first, you are answering the second.

However, you're answer suggests that if you'd want to display a Koala picture, you have to assume it's in $4000-$7fff, which IMHO is not true if you're working cross platform. The file simply doesn't have a location, as you always have to set it in your code when attaching the binary.

You are right, that if you'd load the picture on a real machine ",8,1" you'd have it starting at $6000.
You also suggest transfering it, but this implicates that you'd have to physically move it in the memory after loading.
Both are not necessary if you add the picture in your assembly code the way I suggest.

Perhaps MisterMSK should respond to our suggestions, so we can see where we're going... ;-)
2009-08-28 15:03
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: Quoting TWW
MisterMSK wanted someone to explain to him how to display a picture.

Well, actually he wanted to know how to add a picture into the code.
This can either be explained as how to attach a picture's binary file into the assembly code in order to have it added to the final PRG after compiling *OR* as how to write a routine to display the picture.

I was answering the first, you are answering the second.

However, you're answer suggests that if you'd want to display a Koala picture, you have to assume it's in $4000-$7fff, which IMHO is not true if you're working cross platform. The file simply doesn't have a location, as you always have to set it in your code when attaching the binary.

You are right, that if you'd load the picture on a real machine ",8,1" you'd have it starting at $6000.
You also suggest transfering it, but this implicates that you'd have to physically move it in the memory after loading.
Both are not necessary if you add the picture in your assembly code the way I suggest.

Perhaps MisterMSK should respond to our suggestions, so we can see where we're going... ;-)


Sure. I modified FMGPUCCRBRR to just start a program when it loads. This way I can easly start a PRG from my MMC Replay (Just comment out like 64-67 and it will auto start the program. Make every color 0 so you don't see any text displayed.) Anyway, I am auto-starting sd2brwse, which allows me to browse my uIEC card with my joystick. I found, thou, it starts up to fast for the uIEC. So I wanted to create a 3 to 4 second pause. Then I relized I need more like a 6 to 8 second pause so I know it starts up every time. This is when I'd desided it needed a picture in there. It would be nice to put it in the FMGPUCCRBRR program so if I wanted to switch, let say, to DraBrowse I could. This site contains a program to transfer JPEG to Koala. So with that being easy to do, I would like to try to stick a Koala pick in there and pause for 6 to 8 seconds.

I hope this helps.
2009-08-29 01:10
TWW

Registered: Jul 2009
Posts: 541
So what is your question?

How to include the koala file in your code and/or displaying it on the screen :)

I believe Jan Harries already wrote how to include binaries into ACME:

ACME:

*=address of pic
!bin "filename.prg",, $02

I haven't used this assembler meself but this should normaly not be a problem to figgure out through the assemblers documentation. Even to do a 'selective' loading of the binary file so the such as mace sais to let the assembler relocate it for you (If you for some reason want to do that).

For displaying the code you need to set up the character screen and graphics bank with $dd00/$d018. Then you need to load up the 2 char-multicolor colours onto the character screen you have chosen by setting $d018. $d016 sets single/multicolor mode and $d011 sets hires mode. and ultimately you need to load the last multicolor colors onto $d800.

as said b4 there are a million sources and stuff for this (but if youre to laze to figgure it out I am sure I could post an example for you).

For pausing for some seconds there are a variety of ways to do this. but think that a screen update is 50 times a econd (PAL) (60 in NTSC) so if you count the amount of screen scans you can easilly 'pause'.

ldy #seconds
ldx #$50/60 //PAL/NTSC
cpx $d012
bne *-3
dex
bne *-6
dey
bne *-11


or something like that (not tested but should work if your not depending on $d012 for other stuff).
2009-11-02 16:52
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: So what is your question?

How to include the koala file in your code and/or displaying it on the screen :)

I believe Jan Harries already wrote how to include binaries into ACME:

ACME:

*=address of pic
!bin "filename.prg",, $02

I haven't used this assembler meself but this should normaly not be a problem to figgure out through the assemblers documentation. Even to do a 'selective' loading of the binary file so the such as mace sais to let the assembler relocate it for you (If you for some reason want to do that).

For displaying the code you need to set up the character screen and graphics bank with $dd00/$d018. Then you need to load up the 2 char-multicolor colours onto the character screen you have chosen by setting $d018. $d016 sets single/multicolor mode and $d011 sets hires mode. and ultimately you need to load the last multicolor colors onto $d800.

as said b4 there are a million sources and stuff for this (but if youre to laze to figgure it out I am sure I could post an example for you).

For pausing for some seconds there are a variety of ways to do this. but think that a screen update is 50 times a econd (PAL) (60 in NTSC) so if you count the amount of screen scans you can easilly 'pause'.

ldy #seconds
ldx #$50/60 //PAL/NTSC
cpx $d012
bne *-3
dex
bne *-6
dey
bne *-11


or something like that (not tested but should work if your not depending on $d012 for other stuff).


TWW,

Thanks so much for the information. Got the pausing down. However, still have been trying to figure out the displaying a picture. When looking at different examples, never could get one to display. If you could post an example as you said, I would be greatful.

Thanks,
MisterMSK
2009-11-02 20:01
Perplex

Registered: Feb 2009
Posts: 254
Quote: So what is your question?

How to include the koala file in your code and/or displaying it on the screen :)

I believe Jan Harries already wrote how to include binaries into ACME:

ACME:

*=address of pic
!bin "filename.prg",, $02

I haven't used this assembler meself but this should normaly not be a problem to figgure out through the assemblers documentation. Even to do a 'selective' loading of the binary file so the such as mace sais to let the assembler relocate it for you (If you for some reason want to do that).

For displaying the code you need to set up the character screen and graphics bank with $dd00/$d018. Then you need to load up the 2 char-multicolor colours onto the character screen you have chosen by setting $d018. $d016 sets single/multicolor mode and $d011 sets hires mode. and ultimately you need to load the last multicolor colors onto $d800.

as said b4 there are a million sources and stuff for this (but if youre to laze to figgure it out I am sure I could post an example for you).

For pausing for some seconds there are a variety of ways to do this. but think that a screen update is 50 times a econd (PAL) (60 in NTSC) so if you count the amount of screen scans you can easilly 'pause'.

ldy #seconds
ldx #$50/60 //PAL/NTSC
cpx $d012
bne *-3
dex
bne *-6
dey
bne *-11


or something like that (not tested but should work if your not depending on $d012 for other stuff).


That code won't pause as long as you'd like as it stands.
The reason is that when x becomes below a certain value,
the raster line comparison will be true several times per
frame ($d012 wraps around from $ff to $00 just a few lines
into the lower border).

Easily fixed though:

lda #$fb    // Lower border starts here
ldy #seconds
ldx #$50/60 //PAL/NTSC
cmp $d012
bne *-3
cmp $d012
beq *-3
dex
bne *-11
dey
bne *-16


Sorry about the nitpick. :)
2009-11-02 20:49
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: That code won't pause as long as you'd like as it stands.
The reason is that when x becomes below a certain value,
the raster line comparison will be true several times per
frame ($d012 wraps around from $ff to $00 just a few lines
into the lower border).

Easily fixed though:

lda #$fb    // Lower border starts here
ldy #seconds
ldx #$50/60 //PAL/NTSC
cmp $d012
bne *-3
cmp $d012
beq *-3
dex
bne *-11
dey
bne *-16


Sorry about the nitpick. :)


Well, sorry to nitpick even more but pausing in hex isn't the way to do it... :) #$50/60 vs. #50/60
2009-11-03 00:59
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: Well, sorry to nitpick even more but pausing in hex isn't the way to do it... :) #$50/60 vs. #50/60

Actually, I used this:

         ldx #60*4  ;60 fps * 4 seconds 
         lda #128 
loop1 cmp $d012      ;check if the raster has reached line 128 
         bne loop1      ;no, so keep checking 
loop2 cmp $d012      ;if it has you want to make sure you dont catch it more than once per frame 
         beq loop2      ;so wait till it isn't 0 any more 
         dex 
         bne loop1      ;loop round 60*4 times



I got how to added the Koala pic to $2000 but what is a good code for displaying it?
2009-11-03 02:15
clonK
Account closed

Registered: Aug 2008
Posts: 65
Quote: Actually, I used this:

         ldx #60*4  ;60 fps * 4 seconds 
         lda #128 
loop1 cmp $d012      ;check if the raster has reached line 128 
         bne loop1      ;no, so keep checking 
loop2 cmp $d012      ;if it has you want to make sure you dont catch it more than once per frame 
         beq loop2      ;so wait till it isn't 0 any more 
         dex 
         bne loop1      ;loop round 60*4 times



I got how to added the Koala pic to $2000 but what is a good code for displaying it?


Isn't that basic stuff that you'd be better off learning for yourself?
Is http://codebase64.org/doku.php?id=base:displaying_a_picture_at_.. not what you are looking for?

Also see - http://tnd64.unikat.sk/
and - http://www.oldschool-gaming.com/c64_hex_files.php

Learn about VIC banks.
2009-11-03 15:46
Stranger
Account closed

Registered: Nov 2006
Posts: 6
MisterMSK;
Skate of Glance released some detailed tutorials about bitmap things
But unfortunately in Turkish :) But don't worry. I 'll try to explain it with his way.

Multicolor graphic mode has 3 important components.

Video = 1000 bytes =>$03e8 bytes
Color = 1000 bytes =>$03e8 bytes
Bitmap = 8000 bytes =>$1f40 bytes

We need to load a picture from $2000 to $4710
BITMAP = from $2000+$1F40= to $3F40
VIDEO = from $3f40+$03e8= to $4328
COLOR = from $4328+$03e8= to $4710
BACKGROUND COLOR= $4710

Now we must transfer datas to correct locations for displaying a picture

Default video ram is starting from $0400
Transfer 1000 bytes data from
$3f40 to $0400
$3f41 to $0401
etc...
loks like..

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

Default color ram is starting from $d800
Transfer 1000 bytes data from
$4328 to $d800
$4329 to $d801

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

Also bitmap data at already at right place b'coz we'll load picture from $2000

And ofcourse transfer background color
lda BACKGROUND ($4710)
sta $d021

We need to set bitmap mode on
with
lda#$3b
sta$d011

also multicolor mode
with
lda#$d8
sta$d016

when bitmap adress at $2000 and screen at default $0400
lda#$18
sta$d018

Some values :
Koala Painter Values:
Bitmap = $0000-$1f3f = 0-7999
Video = $1f40-$2327 = 8000-8999
Color = $2328-$270f = 9000-9999
Backgrnd = $2710 = 10000

Advanced Art Studio Values:
Bitmap = $0000-$1f3f = 0-7999
Video = $1f40-$2327 = 8000-8999
Color = $2338-$271f = 9016-10015
Backgrnd = $2329 = 9001



And finally koala shower:


!to "koala.prg",cbm

* = $0801
!byte $0b, $08, $00, $00, $9e, $32, $30, $36, $31, $00, $00, $00

PICTURE = $2000
BITMAP = PICTURE
VIDEO = PICTURE+$1f40
COLOR = PICTURE+$2328
BACKGROUND = PICTURE+$2710

* = $080d

sei
lda #$00
sta $d020 ; Border Color
lda BACKGROUND
sta $d021 ; Screen Color

; Transfer Video and Color
ldx #$00
.LOOP
; Transfers video data
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 .LOOP
;
; 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 *

;File must be at same directory ofcourse
* = PICTURE
!binary "filename",,2
2009-11-03 18:00
clonK
Account closed

Registered: Aug 2008
Posts: 65
Also, http://project64.c64.org/misc/map64.zip is very valuable to me whilst learning.
I made loads of notes, studied those sites I linked to, read and read various manuals and built up a better understanding of the memory map of the C64.
It's invaluable to put some effort into doing this stuff (thinking) yourself and realising WHY certain things are done in order to learn.
I'm still uber-noob, but I know that refraining from asking others to solve every single problem I face is the BEST way to learn! Your brain will thank you for it.
Previous - 1 | 2 | 3 | 4 - Next
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
bugjam
Frida Katarina
hedning/G★P
Acidchild/Padua
Frostbyte/Artline De..
Youth
Guests online: 150
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Carrion  (9.8)
2 Joe  (9.8)
3 Duce  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

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