Search the Community
Showing results for tags 'Virtual World BASIC'.
-
I've been working with DLI's on the Atari 8-bit/5200 - a fascinating and powerful technology for doing really cool things with the display! I have decided to add them to the next release of Virtual World BASIC for the 2600! Here's a BASIC Display List Interrupt Demo for the Atari 2600, the program listing and the DLI chapter from the manual to discuss. DLI_Demo4.bin Display_List_Interrupt_demo4.txt The BASIC DLI demo is only 20 lines of code, easy to review (I reused code from 9LineBlitz). Note: This DLI code won't compile until the next version of vwB is released (soon, along with other enhancements). Draft of the new chapter on DLI's: Display List Interrupts ------------------------------- Display list interrupts run during the vertical blank and provide the ability to split the screen up into multiple horizontal sections, each of which can contain a vertically, horizontally or diagonally scrolling playfield with free floating or tile-mapped sprites. The DLI demo program (DLI_Demo.txt) demonstrates setting up display lists to scroll the top half of the screen vertically while scrolling the bottom half of the screen horizontally at different speeds. The demo actually uses 4 DLI calls to do this but arranges them to create two contiguous scroll zones. Syntax for calling the DLI is simple: "gosub DLI" two rows (1/5) of the screen will be updated based on the value you store in scrollvirtualworldtoggle (it's reused for DLI's; just don't use zero). Put in an 8, and the bottom two rows of the screen will be updated: 100 scrollvirtualworldtoggle=8:gosub DLI:scrollvirtualworldtoggle=0: rem call DLI, update tile rows 9 and 10. Put in a 1 and rows 2 and 3 will be updated near the top of the screen: 100 scrollvirtualworldtoggle=1:gosub DLI:scrollvirtualworldtoggle=0: rem call DLI, update tile rows 2 and 3. Trick to span three rows (about 1/3 of the screen) - use "3" as a prefix before the start row. Put in a 37 and the bottom three rows of the screen will be updated: 100 scrollvirtualworldtoggle=37:gosub DLI:scrollvirtualworldtoggle=0: rem call DLI, update tile rows 8,9 and 10. Put in a 30 and the top 3 rows will be updated. 100 scrollvirtualworldtoggle=30:gosub DLI:scrollvirtualworldtoggle=0: rem call DLI, update tile rows 1,2 and 3. It's no more complex than setting the x,y coordinates for the playfield camera to pan the view about the virtual world, you're just able to do that independantly for each section of the screen you define with a DLI! You can call a DLI from each gameloop with different camerea settings; each game loop runs on one of the vertical blanks so one of your DLI calls will happen "before" (called from the top blank) the display is drawn and one will happen after the display is drawn, the one called from the bottom blank (gameloop2). DLI Overhead: 3 row DLI's will occuply nearly the entire top blank, and cannot fit in the bottom blank while 2 row DLI's leave plenty of space for your own program code. Just like raising an event to scroll the entire screen, A DLI need be called only as frequently as you need to update it's target section of the screen (pan the camera). Exercises for setting up multiple DLI's and setting their animation rates: 1. Increase the scrolling speed of the top half of the screen to match the bottom, so they are both animated at 30 FPS (every other frame). 2. Change the demo to show three visible scroll zones; try to set up two zones scrolling horizontally in opposite directions or at different speeds, while the third "larger" zone (comprised of two zones) scrolls vertically or diagonally.
- 8 replies
-
- 3
-
- DLI
- Atari 2600 DLI
-
(and 4 more)
Tagged with:
-
Demo Scroller Tutorial This tutorial shows how easy it is to write a demo scroller with Virtual World BASIC: How to scroll text and graphics through sprites and through the virtual world, while scrolling the virtual world too! This is scrolling, on top of scrolling, on top of more scrolling and you can do it easily with Virtual World BASIC! Virtual World BASIC extends the hi-res over semigraphics BASIC screen buffer concept into a hi-res over semigraphics virtual world buffer concept, with a camera view: https://www.youtube.com/watch?v=n86z6pRc99A Here are the steps used to write the demo scroller: 1. Drawing the large virtual world and the sprites with ASCII art: virtualworld ......................................X...X..X.........X..XXXX.....XXXXXX......XXXXXXXXXXXXX .X.......XXXXX........................X...X..X.........X..X..X....X......X.....X..........XX ..XX.........X........................X...X...X...X...X...XXXXX..X..X..X..X....X...XXXXXXXXX ....X........X.........................X.X.....X.X.X.X....X....X.X........X....X............ .....X.......X..........................X.......X...X.....XXXXXX.X.X....X.X....XXXXXXXXXX... ......X......X..........XXXXXXXXXX...............................X..XXXX..X.............X... .......X......X..................X................................X......X..............X... ........X.....X..................X.................................XXXXXX...............X... .........X.....X.............X...X.......XXXXXXXXXXXXXXX........................XXXXXXXXX... ..........X...X..............X...X.....................X.................................... ...........X.X...............X...X.....................X............................XXXXXXXX ............X................X...XXXXXXXXX....XXX......XXXXXXXXXXXXXXXXXXXXXXXXX..XXX......X X............................X..................XX................................X........X .X.......XXXXX...............XXXXXXXXXXXXX.......XXX..............................X...XXXXXX ..XX.........X.....................................XXXXXXXXXXXXXXXXXXXXXXXXXXX........X..... ....X........X..............................................................XXxxxxx...X..... .....X.......X.........................................XXXXXXXXXXXXXXXXXXXX.XXxx.xx...X..... ......X......X.................................................XXXXXXXXXXXXXXXXXXXX...X..... .......X......X................................................XXXX...................X..... X.......X.....XXXX.........................XXXXXXXXXXXXXXXXXXXXXXXX...................XXXXXX sprites 0 ..XXX... ..XXX... XXXXX.X. ..XX.XX. XXXX.X.. X.XXX... XX.XXX.. .XX.XXXX 8 .X.X.X.. ..XXXX.. X..XX... XXXXXX.. ...XX.XX ...XX... X.X..X.X .X....X. 16 ........ XX...XX. XX...XX. XXXXXXX. XXXXXXX. XX...XX. XX...XX. ........ 24 ........ ..XXX... .X...X.. .XXXXX.. .X...... .X...... ..XXXX.. ........ 32 ........ .XX..... .XX..... .XX..... .XX..... .XXXXX.. .XXXXX.. ........ 40 ........ .XX..... .XX..... .XX..... .XX..... .XXXXX.. .XXXXX.. ........ 48 ........ ..XXXX.. .XXX.XX. .XX..XX. .XX..XX. .XX.XXX. ..XXXX.. ........ 2. The Camera is programmed to follow player 1 through the virtual world by comparing the players x,y coordinates to the camera and adjusting the cam to keep the player in view: rem ------------------------------------------------ rem ------pan the camera to follow player 1: rem ------------------------------------------------ if x-BITIndex > 12 and BITIndex < 72 then BITIndex=BITIndex+1:scrollvirtualworldtoggle=1 if x < BITIndex+10 and BITIndex>0 then BITIndex=BITIndex-1:scrollvirtualworldtoggle=1 rem -----pan camera vertically (BYTErowoffset) if player is near the edge of the playfield CAM rem i = y*12: rem "read i(fastyindex,y)" is faster (12 step lookup table for virtual world y values) i=fastyindex(y): rem index the y*12 lookup table if BYTErowoffset<120 and BYTErowoffset+36<i then BYTErowoffset=BYTErowoffset+12:scrollvirtualworldtoggle=1 if i>36 then i=i-36 if BYTErowoffset>i then BYTErowoffset=BYTErowoffset-12:scrollvirtualworldtoggle=1 3. Player 1 is animated and set on fire when close to clearing the screen: animateplayer1 rem --- flip sprite in four directions if o=0 then REFP0=0:loadplayer0(0):COLUP0=255: rem face forward, default incommming if o=1 then REFP0=255:COLUP0=$64:rem player face backwards if o=2 then loadplayer0upsidedown(0):COLUP0=$44:rem player upsidedown if o=3 then REFP0=0:COLUP0=$ef:rem player face forward o=o+1 if o=4 then o=0 if score<210 then COLUP0=$64: rem --- only show player 1 on fire beyond 210 (indicates close to clearing board) 4. Player 2 is animated with a scrolling text phrase from the inline sprite library by loading in a scrolling section of sprite graphics by moving the index on each load (with a delay so it doesn't scroll too fast): rem vars: h - sliding index for player 2 sprite message if l<>4 and l<>8 and l<>12 and l<>16 then goto scrollplayerdelay loadplayer1(h) h=h+1 if h>184 then h=112 scrollplayerdelay rem i=i+1:mazecolours(l)=i l=l+1 if l>16 then l=0:COLUP1=mazecolors(n):n=n+1 if n>16 then n=0 rem play 2nd or 3rd (60/90 MUSICINDEX) and clear board if enough blocks are destroyed: if score=255 then score=0:COLUPF=0:MUSICINDEX=90:for i=0 to 91:for j=0 to 19 step 3:vwpixel(i,j,on):next j,i:COLUPF=mazecolors(k):k=k+1 if k>16 then k=0 if score=210 then score=211:h=0:MUSICINDEX=60: rem --- display bonus message in player 2, play reward song, earn extra point. return 5. Sprites are bound to virtual world coordinates (not to physical screen coordinates, though those can be adjusted for fine tuning position) and only show up on screen when they are in the camera view: rem -- bind Player 1 and Player 2 sprites to the virtual world: vwpixel(x,y,bindplayer0) vwpixel(u,v,bindplayer1) 6. Tile pixels are addressed with x,y coordinates throughout the virtual world: vwpixel(x,y,flip):rem flip virtual world tile pixel 7. A phrase from the inline sprite library is scrolled through the center of the virtual world by loading a section of the sprite library and moving the index. Printing the binary strings from the sprite library directly onto the virtual world just like the print@ command in BASIC prints anywhere on the screen - this is possible because Virtual World BASIC let's you access the binary array of the virtual world as a byte array as well: rem --- run playfield central banner routine when scrolling: if r>84 then r=16 for j=0 to 19: rem --- slide sprite library array through virtual world array i=r+j e=fastyindex(j)+5: rem same as j*12+5, lookup table rem e=e+5 virtualworld(e)=sprites(i):push a slice of sprites array into world array next j r=r+20 8. Music: There are three chip tunes defined; the first tune repeats. The second and third tune are heard only when Player 1 catches fire and when the screen is cleared. Hearing the third tune is unlikely because each player takes over one of the two voices to play a note of it's own musical tune whenever the player hits a block. chiptunes 7, 30, 0, 0, 8 7, 24, 0, 0, 8 7, 20, 0, 0, 8 12, 9, 12, 7, 22 12, 14, 12, 11, 22 6, 30, 0, 0, 20 6, 24, 6, 30, 10 6, 22, 6, 30, 10 6, 21, 6, 30, 20 12, 26, 12, 19, 20 0, 0, 0, 0, 254 0,0,0,0,0 6, 5, 4, 12, 20 6, 17, 4, 19, 20 6, 5, 4, 12, 20 6, 17, 4, 15, 35 0, 0, 0, 0, 255 29,23,5,10,0 Note: Virtual World BASIC processes musical scores and sound FX through a filter that changes the sound envelope. Not covered in this tutorial: Controls: Player 1 is controlled by the joystick, player 2 is controlled by the AI or the second joystick. Easter egg: If Player 2 is in view when Player 1 catches fire, a new phrase is scrolled. Virtual World BASIC was designed for building scrolling demo's and tile mapped games, try it out! Follow the link in my signature to download the source code for this demo and the vwBASIC compiler.
-
As a Tiny BASIC implementation vwB has a somewhat familiar feel to bB but a different object set, most notably the large virtual world and playfield camera. There is no visual IDE, so you have to write programs like the one below in an editor, and the graphics definitions are defined inline using ASCII art (WYSIWYG) much like bB. Here's a sample listing to show some of the things you can do, and a link to the compiler and specs. The programmers on this forum have made a ton of awesome games and demos with bB! I'm looking forward to playing what you build with vwB! 1 rem *** Test program for vwBASIC compiler *** 5 rem --------------------------------------- 7 rem ---init section, runs once: ----------- 8 rem --------------------------------------- 15 COLUP0=$40:COLUP1=100: h=0:g=0:l=0:f=0:u=5:v=5: rem init vars 20 rem draw a box of inverted pixels (gosub 20 to call routine again) 30 for x = 5 to 10:rem outer loop 40 for y = 3 to 8: rem inner loop 50 vwpixel(x,y,flip) 60 next x,y 105 rem end block for init section --------------------- 122 rem ------------------------------------------------ 120 rem ---gameloop subroutine, runs every frame: --- 124 rem ------------------------------------------------ 127 rem vars: x,y player0 virtual world coordinates (for sprite binding) 128 rem vars: g,l,f - frame based counters 129 rem vars: u,v player1 virtual world coordinates (for sprite binding) 130 scrollvirtualworldtoggle=0:f=f+1 131 if g<16 then read i(mazecolours,g):COLUPF=i: rem data/read example 132 if f=7 then g=g+1:l=l+1 133 if g<16 or g>48 then REFP0=1 else REFP0=255 135 if g<32 then loadplayer0(0) else loadplayer0upsidedown(0) 137 if g>64 then g=0:rem reset medium frame counter 138 if l>104 then l=0 139 if f=14 then f=0 else vwpixel(u,v,bindplayer1):vwpixel(x,y,bindplayer0):return 152 rem ---scroll sprite library section containing message 155 loadplayer1(l) 555 if joy0up=1 and y>0 then COLUP1=$40:COLUP0=$90:y=y-1 556 if joy0down=1 and y<18 then COLUP1=$64:COLUP0=$70:y=y+1 557 if joy0left=1 and x>0 then COLUP1=$55:COLUP0=$60:x=x-1 558 if joy0right=1 and x<90 then COLUP1=$84:COLUP0=$80:x=x+1 559 rem ---bind player1 to virtual world game grid at player0's location if button is pressed 560 if joy0fire=1 then u=x+1:v=y:vwpixel(x,y,flip):COLUP0=$E0:MUSICINDEX=MUSICINDEX+1 570 if u=x and v=y then COLUBK=$0E else COLUBK=0:rem virtual collision detection 700 rem ------pan camera horizontally (BITIndex) if player is near the edge of the playfield CAM 705 i=x-BITIndex 710 if i > 15 and BITIndex < 72 then BITIndex=BITIndex+1:scrollvirtualworldtoggle=1 712 if x < BITIndex+3 and BITIndex>0 then BITIndex=BITIndex-1:scrollvirtualworldtoggle=1 720 rem -----pan camera vertically (BYTErowoffset) if player is near the edge of the playfield CAM 725 i = y*12 730 if BYTErowoffset<108 and BYTErowoffset+36<i then BYTErowoffset=BYTErowoffset+12:scrollvirtualworldtoggle=1 735 if i>36 then i=i-36 740 if BYTErowoffset>i then BYTErowoffset=BYTErowoffset-12:scrollvirtualworldtoggle=1 1560 rem end block for game loop ---------------
- 22 replies
-
- BASIC Compiler
- Tiny BASIC
- (and 4 more)