Thanks Mike. I will look into that. I'm in the experimentation phase and hoping I can use this in a future game. I enjoy figuring out a solution and acknowledge it might not be the most efficient, but it's easier to learn by doing than just reading about it for me. But that said, I really appreciate any advice from those who have already trodden the path and more experienced
I was hoping you might comment as you always give very solid and knowledgeable answers.
My rationale for this first set up is that I thought that because double height characters are @A, BC, DE (each character on top of the other) that if I stack them vertically then calculating the Y starting position of something I want to draw is just a byte offset in the character memory. Then, if we stick with character aligned for the X position for a moment, I only need to know the address of the column to draw from then use the Y offset to get to the right place in memory.
AddressTable is something I added to TRSE to help with a traditional character display, but it can be used for anything where a lookup of sequential integers / addresses are required. So in that context, imagine your 22 x 23 character display, each integer (in TRSE this is a WORD - two bytes) in the address table is the start address of a Y position on the screen. As such I can get to any character address on the screen quite quickly with:
Code: Select all
screenmemory := addresstable( scr, 0, ypos );
screenmemory[ xpos ] := 1; // put an A character as xpos, ypos
This generates the following ASM:
Code: Select all
lda ypos
asl ; *2
tax
lda scr,x ; Address of table lo
ldy scr+1,x ; Address of table hi
sta screenmemory
sty screenmemory+1
lda #1
ldy xpos
sta (screenmemory),y
* The trade off with TRSE is that it makes writing and understanding code easier in some ways especially as your programs get larger, but it won't be as efficient as writing the ASM directly yourself - although you can jump into ASM code at any point and Nicolaas is constantly improving / optimising the output.
In my example code above, which is just a dump of what I got working as my first effort and can certainly be improved, just uses the address table to get the Y position to plot the double height characters in rows followed by columns.
So I could check that I am able to write to every block of 8 pixels on the screen, I have that DrawOnBitmap procedure. It's just a dirty bit of code for that purpose at the moment and it just goes down character memory starting from the 16th double character, and has a wait for VBL delay so I can see it drawing a simple pattern.
What I plan to do next is to create a routine to plot an 8x8 character image at any character aligned location on the screen. I will likely create another address table to specify where the start of a column (X position) is in memory for the character data and can use something like the following to know where to start drawing to:
Code: Select all
screenmemory := addresstable( charData, 0, xpos );
screenmemory[ ypos ] := 255; // put a line of pixels at xpos / ypos
Following that, for version 1, I will be looking to make a pre-shifting routine for character data I will use as sprites or want to plot at a non-character boundary and something that will draw that character with EOR. My sprites will be 8x8 or 8x16 (or any height for that matter). For version 2 I might dip into masks and images larger than 8 bits wide.
Hope that makes sense as to where I am going with this.