Vic Dungeons & Dragons

Basic and Machine Language

Moderator: Moderators

Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Vic Dungeons & Dragons

Post by Devlin »

Hello,
Well Now that I learned a lot about programming through this fourm,
I wonder, Would it be possible to make a D&D style game.
First I understand that I can change the graphics to my own custom
stuff,
second I own a 1541 and I looked at the manual and I understand the
idea of Random,Seq files to load info in and out of variables.
So all I wonder is how many lines can be in a program with the
16k memory expansion. Some one told me that with out the expansion you can have a total of about 770 lines with a program.
So how many lines can you program with 16k.
Also I learned about sound...Verry easy stuff.
This is like a whole new universe. You discover it..the big bang.. then from there you learn about basic.. then custom grhpx.. then you create on your own. Also I think if I got some feedback on this topic it would be good for other beginners who have the idea of makin a RPG.
Role Playing Game.
Or as I see How about a Dungeons & Dragons game engine with the exact
rules from the Dungeon Masters Guide.
vic user
VicGyver
Posts: 1401
Joined: Thu Mar 25, 2004 9:40 am

Post by vic user »

you are going to love it here!

there are some D&D style games for the vic, and more specifically like the Ultima style, such as Realms of Quest I and II by Ghislain, which you can find the downloads for in the "games" section of this forum.

castle dark is pretty cool too, which you can download from GamBase 20, and there is a link for this too in the forum.

maybe those games will give you an idea of what can and can't be done on a vic.

i am quite interested to see how your project comes along!

chris
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

The number of lines depend on how much commands you stuff in each line. As you probably know, you can in many cases use : to separate statements within one line instead of starting a new line. If you are doing a role-playing game or any game with a lot of game data, you should take in consideration the amount of memory it will take to hold the variables. A string variable that remains unchanged will point to within the program IIRC, but as soon as you change it on the fly, Basic will allocate space for the string. Similar for numeric arrays.

Don't worry so much about running out of space. If that day comes, you can consider optimization, splitting the game into parts or other means to conserve memory.
Anders Carlsson

Image Image Image Image Image
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

More

Post by Devlin »

Ok I will try and download the games.
Also I understand that when using 16k you have diffrent screen and color locations..Also basic changes.. I do have the Vic Programmers Reference Guide. So what was posted and what I looked up made sence.
Now as far as Programmable Characters heh heh does the poke numbers change as well using 16k or do I just use everything like in the section on programmable characters in the guide.
Also for others reading this. Sound Pokes stay the same using 16k. If I am correct.

Devlin
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Yes, custom characters differs a bit too. Actually, it gets a little tricky to use those with 8K or more expansion. On an unexpanded VIC or up to 3K, you typically place the characters just before screen memory and lower the RAM top:

4096 - 7167: Basic RAM
7168 - 7679: Custom characters or Basic RAM
7680 - 8185: Screen memory

POKE 56,28 to protect the characters from being over written by Basic variables. POKE 36869,255 to use custom characters.

On a VIC with 8K expansion, the memory layout is:

4096 - 4601 : Screen memory
4608 - ???? : Basic RAM, where ???? is 16383 for 8K, 24575 for 16K etc

Custom characters has to be put somewhere between 4096 and 8191 in order for the graphics chip to be able to use them. The character set needs to start on an even 1024th address, e.g. 4096 or 5120.

This routine is meant to be executed once. It moves the whole Basic program 512 bytes forward (i.e. from 4608 to 5120), relinks lines and sets pointers. Then it fills 4096 - 4607 with a custom character font, which in your case data should come from DATA statements or likewise. Finally, it moves screen from 4096 to 4608 and adjusts VIC registers. The POKE to address 123 is part of the routine that fetch next Basic byte, to make VIC leap from the old location of the program to the new one before clearing screen and thus damaging the old location.

Code: Select all

5 IF PEEK(44)=20 THEN 30
10 A=PEEK(44)*256+PEEK(43):B=PEEK(46)*256+PEEK(45)
15 FORI=BTOASTEP-1:POKEI+512,PEEK(I):NEXT:POKEI,0
20 POKE44,PEEK(44)+2:POKE46,PEEK(46)+2:SYS50483:CLR:POKE123,PEEK(123)+2
25 FORI=0TO511:A=PEEK(32768+I):POKE4096+I,AOR(A*2):NEXT
30 POKE36866,150:POKE36869,204:POKE648,18
35 PRINT"[CLR]DONE"
Another approach is to work with two parts or more, but in any case you need to move start of Basic RAM forward to get room for custom characters, as Basic can't work with memory in segments (well, by changing the value to address 122/123 you can, but it would be much more cumbersome).
Anders Carlsson

Image Image Image Image Image
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Need more help.

Post by Devlin »

I under stand the fact that the demo code you posted was
able to shift over the characters.
now in the programmers reference guide it has this.
poke 36869,255
move chars i think
next
10 forc=7328 to 7335:read a:poke c,a:next
20 data 60,66,165,129,165,153,66,60

this makes the letter "T" a happy face.
Now then I plug in my 16k memory expansion and
want to make it do the same with the expansion.
Can you give me the correct pokes to do this.
I need Demo code please.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

All the ugly juggling and relocation would be the same. I also keep line 25, to copy the ROM font to RAM:

