Re: [cc65] The most critical operations of the C runtime

From: Emanuele Fornara <emanuele.fornara1gmail.com>
Date: 2007-09-13 18:31:04
Hi Oliver,

> Generally this heavily depends on the application. [...]

you are right, maybe some context would be helpful; mentioning the "IO
chip" was perhaps misleading.

The main applications should be games and the most common operations
are expected to be "register setting" for the graphics of the game
(say 10-20 registers in page 2) and "accessing of C structures" for
the logic of the game. Most common datatypes are expected to be
unsigned chars, array indexes and pointers.

I think a scenario people can relate to is a game for the C64, where
graphics is done by changing registers of the VIC II (e.g. positions
of a sprite); unlike the C64, bulk memory operations shouldn't be very
common.

I was thinking more about "pure C" optimization (libsrc/runtime in
cc65), for example:

unsigned char *IO = 0x200;

struct Enemy {
	enum state_e state;
	unsigned char energy;
	unsigned char x;
	unsigned char y;
};

struct Enemy enemy[MAX_ENEMY_ID];

void update_enemy(unsigned char e) {
	enemy[e].x += 10;
	enemy[e].y += 10;
	IO[10] = 10 + e;
	IO[11] = enemy[e].x;
	IO[12] = enemy[e].y;
}

I would like a beginner C programmer to write that kind of code and
not to worry too much about the overhead of, say, function calls.

Emanuele
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Sep 13 18:31:22 2007

This archive was generated by hypermail 2.1.8 : 2007-09-13 18:31:25 CEST