Register To Post



 Bottom   Previous Topic   Next Topic

#11
Re: .C into .VB
Posted on: 2009/4/10 6:10
PVB Elite
Joined 2008/4/26
USA
526 Posts
CoderContributorLong Time User (5 Years)Top10 PosterHOTY09 3rdPVBCC 2010 Entry
How do I use the vbPrint() function? A line of sample code would be good.
Top

#12
Re: .C into .VB
Posted on: 2009/4/10 6:24
Administrator
Joined 2000/1/8
Germany
2110 Posts
Highscore Top10Highscore Top ScoreCoder#1 PosterHOTY09 1stLong Time User (13 Years) 80+ Game Ratings
Use vbTextOut(), it's a bit easier. Copy your font to character segment 3 like this for example:

copymem((void*)CharSeg3, (void*)FONT, 8192);


Here's an example call of vbTextOut(), printing the string "TEST" to BGMap 0, starting at the tile in position x=1, y=2 (from the top left):

vbTextOut(0, 1, 2, "TEST")


The BGMap shoud then look like this ("0" meaning an empty tile):

000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
0TEST0000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
[...]
000000000000000000000000000000000000000000000000
Top

#13
Re: .C into .VB
Posted on: 2009/4/10 6:54
PVB Elite
Joined 2008/4/26
USA
526 Posts
CoderContributorLong Time User (5 Years)Top10 PosterHOTY09 3rdPVBCC 2010 Entry
This is not working. It has a whole bunch of error messages referring to "WAM."

Attach file:


c gosuba.c Size: 1.64 KB; Hits: 81
Top

#14
Re: .C into .VB
Posted on: 2009/4/10 7:13
PVB Elite
Joined 2003/7/26
USA
967 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (9 Years) App Coder20+ Game Ratings
Hey, this is what I like to see! Way to go, VirtualChris, on taking your first steps! And thanks for using my demo to learn from.

But, KR155E's right; it's more of an OBJ demo than a standard "Hello, World!" program. I only did it that way because I wanted a stereo effect to show off the VB's capabilities...

Anyway, just a few comments concerning text output:

1. The BGMap won't necessarily be set to all 0x00's by default. You should use setmem() or cls() (if your copy of libgccvb.h has it) to clear it before printing.


setmem
((u8*)(BGMap(0)), 08192);


Here's cls() if you don't have it (probably 1,001 better ways to do it...):


void cls
(int seg) {
    for (
int i = (seg 4096); < ((seg 1) * 4096); i++) {
        
BGMM[i] = 0x0000;
    }
}


It takes a BGMap segment number from 0 to 13.

2. dasi has a nice routine here if you want to print the contents of variables.

3. "WAM" is the World Attribute Table. I think we really need to work on that unified library... I'll try to at least post what I used on my compo entry. Most things work in it and I know vbTextOut does (I used it for debugging).
Top

#15
Re: .C into .VB
Posted on: 2009/4/10 7:40
PVB Elite
Joined 2008/4/26
USA
526 Posts
CoderContributorLong Time User (5 Years)Top10 PosterHOTY09 3rdPVBCC 2010 Entry
How many objects can be on the screen at once? Because I'm not getting any of this text stuff. Suppose I wanted those words i had in my vb program to bounce around. Would they need to be objects then? Why is it not a good idea to use vbPrint? I actually kind of knew what i was doing with my first program even though I don't know C, and I'd like to continue and expand on it, add a title screen with something like the coding competition demo picture. (If you don't know what GoSub is going to be like, you control a submarine and avoid a moving octopus and walls through mazes to get the treasure at the end of each maze.) Through trial and error, i learned on the Oric emulator that characters are made backwards for some reason (for example, when I first did this program, my E looked like a 3.) Anyway, I'm actually thrilled that I did what I did knowing what I know (which is basically almost nothing).
Top

#16
Re: .C into .VB
Posted on: 2009/4/10 8:23
PVB Elite
Joined 2003/7/26
USA
967 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (9 Years) App Coder20+ Game Ratings
Quote:

VirtualChris wrote:
How many objects can be on the screen at once?


1024

Quote:
Because I'm not getting any of this text stuff.


Do you have any specific questions? I don't know why "WAM" is giving you problems, since I don't know what exact lib you have. Try looking for/putting this near the top of libgccvb.h as a workaround until I get a new file posted:


u16
WAM = (u16*)0x0003D800;


Quote:
Suppose I wanted those words i had in my vb program to bounce around. Would they need to be objects then?


Not necessarily. It would probably be easier/less resource consuming if you mean each letter bouncing around, but if it's whole words, you could probably use BGMaps.

