Turbo Rascal - Vic Bitmap Mode
Moderator: Moderators
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Turbo Rascal - Vic Bitmap Mode
Hey everyone. This is a follow up from my original question in the Programming board (Bitmap screen and Omega Race) about creating a full screen bitmap. Thanks to DarwinNE and Mike for pointing me in the right direction.
I'm now more than half way through a set of commands for Turbo Rascal that provide some common functionality for working with a bitmap on the Vic 20.
I decided to go with a 20 x 24 character sized screen as that uses up all the available characters. This gives 160 x 192 pixels to play with and looks pleasant on the screen in both PAL and NTSC.
There is also an 19 x 24 character sized mode for the screen that hides the 20th column which can be used for horizontal scrolling in a similar fashion as the C64 does it - allowing you to draw to this hidden column and allow the graphics to scroll into view. I haven't looked at vertical scrolling yet, but perhaps another time.
For scrolling you specify a start line and end line to scroll either left or right. Here's an example of a little parallax effect by scrolling some areas more than others - it looks better in runtime, my recording software has not captured each frame accurately. Click to view animation
Pixel scrolling takes time, to do the whole screen is taking roughly one and a half raster refreshes, so the maximum you can expect is 25/30 frames per second and a little time for your game / demo code. Reducing the area you scroll will let you nip in under the 50 / 60 fps mark. It can comfortably scroll a 64 pixel high text scroller for example.
There is also a very fast 8 character horizontal scroller, it achieves this by positioning the character map that makes up the bitmap.
A core requirement will of course be sprites. I'm implementing two very easy to use sprite routines (an 8x8 and a 16x16) which will cover most use cases, but also a option to create sprites up to the size of the screen should you wish to. Sprite drawing can be done in OR, EOR or AND modes, the latter useful for 'cutting out' from the background or if you wish to have a masked sprite.
Here's a simple 8x8 sprite. The colour banding is how much time it is taking to clear (cyan), position (red) and draw (green), so it should be fast enough to have many sprites on screen.
Click to view animation
Other commands (some implemented, some still todo) are dots, blots (big dots), tiles, tile maps, copy/paste, text, bcd numbers and collision/pixel tests. I'll post some further updates for anyone interested in this project as time goes on. I hope to have everything done, including documentation just after Christmas and released in TRSE for anyone to use in the new year.
I'm now more than half way through a set of commands for Turbo Rascal that provide some common functionality for working with a bitmap on the Vic 20.
I decided to go with a 20 x 24 character sized screen as that uses up all the available characters. This gives 160 x 192 pixels to play with and looks pleasant on the screen in both PAL and NTSC.
There is also an 19 x 24 character sized mode for the screen that hides the 20th column which can be used for horizontal scrolling in a similar fashion as the C64 does it - allowing you to draw to this hidden column and allow the graphics to scroll into view. I haven't looked at vertical scrolling yet, but perhaps another time.
For scrolling you specify a start line and end line to scroll either left or right. Here's an example of a little parallax effect by scrolling some areas more than others - it looks better in runtime, my recording software has not captured each frame accurately. Click to view animation
Pixel scrolling takes time, to do the whole screen is taking roughly one and a half raster refreshes, so the maximum you can expect is 25/30 frames per second and a little time for your game / demo code. Reducing the area you scroll will let you nip in under the 50 / 60 fps mark. It can comfortably scroll a 64 pixel high text scroller for example.
There is also a very fast 8 character horizontal scroller, it achieves this by positioning the character map that makes up the bitmap.
A core requirement will of course be sprites. I'm implementing two very easy to use sprite routines (an 8x8 and a 16x16) which will cover most use cases, but also a option to create sprites up to the size of the screen should you wish to. Sprite drawing can be done in OR, EOR or AND modes, the latter useful for 'cutting out' from the background or if you wish to have a masked sprite.
Here's a simple 8x8 sprite. The colour banding is how much time it is taking to clear (cyan), position (red) and draw (green), so it should be fast enough to have many sprites on screen.
Click to view animation
Other commands (some implemented, some still todo) are dots, blots (big dots), tiles, tile maps, copy/paste, text, bcd numbers and collision/pixel tests. I'll post some further updates for anyone interested in this project as time goes on. I hope to have everything done, including documentation just after Christmas and released in TRSE for anyone to use in the new year.
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Oh, forgot to mention, sprites are pre-shifted. You can import your own, ready-shifted if you wish, but I've also implemented a routine to create the pre-shifted sprites at runtime. Good to keep your program size on tape / disk down and use areas of ram such as the tape buffer or cartridge space RAM for example.
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Here's some example code showing how to use the 8x8 sprite commands.
The draw command uses an OR operation and the clear uses AND. The latter can be used to draw masks for the sprites too. There is an EOR operation too.
As mentioned previously, there is also a 16x16 version and sprite slices that allows any sized sprite.
Code: Select all
program MyProgram;
var
@startblock $2000 "CODE"
x,y :byte;
spr8 : array[] of byte = (
%11111111,
%10000001,
%00111100,
%00100100,
%00100100,
%00111100,
%10000001,
%11111111
);
spr8L0 : array[8] of integer;
spr8R0 : array[8] of integer;
begin
SCREEN_BG_COLOR := SCREEN_BG_WHITE + WHITE;
vbmSetDisplayMode( 0 );
vbmClear( 0 );
// sprite 8x8 - pre-shift in 8 positions, using 64 bytes (8 x 8 = $40)
vbmSpriteShiftR( spr8, ^$a000, 1, 8, spr8L0 );
vbmSpriteShiftL( spr8, ^$a040, 1, 8, spr8R0 );
x:=5;
y:=9;
while (true) offpage do
begin
vbmSetPosition1( x, y );
vbmDrawSprite8( spr8L0, spr8R0 );
waitforraster(100);
vbmSetPosition1( x, y );
vbmClearSprite8( spr8L0, spr8R0 );
x:=x+1;
if x>130 then x := 0;
end;
end.
As mentioned previously, there is also a 16x16 version and sprite slices that allows any sized sprite.
Re: Turbo Rascal - Vic Bitmap Mode
This is really great work Andy! It is looking pretty awesome.
Re: Turbo Rascal - Vic Bitmap Mode
hello, not found in trse vic2o :
vbmSetDisplayMode( 0 );
vbmClear( 0 );
// sprite 8x8 - pre-shift in 8 positions, using 64 bytes (8 x 8 = $40)
vbmSpriteShiftR( spr8, ^$a000, 1, 8, spr8L0 );
vbmSpriteShiftL( spr8, ^$a040, 1, 8, spr8R0 );
greeting
vbmSetDisplayMode( 0 );
vbmClear( 0 );
// sprite 8x8 - pre-shift in 8 positions, using 64 bytes (8 x 8 = $40)
vbmSpriteShiftR( spr8, ^$a000, 1, 8, spr8L0 );
vbmSpriteShiftL( spr8, ^$a040, 1, 8, spr8R0 );
greeting
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
It’s not released yet. Plan to have ready for early new year.
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Little update on my progress.
Today I implemented a command called which will allow you to quickly draw a tilemap of character data to the bitmap of any size up to the size of the screen.
The above image shows two tilemaps drawn - the first a full screen map and the second a smaller 10x10 map near the bottom overlaying the previous. The draw current mode is replace, but like the support for drawing single 'tiles', I will add EOR, OR and AND support too.
Prior to Christmas I also finished the sprite routines. Here is a 16x16 pre-shifted sprite:
Sprite support comes with easy to use commands for 8x8 or 16x16 sprites, but with 'sprite slices' you can make sprites as big as memory and the screen will allow. You can also draw sprites with OR, EOR or AND.
Next up is Text support, then displaying BCD numbers and finally simple pixel collision testing.
Today I implemented a command called
Code: Select all
vbmDrawTileMap( map, chars, x1, y1, x2, y2 )
The above image shows two tilemaps drawn - the first a full screen map and the second a smaller 10x10 map near the bottom overlaying the previous. The draw current mode is replace, but like the support for drawing single 'tiles', I will add EOR, OR and AND support too.
Prior to Christmas I also finished the sprite routines. Here is a 16x16 pre-shifted sprite:
Sprite support comes with easy to use commands for 8x8 or 16x16 sprites, but with 'sprite slices' you can make sprites as big as memory and the screen will allow. You can also draw sprites with OR, EOR or AND.
Next up is Text support, then displaying BCD numbers and finally simple pixel collision testing.
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Text and BCD numbers now supported. Last up are some simple collision/pixel tests ... then on to the documentation for it all.
Re: Turbo Rascal - Vic Bitmap Mode
Hi, Thank You.
I'm looking forward to the new version for the vic20.
greeting
I'm looking forward to the new version for the vic20.
greeting
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Finally finished the coding on the Vic Bitmap Mode commands for Turbo Rascal.
Next up is documentation and an example project showing how to use the various commands. Then there will be lots of testing to do, which will likely be via a beta period for anyone who is interesting in helping with this.
Here's a peek at the first help file and some of the commands available.
Next up is documentation and an example project showing how to use the various commands. Then there will be lots of testing to do, which will likely be via a beta period for anyone who is interesting in helping with this.
Here's a peek at the first help file and some of the commands available.
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
Here is a summary of the commandset:
The draw commands generally have variants for Replace, Or, EOR and AND drawing operations.
My design approach with this commandset is to provide the essentials for doing what you would need in a game. It will still be up to the programmer to decide how they use them so there is flexibility there to do as you wish. For example, I do not implement a sprite manager for handling when to draw and clear sprites to avoid or minimise flicker - but the tools are there (hopefully) to allow you to do that.
There is surely more things I can add to my Vic Bitmap Mode, and I will do over time. Collision routines for sprites and tiles, lines, ellipses and fills for example. Perhaps I can persuade the guys behind the Minigrafik and new frontiers to help me with some code to do that
I'll post more updates soon, probably the mini game initially and the beta release of the VBM commandset within Turbo Rascal (as Nicolaas is eager to do another release in the next month or so). I'm sure I will have bugs to fix, hopefully catch many of these with the development of my mini-game.
- vbmDebug - switch off the bitmap to reveal the ROM characters used to fill the screen
- vbmSetColumn - set the built in screenmemory zero page pointer to the address for a column from 0 to 19. This is used for Tile commands and others.
- vbmNextColumn - add 192 to the screenmemory pointer - effectively goes to the next column
- vbmSetPosition1, vbmSetPosition2 and vbmSetPosition4 - used to set the position to draw a sprite
- vbmClear - clear the bitmap memory with a byte value, usually 0
- vbmClearColor - clear the color memory with a value
- vbmDrawTile - Draw a single 8x8 tile character on the screen. Use with vbmSetColumn and manipulation of the screenmemory pointer
- vbmDrawTileMap - Draws a tilemap of characters of any size to the screen
- vbmTestPixel and vbmTestPixel2 - Test a pixel value at a position on the screen
- vbmTestTilePixel and vbmTestTilePixel2 - Test a pixel value within an 8x8 tile. Can also be used with sprite slices
- vbmDot and vbmBlot - draw dot pixels on the screen
- vbmSrollLeft and vbmScrollRight - rearrange the characters on screen to quickly scroll 8 pixels left or right. Note that there are some restrictions when using this feature
- vbmScreenShiftLeft and vbmScreenShiftRight - scroll an area of the screen 1 pixel at a time - slower than vbmScrollLeft/Right but no restrictions on use
- vbmSpriteShiftL, vbmSpriteShiftR and vbmSpriteStitch - prepare pre-shifted characters for use with the sprite commands
- vbmDrawSprite8 and vbmDrawSprite16 - simple sprite drawing commands
- vbmDrawSpriteSlice - complex sprite command giving precise control and allowing for sprites of any size
- vbmDrawText - draw text to the screen
- vbmDrawBCD - draw numbers (eg: scores) to the screen. Use with the BCD commands
The draw commands generally have variants for Replace, Or, EOR and AND drawing operations.
My design approach with this commandset is to provide the essentials for doing what you would need in a game. It will still be up to the programmer to decide how they use them so there is flexibility there to do as you wish. For example, I do not implement a sprite manager for handling when to draw and clear sprites to avoid or minimise flicker - but the tools are there (hopefully) to allow you to do that.
There is surely more things I can add to my Vic Bitmap Mode, and I will do over time. Collision routines for sprites and tiles, lines, ellipses and fills for example. Perhaps I can persuade the guys behind the Minigrafik and new frontiers to help me with some code to do that
I'll post more updates soon, probably the mini game initially and the beta release of the VBM commandset within Turbo Rascal (as Nicolaas is eager to do another release in the next month or so). I'm sure I will have bugs to fix, hopefully catch many of these with the development of my mini-game.
- Mike
- Herr VC
- Posts: 4976
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Turbo Rascal - Vic Bitmap Mode
@AndyH: PM sent.AndyH wrote:Perhaps I can persuade the guys behind the Minigrafik and new frontiers to help me with some code to do that
Re: Turbo Rascal - Vic Bitmap Mode
Count me in.
a test trse for the sprites in vic20.
my mail : [*********]
greeting
(mod: e-mail address *deleted*. First rule on the 'net: never, ever, publish your e-mail address openly. Use PM for this.)
a test trse for the sprites in vic20.
my mail : [*********]
greeting
(mod: e-mail address *deleted*. First rule on the 'net: never, ever, publish your e-mail address openly. Use PM for this.)
- AndyH
- Vic 20 Afficionado
- Posts: 410
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: Turbo Rascal - Vic Bitmap Mode
I'm working on documentation tonight, so will have a beta version soon.
Re: Turbo Rascal - Vic Bitmap Mode
hello, thanks for the info.
greeting.
greeting.