Making a CRPG Part 2 – Maps, Scrolling and Line of Sight

In this, part 2, we will be looking at scrolling maps, a pivotal element of top-down 2D computer role play games of yore.

I think something that is lost on many modern gamers, who didn’t grow up in the 80’s. The majority of games on the early 8-bit systems were limited to a single screen of play. Really good games may have multiple screens but when you moved off the edge it would load a new screen.

It’s bigger on the inside!

So it was utterly FANTASTIC to see a game screen that was a view-port on a much larger world. When I first saw Ultima II, I was in total shock. There was (to my viewpoint) no limit to what could be beyond the borders of the screen! It both was thrilling and increased my curiosity and expectations of what the game could have.

A scrolling map was also well beyond what most BASIC languages could do in those days. Some were better than others at high-speed video display, but anything close to full screen was a challenge no matter the platform. So knowledge of assembly language was needed to implement one.

So how to render a map that is bigger than the screen? Let’s dive in…

Storing Maps

The first thing to figure out how you are encoding your maps internally. How much memory are you devoting internally to a map? Is the data compressed on disk and must be uncompressed when loaded? How many unique tiles can be present on a map? Are tiles global or specified for the map?

Early Ultima’s like II and III had 64×64 size maps. Both had less than a byte’s worth of tiles (64 and 128) so they would use up 4K of RAM to store the map, uncompressed and using a full byte per tile. Ultima IV uses 32×32 size maps and some clever coding to load a continuous world map. As you walk around, new 32×32 chunks are loaded. This creates some challenging edge cases (literally) when you approach corners and the game will need to load up to 3 new chunks to get the data needed. Ultima V goes to 16×16 chunks for the world map.

The issue with doing continuous map loads on early 8-bit systems is most of them aren’t that efficient with loading data continuously. Until hard drives came along, loading even a few kilobytes from floppy disk could take a second or so. And it got worse on systems like the Commodore 64 where the continuous music would suddenly get stuck on a single note as it loaded fresh data. My own experiments with a “big map” showed the problem, as every time I approached an edge it would take seconds to load fresh data.

So I decided for my own maps to just have singleton maps that are a maximum of 4K in size, and if you left them you’d just load a new one as a self-contained area. For tiles, I have 128, and multiple character sets. So for a world map, there is a “world” tile set that includes mountains and other features only found on world maps. The leftover bit is used as a lighting mechanic; it indicates if this tile is “lit” or not naturally on the map.

The nice thing about a map buffer is it can take any shape you want. Just because I have 4096 tiles doesn’t mean it’s automatically 64×64. By specifying a height and width parameter for each map, I can have them in many different sizes. In practice I found that 32×32 was a decent size for most towns and dungeons. 48×48 was nearly perfect, just big enough to have a lot of interesting areas. 64×64 was almost TOO big, there was a few cases where I split maps into multiple maps because a super large map wasn’t actually ideal, especially if they had a lot of mobs (mobile objects) on them.

Some game maps are compressed on disk so they take less room. With a lot of older CRPG’s this makes good sense; you don’t have a lot of unique tiles and you tend to have long horizontal stripes of them, which screams “compress me!” The most common form of compression is RLE, or run-length-encoding. RLE defines the data as either a singleton (one tile) or a count of whatever comes next of values to repeat. There’s usually also a terminator value as well to indicate map processing should end.

For example, if you have 64 unique tiles, the top two bits could be used to indicate a few different ideas:

  1. The top two bits are control bits. If both are 0, it’s a terminator for the map data. If 01, this is a singleton tile. If 10, it’s two consecutive tiles (or whatever the most common count of consecutive tiles is in your maps.) If 11, use the tile value as a count and that’s how many of the next tile to produce.
  2. The top two bits are count bits. Value 0 means it’s a terminator for the map data. Otherwise produce 1-3 of the given tile.

Let’s look at an example, here is a 7×7 map, showing an island. Uncompressed, if you used a full byte per tile, it would take up 49 bytes.

With method #1 above, it would take two bytes for any length of greater than 2 to store. Crunching the numbers, it would take 25 bytes (including a terminator byte) to store. Almost 50% compression!

With method #2 above, while we are limited to a maximum of 3 repeated tiles, it actually comes in at 21 bytes, over 50% compression. Nice! And the algorithm to decompress is a little simpler as well.

Of course, this example only has two tile types, and the map is rather straight-forward. Any CRPG map is likely to have a lot richer of a data set. And there is a point where RLE won’t be as effective. My own maps utilize a lot of “two pair” tiles where they are the same type (grass, for instance) but are in fact different tiles. This breaks RLE, which expects a lot of the same tiles to be repeated in a horizontal line. For such maps, using a more complex pattern-oriented compression technique like LZW and Huffman makes more sense.

The main value of compression is to reduce disk size, though. Is disk size really a problem to solve? In the old days, the answer was unhesitatingly yes. Most 8-bit systems had 160-180K disks, and every disk was an expense to replicate and put in a box. Data compression saved money. In the modern era, though, with digital distribution and USB sticks that hold more memory than the entire production run of a computer system’s RAM added together, it’s not as big of a deal. Even retro enthusiasts these days tend towards modern storage solutions like emulated disk systems or even cartridges with megabytes of space available. So I figured, why bother?

Towards the end of my development work, I did consider that it would be better to have dynamic tiles. In other words, store a key list of the unique tiles used on the map, assign them unique values, then the map data itself using those values. It’s a nice idea, as each map then basically has it’s own unique tile set, and you wouldn’t have a lot of needless replication. But it adds a lot of overhead towards map loading, and would require a complicated editor for maps. Something to consider for the future…

Viewing Maps

Okay, so you have your map loaded in memory. How to get it on screen?

Well, the first thing is to determine the number of tiles you want to appear on the screen. Depending on how many pixels per tile, how large the screen, etc. And is your “avatar” character always at the center? If so, an odd number of tiles per side makes sense for balance.

Using a ‘view-port buffer’ is a best approach. Don’t try and pull each tile individually from your map data, use an in-between buffer to store it. Using map height and width and a position offset, it’s not hard to create a double loop to copy out map data to your view-port buffer. But what do you do when your view-port goes over the edge of the map?

Different games handle it different ways. If you want your map to just stop scrolling at edges, Gauntlet-style, that’s easy to do; you just make sure offsets never go past a certain value. This does create the sense of reaching a “map edge” though, and may remove the player a little from immersion.

Other games just have a default “overflow” tile that is used, and interacting with it will pop the character off the map. This also works but still clearly illustrates that you’ve reached a map edge.

For my own game, I had two versions. One is “repeat the edge tile” which takes whatever tile was along that edge and repeats it indefinitely. This creates a less obvious map edge. The other version is “wrap-around”, which creates a continuous map by wrapping to the other side. I use this one sparingly, usually for maps that are either “warped magic” in nature or in a more clever fashion to create non-square style caverns.

No wasted space!

One other feature I introduced with my own map system is slanted maps. Since map projection is up for interpretation, I can slant map data by row to make a more natural style map for coast lines that aren’t going in cardinal directions. Very useful, and very difficult to debug!