Quote:
Why is it not a good idea to use vbPrint?


It's just considered deprecated. I think it also expects the font to be in a different place from vbTextOut, so they don't "play well together".

Quote:
I actually kind of knew what i was doing with my first program even though I don't know C, and I'd like to continue and expand on it, add a title screen with something like the coding competition demo picture. (If you don't know what GoSub is going to be like, you control a submarine and avoid a moving octopus and walls through mazes to get the treasure at the end of each maze.)


That sounds like a cool game, but you should probably still use BGMaps for the warning/title screens.

Quote:
Through trial and error, i learned on the Oric emulator that characters are made backwards for some reason (for example, when I first did this program, my E looked like a 3.)


I have no idea what you mean, unless you're talking about the order of bits in a byte, and you shouldn't need to worry about that if you use VIDE or grit for graphics.

Quote:
Anyway, I'm actually thrilled that I did what I did knowing what I know (which is basically almost nothing).


You should be very proud of even such modest accomplishments. Programming isn't that easy and you've done a great job so far. Please keep tinkering and asking questions when you need to. I really want to play "GoSub"!
Top

#17
Re: .C into .VB
Posted on: 2009/4/10 9:33
PVB Elite
Joined 2008/4/26
USA
526 Posts
CoderContributorLong Time User (5 Years)Top10 PosterHOTY09 3rdPVBCC 2010 Entry
How do i turn a vep file into an h file? Maybe that's the problem I'm having, i did it wrong.
Top

#18
Re: .C into .VB
Posted on: 2009/4/10 13:09
Administrator
Joined 2000/1/8
Germany
2110 Posts
Highscore Top10Highscore Top ScoreCoder#1 PosterHOTY09 1stLong Time User (13 Years) 80+ Game Ratings
Quote:

VirtualChris schrieb:
How do i turn a vep file into an h file? Maybe that's the problem I'm having, i did it wrong.


You don't convert the whole VEP file, this is just a "container" file for your project. In VIDE, you create CharSets or BGMaps, and then export them individually using "Advanced" > "Functions" > "Export to *h" (A VIDE plugin by DanB which you need to install seperately, by just copying it into the "PLUGINS" folder of VIDE. Download here). Place the *.h file in your project directory and include it in the code using the "include 'file.h'" command. The CharSeg or BGMap can then be referenced by the name you gave it in VIDE (In my example it was "FONT"). Also make sure that, if you use BGMaps you created in VIDE, the CharSet is in the correct CharSeg (As specified when using the "export to *.h" plugin).


Quote:

RunnerPack schrieb:
I think we really need to work on that unified library... I'll try to at least post what I used on my compo entry. Most things work in it and I know vbTextOut does (I used it for debugging).


Yes, we really need to get back to that topic. I started compiling one, based on the one from the vbJAEngine and my custom lib I wrote for Blox 2. I will probably work on that some more now that VUE Snake is out. Regarding the current topic, I also wrote a custom text out function, which can print from left to right or right to left, horizontally and vertically and takes the Offset of the font in RAM as input, so more than one font can be used.
Edited by KR155E on 2009/4/10 13:25
Top

#19
Re: .C into .VB
Posted on: 2009/4/10 19:55
PVB Elite
Joined 2008/4/26
USA
526 Posts
CoderContributorLong Time User (5 Years)Top10 PosterHOTY09 3rdPVBCC 2010 Entry
Could someone please tell me what I'm doing wrong? I keep doing various things but keep getting back various error messages.

Attach file:


h font.h Size: 48.96 KB; Hits: 88
c gosubd.c Size: 1.44 KB; Hits: 79
Top

#20
Re: .C into .VB
Posted on: 2009/4/11 0:05
PVB Elite
Joined 2003/7/26
USA
967 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (9 Years) App Coder20+ Game Ratings
Basically, you're doing everything wrong j/k

Compare the attached file to yours as I describe them:

1. Don't put any code outside the main() function (unless it's another function, of course).

2. It's a waste of time to use vbTextOut() unless you have a World/BGMap/Charset combo ready to display the result.

3. The World has to be set differently if you're using a BGMap versus using Objects.

4. Remember: C is case-sensitive, so Font is not the same as FONT.

5. Not your fault but you may want to change the FONT array in the include from "static" to "const" to save room in the VB's dinky WRAM.

EDIT: Oops, forgot to say that I haven't compiled this (my environment is quite different from yours) so it may still need some tweaking...

Attach file:


c new_gosubd.c Size: 1.52 KB; Hits: 85
Top

 Top   Previous Topic   Next Topic


Register To Post

You are not logged in.
Lost Password?
Register Resend Activation