Tile Graphics Renderer
macca
Posts: 780
Hello All,
During the past weeks I wrote a graphics renderer for the vga driver.
Specifications:
Notes:
Attached is a small project demonstrating some of the capabilities. It runs on VGA and should be compatibile with the existing demo boards.
My intentions are to write an engine usable as a base for games development so designers can concentrate on the game and graphics instead of understanding how the drivers and renderers work. I also started to write a rudimentary tile and sprite editor in Java.
I whish to thanks all whose code examples and indirect suggestions have contributed to this code (you'll recognize kuroneko's VGA driver and memory transfer code, sid cog from Johannes Ahlebrand, and inspirations from other code examples).
Feel free to make suggestions and code optimizations.
Hope you enjoy.
demo-bst-archive-130316-114946.zip
During the past weeks I wrote a graphics renderer for the vga driver.
Specifications:
- 256x192 or 256x256 pixels, 6bpp resolution
- 8x8 pixels tiles
- 16x16 pixels sprites
- 16 (out of 64) colors palettes
- Up to 256 tiles, 64 sprites and 64 palettes
Notes:
- Tiles map is 34x34 tiles (instead of 32x32 for 256x256 pixels) to allow scrolling and offscreen background updates.
- Sprites are drawn on a virtual screen with a 16 pixels border around the physical screen to allow objects to move out of the screen. Coordinates 0,0 are out of screen, 16,16 is the top-left corner.
- Sprites palettes are actually 15 colors, with color 0 used as transparency.
- The number of sprites on screen and on a single scanline depends on the number of rendering COGs.
Attached is a small project demonstrating some of the capabilities. It runs on VGA and should be compatibile with the existing demo boards.
My intentions are to write an engine usable as a base for games development so designers can concentrate on the game and graphics instead of understanding how the drivers and renderers work. I also started to write a rudimentary tile and sprite editor in Java.
I whish to thanks all whose code examples and indirect suggestions have contributed to this code (you'll recognize kuroneko's VGA driver and memory transfer code, sid cog from Johannes Ahlebrand, and inspirations from other code examples).
Feel free to make suggestions and code optimizations.
Hope you enjoy.
demo-bst-archive-130316-114946.zip
Comments
Based on my tests, the renderer should have plenty of time to do everything, but you can increase the number of rendering cogs (graphics_renderer.spin, COGS constant, set it to 5).
Wondering why I don't see any difference on my monitor.
That said, the driver sounds pretty nice. I think a 4bpp is the right compromise because you still have a good amount of colors, but can store twice as much data as an 8bpp image. For my game I wish I would have made a 4bpp driver because visually there would have been little, if any, visual difference.
The other important key which it sounds like you are addressing is an easy way to get images into the program. Sure, those of us who are hard core can figure out these scripts and converters, but for a beginner these are daunting and you have to have a good understanding of how it wants the image. Before I made the game, I had an image editor i wrote for Linux which was to be a campanion to the driver to make things easier. This I did not finish, but that is definitely the right direction if you want more than 3 people to use it
All drivers were ported to C and optimized a bit with configuration options to save some bytes when certain features are not used, the engine can be used for both spin and C projects.
A multiplatform Game Tools application can be used to draw tile and sprite graphics as well as import from graphics files. Starting from the last release, it has an integrated code editor that allows to write sketch-like code in C. The application can also call the GCC tools to compile, link and upload the code to a propeller board. The editor doesn't have much features yet, it just has a basic syntax highlight, and gets slow as the code grows, but it is usable. As you may guess, this was largely inspired by the Arduino IDE, from which I borrowed some code, and uses the .pge extension to identify its own files.
The project is hosted on http://dev.maccasoft.com/propge from which you can access the downloadable binaries as well as the source code repository and some documentation. The application is downloadable as tar.gz or .zip files, complete with the spin and c libraries. It requires Propeller GCC and BSTC on the command path to compile and upload code (not included).
Enjoy!
First, this is a wonderful object for the Propeller. I'm using this in my current project. Thank you!
Second, is there any way possible to squeeze a COG away from the Tile Graphics Renderer?
I've tried reducing sprites, and reducing cogs, but this seems to have negative effects on the object's functionality.
Thank you
Jeff
here are what i have done to compile
inside the Makefile i removed the option -q for bstc because bstc complained that this option doesn't exist.
for the pingroup i put 1 inside the vga_driver
what should i have to change in this vga_driver or elsewhere?
Check the pins for the other elements, pin group 1 should be 8-15, the audio driver uses pins 10 and 11, if you haven't changed that it will conflict (sound.c initialize_sound).
but i don't have any sound. For the PropBOE right and left are 26 and 27. So i change only this
but i haven't any music. Note : i'm not at the game screen, i' m at the starting screen.
Yes, the starting screen doesn't have any sound.
It plays a song when starting the game by pressing start and another while playing.
Now the next move is to adapt the controller. Instead of a NES/pad, i have a tilt sensor dual axis 2125 and 2 pushbuttons. I have never played with the dual axis since now. I have tested the 2125 on simple-Ide, it works.
is there any simple way to convert tilt to your nes/pad code?
I never worked with such sensors, I guess you have to set a threshold to detect the direction and avoid false triggers with small movements. Assuming 0 is the central value and +/-128 is the range, I would write something like:
With +/-32 being the threshold.
There is the wii classic controller code that does something similar with the analog joystick. I never tested that code so it may not work as expected but it could be used as a base for your sensor.
i copy your nes_padctrl.c to a new file 2125.c, i replaced the read_gamepad by this
and now i have a frogger game for my son. i won't tell him now otherwise i won't be able to get back my propBoe.
I'll try to port some of your other games.
I wish to have pacman but it will be long before i can port the pacman found in this forum.
if you don't mind i'll share the code to the dedicate thread i post sometime ago on PropBOe and VGA game.
Note: i ported your code to simpleIde. for me it's simpler since i use both windows and linux with different PC.
Edit: i had to modify also the include inside the main.c I don't know if it's the best way to do it. maybe something with should be better but i don't know how to retrive the boardname from simpleIde config file
I'm glad it worked. Feel free to share it as you like.
I don't think the board selection is passed to the compiler, as far as I know it is used only by the loader.