One additional task is to place mobs (mobile objects) on your map. This would be your monsters, points of interest, and other items that aren’t part of the static map. I store these in a separate data set, so they must be placed in the view-port area if they are visible. This puts a practical limit of how many mobs per map, since every extra calculation is costing you processing time.

So now we have our view-port, with our set of tiles. Now (finally) it’s time for line of sight!

Line Of Sight

Back in the early 90’s I tried to create the LOS algorithm in BASIC, using sine and cosine functions. I thought of it as I was flinging light out from the center and traversing a circle, and that if I struck a barrier that blocked line of sight, everything after it on the path would be dark.

So… it kind of worked. Except that even on a 11×11 size screen and going 1 degree at a time, it still didn’t cover all the squares. Plus given it was in BASIC it ran VERY slowly, taking ten minutes to complete.

Years later, I got a hold of the Ultima III LOS algorithm, and was able to see my error. I was thinking in reverse! What you do is trace a path from the tile you want to check LOS on and traverse back to the center.

Diagonal then Cardinal

The algorithm is pretty simple:

  • Hide all tiles in the view-port, except the center tile, where your avatar is.
  • For each tile in the view-port, plot a path back to center. The original algorithm uses two arrays to achieve an offset. It moves diagonally towards the center until it hits a cardinal direction, then continues the rest of the way on the cardinal.
  • If at any point you encounter a “blocking” tile, move on to the next tile.
  • Otherwise, if you reach center, uncover the target tile and move to the next tile.

Simple indeed, but processor-intensive. Besides processing the view port in start-to-end order without taking the 2D nature of the data into account, it also ends up reprocessing a LOT of tiles unnecessarily. If a tile is blocked, then wouldn’t any tiles between it and the blocking tile also be blocked? And if so, why calculate those at all?

I introduced some optimizations to reduce unnecessary calculations and it worked pretty well. However, the LOS algorithm in Ultima III was rather heavy; a single tile creates a huge swath of diagonal shadow behind it. I noticed that Ultima IV on the PC seemed to have a better algorithm so I took a copy of the source from XU4 (sadly now an extinct project) to analyze.

Cardinal then Diagonal

The algorithm is VERY different. It starts by tracing in the cardinal directions from the center outward. If it encounters a blocking tile, it blocks only the cardinal tiles behind it.

After the four cardinal plots, it then does four quadrant calculations, which start on the edge and go towards the center on a horizontal or vertical direction first then diagonal. This has the effect of not blocking so pervasively. It’s a much more efficient algorithm because it’s actually taking the structure of the view-port into consideration.

Light

Light Map

So, remember that light bit on the tiles? That’s used to determine dark and light areas. But, if the player has a light source going, how to determine if a square is lit or not?

I use a light map, which has concentric circles of numbers, matching the size of the view port. The center area is value 0, and slowly increases as it goes outward. A light source has a strength (or radius) value, which the light map is subtracted from. If the value is less than zero, it’s not lit. If it’s equal or greater, it’s lit.

The light map is always applied after LOS has been calculated. A square that’s already blocked remains blocked.

Elevation

This was a late-development feature, which came about when I was out on a ridge one day looking over a magnificent set of waterfalls in the distance. I realized that despite being in a forest and having a deep valley of forest between us, I could still see the falls clearly. And that got me thinking, what about elevation and LOS?

The elevation map is a separate data set from the map’s data, as not every map uses elevation. The data is also stored in a compressed format (run-length encoding!) so it doesn’t take up much disk space. There are four levels of elevation, from 0 to 3.

The math is easy. Whatever elevation your avatar is at, everything below it is not a blocking tile. Everything at same level respects the LOS calculations. And everything above your level is considered a blocking tile automatically.

I mostly use elevation on world maps, but a few special maps use it. I think my favorite in this regard is a sewer dungeon, with both upper and lower levels. The biggest problem to solve with elevation was coming up with clear boundary delineation.

The Code

Below is ROA’s map view algorithm, in TMS9900 assembly. It uses multiple buffer maps for each stage and then combines them at the end for the finished mapview.

* Map Building Routine
* Extract map from map buffer into VMAP
BLDMAP MOV  R11,*R10+
       LI   R0,MOBVIS
       LI   R1,32
BLDMP0 CLR  *R0+                       * Clear mob visibility array
       DEC  R1
       JNE  BLDMP0
       LI   R3,2
       BLWP @PAGE1                     * Set >2000 to page 2 (map buffer)
       LI   R3,1
       BLWP @PAGE2                     * Set >3000 to page 1 (elevation)
       MOVB @SLANT,R1                  * Get orientation into R1
       SRL  R1,8
       MOV  @DIRY(R1),R9               * Set R9 to -1 (left), 0 (none), or 1 (right)
       MOV  @DSLANT(R1),R8             * Set R8 to 0 (left), -6 (none), -12 (right)
       MOV  @Y,R1                      * Get Y value into R1
       MOV  @X,R2                      * Get X value into R2
       AI   R1,-6                      * Set starting y position
       A    R8,R2                      * Add slant start to x position       
       LI   R3,13                      * Row count
       LI   R4,13                      * Column count
       CLR  R5                         * buffer index
       MOVB @EDGES,@EDGES              * Check if edge or repeating map
       JNE  BLDMPW
* Build map with edge
BLDMPE MOV  R1,R6                      * Copy R1 to R6
       MOV  R2,R7                      * Copy R2 to R7
       BL   @EDGCHK                    * Check if over edge
       MOV  R0,R0
       JEQ  BLDME1
* Edge correction
       COC  @W1,R0                     * Vertical?
       JNE  EDGEM2
       MOV  R6,R6
       JLT  EDGEM1
       MOV  @VWIDTH,R6
       DEC  R6
       JMP  EDGEM2
EDGEM1 CLR  R6
EDGEM2 COC  @W2,R0                     * Horizontal?
       JNE  BLDME1
       MOV  R7,R7
       JLT  EDGEM3
       MOV  @HWIDTH,R7
       DEC  R7
       JMP  BLDME1
EDGEM3 CLR  R7
* Get tile
BLDME1 MOV  R7,R0                      * Copy R7 to R0
       MPY  @HWIDTH,R6                 * Multiply Y by hortz width
       A    R0,R7                      * Calculate map index into R7
       MOVB @MAPBUF(R7),@VMAP(R5)      * Copy tile
       MOVB @MAPENV(R7),@EMAP(R5)      * Copy elevation level
       MOVB @VMAP(R5),@LMAP(R5)        * Copy light level
       SOCB @B128,@VMAP(R5)            * Set high bit on active tile
       SZCB @B127,@LMAP(R5)            * Filter light array to top bit only
       MOVB @B1,@LOSMAP(R5)            * Set LOS map to blocked
       INC  R5                         * Increment the buffer pointer
       INC  R2                         * Increment the column index
       DEC  R4                         * Decrement the window width count
       JNE  BLDMPE
       INC  R1                         * Increment the row index
       A    R9,R8                      * Add slant change to R8
       MOV  @X,R2                      * Move X back into R2
       A    R8,R2                      * Add slant to x position
       LI   R4,13                      * Reset the window width to 13
       DEC  R3                         * Decrement the window height count
       JNE  BLDMPE
       JMP  BLDMP2                     * Jump to next routine
