Page 14 of 50
Posted: Thu Apr 02, 2009 7:04 pm
by Ghislain
I've been experimenting with different ways to generate random numbers. I came up with the following:
Code: Select all
GENERATERANDOM:
LDX RANDOMSEED
LDA COLOR,X
AND #240
CLC
ROR
ROR
ROR
ROR
STA TEMP1
LDA COLOR+256,X
AND #240
ORA TEMP1
INC RANDOMSEED
RTS
COLOR would be memory location 37888, TEMP1 a location in zero page of no consequence.
RANDOMSEED is another memory location that is always being INCremented by 1 when the program waits for you to press a key so because of the unpredictability of when a player presses the key, it is always a value between 0 to 255.
I've noticed that the upper nibble of the SCREEN COLOR memory map generates a sequence of fairly random numbers. So that, in combination with a randomized position from RANDOMSEED should produce stuff that is fairly 'random' right?
Right now I'm writing the code to create characters.
I'll probably use a Linear feedback shift register when I want to generate mazes.
Posted: Thu Apr 02, 2009 7:31 pm
by Ghislain
I've noticed that if I take RANDOMSEED out, I still produce fairly random numbers every time I freshly execute my program. I find this more simple:
Code: Select all
;********************************************************************
RANDOMBYTE:
JSR RANDOMNIBBLE
STA TEMP1
LDA COLOR+511
AND #240
ORA TEMP1
RTS
;********************************************************************
RANDOMNIBBLE:
LDA COLOR+510
AND #240
CLC
ROR
ROR
ROR
ROR
RTS
;********************************************************************
Posted: Fri Apr 03, 2009 10:42 pm
by Ghislain
I didn't draw any graphics today... I mostly did a few hours of coding where:
1. Character names can now be up to 16 chars long (first and last name seperated by a space). On the main game screen, the first name is displayed while the long version is shown on the VIEWCHAR screen
2. Worked on the CREATE CHARACTER routine -- I've completed the part where the 6 attributes are rolled as well as choosing the race of the character.
3. Cleaned up some of the code. I noticed that I had a lot of JSR $ADDRESS followed by RTS -- I truncated these down to JMP $ADDRESS so I could save a byte of memory.
As for #3, I'll look for parts of the code where I unnecessarily perform a CMP #0 -- many times having a value of 0 in one of the registers is enough to set the flags without having to perform a CMP.
I'd like to thank everybody for their encouragement and offers of help so far--these are greatly appreciated. These things help me to keep motivated to work on the game. Perhaps I might even finish it sooner than I think!
Once I have the CREATE CHARACTER routine finished, I promise to upload a demo for you guys to try out.
Posted: Sat Apr 04, 2009 3:42 am
by Pedro Lambrini
Looking forward to trying out the demo. I'm intrigued to see the 'speed' of the game and to see just how well something like this can run on the Vic. It'll also be nice to see the monsters on a real telly screen.
Between this game, Omega Fury and Carling the Spider this year's looking good already!

Posted: Sat Apr 04, 2009 6:14 am
by Ghislain
Pedro Lambrini wrote:Between this game, Omega Fury and Carling the Spider this year's looking good already!

