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-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.
2009-11-03 19:58
NecroPolo

Registered: Jun 2009
Posts: 231
Another coding über-noob here. This thread is a great help, all the essential hints and pieces of knowledge, explanations are here.

Although I have passed the part of understanding the way it works recently and hopefully I will be able to make my first simple one-file demo soon - I still appreciate the helpful attitude.

Respect for that, for all of you. That is the way the things should be.

NP
2009-11-11 18:15
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: or do it the other way round - align the code to the gfx.
This way you save quite some memory to be overwritten:

*=$5c00

hirescolmap
.bin 8002,1000,"gfxfun/rooms2.ip64h"
.dsb 24,0
hiresbitmap
.bin 2,8000,"gfxfun/rooms2.ip64h"

code_start
	
init_gfx
	sei
	lda #$06
	sta $d020
	lda #%00000010
	sta $dd00
	lda $d011
	ora #%00111000	;enable hires + screen on
	sta $d011	
	lda #%01111000  
	sta  $d018


PS: ip64h is interpaint HiRes - gimp with cbmplugs is able to export to this format ;-)
PPS: you could also put the code inside the 24 byte gap between bitmap and colormap but well....


Just what everyone else said x 1000. Thanks a lot to all. Just a quick question. I tried converting the quoted text acme but I don't know what .dsb is in Acme. Anyone know off the top of there head?
2009-11-11 18:21
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Also, where do you get the cbm plugin for Gimp? I tried the CBM Plugin Registry with no luck.
2009-11-11 21:25
enthusi

Registered: May 2004
Posts: 675
http://packages.debian.org/source/lenny/cbmplugs

and .dsb 24,0
means 24 bytes of value 0.
In this case to fill up the gap between 40x25 and 2^10.

Cheers,
enthusi
2009-11-12 02:21
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Wow! Thanks!
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
fox/bonzai
Didi/Laxity
d0c
radius75
Moderators/CSDb Staff
Krill/Plush
Apollyon/ALD
Mr. SID
Guests online: 136
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 Bromance  (9.6)
10 Memento Mori  (9.6)
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 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Jeroen Tel  (9.7)
3 Stinsen  (9.6)
4 Mutetus  (9.6)
5 Linus  (9.6)

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