The Icon Bar: The Playpen: Slightly cold news on page 10! Phlamey breaks the server.
|
Slightly cold news on page 10! Phlamey breaks the server. |
|
This is a long thread. Click here to view the threaded list. |
|
Jeffrey Lee |
Message #72115, posted by Phlamethrower at 15:20, 25/11/2005, in reply to message #72111 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Hmm, I think I need to rename that hash ADT to a sorted map. And then write a proper hash map
Expression parsing
To make coding missions easier, mission scripts can contain rather complex expressions, e.g.:
ia = id+ie*27 IF ia+5 < ib*fg THEN .foo
These need to be translated into simpler calculations. The way the game will do this is as follows:- As each line of the mission script is tokenised, a list of tokens will be generated. e.g.:
"ia","=","id","+","ie","*","27" "IF","ia","+","5","<","ib","*","fg","THEN",".foo" - The contstants will automatically be converted to constant-variables as they are tokenised
"ia","=","id","+","ie","*","i;27" "IF","ia","+","i;5","<","ib","*","fg","THEN",".foo" - When a mathematical expression is detected, it will be converted to reverse polish notation on the fly:
"ia","id","ie","i;27","*","+","=" "IF","ia","i;5","+","ib","fg","*","<","THEN",".foo" - The expression will also be simplified on the fly. "ie","i;27","*" will be replaced with "i;;0", and the token sequence "*","i;;0","ie","i;27" will be inserted onto the end of the main token list. "id","i;;0","+" will then be replaced with "i;;1", and "+","i;;1","id","i;;0" will be inserted onto the main token list. Eventually the top line will be simplified down to nothing, and the main token list will have had the following added to it:
"*","i;;0","ie","i;27","+","i;;1","id","i;;0","=","ia","i;;1" - As can be seen, i;;0 and i;;1 are temporary variables. Before the next line is processed the temporary variable name pool will be reset. Processing the next line will result in the following being added to the main token list:
"+","i;;0","ia","i;5","*","i;;1","ib","fg","<","i;;2","i;;0","i;;1" And the tokens in the input buffer will be: "IF","i;;2","THEN",".foo" The buffer can't be simplified any further, so will be appended to the processed token list. An expression which makes use of an array, e.g.:
ifoo[ij+5] = ik
Will be initially tokenised to "ifoo[]","[","ij","+","i;5","]","=","ik". Rewriting it will then produce the tokens "+","i;;0","ij","i;5","=","ifoo[]","i;;0","ik"
Commands which read/write the array size, e.g.:
ifoo[] = ii
Will be tokenised as "ifoo[]","[]","=","ii", and rewritten as "=","ifoo[]","[]","ii"
To avoid trying to process command argument lists as expressions (e.g. in BULLET ROCKET vpos 30 pped), the tokenising code will automatically insert a comma token between any two adjacent variables, producing "BULLET","ROCKET","vpos",",","30",",","pped". These commas will be stripped out when the line is added to the main token list.
Seating system, MK 2- Each vehicle will contain several isles of seats
- The number of seats in each isle will be specified in the car definition file
- Each isle can have two doors, one next to the first seat and one next to the last seat
- Seat 0 in isle 0 will be the drivers seat
- The coordinates of each seat can be specified
- Peds will be able to slide past other peds in the same isle, in order to reach a free seat or a door
|
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72118, posted by Phlamethrower at 16:56, 25/11/2005, in reply to message #72115 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*starts work on script parser*
So, when are you lot going to contribute something? |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #72119, posted by monkeyson2 at 17:10, 25/11/2005, in reply to message #72118 |
Please don't let them make me be a monkey butler
Posts: 12380
|
*starts work on script parser*
So, when are you lot going to contribute something? PLAYTESTING |
|
[ Log in to reply ] |
|
Richard Goodwin |
Message #72120, posted by rich at 18:39, 25/11/2005, in reply to message #72118 |
Dictator for life
Posts: 6828
|
*starts work on script parser*
So, when are you lot going to contribute something? So all my morale-boosting by changing thread titles to something more positive, and making polite replies to missives that I barely understand, don't count? ________ Cheers, Rich.
|
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72121, posted by Phlamethrower at 18:57, 25/11/2005, in reply to message #72120 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
So all my morale-boosting by changing thread titles to something more positive, and making polite replies to missives that I barely understand, don't count? Yes
Mmm, compilation errors. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72128, posted by Phlamethrower at 17:49, 26/11/2005, in reply to message #72121 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*adds postfix conversion and expression simplification*
I'm starting to get the feeling that I should use a tried and tested parsing/tokenising system instead of making it up as I go along |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72129, posted by Phlamethrower at 17:52, 26/11/2005, in reply to message #72128 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Hey, it's working now!
*adds code for object property setting and array indexing*
*finds something that doesn't parse, panics*
*works out how to fix it*
*realises fix won't work, resumes panicing*
*works out how to rewrite the fix*
*tests code, rejoices*
[Edited by Phlamethrower at 19:00, 26/11/2005] |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72147, posted by Phlamethrower at 23:17, 27/11/2005, in reply to message #72129 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
For your viewing pleasure:
Stuff done ---------- 27/11/05 * Added support for functions with no args, rewrote NEWGAME to use it * Added support for unary minus * Added code to ensure the P/C/O bits aren't set if an E is set to 0 * Added STRTIME, RAND, GOSUB, RETURN, POP, PUSH script funcs/commands and supporting code * Made script_error invalidate the game instead of quit the program. Improved error handling in script execution code to account for this. * Added gang respect framework and script commands * Fixed arithmetic parsing code so that if the first input to an untyped op is the size of an array, the output type will be set as an int 26/11/05 * Added some more script commands * Added gang bitflags system * Added script_error func * Added code to do reserved word lookup from sorted list * Fixed numerous bugs in the script/mvar code * Added postfix conversion for expressions * Added expression simplifier * Made loading a new script cause existing script related vars to be cleared * Split script.c into scriptexec.c * Added all arithmetic ops * Added IF, NEWGAME, GAMEOVER script commands * Made reserved word parser use special code to detect +, -, *, ==, etc. * Improved script error reporting * Added default keyboard controls * Tweaked templates 25/11/05 * Started todo list! * Added basic script parsing and execution code * Improved mvar code 24/11/05 * Started coding *tries to decide what bit needs doing next* |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72148, posted by Phlamethrower at 00:00, 28/11/2005, in reply to message #72147 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*adds path variable code* |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72150, posted by Phlamethrower at 02:10, 28/11/2005, in reply to message #72148 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*adds loading screen*
Hmm, the 512x384 mode that I have a definition for doesn't seem to work with this monitor |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72171, posted by Phlamethrower at 17:21, 28/11/2005, in reply to message #72150 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
'Aight, let's get this party started!
*starts coding car sprite management code* |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72179, posted by Phlamethrower at 19:24, 28/11/2005, in reply to message #72171 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
And the smiley face test says: It works! |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72199, posted by Phlamethrower at 21:26, 28/11/2005, in reply to message #72179 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*enters the twilight world of programs that randomly switch from working to not working* |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72205, posted by Phlamethrower at 01:49, 29/11/2005, in reply to message #72199 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Work done since yesterday's update (roughly):
29/11/05 * Fixed a bug that could cause _reset functions to crash if their data structure was empty * Fixed a bug causing fonts_reset to crash * Wrote simple BASIC program to generate 256 colour palette files, PalGen * Added an option to carsprs_load for loading files without a path, in case I write some kind of delta utility prog 28/11/05 * Added script variable stack flushing when loading a new script * Made script loader use PATH_MISSIONS (except for gameconfig script) * Fixed a few bugs stopping the intended final gameconfig script from working * Added UI sprite loading/management and LOADUI command * Added basic loading screen & LOADING command * Added font loading/management and LOADFONTS command * Made loading screen use font if available * Added empty sound framework, config window, and LOADSOUND command * Added pause/unpause, desktop, map key checks & skeletion pause menu/map view code * Added gp_screen ptr for screen to mode.h, and moved some mode handling/screen bank swapping code from game.c to mode.c * Rewrote script_getvarpair to be easier to use, rewrote script execution code to match * Added car sprite management code, delta generation, composite generation * Made common loading code update loading screen with status * Added GAMETIME script func * Added tile sprite management code and LOADTILES command Now the question is, what subsystem should be next?- Object sprite management. Can borrow some of the code from the tile system, since it also has to deal with animations
- Car definition files. I think I know enough about what these must contain to do them now.
- Ped sprite management. Sprite loading, recolouring, etc. Might however require code from...
- ...ped definition files
- Object, Car, Ped management will all rely on the corresponding asset management code having been written, so I can't really start on them yet
- However I could have a go at writing the map system. For map generation I'm currently leaning towards some kind of set of definition files, describing what buildings and roads look like, in particular which tiles should be used
- Sound system. The base of the framework is there, I need to look into how sharedsound works before adding any real code. Also need to decide how many sounds cars/peds/objects can make, how to manage the sounds so only the ones nearby are scheduled for playing, etc.
- Event system. Without any peds, cars or objects the only real event I can add is a time based one. But it is the simplest and most flexible.
Hmm.
*starts work on timer event system* |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72209, posted by Phlamethrower at 03:20, 29/11/2005, in reply to message #72205 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
(Timer system now complete btw )
Tunes!
GTA wouldn't be that exciting without the radio, so this game will need a similar thing. I have 4 options available to me:- CD music. This looks to be fairly easy to get going, and will have no performance hit on the game. It also means you can play the music from GTA 1 (Or any other audio CD, homemade orotherwise)
- AMPlayer. This plays MP3's, so will have a crapload of music available for it. It's also been designed with making new frontends in mind, so will be easy to control. Unfortunately decoding MP3's will probably eat up too much CPU time, and make my already slow code appear even slower.
- Tracker player(s). These don't use much CPU time, but the music available is somewhat limited. They're also fairly easy to control from code.
- Another solution. Are there any music playing modules for RISC OS that support CD music, MIDI, wav files, MP3 and tracker files?
!Amp supports all these, but is an application. Luckily it supports the different file formats via a plugin system, but... the plugins are written in BASIC as WIMP applications. Translating these into C for use with a plugin manager built into the game would take time. Also the player modules need to be 32bit compatible. So unless someone can come up with a super fast MP3 player or a mutliformat player module, it looks like I'll be going with CD music |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72233, posted by Phlamethrower at 16:56, 29/11/2005, in reply to message #72209 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
I've been thinking
Screen if you wanna' go faster!
(OK, obviously not thinking about good post titles)
Let's have a looksee at the different elements the screen will be made up of.
http://www.phlamethrower.co.uk/misc2/elements.jpg
A - Cars, peds, and other objects B - Flat tiles C - East/west facing walls D - North/south facing walls E - North/south sloping tiles F - East/west facing wall wedges G - HUD elements
Not shown: H - East/west sloping tiles I - North/south facing wall wedges
Now let's look at how each of these elements can be broken down and rendered (In no particular order).
A - For these we can just use the standard rotated/scaled sprite plotter. B - These are obviously square in shape. We'll make the game assume the mode has square pixels, so that they will be square. Each tile can be broken down into a series of horizontal lines, one per screen row, and each line can be drawn individually. If the tiles are stored pre-rotated then for each screen row we will be drawing from one tile row. A plotting routine can be written especially for this. D - Although they have the shape of a trapezium, the north/south walls are still made up of horizontal rows. This means the same row plotting routine can be used as for B, making plotting these walls fast. E - These are also made up of horizontal rows, so can use the same algorith as D. C - These walls are made up of vertical columns, instead of horizontal rows. This means that we have two approaches - either plot each screen row at a time, and have to keep track of X and Y sprite deltas, or plot screen columns at a time and only keep track of the X delta. Plotting columns will be the easiest to program, so until I get the engine running and can see how it performs I'll be sticking with that. H - These tiles are also made up of vertical columns, so will be plotted column by column. F - These are similar to the east/west walls and slopes, except that they are a more irregular shape. They can still be decomposed into vertical columns though, so the same low level routine can be used. I - As with F, they can still be decomposed into horizontal rows, so the row plotting routine can still be used. G - These can just be done using the regular sprite plotting commands.
Column plotting
This will probably be a simple loop. In C it would appear something like:
void colplot(short *scr,short *spr,f1616 x,f1616 dx,int len,int wid) { while (len--) { *scr = spr[x >> 16]; scr += wid; /* Move to next screen row */ x += dx; /* Increase sprite index */ } }
Where scr points to the first pixel of the column, spr points to the sprite row, x is the index into the sprite row, dx is the index increment per screen pixel, len is how many pixels to plot, and wid is the width of the screen in pixels.
There are less optimisation opportunities for this than for the horizontal plotter, so I'll focus my efforts on the horizontal plotter.
Row plotting
Similar to above, the basic plotter in C would appear as:
void rowplot(short *scr,short *spr,f1616 x,f1616 dx,int len) { while (len--) { *scr = spr[x >> 16]; scr++; /* Move to next screen pixel */ x += dx; /* Increase sprite index */ } }
This one however has lots more optimisation opportunities.
If we assume that the entire row will be on screen, then we can omit the x argument. Furthermore the dx argument will be directly related to len, in that dx = 64/len. (Ignoring the fact we'll have to shift the result left 16 places to make it an f1616). Most, if not all, tile rows will be between 1 and 256 pixels long, so we have an opportunity to either:
a) Use a lookup table to calculate dx or b) Generate 256 different optimised plotters, one for each length of line
b) is far more interesting, as if you're looking at a screen full of flat tiles then all the rows will be the same length. If an optimised plotter designed around a fixed line length can be used then it should plot the screen many times faster than one based around variable line lengths.
A complication
We'll need two versions of each plotter, one for word-aligned plotting and one for half-word-aligned plotting. I'm just glad that I'm not doing this in an 8bpp mode, otherwise there'd be 4 of each
Also we'll have to deal with masked sprites. For simplicity, the optimised row plotters will only work with unmasked sprites.
The code
...hasn't been written yet. It'll probably be based around runtime assembly (like the GnarlPlot sprite plotters), caching the plotting code for each line length until the program quits. The simplest way of creating the code would be to LDM blocks of tile pixels, then STRB, STR, and STM them onto the screen.
Unfortunately the screen memory is set to write-through by default, so lots of STRBs will be slow.
There is a way around this, by setting it to write-back and then flushing the cache afterwards, but it's a bit naughty and can cause graphical corruption if the program crashes. It'll also need detection code for the Iyonix/a9home/viewfinder/etc, since I suspect the technique won't work properly on those machines.
The alternative then would be to write the code generator differently, so that it packs pixels together before writing them out with STM's. A Risc PC cache line is 16 bytes long, so writing 8 pixels at once would be ideal (Does the Strong ARM send a cache line at a time or only the required bytes/words when dealing with write-through? I dunno).
I guess I'll write a benchmark prog to test the effectiveness of various writing methods to screen memory.
What about LDRH/STRH?
Someone told me once that they don't work on the Risc PC's memory bus. I haven't bothered testing it yet |
|
[ Log in to reply ] |
|
Kevin Wells |
Message #72240, posted by Revin Kevin at 18:58, 29/11/2005, in reply to message #72233 |
Member
Posts: 644
|
The graphics look good, but the cars are on the wrong side of the road.
We drive on the left in this country. ________ I did not do it. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72242, posted by Phlamethrower at 19:17, 29/11/2005, in reply to message #72240 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
That was a screenshot from GTA 1, not from this game
The most exciting thing that this game can draw at the moment is its loading screen, and that's just a static image with a message printed beneath it. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72253, posted by Phlamethrower at 23:30, 29/11/2005, in reply to message #72242 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Map code is "done".
i.e. it can load and save maps, but not make any from scratch.
And the loading code won't work anyway, because the map is loaded before the tiles are. (I can fix it to force the tiles to load though)
And the reset command in the mission scripts doesn't unload any of the unused graphics/cars/peds/other unimplemented features yet |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72254, posted by Phlamethrower at 23:30, 29/11/2005, in reply to message #72242 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Map code is "done".
i.e. it can load and save maps, but not make any from scratch. [edit #2: can now make maps, stacks, blocks. Next stop, rendering!]
And the loading code won't work anyway, because the map is loaded before the tiles are. (I can fix it to force the tiles to load though) [edit: now done]
And the reset command in the mission scripts doesn't unload any of the unused graphics/cars/peds/other unimplemented features yet [edit: also done]
[Edited by Phlamethrower at 23:50, 29/11/2005]
[Edited by Phlamethrower at 00:13, 30/11/2005] |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72257, posted by Phlamethrower at 03:52, 30/11/2005, in reply to message #72254 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Nasty row based tile plotting routine is done, just the equally nasty but very similar column based one to add. (And then the functions to plot the rows/columns themselves). I've also got the bits of code around those two functions done, i.e. the bits that work out what blocks are visible and where they should be plotted. But no depth sorting yet
Also got some simple yet powerful map manipulation commands added to the script parser, so scripts can change map segments. Which is nice, because it means I can make a test map without having to write another kludgy C function
There'll also be a zoomed out flat view of the map available, to help you get around the city. Since only top surface tiles will be drawn, and they'll be flat, it can reuse some of the code from the 3D plotter to make it nice and snappy. |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #72258, posted by monkeyson2 at 09:10, 30/11/2005, in reply to message #72257 |
Please don't let them make me be a monkey butler
Posts: 12380
|
|
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72262, posted by Phlamethrower at 15:23, 30/11/2005, in reply to message #72258 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
The prototype map renderer is now FINISHED.
Now I just have to link it into the rest of the code, fix the compilation errors, then write a test script to build a simple map and test it all out |
|
[ Log in to reply ] |
|
Andrew Poole |
Message #72263, posted by andypoole at 15:37, 30/11/2005, in reply to message #72262 |
Posts: 5558
|
The prototype map renderer is now FINISHED.
Now I just have to link it into the rest of the code, fix the compilation errors, then write a test script to build a simple map and test it all out Well get on with it then! |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72264, posted by Phlamethrower at 15:59, 30/11/2005, in reply to message #72263 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
It's compiling and running, but doesn't want to draw anything yet
The fact that it hasn't crashed suggests that it's having trouble building the map. That and the fact I just fixed a map building related bug, and the savegame I made didn't have any texture names stored in it
And my makefile is randomly building files which are up to date |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72265, posted by Phlamethrower at 16:22, 30/11/2005, in reply to message #72264 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
The fact that it hasn't crashed suggests that it's having trouble building the map. That and the fact I just fixed a map building related bug, and the savegame I made didn't have any texture names stored in it OS_GBPB 9 doesn't want to look inside directories for files
And my makefile is randomly building files which are up to date Fixed that, it was touching the wrong file.
Now to debug the tile loading code, which would have been debugged yesterday if OS_GBPB was doing its job properly... |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72266, posted by Phlamethrower at 16:29, 30/11/2005, in reply to message #72265 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Tile loading is fixed, and map generation seems to work fine, now I just need to work out why it still isn't drawing anything |
|
[ Log in to reply ] |
|
James Shaw |
Message #72267, posted by Hertzsprung at 16:36, 30/11/2005, in reply to message #72266 |
Ghost-like
Posts: 1746
|
|
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72268, posted by Phlamethrower at 18:03, 30/11/2005, in reply to message #72267 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
*finally gets the metal roller for his emergency backup mouse back into its springy holder thing*
Now, where was I? |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #72270, posted by Phlamethrower at 18:28, 30/11/2005, in reply to message #72268 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Me = Your god.
(Although what you can't see there is that the east and west sides of the bottom block are extending onto the top of the alternate screen bank. Which probably explains why trying to plot the top two corner blocks will cause the program to crash Must add some more range checks ) |
|
[ Log in to reply ] |
|
Pages (22): |< <
4
> >|
|
The Icon Bar: The Playpen: Slightly cold news on page 10! Phlamey breaks the server. |
|