1 DATA 60,66,165,129,165,153,66,60
5 IF PEEK(44)=20 THEN 30
10 A=PEEK(44)*256+PEEK(43):B=PEEK(46)*256+PEEK(45)
15 FORI=BTOASTEP-1:POKEI+512,PEEK(I):NEXT:POKEI,0
20 POKE44,PEEK(44)+2:POKE46,PEEK(46)+2:SYS50483:CLR:POKE123,PEEK(123)+2
25 FORI=0TO511:A=PEEK(32768+I):POKE4096+I,AOR(A*2):NEXT
27 FOR C=4256 TO 4263:READ A:POKE C,A:NEXT
30 POKE36866,150:POKE36869,204:POKE648,18
35 PRINT"[CLR]DONE - HAPPY FACE: T"

Basically, in this setup, custom characters at 4096-4607, screen memory at 4608-5113 and Basic program at 5120 and onwards. POKE 36869,204 to turn on custom characters. POKE 36869,192 to turn it off.

In line 15, we are moving the entire Basic program 512 bytes forward in memory. If the program is rather large, it will be a waste of time.

Actually, here is a better way to do it. First enter this one-line program from the default +8K configuration:

10 POKE 44,20:POKE 46,20:CLR:SYS 50830

Then issue the following line in direct (not program) mode:

POKE 44,20:POKE 5120,0:NEW

Now you can enter your program:

10 DATA 60,66,165,129,165,153,66,60
15 FORI=0 TO 511:POKE4096+I,PEEK(32768+I):NEXT
20 FORI=4256 TO 4263:READA:POKEI,A:NEXT
25 POKE 36866,150:POKE 36869,204:POKE 648,18
30 PRINT"[CLR]HAPPY FACE: T"

But! Before you save, you have to POKE 44,18 again.

Now we have two Basic programs in memory. The first one will simply branch to the second one. The second one sets up custom characters and moves screen memory to the location of the first program, so the first stub will be overwritten when the second part is executed.

The small drawback with this method is that everytime you wish to edit your program, upon loading you have to POKE 44,20:POKE 46,20:CLR to "move" to the area where your main program is.
Anders Carlsson

Image Image Image Image Image
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Wow Wee!

Post by Devlin »

Well the first style did not work. I will try it again tommorw.
The Second style was awsome and worked perfect!.
Thanks.
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

bummer

Post by Devlin »

Il re-typed in the first example 3 times and every time
i entered run I got syntax error in 0
there was no line 0.
what could be the problem? the second example works fine. BUT!
if I used the second example then how can someone just run the program by loading it off cassette or floppy?
is there a way to do the second example where it is just 1 program so they do not have to enter the line 10 and after that the pokes?
so to wrap this all up how can i do this with just 1 program in memory?
Please Help
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Or

Post by Devlin »

Well I could have special loading instructions. :)
The whole reason behind this is I want custom chars for monsters in my dungeons and dragons game! Smile from me!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Remember that these programs are meant for 8K (or more) expanded VIC-20. The first program assumes that PEEK(44)=18 which is the case when you have memory expansion. On unexpanded VIC, PEEK(44)=16.

There is another dilemma with the second method. If you wish to run your program, the first stub is overwritten by screen memory. It means that if you wish to execute your program during development, it is cumbersome to restore the stub. You can save the program as it is (starting on address 5120).

My suggestion would thus be to work in two files to start with. The first file just relocates start of Basic and loads the main part:

10 POKE 44,20:POKE 46,20:CLR:SYS 50830
POKE 44,20:POKE 5120,0:NEW
10 LOAD"PART 2",PEEK(186):REM LAST USED DEVICE
POKE 44,18
SAVE"PART 1",8

The main part you write like normal. You can edit, execute and save it, but every time you want to load the program, you have to do it via the first part. Once the program is finished, you can merge the two:

10 POKE 44,20:POKE 46,20:CLR:SYS 50830
POKE 44,20:POKE 5120,0:NEW
LOAD"PART 2",8
POKE 44,18
SAVE"EVERYTHING",8
Anders Carlsson

Image Image Image Image Image
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Last Question on Subject.

Post by Devlin »

Ok,
custom chars 4096 - 4607
screen memory 4608 - 5113
Program 5120 - on

How about Color codes with poke using this?
So i can change happy face color? ect ect
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Colour memory will be at 38400-38905 just like unexpanded, since screen memory starts at an "odd" half kilobyte. If screen had been at 4096 like the default +8K mode, colour is at 37888.
Anders Carlsson

Image Image Image Image Image
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Ok.

Post by Devlin »

I wanted to say Thank Youi this has been a great learning experience, and I can use these bits of code in my upcoming D&D program.
Journey On!
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Map Editor

Post by Devlin »

Okhow about this.

********
********
********
********
********

Imagine a map like the above. Instead Of using the * , use diffrent graphics to make little mini maps that can be travled on! Well to do this
I must make a little map editor that sotres the information in a file onto cassette or floopydisk. The ultimate is to use chars that I personally created. As the First topic of this whole thing. Ok I was wondering how can I store the information? Load it all into an array? From a Seq File? Or a Random access file? Ok Now the loading part could be possible. So to make the map I need to make the cursor only appear on the map and then be able to hit a key to create a picture. Then maybe hit F1 to save map info? Ok A bit on how this can be done? So any feedback on how this is possible would help.
So my point is I am gonna try to make a map editor with extened memory 16k as a matter of fact. Just so the extra memory is there. If
needed.

Before I do make my attempt I would like a bit of the theroy on how this can be done? Or some pointers.

:)
Post Reply