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 > Kick Assembler Thread 2
2009-07-21 17:20
Slammer

Registered: Feb 2004
Posts: 416
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 592 posts hidden. Click here to view all posts....
 
2011-10-08 09:38
Slammer

Registered: Feb 2004
Posts: 416
I would do something like this:
//---------------------------------------------
// Mode Control
//---------------------------------------------
.enum {MODE1, MODE2, UNSET}
.const defaultMode = MODE1
.var mode=UNSET
.function getMode() { 
	.if (mode==UNSET) return defaultMode
	.return mode
}  
//---------------------------------------------
// Commands
//---------------------------------------------
.psesudocommand myCmd a; b {
	.if (getMode()==MODE1) {
	 	/* DO SOMETHING */
	}	

	.if (getMode()==MODE2) {
	 	/* DO SOMETHING */
	}	

}
2011-10-12 16:40
Cruzer

Registered: Dec 2001
Posts: 1048
A little request: When a branch distance gets too far, it would be nice to know by how much.
2011-10-19 11:46
Pantaloon

Registered: Aug 2003
Posts: 124
I wrote a useless test with a zooming 2x2 char fonts, here is the routine in KickAsm that precomputes all the scaled characters if someone is interested.

	.pc = $6000 "Zoomed Font"

	.const c_zoomLevelCount = 19
	.const c_zoomMin = 0.15
	.const c_zoomMax = 1
	.const c_charCount = 30

	//
	// load the font into 16x16 pixel chunks
	//  

		.var originalFont = List()

		.var charsetFont = LoadPicture("data/fonts/2x2_formaterad.gif", List().add($000000, $ffffff))
		.for (var c = 0; c < c_charCount; c++)
		{
			.var theChar = List()
			.for (var y = 0; y < 16; y++)
			{
				.for (var x = 0; x < 16; x++)
				{
					.var p = charsetFont.getPixel(x + c * 16, y) & 255
					.eval theChar.add(p)
				}
			}
			.eval originalFont.add(theChar)
		}

	//
	// create zoomed versions
	//  
		.function linearInterpolate(a,b,t)
		{
			.return [a*[1.0-t]] + [b*t]
		}

		.macro scale16x16(source, dest, zoom)
		{
			.var xratio = zoom
			.var yratio = zoom

			.var xoffset = [1-xratio] * 8
			.var yoffset = [1-yratio] * 8

			.for (var dy = 0; dy < 16; dy++)
			{
				.var sY = round([dy * yratio] + yoffset)
				.for (var dx = 0; dx < 16; dx++)
				{
					.var sX = round([dx * xratio] + xoffset)
					.eval dest.set(sX + sY*16 , source.get(dx + dy * 16))
				}
			}
		}

		.for (var c = 0; c < c_charCount; c++)
		{
			.for (var zoom = 0; zoom < c_zoomLevelCount; zoom++)
			{
				.var t = zoom / [c_zoomLevelCount-1]
				.var zoomLevel = linearInterpolate(c_zoomMin, c_zoomMax, t)

				.var originalChar = originalFont.get(c)
				.var destChar = List()
				.for (var i = 0; i < 256; i++)
					.eval destChar.add(0)

				:scale16x16(originalChar, destChar, zoomLevel)

				.for (var j = 0; j < 2; j++)
				{
					.for (var y = 0; y < 16; y++)
					{
						.var theByte = 0
						.for (var x = 0; x < 8; x++)
						{
							.var yy = y
							.var xx = x + j * 8

							.var addr = xx + yy * 16

							.if (destChar.get(addr) == 255)
								.eval theByte = theByte | [1 << [7-x]]

						}
						.byte theByte

					}
				}

			}
		}

2011-11-01 15:21
Pantaloon

Registered: Aug 2003
Posts: 124
I found a bug (i think) with the .importonce directive.

Lets say i have A.s containg this

.importonce
.var tracksector_hashtable = Hashtable()
.eval tracksector_hashtable.put("STARTUP",TRACKSECTOR(1,0))

And another file, B.s looking like this:

.import source "A.s"
.var ts = tracksector_hashtable.get("STARTUP")

Will produce this error:
Error: Unknown symbol 'tracksector_hashtable'

2011-11-02 07:11
Slammer

Registered: Feb 2004
Posts: 416
Panta: Late night coding i guess? :-)

My guess is that you have several .import statements and that the first one is inside a scope, so when you want to access the variable from another file it's out of scope?

I will have to see some example source to say anything precise.

You can check in which scope the tracksector_hashtable is placed yourself by:

1. Change the tracksector_hashtable to a label (.label tracksector_hashtable =...)
2. Comment out the line that fails
3. Assemble and look in the symbol file in which scope tracksector_hashtable is placed.

The symbolfile is not meant for reading (but for .importing) but it should be readable.


Btw. Making a more structured solution to scoping (also for functions and macros) is something thats on the TODO list for a version 4.0.
2011-11-02 08:10
Pantaloon

Registered: Aug 2003
Posts: 124
Thanks Slammer, i will try it out. If i can't find any obvious errors i'll send you the sourcecode :)

-panta
2011-11-02 13:07
Dr.j

Registered: Feb 2003
Posts: 277
2 fast quest. from a newcmmer to KickAsm.2
i really new with this stuff so try to easy with me.
1. i want to create macro which just print the
value of $d012 .
2. can i send chunk of data to a list? f.ex: i want
to send location lets say $400-$500 to macro/func. and it
will add it to a list and then do some calc. and store
it back or to the same or other location. to simplify
lets say we add $06 to all the list and store it back.


2011-11-02 19:42
Cruzer

Registered: Dec 2001
Posts: 1048
Dr.J: Macros etc. are for making life easier at compile time, not at run time. So you can't operate on memory content or registers. If you want manipulate the content from $400-$500, you have to keep it in Lists until all the calculations are done before storing it to memory.
2011-11-03 07:29
Dr.j

Registered: Feb 2003
Posts: 277
@Cruzer: can you show me ex. of precalc how do i
send the $400-$500 to a list and store it back.
i know how do create bytes from list but didn't see
the opposite.

2011-11-03 08:55
JackAsser

Registered: Jun 2002
Posts: 1997
Quote: @Cruzer: can you show me ex. of precalc how do i
send the $400-$500 to a list and store it back.
i know how do create bytes from list but didn't see
the opposite.



What exactly are you trying to accomplish?!? I mean... the assembler can not know what the memory contents on the real device are when assembling.

If you would like to simply add the value 6 to all bytes between $400-$500 you either write a simple assembly loop, or use Lists and macros to generate speed code.
Previous - 1 | ... | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ... | 61 - 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
csabanw
Mibri/ATL^MSL^PRX
nucleus/TempesT
Krill/Plush
MCM/ONSLAUGHT
t0m3000/HF^BOOM!^IBX
REBEL 1
Freddie
Guests online: 67
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Original Suppliers
1 Black Beard  (9.7)
2 Derbyshire Ram  (9.5)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Jazzcat  (8.6)

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