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 > is there a putpixel example ?
2006-03-27 03:16
Trifox
Account closed

Registered: Mar 2006
Posts: 108
is there a putpixel example ?

Hi, i wonder if there is a easy to read example wich plots exactly one pixel in a particular gfx mode? on to a given coordinate?
2006-03-27 07:31
WVL

Registered: Mar 2002
Posts: 902
you really should read the 'Programmers Reference Guide' or 'Mapping the C64'..

http://www.unusedino.de/ec64/technical/project64/programmers_re..

http://www.unusedino.de/ec64/technical/project64/mapping_c64.ht..
2006-03-27 07:41
Frantic

Registered: Mar 2003
Posts: 1648
@trifox

Generally, this is not the way to go if you want to code demo effects on the C64 since it will be very slow (too slow!). If demo effects is what you want to do, then half the work is figuring out how to put several "pixels" at once, in a way that suits the particular effect you are trying to achieve. But, of course, there may be other cases when a putpixel routine is needed, so I'm not trying to be "smart" here. Just telling you, in case you didn't know.
2006-03-27 09:02
Oswald

Registered: Apr 2002
Posts: 5094
trifox, here is the easyest way:

set up a 16x16 character "matrix" on the screen. a little explanation how it would look like:

@p..............
aq..............
br..............
cs..............
dt..............
e...............
f...............
g...............
h...............
i...............
j...............
k...............
l...............
m...............
n...............
o...............

(ofcourse you have to fill up the whole matrix according to the rule you see above)

what you have won with this ? we have plotted consecutive characters under eachother on the screen, so we can adress each column of the matrix like this:

ldy ycoord
sta column,y

as simple as that.

we will need the following tables (first look at the code, then the tables will be more straightforward)

mul128low/high, are two tables containing:

for t=0 to 128
column=((x/8)*128)+adressofyourcharacterset
mul128low(t)= low8bit(column)
mul128high(t)=high8bit(column)
next t


mask table is :

for t=0 to 128
mask(t)=2^7-(t and 7)
next t


(in general mask should contain this data:

%10000000
%01000000
%00100000
%00010000
%00001000
%00000100
%00000010
%00000001

and starting now over from %100000000)


how to plot to a given x,y coordinate ?

ldy ycoord
ldx xcoord
lda mul128low,x
sta $fe
lda mul128high,x
sta !ff

lda mask,x
ora ($fe),y
sta ($fe),y


plotting to a bitmap is not much more complicated (if we restrict the screen to 32x25), wanna see an example for that too ? ;)

also there's a method invented by graham which uses 3 character sets to cover 32x25 chars, its slightly faster then plotting into a bitmap. but the fastest is the above 16x16 char stuff.
2006-03-27 11:20
Trifox
Account closed

Registered: Mar 2006
Posts: 108
aha, 16x16 charachters = 128x128 pixels?

i have some particular effects in mind which rely in pixel access ... ;(
2006-03-27 12:04
Oswald

Registered: Apr 2002
Posts: 5094
in hires mode, yes.
2006-03-27 12:12
Graham
Account closed

Registered: Dec 2002
Posts: 990
If you want to do bitmap plotting, it's best to use address tables for each rasterline. This routine will calculate the addresses of each rasterline on a bitmap:
 LDX #$00
loop:
 TXA
 AND #$07
 ASL
 ASL
 STA $FC
 TXA
 LSR
 LSR
 LSR
 STA $FD
 LSR
 ROR $FC
 LSR
 ROR $FC
 ADC $FD
 ORA #$20 ; bitmap address $2000
 STA YTABHI,X
 LDA $FC
 STA YTABLO,X
 INX
 CPX #200
 BNE loop

For horizontal access, you need these tables for hires pixels:

 LDA #$80
 STA $FC
 LDX #$00
loop:
 TXA
 AND #$F8
 STA XTAB,X
 LDA $FC
 STA BITTAB,x
 LSR
 BCC skip
 LDA #$80
skip:
 STA $FC
 INX
 BNE loop

Plotting a pixel would be:

LDA YTABLO,Y
STA $FC
LDA YTABHI,Y
STA $FD
LDY XTAB,X
LDA ($FC),Y
ORA BITTAB,X
STA ($FC),Y

Lores (160x200) ofcourse needs different XTAB and BITTAB.
2006-03-27 12:15
Cruzer

Registered: Dec 2001
Posts: 1048
@Frantic: You gotta be able to crawl before you can walk. I think learning how to plot single pixels is a good place to start for a n00b, then layer, when Trifox he gets annoyed that it's so slow, he might get motivated for learning how to optimize his code.
2006-03-27 12:26
Oswald

Registered: Apr 2002
Posts: 5094
cruzer, how true. the learning curve always goes from slow routines -> fast routines. Without understanding the slow way, you have not much chance to understand the fast way.
2006-03-27 12:33
Radiant

Registered: Sep 2004
Posts: 639
Yeah, you won't exactly break any world records by ORA single pixel plotting, but it's a nice way to start. All my plotters this far have been one pixel at a time.
2006-03-28 15:51
Trifox
Account closed

Registered: Mar 2006
Posts: 108
thank you for tips, i have not finished yet exploring the pixelset stuff, but i made my first sprite multiplexer:

http://www.digitalgott.com/c64/sprites_dotflag.prg
and source:
http://www.digitalgott.com/c64/sprites_dotflag.a

what you think ;)it is all done with sprites, display is not switched off, but turned black ... what is now the best way to put a ~stable raster line on the top or bottom ?

