 Text viewports and sprites |
Posted - 7/21/2008 9:19:21 AM | Back to work on the TI-83 Plus port of BBC BASIC! To complement the graphics viewport I've added support for text viewports — this lets you define the area the text console uses. The following VDU commands are now supported:
- VDU 24,<left>;<top>;<right>;<bottom>;
Define a graphics viewport. - VDU 28,<left>,<top>,<right>,<bottom>
Define a text viewport. - VDU 26
Reset both viewports to their default settings (full screen). - VDU 29,<x>;<y>;
Defines the graphics origin.

The above screenshots defines the graphics viewport to fill the left hand side of the screen and shunts the text viewport over to the right half, using the following code:VDU 24,0;0;47;63;
VDU 28,12,0,23,9
VDU 29,24;32; I've also added simple sprite drawing to BBC BASIC's PLOT command. PLOT usually takes a shape type and two coordinates, but for sprites (shapes 208..215) I've added an extra parameter - the address of the sprite data to use.

10 DIM ball 7
20 ball?0=&3C
30 ball?1=&5E
40 ball?2=&8F
50 ball?3=&DF
60 ball?4=&FF
70 ball?5=&FF
80 ball?6=&7E
90 ball?7=&3C
100 *REFRESH OFF
110 REPEAT
120 CLG
130 T=TIME/100
140 FOR P=0 TO 5
150 A=P/3*PI+T
160 X=16*SIN(A)+44
170 Y=16*COS(A)+28
180 PLOT 213,X,Y,ball
190 NEXT
200 *REFRESH
210 UNTIL INKEY(0)<>-1
220 *REFRESH ON
The above code allocates 8 bytes of memory (DIM ball 7) then copies the sprite data to it by use of the ? indirection operator. This is a little laborious, so in reality you'd probably store your sprites in a binary file external to the main program, and might load them like this:
10 ball%=FN_loadSprite("SPRITES",0)
20 face%=FN_loadSprite("SPRITES",1)
30 *REFRESH OFF
40 REPEAT
50 CLG
60 T=TIME/100
70 FOR P=0 TO 5
80 A=P/3*PI+T
90 X=16*SIN(A)+44
100 Y=16*COS(A)+28
110 PLOT 213,X,Y,ball%
120 NEXT
130 PLOT 213,44,28,face%
140 *REFRESH
150 UNTIL INKEY(0)<>-1
160 *REFRESH ON
170 END
180 DEF FN_loadSprite(f$,i%)
190 fh%=OPENIN(f$)
200 PTR#fh%=i%*8
210 DIM spr 7
220 FOR j%=0 TO 7
230 spr?j%=BGET#fh%
240 NEXT j%
250 CLOSE#fh%
260 =spr
270 ENDPROC
(Note FN_loadSprite() at the end of the program). The result is the following:

Next up: drawing text at the graphics cursor position (as sprites).
| |
Comments
 |  Scet GDNet+
Member since: 8/3/2002 From: Mississauga, Ontario |
Posted - 7/21/2008 9:53:11 PM | I've always been meaning to ask this, how long does it take you to make these journal entries? I assume you have some sort of automatic way of making all these animated gifs, but it still looks like they took a while.
I'm not complaining, I like them. It makes this journal unique as you usually don't see so much animation in the others.
| |
 |  benryves GDNet+
Member since: 9/4/2003 From: Purley, Greater London |
Posted - 7/22/2008 5:54:18 AM | Quote:Original post by Scet
I assume you have some sort of automatic way of making all these animated gifs, but it still looks like they took a while. |
There are a number of tools to capture GIFs from emulators, either being external applications (such as TISShot for VTI) or built in (such as in PindurTI or Wabbitemu). It's just a case of hitting a button when you want to start recording and hitting it again when you're done, with the optional extra stage of further trimming or optimising in the GIF animation software of your choice. 
| |
|
| S | M | T | W | T | F | S | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | |
OPTIONS
Track this Journal
ARCHIVES
August, 2010
July, 2010
June, 2010
April, 2010
March, 2010
February, 2010
January, 2010
December, 2009
November, 2009
October, 2009
August, 2009
June, 2009
May, 2009
March, 2009
February, 2009
January, 2009
December, 2008
November, 2008
October, 2008
September, 2008
August, 2008
July, 2008
June, 2008
May, 2008
April, 2008
March, 2008
February, 2008
November, 2007
October, 2007
September, 2007
August, 2007
July, 2007
May, 2007
April, 2007
February, 2007
January, 2007
December, 2006
November, 2006
October, 2006
September, 2006
August, 2006
July, 2006
June, 2006
May, 2006
April, 2006
March, 2006
February, 2006
January, 2006
December, 2005
November, 2005
October, 2005
September, 2005
August, 2005
April, 2005
February, 2005
January, 2005
|