[Alpha] QASM - A Simplified CA65 with Debugger Output

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Wave
Posts: 110
Joined: Mon Nov 16, 2009 5:59 am

Post by Wave »

I'm glad I can be of any help. If this assembler has all the features I have in NESHLA I'll try to switch to it (losing switch and while statements I guess)

EDIT:
Also on structs maybe it could be like:

Code: Select all

.equ NUM_PLAYERS 4
.struct struct_players
    .res x 2
    .res y 2
    .res life
.endstruct

.res players struct_players NUM_PLAYERS
So it creates player X and Y as 2 * NUM_PLAYERS, this way you only use the number of objects once and every entry can have a different size.
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Yea, that's what I assumed from your first post. Here's the example code I've written:

Code: Select all

; Define a data structure
.datastruct object
	.res x		2	; X position in pixels / 16
	.res y		2	; Y position in pixels / 16
	.res vx		1	; X velocity in pixels / 16
	.res vy		1	; Y velocity in pixels / 16
	.res shape	1	; Shape number
.enddatastruct


; Create a single object instance
.struct player object


; Create a table of objects
.equ MAX_OBJECTS 16
.struct game_objects object MAX_OBJECTS


; Define an initialized object instance
.data some_obj object x=0x0170, y=0x00a0, vx=48, vy=0, shape=7


; Define an initialized table of objects
.table object_templates object
	.data x=0x0170, y=0x00a0, vx=48, vy=0, shape=7
	.data x=0x0170, y=0x00a0, vx=96, vy=0, shape=4
.endtable
These directives take care of an awful lot of problems I have when defining data for my game. I think this will make the whole process much smoother.

One thing I also like is that this will be easy for an external tool to parse the initialized data tables. For instance, I have a script that generates a tile set image based on definitions, graphics files and palette files. I could easily read the tile definitions in from the table definition.

Thanks for all of the inspiration! I now have a road map through version 0.05 :d
Wave
Posts: 110
Joined: Mon Nov 16, 2009 5:59 am

Post by Wave »

This is for discussion but it seemed it was easier to access data in "non interleaved" fashion, like:
x,x,x,x,y,y,y,y,z,z,z,z
instead of x,y,z,x,y,z,x,y,z

In interleaved you have:
ldx numplayer * sizeof(data)
lda data + offset(z), x
On non interleaved:
ldx numplayer * sizeof(z)
lda data.z, x

As struct sizes can be any number and variables inside a struct would usually be 1~4 bytes, seems that non-interleaved would be better.
(as stated on KNES C library recommendations)
Also you could access more than 256 bytes using only the x register (up to 256bytes per struct entry)

I don't know if it's clear what I'm saying...
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

What I am talking about is specifying the data in an interleaved fashion, but outputting it in a non-interleaved fashion.

So this code:

Code: Select all

.table object_templates object
	.data x=0x0170, y=0x00a0, vx=48, vy=0, shape=7
	.data x=0x0170, y=0x00a0, vx=96, vy=0, shape=4
.endtable
Would be equivalent to this code, but with an easier to understand syntax:

Code: Select all

.scope object_templates
	x: .word 0x0170, 0x0170
	y: .word 0x00a0, 0x00a0
	vx: .byte 48, 96
	vy: 0, 0
	shape: 7, 4
.endscope
This gives you the convenience of C-style structs and the runtime efficiency of tables.
Wave
Posts: 110
Joined: Mon Nov 16, 2009 5:59 am

Post by Wave »

Yeah, yeah, that's what I was talking about too :)
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Updated to version 0.04 with conditional assembly support. Man, that was a major rewrite :D It will be a lot easier to implement new features now though.

The next thing I will work on is data structures. I want to use them when I port over my demo.
Wave
Posts: 110
Joined: Mon Nov 16, 2009 5:59 am

Post by Wave »

Cool, I'm waiting for that part to try to port over my nes framework to it.
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Yea, definitely wait a bit. I have found and fixed a ton of bugs in version 0.04 that came from the rewrite. I am going to wait until I've ported over some of my own code with 0.05 before I release it so I can try to get some of the bugs out :D
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

I have realized that the whole data structure thing is a little mis-guided. It breaks if you allow fields to be larger than one byte. It is still very useful for that though. You just have to address your multi-byte values as individual bytes.
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Updated to version 0.05 with support for data structures. I have ported my entire scrolling demo over to this assembler and fixed a lot of bugs in the process.

If anyone wants to try this out, now is the time. I am going to start working on my demo again using this assembler. Hopefully that will work out any more bugs that may be present.
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Minor update, I added a syntax highlighting definition for notepad++ including folding.
User avatar
qbradq
Posts: 952
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

Well I finally caught up on my documentation so I figured I'd go ahead and release version 0.7. Here's what's changed:

Version 0.7

* Macro parameter expressions are now scoped to the line invoking the macro, not the macro body
* Added offset and length parameters to the .incbin directive
* Added option to print the memory map to the screen following assembly
* Added support for custom character encodings
* Added the .encoding, .endencoding, .char, .range and .text directives
* Fixed a bug that created invalid addresses when forward-referencing zero-page labels
* Fixed a bug that prevented the use of labels within macros defined outside of a segment block
* Added .__size__ default labels for data structure definitions, objects, object arrays and data tables
* Added .__count__ default labels for objects, object arrays and data tables
* Added .__size__ and .__count__ default labels to all .res labels

Version 0.06

* Fixed missed requirement: macro bodies are scopes without an associated label address
* More useful error messages for bad named value pairs
* Fixed a crash bug that occurred when a macro parameter name masked the name of a label within the macro's parent scope
* Added the .error directive
* Added support for multiple symbols to the .ifdef and .ifndef directives


I am very happy with the progress made on the assembler. As I continue to use it for my projects I keep adding nice features and finding the bugs. Hopefully this will be ready to use by others soon :D
Post Reply