har har, and i can even put text on the right side ...




2006-03-28 17:02
Trifox
Account closed

Registered: Mar 2006
Posts: 108
i made another sprite multiplexer routine :

this one 16x8 Sprites are moved independently on x axis :)

source:
http://www.digitalgott.de/c64/sprites_double.asm

bin:
http://www.digitalgott.de/c64/sprites_double.prg
2006-03-29 06:37
Oswald

Registered: Apr 2002
Posts: 5094
looks like some of those "experimental" flash stuffs :)
2006-03-29 08:38
Skate

Registered: Jul 2003
Posts: 494
@trifox: Not bad at all. I think you've a good coding background but now you are interested in c64 platform. Correct me if I'm wrong.
2006-03-29 16:13
Cruzer

Registered: Dec 2001
Posts: 1048
nice previews, reminds me of some of my first routines from 1989-90.
2006-03-31 23:29
Trifox
Account closed

Registered: Mar 2006
Posts: 108
hi, thanks for replys,

@skate yes i did all this stuff on the good old amiga, and now ( in my first week of c64 coding ... ;)) i try to reimplement most of the effects i know so far, nothing special at all, just sine/cosine playing, i just finished a nice text mode dotflag ... ;)

exe
http://www.digitalgott.com/c64/dotflag.prg
src
http://www.digitalgott.com/c64/dotflag.asm

most of my sample codes consists of exxcesive macro usage, this is mostly because of the ugly 256byte page jumping around, so if i want to fill a line of text i make a macro
and use this macro 25 times ... ;)

now i am ready to do some more interesting stuff, i will open a new thread for getting info about linedoubling ...


but here is just another piece of code, a big text scroller
src
http://www.digitalgott.com/c64/scrolltext_smooth.asm
exe
http://www.digitalgott.com/c64/scrolltext_smooth.prg

and i also started a little demo editing toolkit for windows, here is the sinus editor for the sprite multiplexer:
http://www.digitalgott.com/c64/c64_sineditor.exe

and due to the fact that i want to achieve a plasma effect on c64 i made also an opengl plasma editor ;)
http://www.digitalgott.com/c64/c64_plasma_editor.exe
2006-04-01 05:29
Oswald

Registered: Apr 2002
Posts: 5094
nice to see you're making fast progress ! :)

little advice for the dot flag: make the x and y movement about the same speed. Currently x speed is too high and its not so nice. Also if you use a bitmap plotter you could have a much bigger amplitude. As the fx looks now, it could be done with animated characters ;)

2006-04-01 07:38
Trifox
Account closed

Registered: Mar 2006
Posts: 108
... sorry, it actually IS DONE by animating charachters ... ;) 25*15 charachters, hehe, i have not implemented anything using bitmaps ... ;//
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
JEZ
kenji/dream
Mr. Lee
Meikel aka ZUX/Sparks
Andy/AEG
Bieno/Commodore Plus
jicas/Patagonia
leonofsgr/Singular C..
Guests online: 101
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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