opcode, on Thu Dec 1, 2005 7:28 PM, said:
Problem is, how would you define a tile in Graphic 2 mode? It would require a lot of writing, becoming a tedious process. I was thinking of a higher level language. Like, once you have created the tiles using the graphic tool, you would use the following syntax to load it:
DIM mygraph as GDATA = c:\<some path>\graph2.scr
mygraph.load(0,0) 'load graphic data to vram starting in character table 0, position 0
graph2.scr is a special file, with compressed graphic data generated by the graphic tool. It will be linked to the ROM image in compile time.
Actually, I was thinking the same thing, but I didn't get the chance to elaborate. There are so many issues with your above reply that it's going to take a while for me to formulate a complete response. Just keep in mind that my explanations will probably contain several flaws because my understanding of the CV hardware is very limited. But I'm sure we can iron things out together. I just hope you can see things my way...
First of all, in my vision of the dev kit, the programmer first creates a "project" and selects the total cartridge size (16K, 32K, 64K). The project regroups such entities as pattern tables, title screen layout (with the multi-colored "COLECOVISION" label at the top of the screen), game screens (a.k.a. name table data), sound data and other types of binary data together with the central source code, and all these entities are saved in separate data files under the same project directory, and will be all linked together automatically by the compiler/linker upon ROM generation. Of course, the entities (pattern tables, sounds data, etc.) can be exported and imported in other projects later.
The dev kit would offer a graphical interface for everything that can be presented graphically. For example, imagine a window with a rectangle of 128x256 pixels, where each pixel represents one byte of a 32K ROM space. The bytes already taken by data appear as red pixels, and the free bytes are shown as green pixels. With this interface, you can see at a glance how much space you have left to work with at any time. Under this rectangle, there would be a combo-box with a list of entities defined by the programmer, and when he selects one of these entities in the list, the bytes taken by this entity in the ROM space appear as yellow pixels in the rectangle. For example, select a game screen, and the 768 contiguous bytes taken for this game screen appear in yellow in the ROM space rectangle.
Pattern tables and other entities are external to the main source code of the game, and are referenced by name. This means that your line of code:
DIM mygraph as GDATA = c:\<some path>\graph2.scr
would look more like this:
LET adr_pat_tab_1 = ADR "pattern_table_1"
where "adr_pat_tab_1" is the name of a variable, and "pattern_table_1" is the name given to one of the entities (in this case a pattern table) defined by the programmer under the current project. Of course, the instruction above is pointless unless you want to do something special with the pattern table, because under normal circumstances, all you need to load a pattern table in VRAM is a command like this one:
LOAD PATTERN TABLE "pattern_table_1"
When the compiler/linker generates the ROM file, the starting address of "pattern_table_1" is known, so the LOAD PATTERN TABLE instruction translates into a single "memcopy" operation of 2048 bytes between the ROM space and the VRAM (I'm assuming the CV hardware offers an easy way to do a memcopy like that). This perfectly illustrates the goal of the language: To allow the programmer to work in assembly, without having to write actual assembly code!
opcode, on Thu Dec 1, 2005 7:28 PM, said:
In addition you can have something like this to control the fine details:
DIM mytile as GTILE = 2,0 'mychar is tile # 0 in pattern table #2 (or 3rd third)
mytile.color=(2,0;2,0;3,0;3,2;3,2;3,0;2,0;2,0) 'define all colors for a tile
or yet
mytile.color(2)=(3,0) 'define colors for line 3 in tile
I don't think defining such color data within the source code is a good idea (it should be done at the project level via the GUI of the dev kit), but I guess the programmer can need to modify the colors during run-time... To be honest, I haven't given much thought to the differences between the graphic modes, so this will require further discussions.
However, no offense Eduardo, but using object-oriented syntax like "mytile.color()' is exactly the kind of thing I want to avoid with this dev kit. What I'm aiming for is a language that is easy to read and also directly translates into CV machine code.
opcode, on Thu Dec 1, 2005 7:28 PM, said:
Quote
The above example is an introduction to my philosophy for the proposed language: Keep things at a low, almost assembly level, but always keep it readable. Beginners can understand concepts such as "name table", "pattern table" and "color table" as long as it's explained in a basic way in tutorials, and so these should simply be "usable components" within the language.
But in this case, wouldn't be C good enough?
Allow me to tell you a story to illustrate my point of view: When I was studying at my local university in computer programming, there was a debate among teachers as to what language should be taught to first-year students. They discussed Pascal, ADA, some other languages, but one thing was unanimously agreed upon by all the teachers: C/C++ was NOT an acceptable option. Why? Because the syntax is too rough for beginners, and the compilers are generally too permissive. Building compiler/linker safeguards into something as loose as C syntax is downright impossible, and it is far more easy to do so in a language like the one I'm proposing. I want this dev kit to be something else than a glorified C compiler.
opcode, on Thu Dec 1, 2005 7:28 PM, said:
The joysticks and keyboards requires a relatively long setup time before you can read them, so accessing them in real time isn't a good idea. It is better to read them just a single time inside the NMI. Then you can store the current status and the changes from previous read, so you can know if a button was just pressed or released for example.
This way you can do:
DIM myjoy as JOYSTICK = 1 'joystick player 1
if myjoy.changed.fire1 then.......
I'm not sure I understand your explanation (mostly because I don't know what the NMI is) but I'm sure we can adjust the language to deal with this delay problem. And again, I must say I don't like using the C++ syntax...
opcode, on Thu Dec 1, 2005 7:28 PM, said:
Quote
Yet another example: Let's say you want to set sprite #1 (of the 32 available sprites) at a certain location on the screen. It would be done like this:
SET SPRITE 1 AT 45 151
Other variants are possible:
SET SPRITE 1 PATTERN 245
SET SPRITE 1 COLOR 0 13
SET SPRITE 1 AT 45 151 PATTERN 245 COLOR 0 13
This puts the sprite at x=45, y=151 on the screen, sets the sprite to use pattern #245 in the sprite descriptor table, and sets the sprite color to the transparent/magenta combo. Same as before, these are translated into simple "poke" commands in the generated ROM image, and integer variables can be used instead of constants:
SET SPRITE a PATTERN b
SET SPRITE a COLOR b c
SET SPRITE a AT b c PATTERN d COLOR e f
Ok, but you would still need some macros for easier animation
It's funny you should mention that, because this raises the main issue which prevents me from forming a complete picture of the dev kit's language in my mind: How does a programmer set the overall speed and timing of objects within a game? And how does sound output fit into all this? This is an issue which remains a complete mystery to me, because all the programs I've written in my life were designed to perform jobs as quickly as possible, and I never had to calibrate a running program to a specific speed of execution, to make it normally playable. I've heard about the "vsync technique", but that's for PCs, right? If I could get a real handle on that concept, it would help me tremendously...
opcode, on Thu Dec 1, 2005 7:28 PM, said:
I would suggest several objects here:
DIM mysprset1 as SPRITESET = (2)
DIM mysprset2 as SPRITESET = (2) .... 'define several sprite sets for animation, 2 sprites each
mysprset1.pattern=(0,1)
mysprset2.pattern=(2,3)
mysprset1.color=(6,4)
mysprset2.color=(9,4)
mysprset1.xoffset=(0,0)
mysprset2.xoffset=(0,16)
mysprset1.yoffset=(-8,

mysprset2.yoffset=(0,0) 'define pattern, color, x and y offset in the sprite set
Then:
DIM mychar as CHARACTER
mychar.spriteset=mysprset1
mychar.x=10
mychar.y=32
Maybe we would even create a few extra macro structures....
Hmm... So you want to put an extra layer of abstraction between the programmer and the actual hardware sprites... Considering we only have 1K of RAM to work with, do you think it's really a good idea to create extra data structures like that? Not that's it's really a bad idea or anything, I'm just concerned.
opcode, on Thu Dec 1, 2005 7:28 PM, said:
Quote
(BTW, can the CV do floating-point arithmetics, or is it limited to integer math? What about the SEM?)
Since both are based on the Z80 CPU, you can't do floating-point math by hardware.
That's okay, we can live without it for now, I guess. I assume that standard integer values are coded on two bytes, and that they can be signed or unsigned?