I think that finishing the game by the end of this year would be _extremly_ optimistic!
My past RPG games basically were very similar to TELENGARD in terms of character management -- very simple. I never really dealt with racial adjustments and class restrictions, and these things take some time to do. But it's the little things like these that will make this game pretty cool. Here's a racial stat adjustment table I created:
Code: Select all
@ADJUSTRACE:
.byte 1,1,0,0,0,0 ;human
.byte 0,1,0,1,255,1 ;elf
.byte 2,0,0,255,2,255 ;dwarf
.byte 255,0,1,1,1,0 ;hobbit
255 basically means minus 1. Dwarves make GREAT fighters in this game!
Posted: Sat Apr 04, 2009 7:24 am
by Ghislain
Pedro Lambrini wrote:Looking forward to trying out the demo. I'm intrigued to see the 'speed' of the game and to see just how well something like this can run on the Vic. It'll also be nice to see the monsters on a real telly screen.
OK, I have the demo ready now:
http://www.usaupload.net/d/9ivmbq17kw7
To run it, you need to do the following:
1. Start a VIC-20 emulator with all four 8K expansion blocks enabled
2. type LOAD"RQ3.PRG",8,1 (return)
3. type NEW (return)
4. type LOAD"RQ4.PRG",8,1 (return)
5. type NEW (return)
6. type SYS 8192 (return)
Press the SPACE bar to cycle through 30+ monster portraits
The menu options implemented in this demo are:
keys 1-6 (or cursor keys) select active party member/character
V (view character)
O (order -- change position of party member with another)
C (create character -- must be empty first)
D (delete character)
E (edit the name of the character).
The menus in this rough demo are not 'final' -- I will probably find ways to improve their appearance, etc.
So for now, at least character creation is completed (more or less). Phew.
If you guys notice any bugs or inconsistencies, please let me know how you reproduced it.
Posted: Sat Apr 04, 2009 7:44 am
by Schlowski
Looks very good - and on a real VIC even better! I think that the font is much more readable on the real machine. and the enemies look great, can't wait to slay them
I think I found a bug: If I create a new character I always get 15 for each attribute, rerolling doesn't help, it remains 15 for each attribute.
Another small issue (which isn't harmful anyway): Going through all enemy pictures leads after the last one to some "garbled" images. Looks like you rely on memory beeing always 0, but at least with my memory expansion this isn't true.
Great demo so far!
Posted: Sat Apr 04, 2009 7:51 am
by Ghislain
Schlowski wrote:Looks very good - and on a real VIC even better! I think that the font is much more readable on the real machine. and the enemies look great, can't wait to slay them
You were able to run the demo on a real VIC-20? Do you have 32K ram expansion? That is really cool. Even cooler that you were able to run it so quickly on the real hardware.
I think I found a bug: If I create a new character I always get 15 for each attribute, rerolling doesn't help, it remains 15 for each attribute.
That is strange! I'm not seeing this behavior in VICE in NTSC mode. Let me try it in PAL mode to see if the same thing happens.
Another small issue (which isn't harmful anyway): Going through all enemy pictures leads after the last one to some "garbled" images. Looks like you rely on memory beeing always 0, but at least with my memory expansion this isn't true.
That is OK -- it's trying to cycle through 40 images and the 'garbled' ones represent those portraits that I haven't done yet
Hey guys, I rolled a killer hobbit character
Now on to debugging the stats always being 15 issue!
Posted: Sat Apr 04, 2009 8:03 am
by Schlowski
Yip, I have an Ultimate Expander by Eslapion and the uIEC by Jim Brain, great combination
Just tested it on VICE without any problems, so VICE or my VIC does not work like expected
Ok, some more results: Looks like I get the same value for all attributes but after a cold start this value changes. Last time I got 3s for all attributes. Ah, and it makes no difference if I use the stock kernal or JiffyDOS (thought suddenly maybe JiffyDOS causes the trouble, but this is not the fact).
Posted: Sat Apr 04, 2009 8:12 am
by Schlowski
Maybe you have to change your random function? Relying on some garbage at the upper 4 bits of colour RAM seem to cause the trouble... But maybe I'm totally wrong, trying to debug another ones program without source could lead me to totally wrong ideas
Just in case here's the RND function I used in Videopoker:
Code: Select all
rndseed = 673
; ---------------------------------------------------------------------
; Simple random procedures
; ---------------------------------------------------------------------
Randomize:
lda $9124
sta rndseed
lda $9125
sta rndseed+1
lda $9004
sta rndseed+2
lda $9003
sta rndseed+3
rts
RND:
sec ;Make sure it's deterministic
lda #$7a
adc rndseed
sta rndseed
rol a
rol a
adc #$69
adc rndseed+1
sta rndseed+1
adc #$a3
rol a
rol a
rol a
rol a
adc #$e1
eor rndseed+2
sta rndseed+2
rol a
rol a
rol a
rol a
rol a
adc #$57
adc rndseed+3
sta rndseed+3
rts
It's not my own invention, I stumbled upon this while searching the internet, but don't ask me where I found this...
Just call Randomize at program start and RND every time you need a random number. The behaviour of the random seed was ok for me, the distribution of numbers where at least even enough for my needs.
Posted: Sat Apr 04, 2009 8:49 am
by Ghislain
Schlowski wrote:Maybe you have to change your random function? Relying on some garbage at the upper 4 bits of colour RAM seem to cause the trouble... But maybe I'm totally wrong, trying to debug another ones program without source could lead me to totally wrong ideas

Reading the garbage in the upper 4 bits of color RAM really worked great in VICE though
Anyway, thanks for the code. Copied and pasted to my source code and now works like a charm.
Here is a "proper" working demo (hopefully!):
http://www.usaupload.net/d/zeiyesobusu
Thanks for letting me know what kind of hardware that you were using--it's good to know that there are VIC-20 users out there with various HW configurations that are willing to test my demos. I want to make sure that my game works in PAL, NTSC and all the various different types of hardware and RAM expansion configurations.
If you'd like to see my source code (just out of curiosity), send me a private message with your email address and I'll send it to you.
Posted: Sat Apr 04, 2009 8:59 am
by Schlowski
Success
Now I get really random numbers, this makes me even more wanting to play the game!
Posted: Sat Apr 04, 2009 11:26 am
by Ghislain
Schlowski wrote:Now I get really random numbers, this makes me even more wanting to play the game!
Glad it works. I also have a lot of anticipation about finishing this game as well.
I did some updates since then, basically the screen does not clear when it lets you know that the character is (or not) empty as well as allowing you to edit a name without clearing the screen. That was pretty hard to do--I had to re-write some routines and resolve conflicts. But I want the game to feel and look as professionally made as possible. The cursor keys will also be used prominently for the reason that it will also be 'emulator-friendly'. The joystick will also be used (if you have a joystick, use that instead of the cursor keys).
I'm seriously thinking about replacing single key presses (or at least minimizing them) and making navigation through menus done entirely by joystick or cursor keys.
I just thought of how I will determine which players get attacked during a combat system. The player who is first in line has a 33% chance of being attacked... if that check fails then it goes to #2 and checks for a 33% chance and so on.
That means that under such a system, the character in position 6 will have about a 5% chance of being attacked. This will allow to place wizards and fighters who use bows (the latter situation means a penalty to your armor class) in the back. This also resolves issues where a character is dead and in position 1--all characters who are in a 'dead' status are skipped entirely.
Posted: Sat Apr 04, 2009 1:29 pm
by adamantyr
Random number generation's always an interesting exercise when vintage programming. Here's the one I'm using in my own CRPG on the TI, in TMS9900 assembly:
Code: Select all
* Random number generation
RNDGEN LI R4,23729
MPY @>83C0,R4
AI R5,31871
MOV @CLOCK,R0
ANDI R0,>000F
SRC R5,0
MOV R5,@>83C0
RT
Basically I load a large value into one register, multiply by a random seed value in address 83C0h, add another large value to R5 (which is the lower word of the 32-bit multiply result), then shift it circularly (bits carry to the other side) a number of places equal to the current clock bit's last four bits (0-15) and push it back into the random seed. R4 is the return random value.
For really simple decisions, choosing a direction to go (4 ways), I just grab 2 clock bits.
Adamantyr
Posted: Sat Apr 04, 2009 3:10 pm
by Ghislain
I've decided to revamp my display/menu system again.
Which do you guys prefer...
OPTION #1: that requires key presses to interact with the menu options:
or OPTION #2: which minimizes keypresses as much as possible (though not completely) but allows the use of joystick or cursor keys to navigate through the menus.
The latter is not really 'retro' but it looks nicer. Now, I won't implement cursor/joystick navigation for EVERYTHING (such as when you create a character, you'll be asked to press different keys to choose the races). I was just thinking that with the first menu, the two different colors look kind of funny.
It would be a lot easier to make the interface completely key-driven but because of aesthetics, I've decided to go with a 'navigation' type of menu.