* Build map with wrapping
BLDMPW MOV  R1,R6                      * Copy R1 to R6
       MOV  R2,R7                      * Copy R2 to R7
       BL   @EDGCHK                    * Check if over edge
       MOV  R0,R0
       JEQ  BLDMW1
* Wrap correction
       COC  @W1,R0                     * Vertical?
       JNE  WRAPM2
       MOV  R6,R6
       JLT  WRAPM1
       S    @VWIDTH,R6
       JMP  WRAPM2
WRAPM1 A    @VWIDTH,R6
WRAPM2 COC  @W2,R0                     * Horizontal?
       JNE  BLDMW1
       MOV  R7,R7
       JLT  WRAPM3
       S    @HWIDTH,R7
       JMP  BLDMW1
WRAPM3 A    @HWIDTH,R7
* Get tile
BLDMW1 MOV  R7,R0                      * Copy R7 to R0
       MPY  @HWIDTH,R6                 * Multiply Y by hortz width
       A    R0,R7                      * Calculate map index into R7
       MOVB @MAPBUF(R7),@VMAP(R5)      * Copy tile
       MOVB @MAPENV(R7),@EMAP(R5)      * Copy elevation level
       MOVB @VMAP(R5),@LMAP(R5)        * Copy light level
       SOCB @B128,@VMAP(R5)            * Set high bit on active tile
       SZCB @B127,@LMAP(R5)            * Filter light array to top bit only
       MOVB @B2,@LOSMAP(R5)            * Set LOS map to blocked
       INC  R5                         * Increment the buffer pointer
       INC  R2                         * Increment the column index
       DEC  R4                         * Decrement the window width count
       JNE  BLDMPW
       INC  R1                         * Increment the row index
       A    R9,R8                      * Add slant change to R8
       MOV  @X,R2                      * Move X back into R2
       A    R8,R2                      * Add slant to x position
       LI   R4,13                      * Reset the window width to 13
       DEC  R3                         * Decrement the window height count
       JNE  BLDMPW
* Retrieve data into state and sensing arrays
BLDMP2 MOVB @VMAP+84,@CTILE            * Set current tile value
       MOVB @EMAP+84,@CELEV            * Set current elevation level
       MOVB @B247,@VMAP+84             * Set player graphic for permissible space
       MOVB @B1,@LOSMAP+84             * Set center of LOS map to visible
       SETO @SURRND                    * Clear the surrounding tile contents
       SETO @SURRND+2
       SETO @SURRND+4
       SETO @SURRND+6
       MOVB @VMAP+97,@SURRND           * Copy the down tile
       MOVB @VMAP+83,@SURRND+2         * Copy the left tile
       MOVB @VMAP+71,@SURRND+4         * Copy the up tile
       MOVB @VMAP+85,@SURRND+6         * Copy the right tile
