Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Kick Assembler Thread 2
2009-07-21 19:20
Slammer

Registered: Feb 2004
Posts: 295
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 414 posts hidden. Click here to view all posts....
 
2011-10-07 00:38
TWW

Registered: Jul 2009
Posts: 283
F.ex:

I want a spudocommand/routine to behave in three different ways:

#1 - Set a global constant (ex: .const SafeMode = 1) which the automatically preserves all registers within pseudocommands.

#2 - Call up a pseudo with a SafeMode setting which then might overrrule the global setting to allow individual routines behave differently if I so choose.

#3 - If none of them are defined, force a default mode


So basically I want to check if a Constant or a Variable is defined from before.

However I am sure, by your question, you already got a(nother) method to do this^^
2011-10-08 11:38
Slammer

Registered: Feb 2004
Posts: 295
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 18:40
Cruzer

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

Registered: Aug 2003
Posts: 83
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 16:21
Pantaloon

Registered: Aug 2003
Posts: 83
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 08:11
Slammer

Registered: Feb 2004
Posts: 295
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 09:10
Pantaloon

Registered: Aug 2003
Posts: 83
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 14:07
The Dr.j

Registered: Feb 2003
Posts: 73
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 20:42
Cruzer

Registered: Dec 2001
Posts: 719
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 08:29
The Dr.j

Registered: Feb 2003
Posts: 73
@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.

Previous - 1 | ... | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ... | 43 - 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
r242
Zorch
H Macaroni/GSW/G*P
celticdesign/MDG/G¤P
Rayne/X-Stayle/Coven..
STE'86
Ejner/inZane
Yazoo/Censor/Arsenic
6R6/shape
Zyron/GeNos¤ProjecTary
Guests online: 28
Top Demos
1 Edge of Disgrace  (9.7)
2 Coma Light 13  (9.7)
3 Daah, those acid pil..  (9.7)
4 Deus Ex Machina  (9.3)
5 Andropolis  (9.3)
6 Te-Te-Te-TechTech It..  (9.3)
7 +H2K  (9.2)
8 GOLC  (9.2)
9 Artphosis  (9.2)
10 2011 - A Press Space..  (9.2)
Top Groups
1 Booze Design  (9.4)
2 Crest  (9.4)
3 Oxyron  (9.4)
4 Maniacs of Noise  (9.2)
5 Eagle Soft Incorpora..  (9.2)
Top Diskmag Editors
1 Jazzcat  (9.6)
2 Remix  (9.5)
3 Peter  (9.4)
4 Newscopy  (9.4)
5 Jack Daniels  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2013
Page generated in: 0.508 sec.