* Mob processing
       LI   R3,4
       BLWP @PAGE2
       CLR  @WORK2                     * Clear WORK2 (in map mob count)
       MOV  @MOBCNT,R0                 * Copy total mob count to R0
       JEQ  BLDMP3                     * If 0, skip to next phase
       MOV  @MOBADR,R1
       CLR  @WORK                      * Clear @WORK (Mob #)
       LI   R6,WORK2+2                 * Set R6 to WORK2+2
BM2    MOVB *R1,R2                     * Copy mob type into R2
       JEQ  BM2B                       * If zero, skip, no counter decrease
       CB   @B23,R2                    * Check if inert
       JEQ  BM2B                       * If so, skip but decrease counter
       JMP  BM2C
BM2A   AB   @B1,@WORK
       DEC  R0                         * Decrement mobs processed
       JEQ  BLDMP3                     * If finished, move on
       JMP  BM2
BM2B   AB   @B1,@WORK
       AI   R1,8                       * Go to next mob
       DEC  R0                         * Decrement mobs processed
       JEQ  BLDMP3                     * If finished, move on
       JMP  BM2
BM2C   MOV  *R1+,@MAPMOB               * Get mob data
       MOV  *R1+,@MAPMOB+2
       MOV  *R1+,@MAPMOB+4
       MOV  *R1+,@MAPMOB+6
       BLWP @MOBWIN                    * Calculate window positon
       MOV  R3,R3
       JLT  BM2A                       * Not visible, skip placement
       INC  @WORK2                     * Increase mob count
       MOV  R3,*R6+                    * Copy index to WORK2 array
       MOVB @MAPMOB+1,*R6+             * Copy pattern to WORK2 array
       MOVB @WORK,*R6+                 * Copy mob index
       MOVB @MAPMOB+1,@VMAP(R3)        * Copy pattern to VMAP for LOS calculations
       LI   R4,4
       LI   R2,MOBSEN                  * Load mob sense data
BM2D   C    R3,*R2+                    * Check if position is next to player
       JNE  BM2E
       MOV  *R2+,R5                    * Get address into R5
       MOVB @WORK,*R5                  * Copy mob to state array
BM2E   INCT R2
BM2F   DEC  R4                         * Loop all four locations
       JNE  BM2D
       JMP  BM2A
* Update sense counter for traps/secrets
BLDMP3 CLR  R1                         * Clear R1 for sense counter
       LI   R0,SURRND+1                * Set R0 to SURRND array, mob area
       LI   R2,4                       * Set R2 to 4 (4 directions)
BM3A   CLR  R3
       MOVB *R0+,R3                    * Copy mob # to R3
       JLT  BM3B                       * if negative, skip
       SRL  R3,5                       * Make 8-step index
       A    @MOBADR,R3
       MOVB *R3,R4                     * Copy mob type to R4
       SB   @B16,R4                    * Subtract 16 from mob ID
       JLT  BM3B                       * If less than zero, not a hidden mob
       SRL  R4,8                       * Shift value to make index
       MOVB @SENSEV(R4),R5             * Copy from character array
       JEQ  BM3B                       * If 0, skip
       SOCB R5,R1                      * Set bit
BM3B   INC  R0                         * Increase to next tile position
       DEC  R2                         * Decrement counter
       JNE  BM3A
       MOVB R1,@SENSEC+1               * Copy R1 to SENSEC (Counter)
* Check party light level, map onto tiles
LGTMAP MOV  @MAGEYE,R0                 * Check if magic eye is active
       JEQ  LGT1
       BL   @MEVIEW                    * Fully open map
       B    @PCME4A
LGT1   MOVB @LIGHT,R0                  * Check if map is fully lit
       JEQ  LGT1A                      * If so, skip to LOS algorithm
       MOVB @PARTY+30,R0
       ANDI R0,>2000                   * Check for Radiant Pharos
       JEQ  LGT1B
LGT1A  BL   @MEVIEW                    * Fully open map
       JMP  LOS
LGT1B  CLR  R1                         * Set buffer index
       LI   R5,169                     * Set buffer counter
LGT2   MOVB @ALIGHT(R1),R2             * Copy window position light value into R2
       SB   @LGTLV+1,R2                * Subtract the current light strength from window value
       JGT  LGT3                       * If greater, unlit
       MOVB @B128,@LMAP(R1)            * Otherwise, mark the tile lit
LGT3   INC  R1
       DEC  R5
       JNE  LGT2
* Map line-of-sight on the map
LOS    LI   R8,4                       * Number of directions to process
       CLR  R9                         * Direction index
CLOS1  LI   R7,6                       * Count of tiles
       LI   R0,6                       * Column position
       LI   R1,6                       * Row position
CLOS2  CLR  R12                        * Set tile to copy to closed tile
       BL   @POSCLC                    * Calculate position
       MOVB @LOSMAP(R3),R2
       JEQ  CLOS3
       CI   R3,84
       JEQ  CLOS2A
       BL   @CHKTLE                    * Fetch tile's opacity level, also check elevation
       ANDI R5,>8000                   * Check if a blocking tile
       JNE  CLOS3
CLOS2A LI   R12,>0100                  * Set tile to open
* Set tile
CLOS3  MOV  @MAPLOS(R9),R2             * Copy direction vector index
       A    @DIRX(R2),R0               * Add direction vector to column
       A    @DIRY(R2),R1               * Add direction vector to row
       BL   @POSCLC                    * Get buffer index
       MOVB R12,@LOSMAP(R3)            * Copy visible/blocked value to buffer
       DEC  R7
       JNE  CLOS2                      * Loop through path
       INCT R9                         * Change direction
       DEC  R8
       JNE  CLOS1                      * Loop through rows
* Diagonal LOS
DLOS   LI   R8,4                       * Number of directions to process
       CLR  R9                         * Direction index
DLOS1  LI   R6,6
       LI   R0,6
DLOS2  LI   R7,6
       LI   R1,6
DLOS3  BL   @POSCLC
* Collect four tile indices in FRAM array
       MOV  R3,@FRAM
       MOV  R0,@FRAM+8
       MOV  R1,@FRAM+10
       MOV  @MAPLOS+8(R9),R2
       A    @DIRX(R2),R0
       A    @DIRY(R2),R1
       BL   @POSCLC
       MOV  R3,@FRAM+2
       MOV  @FRAM+8,R0
       MOV  @FRAM+10,R1
       MOV  @MAPLOS+10(R9),R2
       A    @DIRX(R2),R0
       A    @DIRY(R2),R1
       BL   @POSCLC
       MOV  R3,@FRAM+4
       MOV  @MAPLOS+8(R9),R2
       A    @DIRX(R2),R0
       A    @DIRY(R2),R1
       BL   @POSCLC
       MOV  R3,@FRAM+6
       MOV  @FRAM+8,R0
       MOV  @FRAM+10,R1
* Check three surrounding tiles
       CLR  R12
       MOV  @W3,@FRAM+8
       LI   R2,FRAM
DLOS4  MOV  *R2+,R3
       MOVB @LOSMAP(R3),R4
       JEQ  DLOS5
       BL   @CHKTLE
       ANDI R5,>8000
       JEQ  DLOS6
DLOS5  DEC  @FRAM+8
       JNE  DLOS4
       JMP  DLOS7
DLOS6  LI   R12,>0100
* Set tile
DLOS7  MOV  @FRAM+6,R3
       MOVB R12,@LOSMAP(R3)
       MOV  @MAPLOS+8(R9),R2
       A    @DIRY(R2),R1
       DEC  R7
       JNE  DLOS3
       MOV  @MAPLOS+10(R9),R2
       A    @DIRX(R2),R0
       DEC  R6
       JNE  DLOS2
       AI   R9,4
       DEC  R8
       JNE  DLOS1
* Final opening of permitted space
PCMEND CLR  R1                         * Set buffer index
       LI   R0,169                     * Set buffer counter
       MOVB @CELEV,R2                  * Copy elevation to R2
PCME1  MOVB @LOSMAP(R1),R3             * Check LOS
       JEQ  PCME3
       MOVB @VMAP(R1),@LMAP(R1)        * Set the tile onto the map
       JMP  PCME4
PCME3  MOVB @SPACE,@LMAP(R1)           * Make the tile black (invisible)
PCME4  INC  R1
       DEC  R0
       JNE  PCME1
* Place visible mobs
PCME4A MOV  @WORK2,R0                  * Check mob count
       JEQ  PCME7                      * If zero, skip
       LI   R1,WORK2+2
PCME5  MOV  *R1+,R2                    * Get mob index
       MOV  *R1+,R3                    * Get pattern
       CB   @LMAP(R2),@SPACE           * Is the space blacked out?
       JEQ  PCME6
       MOVB R3,@LMAP(R2)               * Set mob on map
       ANDI R3,>00FF                   * Get mob #
       MOVB @B1,@MOBVIS(R3)            * Set mob visibility to 1
PCME6  DEC  R0                         * Decrement count
       JNE  PCME5
PCME7  LI   R0,>F700
       SB   @BOAT,R0
       MOVB R0,@LMAP+84                * Copy the party icon to the center
       B    @SUBRET

* Magic eye/Pharos view
MEVIEW LI   R0,169                     * Set all tiles to lit/visible
       LI   R1,VMAP
       LI   R2,LMAP
MEVW1  MOVB *R1+,*R2+
       DEC  R0
       JNE  MEVW1
       RT

* Calculate mob position in viewing window
* Returns window index (0-169) in R3, -1 = not in window
MOBWIN DATA VWS,MOBWN0
MOBWN0 MOVB @SLANT,R2                  * Get orientation into R2
       SRL  R2,8
       MOV  @DIRY(R2),R0               * Set R7 to 1 (left), 0 (none), or -1 (right)
       NEG  R0                         * Negate R0
       MOV  @W7,@WMOB                  * Store 7 in WMOB
       MOV  @WN7,@WMOB+2               * Store -7 in WMOB+2
       MOV  @MAPMOB+2,R2
       MOV  R2,R4
       SRL  R2,8                       * Set R2 to mob Y
       ANDI R4,>00FF                   * Set R4 to mob X
       S    @Y,R2                      * Subtract player y from mob y
       CI   R2,7                       * Check right vector
       JLT  MOBWN1
       MOVB @EDGES,@EDGES
       JEQ  MOBWN5
       S    @VWIDTH,R2                 * Subtract wrap offset
MOBWN1 CI   R2,-7                      * Check left vector
       JGT  MOBWN2
       MOVB @EDGES,@EDGES
       JEQ  MOBWN5
       A    @VWIDTH,R2                 * Add wrap offset
       CI   R2,6                       * Check left vector again
       JGT  MOBWN5
MOBWN2 MPY  R2,R0                      * Multiply Y offset by R0
       S    R1,@WMOB                   * Adjust positive boudnary for X
       S    R1,@WMOB+2                 * Adjust negative boundary for X
       MOV  @WMOB,@WMOB+4
       DEC  @WMOB+4
       S    @X,R4                      * Subtract player x from mob x
       C    R4,@WMOB                   * Check down vector
       JLT  MOBWN3
       MOVB @EDGES,@EDGES
       JEQ  MOBWN5
       S    @HWIDTH,R4                 * Subtract wrap offset
MOBWN3 C    R4,@WMOB+2                 * Check vector
       JGT  MOBWN4
       MOVB @EDGES,@EDGES
       JEQ  MOBWN5
       A    @HWIDTH,R4                 * Add wrap offset
       C    R4,@WMOB+4
       JGT  MOBWN5
MOBWN4 MPY  @W13,R2                    * Multiply by 13 (window width)
       AI   R3,84                      * Add center offset
       A    R4,R3                      * Add X delta
       A    R1,R3                      * Add shift delta
       MOV  R3,R3
       JLT  MOBWN5
       CI   R3,168
       JGT  MOBWN5
       MOV  R3,@>0006(R13)             * Copy back to calling routine
       RTWP
MOBWN5 SETO @>0006(R13)
       RTWP

* Check tile at index in R3
CHKTLE MOVB @LMAP(R3),R4               * Check light level
       JEQ  CHKTL2                     * If not lit, is automatically blocking
       CB   @CELEV,@EMAP(R3)           * Check current elevation against target tile
       JEQ  CHKTL3                     * If equal, continue to opacity test
       JLT  CHKTL2                     * If less, go to block
CHKTL1 CLR  R5                         * Clear R5 (open)
       JMP  CHKTL4
CHKTL2 SETO R5                         * Set R5 (closed)
       JMP  CHKTL4
CHKTL3 MOVB @VMAP(R3),R4               * Copy tile to R4 low byte
       SRL  R4,8
       ANDI R4,>007F
       MOVB @TILES(R4),R5              * Copy tile code into R5 high byte
CHKTL4 RT

* Check for map edges
* R1 = Y, R2 = X
* R0 returns 0 if no violation, 1 if vertical, 2 if horizontal, 3 if both
EDGCHK CLR  R0                         * Set to 0
       C    R2,@HWIDTH                 * Check X against horizontal width
       JL   EDGCH1
       INCT R0
EDGCH1 C    R1,@VWIDTH
       JL   EDGCH2
       INC  R0
EDGCH2 RT

* Determine index on map
POSCLC MOV  R1,R2
       MPY  @W13,R2
       A    R0,R3
       RT

Conclusion

Despite the numerous calculations going on, the map view creation is pretty fast, enough that I had to introduce some artificial delays. I did notice that the more mobs on the map the more impact it had on performance. For that reason, there is a limit of mobs per map, and I actually broke up some maps into more than one map to remove performance problems.

So that’s it with maps and part 2! I’m not sure what part 3 will cover yet, I’m open to feedback.

Posted in Coding, CRPG, Design | 2 Comments

Summer Update

Hey all…

Sorry, it’s been awhile since I posted here. After the release of the game, I got crazy busy doing patches, testing, and improvements.

Thanks to the help of several enthusiastic fans, I was able to do a large substantial update to the game to address a number of balance issues in the middle tier of the game, and add several new features. I am calling it “done” now, with only bug fixes going forward.

I also decided to do one last thing, which was a 2nd printing of the Collector’s Edition. And this time use crowdsource funding to do it. If it gets funded, great! If not, I may do a small print run privately for the store to sell and then I’ll close the book on this chapter.

You can find the Kickstarter here:
https://www.kickstarter.com/projects/arcadeshopper/realms-of-antiquity-the-shattered-crown-collectors-edition/

Posted in CRPG, Personal, RPG, TI-99/4a | Leave a comment

Waiting on the Post

Stack em up!

Okay, all pre-ordered collector’s editions have been mailed! Going forward, I’ll be shipping them individually rather than waves. I just received my last order of game boxes, which means there will be around 100 or so collector’s editions. I don’t plan on doing more, so get them while you can!

If you want the custom cartridge and/or disk, there will likely be a delay in shipping your order. I have to order the cart boards and chips separately,  and with floppy disks I’ve been recycling old disks I  got a pile of (thanks Ciro!), but it’s a roll of the roulette wheel if they’re usable or not…

Part 2 of Making a CRPG will be coming next… with a focus on scrolling maps!

Posted in CRPG, Personal, TI-99/4a | 2 Comments

Making a CRPG – Part 1: Infrastructure and Platform

In this, the first part of several, I will talk about the creation of Realms of Antiquity for the TI-99/4a home computer. There will be technical, narrative, and designer content, with plenty of side-treks. Strap yourselves in!

I should add that these articles are likely to be very “crunchy” with technical detail. The intended audience would have some passing knowledge of assembly language as well as being CRPG enthusiasts. If you want more detail, program listings, algorithm definitions, by all means post and ask!

The best place to start? The platform it was built upon, and the infrastructure of how the code drives the program. And on that note, the number one best resource EVER is the TI Tech pages. They were an awesome and useful resource with my project!

The Platform

A big reason that there was a distinct lack of good software for the TI until well after the home computer division was cancelled in 1983 is the processor that drives the TI-99/4a, the TMS9900 microprocessor, released in 1976.

It has occasionally been called the “first” 16-bit processor, but that claim is disputed by IBM and Motorola. It’s VERY different from the 6502, arguably the most popular and well-known microprocessor of its era, in a multitude of ways:

  • 3mz clock speed, around 3 times the speed of contemporary processors
  • 16-bit instead of 8-bit
  • Can do register-to-memory, memory-to-register, or even memory-to-memory operations
  • Big-Endian (high byte first, then low byte, going left to right)
  • Hardware unsigned multiplication and division operators
  • No native stack implementation
  • No memory page addressing; no “zero page” concept
  • 15-bit address line, so it accesses 32,767 “words” of 16-bit size
    • Byte operations are handled via special op codes
  • 16 CPU general purpose registers available
    • Instead of hardware registers, they are relocatable anywhere in CPU memory using a workspace pointer
    • You can have as many register sets as you want; this effectively replaces a “stack” concept, as you can use registers as a means to pass values
    • Only a few registers have special uses
      • R11 is always the return address for a branch and link
      • R12 is used by the communications register unit (CRU) for special purposes; the SAMS card needs this for page swaps
      • R13-15 are used for context switches. They store the return address, workspace address, and status register from the prior context

Because opcodes are 16-bit, TMS9900 assembly uses more memory than a 6502 line-by-line, as instructions can run anywhere from 1-3 words (2-6 bytes). But you save memory because you can do in one instruction what takes several on other processors.

To use a car analogy, if a standard 8086 processor is your typical car, the TMS9900 is a Cadillac. Big luxurious driving, but kind of expensive and fuel-consumptive. 🙂

Memory

The TI-99/4a has a 16-bit addressing range, for 64k total.

Unlike other architectures, none of this addressing space is used to map video; the VDP chip has it’s own 16k of dedicated RAM which is accessed through memory-mapped ports. These ports only allow you to read/write bytes, not words. This bottleneck is the cause of much anguish and annoyance on the part of TI programmers. It can and HAS been overcome; the singular most impressive work in this area in my opinion is Mike Brent’s “Dragon’s Lair” for the TI-99/4a, which runs on the base console and renders all the original videos in a fairly decent rendition on TI’s bitmap mode.

The base console only has 256 bytes (!) of CPU RAM, nicknamed the “scratchpad”, which is fast 16-bit memory. Most of the time, it’s best to locate your register set here. Some values in the space are used by internal processes but most of it is available for your use. TI’s Parsec cartridge (which features horizontal pixel bitmap scrolling) had to locate it’s scrolling routine in the scratchpad for maximum speed.

If you have the 32K memory expansion, you get two large blocks of CPU RAM, a lower 8K block and the upper 24k block. This RAM is accessed with a slower 8-bit multiplexer, which adds wait states when accessed, so many 99’ers try and move time-critical code into the scratchpad for best performance. My personal experience has been the slower speed is not really an impediment unless you’re doing something really over the top.

So where, you ask, are memory pages, like Apple and Commodore have? Well, there aren’t any in the base TI architecture. The only page switches occur with some cartridges, which have their own 8K space. That’s where the SAMS card comes in.

Reverse-engineered from the never-released TI-99/8 architecture, the Super Advanced Memory System (SAMS) card allows you to swap out 4K pages anywhere in the addressing space that RAM exists, just using some simple instructions to configure it. These pages don’t even need to be unique; you technically could assign the same page twice in two different places. The base SAMS card gives the TI 1MB of memory, or 256 pages, which is a bounty of space to play in!

But how to write code for such a system? Well, that’s the tricky bit…

Assembly

One thing to call out is that Realms of Antiquity is written in 100% assembly language. It’s reasonable to ask why, when high-level languages could be utilized to simplify maintenance and understanding.

Well, for one, because I wanted to. 🙂

Second, If I was writing a game for modern computers directly, I would not hesitate to use a high-level language. Besides being easier to manage, the most important thing about them is they can be compiled for different architectures. If I wrote a game in Java, I know it will run on a PC, MAC, or even Linux without any problems, and regardless of what kind of chipset or hardware are present.

But for a classic retro computer? You know the hardware and how it works and how to optimize for it. If you need speed and performance, assembly is the way to go. Any high-level language may apply a software pattern that works but could have been implemented with less memory or better efficiency.

Loaders

The TI-99/4a differs from a lot of other microcomputers of the era in that assembly language isn’t readily accessible with the base console. TI BASIC completely blocks access to it, TI Extended BASIC offers some access to load and run but no assembler is provided.

Most 99’ers use the Editor/Assembler to do their work. It was the big package deal, requiring the full system (disk drives, 32K expansion) to use. It had both a text editor and assembler, and two disks of utilities. They even threw in the complete source code for one of their games, Tombstone City.

Now on the TI, there are two kinds of assembly binaries:

  • Tagged-object code
    • Can be loaded anywhere in memory
    • Can co-exist with other object code and ran independently via name
    • Can refer to each other using assembly directives
  • Fixed-binary code
    • Only loads to specific memory locations
    • Stored as “memory images” with a maximum size of 8K per image minus six bytes for a header value
    • Loaded as a chain of files to fill up the entire memory space
    • Usually called “EA5” format as they were loaded using the Editor/Assembler cartridge’s option #5 “Load Program File”

Most 99’ers write assembly programs to start with as tagged object code. They are then converted to fixed-binary files using a utility. Programs load much faster this way as it loads them as 8K segments directly into memory.

As for how to load a SAMS program, which occupies more space than the 32K RAM? We’ll get to that in a bit. First, we go into…

Modules

So in the summer of 2017, I made the decision to convert Realms of Antiquity to use the SAMS memory card. As part of this, I had to figure out HOW to use it effectively.

The only assembler ever written for the AMS was an extension of a popular macro assembler called “Ragtime”, written by Art Green. I’ll give him credit; he did create an entire assembler/linker/loader platform which could utilize the card. But I had already been using a cross-assembler on the PC for speed and efficiency so I didn’t really want to try and compile everything on the TI in emulation.

So instead I read the documentation on how it built modules that were linked to each other and I figured out the pattern.

The first thing with any program in modules to do is identify your “root” functions that absolutely are needed everywhere. These form the basis of your “root” module, which always is present in memory and is accessed by everything. Then, figure out how many other modules you need. Ideally, if the root module and another are loaded, you should always be able to fit it into the existing address space. (Which on the TI is 32k, split into the 8k and 24k blocks.)

For Realms of Antiquity, I wanted the 8K block for data pages only, utilized by the modules for various functions. So I split the upper 24k into two modules, the root module and then potentially four other modules:

  • Start Module (Contains the title screen, character creation, music player and data, and end game sequence)
  • Travel Module (Contains the code for travel mode, includes map loading and mob interactions)
  • Manager Module (Contains the code for inventory, stat screens, and complex transaction management)
  • Combat Module (Contains the code for combat mode)

I later added more modules and sub-modules:

  • Encounter Module (Contains the code to generate battlemaps, as well as end battle management such as chests, traps, rewards, etc.)
  • FX/Scan Module (Contains all the code to create FX for combat, sprite based effects, as well as the code to create the monster stat screen. Only swaps out the last 4K page of the Combat or Encounter module.)
  • AI Module (Contains all the code to determine monster actions. Only swaps out the last 4K page of the Combat module.)

The sub-modules occurred as modules got full and I didn’t want to try and create a whole new module. This made me realize after the fact that I could have done a better job splitting up functionality and making smaller modules instead of larger monolithic modules. A good lesson for future projects!

So how to compile it? I just created several batch files to execute my cross assembler at a combination of the root module files and each targeted modules files, effectively compiling them as separate binary files. I then created some utility programs that copy the binary code out into the program binary file in specific locations for each module.

Memory Map

Here’s a picture of my file and memory map:

The greyed out areas are pages that are technically assigned to ROM addressing space at start-up time. That is the default mode for SAMS; pages 0-15 are just assigned consecutively. So that means after the program has started I can freely use those pages for data.

Pages 2-3 are the 8K lower memory space which means they are switched as needed for different functions. Pages 10-12 are always the root module. Pages 13-15 are the alternate modules. Everything after those is raw data used by the game, up to page 53. I use page 64 onwards for storing saved game data in memory while you play.

So how to get this into the SAMS card? The E/A loader certainly can’t do this. Time for a custom loader…

Custom Loader

The first issue to deal with is getting a loader in the right place. The default location for most assembly programs is the start of the upper 24K block. That’s not ideal here, though, because we want the root module there and if we swap it out at any point in the loading process the loader code will be lost! So we make sure it’s located in the lower 8K RAM instead. This is achievable by using an opcode called AORG (Absolute Origin) to relocate the program there.

The loader has to be self-contained, so it contains not just the loading code itself but subroutines for reading and writing to VDP. This is necessary beyond just updating the screen; the TI device service routines (DSR) which the disk system utilizes requires you to use buffer space in the video memory. This curious design is likely because on a base TI console that was the only RAM memory any architect could rely upon being there for buffer. Unfortunately that means all data has to be read from the VDP back into CPU memory.

The loader loads 8K chunks of data from the program binary at a time into the upper RAM, which are assigned to the requisite pages. It updates the page assignments on each pass, so each 4K blocks ends up in it’s correct page. With 44 pages of data, or 176k, it takes a bit! I originally designed my loader to read in 12K blocks from the program binary, but I found in practice this didn’t work, even when I was certain the VDP memory was freed up. I have noticed that TI was biased towards 8K blocks as a maximum size.

For the cartridge ROM, I have a different approach. I use 8K ROM pages to store the program, using 2K of the space for the loader and 6K for program segments. This is necessary because you aren’t guaranteed what ROM page a cartridge starts on, so you have to replicate your root code in every page. It does a direct CPU to CPU memory copy from the ROM page into the upper 24K page space with page swaps in a similar fashion. This is one reason the cartridge is by far the fastest way to load the game, no VDP in the middle of the process!

And here ends Part 1. In Part 2, we will start looking at specific modules and routines and going into excruciating detail on them!

 

Posted in Assembly, Coding, CRPG, Design, TI-99/4a | 11 Comments

Packing, Stacking and Mailing

Been nearly a month since release, and I’m overwhelmed by the response and feedback! Thank you everyone who purchased the game, and I hope to see more as word spreads.

I did an interview with The Lost Sectors on YouTube on Friday, you can view it here:

I also received the cartridge boards and EPROMs from my source to create the custom cartridges for Collector’s Editions, so I have everything I need now to start the mailing! (Formatting floppy disks and copying data is by far the slowest part of the operation. Thank goodness my drives are holding up for the task.)

Each Collector’s Edition will have all contents inside the game box, and will also be shrink-wrapped for added protection. I purchased custom mailers from ULine that fit the box perfectly as well. I’ll be taping them up thoroughly, especially for international shipping. Customs forms will identify it as “merchandise” worth $20 U.S. to avoid high duty fees and delay. Everyone will get emailed a tracking # for it as well. I’ll start on them this week and try and get them all out by the end of the week.

As for what’s next for the blog?

Well, my next TI project at some point! I plan to do a few small-scale ones that I’ve had on my mind. I wanted to do a true assembly version of an old BASIC program I wrote “Aperture”, just to learn the ins and outs of doing a platformer. I also every year around Christmas get a bug to write a game with shopping and having to pick up gifts in a department store and navigate around rude senseless people.

My next big project will be my Gauntlet clone, which will require the SAMS card. I have some particular technical limitations and challenges I have to make sure are achievable with it. I also have a Roguelike on the brain… Something that’s a mix of Rogue, NetHack, Warriors of Ras, and similar.

I may also take some time on the blog detailing the actual coding and design work that makes up Realms of Antiquity. My blog over the years has a lot of details on it, but a linear step-by-step set of posts of “How was it made?” and “Why this and not this?” may be educational for some.

Happy gaming to all! And be sure to check out Nox Archaist, another retro CRPG for the Apple II!

Posted in Blog, CRPG, TI-99/4a, Video | 3 Comments

Release!

Well I didn’t quite make Christmas… But I did get it done in 2020!

Realms of Antiquity

Realms of Antiquity: The Shattered Crown is now released! Digital edition is available immediately, collector’s editions are in pre-order and will ship late January/early February.

I’ve put together a website for it here, you’ll find links to the store to purchase it on the product page:

http://quixotic.adamantyr.com/

I’ve created a topic on AtariAge as well, as an additional resource for questions and information.

Excelsior! Time to see how long before I have to release a new build…

Posted in CRPG, TI-99/4a | 15 Comments

All I Want for Christmas

Wow… It’s amazing to be here. On the cusp of release! My plan is to do so next month, in time for the holidays. 😀

I’m currently working on the “release candidate” code, which is me playing a game all the way through myself, and fixing stuff on the way. I’ve found enough substantial changes to make it worth the time and trouble!

A change I recently made was to “pad out” transaction scripts and mob files to a near 2-bit value. This gives me a little buffer space at the end of each transaction for changes later after release that won’t alter the address location in the disk file. Without that, any minor change would require a player to start the game over from scratch, something I’d like to avoid.

The game will be sold through a fellow 99’er and a good friend’s website at ArcadeShopper. He sells a lot of great retro equipment and software for a variety of platforms, and hey, anything I can do to pay back a bit to the community is great!

My… precious…

As part of release, I’ve also been working on the tangibles. The game will have a full digital release, of course, but you can’t have a classic CRPG without a collector’s edition!

I’ve had a game box custom-created by BoardGamesMaker, which is large enough to fit all the Collector’s Edition contents. They do excellent work, albeit with a bit of lag time. The unit cost is VERY high though, and so I probably will have to have boxes printed in small numbers, even though I’d save money with bulk.

The manuals I originally had printed by Lulu, but I decided I wanted to get a slightly better one printed locally at a print shop I’ve done business with before. They did an excellent job with both the manuals and reference cards! Sadly, I decided this after I’d ordered a batch of 50 from Lulu, so I guess I’ll have spares to sell…

The cloth map wasn’t something I’d sure I’d even be able to do, until a good friend and fellow retro CRPG developer suggested Spoonflower. I was able to print 9 maps on a yard of fabric for a relatively low cost. I then engaged a professional seamstress with years of experience (Thanks mom!) to help me baste and hem the edges.

It would come as no surprise to any retro-enthusiast that there are many who want the game on ACTUAL old-school media, namely cartridge and floppy disk. Of course, this presents some challenges…

The cartridge is the game’s executable loaded onto a cartridge for faster loading. This also removes the need for any of the other requisite cartridges to run the game. A fellow 99’er has offered me a good bulk rate deal on assembled boards with EPROMS, and I have several dozen old TI carts I can recycle the case for. However, the game loads just fine from disk as well, and the cartridge ROM can be put on an SD card for a modern-cartridge peripheral called FinalGROM. So at some point I’ll probably say “No more carts.” I had cartridge labels printed up in two styles at StickerGiant.

Floppy disks are interesting… They are no longer manufactured, and aren’t something you can 3D print. So working disks can be a bit of a pain to find. Plus my game is pretty big, it requires three double-sided double-density (360k) disks to store. And you can’t use high-density either, they won’t work with the older disk drives or controllers.

Fortunately I got an offer of some old user group disks from an enthusiastic supporter, and I bought some from Greg as well. And anyone who just wants labels because they have their own disks they can use I’ll provide them. (3 1/2″ disks I can’t do anyway… that particular combination for the TI is very rare.)

How many collector’s editions will there be? Unknown… I had dreamed of only selling 99 at most, but I thought that was unlikely to happen. Now, though, seeing the enthusiasm of the retro community I don’t know, it could get that high. Either way, there will be a point where I’ll say “I’m done, digital only going forward.”

Stay tuned for a link to the website in the next couple weeks!

Posted in CRPG, Design, Personal, Screenshots, TI-99/4a | 6 Comments

Inch by Inch

Well we are officially into the last third of the year, four months left in 2020 to keep my New Year’s resolution to release the game in 2020…

This post coincides with the release of beta 33. (If you’re asking what happened with 32, it was an internal release that followed 31 hastily due to a game-breaking set of bugs, and wasn’t announced.) One of the testers has successfully won the game, albeit with me providing several fixes ahead of them. So I’m feeling very confident that we are close to completion!

The changelist for 33 is huge, I made a lot of updates and fixes based upon tester feedback. Besides fixing obvious bugs or issues, a lot of it is also polishing the design. I ended up changing one spell (Terror) so it impacted all enemy units instead of just one because the spell was almost useless otherwise. In a lot of classic CRPG’s the spells tend to be more for show than actual practical use, and I want to avoid that.

Another change in 33 was a total revamp of the monster’s AI. I originally intended to keep it simple. But I found that many of the stronger “boss” creatures or opponents with spells were just so random and stupid with their use of them that battles were easy to win and kind of dull.

Some of the changes made:

  • I added a new monster trait, pounce, which allows a monster to jump right next to an opponent

  • I updated targeting to be based upon distance to unit and a “threat” level. So the character who hangs back throwing fireballs is eventually going to get targeted.

  • Some monsters are smart, and also consider how wounded characters are as part of the threat assessment.

  • For buff and healing spells, monsters consider if they or any allies need them before casting them.

  • For debuff spells, monsters consider if the target already has it. I was getting tired of the plains dragon constantly hitting the same target with its sleep breath over and over.

  • For any spells that affected locations, the monster now determines how many enemy and ally units are impacted. That way they pick the best direction or location for maximum impact and minimal friendly-fire.

I’m hopeful this will make combat a bit more interesting, since you spend a lot of time in any CRPG engaged in it. 🙂

So let’s hope 33 proves to be a success and from here on out it’s just spit and polish to the first release candidate. I am still doing some balance checks with the economy. The early game seems good but the latter game there was way too much much money and not enough things to spend it on.

That NPC looks like a switch?

That army looks like a staircase?

Terror spell works pretty well…

Posted in Beta, CRPG, Design, Screenshots, TI-99/4a, Video | 3 Comments

Summer of Testing

And here we are in July, in what is proving to be the most “interesting” year of the new century so far. And I don’t mean that in a complimentary fashion. 😛

My 45th birthday is coming up this week, and sadly I’ll have to spend it at home alone. My family (my mom’s birthday is the day before mine, my brother’s a week after mine) all live in Yakima county, which if you’ve been reading the news, has the highest rate of infection and positive cases for the entire west coast. This doesn’t surprise me in the least; the county’s population is very neanderthal conservative and pretty much ignored all the state government’s emergency mandates until just a month ago.

Even though my family is being ultra-safe, we decided it’s better I don’t come come over to visit until things improve a bit. (I’ll have to deliberately self-quarantine myself coming BACK, just as a precaution.)

And meanwhile, testing continues. And continues. And continues some more!

Beta 29.4 is nearing the end of it’s cycle and 30 will be coming shortly. One of my testers has been both enthusiastic and thorough, and it’s really helped with finding content bugs and even code bugs. I really wanted 30 to be the last beta build, but we’ll see how that goes.

The engine feels like it’s getting pretty solid now. Although… there is some signs there may be some subtle and inconsistent bugs in the code somewhere. After several hours of play, testing started to see little “glitches” on the display, and crashes when interacting with mobs. A game restart cleared up the issues. These could take awhile to hunt down, unfortunately…

One example was a bug with teleport in combat. It crashed the game, but not every time. I eventually had to use a debugger dump to figure out where it was before it went crazy, and it turned out the data table storing the address for the “teleport” routine was getting over-written by monster pathfinding algorithms, as they were next to each other in memory.

I also had to make changes to content when it came to altering maps. I have script and mob types that alter map tiles, but I had to greatly reduce their use. Why? Because they reset after you reload. This creates situations where a player may get trapped. This is something I never noticed in my own testing because I wasn’t playing a “save/reload” style a typical player would.

Both my level curve and monster stats needed adjustment as well. My main tester easily got the party to level 11 (out of 16) without even touching several areas of content, and generally found the bosses easy to defeat if they didn’t have any special attacks. I’d rather err on the side of “too easy” than “too hard” though.

One thing this whole process has made me realize is with any complex system (like a CRPG), the amount of testing is staggering. You could get away with less testing, if you have a much more simple system, but you may not end up with that great of a game.

Also, it’s important to leave your ego out of it. As a game designer and coder, you may get feedback you don’t like hearing. I wasn’t convinced that floating values for damage was necessary, and it was a pain to implement, but I did it. And I’m glad I did so now. Good testers make for a great game!

Posted in Beta, CRPG, Personal, Screenshots, TI-99/4a | 2 Comments

15 Years of Development

Title Screen
Early Title Screen

In May of 2005, I graduated from college with my Bachelor’s in Computer Science. At the time, I had started preliminary work on my CRPG, having decided that working on something original and new was better than trying to port over other games. (Which, in this case, was Chris Crawford’s Eastern Front 1941 for the Atari 8-bit systems.) My first task was to create a scrolling engine, using line of sight blocking. I wonder if every top-down CRPG starts with this?

So, with this month, it’s been 15 years. Yikes.

So it’s been an interesting couple months. I was furloughed from work for six weeks, as a cost-saving measure as the company re-oriented itself for a new and uncertain future. I’m back working now, thankfully, but I’m definitely keeping my eye on how things go.

Despite having nothing but free time, development has been slow. Stressing out about potentially needing to find new work in the middle of the worst crisis the country has experienced in over a century is not very conducive to creative thinking. I did get beta 28 out, but I still have a lot of script testing to do.

A few new features made their way into beta 29, based upon tester feedback:

  • A “return to town” effect, which will take the party back to the last place they rested. Or the starting location, if they haven’t yet. There is both a spell and an item that can do this. Some maps can’t be escaped from this way, because the game requires you to be “trapped”.
  • Floating damage indicators on the battlemap screen. The damage inflicted appears as little floating digits briefly. I pushed back on this a little, not seeing the need but one of the testers said they were so focused on the battlemap they never saw the numbers displayed below.

I still have script testing to do in several more locations, so I’m trying to buckle down and get that done. I want to make beta 29 and/or 30 the LAST beta build before a release.

After that, I have to figure out how I will distribute it. I was originally going to just put it up free for download, but I’ve been realizing that doing so would be wrong. A lot of work goes into a game like this, and to set the expectation that it should be free just because it’s on a vintage system is a bad idea.

As a look back, here’s some screen shots of the early game development to enjoy!

Statistic Bars
Early engine design, different appearance!
Screenshot #1
Early look. Not a lot of mixed colors used… Maps also had names
Screenshot #2
A lot of the basic graphics were done long ago
Screenshot #5
Dungeon walls changed, stopped trying for 3D isometric perspective
Screenshot #8
Combat was similar, but I was running out of screen space…
Posted in Beta, CRPG, Personal, RPG, Screenshots, TI-99/4a | 4 Comments